All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [scsi 1/2] scsi device: add setters and getters for hostadat
@ 2015-03-01 10:22 Tomas Winkler
  2015-03-01 10:22 ` [scsi 2/2] scsi_debug: use scsi_device_get_hdata Tomas Winkler
  0 siblings, 1 reply; 2+ messages in thread
From: Tomas Winkler @ 2015-03-01 10:22 UTC (permalink / raw
  To: James E.J. Bottomley"
  Cc: linux-scsi, Tomas Winkler, Christoph Hellwig, Douglas Gilbert

Add setters and getters for host data of scsi_device
and scsi_target in spirit of  dev_set/get_drvdata

Cc: Christoph Hellwig <hch@lst.de>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 include/scsi/scsi_device.h | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index a4c9336811d1..fdf407e8bbed 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -532,6 +532,27 @@ static inline int scsi_device_tpgs(struct scsi_device *sdev)
 	return sdev->inquiry ? (sdev->inquiry[5] >> 4) & 0x3 : 0;
 }
 
+static inline void *scsi_device_get_hdata(struct scsi_device *sdev)
+{
+	return sdev->hostdata;
+}
+
+static inline void scsi_device_set_hdata(struct scsi_device *sdev, void *hdata)
+{
+	sdev->hostdata = hdata;
+}
+
+static inline void *scsi_target_get_hdata(struct scsi_target *starget)
+{
+	return starget->hostdata;
+}
+
+static inline void scsi_target_set_hdata(struct scsi_target *starget,
+					  void *hdata)
+{
+	starget->hostdata = hdata;
+}
+
 #define MODULE_ALIAS_SCSI_DEVICE(type) \
 	MODULE_ALIAS("scsi:t-" __stringify(type) "*")
 #define SCSI_DEVICE_MODALIAS_FMT "scsi:t-0x%02x"
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [scsi 2/2] scsi_debug: use scsi_device_get_hdata
  2015-03-01 10:22 [scsi 1/2] scsi device: add setters and getters for hostadat Tomas Winkler
@ 2015-03-01 10:22 ` Tomas Winkler
  0 siblings, 0 replies; 2+ messages in thread
From: Tomas Winkler @ 2015-03-01 10:22 UTC (permalink / raw
  To: James E.J. Bottomley"
  Cc: linux-scsi, Tomas Winkler, Christoph Hellwig, Douglas Gilbert

Cc: Christoph Hellwig <hch@lst.de>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
 drivers/scsi/scsi_debug.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 079934c8698e..0825c0a62a33 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -3498,7 +3498,7 @@ static void sdebug_q_cmd_complete(unsigned long indx)
 		pr_err("scp is NULL\n");
 		return;
 	}
-	devip = (struct sdebug_dev_info *)scp->device->hostdata;
+	devip = scsi_device_get_hdata(scp->device);
 	if (devip)
 		atomic_dec(&devip->num_in_q);
 	else
@@ -3558,7 +3558,7 @@ sdebug_q_cmd_hrt_complete(struct hrtimer *timer)
 		pr_err("scp is NULL\n");
 		goto the_end;
 	}
-	devip = (struct sdebug_dev_info *)scp->device->hostdata;
+	devip = scsi_device_get_hdata(scp->device);
 	if (devip)
 		atomic_dec(&devip->num_in_q);
 	else
@@ -3611,8 +3611,7 @@ static struct sdebug_dev_info * devInfoReg(struct scsi_device * sdev)
 {
 	struct sdebug_host_info * sdbg_host;
 	struct sdebug_dev_info * open_devip = NULL;
-	struct sdebug_dev_info * devip =
-			(struct sdebug_dev_info *)sdev->hostdata;
+	struct sdebug_dev_info *devip = scsi_device_get_hdata(sdev);
 
 	if (devip)
 		return devip;
@@ -3670,7 +3669,7 @@ static int scsi_debug_slave_configure(struct scsi_device *sdp)
 	devip = devInfoReg(sdp);
 	if (NULL == devip)
 		return 1;	/* no resources, will be marked offline */
-	sdp->hostdata = devip;
+	scsi_device_set_hdata(sdp, devip);
 	blk_queue_max_segment_size(sdp->request_queue, -1U);
 	if (scsi_debug_no_uld)
 		sdp->no_uld_attach = 1;
@@ -3679,8 +3678,7 @@ static int scsi_debug_slave_configure(struct scsi_device *sdp)
 
 static void scsi_debug_slave_destroy(struct scsi_device *sdp)
 {
-	struct sdebug_dev_info *devip =
-		(struct sdebug_dev_info *)sdp->hostdata;
+	struct sdebug_dev_info *devip = scsi_device_get_hdata(sdp);
 
 	if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)
 		pr_info("slave_destroy <%u %u %u %llu>\n",
@@ -3688,7 +3686,7 @@ static void scsi_debug_slave_destroy(struct scsi_device *sdp)
 	if (devip) {
 		/* make this slot available for re-use */
 		devip->used = false;
-		sdp->hostdata = NULL;
+		scsi_device_set_hdata(sdp, NULL);
 	}
 }
 
@@ -3709,8 +3707,7 @@ static int stop_queued_cmnd(struct scsi_cmnd *cmnd)
 		if (test_bit(k, queued_in_use_bm)) {
 			sqcp = &queued_arr[k];
 			if (cmnd == sqcp->a_cmnd) {
-				devip = (struct sdebug_dev_info *)
-					cmnd->device->hostdata;
+				devip = scsi_device_get_hdata(cmnd->device);
 				if (devip)
 					atomic_dec(&devip->num_in_q);
 				sqcp->a_cmnd = NULL;
@@ -3750,8 +3747,7 @@ static void stop_all_queued(void)
 		if (test_bit(k, queued_in_use_bm)) {
 			sqcp = &queued_arr[k];
 			if (sqcp->a_cmnd) {
-				devip = (struct sdebug_dev_info *)
-					sqcp->a_cmnd->device->hostdata;
+				devip = scsi_device_get_hdata(sqcp->a_cmnd->device);
 				if (devip)
 					atomic_dec(&devip->num_in_q);
 				sqcp->a_cmnd = NULL;
@@ -5113,7 +5109,7 @@ sdebug_change_qdepth(struct scsi_device *sdev, int qdepth)
 	struct sdebug_dev_info *devip;
 
 	spin_lock_irqsave(&queued_arr_lock, iflags);
-	devip = (struct sdebug_dev_info *)sdev->hostdata;
+	devip = scsi_device_get_hdata(sdev);
 	if (NULL == devip) {
 		spin_unlock_irqrestore(&queued_arr_lock, iflags);
 		return	-ENODEV;
@@ -5212,7 +5208,7 @@ scsi_debug_queuecommand(struct scsi_cmnd *scp)
 
 	sdeb_i = opcode_ind_arr[opcode];	/* fully mapped */
 	oip = &opcode_info_arr[sdeb_i];		/* safe if table consistent */
-	devip = (struct sdebug_dev_info *)sdp->hostdata;
+	devip = scsi_device_get_hdata(sdp);
 	if (!devip) {
 		devip = devInfoReg(sdp);
 		if (NULL == devip)
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-01 10:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-01 10:22 [scsi 1/2] scsi device: add setters and getters for hostadat Tomas Winkler
2015-03-01 10:22 ` [scsi 2/2] scsi_debug: use scsi_device_get_hdata Tomas Winkler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.