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;
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;
}
/*
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;
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)
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 )
h = kzalloc(sizeof(*h) , GFP_KERNEL);
if (!h)
- return -ENOMEM;
+ return SCSI_DH_NOMEM;
h->lun = UNINITIALIZED_LUN;
h->state = RDAC_STATE_ACTIVE;
lun_state[(int)h->lun_state]);
sdev->handler_data = h;
- return 0;
+ return SCSI_DH_OK;
clean_ctlr:
spin_lock(&list_lock);
failed:
kfree(h);
- return -EINVAL;
+ return err;
}
static void rdac_bus_detach( struct scsi_device *sdev )
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;
}
/*