Skip to contentSkip to conversation

USB: storage: Notify the subdrivers that they need to reinitialize the device.

PATCH In review Mikhail Zaytsev 2 participants 6 messages Nov 29, 2017 – Nov 30, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: storage: Notify the subdrivers that they need to reinitialize the device.

This patch adds the device_reinit function into the us_data structure. The usb-storage driver uses this function for notify the subdrivers that
they need to reinitialize the device.

---
 drivers/usb/storage/usb.c | 16 ++++++++--------
 drivers/usb/storage/usb.h |  8 +++++---
 2 files changed, 13 insertions(+), 11 deletions(-)
drivers/usb/storage/usb.c +8 -8
index a0c07e05a8f1..60c47b2e877d 100644
@@ -210,10 +210,10 @@ int usb_stor_reset_resume(struct usb_interface *iface)
        /* Report the reset to the SCSI core */
        usb_stor_report_bus_reset(us);
 
-	/*
-	 * FIXME: Notify the subdrivers that they need to reinitialize
-	 * the device
-	 */
+	if (us->device_reinit) {
+		usb_stor_dbg(us, "-- calling device_reinit()\n");
+		us->device_reinit(us);
+	}
        return 0;
 }
 EXPORT_SYMBOL_GPL(usb_stor_reset_resume);
@@ -242,10 +242,10 @@ int usb_stor_post_reset(struct usb_interface *iface)
        /* Report the reset to the SCSI core */
        usb_stor_report_bus_reset(us);
 
-	/*
-	 * FIXME: Notify the subdrivers that they need to reinitialize
-	 * the device
-	 */
+	if (us->device_reinit) {
+		usb_stor_dbg(us, "-- calling device_reinit()\n");
+		us->device_reinit(us);
+	}
 
        mutex_unlock(&us->dev_mutex);
        return 0;
drivers/usb/storage/usb.h +5 -3
index 90133e16bec5..c646a0464a51 100644
@@ -77,9 +77,10 @@ struct us_unusual_dev {
 #define US_IOBUF_SIZE		64	/* Size of the DMA-mapped I/O buffer */
 #define US_SENSE_SIZE		18	/* Size of the autosense data buffer */
 
-typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*);
-typedef int (*trans_reset)(struct us_data*);
-typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*);
+typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data *);
+typedef int (*trans_reset)(struct us_data *);
+typedef int (*dev_reinit)(struct us_data *);
+typedef void (*proto_cmnd)(struct scsi_cmnd *, struct us_data *);
 typedef void (*extra_data_destructor)(void *);	/* extra data destructor */
 typedef void (*pm_hook)(struct us_data *, int);	/* power management hook */
 
@@ -119,6 +120,7 @@ struct us_data {
        /* function pointers for this device */
        trans_cmnd		transport;	 /* transport function	   */
        trans_reset		transport_reset; /* transport device reset */
+	dev_reinit		device_reinit;   /* device reinitialize	   */
        proto_cmnd		proto_handler;	 /* protocol handler	   */
 
        /* SCSI interfaces */

--

maintainer
#1 lore raw
Quoted 5 lines · Mikhail Zaytsev

This patch adds the device_reinit function into the us_data structure. The usb-storage driver uses this function for notify the subdrivers that
they need to reinitialize the device.

I'd feel more inclined to accept this patch if the new code got used somewhere. As it is, it fixes a "problem" that doesn't actually have any real effect.

Alan Stern

Quoted 68 lines
---
 drivers/usb/storage/usb.c | 16 ++++++++--------
 drivers/usb/storage/usb.h |  8 +++++---
 2 files changed, 13 insertions(+), 11 deletions(-)
drivers/usb/storage/usb.c +8 -8
index a0c07e05a8f1..60c47b2e877d 100644
@@ -210,10 +210,10 @@ int usb_stor_reset_resume(struct usb_interface *iface)
        /* Report the reset to the SCSI core */
        usb_stor_report_bus_reset(us);
 
-	/*
-	 * FIXME: Notify the subdrivers that they need to reinitialize
-	 * the device
-	 */
+	if (us->device_reinit) {
+		usb_stor_dbg(us, "-- calling device_reinit()\n");
+		us->device_reinit(us);
+	}
        return 0;
 }
 EXPORT_SYMBOL_GPL(usb_stor_reset_resume);
@@ -242,10 +242,10 @@ int usb_stor_post_reset(struct usb_interface *iface)
        /* Report the reset to the SCSI core */
        usb_stor_report_bus_reset(us);
 
-	/*
-	 * FIXME: Notify the subdrivers that they need to reinitialize
-	 * the device
-	 */
+	if (us->device_reinit) {
+		usb_stor_dbg(us, "-- calling device_reinit()\n");
+		us->device_reinit(us);
+	}
 
        mutex_unlock(&us->dev_mutex);
        return 0;
drivers/usb/storage/usb.h +5 -4
index 90133e16bec5..c646a0464a51 100644
@@ -77,9 +77,10 @@ struct us_unusual_dev {
 #define US_IOBUF_SIZE		64	/* Size of the DMA-mapped I/O buffer */
 #define US_SENSE_SIZE		18	/* Size of the autosense data buffer */
 
-typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data*);
-typedef int (*trans_reset)(struct us_data*);
-typedef void (*proto_cmnd)(struct scsi_cmnd*, struct us_data*);
+typedef int (*trans_cmnd)(struct scsi_cmnd *, struct us_data *);
+typedef int (*trans_reset)(struct us_data *);
+typedef int (*dev_reinit)(struct us_data *);
+typedef void (*proto_cmnd)(struct scsi_cmnd *, struct us_data *);
 typedef void (*extra_data_destructor)(void *);	/* extra data destructor */
 typedef void (*pm_hook)(struct us_data *, int);	/* power management hook */
 
@@ -119,6 +120,7 @@ struct us_data {
        /* function pointers for this device */
        trans_cmnd		transport;	 /* transport function	   */
        trans_reset		transport_reset; /* transport device reset */
+	dev_reinit		device_reinit;   /* device reinitialize	   */
        proto_cmnd		proto_handler;	 /* protocol handler	   */
 
        /* SCSI interfaces */
--
#2 lore raw
Quoted 6 lines · On Wed, 29 Nov 2017 Alan Stern <[email protected]> wrote:
Quoted 4 lines · Mikhail Zaytsev

This patch adds the device_reinit function into the us_data structure. The usb-storage driver uses this function for notify the subdrivers that they need to reinitialize the device.

Quoted 7 lines
Quoted 1 line

I'd feel more inclined to accept this patch if the new code got used somewhere. As it is, it fixes a "problem" that doesn't actually have any real effect.

Alan Stern

I propose to delete this FIXME comments without any code changes.

Regards, Mikhail

maintainer
#3 lore raw
Quoted 10 lines · Mikhail Zaytsev
Quoted 8 lines · On Wed, 29 Nov 2017 Alan Stern <[email protected]> wrote:
Quoted 5 lines · Mikhail Zaytsev

This patch adds the device_reinit function into the us_data structure. The usb-storage driver uses this function for notify the subdrivers that they need to reinitialize the device.

Quoted 7 lines
Quoted 5 lines

I'd feel more inclined to accept this patch if the new code got used somewhere. As it is, it fixes a "problem" that doesn't actually have any real effect.

Alan Stern

I propose to delete this FIXME comments without any code changes.

Okay. You could leave a comment saying that if any of the subdrivers implemented a reinitialization scheme, this is where the callback would be invoked.

Alan Stern

#4 lore raw

PATCH 1/1 USB: storage: Remove obsolete "FIXME"

The fix of "FIXME: Notify the subdrivers..." doesn't actually have any
real effect. The "FIXME" changed to simple comment.

---
 drivers/usb/storage/usb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/storage/usb.c +4 -4
index a0c07e0..3eb9347 100644
@@ -211,8 +211,8 @@ int usb_stor_reset_resume(struct usb_interface *iface)
 	usb_stor_report_bus_reset(us);
 
 	/*
-	 * FIXME: Notify the subdrivers that they need to reinitialize
-	 * the device
+	 * If any of the subdrivers implemented a reinitialization scheme,
+	 * this is where the callback would be invoked.
 	 */
 	return 0;
 }
@@ -243,8 +243,8 @@ int usb_stor_post_reset(struct usb_interface *iface)
 	usb_stor_report_bus_reset(us);
 
 	/*
-	 * FIXME: Notify the subdrivers that they need to reinitialize
-	 * the device
+	 * If any of the subdrivers implemented a reinitialization scheme,
+	 * this is where the callback would be invoked.
 	 */
 
 	mutex_unlock(&us->dev_mutex);
Signature · 1 line
2.1.4
maintainer Acked-by on v1 1/1
#5 lore raw

Re: [PATCH v1] USB: storage: Remove obsolete "FIXME"

Quoted 24 lines · Mikhail Zaytsev

The fix of "FIXME: Notify the subdrivers..." doesn't actually have any
real effect. The "FIXME" changed to simple comment.

---
 drivers/usb/storage/usb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/storage/usb.c +2 -2
index a0c07e0..3eb9347 100644
@@ -211,8 +211,8 @@ int usb_stor_reset_resume(struct usb_interface *iface)
 	usb_stor_report_bus_reset(us);
 
 	/*
-	 * FIXME: Notify the subdrivers that they need to reinitialize
-	 * the device
+	 * If any of the subdrivers implemented a reinitialization scheme,
+	 * this is where the callback would be invoked.
 	 */
 	return 0;
 }

drivers/usb/storage/usb.c int usb_stor_post_reset(struct usb_interface *iface) · line 250

Quoted 10 lines
drivers/usb/storage/usb.c +2 -2
@@ -243,8 +243,8 @@ int usb_stor_post_reset(struct usb_interface *iface)
 	usb_stor_report_bus_reset(us);
 
 	/*
-	 * FIXME: Notify the subdrivers that they need to reinitialize
-	 * the device
+	 * If any of the subdrivers implemented a reinitialization scheme,
+	 * this is where the callback would be invoked.
 	 */
 
 	mutex_unlock(&us->dev_mutex);