aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-02-14 14:15:57 -0500
committerMartin K. Petersen <martin.petersen@oracle.com>2017-02-22 19:35:24 -0500
commit74a78ebda4fa5c5ae87fc501152863ee31c17da4 (patch)
treec014cfa9f47dae80e4e2dbb3d7557a3fdb000ac0
parent6fa2b8f9e3ae8dd770d8fa264825f86b146381c8 (diff)
scsi: make the sense header argument to scsi_test_unit_ready mandatory
It's a tiny structure that can be allocated on the stack, don't complicate the code by making it optional. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/osd/osd_uld.c3
-rw-r--r--drivers/scsi/scsi_ioctl.c3
-rw-r--r--drivers/scsi/scsi_lib.c14
3 files changed, 6 insertions, 14 deletions
diff --git a/drivers/scsi/osd/osd_uld.c b/drivers/scsi/osd/osd_uld.c
index 243eab3d10d0..e0ce5d2fd14d 100644
--- a/drivers/scsi/osd/osd_uld.c
+++ b/drivers/scsi/osd/osd_uld.c
@@ -372,6 +372,7 @@ EXPORT_SYMBOL(osduld_device_same);
372static int __detect_osd(struct osd_uld_device *oud) 372static int __detect_osd(struct osd_uld_device *oud)
373{ 373{
374 struct scsi_device *scsi_device = oud->od.scsi_device; 374 struct scsi_device *scsi_device = oud->od.scsi_device;
375 struct scsi_sense_hdr sense_hdr;
375 char caps[OSD_CAP_LEN]; 376 char caps[OSD_CAP_LEN];
376 int error; 377 int error;
377 378
@@ -380,7 +381,7 @@ static int __detect_osd(struct osd_uld_device *oud)
380 */ 381 */
381 OSD_DEBUG("start scsi_test_unit_ready %p %p %p\n", 382 OSD_DEBUG("start scsi_test_unit_ready %p %p %p\n",
382 oud, scsi_device, scsi_device->request_queue); 383 oud, scsi_device, scsi_device->request_queue);
383 error = scsi_test_unit_ready(scsi_device, 10*HZ, 5, NULL); 384 error = scsi_test_unit_ready(scsi_device, 10*HZ, 5, &sense_hdr);
384 if (error) 385 if (error)
385 OSD_ERR("warning: scsi_test_unit_ready failed\n"); 386 OSD_ERR("warning: scsi_test_unit_ready failed\n");
386 387
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index 8b8c814df5c7..b6bf3f29a12a 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -199,6 +199,7 @@ static int scsi_ioctl_get_pci(struct scsi_device *sdev, void __user *arg)
199int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg) 199int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
200{ 200{
201 char scsi_cmd[MAX_COMMAND_SIZE]; 201 char scsi_cmd[MAX_COMMAND_SIZE];
202 struct scsi_sense_hdr sense_hdr;
202 203
203 /* Check for deprecated ioctls ... all the ioctls which don't 204 /* Check for deprecated ioctls ... all the ioctls which don't
204 * follow the new unique numbering scheme are deprecated */ 205 * follow the new unique numbering scheme are deprecated */
@@ -243,7 +244,7 @@ int scsi_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
243 return scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW); 244 return scsi_set_medium_removal(sdev, SCSI_REMOVAL_ALLOW);
244 case SCSI_IOCTL_TEST_UNIT_READY: 245 case SCSI_IOCTL_TEST_UNIT_READY:
245 return scsi_test_unit_ready(sdev, IOCTL_NORMAL_TIMEOUT, 246 return scsi_test_unit_ready(sdev, IOCTL_NORMAL_TIMEOUT,
246 NORMAL_RETRIES, NULL); 247 NORMAL_RETRIES, &sense_hdr);
247 case SCSI_IOCTL_START_UNIT: 248 case SCSI_IOCTL_START_UNIT:
248 scsi_cmd[0] = START_STOP; 249 scsi_cmd[0] = START_STOP;
249 scsi_cmd[1] = 0; 250 scsi_cmd[1] = 0;
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 39b2d727f033..a3c7ec1795c9 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2520,28 +2520,20 @@ EXPORT_SYMBOL(scsi_mode_sense);
2520 * @sdev: scsi device to change the state of. 2520 * @sdev: scsi device to change the state of.
2521 * @timeout: command timeout 2521 * @timeout: command timeout
2522 * @retries: number of retries before failing 2522 * @retries: number of retries before failing
2523 * @sshdr_external: Optional pointer to struct scsi_sense_hdr for 2523 * @sshdr: outpout pointer for decoded sense information.
2524 * returning sense. Make sure that this is cleared before passing
2525 * in.
2526 * 2524 *
2527 * Returns zero if unsuccessful or an error if TUR failed. For 2525 * Returns zero if unsuccessful or an error if TUR failed. For
2528 * removable media, UNIT_ATTENTION sets ->changed flag. 2526 * removable media, UNIT_ATTENTION sets ->changed flag.
2529 **/ 2527 **/
2530int 2528int
2531scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries, 2529scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
2532 struct scsi_sense_hdr *sshdr_external) 2530 struct scsi_sense_hdr *sshdr)
2533{ 2531{
2534 char cmd[] = { 2532 char cmd[] = {
2535 TEST_UNIT_READY, 0, 0, 0, 0, 0, 2533 TEST_UNIT_READY, 0, 0, 0, 0, 0,
2536 }; 2534 };
2537 struct scsi_sense_hdr *sshdr;
2538 int result; 2535 int result;
2539 2536
2540 if (!sshdr_external)
2541 sshdr = kzalloc(sizeof(*sshdr), GFP_KERNEL);
2542 else
2543 sshdr = sshdr_external;
2544
2545 /* try to eat the UNIT_ATTENTION if there are enough retries */ 2537 /* try to eat the UNIT_ATTENTION if there are enough retries */
2546 do { 2538 do {
2547 result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr, 2539 result = scsi_execute_req(sdev, cmd, DMA_NONE, NULL, 0, sshdr,
@@ -2552,8 +2544,6 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries,
2552 } while (scsi_sense_valid(sshdr) && 2544 } while (scsi_sense_valid(sshdr) &&
2553 sshdr->sense_key == UNIT_ATTENTION && --retries); 2545 sshdr->sense_key == UNIT_ATTENTION && --retries);
2554 2546
2555 if (!sshdr_external)
2556 kfree(sshdr);
2557 return result; 2547 return result;
2558} 2548}
2559EXPORT_SYMBOL(scsi_test_unit_ready); 2549EXPORT_SYMBOL(scsi_test_unit_ready);