Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

scsi: storvsc: Miscellaneous code cleanups

As general cleanup and in preparation for subsequent patches:

- Use min() instead of open coding.

- Use set_host_byte() instead of open coding access to scsi_status
field.

- Collapse nested "if" statements to reduce indentation.

- Fix other indentation.

- Remove extra blank lines.

No functional changes.

[mkp: dropped status_byte() which no longer exists]

Link: https://lore.kernel.org/r/1622827263-12516-1-git-send-email-mikelley@microsoft.com
Signed-off-by: Michael Kelley <mikelley@microsoft.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Michael Kelley and committed by
Martin K. Petersen
d4674859 33c79741

+13 -26
+13 -26
drivers/scsi/storvsc_drv.c
··· 1160 1160 vstor_packet->vm_srb.srb_status = SRB_STATUS_SUCCESS; 1161 1161 } 1162 1162 1163 - 1164 1163 /* Copy over the status...etc */ 1165 1164 stor_pkt->vm_srb.scsi_status = vstor_packet->vm_srb.scsi_status; 1166 1165 stor_pkt->vm_srb.srb_status = vstor_packet->vm_srb.srb_status; 1167 1166 1168 - /* Validate sense_info_length (from Hyper-V) */ 1169 - if (vstor_packet->vm_srb.sense_info_length > sense_buffer_size) 1170 - vstor_packet->vm_srb.sense_info_length = sense_buffer_size; 1171 - 1172 - stor_pkt->vm_srb.sense_info_length = 1173 - vstor_packet->vm_srb.sense_info_length; 1167 + /* 1168 + * Copy over the sense_info_length, but limit to the known max 1169 + * size if Hyper-V returns a bad value. 1170 + */ 1171 + stor_pkt->vm_srb.sense_info_length = min_t(u8, sense_buffer_size, 1172 + vstor_packet->vm_srb.sense_info_length); 1174 1173 1175 1174 if (vstor_packet->vm_srb.scsi_status != 0 || 1176 1175 vstor_packet->vm_srb.srb_status != SRB_STATUS_SUCCESS) ··· 1179 1180 vstor_packet->vm_srb.scsi_status, 1180 1181 vstor_packet->vm_srb.srb_status); 1181 1182 1182 - if ((vstor_packet->vm_srb.scsi_status & 0xFF) == 0x02) { 1183 - /* CHECK_CONDITION */ 1184 - if (vstor_packet->vm_srb.srb_status & 1185 - SRB_STATUS_AUTOSENSE_VALID) { 1186 - /* autosense data available */ 1187 - 1188 - storvsc_log(device, STORVSC_LOGGING_WARN, 1189 - "stor pkt %p autosense data valid - len %d\n", 1190 - request, vstor_packet->vm_srb.sense_info_length); 1191 - 1192 - memcpy(request->cmd->sense_buffer, 1193 - vstor_packet->vm_srb.sense_data, 1194 - vstor_packet->vm_srb.sense_info_length); 1195 - 1196 - } 1183 + if (vstor_packet->vm_srb.scsi_status == SAM_STAT_CHECK_CONDITION && 1184 + (vstor_packet->vm_srb.srb_status & SRB_STATUS_AUTOSENSE_VALID)) 1185 + memcpy(request->cmd->sense_buffer, 1186 + vstor_packet->vm_srb.sense_data, 1187 + stor_pkt->vm_srb.sense_info_length); 1197 1188 } 1198 1189 1199 1190 stor_pkt->vm_srb.data_transfer_length = 1200 - vstor_packet->vm_srb.data_transfer_length; 1191 + vstor_packet->vm_srb.data_transfer_length; 1201 1192 1202 1193 storvsc_command_completion(request, stor_device); 1203 1194 1204 1195 if (atomic_dec_and_test(&stor_device->num_outstanding_req) && 1205 1196 stor_device->drain_notify) 1206 1197 wake_up(&stor_device->waiting_to_drain); 1207 - 1208 - 1209 1198 } 1210 1199 1211 1200 static void storvsc_on_receive(struct storvsc_device *stor_device, ··· 1662 1675 * this. So, don't send it. 1663 1676 */ 1664 1677 case SET_WINDOW: 1665 - scmnd->result = DID_ERROR << 16; 1678 + set_host_byte(scmnd, DID_ERROR); 1666 1679 allowed = false; 1667 1680 break; 1668 1681 default: