diff options
author | Christoph Hellwig <hch@lst.de> | 2014-09-14 06:59:51 +0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2014-11-12 13:19:25 +0300 |
commit | cd37743fc978a14fee75a4e662582e15d16038a3 (patch) | |
tree | 7b050076efb8a9dbf263ce593f30823445fb672a /drivers/scsi/device_handler/scsi_dh_rdac.c | |
parent | 27c888f0bb889693c6a3b6d39eba3265c16c072f (diff) | |
download | linux-cd37743fc978a14fee75a4e662582e15d16038a3.tar.xz |
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_rdac.c')
-rw-r--r-- | drivers/scsi/device_handler/scsi_dh_rdac.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index b850954c4e22..ef8caaaad76f 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -181,6 +181,7 @@ struct c2_inquiry { }; struct rdac_dh_data { + struct scsi_dh_data dh_data; struct rdac_controller *ctlr; #define UNINITIALIZED_LUN (1 << 8) unsigned lun; @@ -261,9 +262,7 @@ do { \ static inline struct rdac_dh_data *get_rdac_data(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data = sdev->scsi_dh_data; - BUG_ON(scsi_dh_data == NULL); - return ((struct rdac_dh_data *) scsi_dh_data->buf); + return container_of(sdev->scsi_dh_data, struct rdac_dh_data, dh_data); } static struct request *get_rdac_req(struct scsi_device *sdev, @@ -842,23 +841,20 @@ static struct scsi_device_handler rdac_dh = { static int rdac_bus_attach(struct scsi_device *sdev) { - struct scsi_dh_data *scsi_dh_data; struct rdac_dh_data *h; unsigned long flags; int err; char array_name[ARRAY_LABEL_LEN]; char array_id[UNIQUE_ID_LEN]; - 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", RDAC_NAME); return -ENOMEM; } - scsi_dh_data->scsi_dh = &rdac_dh; - h = (struct rdac_dh_data *) scsi_dh_data->buf; + h->dh_data.scsi_dh = &rdac_dh; h->lun = UNINITIALIZED_LUN; h->state = RDAC_STATE_ACTIVE; @@ -879,7 +875,7 @@ static int rdac_bus_attach(struct scsi_device *sdev) goto clean_ctlr; 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_NOTICE, sdev, @@ -895,7 +891,7 @@ clean_ctlr: spin_unlock(&list_lock); failed: - kfree(scsi_dh_data); + kfree(h); sdev_printk(KERN_ERR, sdev, "%s: not attached\n", RDAC_NAME); return -EINVAL; @@ -903,12 +899,9 @@ failed: static void rdac_bus_detach( struct scsi_device *sdev ) { - struct scsi_dh_data *scsi_dh_data; - struct rdac_dh_data *h; + struct rdac_dh_data *h = get_rdac_data(sdev); unsigned long flags; - scsi_dh_data = sdev->scsi_dh_data; - h = (struct rdac_dh_data *) scsi_dh_data->buf; if (h->ctlr && h->ctlr->ms_queued) flush_workqueue(kmpath_rdacd); @@ -920,7 +913,7 @@ static void rdac_bus_detach( struct scsi_device *sdev ) if (h->ctlr) kref_put(&h->ctlr->kref, release_controller); spin_unlock(&list_lock); - kfree(scsi_dh_data); + kfree(h); sdev_printk(KERN_NOTICE, sdev, "%s: Detached\n", RDAC_NAME); } |