summaryrefslogtreecommitdiff
path: root/drivers/scsi/scsi_dh.c
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2017-09-20 10:18:51 +0300
committerMartin K. Petersen <martin.petersen@oracle.com>2017-09-26 02:03:14 +0300
commit2a8f7a0344c8b068cf4b13f1bf4bdd65b8787d04 (patch)
treef47c8b4be2bf668a3eece994a654d6a4b8e36a25 /drivers/scsi/scsi_dh.c
parentb7af62a945706e32b987f1dd0cc86bb41a8210c3 (diff)
downloadlinux-2a8f7a0344c8b068cf4b13f1bf4bdd65b8787d04.tar.xz
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.c17
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;
}
/*