Skip to content

Commit 7951952

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: core: Improve type safety of scsi_rescan_device()
Most callers of scsi_rescan_device() have the scsi_device pointer readily available. Pass a struct scsi_device pointer to scsi_rescan_device() instead of a struct device pointer. This change prevents that a pointer to another struct device would be passed accidentally to scsi_rescan_device(). Remove the scsi_rescan_device() declaration from the scsi_priv.h header file since it duplicates the declaration in <scsi/scsi_host.h>. Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: John Garry <[email protected]> Cc: Mike Christie <[email protected]> Cc: Ming Lei <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent e1a87e2 commit 7951952

File tree

11 files changed

+12
-13
lines changed

11 files changed

+12
-13
lines changed

drivers/ata/libata-scsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4884,7 +4884,7 @@ void ata_scsi_dev_rescan(struct work_struct *work)
48844884
}
48854885

48864886
spin_unlock_irqrestore(ap->lock, flags);
4887-
scsi_rescan_device(&(sdev->sdev_gendev));
4887+
scsi_rescan_device(sdev);
48884888
scsi_device_put(sdev);
48894889
spin_lock_irqsave(ap->lock, flags);
48904890
}

drivers/scsi/aacraid/commsup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ static void aac_handle_aif(struct aac_dev * dev, struct fib * fibptr)
14511451
#endif
14521452
break;
14531453
}
1454-
scsi_rescan_device(&device->sdev_gendev);
1454+
scsi_rescan_device(device);
14551455
break;
14561456

14571457
default:

drivers/scsi/mvumi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ static void mvumi_rescan_devices(struct mvumi_hba *mhba, int id)
15001500

15011501
sdev = scsi_device_lookup(mhba->shost, 0, id, 0);
15021502
if (sdev) {
1503-
scsi_rescan_device(&sdev->sdev_gendev);
1503+
scsi_rescan_device(sdev);
15041504
scsi_device_put(sdev);
15051505
}
15061506
}

drivers/scsi/scsi_lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2458,7 +2458,7 @@ static void scsi_evt_emit(struct scsi_device *sdev, struct scsi_event *evt)
24582458
envp[idx++] = "SDEV_MEDIA_CHANGE=1";
24592459
break;
24602460
case SDEV_EVT_INQUIRY_CHANGE_REPORTED:
2461-
scsi_rescan_device(&sdev->sdev_gendev);
2461+
scsi_rescan_device(sdev);
24622462
envp[idx++] = "SDEV_UA=INQUIRY_DATA_HAS_CHANGED";
24632463
break;
24642464
case SDEV_EVT_CAPACITY_CHANGE_REPORTED:

drivers/scsi/scsi_priv.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ extern int scsi_complete_async_scans(void);
137137
extern int scsi_scan_host_selected(struct Scsi_Host *, unsigned int,
138138
unsigned int, u64, enum scsi_scan_mode);
139139
extern void scsi_forget_host(struct Scsi_Host *);
140-
extern void scsi_rescan_device(struct device *);
141140

142141
/* scsi_sysctl.c */
143142
#ifdef CONFIG_SYSCTL

drivers/scsi/scsi_scan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,9 +1619,9 @@ int scsi_add_device(struct Scsi_Host *host, uint channel,
16191619
}
16201620
EXPORT_SYMBOL(scsi_add_device);
16211621

1622-
void scsi_rescan_device(struct device *dev)
1622+
void scsi_rescan_device(struct scsi_device *sdev)
16231623
{
1624-
struct scsi_device *sdev = to_scsi_device(dev);
1624+
struct device *dev = &sdev->sdev_gendev;
16251625

16261626
device_lock(dev);
16271627

drivers/scsi/scsi_sysfs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ static ssize_t
747747
store_rescan_field (struct device *dev, struct device_attribute *attr,
748748
const char *buf, size_t count)
749749
{
750-
scsi_rescan_device(dev);
750+
scsi_rescan_device(to_scsi_device(dev));
751751
return count;
752752
}
753753
static DEVICE_ATTR(rescan, S_IWUSR, NULL, store_rescan_field);
@@ -840,7 +840,7 @@ store_state_field(struct device *dev, struct device_attribute *attr,
840840
* waiting for pending I/O to finish.
841841
*/
842842
blk_mq_run_hw_queues(sdev->request_queue, true);
843-
scsi_rescan_device(dev);
843+
scsi_rescan_device(sdev);
844844
}
845845

846846
return ret == 0 ? count : -EINVAL;

drivers/scsi/smartpqi/smartpqi_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,7 @@ static void pqi_update_device_list(struct pqi_ctrl_info *ctrl_info,
22572257
device->advertised_queue_depth = device->queue_depth;
22582258
scsi_change_queue_depth(device->sdev, device->advertised_queue_depth);
22592259
if (device->rescan) {
2260-
scsi_rescan_device(&device->sdev->sdev_gendev);
2260+
scsi_rescan_device(device->sdev);
22612261
device->rescan = false;
22622262
}
22632263
}

drivers/scsi/storvsc_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ static void storvsc_device_scan(struct work_struct *work)
470470
sdev = scsi_device_lookup(wrk->host, 0, wrk->tgt_id, wrk->lun);
471471
if (!sdev)
472472
goto done;
473-
scsi_rescan_device(&sdev->sdev_gendev);
473+
scsi_rescan_device(sdev);
474474
scsi_device_put(sdev);
475475

476476
done:

drivers/scsi/virtio_scsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ static void virtscsi_handle_param_change(struct virtio_scsi *vscsi,
325325
/* Handle "Parameters changed", "Mode parameters changed", and
326326
"Capacity data has changed". */
327327
if (asc == 0x2a && (ascq == 0x00 || ascq == 0x01 || ascq == 0x09))
328-
scsi_rescan_device(&sdev->sdev_gendev);
328+
scsi_rescan_device(sdev);
329329

330330
scsi_device_put(sdev);
331331
}

include/scsi/scsi_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ scsi_template_proc_dir(const struct scsi_host_template *sht);
764764
#define scsi_template_proc_dir(sht) NULL
765765
#endif
766766
extern void scsi_scan_host(struct Scsi_Host *);
767-
extern void scsi_rescan_device(struct device *);
767+
extern void scsi_rescan_device(struct scsi_device *);
768768
extern void scsi_remove_host(struct Scsi_Host *);
769769
extern struct Scsi_Host *scsi_host_get(struct Scsi_Host *);
770770
extern int scsi_host_busy(struct Scsi_Host *shost);

0 commit comments

Comments
 (0)