ide: add port and host iterators

Add ide_port_for_each_dev() / ide_host_for_each_port() iterators
and update IDE code to use them.

While at it:
- s/unit/i/ variable in ide_port_wait_ready(), ide_probe_port(),
  ide_port_tune_devices(), ide_port_init_devices_data(), do_reset1(),
  ide_acpi_set_state() and scc_dma_end()
- s/d/i/ variable in ide_proc_port_register_devices()

There should be no functional changes caused by this patch.
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 5e7f3a46
...@@ -641,7 +641,8 @@ void ide_acpi_push_timing(ide_hwif_t *hwif) ...@@ -641,7 +641,8 @@ void ide_acpi_push_timing(ide_hwif_t *hwif)
*/ */
void ide_acpi_set_state(ide_hwif_t *hwif, int on) void ide_acpi_set_state(ide_hwif_t *hwif, int on)
{ {
int unit; ide_drive_t *drive;
int i;
if (ide_noacpi || ide_noacpi_psx) if (ide_noacpi || ide_noacpi_psx)
return; return;
...@@ -655,9 +656,8 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on) ...@@ -655,9 +656,8 @@ void ide_acpi_set_state(ide_hwif_t *hwif, int on)
/* channel first and then drives for power on and verse versa for power off */ /* channel first and then drives for power on and verse versa for power off */
if (on) if (on)
acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0); acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
for (unit = 0; unit < MAX_DRIVES; ++unit) {
ide_drive_t *drive = hwif->devices[unit];
ide_port_for_each_dev(i, drive, hwif) {
if (!drive->acpidata->obj_handle) if (!drive->acpidata->obj_handle)
drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive); drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
...@@ -717,9 +717,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif) ...@@ -717,9 +717,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
/* /*
* Send IDENTIFY for each drive * Send IDENTIFY for each drive
*/ */
for (i = 0; i < MAX_DRIVES; i++) { ide_port_for_each_dev(i, drive, hwif) {
drive = hwif->devices[i];
memset(drive->acpidata, 0, sizeof(*drive->acpidata)); memset(drive->acpidata, 0, sizeof(*drive->acpidata));
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
...@@ -744,9 +742,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif) ...@@ -744,9 +742,7 @@ void ide_acpi_port_init_devices(ide_hwif_t *hwif)
ide_acpi_get_timing(hwif); ide_acpi_get_timing(hwif);
ide_acpi_push_timing(hwif); ide_acpi_push_timing(hwif);
for (i = 0; i < MAX_DRIVES; i++) { ide_port_for_each_dev(i, drive, hwif) {
drive = hwif->devices[i];
if (drive->dev_flags & IDE_DFLAG_PRESENT) if (drive->dev_flags & IDE_DFLAG_PRESENT)
/* Execute ACPI startup code */ /* Execute ACPI startup code */
ide_acpi_exec_tfs(drive); ide_acpi_exec_tfs(drive);
......
...@@ -1081,8 +1081,9 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) ...@@ -1081,8 +1081,9 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
struct ide_io_ports *io_ports = &hwif->io_ports; struct ide_io_ports *io_ports = &hwif->io_ports;
const struct ide_tp_ops *tp_ops = hwif->tp_ops; const struct ide_tp_ops *tp_ops = hwif->tp_ops;
const struct ide_port_ops *port_ops; const struct ide_port_ops *port_ops;
ide_drive_t *tdrive;
unsigned long flags, timeout; unsigned long flags, timeout;
unsigned int unit; int i;
DEFINE_WAIT(wait); DEFINE_WAIT(wait);
spin_lock_irqsave(&hwif->lock, flags); spin_lock_irqsave(&hwif->lock, flags);
...@@ -1110,9 +1111,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) ...@@ -1110,9 +1111,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE); prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE);
timeout = jiffies; timeout = jiffies;
for (unit = 0; unit < MAX_DRIVES; unit++) { ide_port_for_each_dev(i, tdrive, hwif) {
ide_drive_t *tdrive = hwif->devices[unit];
if (tdrive->dev_flags & IDE_DFLAG_PRESENT && if (tdrive->dev_flags & IDE_DFLAG_PRESENT &&
tdrive->dev_flags & IDE_DFLAG_PARKED && tdrive->dev_flags & IDE_DFLAG_PARKED &&
time_after(tdrive->sleep, timeout)) time_after(tdrive->sleep, timeout))
...@@ -1133,8 +1132,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) ...@@ -1133,8 +1132,8 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi)
* First, reset any device state data we were maintaining * First, reset any device state data we were maintaining
* for any of the drives on this interface. * for any of the drives on this interface.
*/ */
for (unit = 0; unit < MAX_DRIVES; ++unit) ide_port_for_each_dev(i, tdrive, hwif)
pre_reset(hwif->devices[unit]); pre_reset(tdrive);
if (io_ports->ctl_addr == 0) { if (io_ports->ctl_addr == 0) {
spin_unlock_irqrestore(&hwif->lock, flags); spin_unlock_irqrestore(&hwif->lock, flags);
......
...@@ -697,7 +697,8 @@ static int ide_register_port(ide_hwif_t *hwif) ...@@ -697,7 +697,8 @@ static int ide_register_port(ide_hwif_t *hwif)
static int ide_port_wait_ready(ide_hwif_t *hwif) static int ide_port_wait_ready(ide_hwif_t *hwif)
{ {
int unit, rc; ide_drive_t *drive;
int i, rc;
printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name); printk(KERN_DEBUG "Probing IDE interface %s...\n", hwif->name);
...@@ -714,9 +715,7 @@ static int ide_port_wait_ready(ide_hwif_t *hwif) ...@@ -714,9 +715,7 @@ static int ide_port_wait_ready(ide_hwif_t *hwif)
return rc; return rc;
/* Now make sure both master & slave are ready */ /* Now make sure both master & slave are ready */
for (unit = 0; unit < MAX_DRIVES; unit++) { ide_port_for_each_dev(i, drive, hwif) {
ide_drive_t *drive = hwif->devices[unit];
/* Ignore disks that we will not probe for later. */ /* Ignore disks that we will not probe for later. */
if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 || if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 ||
(drive->dev_flags & IDE_DFLAG_PRESENT)) { (drive->dev_flags & IDE_DFLAG_PRESENT)) {
...@@ -732,7 +731,7 @@ static int ide_port_wait_ready(ide_hwif_t *hwif) ...@@ -732,7 +731,7 @@ static int ide_port_wait_ready(ide_hwif_t *hwif)
} }
out: out:
/* Exit function with master reselected (let's be sane) */ /* Exit function with master reselected (let's be sane) */
if (unit) if (i)
SELECT_DRIVE(hwif->devices[0]); SELECT_DRIVE(hwif->devices[0]);
return rc; return rc;
...@@ -778,9 +777,10 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave); ...@@ -778,9 +777,10 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave);
static int ide_probe_port(ide_hwif_t *hwif) static int ide_probe_port(ide_hwif_t *hwif)
{ {
ide_drive_t *drive;
unsigned long flags; unsigned long flags;
unsigned int irqd; unsigned int irqd;
int unit, rc = -ENODEV; int i, rc = -ENODEV;
BUG_ON(hwif->present); BUG_ON(hwif->present);
...@@ -806,9 +806,7 @@ static int ide_probe_port(ide_hwif_t *hwif) ...@@ -806,9 +806,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
* Second drive should only exist if first drive was found, * Second drive should only exist if first drive was found,
* but a lot of cdrom drives are configured as single slaves. * but a lot of cdrom drives are configured as single slaves.
*/ */
for (unit = 0; unit < MAX_DRIVES; ++unit) { ide_port_for_each_dev(i, drive, hwif) {
ide_drive_t *drive = hwif->devices[unit];
(void) probe_for_drive(drive); (void) probe_for_drive(drive);
if (drive->dev_flags & IDE_DFLAG_PRESENT) if (drive->dev_flags & IDE_DFLAG_PRESENT)
rc = 0; rc = 0;
...@@ -829,20 +827,17 @@ static int ide_probe_port(ide_hwif_t *hwif) ...@@ -829,20 +827,17 @@ static int ide_probe_port(ide_hwif_t *hwif)
static void ide_port_tune_devices(ide_hwif_t *hwif) static void ide_port_tune_devices(ide_hwif_t *hwif)
{ {
const struct ide_port_ops *port_ops = hwif->port_ops; const struct ide_port_ops *port_ops = hwif->port_ops;
int unit; ide_drive_t *drive;
int i;
for (unit = 0; unit < MAX_DRIVES; unit++) {
ide_drive_t *drive = hwif->devices[unit];
ide_port_for_each_dev(i, drive, hwif) {
if (drive->dev_flags & IDE_DFLAG_PRESENT) { if (drive->dev_flags & IDE_DFLAG_PRESENT) {
if (port_ops && port_ops->quirkproc) if (port_ops && port_ops->quirkproc)
port_ops->quirkproc(drive); port_ops->quirkproc(drive);
} }
} }
for (unit = 0; unit < MAX_DRIVES; ++unit) { ide_port_for_each_dev(i, drive, hwif) {
ide_drive_t *drive = hwif->devices[unit];
if (drive->dev_flags & IDE_DFLAG_PRESENT) { if (drive->dev_flags & IDE_DFLAG_PRESENT) {
ide_set_max_pio(drive); ide_set_max_pio(drive);
...@@ -853,9 +848,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) ...@@ -853,9 +848,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
} }
} }
for (unit = 0; unit < MAX_DRIVES; ++unit) { ide_port_for_each_dev(i, drive, hwif) {
ide_drive_t *drive = hwif->devices[unit];
if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) || if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) ||
drive->id[ATA_ID_DWORD_IO]) drive->id[ATA_ID_DWORD_IO])
drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT;
...@@ -927,12 +920,11 @@ static DEFINE_MUTEX(ide_cfg_mtx); ...@@ -927,12 +920,11 @@ static DEFINE_MUTEX(ide_cfg_mtx);
*/ */
static int ide_port_setup_devices(ide_hwif_t *hwif) static int ide_port_setup_devices(ide_hwif_t *hwif)
{ {
ide_drive_t *drive;
int i, j = 0; int i, j = 0;
mutex_lock(&ide_cfg_mtx); mutex_lock(&ide_cfg_mtx);
for (i = 0; i < MAX_DRIVES; i++) { ide_port_for_each_dev(i, drive, hwif) {
ide_drive_t *drive = hwif->devices[i];
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
continue; continue;
...@@ -1161,10 +1153,10 @@ static int hwif_init(ide_hwif_t *hwif) ...@@ -1161,10 +1153,10 @@ static int hwif_init(ide_hwif_t *hwif)
static void hwif_register_devices(ide_hwif_t *hwif) static void hwif_register_devices(ide_hwif_t *hwif)
{ {
ide_drive_t *drive;
unsigned int i; unsigned int i;
for (i = 0; i < MAX_DRIVES; i++) { ide_port_for_each_dev(i, drive, hwif) {
ide_drive_t *drive = hwif->devices[i];
struct device *dev = &drive->gendev; struct device *dev = &drive->gendev;
int ret; int ret;
...@@ -1187,11 +1179,10 @@ static void hwif_register_devices(ide_hwif_t *hwif) ...@@ -1187,11 +1179,10 @@ static void hwif_register_devices(ide_hwif_t *hwif)
static void ide_port_init_devices(ide_hwif_t *hwif) static void ide_port_init_devices(ide_hwif_t *hwif)
{ {
const struct ide_port_ops *port_ops = hwif->port_ops; const struct ide_port_ops *port_ops = hwif->port_ops;
ide_drive_t *drive;
int i; int i;
for (i = 0; i < MAX_DRIVES; i++) { ide_port_for_each_dev(i, drive, hwif) {
ide_drive_t *drive = hwif->devices[i];
drive->dn = i + hwif->channel * 2; drive->dn = i + hwif->channel * 2;
if (hwif->host_flags & IDE_HFLAG_IO_32BIT) if (hwif->host_flags & IDE_HFLAG_IO_32BIT)
...@@ -1282,16 +1273,16 @@ static const u8 ide_hwif_to_major[] = ...@@ -1282,16 +1273,16 @@ static const u8 ide_hwif_to_major[] =
static void ide_port_init_devices_data(ide_hwif_t *hwif) static void ide_port_init_devices_data(ide_hwif_t *hwif)
{ {
int unit; ide_drive_t *drive;
int i;
for (unit = 0; unit < MAX_DRIVES; ++unit) { ide_port_for_each_dev(i, drive, hwif) {
ide_drive_t *drive = hwif->devices[unit]; u8 j = (hwif->index * MAX_DRIVES) + i;
u8 j = (hwif->index * MAX_DRIVES) + unit;
memset(drive, 0, sizeof(*drive)); memset(drive, 0, sizeof(*drive));
drive->media = ide_disk; drive->media = ide_disk;
drive->select = (unit << 4) | ATA_DEVICE_OBS; drive->select = (i << 4) | ATA_DEVICE_OBS;
drive->hwif = hwif; drive->hwif = hwif;
drive->ready_stat = ATA_DRDY; drive->ready_stat = ATA_DRDY;
drive->bad_wstat = BAD_W_STAT; drive->bad_wstat = BAD_W_STAT;
...@@ -1387,10 +1378,11 @@ static void ide_free_port_slot(int idx) ...@@ -1387,10 +1378,11 @@ static void ide_free_port_slot(int idx)
static void ide_port_free_devices(ide_hwif_t *hwif) static void ide_port_free_devices(ide_hwif_t *hwif)
{ {
ide_drive_t *drive;
int i; int i;
for (i = 0; i < MAX_DRIVES; i++) ide_port_for_each_dev(i, drive, hwif)
kfree(hwif->devices[i]); kfree(drive);
} }
static int ide_port_alloc_devices(ide_hwif_t *hwif, int node) static int ide_port_alloc_devices(ide_hwif_t *hwif, int node)
...@@ -1478,9 +1470,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1478,9 +1470,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
ide_hwif_t *hwif, *mate = NULL; ide_hwif_t *hwif, *mate = NULL;
int i, j = 0; int i, j = 0;
for (i = 0; i < MAX_HOST_PORTS; i++) { ide_host_for_each_port(i, hwif, host) {
hwif = host->ports[i];
if (hwif == NULL) { if (hwif == NULL) {
mate = NULL; mate = NULL;
continue; continue;
...@@ -1506,9 +1496,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1506,9 +1496,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
ide_port_init_devices(hwif); ide_port_init_devices(hwif);
} }
for (i = 0; i < MAX_HOST_PORTS; i++) { ide_host_for_each_port(i, hwif, host) {
hwif = host->ports[i];
if (hwif == NULL) if (hwif == NULL)
continue; continue;
...@@ -1523,9 +1511,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1523,9 +1511,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
ide_port_tune_devices(hwif); ide_port_tune_devices(hwif);
} }
for (i = 0; i < MAX_HOST_PORTS; i++) { ide_host_for_each_port(i, hwif, host) {
hwif = host->ports[i];
if (hwif == NULL) if (hwif == NULL)
continue; continue;
...@@ -1550,9 +1536,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1550,9 +1536,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
ide_acpi_port_init_devices(hwif); ide_acpi_port_init_devices(hwif);
} }
for (i = 0; i < MAX_HOST_PORTS; i++) { ide_host_for_each_port(i, hwif, host) {
hwif = host->ports[i];
if (hwif == NULL) if (hwif == NULL)
continue; continue;
...@@ -1560,9 +1544,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ...@@ -1560,9 +1544,7 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
hwif_register_devices(hwif); hwif_register_devices(hwif);
} }
for (i = 0; i < MAX_HOST_PORTS; i++) { ide_host_for_each_port(i, hwif, host) {
hwif = host->ports[i];
if (hwif == NULL) if (hwif == NULL)
continue; continue;
...@@ -1602,11 +1584,10 @@ EXPORT_SYMBOL_GPL(ide_host_add); ...@@ -1602,11 +1584,10 @@ EXPORT_SYMBOL_GPL(ide_host_add);
static void __ide_port_unregister_devices(ide_hwif_t *hwif) static void __ide_port_unregister_devices(ide_hwif_t *hwif)
{ {
ide_drive_t *drive;
int i; int i;
for (i = 0; i < MAX_DRIVES; i++) { ide_port_for_each_dev(i, drive, hwif) {
ide_drive_t *drive = hwif->devices[i];
if (drive->dev_flags & IDE_DFLAG_PRESENT) { if (drive->dev_flags & IDE_DFLAG_PRESENT) {
device_unregister(&drive->gendev); device_unregister(&drive->gendev);
wait_for_completion(&drive->gendev_rel_comp); wait_for_completion(&drive->gendev_rel_comp);
...@@ -1675,9 +1656,7 @@ void ide_host_free(struct ide_host *host) ...@@ -1675,9 +1656,7 @@ void ide_host_free(struct ide_host *host)
ide_hwif_t *hwif; ide_hwif_t *hwif;
int i; int i;
for (i = 0; i < MAX_HOST_PORTS; i++) { ide_host_for_each_port(i, hwif, host) {
hwif = host->ports[i];
if (hwif == NULL) if (hwif == NULL)
continue; continue;
...@@ -1692,11 +1671,12 @@ EXPORT_SYMBOL_GPL(ide_host_free); ...@@ -1692,11 +1671,12 @@ EXPORT_SYMBOL_GPL(ide_host_free);
void ide_host_remove(struct ide_host *host) void ide_host_remove(struct ide_host *host)
{ {
ide_hwif_t *hwif;
int i; int i;
for (i = 0; i < MAX_HOST_PORTS; i++) { ide_host_for_each_port(i, hwif, host) {
if (host->ports[i]) if (hwif)
ide_unregister(host->ports[i]); ide_unregister(hwif);
} }
ide_host_free(host); ide_host_free(host);
......
...@@ -593,14 +593,13 @@ EXPORT_SYMBOL(ide_proc_unregister_driver); ...@@ -593,14 +593,13 @@ EXPORT_SYMBOL(ide_proc_unregister_driver);
void ide_proc_port_register_devices(ide_hwif_t *hwif) void ide_proc_port_register_devices(ide_hwif_t *hwif)
{ {
int d;
struct proc_dir_entry *ent; struct proc_dir_entry *ent;
struct proc_dir_entry *parent = hwif->proc; struct proc_dir_entry *parent = hwif->proc;
ide_drive_t *drive;
char name[64]; char name[64];
int i;
for (d = 0; d < MAX_DRIVES; d++) { ide_port_for_each_dev(i, drive, hwif) {
ide_drive_t *drive = hwif->devices[d];
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc) if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc)
continue; continue;
......
...@@ -488,6 +488,7 @@ MODULE_PARM_DESC(ignore_cable, "ignore cable detection"); ...@@ -488,6 +488,7 @@ MODULE_PARM_DESC(ignore_cable, "ignore cable detection");
void ide_port_apply_params(ide_hwif_t *hwif) void ide_port_apply_params(ide_hwif_t *hwif)
{ {
ide_drive_t *drive;
int i; int i;
if (ide_ignore_cable & (1 << hwif->index)) { if (ide_ignore_cable & (1 << hwif->index)) {
...@@ -496,8 +497,8 @@ void ide_port_apply_params(ide_hwif_t *hwif) ...@@ -496,8 +497,8 @@ void ide_port_apply_params(ide_hwif_t *hwif)
hwif->cbl = ATA_CBL_PATA40_SHORT; hwif->cbl = ATA_CBL_PATA40_SHORT;
} }
for (i = 0; i < MAX_DRIVES; i++) ide_port_for_each_dev(i, drive, hwif)
ide_dev_apply_params(hwif->devices[i], i); ide_dev_apply_params(drive, i);
} }
/* /*
......
...@@ -406,20 +406,20 @@ static int scc_dma_end(ide_drive_t *drive) ...@@ -406,20 +406,20 @@ static int scc_dma_end(ide_drive_t *drive)
data_loss = 1; data_loss = 1;
if (retry++) { if (retry++) {
struct request *rq = hwif->rq; struct request *rq = hwif->rq;
int unit; ide_drive_t *drive;
int i;
/* ERROR_RESET and drive->crc_count are needed /* ERROR_RESET and drive->crc_count are needed
* to reduce DMA transfer mode in retry process. * to reduce DMA transfer mode in retry process.
*/ */
if (rq) if (rq)
rq->errors |= ERROR_RESET; rq->errors |= ERROR_RESET;
for (unit = 0; unit < MAX_DRIVES; unit++) {
ide_drive_t *drive = hwif->devices[unit];
ide_port_for_each_dev(i, drive, hwif)
drive->crc_count++; drive->crc_count++;
} }
} }
} }
}
while (1) { while (1) {
reg = in_be32((void __iomem *)intsts_port); reg = in_be32((void __iomem *)intsts_port);
......
...@@ -753,7 +753,7 @@ typedef struct hwif_s { ...@@ -753,7 +753,7 @@ typedef struct hwif_s {
unsigned long sata_scr[SATA_NR_PORTS]; unsigned long sata_scr[SATA_NR_PORTS];
ide_drive_t *devices[MAX_DRIVES]; ide_drive_t *devices[MAX_DRIVES + 1];
u8 major; /* our major number */ u8 major; /* our major number */
u8 index; /* 0 for ide0; 1 for ide1; ... */ u8 index; /* 0 for ide0; 1 for ide1; ... */
...@@ -861,7 +861,7 @@ typedef struct hwif_s { ...@@ -861,7 +861,7 @@ typedef struct hwif_s {
#define MAX_HOST_PORTS 4 #define MAX_HOST_PORTS 4
struct ide_host { struct ide_host {
ide_hwif_t *ports[MAX_HOST_PORTS]; ide_hwif_t *ports[MAX_HOST_PORTS + 1];
unsigned int n_ports; unsigned int n_ports;
struct device *dev[2]; struct device *dev[2];
unsigned int (*init_chipset)(struct pci_dev *); unsigned int (*init_chipset)(struct pci_dev *);
...@@ -1604,4 +1604,11 @@ static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive) ...@@ -1604,4 +1604,11 @@ static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive)
return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL;
} }
#define ide_port_for_each_dev(i, dev, port) \
for ((i) = 0; ((dev) = (port)->devices[i]) || (i) < MAX_DRIVES; (i)++)
#define ide_host_for_each_port(i, port, host) \
for ((i) = 0; ((port) = (host)->ports[i]) || (i) < MAX_HOST_PORTS; (i)++)
#endif /* _IDE_H */ #endif /* _IDE_H */
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