Skip to content

Commit 519bfc1

Browse files
johnpgarrymartinkpetersen
authored andcommitted
scsi: scsi_debug: Drop scsi_debug_bus_reset() NULL pointer checks
The checks for SCSI cmnd, SCSI device, and SCSI host are unnecessary, so drop them. Likewise, drop the NULL check for sdbg_host. The only caller is scsi_try_bus_reset() -> eh_bus_reset_handler(), and there those pointers cannot be NULL. Signed-off-by: John Garry <john.g.garry@oracle.com> Acked-by: Douglas Gilbert <dgilbert@interlog.com> Link: https://lore.kernel.org/r/20230313093114.1498305-7-john.g.garry@oracle.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent a15df53 commit 519bfc1

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

drivers/scsi/scsi_debug.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5412,34 +5412,24 @@ static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt)
54125412

54135413
static int scsi_debug_bus_reset(struct scsi_cmnd *SCpnt)
54145414
{
5415-
struct sdebug_host_info *sdbg_host;
5415+
struct scsi_device *sdp = SCpnt->device;
5416+
struct sdebug_host_info *sdbg_host = shost_to_sdebug_host(sdp->host);
54165417
struct sdebug_dev_info *devip;
5417-
struct scsi_device *sdp;
5418-
struct Scsi_Host *hp;
54195418
int k = 0;
54205419

54215420
++num_bus_resets;
5422-
if (!(SCpnt && SCpnt->device))
5423-
goto lie;
5424-
sdp = SCpnt->device;
5421+
54255422
if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
54265423
sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
5427-
hp = sdp->host;
5428-
if (hp) {
5429-
sdbg_host = shost_to_sdebug_host(hp);
5430-
if (sdbg_host) {
5431-
list_for_each_entry(devip,
5432-
&sdbg_host->dev_info_list,
5433-
dev_list) {
5434-
set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
5435-
++k;
5436-
}
5437-
}
5424+
5425+
list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) {
5426+
set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
5427+
++k;
54385428
}
5429+
54395430
if (SDEBUG_OPT_RESET_NOISE & sdebug_opts)
54405431
sdev_printk(KERN_INFO, sdp,
54415432
"%s: %d device(s) found in host\n", __func__, k);
5442-
lie:
54435433
return SUCCESS;
54445434
}
54455435

0 commit comments

Comments
 (0)