Re: [PATCH v2] USB:UAS:return ENODEV when submit urbs fail with device not attached.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024/2/28 16:00, Oliver Neukum wrote:

@@ -562,9 +561,9 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,

      lockdep_assert_held(&devinfo->lock);
      if (cmdinfo->state & SUBMIT_STATUS_URB) {
-             urb = uas_submit_sense_urb(cmnd, GFP_ATOMIC);
-             if (!urb)
-                     return SCSI_MLQUEUE_DEVICE_BUSY;
+             err = uas_submit_sense_urb(cmnd, GFP_ATOMIC);
+             if (err)
+                     return (err == -ENODEV) ? -ENODEV : SCSI_MLQUEUE_DEVICE_BUSY;

Either we ought to use SCSI error codes or generic error codes.
There is no need to translate all but one error condition here.


 static int uas_submit_urbs(struct scsi_cmnd *cmnd,
@@ -562,10 +561,13 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,

 	lockdep_assert_held(&devinfo->lock);
 	if (cmdinfo->state & SUBMIT_STATUS_URB) {
-		urb = uas_submit_sense_urb(cmnd, GFP_ATOMIC);
-		if (!urb)
+		err = uas_submit_sense_urb(cmnd, GFP_ATOMIC);
+		if (!err)
+			cmdinfo->state &= ~SUBMIT_STATUS_URB;
+		else if (err == -ENODEV)
+			return -ENODEV;
+		else
 			return SCSI_MLQUEUE_DEVICE_BUSY;
-		cmdinfo->state &= ~SUBMIT_STATUS_URB;
 	}

 	if (cmdinfo->state & ALLOC_DATA_IN_URB) {
@@ -582,6 +584,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
 		if (err) {
 			usb_unanchor_urb(cmdinfo->data_in_urb);
 			uas_log_cmd_state(cmnd, "data in submit err", err);
+			if (err == -ENODEV)
+				return -ENODEV;
 			return SCSI_MLQUEUE_DEVICE_BUSY;
 		}
 		cmdinfo->state &= ~SUBMIT_DATA_IN_URB;
@@ -602,6 +606,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
 		if (err) {
 			usb_unanchor_urb(cmdinfo->data_out_urb);
 			uas_log_cmd_state(cmnd, "data out submit err", err);
+			if (err == -ENODEV)
+				return -ENODEV;
 			return SCSI_MLQUEUE_DEVICE_BUSY;
 		}
 		cmdinfo->state &= ~SUBMIT_DATA_OUT_URB;
@@ -621,6 +627,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
 		if (err) {
 			usb_unanchor_urb(cmdinfo->cmd_urb);
 			uas_log_cmd_state(cmnd, "cmd submit err", err);
+			if (err == -ENODEV)
+				return -ENODEV;
 			return SCSI_MLQUEUE_DEVICE_BUSY;
 		}

I'm not sure I fully understand what your mean.
Whether the above code is more reasonable? If not,could you give me some
suggestion? Thanks for your help!

Weitao






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux