public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Garzik <jgarzik@pobox.com>
To: linux-scsi@vger.kernel.org
Subject: [scsi hcil 6/9] introduce sfoo_printk, sfoo_id, sfoo_channel helpers
Date: Mon, 24 Oct 2005 18:03:34 -0400	[thread overview]
Message-ID: <20051024220334.GF10567@havoc.gtf.org> (raw)
In-Reply-To: <20051024220013.GA10070@havoc.gtf.org>


commit 30d604030b5c7add791746119c72cab358eb75c3
Author: Jeff Garzik <jgarzik@pobox.com>
Date:   Mon Oct 24 15:59:30 2005 -0400

    [SCSI] introduce sfoo_printk, sfoo_id, sfoo_channel helpers
    
    New dev_printk wrappers, which allow us to shrink code, and
    eliminate direct references to host/channel/id/lun members:
    	{scmd,sdev,starget,shost}_printk()
    
    Introduce wrappers for highly common idioms, which may also help us
    eliminate some ->{channel,id} references in the future:
    	{scmd,sdev}_id()
    	{scmd,sdev}_channel()
    
    The scmd_* wrappers are present in scsi/scsi_device.h because they all
    employ the dereference chain cmd->device->$member.  We would prefer to
    use static inline functions rather than macros, but that would have a

 include/scsi/scsi_device.h |   22 ++++++++++++++++++++++
 include/scsi/scsi_host.h   |    4 ++++
 2 files changed, 26 insertions(+)

diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 14d89eb..39b4aad 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -148,6 +148,12 @@ struct scsi_device {
 #define transport_class_to_sdev(class_dev) \
 	to_scsi_device(class_dev->dev)
 
+#define sdev_printk(prefix, sdev, fmt, a...)	\
+	dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a)
+
+#define scmd_printk(prefix, scmd, fmt, a...)	\
+	dev_printk(prefix, &(scmd)->device->sdev_gendev, fmt, ##a)
+
 /*
  * scsi_target: representation of a scsi target, for now, this is only
  * used for single_lun devices. If no one has active IO to the target,
@@ -177,6 +183,9 @@ static inline struct scsi_target *scsi_t
 #define transport_class_to_starget(class_dev) \
 	to_scsi_target(class_dev->dev)
 
+#define starget_printk(prefix, starget, fmt, a...)	\
+	dev_printk(prefix, &(starget)->dev, fmt, ##a)
+
 extern struct scsi_device *__scsi_add_device(struct Scsi_Host *,
 		uint, uint, uint, void *hostdata);
 extern int scsi_add_device(struct Scsi_Host *host, uint channel,
@@ -264,6 +273,19 @@ extern int scsi_execute_req(struct scsi_
 			    int data_direction, void *buffer, unsigned bufflen,
 			    struct scsi_sense_hdr *, int timeout, int retries);
 
+static inline unsigned int sdev_channel(struct scsi_device *sdev)
+{
+	return sdev->channel;
+}
+
+static inline unsigned int sdev_id(struct scsi_device *sdev)
+{
+	return sdev->id;
+}
+
+#define scmd_id(scmd) sdev_id((scmd)->device)
+#define scmd_channel(scmd) sdev_channel((scmd)->device)
+
 static inline int scsi_device_online(struct scsi_device *sdev)
 {
 	return sdev->sdev_state != SDEV_OFFLINE;
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 26b3f70..ecd53d7 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -609,6 +609,10 @@ struct Scsi_Host {
 #define		class_to_shost(d)	\
 	container_of(d, struct Scsi_Host, shost_classdev)
 
+#define shost_printk(prefix, shost, fmt, a...)	\
+	dev_printk(prefix, &(shost)->shost_gendev, fmt, ##a)
+
+
 int scsi_is_host_device(const struct device *);
 
 static inline struct Scsi_Host *dev_to_shost(struct device *dev)

  parent reply	other threads:[~2005-10-24 22:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-24 22:00 [scsi hcil 0/9] marginalize HCIL a bit Jeff Garzik
2005-10-24 22:01 ` [scsi hcil 1/9] kill unused scsi_scan_single_target() Jeff Garzik
2005-10-24 22:01 ` [scsi hcil 2/9] remove cpqfcTS driver, long uncompilable Jeff Garzik
2005-10-24 22:02 ` [scsi hcil 3/9] misc cleanups Jeff Garzik
2005-10-29  1:34   ` James Bottomley
2005-10-24 22:02 ` [scsi hcil 4/9] s/scsi_scan_target/spi_scan_target/ Jeff Garzik
2005-10-24 22:03 ` [scsi hcil 5/9] split up __spi_scan_target() Jeff Garzik
2005-10-24 22:03 ` Jeff Garzik [this message]
2005-10-24 22:04 ` [scsi hcil 7/9] use {sdev,scmd,starget,shost}_printk in generic code Jeff Garzik
2005-10-24 22:04 ` [scsi hcil 8/9] use sfoo_printk() in drivers Jeff Garzik
2005-10-24 22:05 ` [scsi hcil 9/9] use scmd_id(), scmd_channel() throughout code Jeff Garzik
2005-10-24 22:30 ` [scsi hcil 10/9] ibmmca bug fix Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051024220334.GF10567@havoc.gtf.org \
    --to=jgarzik@pobox.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox