summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/device_handler/scsi_dh_emc.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-09-13 19:59:51 -0700
committerChristoph Hellwig <hch@lst.de>2014-11-12 11:19:25 +0100
commitcd37743fc978a14fee75a4e662582e15d16038a3 (patch)
tree7b050076efb8a9dbf263ce593f30823445fb672a /drivers/scsi/device_handler/scsi_dh_emc.c
parent27c888f0bb889693c6a3b6d39eba3265c16c072f (diff)
downloadlinux-cd37743fc978a14fee75a4e662582e15d16038a3.tar.gz
linux-cd37743fc978a14fee75a4e662582e15d16038a3.tar.bz2
linux-cd37743fc978a14fee75a4e662582e15d16038a3.zip
scsi: use container_of to get at device handler private data
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mike Christie <michaelc@cs.wisc.edu> Reviewed-by: Hannes Reinecke <hare@suse.de>
Diffstat (limited to 'drivers/scsi/device_handler/scsi_dh_emc.c')
-rw-r--r--drivers/scsi/device_handler/scsi_dh_emc.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/scsi/device_handler/scsi_dh_emc.c b/drivers/scsi/device_handler/scsi_dh_emc.c
index 153b4c3547a2..c2e26cdef21a 100644
--- a/drivers/scsi/device_handler/scsi_dh_emc.c
+++ b/drivers/scsi/device_handler/scsi_dh_emc.c
@@ -72,6 +72,7 @@ static const char * lun_state[] =
};
struct clariion_dh_data {
+ struct scsi_dh_data dh_data;
/*
* Flags:
* CLARIION_SHORT_TRESPASS
@@ -116,9 +117,8 @@ struct clariion_dh_data {
static inline struct clariion_dh_data
*get_clariion_data(struct scsi_device *sdev)
{
- struct scsi_dh_data *scsi_dh_data = sdev->scsi_dh_data;
- BUG_ON(scsi_dh_data == NULL);
- return ((struct clariion_dh_data *) scsi_dh_data->buf);
+ return container_of(sdev->scsi_dh_data, struct clariion_dh_data,
+ dh_data);
}
/*
@@ -665,21 +665,18 @@ static struct scsi_device_handler clariion_dh = {
static int clariion_bus_attach(struct scsi_device *sdev)
{
- struct scsi_dh_data *scsi_dh_data;
struct clariion_dh_data *h;
unsigned long flags;
int err;
- scsi_dh_data = kzalloc(sizeof(*scsi_dh_data)
- + sizeof(*h) , GFP_KERNEL);
- if (!scsi_dh_data) {
+ h = kzalloc(sizeof(*h) , GFP_KERNEL);
+ if (!h) {
sdev_printk(KERN_ERR, sdev, "%s: Attach failed\n",
CLARIION_NAME);
return -ENOMEM;
}
- scsi_dh_data->scsi_dh = &clariion_dh;
- h = (struct clariion_dh_data *) scsi_dh_data->buf;
+ h->dh_data.scsi_dh = &clariion_dh;
h->lun_state = CLARIION_LUN_UNINITIALIZED;
h->default_sp = CLARIION_UNBOUND_LU;
h->current_sp = CLARIION_UNBOUND_LU;
@@ -693,7 +690,7 @@ static int clariion_bus_attach(struct scsi_device *sdev)
goto failed;
spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
- sdev->scsi_dh_data = scsi_dh_data;
+ sdev->scsi_dh_data = &h->dh_data;
spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
sdev_printk(KERN_INFO, sdev,
@@ -705,7 +702,7 @@ static int clariion_bus_attach(struct scsi_device *sdev)
return 0;
failed:
- kfree(scsi_dh_data);
+ kfree(h);
sdev_printk(KERN_ERR, sdev, "%s: not attached\n",
CLARIION_NAME);
return -EINVAL;
@@ -713,18 +710,17 @@ failed:
static void clariion_bus_detach(struct scsi_device *sdev)
{
- struct scsi_dh_data *scsi_dh_data;
+ struct clariion_dh_data *h = get_clariion_data(sdev);
unsigned long flags;
spin_lock_irqsave(sdev->request_queue->queue_lock, flags);
- scsi_dh_data = sdev->scsi_dh_data;
sdev->scsi_dh_data = NULL;
spin_unlock_irqrestore(sdev->request_queue->queue_lock, flags);
sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n",
CLARIION_NAME);
- kfree(scsi_dh_data);
+ kfree(h);
}
static int __init clariion_init(void)