Skip to content

Commit abb596b

Browse files
Sergei Shtylyovbzolnier
authored andcommitted
ide: turn selectproc() method into dev_select() method (take 5)
Turn selectproc() method into dev_select() method by teaching it to write to the device register and moving it from 'struct ide_port_ops' to 'struct ide_tp_ops'. Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com> Cc: benh@kernel.crashing.org Cc: petkovbb@gmail.com [bart: add ->dev_select to at91_ide.c and tx4939.c (__BIG_ENDIAN case)] Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
1 parent 0f861e8 commit abb596b

17 files changed

Lines changed: 139 additions & 48 deletions

‎drivers/ide/at91_ide.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ static const struct ide_tp_ops at91_ide_tp_ops = {
283283
.read_altstatus = ide_read_altstatus,
284284
.write_devctl = ide_write_devctl,
285285

286+
.dev_select = ide_dev_select,
286287
.tf_load = at91_ide_tf_load,
287288
.tf_read = at91_ide_tf_read,
288289

‎drivers/ide/au1xxx-ide.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ static const struct ide_tp_ops au1xxx_tp_ops = {
469469
.read_altstatus = ide_read_altstatus,
470470
.write_devctl = ide_write_devctl,
471471

472+
.dev_select = ide_dev_select,
472473
.tf_load = ide_tf_load,
473474
.tf_read = ide_tf_read,
474475

‎drivers/ide/falconide.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static const struct ide_tp_ops falconide_tp_ops = {
9191
.read_altstatus = ide_read_altstatus,
9292
.write_devctl = ide_write_devctl,
9393

94+
.dev_select = ide_dev_select,
9495
.tf_load = ide_tf_load,
9596
.tf_read = ide_tf_read,
9697

‎drivers/ide/ht6560b.c‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
/*
104104
* This routine is invoked from ide.c to prepare for access to a given drive.
105105
*/
106-
static void ht6560b_selectproc (ide_drive_t *drive)
106+
static void ht6560b_dev_select(ide_drive_t *drive)
107107
{
108108
ide_hwif_t *hwif = drive->hwif;
109109
unsigned long flags;
@@ -143,6 +143,8 @@ static void ht6560b_selectproc (ide_drive_t *drive)
143143
#endif
144144
}
145145
local_irq_restore(flags);
146+
147+
outb(drive->select | ATA_DEVICE_OBS, hwif->io_ports.device_addr);
146148
}
147149

148150
/*
@@ -305,15 +307,29 @@ static int probe_ht6560b;
305307
module_param_named(probe, probe_ht6560b, bool, 0);
306308
MODULE_PARM_DESC(probe, "probe for HT6560B chipset");
307309

310+
static const struct ide_tp_ops ht6560b_tp_ops = {
311+
.exec_command = ide_exec_command,
312+
.read_status = ide_read_status,
313+
.read_altstatus = ide_read_altstatus,
314+
.write_devctl = ide_write_devctl,
315+
316+
.dev_select = ht6560b_dev_select,
317+
.tf_load = ide_tf_load,
318+
.tf_read = ide_tf_read,
319+
320+
.input_data = ide_input_data,
321+
.output_data = ide_output_data,
322+
};
323+
308324
static const struct ide_port_ops ht6560b_port_ops = {
309325
.init_dev = ht6560b_init_dev,
310326
.set_pio_mode = ht6560b_set_pio_mode,
311-
.selectproc = ht6560b_selectproc,
312327
};
313328

314329
static const struct ide_port_info ht6560b_port_info __initdata = {
315330
.name = DRV_NAME,
316331
.chipset = ide_ht6560b,
332+
.tp_ops = &ht6560b_tp_ops,
317333
.port_ops = &ht6560b_port_ops,
318334
.host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */
319335
IDE_HFLAG_NO_DMA |

‎drivers/ide/ide-h8300.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ static const struct ide_tp_ops h8300_tp_ops = {
151151
.read_altstatus = ide_read_altstatus,
152152
.write_devctl = ide_write_devctl,
153153

154+
.dev_select = ide_dev_select,
154155
.tf_load = h8300_tf_load,
155156
.tf_read = h8300_tf_read,
156157

‎drivers/ide/ide-io-std.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ void ide_write_devctl(ide_hwif_t *hwif, u8 ctl)
7373
}
7474
EXPORT_SYMBOL_GPL(ide_write_devctl);
7575

76+
void ide_dev_select(ide_drive_t *drive)
77+
{
78+
ide_hwif_t *hwif = drive->hwif;
79+
u8 select = drive->select | ATA_DEVICE_OBS;
80+
81+
if (hwif->host_flags & IDE_HFLAG_MMIO)
82+
writeb(select, (void __iomem *)hwif->io_ports.device_addr);
83+
else
84+
outb(select, hwif->io_ports.device_addr);
85+
}
86+
EXPORT_SYMBOL_GPL(ide_dev_select);
87+
7688
void ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd)
7789
{
7890
ide_hwif_t *hwif = drive->hwif;
@@ -280,6 +292,7 @@ const struct ide_tp_ops default_tp_ops = {
280292
.read_altstatus = ide_read_altstatus,
281293
.write_devctl = ide_write_devctl,
282294

295+
.dev_select = ide_dev_select,
283296
.tf_load = ide_tf_load,
284297
.tf_read = ide_tf_read,
285298

‎drivers/ide/ide-iops.c‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,7 @@
2929

3030
void SELECT_DRIVE(ide_drive_t *drive)
3131
{
32-
ide_hwif_t *hwif = drive->hwif;
33-
const struct ide_port_ops *port_ops = hwif->port_ops;
34-
struct ide_cmd cmd;
35-
36-
if (port_ops && port_ops->selectproc)
37-
port_ops->selectproc(drive);
38-
39-
memset(&cmd, 0, sizeof(cmd));
40-
cmd.tf_flags = IDE_TFLAG_OUT_DEVICE;
41-
42-
drive->hwif->tp_ops->tf_load(drive, &cmd);
32+
drive->hwif->tp_ops->dev_select(drive);
4333
}
4434

4535
void SELECT_MASK(ide_drive_t *drive, int mask)

‎drivers/ide/ns87415.c‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,15 @@ static void superio_tf_read(ide_drive_t *drive, struct ide_cmd *cmd)
9898
}
9999
}
100100

101+
static void ns87415_dev_select(ide_drive_t *drive);
102+
101103
static const struct ide_tp_ops superio_tp_ops = {
102104
.exec_command = ide_exec_command,
103105
.read_status = superio_read_status,
104106
.read_altstatus = ide_read_altstatus,
105107
.write_devctl = ide_write_devctl,
106108

109+
.dev_select = ns87415_dev_select,
107110
.tf_load = ide_tf_load,
108111
.tf_read = superio_tf_read,
109112

@@ -182,10 +185,12 @@ static void ns87415_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
182185
local_irq_restore(flags);
183186
}
184187

185-
static void ns87415_selectproc (ide_drive_t *drive)
188+
static void ns87415_dev_select(ide_drive_t *drive)
186189
{
187190
ns87415_prepare_drive(drive,
188191
!!(drive->dev_flags & IDE_DFLAG_USING_DMA));
192+
193+
outb(drive->select | ATA_DEVICE_OBS, drive->hwif->io_ports.device_addr);
189194
}
190195

191196
static void ns87415_dma_start(ide_drive_t *drive)
@@ -229,7 +234,7 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
229234
* Also, leave IRQ masked during drive probing, to prevent infinite
230235
* interrupts from a potentially floating INTA..
231236
*
232-
* IRQs get unmasked in selectproc when drive is first used.
237+
* IRQs get unmasked in dev_select() when drive is first used.
233238
*/
234239
(void) pci_read_config_dword(dev, 0x40, &ctrl);
235240
(void) pci_read_config_byte(dev, 0x09, &progif);
@@ -281,8 +286,18 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif)
281286
outb(0x60, hwif->dma_base + ATA_DMA_STATUS);
282287
}
283288

284-
static const struct ide_port_ops ns87415_port_ops = {
285-
.selectproc = ns87415_selectproc,
289+
static const struct ide_tp_ops ns87415_tp_ops = {
290+
.exec_command = ide_exec_command,
291+
.read_status = ide_read_status,
292+
.read_altstatus = ide_read_altstatus,
293+
.write_devctl = ide_write_devctl,
294+
295+
.dev_select = ns87415_dev_select,
296+
.tf_load = ide_tf_load,
297+
.tf_read = ide_tf_read,
298+
299+
.input_data = ide_input_data,
300+
.output_data = ide_output_data,
286301
};
287302

288303
static const struct ide_dma_ops ns87415_dma_ops = {
@@ -299,7 +314,7 @@ static const struct ide_dma_ops ns87415_dma_ops = {
299314
static const struct ide_port_info ns87415_chipset __devinitdata = {
300315
.name = DRV_NAME,
301316
.init_hwif = init_hwif_ns87415,
302-
.port_ops = &ns87415_port_ops,
317+
.tp_ops = &ns87415_tp_ops,
303318
.dma_ops = &ns87415_dma_ops,
304319
.host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA |
305320
IDE_HFLAG_NO_ATAPI_DMA,

‎drivers/ide/pmac.c‎

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,6 @@ kauai_lookup_timing(struct kauai_timing* table, int cycle_time)
404404
#define IDE_WAKEUP_DELAY (1*HZ)
405405

406406
static int pmac_ide_init_dma(ide_hwif_t *, const struct ide_port_info *);
407-
static void pmac_ide_selectproc(ide_drive_t *drive);
408-
static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
409407

410408
#define PMAC_IDE_REG(x) \
411409
((void __iomem *)((drive)->hwif->io_ports.data_addr + (x)))
@@ -415,8 +413,7 @@ static void pmac_ide_kauai_selectproc(ide_drive_t *drive);
415413
* timing register when selecting that unit. This version is for
416414
* ASICs with a single timing register
417415
*/
418-
static void
419-
pmac_ide_selectproc(ide_drive_t *drive)
416+
static void pmac_ide_apply_timings(ide_drive_t *drive)
420417
{
421418
ide_hwif_t *hwif = drive->hwif;
422419
pmac_ide_hwif_t *pmif =
@@ -434,8 +431,7 @@ pmac_ide_selectproc(ide_drive_t *drive)
434431
* timing register when selecting that unit. This version is for
435432
* ASICs with a dual timing register (Kauai)
436433
*/
437-
static void
438-
pmac_ide_kauai_selectproc(ide_drive_t *drive)
434+
static void pmac_ide_kauai_apply_timings(ide_drive_t *drive)
439435
{
440436
ide_hwif_t *hwif = drive->hwif;
441437
pmac_ide_hwif_t *pmif =
@@ -464,9 +460,25 @@ pmac_ide_do_update_timings(ide_drive_t *drive)
464460
if (pmif->kind == controller_sh_ata6 ||
465461
pmif->kind == controller_un_ata6 ||
466462
pmif->kind == controller_k2_ata6)
467-
pmac_ide_kauai_selectproc(drive);
463+
pmac_ide_kauai_apply_timings(drive);
468464
else
469-
pmac_ide_selectproc(drive);
465+
pmac_ide_apply_timings(drive);
466+
}
467+
468+
static void pmac_dev_select(ide_drive_t *drive)
469+
{
470+
pmac_ide_apply_timings(drive);
471+
472+
writeb(drive->select | ATA_DEVICE_OBS,
473+
(void __iomem *)drive->hwif->io_ports.device_addr);
474+
}
475+
476+
static void pmac_kauai_dev_select(ide_drive_t *drive)
477+
{
478+
pmac_ide_kauai_apply_timings(drive);
479+
480+
writeb(drive->select | ATA_DEVICE_OBS,
481+
(void __iomem *)drive->hwif->io_ports.device_addr);
470482
}
471483

472484
static void pmac_exec_command(ide_hwif_t *hwif, u8 cmd)
@@ -947,34 +959,39 @@ static const struct ide_tp_ops pmac_tp_ops = {
947959
.read_altstatus = ide_read_altstatus,
948960
.write_devctl = pmac_write_devctl,
949961

962+
.dev_select = pmac_dev_select,
950963
.tf_load = ide_tf_load,
951964
.tf_read = ide_tf_read,
952965

953966
.input_data = ide_input_data,
954967
.output_data = ide_output_data,
955968
};
956969

957-
static const struct ide_port_ops pmac_ide_ata6_port_ops = {
958-
.init_dev = pmac_ide_init_dev,
959-
.set_pio_mode = pmac_ide_set_pio_mode,
960-
.set_dma_mode = pmac_ide_set_dma_mode,
961-
.selectproc = pmac_ide_kauai_selectproc,
962-
.cable_detect = pmac_ide_cable_detect,
970+
static const struct ide_tp_ops pmac_ata6_tp_ops = {
971+
.exec_command = pmac_exec_command,
972+
.read_status = ide_read_status,
973+
.read_altstatus = ide_read_altstatus,
974+
.write_devctl = pmac_write_devctl,
975+
976+
.dev_select = pmac_kauai_dev_select,
977+
.tf_load = ide_tf_load,
978+
.tf_read = ide_tf_read,
979+
980+
.input_data = ide_input_data,
981+
.output_data = ide_output_data,
963982
};
964983

965984
static const struct ide_port_ops pmac_ide_ata4_port_ops = {
966985
.init_dev = pmac_ide_init_dev,
967986
.set_pio_mode = pmac_ide_set_pio_mode,
968987
.set_dma_mode = pmac_ide_set_dma_mode,
969-
.selectproc = pmac_ide_selectproc,
970988
.cable_detect = pmac_ide_cable_detect,
971989
};
972990

973991
static const struct ide_port_ops pmac_ide_port_ops = {
974992
.init_dev = pmac_ide_init_dev,
975993
.set_pio_mode = pmac_ide_set_pio_mode,
976994
.set_dma_mode = pmac_ide_set_dma_mode,
977-
.selectproc = pmac_ide_selectproc,
978995
};
979996

980997
static const struct ide_dma_ops pmac_dma_ops;
@@ -1011,15 +1028,18 @@ static int __devinit pmac_ide_setup_device(pmac_ide_hwif_t *pmif, hw_regs_t *hw)
10111028
pmif->broken_dma = pmif->broken_dma_warn = 0;
10121029
if (of_device_is_compatible(np, "shasta-ata")) {
10131030
pmif->kind = controller_sh_ata6;
1014-
d.port_ops = &pmac_ide_ata6_port_ops;
1031+
d.tp_ops = &pmac_ata6_tp_ops;
1032+
d.port_ops = &pmac_ide_ata4_port_ops;
10151033
d.udma_mask = ATA_UDMA6;
10161034
} else if (of_device_is_compatible(np, "kauai-ata")) {
10171035
pmif->kind = controller_un_ata6;
1018-
d.port_ops = &pmac_ide_ata6_port_ops;
1036+
d.tp_ops = &pmac_ata6_tp_ops;
1037+
d.port_ops = &pmac_ide_ata4_port_ops;
10191038
d.udma_mask = ATA_UDMA5;
10201039
} else if (of_device_is_compatible(np, "K2-UATA")) {
10211040
pmif->kind = controller_k2_ata6;
1022-
d.port_ops = &pmac_ide_ata6_port_ops;
1041+
d.tp_ops = &pmac_ata6_tp_ops;
1042+
d.port_ops = &pmac_ide_ata4_port_ops;
10231043
d.udma_mask = ATA_UDMA5;
10241044
} else if (of_device_is_compatible(np, "keylargo-ata")) {
10251045
if (strcmp(np->name, "ata-4") == 0) {

‎drivers/ide/q40ide.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ static const struct ide_tp_ops q40ide_tp_ops = {
101101
.read_altstatus = ide_read_altstatus,
102102
.write_devctl = ide_write_devctl,
103103

104+
.dev_select = ide_dev_select,
104105
.tf_load = ide_tf_load,
105106
.tf_read = ide_tf_read,
106107

0 commit comments

Comments
 (0)