diff options
author | Hannes Reinecke <hare@suse.de> | 2017-09-20 09:18:51 +0200 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2017-09-25 19:03:14 -0400 |
commit | 2a8f7a0344c8b068cf4b13f1bf4bdd65b8787d04 (patch) | |
tree | f47c8b4be2bf668a3eece994a654d6a4b8e36a25 /drivers/scsi/scsi_dh.c | |
parent | b7af62a945706e32b987f1dd0cc86bb41a8210c3 (diff) | |
download | linux-stable-2a8f7a0344c8b068cf4b13f1bf4bdd65b8787d04.tar.gz linux-stable-2a8f7a0344c8b068cf4b13f1bf4bdd65b8787d04.tar.bz2 linux-stable-2a8f7a0344c8b068cf4b13f1bf4bdd65b8787d04.zip |
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 <hch@lst.de>
Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/scsi_dh.c')
-rw-r--r-- | drivers/scsi/scsi_dh.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c index 84addee05be6..ac798d284a7e 100644 --- a/drivers/scsi/scsi_dh.c +++ b/drivers/scsi/scsi_dh.c @@ -126,20 +126,31 @@ static struct scsi_device_handler *scsi_dh_lookup(const char *name) static int scsi_dh_handler_attach(struct scsi_device *sdev, struct scsi_device_handler *scsi_dh) { - int error; + int error, ret = 0; if (!try_module_get(scsi_dh->module)) return -EINVAL; error = scsi_dh->attach(sdev); - if (error) { + if (error != SCSI_DH_OK) { + switch (error) { + case SCSI_DH_NOMEM: + ret = -ENOMEM; + break; + case SCSI_DH_RES_TEMP_UNAVAIL: + ret = -EAGAIN; + break; + default: + ret = -EINVAL; + break; + } sdev_printk(KERN_ERR, sdev, "%s: Attach failed (%d)\n", scsi_dh->name, error); module_put(scsi_dh->module); } else sdev->handler = scsi_dh; - return error; + return ret; } /* |