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 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'drivers/scsi/device_handler/scsi_dh_alua.c') 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; } /* -- cgit v1.2.3