* [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper
@ 2008-12-21 21:00 Bartlomiej Zolnierkiewicz
2008-12-21 21:00 ` [PATCH 2/7] cmd640: " Bartlomiej Zolnierkiewicz
` (6 more replies)
0 siblings, 7 replies; 11+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-12-21 21:00 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] amd74xx: use ide_get_pair_dev() helper
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
updates for pata-2.6 tree
drivers/ide/amd74xx.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: b/drivers/ide/amd74xx.c
===================================================================
--- a/drivers/ide/amd74xx.c
+++ b/drivers/ide/amd74xx.c
@@ -82,7 +82,7 @@ static void amd_set_drive(ide_drive_t *d
{
ide_hwif_t *hwif = drive->hwif;
struct pci_dev *dev = to_pci_dev(hwif->dev);
- ide_drive_t *peer = hwif->drives + (~drive->dn & 1);
+ ide_drive_t *peer = ide_get_pair_dev(drive);
struct ide_timing t, p;
int T, UT;
u8 udma_mask = hwif->ultra_mask;
@@ -92,7 +92,7 @@ static void amd_set_drive(ide_drive_t *d
ide_timing_compute(drive, speed, &t, T, UT);
- if (peer->dev_flags & IDE_DFLAG_PRESENT) {
+ if (peer) {
ide_timing_compute(peer, peer->current_speed, &p, T, UT);
ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT);
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/7] cmd640: use ide_get_pair_dev() helper
2008-12-21 21:00 [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper Bartlomiej Zolnierkiewicz
@ 2008-12-21 21:00 ` Bartlomiej Zolnierkiewicz
2008-12-22 10:08 ` Sergei Shtylyov
2008-12-21 21:00 ` [PATCH 3/7] cmd64x: " Bartlomiej Zolnierkiewicz
` (5 subsequent siblings)
6 siblings, 1 reply; 11+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-12-21 21:00 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] cmd640: use ide_get_pair_dev() helper
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/cmd640.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
Index: b/drivers/ide/cmd640.c
===================================================================
--- a/drivers/ide/cmd640.c
+++ b/drivers/ide/cmd640.c
@@ -467,11 +467,10 @@ static void program_drive_counts(ide_dri
* so we merge the timings, using the slowest value for each timing.
*/
if (index > 1) {
- ide_hwif_t *hwif = drive->hwif;
- ide_drive_t *peer = &hwif->drives[!(drive->dn & 1)];
+ ide_drive_t *peer = ide_get_pair_dev(drive);
unsigned int mate = index ^ 1;
- if (peer->dev_flags & IDE_DFLAG_PRESENT) {
+ if (peer) {
if (setup_count < setup_counts[mate])
setup_count = setup_counts[mate];
if (active_count < active_counts[mate])
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/7] cmd64x: use ide_get_pair_dev() helper
2008-12-21 21:00 [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper Bartlomiej Zolnierkiewicz
2008-12-21 21:00 ` [PATCH 2/7] cmd640: " Bartlomiej Zolnierkiewicz
@ 2008-12-21 21:00 ` Bartlomiej Zolnierkiewicz
2008-12-22 10:07 ` Sergei Shtylyov
2008-12-21 21:00 ` [PATCH 4/7] it821x: " Bartlomiej Zolnierkiewicz
` (4 subsequent siblings)
6 siblings, 1 reply; 11+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-12-21 21:00 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] cmd64x: use ide_get_pair_dev() helper
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/cmd64x.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
Index: b/drivers/ide/cmd64x.c
===================================================================
--- a/drivers/ide/cmd64x.c
+++ b/drivers/ide/cmd64x.c
@@ -138,10 +138,12 @@ static void cmd64x_tune_pio(ide_drive_t
* the slowest address setup timing ourselves.
*/
if (hwif->channel) {
- ide_drive_t *drives = hwif->drives;
+ ide_drive_t *pair = ide_get_pair_dev(drive);
drive->drive_data = setup_count;
- setup_count = max(drives[0].drive_data, drives[1].drive_data);
+
+ if (pair)
+ setup_count = max_t(u8, setup_count, pair->drive_data);
}
if (setup_count > 5) /* shouldn't actually happen... */
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/7] it821x: use ide_get_pair_dev() helper
2008-12-21 21:00 [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper Bartlomiej Zolnierkiewicz
2008-12-21 21:00 ` [PATCH 2/7] cmd640: " Bartlomiej Zolnierkiewicz
2008-12-21 21:00 ` [PATCH 3/7] cmd64x: " Bartlomiej Zolnierkiewicz
@ 2008-12-21 21:00 ` Bartlomiej Zolnierkiewicz
2008-12-22 10:11 ` Sergei Shtylyov
2008-12-21 21:00 ` [PATCH 5/7] ide: NUMA aware allocation of host and port structures Bartlomiej Zolnierkiewicz
` (3 subsequent siblings)
6 siblings, 1 reply; 11+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-12-21 21:00 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] it821x: use ide_get_pair_dev() helper
Because presence of the peer device was not checked in
it821x_set_pio_mode() PIO0 mode was used for taskfile PIO
in single device configurations.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/it821x.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
Index: b/drivers/ide/it821x.c
===================================================================
--- a/drivers/ide/it821x.c
+++ b/drivers/ide/it821x.c
@@ -167,12 +167,10 @@ static void it821x_clock_strategy(ide_dr
ide_hwif_t *hwif = drive->hwif;
struct pci_dev *dev = to_pci_dev(hwif->dev);
struct it821x_dev *itdev = ide_get_hwifdata(hwif);
- ide_drive_t *pair;
+ ide_drive_t *pair = ide_get_pair_dev(drive);
int clock, altclock, sel = 0;
u8 unit = drive->dn & 1, v;
- pair = &hwif->drives[1 - unit];
-
if(itdev->want[0][0] > itdev->want[1][0]) {
clock = itdev->want[0][1];
altclock = itdev->want[1][1];
@@ -239,15 +237,13 @@ static void it821x_set_pio_mode(ide_driv
{
ide_hwif_t *hwif = drive->hwif;
struct it821x_dev *itdev = ide_get_hwifdata(hwif);
- ide_drive_t *pair;
+ ide_drive_t *pair = ide_get_pair_dev(drive);
u8 unit = drive->dn & 1, set_pio = pio;
/* Spec says 89 ref driver uses 88 */
static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 };
static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY };
- pair = &hwif->drives[1 - unit];
-
/*
* Compute the best PIO mode we can for a given device. We must
* pick a speed that does not cause problems with the other device
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 5/7] ide: NUMA aware allocation of host and port structures
2008-12-21 21:00 [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper Bartlomiej Zolnierkiewicz
` (2 preceding siblings ...)
2008-12-21 21:00 ` [PATCH 4/7] it821x: " Bartlomiej Zolnierkiewicz
@ 2008-12-21 21:00 ` Bartlomiej Zolnierkiewicz
2008-12-21 21:00 ` [PATCH 6/7] ide: dynamic allocation of device structures Bartlomiej Zolnierkiewicz
` (2 subsequent siblings)
6 siblings, 0 replies; 11+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-12-21 21:00 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: NUMA aware allocation of host and port structures
kzalloc() -> kzalloc_node() in ide_host_alloc().
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-probe.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1391,9 +1391,11 @@ static void ide_free_port_slot(int idx)
struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
{
struct ide_host *host;
+ struct device *dev = hws[0] ? hws[0]->dev : NULL;
+ int node = dev ? dev_to_node(dev) : -1;
int i;
- host = kzalloc(sizeof(*host), GFP_KERNEL);
+ host = kzalloc_node(sizeof(*host), GFP_KERNEL, node);
if (host == NULL)
return NULL;
@@ -1404,7 +1406,7 @@ struct ide_host *ide_host_alloc(const st
if (hws[i] == NULL)
continue;
- hwif = kzalloc(sizeof(*hwif), GFP_KERNEL);
+ hwif = kzalloc_node(sizeof(*hwif), GFP_KERNEL, node);
if (hwif == NULL)
continue;
@@ -1429,8 +1431,7 @@ struct ide_host *ide_host_alloc(const st
return NULL;
}
- if (hws[0])
- host->dev[0] = hws[0]->dev;
+ host->dev[0] = dev;
if (d) {
host->init_chipset = d->init_chipset;
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 6/7] ide: dynamic allocation of device structures
2008-12-21 21:00 [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper Bartlomiej Zolnierkiewicz
` (3 preceding siblings ...)
2008-12-21 21:00 ` [PATCH 5/7] ide: NUMA aware allocation of host and port structures Bartlomiej Zolnierkiewicz
@ 2008-12-21 21:00 ` Bartlomiej Zolnierkiewicz
2008-12-21 21:00 ` [PATCH 7/7] ide: add port and host iterators Bartlomiej Zolnierkiewicz
2008-12-22 10:09 ` [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper Sergei Shtylyov
6 siblings, 0 replies; 11+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-12-21 21:00 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: dynamic allocation of device structures
Allocate device structures dynamically instead of having them embedded
in ide_hwif_t:
* Remove needless zeroing of port structure from ide_init_port_data().
* Add ide_hwif_t.devices[MAX_DRIVES] (table of pointers to the devices).
* Add ide_port_{alloc,free}_devices() helpers and use them respectively
in ide_{host,free}_alloc().
* Convert all users of ->drives[] to use ->devices[] instead.
While at it:
* Use drive->dn for the slave device check in scc_pata.c.
As a nice side-effect this patch cuts ~1kB (x86-32) from the resulting
code size:
text data bss dec hex filename
53963 1244 237 55444 d894 drivers/ide/ide-core.o.before
52981 1244 237 54462 d4be drivers/ide/ide-core.o.after
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-acpi.c | 10 +++---
drivers/ide/ide-iops.c | 4 +-
drivers/ide/ide-probe.c | 71 ++++++++++++++++++++++++++++++++++--------------
drivers/ide/ide-proc.c | 2 -
drivers/ide/ide.c | 2 -
drivers/ide/scc_pata.c | 5 ++-
include/linux/ide.h | 4 +-
7 files changed, 65 insertions(+), 33 deletions(-)
Index: b/drivers/ide/ide-acpi.c
===================================================================
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -656,7 +656,7 @@ void ide_acpi_set_state(ide_hwif_t *hwif
if (on)
acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
for (unit = 0; unit < MAX_DRIVES; ++unit) {
- ide_drive_t *drive = &hwif->drives[unit];
+ ide_drive_t *drive = hwif->devices[unit];
if (!drive->acpidata->obj_handle)
drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
@@ -711,14 +711,14 @@ void ide_acpi_port_init_devices(ide_hwif
* for both drives, regardless whether they are connected
* or not.
*/
- hwif->drives[0].acpidata = &hwif->acpidata->master;
- hwif->drives[1].acpidata = &hwif->acpidata->slave;
+ hwif->devices[0]->acpidata = &hwif->acpidata->master;
+ hwif->devices[1]->acpidata = &hwif->acpidata->slave;
/*
* Send IDENTIFY for each drive
*/
for (i = 0; i < MAX_DRIVES; i++) {
- drive = &hwif->drives[i];
+ drive = hwif->devices[i];
memset(drive->acpidata, 0, sizeof(*drive->acpidata));
@@ -745,7 +745,7 @@ void ide_acpi_port_init_devices(ide_hwif
ide_acpi_push_timing(hwif);
for (i = 0; i < MAX_DRIVES; i++) {
- drive = &hwif->drives[i];
+ drive = hwif->devices[i];
if (drive->dev_flags & IDE_DFLAG_PRESENT)
/* Execute ACPI startup code */
Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -1111,7 +1111,7 @@ static ide_startstop_t do_reset1 (ide_dr
prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE);
timeout = jiffies;
for (unit = 0; unit < MAX_DRIVES; unit++) {
- ide_drive_t *tdrive = &hwif->drives[unit];
+ ide_drive_t *tdrive = hwif->devices[unit];
if (tdrive->dev_flags & IDE_DFLAG_PRESENT &&
tdrive->dev_flags & IDE_DFLAG_PARKED &&
@@ -1134,7 +1134,7 @@ static ide_startstop_t do_reset1 (ide_dr
* for any of the drives on this interface.
*/
for (unit = 0; unit < MAX_DRIVES; ++unit)
- pre_reset(&hwif->drives[unit]);
+ pre_reset(hwif->devices[unit]);
if (io_ports->ctl_addr == 0) {
spin_unlock_irqrestore(&hwif->lock, flags);
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -463,7 +463,7 @@ static int do_probe (ide_drive_t *drive,
if (ide_read_device(drive) != drive->select && present == 0) {
if (drive->dn & 1) {
/* exit with drive0 selected */
- SELECT_DRIVE(&hwif->drives[0]);
+ SELECT_DRIVE(hwif->devices[0]);
/* allow ATA_BUSY to assert & clear */
msleep(50);
}
@@ -509,7 +509,7 @@ static int do_probe (ide_drive_t *drive,
}
if (drive->dn & 1) {
/* exit with drive0 selected */
- SELECT_DRIVE(&hwif->drives[0]);
+ SELECT_DRIVE(hwif->devices[0]);
msleep(50);
/* ensure drive irq is clear */
(void)tp_ops->read_status(hwif);
@@ -715,7 +715,7 @@ static int ide_port_wait_ready(ide_hwif_
/* Now make sure both master & slave are ready */
for (unit = 0; unit < MAX_DRIVES; unit++) {
- ide_drive_t *drive = &hwif->drives[unit];
+ ide_drive_t *drive = hwif->devices[unit];
/* Ignore disks that we will not probe for later. */
if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 ||
@@ -733,7 +733,7 @@ static int ide_port_wait_ready(ide_hwif_
out:
/* Exit function with master reselected (let's be sane) */
if (unit)
- SELECT_DRIVE(&hwif->drives[0]);
+ SELECT_DRIVE(hwif->devices[0]);
return rc;
}
@@ -749,7 +749,7 @@ out:
void ide_undecoded_slave(ide_drive_t *dev1)
{
- ide_drive_t *dev0 = &dev1->hwif->drives[0];
+ ide_drive_t *dev0 = dev1->hwif->devices[0];
if ((dev1->dn & 1) == 0 || (dev0->dev_flags & IDE_DFLAG_PRESENT) == 0)
return;
@@ -784,8 +784,8 @@ static int ide_probe_port(ide_hwif_t *hw
BUG_ON(hwif->present);
- if ((hwif->drives[0].dev_flags & IDE_DFLAG_NOPROBE) &&
- (hwif->drives[1].dev_flags & IDE_DFLAG_NOPROBE))
+ if ((hwif->devices[0]->dev_flags & IDE_DFLAG_NOPROBE) &&
+ (hwif->devices[1]->dev_flags & IDE_DFLAG_NOPROBE))
return -EACCES;
/*
@@ -807,7 +807,7 @@ static int ide_probe_port(ide_hwif_t *hw
* but a lot of cdrom drives are configured as single slaves.
*/
for (unit = 0; unit < MAX_DRIVES; ++unit) {
- ide_drive_t *drive = &hwif->drives[unit];
+ ide_drive_t *drive = hwif->devices[unit];
(void) probe_for_drive(drive);
if (drive->dev_flags & IDE_DFLAG_PRESENT)
@@ -832,7 +832,7 @@ static void ide_port_tune_devices(ide_hw
int unit;
for (unit = 0; unit < MAX_DRIVES; unit++) {
- ide_drive_t *drive = &hwif->drives[unit];
+ ide_drive_t *drive = hwif->devices[unit];
if (drive->dev_flags & IDE_DFLAG_PRESENT) {
if (port_ops && port_ops->quirkproc)
@@ -841,7 +841,7 @@ static void ide_port_tune_devices(ide_hw
}
for (unit = 0; unit < MAX_DRIVES; ++unit) {
- ide_drive_t *drive = &hwif->drives[unit];
+ ide_drive_t *drive = hwif->devices[unit];
if (drive->dev_flags & IDE_DFLAG_PRESENT) {
ide_set_max_pio(drive);
@@ -854,7 +854,7 @@ static void ide_port_tune_devices(ide_hw
}
for (unit = 0; unit < MAX_DRIVES; ++unit) {
- ide_drive_t *drive = &hwif->drives[unit];
+ ide_drive_t *drive = hwif->devices[unit];
if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) ||
drive->id[ATA_ID_DWORD_IO])
@@ -931,7 +931,7 @@ static int ide_port_setup_devices(ide_hw
mutex_lock(&ide_cfg_mtx);
for (i = 0; i < MAX_DRIVES; i++) {
- ide_drive_t *drive = &hwif->drives[i];
+ ide_drive_t *drive = hwif->devices[i];
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
continue;
@@ -1017,7 +1017,7 @@ static struct kobject *ata_probe(dev_t d
{
ide_hwif_t *hwif = data;
int unit = *part >> PARTN_BITS;
- ide_drive_t *drive = &hwif->drives[unit];
+ ide_drive_t *drive = hwif->devices[unit];
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
return NULL;
@@ -1164,7 +1164,7 @@ static void hwif_register_devices(ide_hw
unsigned int i;
for (i = 0; i < MAX_DRIVES; i++) {
- ide_drive_t *drive = &hwif->drives[i];
+ ide_drive_t *drive = hwif->devices[i];
struct device *dev = &drive->gendev;
int ret;
@@ -1190,7 +1190,7 @@ static void ide_port_init_devices(ide_hw
int i;
for (i = 0; i < MAX_DRIVES; i++) {
- ide_drive_t *drive = &hwif->drives[i];
+ ide_drive_t *drive = hwif->devices[i];
drive->dn = i + hwif->channel * 2;
@@ -1285,7 +1285,7 @@ static void ide_port_init_devices_data(i
int unit;
for (unit = 0; unit < MAX_DRIVES; ++unit) {
- ide_drive_t *drive = &hwif->drives[unit];
+ ide_drive_t *drive = hwif->devices[unit];
u8 j = (hwif->index * MAX_DRIVES) + unit;
memset(drive, 0, sizeof(*drive));
@@ -1309,9 +1309,6 @@ static void ide_port_init_devices_data(i
static void ide_init_port_data(ide_hwif_t *hwif, unsigned int index)
{
- /* bulk initialize hwif & drive info with zeros */
- memset(hwif, 0, sizeof(ide_hwif_t));
-
/* fill in any non-zero initial values */
hwif->index = index;
hwif->major = ide_hwif_to_major[index];
@@ -1388,6 +1385,34 @@ static void ide_free_port_slot(int idx)
mutex_unlock(&ide_cfg_mtx);
}
+static void ide_port_free_devices(ide_hwif_t *hwif)
+{
+ int i;
+
+ for (i = 0; i < MAX_DRIVES; i++)
+ kfree(hwif->devices[i]);
+}
+
+static int ide_port_alloc_devices(ide_hwif_t *hwif, int node)
+{
+ int i;
+
+ for (i = 0; i < MAX_DRIVES; i++) {
+ ide_drive_t *drive;
+
+ drive = kzalloc_node(sizeof(*drive), GFP_KERNEL, node);
+ if (drive == NULL)
+ goto out_nomem;
+
+ hwif->devices[i] = drive;
+ }
+ return 0;
+
+out_nomem:
+ ide_port_free_devices(hwif);
+ return -ENOMEM;
+}
+
struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws)
{
struct ide_host *host;
@@ -1410,6 +1435,11 @@ struct ide_host *ide_host_alloc(const st
if (hwif == NULL)
continue;
+ if (ide_port_alloc_devices(hwif, node) < 0) {
+ kfree(hwif);
+ continue;
+ }
+
idx = ide_find_port_slot(d);
if (idx < 0) {
printk(KERN_ERR "%s: no free slot for interface\n",
@@ -1575,7 +1605,7 @@ static void __ide_port_unregister_device
int i;
for (i = 0; i < MAX_DRIVES; i++) {
- ide_drive_t *drive = &hwif->drives[i];
+ ide_drive_t *drive = hwif->devices[i];
if (drive->dev_flags & IDE_DFLAG_PRESENT) {
device_unregister(&drive->gendev);
@@ -1651,6 +1681,7 @@ void ide_host_free(struct ide_host *host
if (hwif == NULL)
continue;
+ ide_port_free_devices(hwif);
ide_free_port_slot(hwif->index);
kfree(hwif);
}
Index: b/drivers/ide/ide-proc.c
===================================================================
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -599,7 +599,7 @@ void ide_proc_port_register_devices(ide_
char name[64];
for (d = 0; d < MAX_DRIVES; d++) {
- ide_drive_t *drive = &hwif->drives[d];
+ ide_drive_t *drive = hwif->devices[d];
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc)
continue;
Index: b/drivers/ide/ide.c
===================================================================
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -497,7 +497,7 @@ void ide_port_apply_params(ide_hwif_t *h
}
for (i = 0; i < MAX_DRIVES; i++)
- ide_dev_apply_params(&hwif->drives[i], i);
+ ide_dev_apply_params(hwif->devices[i], i);
}
/*
Index: b/drivers/ide/scc_pata.c
===================================================================
--- a/drivers/ide/scc_pata.c
+++ b/drivers/ide/scc_pata.c
@@ -259,7 +259,7 @@ static void scc_set_dma_mode(ide_drive_t
unsigned long scrcst_port = ctl_base + 0x014;
unsigned long udenvt_port = ctl_base + 0x018;
unsigned long tdvhsel_port = ctl_base + 0x020;
- int is_slave = (&hwif->drives[1] == drive);
+ int is_slave = drive->dn & 1;
int offset, idx;
unsigned long reg;
unsigned long jcactsel;
@@ -413,7 +413,8 @@ static int scc_dma_end(ide_drive_t *driv
if (rq)
rq->errors |= ERROR_RESET;
for (unit = 0; unit < MAX_DRIVES; unit++) {
- ide_drive_t *drive = &hwif->drives[unit];
+ ide_drive_t *drive = hwif->devices[unit];
+
drive->crc_count++;
}
}
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -753,7 +753,7 @@ typedef struct hwif_s {
unsigned long sata_scr[SATA_NR_PORTS];
- ide_drive_t drives[MAX_DRIVES]; /* drive info */
+ ide_drive_t *devices[MAX_DRIVES];
u8 major; /* our major number */
u8 index; /* 0 for ide0; 1 for ide1; ... */
@@ -1599,7 +1599,7 @@ static inline int hwif_to_node(ide_hwif_
static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive)
{
- ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1];
+ ide_drive_t *peer = drive->hwif->devices[(drive->dn ^ 1) & 1];
return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL;
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 7/7] ide: add port and host iterators
2008-12-21 21:00 [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper Bartlomiej Zolnierkiewicz
` (4 preceding siblings ...)
2008-12-21 21:00 ` [PATCH 6/7] ide: dynamic allocation of device structures Bartlomiej Zolnierkiewicz
@ 2008-12-21 21:00 ` Bartlomiej Zolnierkiewicz
2008-12-22 10:09 ` [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper Sergei Shtylyov
6 siblings, 0 replies; 11+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2008-12-21 21:00 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] 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: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-acpi.c | 14 ++-----
drivers/ide/ide-iops.c | 15 +++----
drivers/ide/ide-probe.c | 96 +++++++++++++++++++-----------------------------
drivers/ide/ide-proc.c | 7 +--
drivers/ide/ide.c | 5 +-
drivers/ide/scc_pata.c | 8 ++--
include/linux/ide.h | 11 ++++-
7 files changed, 69 insertions(+), 87 deletions(-)
Index: b/drivers/ide/ide-acpi.c
===================================================================
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -641,7 +641,8 @@ void ide_acpi_push_timing(ide_hwif_t *hw
*/
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)
return;
@@ -655,9 +656,8 @@ void ide_acpi_set_state(ide_hwif_t *hwif
/* channel first and then drives for power on and verse versa for power off */
if (on)
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)
drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
@@ -717,9 +717,7 @@ void ide_acpi_port_init_devices(ide_hwif
/*
* Send IDENTIFY for each drive
*/
- for (i = 0; i < MAX_DRIVES; i++) {
- drive = hwif->devices[i];
-
+ ide_port_for_each_dev(i, drive, hwif) {
memset(drive->acpidata, 0, sizeof(*drive->acpidata));
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
@@ -744,9 +742,7 @@ void ide_acpi_port_init_devices(ide_hwif
ide_acpi_get_timing(hwif);
ide_acpi_push_timing(hwif);
- for (i = 0; i < MAX_DRIVES; i++) {
- drive = hwif->devices[i];
-
+ ide_port_for_each_dev(i, drive, hwif) {
if (drive->dev_flags & IDE_DFLAG_PRESENT)
/* Execute ACPI startup code */
ide_acpi_exec_tfs(drive);
Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -1081,8 +1081,9 @@ static ide_startstop_t do_reset1 (ide_dr
struct ide_io_ports *io_ports = &hwif->io_ports;
const struct ide_tp_ops *tp_ops = hwif->tp_ops;
const struct ide_port_ops *port_ops;
+ ide_drive_t *tdrive;
unsigned long flags, timeout;
- unsigned int unit;
+ int i;
DEFINE_WAIT(wait);
spin_lock_irqsave(&hwif->lock, flags);
@@ -1110,11 +1111,9 @@ static ide_startstop_t do_reset1 (ide_dr
prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE);
timeout = jiffies;
- for (unit = 0; unit < MAX_DRIVES; unit++) {
- ide_drive_t *tdrive = hwif->devices[unit];
-
- if (tdrive->dev_flags & IDE_DFLAG_PRESENT &&
- tdrive->dev_flags & IDE_DFLAG_PARKED &&
+ ide_port_for_each_dev(i, tdrive, hwif) {
+ if (tdrive->dev_flags & IDE_DFLAG_PRESENT &&
+ tdrive->dev_flags & IDE_DFLAG_PARKED &&
time_after(tdrive->sleep, timeout))
timeout = tdrive->sleep;
}
@@ -1133,8 +1132,8 @@ static ide_startstop_t do_reset1 (ide_dr
* First, reset any device state data we were maintaining
* for any of the drives on this interface.
*/
- for (unit = 0; unit < MAX_DRIVES; ++unit)
- pre_reset(hwif->devices[unit]);
+ ide_port_for_each_dev(i, tdrive, hwif)
+ pre_reset(tdrive);
if (io_ports->ctl_addr == 0) {
spin_unlock_irqrestore(&hwif->lock, flags);
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -697,7 +697,8 @@ out:
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);
@@ -714,9 +715,7 @@ static int ide_port_wait_ready(ide_hwif_
return rc;
/* Now make sure both master & slave are ready */
- for (unit = 0; unit < MAX_DRIVES; unit++) {
- ide_drive_t *drive = hwif->devices[unit];
-
+ ide_port_for_each_dev(i, drive, hwif) {
/* Ignore disks that we will not probe for later. */
if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 ||
(drive->dev_flags & IDE_DFLAG_PRESENT)) {
@@ -732,7 +731,7 @@ static int ide_port_wait_ready(ide_hwif_
}
out:
/* Exit function with master reselected (let's be sane) */
- if (unit)
+ if (i)
SELECT_DRIVE(hwif->devices[0]);
return rc;
@@ -778,9 +777,10 @@ EXPORT_SYMBOL_GPL(ide_undecoded_slave);
static int ide_probe_port(ide_hwif_t *hwif)
{
+ ide_drive_t *drive;
unsigned long flags;
unsigned int irqd;
- int unit, rc = -ENODEV;
+ int i, rc = -ENODEV;
BUG_ON(hwif->present);
@@ -806,9 +806,7 @@ static int ide_probe_port(ide_hwif_t *hw
* Second drive should only exist if first drive was found,
* but a lot of cdrom drives are configured as single slaves.
*/
- for (unit = 0; unit < MAX_DRIVES; ++unit) {
- ide_drive_t *drive = hwif->devices[unit];
-
+ ide_port_for_each_dev(i, drive, hwif) {
(void) probe_for_drive(drive);
if (drive->dev_flags & IDE_DFLAG_PRESENT)
rc = 0;
@@ -829,20 +827,17 @@ static int ide_probe_port(ide_hwif_t *hw
static void ide_port_tune_devices(ide_hwif_t *hwif)
{
const struct ide_port_ops *port_ops = hwif->port_ops;
- int unit;
-
- for (unit = 0; unit < MAX_DRIVES; unit++) {
- ide_drive_t *drive = hwif->devices[unit];
+ ide_drive_t *drive;
+ int i;
+ ide_port_for_each_dev(i, drive, hwif) {
if (drive->dev_flags & IDE_DFLAG_PRESENT) {
if (port_ops && port_ops->quirkproc)
port_ops->quirkproc(drive);
}
}
- 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) {
ide_set_max_pio(drive);
@@ -853,9 +848,7 @@ static void ide_port_tune_devices(ide_hw
}
}
- for (unit = 0; unit < MAX_DRIVES; ++unit) {
- ide_drive_t *drive = hwif->devices[unit];
-
+ ide_port_for_each_dev(i, drive, hwif) {
if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) ||
drive->id[ATA_ID_DWORD_IO])
drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT;
@@ -927,12 +920,11 @@ static DEFINE_MUTEX(ide_cfg_mtx);
*/
static int ide_port_setup_devices(ide_hwif_t *hwif)
{
+ ide_drive_t *drive;
int i, j = 0;
mutex_lock(&ide_cfg_mtx);
- for (i = 0; i < MAX_DRIVES; i++) {
- ide_drive_t *drive = hwif->devices[i];
-
+ ide_port_for_each_dev(i, drive, hwif) {
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
continue;
@@ -1161,10 +1153,10 @@ out:
static void hwif_register_devices(ide_hwif_t *hwif)
{
+ ide_drive_t *drive;
unsigned int i;
- for (i = 0; i < MAX_DRIVES; i++) {
- ide_drive_t *drive = hwif->devices[i];
+ ide_port_for_each_dev(i, drive, hwif) {
struct device *dev = &drive->gendev;
int ret;
@@ -1187,11 +1179,10 @@ static void hwif_register_devices(ide_hw
static void ide_port_init_devices(ide_hwif_t *hwif)
{
const struct ide_port_ops *port_ops = hwif->port_ops;
+ ide_drive_t *drive;
int i;
- for (i = 0; i < MAX_DRIVES; i++) {
- ide_drive_t *drive = hwif->devices[i];
-
+ ide_port_for_each_dev(i, drive, hwif) {
drive->dn = i + hwif->channel * 2;
if (hwif->host_flags & IDE_HFLAG_IO_32BIT)
@@ -1282,16 +1273,16 @@ static const u8 ide_hwif_to_major[] =
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_drive_t *drive = hwif->devices[unit];
- u8 j = (hwif->index * MAX_DRIVES) + unit;
+ ide_port_for_each_dev(i, drive, hwif) {
+ u8 j = (hwif->index * MAX_DRIVES) + i;
memset(drive, 0, sizeof(*drive));
drive->media = ide_disk;
- drive->select = (unit << 4) | ATA_DEVICE_OBS;
+ drive->select = (i << 4) | ATA_DEVICE_OBS;
drive->hwif = hwif;
drive->ready_stat = ATA_DRDY;
drive->bad_wstat = BAD_W_STAT;
@@ -1387,10 +1378,11 @@ static void ide_free_port_slot(int idx)
static void ide_port_free_devices(ide_hwif_t *hwif)
{
+ ide_drive_t *drive;
int i;
- for (i = 0; i < MAX_DRIVES; i++)
- kfree(hwif->devices[i]);
+ ide_port_for_each_dev(i, drive, hwif)
+ kfree(drive);
}
static int ide_port_alloc_devices(ide_hwif_t *hwif, int node)
@@ -1478,9 +1470,7 @@ int ide_host_register(struct ide_host *h
ide_hwif_t *hwif, *mate = NULL;
int i, j = 0;
- for (i = 0; i < MAX_HOST_PORTS; i++) {
- hwif = host->ports[i];
-
+ ide_host_for_each_port(i, hwif, host) {
if (hwif == NULL) {
mate = NULL;
continue;
@@ -1506,9 +1496,7 @@ int ide_host_register(struct ide_host *h
ide_port_init_devices(hwif);
}
- for (i = 0; i < MAX_HOST_PORTS; i++) {
- hwif = host->ports[i];
-
+ ide_host_for_each_port(i, hwif, host) {
if (hwif == NULL)
continue;
@@ -1523,9 +1511,7 @@ int ide_host_register(struct ide_host *h
ide_port_tune_devices(hwif);
}
- for (i = 0; i < MAX_HOST_PORTS; i++) {
- hwif = host->ports[i];
-
+ ide_host_for_each_port(i, hwif, host) {
if (hwif == NULL)
continue;
@@ -1550,9 +1536,7 @@ int ide_host_register(struct ide_host *h
ide_acpi_port_init_devices(hwif);
}
- for (i = 0; i < MAX_HOST_PORTS; i++) {
- hwif = host->ports[i];
-
+ ide_host_for_each_port(i, hwif, host) {
if (hwif == NULL)
continue;
@@ -1560,9 +1544,7 @@ int ide_host_register(struct ide_host *h
hwif_register_devices(hwif);
}
- for (i = 0; i < MAX_HOST_PORTS; i++) {
- hwif = host->ports[i];
-
+ ide_host_for_each_port(i, hwif, host) {
if (hwif == NULL)
continue;
@@ -1602,11 +1584,10 @@ EXPORT_SYMBOL_GPL(ide_host_add);
static void __ide_port_unregister_devices(ide_hwif_t *hwif)
{
+ ide_drive_t *drive;
int i;
- for (i = 0; i < MAX_DRIVES; i++) {
- ide_drive_t *drive = hwif->devices[i];
-
+ ide_port_for_each_dev(i, drive, hwif) {
if (drive->dev_flags & IDE_DFLAG_PRESENT) {
device_unregister(&drive->gendev);
wait_for_completion(&drive->gendev_rel_comp);
@@ -1675,9 +1656,7 @@ void ide_host_free(struct ide_host *host
ide_hwif_t *hwif;
int i;
- for (i = 0; i < MAX_HOST_PORTS; i++) {
- hwif = host->ports[i];
-
+ ide_host_for_each_port(i, hwif, host) {
if (hwif == NULL)
continue;
@@ -1692,11 +1671,12 @@ EXPORT_SYMBOL_GPL(ide_host_free);
void ide_host_remove(struct ide_host *host)
{
+ ide_hwif_t *hwif;
int i;
- for (i = 0; i < MAX_HOST_PORTS; i++) {
- if (host->ports[i])
- ide_unregister(host->ports[i]);
+ ide_host_for_each_port(i, hwif, host) {
+ if (hwif)
+ ide_unregister(hwif);
}
ide_host_free(host);
Index: b/drivers/ide/ide-proc.c
===================================================================
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -593,14 +593,13 @@ EXPORT_SYMBOL(ide_proc_unregister_driver
void ide_proc_port_register_devices(ide_hwif_t *hwif)
{
- int d;
struct proc_dir_entry *ent;
struct proc_dir_entry *parent = hwif->proc;
+ ide_drive_t *drive;
char name[64];
+ int i;
- for (d = 0; d < MAX_DRIVES; d++) {
- ide_drive_t *drive = hwif->devices[d];
-
+ ide_port_for_each_dev(i, drive, hwif) {
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc)
continue;
Index: b/drivers/ide/ide.c
===================================================================
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -488,6 +488,7 @@ MODULE_PARM_DESC(ignore_cable, "ignore c
void ide_port_apply_params(ide_hwif_t *hwif)
{
+ ide_drive_t *drive;
int i;
if (ide_ignore_cable & (1 << hwif->index)) {
@@ -496,8 +497,8 @@ void ide_port_apply_params(ide_hwif_t *h
hwif->cbl = ATA_CBL_PATA40_SHORT;
}
- for (i = 0; i < MAX_DRIVES; i++)
- ide_dev_apply_params(hwif->devices[i], i);
+ ide_port_for_each_dev(i, drive, hwif)
+ ide_dev_apply_params(drive, i);
}
/*
Index: b/drivers/ide/scc_pata.c
===================================================================
--- a/drivers/ide/scc_pata.c
+++ b/drivers/ide/scc_pata.c
@@ -406,17 +406,17 @@ static int scc_dma_end(ide_drive_t *driv
data_loss = 1;
if (retry++) {
struct request *rq = hwif->rq;
- int unit;
+ ide_drive_t *drive;
+ int i;
+
/* ERROR_RESET and drive->crc_count are needed
* to reduce DMA transfer mode in retry process.
*/
if (rq)
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++;
- }
}
}
}
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -753,7 +753,7 @@ typedef struct hwif_s {
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 index; /* 0 for ide0; 1 for ide1; ... */
@@ -860,7 +860,7 @@ typedef struct hwif_s {
#define MAX_HOST_PORTS 4
struct ide_host {
- ide_hwif_t *ports[MAX_HOST_PORTS];
+ ide_hwif_t *ports[MAX_HOST_PORTS + 1];
unsigned int n_ports;
struct device *dev[2];
unsigned int (*init_chipset)(struct pci_dev *);
@@ -1603,4 +1603,11 @@ static inline ide_drive_t *ide_get_pair_
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 */
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/7] cmd64x: use ide_get_pair_dev() helper
2008-12-21 21:00 ` [PATCH 3/7] cmd64x: " Bartlomiej Zolnierkiewicz
@ 2008-12-22 10:07 ` Sergei Shtylyov
0 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2008-12-22 10:07 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, linux-kernel
Hello.
Bartlomiej Zolnierkiewicz wrote:
> From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> Subject: [PATCH] cmd64x: use ide_get_pair_dev() helper
>
> There should be no functional changes caused by this patch.
>
> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
MBR, Sergei
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 2/7] cmd640: use ide_get_pair_dev() helper
2008-12-21 21:00 ` [PATCH 2/7] cmd640: " Bartlomiej Zolnierkiewicz
@ 2008-12-22 10:08 ` Sergei Shtylyov
0 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2008-12-22 10:08 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, linux-kernel
Bartlomiej Zolnierkiewicz wrote:
> From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> Subject: [PATCH] cmd640: use ide_get_pair_dev() helper
>
> There should be no functional changes caused by this patch.
>
> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
MBR, Sergei
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper
2008-12-21 21:00 [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper Bartlomiej Zolnierkiewicz
` (5 preceding siblings ...)
2008-12-21 21:00 ` [PATCH 7/7] ide: add port and host iterators Bartlomiej Zolnierkiewicz
@ 2008-12-22 10:09 ` Sergei Shtylyov
6 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2008-12-22 10:09 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, linux-kernel
Bartlomiej Zolnierkiewicz wrote:
> From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> Subject: [PATCH] amd74xx: use ide_get_pair_dev() helper
>
> There should be no functional changes caused by this patch.
>
> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
MBR, Sergei
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/7] it821x: use ide_get_pair_dev() helper
2008-12-21 21:00 ` [PATCH 4/7] it821x: " Bartlomiej Zolnierkiewicz
@ 2008-12-22 10:11 ` Sergei Shtylyov
0 siblings, 0 replies; 11+ messages in thread
From: Sergei Shtylyov @ 2008-12-22 10:11 UTC (permalink / raw)
To: Bartlomiej Zolnierkiewicz; +Cc: linux-ide, linux-kernel
Bartlomiej Zolnierkiewicz wrote:
> Because presence of the peer device was not checked in
> it821x_set_pio_mode() PIO0 mode was used for taskfile PIO
> in single device configurations.
>
> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
>
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
> Index: b/drivers/ide/it821x.c
> ===================================================================
> --- a/drivers/ide/it821x.c
> +++ b/drivers/ide/it821x.c
> @@ -167,12 +167,10 @@ static void it821x_clock_strategy(ide_dr
> ide_hwif_t *hwif = drive->hwif;
> struct pci_dev *dev = to_pci_dev(hwif->dev);
> struct it821x_dev *itdev = ide_get_hwifdata(hwif);
> - ide_drive_t *pair;
> + ide_drive_t *pair = ide_get_pair_dev(drive);
> int clock, altclock, sel = 0;
> u8 unit = drive->dn & 1, v;
>
> - pair = &hwif->drives[1 - unit];
> -
> if(itdev->want[0][0] > itdev->want[1][0]) {
> clock = itdev->want[0][1];
> altclock = itdev->want[1][1];
> @@ -239,15 +237,13 @@ static void it821x_set_pio_mode(ide_driv
> {
> ide_hwif_t *hwif = drive->hwif;
> struct it821x_dev *itdev = ide_get_hwifdata(hwif);
> - ide_drive_t *pair;
> + ide_drive_t *pair = ide_get_pair_dev(drive);
> u8 unit = drive->dn & 1, set_pio = pio;
>
> /* Spec says 89 ref driver uses 88 */
> static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 };
> static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY };
>
> - pair = &hwif->drives[1 - unit];
> -
> /*
> * Compute the best PIO mode we can for a given device. We must
> * pick a speed that does not cause problems with the other device
I wonder why this driver was testing 'pair', there was absolutely no
chance for it being NULL. :-)
MBR, Sergei
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-12-22 10:11 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-21 21:00 [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper Bartlomiej Zolnierkiewicz
2008-12-21 21:00 ` [PATCH 2/7] cmd640: " Bartlomiej Zolnierkiewicz
2008-12-22 10:08 ` Sergei Shtylyov
2008-12-21 21:00 ` [PATCH 3/7] cmd64x: " Bartlomiej Zolnierkiewicz
2008-12-22 10:07 ` Sergei Shtylyov
2008-12-21 21:00 ` [PATCH 4/7] it821x: " Bartlomiej Zolnierkiewicz
2008-12-22 10:11 ` Sergei Shtylyov
2008-12-21 21:00 ` [PATCH 5/7] ide: NUMA aware allocation of host and port structures Bartlomiej Zolnierkiewicz
2008-12-21 21:00 ` [PATCH 6/7] ide: dynamic allocation of device structures Bartlomiej Zolnierkiewicz
2008-12-21 21:00 ` [PATCH 7/7] ide: add port and host iterators Bartlomiej Zolnierkiewicz
2008-12-22 10:09 ` [PATCH 1/7] amd74xx: use ide_get_pair_dev() helper Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).