From 2a8f7a0344c8b068cf4b13f1bf4bdd65b8787d04 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Wed, 20 Sep 2017 09:18:51 +0200 Subject: scsi: scsi_dh: Return SCSI_DH_XX error code from ->attach() Rather than having each device handler implementing their own error mapping, have the ->attach() call return a SCSI_DH_XXX error code and implement the mapping in scsi_dh_handler_attach(). Suggested-by: Christoph Hellwig Signed-off-by: Hannes Reinecke Reviewed-by: Johannes Thumshirn Signed-off-by: Martin K. Petersen --- drivers/scsi/device_handler/scsi_dh_alua.c | 10 ++++------ drivers/scsi/device_handler/scsi_dh_emc.c | 6 +++--- drivers/scsi/device_handler/scsi_dh_hp_sw.c | 12 ++++++++---- drivers/scsi/device_handler/scsi_dh_rdac.c | 6 +++--- 4 files changed, 18 insertions(+), 16 deletions(-) (limited to 'drivers/scsi/device_handler') diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c index 0962fd544401..fd22dc6ab5d9 100644 --- a/drivers/scsi/device_handler/scsi_dh_alua.c +++ b/drivers/scsi/device_handler/scsi_dh_alua.c @@ -1085,11 +1085,11 @@ static void alua_rescan(struct scsi_device *sdev) static int alua_bus_attach(struct scsi_device *sdev) { struct alua_dh_data *h; - int err, ret = -EINVAL; + int err; h = kzalloc(sizeof(*h) , GFP_KERNEL); if (!h) - return -ENOMEM; + return SCSI_DH_NOMEM; spin_lock_init(&h->pg_lock); rcu_assign_pointer(h->pg, NULL); h->init_error = SCSI_DH_OK; @@ -1098,16 +1098,14 @@ static int alua_bus_attach(struct scsi_device *sdev) mutex_init(&h->init_mutex); err = alua_initialize(sdev, h); - if (err == SCSI_DH_NOMEM) - ret = -ENOMEM; if (err != SCSI_DH_OK && err != SCSI_DH_DEV_OFFLINED) goto failed; sdev->handler_data = h; - return 0; + return SCSI_DH_OK; failed: kfree(h); - return ret; + return err; } /* diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c index 8654e940e1a8..6a2792f3a37e 100644 --- a/drivers/scsi/device_handler/scsi_dh_emc.c +++ b/drivers/scsi/device_handler/scsi_dh_emc.c @@ -490,7 +490,7 @@ static int clariion_bus_attach(struct scsi_device *sdev) h = kzalloc(sizeof(*h) , GFP_KERNEL); if (!h) - return -ENOMEM; + return SCSI_DH_NOMEM; h->lun_state = CLARIION_LUN_UNINITIALIZED; h->default_sp = CLARIION_UNBOUND_LU; h->current_sp = CLARIION_UNBOUND_LU; @@ -510,11 +510,11 @@ static int clariion_bus_attach(struct scsi_device *sdev) h->default_sp + 'A'); sdev->handler_data = h; - return 0; + return SCSI_DH_OK; failed: kfree(h); - return -EINVAL; + return err; } static void clariion_bus_detach(struct scsi_device *sdev) diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c index 62d314e07d11..e65a0ebb4b54 100644 --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c @@ -218,24 +218,28 @@ static int hp_sw_bus_attach(struct scsi_device *sdev) h = kzalloc(sizeof(*h), GFP_KERNEL); if (!h) - return -ENOMEM; + return SCSI_DH_NOMEM; h->path_state = HP_SW_PATH_UNINITIALIZED; h->retries = HP_SW_RETRIES; h->sdev = sdev; ret = hp_sw_tur(sdev, h); - if (ret != SCSI_DH_OK || h->path_state == HP_SW_PATH_UNINITIALIZED) + if (ret != SCSI_DH_OK) goto failed; + if (h->path_state == HP_SW_PATH_UNINITIALIZED) { + ret = SCSI_DH_NOSYS; + goto failed; + } sdev_printk(KERN_INFO, sdev, "%s: attached to %s path\n", HP_SW_NAME, h->path_state == HP_SW_PATH_ACTIVE? "active":"passive"); sdev->handler_data = h; - return 0; + return SCSI_DH_OK; failed: kfree(h); - return -EINVAL; + return ret; } static void hp_sw_bus_detach( struct scsi_device *sdev ) diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index 2ceff585f189..7af31a1247ee 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -729,7 +729,7 @@ static int rdac_bus_attach(struct scsi_device *sdev) h = kzalloc(sizeof(*h) , GFP_KERNEL); if (!h) - return -ENOMEM; + return SCSI_DH_NOMEM; h->lun = UNINITIALIZED_LUN; h->state = RDAC_STATE_ACTIVE; @@ -755,7 +755,7 @@ static int rdac_bus_attach(struct scsi_device *sdev) lun_state[(int)h->lun_state]); sdev->handler_data = h; - return 0; + return SCSI_DH_OK; clean_ctlr: spin_lock(&list_lock); @@ -764,7 +764,7 @@ clean_ctlr: failed: kfree(h); - return -EINVAL; + return err; } static void rdac_bus_detach( struct scsi_device *sdev ) -- cgit v1.2.3