@@ -454,7 +454,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
sdev = container_of(work, struct scsi_device, ew.work);
- mod = sdev->host->hostt->module;
+ mod = sdev->drop_module_ref ? sdev->host->hostt->module : NULL;
scsi_dh_release_device(sdev);
@@ -525,9 +525,8 @@ static void scsi_device_dev_release(struct device *dev)
{
struct scsi_device *sdp = to_scsi_device(dev);
- /* Set module pointer as NULL in case of module unloading */
- if (!try_module_get(sdp->host->hostt->module))
- sdp->host->hostt->module = NULL;
+ if (try_module_get(sdp->host->hostt->module))
+ sdp->drop_module_ref = true;
execute_in_process_context(scsi_device_dev_release_usercontext,
&sdp->ew);
@@ -214,6 +214,7 @@ struct scsi_device {
* creation time */
unsigned ignore_media_change:1; /* Ignore MEDIA CHANGE on resume */
unsigned silence_suspend:1; /* Do not print runtime PM related messages */
+ unsigned drop_module_ref:1;
unsigned int queue_stopped; /* request queue is quiesced */
bool offline_already; /* Device offline message logged */
Instead of clearing the host template module pointer if the LLD kernel module is being unloaded, set the 'drop_module_ref' SCSI device member. This patch prepares for constifying the SCSI host template. Cc: Christoph Hellwig <hch@lst.de> Cc: Ming Lei <ming.lei@redhat.com> Cc: Hannes Reinecke <hare@suse.de> Cc: John Garry <john.garry@huawei.com> Cc: Mike Christie <michael.christie@oracle.com> Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Bart Van Assche <bvanassche@acm.org> --- drivers/scsi/scsi_sysfs.c | 7 +++---- include/scsi/scsi_device.h | 1 + 2 files changed, 4 insertions(+), 4 deletions(-)