[SCSI] scsi_dh_rdac: Adding the match function for rdac device handler
authorMoger, Babu <Babu.Moger@netapp.com>
Thu, 1 Dec 2011 20:01:40 +0000 (15:01 -0500)
committerJames Bottomley <JBottomley@Parallels.com>
Thu, 15 Dec 2011 06:55:00 +0000 (10:55 +0400)
This patch introduces the match function for rdac device handler. Without
this, sometimes handler attach fails during the device_add. Included check for
TPGS bit before proceeding further. The match function was introduced by
commit 6c3633d08acf514e2e89aa95d2346ce9d64d719a

Signed-off-by: Babu Moger <babu.moger@netapp.com>
Acked-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
drivers/scsi/device_handler/scsi_dh_rdac.c

index 1d31279200639074b87aa075475d1e84f77bf2eb..841ebf4a6788fc3895d5ddd31b8a67f7ce49ab55 100644 (file)
@@ -820,6 +820,24 @@ static const struct scsi_dh_devlist rdac_dev_list[] = {
        {NULL, NULL},
 };
 
+static bool rdac_match(struct scsi_device *sdev)
+{
+       int i;
+
+       if (scsi_device_tpgs(sdev))
+               return false;
+
+       for (i = 0; rdac_dev_list[i].vendor; i++) {
+               if (!strncmp(sdev->vendor, rdac_dev_list[i].vendor,
+                       strlen(rdac_dev_list[i].vendor)) &&
+                   !strncmp(sdev->model, rdac_dev_list[i].model,
+                       strlen(rdac_dev_list[i].model))) {
+                       return true;
+               }
+       }
+       return false;
+}
+
 static int rdac_bus_attach(struct scsi_device *sdev);
 static void rdac_bus_detach(struct scsi_device *sdev);
 
@@ -832,6 +850,7 @@ static struct scsi_device_handler rdac_dh = {
        .attach = rdac_bus_attach,
        .detach = rdac_bus_detach,
        .activate = rdac_activate,
+       .match = rdac_match,
 };
 
 static int rdac_bus_attach(struct scsi_device *sdev)