Commit 01d73de0 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley

[PATCH] helper for device list traversal

This patch adds shost_for_each_device().  It's used to abstract out
scsi_host.my_devices traversal.  The next step will be to replace
the current simple implementation with one that's fully locked down
an reference counted.
parent ec5c4a6f
...@@ -2592,7 +2592,7 @@ int fas216_eh_bus_reset(Scsi_Cmnd *SCpnt) ...@@ -2592,7 +2592,7 @@ int fas216_eh_bus_reset(Scsi_Cmnd *SCpnt)
* all command structures. Leave the running * all command structures. Leave the running
* command in place. * command in place.
*/ */
list_for_each_entry(SDpnt, &info->host->my_devices, siblings) { shost_for_each_device(SDpnt, info->host) {
int i; int i;
if (SDpnt->soft_reset) if (SDpnt->soft_reset)
...@@ -3007,7 +3007,7 @@ int fas216_print_devices(FAS216_Info *info, char *buffer) ...@@ -3007,7 +3007,7 @@ int fas216_print_devices(FAS216_Info *info, char *buffer)
p += sprintf(p, "Device/Lun TaggedQ Parity Sync\n"); p += sprintf(p, "Device/Lun TaggedQ Parity Sync\n");
list_for_each_entry(scd, &info->host->my_devices, siblings) { shost_for_each_device(scd, info->host) {
dev = &info->device[scd->id]; dev = &info->device[scd->id];
p += sprintf(p, " %d/%d ", scd->id, scd->lun); p += sprintf(p, " %d/%d ", scd->id, scd->lun);
if (scd->tagged_supported) if (scd->tagged_supported)
......
...@@ -2483,7 +2483,7 @@ static void adpt_fail_posted_scbs(adpt_hba* pHba) ...@@ -2483,7 +2483,7 @@ static void adpt_fail_posted_scbs(adpt_hba* pHba)
Scsi_Cmnd* cmd = NULL; Scsi_Cmnd* cmd = NULL;
Scsi_Device* d = NULL; Scsi_Device* d = NULL;
list_for_each_entry(d, &pHba->host->my_devices, siblings) { shost_for_each_device(d, pHba->host) {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&d->list_lock, flags); spin_lock_irqsave(&d->list_lock, flags);
list_for_each_entry(cmd, &d->cmd_list, list) { list_for_each_entry(cmd, &d->cmd_list, list) {
......
...@@ -245,7 +245,7 @@ int fcal_proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t of ...@@ -245,7 +245,7 @@ int fcal_proc_info (struct Scsi_Host *host, char *buffer, char **start, off_t of
alpa, u1[0], u1[1], u2[0], u2[1]); alpa, u1[0], u1[1], u2[0], u2[1]);
} else { } else {
Scsi_Device *scd; Scsi_Device *scd;
list_for_each_entry (scd, &host->my_devices, siblings) shost_for_each_device(scd, host)
if (scd->id == target) { if (scd->id == target) {
SPRINTF (" [AL-PA: %02x, Id: %02d, Port WWN: %08x%08x, Node WWN: %08x%08x] ", SPRINTF (" [AL-PA: %02x, Id: %02d, Port WWN: %08x%08x, Node WWN: %08x%08x] ",
alpa, target, u1[0], u1[1], u2[0], u2[1]); alpa, target, u1[0], u1[1], u2[0], u2[1]);
......
...@@ -825,7 +825,7 @@ static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, c ...@@ -825,7 +825,7 @@ static int generic_NCR5380_proc_info(struct Scsi_Host *scsi_ptr, char *buffer, c
PRINTP(" %d pending writes" ANDP hostdata->pendingw); PRINTP(" %d pending writes" ANDP hostdata->pendingw);
if (hostdata->pendingr || hostdata->pendingw) if (hostdata->pendingr || hostdata->pendingw)
PRINTP("\n"); PRINTP("\n");
list_for_each_entry (dev, &scsi_ptr->my_devices, siblings) { shost_for_each_device(dev, scsi_ptr) {
unsigned long br = hostdata->bytes_read[dev->id]; unsigned long br = hostdata->bytes_read[dev->id];
unsigned long bw = hostdata->bytes_write[dev->id]; unsigned long bw = hostdata->bytes_write[dev->id];
long tr = hostdata->time_read[dev->id] / HZ; long tr = hostdata->time_read[dev->id] / HZ;
......
...@@ -211,8 +211,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost, ...@@ -211,8 +211,7 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost,
int cmd_cancel = 0; int cmd_cancel = 0;
int devices_failed = 0; int devices_failed = 0;
shost_for_each_device(sdev, shost) {
list_for_each_entry(sdev, &shost->my_devices, siblings) {
list_for_each_entry(scmd, work_q, eh_entry) { list_for_each_entry(scmd, work_q, eh_entry) {
if (scmd->device == sdev) { if (scmd->device == sdev) {
++total_failures; ++total_failures;
...@@ -850,7 +849,7 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost, ...@@ -850,7 +849,7 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
struct scsi_device *sdev; struct scsi_device *sdev;
int rtn; int rtn;
list_for_each_entry(sdev, &shost->my_devices, siblings) { shost_for_each_device(sdev, shost) {
bdr_scmd = NULL; bdr_scmd = NULL;
list_for_each_entry(scmd, work_q, eh_entry) list_for_each_entry(scmd, work_q, eh_entry)
if (scmd->device == sdev) { if (scmd->device == sdev) {
...@@ -1363,9 +1362,10 @@ static void scsi_restart_operations(struct Scsi_Host *shost) ...@@ -1363,9 +1362,10 @@ static void scsi_restart_operations(struct Scsi_Host *shost)
* onto the head of the SCSI request queue for the device. There * onto the head of the SCSI request queue for the device. There
* is no point trying to lock the door of an off-line device. * is no point trying to lock the door of an off-line device.
*/ */
list_for_each_entry(sdev, &shost->my_devices, siblings) shost_for_each_device(sdev, shost) {
if (sdev->online && sdev->locked) if (sdev->online && sdev->locked)
scsi_eh_lock_door(sdev); scsi_eh_lock_door(sdev);
}
/* /*
* next free up anything directly waiting upon the host. this * next free up anything directly waiting upon the host. this
...@@ -1621,7 +1621,7 @@ void scsi_report_bus_reset(struct Scsi_Host *shost, int channel) ...@@ -1621,7 +1621,7 @@ void scsi_report_bus_reset(struct Scsi_Host *shost, int channel)
{ {
struct scsi_device *sdev; struct scsi_device *sdev;
list_for_each_entry(sdev, &shost->my_devices, siblings) { shost_for_each_device(sdev, shost) {
if (channel == sdev->channel) { if (channel == sdev->channel) {
sdev->was_reset = 1; sdev->was_reset = 1;
sdev->expecting_cc_ua = 1; sdev->expecting_cc_ua = 1;
...@@ -1655,7 +1655,7 @@ void scsi_report_device_reset(struct Scsi_Host *shost, int channel, int target) ...@@ -1655,7 +1655,7 @@ void scsi_report_device_reset(struct Scsi_Host *shost, int channel, int target)
{ {
struct scsi_device *sdev; struct scsi_device *sdev;
list_for_each_entry(sdev, &shost->my_devices, siblings) { shost_for_each_device(sdev, shost) {
if (channel == sdev->channel && if (channel == sdev->channel &&
target == sdev->id) { target == sdev->id) {
sdev->was_reset = 1; sdev->was_reset = 1;
......
...@@ -462,7 +462,7 @@ void scsi_run_host_queues(struct Scsi_Host *shost) ...@@ -462,7 +462,7 @@ void scsi_run_host_queues(struct Scsi_Host *shost)
{ {
struct scsi_device *sdev; struct scsi_device *sdev;
list_for_each_entry(sdev, &shost->my_devices, siblings) shost_for_each_device(sdev, shost)
scsi_run_queue(sdev->request_queue); scsi_run_queue(sdev->request_queue);
} }
......
...@@ -112,6 +112,9 @@ extern int scsi_device_cancel(struct scsi_device *, int); ...@@ -112,6 +112,9 @@ extern int scsi_device_cancel(struct scsi_device *, int);
extern int scsi_device_get(struct scsi_device *); extern int scsi_device_get(struct scsi_device *);
extern void scsi_device_put(struct scsi_device *); extern void scsi_device_put(struct scsi_device *);
#define shost_for_each_device(sdev, shost) \
list_for_each_entry((sdev), &((shost)->my_devices), siblings)
extern void scsi_adjust_queue_depth(struct scsi_device *, int, int); extern void scsi_adjust_queue_depth(struct scsi_device *, int, int);
extern int scsi_track_queue_full(struct scsi_device *, int); extern int scsi_track_queue_full(struct scsi_device *, int);
......
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