Skip to content

Commit 123995b

Browse files
committed
ide: use 'drive->dn & 1' instead of drive->select.b.unit
* Call ide_port_init_devices() in ide_host_register() also if 'struct ide_port_info *d' is not available. * Init drive->dn in ide_port_init_devices() instead of ide_probe_port() so it is valid also in ->init_dev. * Pass device number to ide_dev_apply_params(). * Use 'drive->dn & 1' instead of drive->select.b.unit. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 8595259 commit 123995b

19 files changed

Lines changed: 66 additions & 72 deletions

‎drivers/ide/ide-dma.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static int dma_timer_expiry (ide_drive_t *drive)
370370
void ide_dma_host_set(ide_drive_t *drive, int on)
371371
{
372372
ide_hwif_t *hwif = HWIF(drive);
373-
u8 unit = (drive->select.b.unit & 0x01);
373+
u8 unit = drive->dn & 1;
374374
u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
375375

376376
if (on)

‎drivers/ide/ide-probe.c‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
447447
msleep(50);
448448

449449
if (ide_read_device(drive) != drive->select.all && present == 0) {
450-
if (drive->select.b.unit != 0) {
450+
if (drive->dn & 1) {
451451
/* exit with drive0 selected */
452452
SELECT_DRIVE(&hwif->drives[0]);
453453
/* allow ATA_BUSY to assert & clear */
@@ -493,7 +493,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
493493
/* not present or maybe ATAPI */
494494
rc = 3;
495495
}
496-
if (drive->select.b.unit != 0) {
496+
if (drive->dn & 1) {
497497
/* exit with drive0 selected */
498498
SELECT_DRIVE(&hwif->drives[0]);
499499
msleep(50);
@@ -798,7 +798,7 @@ static int ide_probe_port(ide_hwif_t *hwif)
798798
*/
799799
for (unit = 0; unit < MAX_DRIVES; ++unit) {
800800
ide_drive_t *drive = &hwif->drives[unit];
801-
drive->dn = (hwif->channel ? 2 : 0) + unit;
801+
802802
(void) probe_for_drive(drive);
803803
if (drive->dev_flags & IDE_DFLAG_PRESENT)
804804
rc = 0;
@@ -1357,6 +1357,8 @@ static void ide_port_init_devices(ide_hwif_t *hwif)
13571357
for (i = 0; i < MAX_DRIVES; i++) {
13581358
ide_drive_t *drive = &hwif->drives[i];
13591359

1360+
drive->dn = i + hwif->channel * 2;
1361+
13601362
if (hwif->host_flags & IDE_HFLAG_IO_32BIT)
13611363
drive->io_32bit = 1;
13621364
if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS)
@@ -1627,18 +1629,18 @@ int ide_host_register(struct ide_host *host, const struct ide_port_info *d,
16271629

16281630
if (d == NULL) {
16291631
mate = NULL;
1630-
continue;
1631-
}
1632+
} else {
1633+
if ((i & 1) && mate) {
1634+
hwif->mate = mate;
1635+
mate->mate = hwif;
1636+
}
16321637

1633-
if ((i & 1) && mate) {
1634-
hwif->mate = mate;
1635-
mate->mate = hwif;
1636-
}
1638+
mate = (i & 1) ? NULL : hwif;
16371639

1638-
mate = (i & 1) ? NULL : hwif;
1640+
ide_init_port(hwif, i & 1, d);
1641+
ide_port_cable_detect(hwif);
1642+
}
16391643

1640-
ide_init_port(hwif, i & 1, d);
1641-
ide_port_cable_detect(hwif);
16421644
ide_port_init_devices(hwif);
16431645
}
16441646

‎drivers/ide/ide.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,9 +713,9 @@ static int ide_set_disk_chs(const char *str, struct kernel_param *kp)
713713
module_param_call(chs, ide_set_disk_chs, NULL, NULL, 0);
714714
MODULE_PARM_DESC(chs, "force device as a disk (using CHS)");
715715

716-
static void ide_dev_apply_params(ide_drive_t *drive)
716+
static void ide_dev_apply_params(ide_drive_t *drive, u8 unit)
717717
{
718-
int i = drive->hwif->index * MAX_DRIVES + drive->select.b.unit;
718+
int i = drive->hwif->index * MAX_DRIVES + unit;
719719

720720
if (ide_nodma & (1 << i)) {
721721
printk(KERN_INFO "ide: disallowing DMA for %s\n", drive->name);
@@ -791,7 +791,7 @@ void ide_port_apply_params(ide_hwif_t *hwif)
791791
}
792792

793793
for (i = 0; i < MAX_DRIVES; i++)
794-
ide_dev_apply_params(&hwif->drives[i]);
794+
ide_dev_apply_params(&hwif->drives[i], i);
795795
}
796796

797797
/*

‎drivers/ide/legacy/ali14xx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static void ali14xx_set_pio_mode(ide_drive_t *drive, const u8 pio)
131131
drive->name, pio, time1, time2, param1, param2, param3, param4);
132132

133133
/* stuff timing parameters into controller registers */
134-
driveNum = (HWIF(drive)->index << 1) + drive->select.b.unit;
134+
driveNum = (drive->hwif->index << 1) + (drive->dn & 1);
135135
spin_lock_irqsave(&ali14xx_lock, flags);
136136
outb_p(regOn, basePort);
137137
outReg(param1, regTab[driveNum].reg1);

‎drivers/ide/legacy/qd65xx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ static void __init qd6580_init_dev(ide_drive_t *drive)
305305
} else
306306
t2 = t1 = hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA;
307307

308-
drive->drive_data = drive->select.b.unit ? t2 : t1;
308+
drive->drive_data = (drive->dn & 1) ? t2 : t1;
309309
}
310310

311311
static const struct ide_port_ops qd6500_port_ops = {

‎drivers/ide/pci/aec62xx.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed)
115115
struct pci_dev *dev = to_pci_dev(hwif->dev);
116116
struct ide_host *host = pci_get_drvdata(dev);
117117
struct chipset_bus_clock_list_entry *bus_clock = host->host_priv;
118-
u8 unit = (drive->select.b.unit & 0x01);
118+
u8 unit = drive->dn & 1;
119119
u8 tmp1 = 0, tmp2 = 0;
120120
u8 ultra = 0, drive_conf = 0, ultra_conf = 0;
121121
unsigned long flags;

‎drivers/ide/pci/alim15x3.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
7777
int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
7878
int port = hwif->channel ? 0x5c : 0x58;
7979
int portFIFO = hwif->channel ? 0x55 : 0x54;
80-
u8 cd_dma_fifo = 0;
81-
int unit = drive->select.b.unit & 1;
80+
u8 cd_dma_fifo = 0, unit = drive->dn & 1;
8281

8382
if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8)
8483
s_clc = 0;
@@ -112,7 +111,7 @@ static void ali_set_pio_mode(ide_drive_t *drive, const u8 pio)
112111
}
113112

114113
pci_write_config_byte(dev, port, s_clc);
115-
pci_write_config_byte(dev, port+drive->select.b.unit+2, (a_clc << 4) | r_clc);
114+
pci_write_config_byte(dev, port + unit + 2, (a_clc << 4) | r_clc);
116115
local_irq_restore(flags);
117116
}
118117

@@ -154,7 +153,7 @@ static void ali_set_dma_mode(ide_drive_t *drive, const u8 speed)
154153
ide_hwif_t *hwif = HWIF(drive);
155154
struct pci_dev *dev = to_pci_dev(hwif->dev);
156155
u8 speed1 = speed;
157-
u8 unit = (drive->select.b.unit & 0x01);
156+
u8 unit = drive->dn & 1;
158157
u8 tmpbyte = 0x00;
159158
int m5229_udma = (hwif->channel) ? 0x57 : 0x56;
160159

‎drivers/ide/pci/cmd640.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static void program_drive_counts(ide_drive_t *drive, unsigned int index)
468468
*/
469469
if (index > 1) {
470470
ide_hwif_t *hwif = drive->hwif;
471-
ide_drive_t *peer = &hwif->drives[!drive->select.b.unit];
471+
ide_drive_t *peer = &hwif->drives[!(drive->dn & 1)];
472472
unsigned int mate = index ^ 1;
473473

474474
if (peer->dev_flags & IDE_DFLAG_PRESENT) {
@@ -607,7 +607,7 @@ static void cmd640_set_pio_mode(ide_drive_t *drive, const u8 pio)
607607

608608
static void cmd640_init_dev(ide_drive_t *drive)
609609
{
610-
unsigned int i = drive->hwif->channel * 2 + drive->select.b.unit;
610+
unsigned int i = drive->hwif->channel * 2 + (drive->dn & 1);
611611

612612
#ifdef CONFIG_BLK_DEV_CMD640_ENHANCED
613613
/*

‎drivers/ide/pci/cs5535.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ static unsigned int cs5535_udma_timings[5] =
7676
static void cs5535_set_speed(ide_drive_t *drive, const u8 speed)
7777
{
7878
u32 reg = 0, dummy;
79-
int unit = drive->select.b.unit;
79+
u8 unit = drive->dn & 1;
8080

8181
/* Set the PIO timings */
8282
if (speed < XFER_SW_DMA_0) {

‎drivers/ide/pci/cy82c693.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ static void cy82c693_set_dma_mode(ide_drive_t *drive, const u8 mode)
178178

179179
#if CY82C693_DEBUG_INFO
180180
printk(KERN_INFO "%s (ch=%d, dev=%d): set DMA mode to %d (single=%d)\n",
181-
drive->name, HWIF(drive)->channel, drive->select.b.unit,
182-
mode & 3, single);
181+
drive->name, hwif->channel, drive->dn & 1, mode & 3, single);
183182
#endif /* CY82C693_DEBUG_INFO */
184183

185184
/*
@@ -224,7 +223,7 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
224223
compute_clocks(pio, &pclk);
225224

226225
/* now let's write the clocks registers */
227-
if (drive->select.b.unit == 0) {
226+
if ((drive->dn & 1) == 0) {
228227
/*
229228
* set master drive
230229
* address setup control register
@@ -266,7 +265,7 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
266265
#if CY82C693_DEBUG_INFO
267266
printk(KERN_INFO "%s (ch=%d, dev=%d): set PIO timing to "
268267
"(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n",
269-
drive->name, hwif->channel, drive->select.b.unit,
268+
drive->name, hwif->channel, drive->dn & 1,
270269
addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8);
271270
#endif /* CY82C693_DEBUG_INFO */
272271
}

0 commit comments

Comments
 (0)