Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sergei Shtylyov and committed by
Bartlomiej Zolnierkiewicz
abb596b2 0f861e8c

+139 -48
+1
drivers/ide/at91_ide.c
··· 283 283 .read_altstatus = ide_read_altstatus, 284 284 .write_devctl = ide_write_devctl, 285 285 286 + .dev_select = ide_dev_select, 286 287 .tf_load = at91_ide_tf_load, 287 288 .tf_read = at91_ide_tf_read, 288 289
+1
drivers/ide/au1xxx-ide.c
··· 469 469 .read_altstatus = ide_read_altstatus, 470 470 .write_devctl = ide_write_devctl, 471 471 472 + .dev_select = ide_dev_select, 472 473 .tf_load = ide_tf_load, 473 474 .tf_read = ide_tf_read, 474 475
+1
drivers/ide/falconide.c
··· 91 91 .read_altstatus = ide_read_altstatus, 92 92 .write_devctl = ide_write_devctl, 93 93 94 + .dev_select = ide_dev_select, 94 95 .tf_load = ide_tf_load, 95 96 .tf_read = ide_tf_read, 96 97
+18 -2
drivers/ide/ht6560b.c
··· 103 103 /* 104 104 * This routine is invoked from ide.c to prepare for access to a given drive. 105 105 */ 106 - static void ht6560b_selectproc (ide_drive_t *drive) 106 + static void ht6560b_dev_select(ide_drive_t *drive) 107 107 { 108 108 ide_hwif_t *hwif = drive->hwif; 109 109 unsigned long flags; ··· 143 143 #endif 144 144 } 145 145 local_irq_restore(flags); 146 + 147 + outb(drive->select | ATA_DEVICE_OBS, hwif->io_ports.device_addr); 146 148 } 147 149 148 150 /* ··· 307 305 module_param_named(probe, probe_ht6560b, bool, 0); 308 306 MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); 309 307 308 + static const struct ide_tp_ops ht6560b_tp_ops = { 309 + .exec_command = ide_exec_command, 310 + .read_status = ide_read_status, 311 + .read_altstatus = ide_read_altstatus, 312 + .write_devctl = ide_write_devctl, 313 + 314 + .dev_select = ht6560b_dev_select, 315 + .tf_load = ide_tf_load, 316 + .tf_read = ide_tf_read, 317 + 318 + .input_data = ide_input_data, 319 + .output_data = ide_output_data, 320 + }; 321 + 310 322 static const struct ide_port_ops ht6560b_port_ops = { 311 323 .init_dev = ht6560b_init_dev, 312 324 .set_pio_mode = ht6560b_set_pio_mode, 313 - .selectproc = ht6560b_selectproc, 314 325 }; 315 326 316 327 static const struct ide_port_info ht6560b_port_info __initdata = { 317 328 .name = DRV_NAME, 318 329 .chipset = ide_ht6560b, 330 + .tp_ops = &ht6560b_tp_ops, 319 331 .port_ops = &ht6560b_port_ops, 320 332 .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */ 321 333 IDE_HFLAG_NO_DMA |
+1
drivers/ide/ide-h8300.c
··· 151 151 .read_altstatus = ide_read_altstatus, 152 152 .write_devctl = ide_write_devctl, 153 153 154 + .dev_select = ide_dev_select, 154 155 .tf_load = h8300_tf_load, 155 156 .tf_read = h8300_tf_read, 156 157
+13
drivers/ide/ide-io-std.c
··· 73 73 } 74 74 EXPORT_SYMBOL_GPL(ide_write_devctl); 75 75 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 + 76 88 void ide_tf_load(ide_drive_t *drive, struct ide_cmd *cmd) 77 89 { 78 90 ide_hwif_t *hwif = drive->hwif; ··· 292 280 .read_altstatus = ide_read_altstatus, 293 281 .write_devctl = ide_write_devctl, 294 282 283 + .dev_select = ide_dev_select, 295 284 .tf_load = ide_tf_load, 296 285 .tf_read = ide_tf_read, 297 286
+1 -11
drivers/ide/ide-iops.c
··· 29 29 30 30 void SELECT_DRIVE(ide_drive_t *drive) 31 31 { 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); 43 33 } 44 34 45 35 void SELECT_MASK(ide_drive_t *drive, int mask)
+20 -5
drivers/ide/ns87415.c
··· 98 98 } 99 99 } 100 100 101 + static void ns87415_dev_select(ide_drive_t *drive); 102 + 101 103 static const struct ide_tp_ops superio_tp_ops = { 102 104 .exec_command = ide_exec_command, 103 105 .read_status = superio_read_status, 104 106 .read_altstatus = ide_read_altstatus, 105 107 .write_devctl = ide_write_devctl, 106 108 109 + .dev_select = ns87415_dev_select, 107 110 .tf_load = ide_tf_load, 108 111 .tf_read = superio_tf_read, 109 112 ··· 185 182 local_irq_restore(flags); 186 183 } 187 184 188 - static void ns87415_selectproc (ide_drive_t *drive) 185 + static void ns87415_dev_select(ide_drive_t *drive) 189 186 { 190 187 ns87415_prepare_drive(drive, 191 188 !!(drive->dev_flags & IDE_DFLAG_USING_DMA)); 189 + 190 + outb(drive->select | ATA_DEVICE_OBS, drive->hwif->io_ports.device_addr); 192 191 } 193 192 194 193 static void ns87415_dma_start(ide_drive_t *drive) ··· 234 229 * Also, leave IRQ masked during drive probing, to prevent infinite 235 230 * interrupts from a potentially floating INTA.. 236 231 * 237 - * IRQs get unmasked in selectproc when drive is first used. 232 + * IRQs get unmasked in dev_select() when drive is first used. 238 233 */ 239 234 (void) pci_read_config_dword(dev, 0x40, &ctrl); 240 235 (void) pci_read_config_byte(dev, 0x09, &progif); ··· 286 281 outb(0x60, hwif->dma_base + ATA_DMA_STATUS); 287 282 } 288 283 289 - static const struct ide_port_ops ns87415_port_ops = { 290 - .selectproc = ns87415_selectproc, 284 + static const struct ide_tp_ops ns87415_tp_ops = { 285 + .exec_command = ide_exec_command, 286 + .read_status = ide_read_status, 287 + .read_altstatus = ide_read_altstatus, 288 + .write_devctl = ide_write_devctl, 289 + 290 + .dev_select = ns87415_dev_select, 291 + .tf_load = ide_tf_load, 292 + .tf_read = ide_tf_read, 293 + 294 + .input_data = ide_input_data, 295 + .output_data = ide_output_data, 291 296 }; 292 297 293 298 static const struct ide_dma_ops ns87415_dma_ops = { ··· 314 299 static const struct ide_port_info ns87415_chipset __devinitdata = { 315 300 .name = DRV_NAME, 316 301 .init_hwif = init_hwif_ns87415, 317 - .port_ops = &ns87415_port_ops, 302 + .tp_ops = &ns87415_tp_ops, 318 303 .dma_ops = &ns87415_dma_ops, 319 304 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | 320 305 IDE_HFLAG_NO_ATAPI_DMA,
+39 -19
drivers/ide/pmac.c
··· 404 404 #define IDE_WAKEUP_DELAY (1*HZ) 405 405 406 406 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); 409 407 410 408 #define PMAC_IDE_REG(x) \ 411 409 ((void __iomem *)((drive)->hwif->io_ports.data_addr + (x))) ··· 413 415 * timing register when selecting that unit. This version is for 414 416 * ASICs with a single timing register 415 417 */ 416 - static void 417 - pmac_ide_selectproc(ide_drive_t *drive) 418 + static void pmac_ide_apply_timings(ide_drive_t *drive) 418 419 { 419 420 ide_hwif_t *hwif = drive->hwif; 420 421 pmac_ide_hwif_t *pmif = ··· 431 434 * timing register when selecting that unit. This version is for 432 435 * ASICs with a dual timing register (Kauai) 433 436 */ 434 - static void 435 - pmac_ide_kauai_selectproc(ide_drive_t *drive) 437 + static void pmac_ide_kauai_apply_timings(ide_drive_t *drive) 436 438 { 437 439 ide_hwif_t *hwif = drive->hwif; 438 440 pmac_ide_hwif_t *pmif = ··· 460 464 if (pmif->kind == controller_sh_ata6 || 461 465 pmif->kind == controller_un_ata6 || 462 466 pmif->kind == controller_k2_ata6) 463 - pmac_ide_kauai_selectproc(drive); 467 + pmac_ide_kauai_apply_timings(drive); 464 468 else 465 - pmac_ide_selectproc(drive); 469 + pmac_ide_apply_timings(drive); 470 + } 471 + 472 + static void pmac_dev_select(ide_drive_t *drive) 473 + { 474 + pmac_ide_apply_timings(drive); 475 + 476 + writeb(drive->select | ATA_DEVICE_OBS, 477 + (void __iomem *)drive->hwif->io_ports.device_addr); 478 + } 479 + 480 + static void pmac_kauai_dev_select(ide_drive_t *drive) 481 + { 482 + pmac_ide_kauai_apply_timings(drive); 483 + 484 + writeb(drive->select | ATA_DEVICE_OBS, 485 + (void __iomem *)drive->hwif->io_ports.device_addr); 466 486 } 467 487 468 488 static void pmac_exec_command(ide_hwif_t *hwif, u8 cmd) ··· 959 947 .read_altstatus = ide_read_altstatus, 960 948 .write_devctl = pmac_write_devctl, 961 949 950 + .dev_select = pmac_dev_select, 962 951 .tf_load = ide_tf_load, 963 952 .tf_read = ide_tf_read, 964 953 ··· 967 954 .output_data = ide_output_data, 968 955 }; 969 956 970 - static const struct ide_port_ops pmac_ide_ata6_port_ops = { 971 - .init_dev = pmac_ide_init_dev, 972 - .set_pio_mode = pmac_ide_set_pio_mode, 973 - .set_dma_mode = pmac_ide_set_dma_mode, 974 - .selectproc = pmac_ide_kauai_selectproc, 975 - .cable_detect = pmac_ide_cable_detect, 957 + static const struct ide_tp_ops pmac_ata6_tp_ops = { 958 + .exec_command = pmac_exec_command, 959 + .read_status = ide_read_status, 960 + .read_altstatus = ide_read_altstatus, 961 + .write_devctl = pmac_write_devctl, 962 + 963 + .dev_select = pmac_kauai_dev_select, 964 + .tf_load = ide_tf_load, 965 + .tf_read = ide_tf_read, 966 + 967 + .input_data = ide_input_data, 968 + .output_data = ide_output_data, 976 969 }; 977 970 978 971 static const struct ide_port_ops pmac_ide_ata4_port_ops = { 979 972 .init_dev = pmac_ide_init_dev, 980 973 .set_pio_mode = pmac_ide_set_pio_mode, 981 974 .set_dma_mode = pmac_ide_set_dma_mode, 982 - .selectproc = pmac_ide_selectproc, 983 975 .cable_detect = pmac_ide_cable_detect, 984 976 }; 985 977 ··· 992 974 .init_dev = pmac_ide_init_dev, 993 975 .set_pio_mode = pmac_ide_set_pio_mode, 994 976 .set_dma_mode = pmac_ide_set_dma_mode, 995 - .selectproc = pmac_ide_selectproc, 996 977 }; 997 978 998 979 static const struct ide_dma_ops pmac_dma_ops; ··· 1028 1011 pmif->broken_dma = pmif->broken_dma_warn = 0; 1029 1012 if (of_device_is_compatible(np, "shasta-ata")) { 1030 1013 pmif->kind = controller_sh_ata6; 1031 - d.port_ops = &pmac_ide_ata6_port_ops; 1014 + d.tp_ops = &pmac_ata6_tp_ops; 1015 + d.port_ops = &pmac_ide_ata4_port_ops; 1032 1016 d.udma_mask = ATA_UDMA6; 1033 1017 } else if (of_device_is_compatible(np, "kauai-ata")) { 1034 1018 pmif->kind = controller_un_ata6; 1035 - d.port_ops = &pmac_ide_ata6_port_ops; 1019 + d.tp_ops = &pmac_ata6_tp_ops; 1020 + d.port_ops = &pmac_ide_ata4_port_ops; 1036 1021 d.udma_mask = ATA_UDMA5; 1037 1022 } else if (of_device_is_compatible(np, "K2-UATA")) { 1038 1023 pmif->kind = controller_k2_ata6; 1039 - d.port_ops = &pmac_ide_ata6_port_ops; 1024 + d.tp_ops = &pmac_ata6_tp_ops; 1025 + d.port_ops = &pmac_ide_ata4_port_ops; 1040 1026 d.udma_mask = ATA_UDMA5; 1041 1027 } else if (of_device_is_compatible(np, "keylargo-ata")) { 1042 1028 if (strcmp(np->name, "ata-4") == 0) {
+1
drivers/ide/q40ide.c
··· 101 101 .read_altstatus = ide_read_altstatus, 102 102 .write_devctl = ide_write_devctl, 103 103 104 + .dev_select = ide_dev_select, 104 105 .tf_load = ide_tf_load, 105 106 .tf_read = ide_tf_read, 106 107
+18 -3
drivers/ide/qd65xx.c
··· 90 90 * This routine is invoked to prepare for access to a given drive. 91 91 */ 92 92 93 - static void qd65xx_select(ide_drive_t *drive) 93 + static void qd65xx_dev_select(ide_drive_t *drive) 94 94 { 95 95 u8 index = (( (QD_TIMREG(drive)) & 0x80 ) >> 7) | 96 96 (QD_TIMREG(drive) & 0x02); 97 97 98 98 if (timings[index] != QD_TIMING(drive)) 99 99 outb(timings[index] = QD_TIMING(drive), QD_TIMREG(drive)); 100 + 101 + outb(drive->select | ATA_DEVICE_OBS, drive->hwif->io_ports.device_addr); 100 102 } 101 103 102 104 /* ··· 311 309 drive->drive_data = (drive->dn & 1) ? t2 : t1; 312 310 } 313 311 312 + static const struct ide_tp_ops qd65xx_tp_ops = { 313 + .exec_command = ide_exec_command, 314 + .read_status = ide_read_status, 315 + .read_altstatus = ide_read_altstatus, 316 + .write_devctl = ide_write_devctl, 317 + 318 + .dev_select = qd65xx_dev_select, 319 + .tf_load = ide_tf_load, 320 + .tf_read = ide_tf_read, 321 + 322 + .input_data = ide_input_data, 323 + .output_data = ide_output_data, 324 + }; 325 + 314 326 static const struct ide_port_ops qd6500_port_ops = { 315 327 .init_dev = qd6500_init_dev, 316 328 .set_pio_mode = qd6500_set_pio_mode, 317 - .selectproc = qd65xx_select, 318 329 }; 319 330 320 331 static const struct ide_port_ops qd6580_port_ops = { 321 332 .init_dev = qd6580_init_dev, 322 333 .set_pio_mode = qd6580_set_pio_mode, 323 - .selectproc = qd65xx_select, 324 334 }; 325 335 326 336 static const struct ide_port_info qd65xx_port_info __initdata = { 327 337 .name = DRV_NAME, 338 + .tp_ops = &qd65xx_tp_ops, 328 339 .chipset = ide_qd65xx, 329 340 .host_flags = IDE_HFLAG_IO_32BIT | 330 341 IDE_HFLAG_NO_DMA,
+1
drivers/ide/scc_pata.c
··· 825 825 .read_altstatus = scc_read_altstatus, 826 826 .write_devctl = scc_write_devctl, 827 827 828 + .dev_select = ide_dev_select, 828 829 .tf_load = scc_tf_load, 829 830 .tf_read = scc_tf_read, 830 831
+1
drivers/ide/sgiioc4.c
··· 505 505 .read_altstatus = ide_read_altstatus, 506 506 .write_devctl = ide_write_devctl, 507 507 508 + .dev_select = ide_dev_select, 508 509 .tf_load = ide_tf_load, 509 510 .tf_read = ide_tf_read, 510 511
+16 -4
drivers/ide/trm290.c
··· 171 171 local_irq_restore(flags); 172 172 } 173 173 174 - static void trm290_selectproc (ide_drive_t *drive) 174 + static void trm290_dev_select(ide_drive_t *drive) 175 175 { 176 176 trm290_prepare_drive(drive, !!(drive->dev_flags & IDE_DFLAG_USING_DMA)); 177 + 178 + outb(drive->select | ATA_DEVICE_OBS, drive->hwif->io_ports.device_addr); 177 179 } 178 180 179 181 static int trm290_dma_check(ide_drive_t *drive, struct ide_cmd *cmd) ··· 300 298 #endif 301 299 } 302 300 303 - static const struct ide_port_ops trm290_port_ops = { 304 - .selectproc = trm290_selectproc, 301 + static const struct ide_tp_ops trm290_tp_ops = { 302 + .exec_command = ide_exec_command, 303 + .read_status = ide_read_status, 304 + .read_altstatus = ide_read_altstatus, 305 + .write_devctl = ide_write_devctl, 306 + 307 + .dev_select = trm290_dev_select, 308 + .tf_load = ide_tf_load, 309 + .tf_read = ide_tf_read, 310 + 311 + .input_data = ide_input_data, 312 + .output_data = ide_output_data, 305 313 }; 306 314 307 315 static struct ide_dma_ops trm290_dma_ops = { ··· 327 315 static const struct ide_port_info trm290_chipset __devinitdata = { 328 316 .name = DRV_NAME, 329 317 .init_hwif = init_hwif_trm290, 330 - .port_ops = &trm290_port_ops, 318 + .tp_ops = &trm290_tp_ops, 331 319 .dma_ops = &trm290_dma_ops, 332 320 .host_flags = IDE_HFLAG_TRM290 | 333 321 IDE_HFLAG_NO_ATAPI_DMA |
+1
drivers/ide/tx4938ide.c
··· 189 189 .read_altstatus = ide_read_altstatus, 190 190 .write_devctl = ide_write_devctl, 191 191 192 + .dev_select = ide_dev_select, 192 193 .tf_load = tx4938ide_tf_load, 193 194 .tf_read = tx4938ide_tf_read, 194 195
+3 -1
drivers/ide/tx4939ide.c
··· 429 429 * Fix ATA100 CORE System Control Register. (The write to the 430 430 * Device/Head register may write wrong data to the System 431 431 * Control Register) 432 - * While Sys_Ctl is written here, selectproc is not needed. 432 + * While Sys_Ctl is written here, dev_select() is not needed. 433 433 */ 434 434 tx4939ide_writew(sysctl, base, TX4939IDE_Sys_Ctl); 435 435 } ··· 556 556 .read_altstatus = ide_read_altstatus, 557 557 .write_devctl = ide_write_devctl, 558 558 559 + .dev_select = ide_dev_select, 559 560 .tf_load = tx4939ide_tf_load, 560 561 .tf_read = tx4939ide_tf_read, 561 562 ··· 580 579 .read_altstatus = ide_read_altstatus, 581 580 .write_devctl = ide_write_devctl, 582 581 582 + .dev_select = ide_dev_select, 583 583 .tf_load = tx4939ide_tf_load, 584 584 .tf_read = ide_tf_read, 585 585
+3 -3
include/linux/ide.h
··· 603 603 604 604 unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ 605 605 unsigned int cyl; /* "real" number of cyls */ 606 - unsigned int drive_data; /* used by set_pio_mode/selectproc */ 606 + unsigned int drive_data; /* used by set_pio_mode/dev_select() */ 607 607 unsigned int failures; /* current failure count */ 608 608 unsigned int max_failures; /* maximum allowed failure count */ 609 609 u64 probed_capacity;/* initial reported media capacity (ide-cd only currently) */ ··· 661 661 u8 (*read_altstatus)(struct hwif_s *); 662 662 void (*write_devctl)(struct hwif_s *, u8); 663 663 664 + void (*dev_select)(ide_drive_t *); 664 665 void (*tf_load)(ide_drive_t *, struct ide_cmd *); 665 666 void (*tf_read)(ide_drive_t *, struct ide_cmd *); 666 667 ··· 679 678 * @init_dev: host specific initialization of a device 680 679 * @set_pio_mode: routine to program host for PIO mode 681 680 * @set_dma_mode: routine to program host for DMA mode 682 - * @selectproc: tweaks hardware to select drive 683 681 * @reset_poll: chipset polling based on hba specifics 684 682 * @pre_reset: chipset specific changes to default for device-hba resets 685 683 * @resetproc: routine to reset controller after a disk reset ··· 695 695 void (*init_dev)(ide_drive_t *); 696 696 void (*set_pio_mode)(ide_drive_t *, const u8); 697 697 void (*set_dma_mode)(ide_drive_t *, const u8); 698 - void (*selectproc)(ide_drive_t *); 699 698 int (*reset_poll)(ide_drive_t *); 700 699 void (*pre_reset)(ide_drive_t *); 701 700 void (*resetproc)(ide_drive_t *); ··· 1169 1170 u8 ide_read_altstatus(ide_hwif_t *); 1170 1171 void ide_write_devctl(ide_hwif_t *, u8); 1171 1172 1173 + void ide_dev_select(ide_drive_t *); 1172 1174 void ide_tf_load(ide_drive_t *, struct ide_cmd *); 1173 1175 void ide_tf_read(ide_drive_t *, struct ide_cmd *); 1174 1176