aboutsummaryrefslogtreecommitdiffstats
path: root/include/scsi/scsi_device.h
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2005-10-24 18:03:34 -0400
committerJames Bottomley <jejb@mulgrave.(none)>2005-10-28 21:47:24 -0400
commit01d7b3b8d09ef78e2c835c03d97ea1d91c26e245 (patch)
tree1e9d9744ea19788f8cd11c5547957325d21bb5bc /include/scsi/scsi_device.h
parent13ec92b33e4f41b81b3a237ad1d9a588a81f2f03 (diff)
[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_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 Rejections fixed up and Signed-off-by: James Bottomley <James.Bottomley@SteelEye.com>
Diffstat (limited to 'include/scsi/scsi_device.h')
-rw-r--r--include/scsi/scsi_device.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 7f621ab2865d..85cfd88461c8 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -151,6 +151,9 @@ struct scsi_device {
151#define sdev_printk(prefix, sdev, fmt, a...) \ 151#define sdev_printk(prefix, sdev, fmt, a...) \
152 dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a) 152 dev_printk(prefix, &(sdev)->sdev_gendev, fmt, ##a)
153 153
154#define scmd_printk(prefix, scmd, fmt, a...) \
155 dev_printk(prefix, &(scmd)->device->sdev_gendev, fmt, ##a)
156
154/* 157/*
155 * scsi_target: representation of a scsi target, for now, this is only 158 * scsi_target: representation of a scsi target, for now, this is only
156 * used for single_lun devices. If no one has active IO to the target, 159 * used for single_lun devices. If no one has active IO to the target,
@@ -272,6 +275,19 @@ extern int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd,
272 int data_direction, void *buffer, unsigned bufflen, 275 int data_direction, void *buffer, unsigned bufflen,
273 struct scsi_sense_hdr *, int timeout, int retries); 276 struct scsi_sense_hdr *, int timeout, int retries);
274 277
278static inline unsigned int sdev_channel(struct scsi_device *sdev)
279{
280 return sdev->channel;
281}
282
283static inline unsigned int sdev_id(struct scsi_device *sdev)
284{
285 return sdev->id;
286}
287
288#define scmd_id(scmd) sdev_id((scmd)->device)
289#define scmd_channel(scmd) sdev_channel((scmd)->device)
290
275static inline int scsi_device_online(struct scsi_device *sdev) 291static inline int scsi_device_online(struct scsi_device *sdev)
276{ 292{
277 return sdev->sdev_state != SDEV_OFFLINE; 293 return sdev->sdev_state != SDEV_OFFLINE;