Commit 01d7b3b8 authored by Jeff Garzik's avatar Jeff Garzik Committed by James Bottomley

[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: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 13ec92b3
...@@ -151,6 +151,9 @@ struct scsi_device { ...@@ -151,6 +151,9 @@ struct scsi_device {
#define sdev_printk(prefix, sdev, fmt, a...) \ #define sdev_printk(prefix, sdev, fmt, a...) \
dev_printk(prefix, &(sdev)->sdev_gendev, 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 * 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, * 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,6 +275,19 @@ extern int scsi_execute_req(struct scsi_device *sdev, const unsigned char *cmd,
int data_direction, void *buffer, unsigned bufflen, int data_direction, void *buffer, unsigned bufflen,
struct scsi_sense_hdr *, int timeout, int retries); 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) static inline int scsi_device_online(struct scsi_device *sdev)
{ {
return sdev->sdev_state != SDEV_OFFLINE; return sdev->sdev_state != SDEV_OFFLINE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment