scsi: g_NCR5380: Check for chip presence before calling NCR5380_init()
authorOndrej Zary <linux@rainbow-software.org>
Mon, 5 Dec 2016 06:07:19 +0000 (01:07 -0500)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 8 Dec 2016 21:56:41 +0000 (16:56 -0500)
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 <linux@rainbow-software.org>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Tested-by: Ondrej Zary <linux@rainbow-software.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/g_NCR5380.c

index de5147a..76e3745 100644 (file)
@@ -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;