From: Ondrej Zary Date: Mon, 5 Dec 2016 06:07:19 +0000 (-0500) Subject: scsi: g_NCR5380: Check for chip presence before calling NCR5380_init() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=89fa9b5cb08c9d8ad709415b88395be463eceeee;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git scsi: g_NCR5380: Check for chip presence before calling NCR5380_init() Write and read back mode register to check that a chip is really there. If no card is present, reads result in 0xff. Signed-off-by: Ondrej Zary Signed-off-by: Finn Thain Tested-by: Ondrej Zary Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/g_NCR5380.c b/drivers/scsi/g_NCR5380.c index de5147a8c959..76e37455480e 100644 --- a/drivers/scsi/g_NCR5380.c +++ b/drivers/scsi/g_NCR5380.c @@ -248,6 +248,13 @@ static int generic_NCR5380_init_one(struct scsi_host_template *tpnt, } } + /* Check for vacant slot */ + NCR5380_write(MODE_REG, 0); + if (NCR5380_read(MODE_REG) != 0) { + ret = -ENODEV; + goto out_unregister; + } + ret = NCR5380_init(instance, flags | FLAG_LATE_DMA_SETUP); if (ret) goto out_unregister;