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

From: Oliver Neukum
Date: Wed Feb 28 2024 - 09:48:02 EST




On 28.02.24 23:32, WeitaoWang-oc@xxxxxxxxxxx wrote:

@@ -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;

This is a generic error code from errno.h

             return SCSI_MLQUEUE_DEVICE_BUSY;

This is not.

         }
         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!

You want to change uas_submit_urbs() to return the reason for
errors, because -ENODEV needs to be handled differently. That
is good.
But why don't you just do

return err;

unconditionally? There is no point in using SCSI_MLQUEUE_DEVICE_BUSY

Regards
Oliver