From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754005AbdK2Jrb (ORCPT ); Wed, 29 Nov 2017 04:47:31 -0500 Received: from fallback4.mail.ru ([94.100.181.169]:44548 "EHLO fallback.mail.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753397AbdK2Jr3 (ORCPT ); Wed, 29 Nov 2017 04:47:29 -0500 Date: Wed, 29 Nov 2017 12:46:46 +0300 From: Mikhail Zaytsev To: Alan Stern , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net, linux-kernel@vger.kernel.org Subject: [PATCH v1] USB: storage: Notify the subdrivers that they need to reinitialize the device. Message-ID: <20171129124646.65a3692e@zaitsev.tver.pg> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-7FA49CB5: 0D63561A33F958A52EBF4753F2105E882F2FD4A535CA15470769170AC4760B85725E5C173C3A84C355CB0F2F0488E140FD751C9D353C4AED42539A7722CA490CB5C8C57E37DE458B4C7702A67D5C3316FA3894348FB808DBEB6346B700B4D54FE5BFE6E7EFDEDCD789D4C264860C145E X-Mailru-Sender: DBE5340C3C7EDD8748A9F62D407CC5DB26F526BDBBADD0CA12198951266911BBDF580C3AF0510E413C8BDCE45491770B027D9DD7AE851095372E3D06A1D6CBE64DA9DA30EEEEBA7A0D4ABDE8C577C2ED X-Mras: OK X-Mras: OK Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Mikhail Zaytsev --- drivers/usb/storage/usb.c | 16 ++++++++-------- drivers/usb/storage/usb.h | 8 +++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index a0c07e05a8f1..60c47b2e877d 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -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; diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index 90133e16bec5..c646a0464a51 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h @@ -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 */ --