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

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (46 commits)
ide: constify struct ide_dma_ops
ide: add struct ide_dma_ops (take 3)
ide: add IDE_HFLAG_SERIALIZE_DMA host flag
sl82c105: check bridge revision in sl82c105_init_one()
au1xxx-ide: use ->init_dma method
palm_bk3710: use ->init_dma method
sgiioc4: use ->init_dma method
icside: use ->init_dma method
ide-pmac: use ->init_dma method
ide: do complete DMA setup in ->init_dma method (take 2)
au1xxx-ide: fix MWDMA support
ide: cleanup ide_setup_dma()
ide: factor out setting PCI bus-mastering from ide_hwif_setup_dma()
ide: export ide_allocate_dma_engine()
ide: move ide_setup_dma() call out from ->init_dma method
alim15x3: skip DMA initialization completely on revs < 0x20
pdc202xx_old: remove init_dma_pdc202xx()
ide: don't display "BIOS" settings in ide_setup_dma()
ide: remove ->cds field from ide_hwif_t (take 2)
ide: remove ide_dma_iobase()
...

+1782 -1880
-46
Documentation/mips/AU1xxx_IDE.README
··· 46 46 47 47 a) 'include/asm-mips/mach-au1x00/au1xxx_ide.h' 48 48 containes : struct _auide_hwif 49 - struct drive_list_entry dma_white_list 50 - struct drive_list_entry dma_black_list 51 49 timing parameters for PIO mode 0/1/2/3/4 52 50 timing parameters for MWDMA 0/1/2 53 51 ··· 60 62 controller 61 63 CONFIG_BLK_DEV_IDE_AU1XXX_SEQTS_PER_RQ - maximum transfer size 62 64 per descriptor 63 - 64 - If MWDMA is enabled and the connected hard disc is not on the white list, the 65 - kernel switches to a "safe mwdma mode" at boot time. In this mode the IDE 66 - performance is substantial slower then in full speed mwdma. In this case 67 - please add your hard disc to the white list (follow instruction from 'ADD NEW 68 - HARD DISC TO WHITE OR BLACK LIST' section). 69 65 70 66 71 67 SUPPORTED IDE MODES ··· 111 119 112 120 Also undefine 'IDE_AU1XXX_BURSTMODE' in 'drivers/ide/mips/au1xxx-ide.c' to 113 121 disable the burst support on DBDMA controller. 114 - 115 - ADD NEW HARD DISC TO WHITE OR BLACK LIST 116 - ---------------------------------------- 117 - 118 - Step 1 : detect the model name of your hard disc 119 - 120 - a) connect your hard disc to the AU1XXX 121 - 122 - b) boot your kernel and get the hard disc model. 123 - 124 - Example boot log: 125 - 126 - --snipped-- 127 - Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2 128 - ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx 129 - Au1xxx IDE(builtin) configured for MWDMA2 130 - Probing IDE interface ide0... 131 - hda: Maxtor 6E040L0, ATA DISK drive 132 - ide0 at 0xac800000-0xac800007,0xac8001c0 on irq 64 133 - hda: max request size: 64KiB 134 - hda: 80293248 sectors (41110 MB) w/2048KiB Cache, CHS=65535/16/63, (U)DMA 135 - --snipped-- 136 - 137 - In this example 'Maxtor 6E040L0'. 138 - 139 - Step 2 : edit 'include/asm-mips/mach-au1x00/au1xxx_ide.h' 140 - 141 - Add your hard disc to the dma_white_list or dma_black_list structur. 142 - 143 - Step 3 : Recompile the kernel 144 - 145 - Enable MWDMA support in the kernel configuration. Recompile the kernel and 146 - reboot. 147 - 148 - Step 4 : Tests 149 - 150 - If you have add a hard disc to the white list, please run some stress tests 151 - for verification. 152 122 153 123 154 124 ACKNOWLEDGMENTS
+1 -2
drivers/ide/arm/bast-ide.c
··· 55 55 ide_init_port_data(hwif, i); 56 56 57 57 ide_init_port_hw(hwif, &hw); 58 - hwif->mmio = 1; 59 - hwif->quirkproc = NULL; 58 + hwif->port_ops = NULL; 60 59 61 60 idx[0] = i; 62 61
+35 -19
drivers/ide/arm/icside.c
··· 191 191 local_irq_restore(flags); 192 192 } 193 193 194 + static const struct ide_port_ops icside_v6_no_dma_port_ops = { 195 + .maskproc = icside_maskproc, 196 + }; 197 + 194 198 #ifdef CONFIG_BLK_DEV_IDEDMA_ICS 195 199 /* 196 200 * SG-DMA support. ··· 269 265 printk("%s: %s selected (peak %dMB/s)\n", drive->name, 270 266 ide_xfer_verbose(xfer_mode), 2000 / drive->drive_data); 271 267 } 268 + 269 + static const struct ide_port_ops icside_v6_port_ops = { 270 + .set_dma_mode = icside_set_dma_mode, 271 + .maskproc = icside_maskproc, 272 + }; 272 273 273 274 static void icside_dma_host_set(ide_drive_t *drive, int on) 274 275 { ··· 384 375 printk(KERN_ERR "%s: IRQ lost\n", drive->name); 385 376 } 386 377 387 - static void icside_dma_init(ide_hwif_t *hwif) 378 + static int icside_dma_init(ide_hwif_t *hwif, const struct ide_port_info *d) 388 379 { 389 380 hwif->dmatable_cpu = NULL; 390 381 hwif->dmatable_dma = 0; 391 - hwif->set_dma_mode = icside_set_dma_mode; 392 382 393 - hwif->dma_host_set = icside_dma_host_set; 394 - hwif->dma_setup = icside_dma_setup; 395 - hwif->dma_exec_cmd = icside_dma_exec_cmd; 396 - hwif->dma_start = icside_dma_start; 397 - hwif->ide_dma_end = icside_dma_end; 398 - hwif->ide_dma_test_irq = icside_dma_test_irq; 399 - hwif->dma_timeout = icside_dma_timeout; 400 - hwif->dma_lost_irq = icside_dma_lost_irq; 383 + return 0; 401 384 } 385 + 386 + static const struct ide_dma_ops icside_v6_dma_ops = { 387 + .dma_host_set = icside_dma_host_set, 388 + .dma_setup = icside_dma_setup, 389 + .dma_exec_cmd = icside_dma_exec_cmd, 390 + .dma_start = icside_dma_start, 391 + .dma_end = icside_dma_end, 392 + .dma_test_irq = icside_dma_test_irq, 393 + .dma_timeout = icside_dma_timeout, 394 + .dma_lost_irq = icside_dma_lost_irq, 395 + }; 402 396 #else 403 - #define icside_dma_init(hwif) (0) 397 + #define icside_v6_dma_ops NULL 404 398 #endif 399 + 400 + static int icside_dma_off_init(ide_hwif_t *hwif, const struct ide_port_info *d) 401 + { 402 + return -EOPNOTSUPP; 403 + } 405 404 406 405 static ide_hwif_t * 407 406 icside_setup(void __iomem *base, struct cardinfo *info, struct expansion_card *ec) ··· 425 408 * Ensure we're using MMIO 426 409 */ 427 410 default_hwif_mmiops(hwif); 428 - hwif->mmio = 1; 429 411 430 412 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) { 431 413 hwif->io_ports[i] = port; ··· 432 416 } 433 417 hwif->io_ports[IDE_CONTROL_OFFSET] = (unsigned long)base + info->ctrloffset; 434 418 hwif->irq = ec->irq; 435 - hwif->noprobe = 0; 436 419 hwif->chipset = ide_acorn; 437 420 hwif->gendev.parent = &ec->dev; 438 421 hwif->dev = &ec->dev; ··· 477 462 } 478 463 479 464 static const struct ide_port_info icside_v6_port_info __initdata = { 465 + .init_dma = icside_dma_off_init, 466 + .port_ops = &icside_v6_no_dma_port_ops, 467 + .dma_ops = &icside_v6_dma_ops, 480 468 .host_flags = IDE_HFLAG_SERIALIZE | 481 - IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ 482 469 IDE_HFLAG_NO_AUTOTUNE, 483 470 .mwdma_mask = ATA_MWDMA2, 484 471 .swdma_mask = ATA_SWDMA2, ··· 543 526 state->hwif[0] = hwif; 544 527 state->hwif[1] = mate; 545 528 546 - hwif->maskproc = icside_maskproc; 547 529 hwif->hwif_data = state; 548 530 hwif->config_data = (unsigned long)ioc_base; 549 531 hwif->select_data = sel; ··· 553 537 mate->select_data = sel | 1; 554 538 555 539 if (ec->dma != NO_DMA && !request_dma(ec->dma, hwif->name)) { 556 - icside_dma_init(hwif); 557 - icside_dma_init(mate); 558 - } else 559 - d.mwdma_mask = d.swdma_mask = 0; 540 + d.init_dma = icside_dma_init; 541 + d.port_ops = &icside_v6_dma_port_ops; 542 + d.dma_ops = NULL; 543 + } 560 544 561 545 idx[0] = hwif->index; 562 546 idx[1] = mate->index;
+17 -1
drivers/ide/arm/ide_arm.c
··· 14 14 #include <asm/mach-types.h> 15 15 #include <asm/irq.h> 16 16 17 + #define DRV_NAME "ide_arm" 18 + 17 19 #ifdef CONFIG_ARCH_CLPS7500 18 20 # include <asm/arch/hardware.h> 19 21 # ··· 30 28 { 31 29 ide_hwif_t *hwif; 32 30 hw_regs_t hw; 31 + unsigned long base = IDE_ARM_IO, ctl = IDE_ARM_IO + 0x206; 33 32 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 34 33 34 + if (!request_region(base, 8, DRV_NAME)) { 35 + printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", 36 + DRV_NAME, base, base + 7); 37 + return -EBUSY; 38 + } 39 + 40 + if (!request_region(ctl, 1, DRV_NAME)) { 41 + printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", 42 + DRV_NAME, ctl); 43 + release_region(base, 8); 44 + return -EBUSY; 45 + } 46 + 35 47 memset(&hw, 0, sizeof(hw)); 36 - ide_std_init_ports(&hw, IDE_ARM_IO, IDE_ARM_IO + 0x206); 48 + ide_std_init_ports(&hw, base, ctl); 37 49 hw.irq = IDE_ARM_IRQ; 38 50 39 51 hwif = ide_find_port();
+20 -8
drivers/ide/arm/palm_bk3710.c
··· 317 317 return ATA_CBL_PATA80; 318 318 } 319 319 320 - static void __devinit palm_bk3710_init_hwif(ide_hwif_t *hwif) 320 + static int __devinit palm_bk3710_init_dma(ide_hwif_t *hwif, 321 + const struct ide_port_info *d) 321 322 { 322 - hwif->set_pio_mode = palm_bk3710_set_pio_mode; 323 - hwif->set_dma_mode = palm_bk3710_set_dma_mode; 323 + unsigned long base = 324 + hwif->io_ports[IDE_DATA_OFFSET] - IDE_PALM_ATA_PRI_REG_OFFSET; 324 325 325 - hwif->cable_detect = palm_bk3710_cable_detect; 326 + printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); 327 + 328 + if (ide_allocate_dma_engine(hwif)) 329 + return -1; 330 + 331 + ide_setup_dma(hwif, base); 332 + 333 + return 0; 326 334 } 327 335 336 + static const struct ide_port_ops palm_bk3710_ports_ops = { 337 + .set_pio_mode = palm_bk3710_set_pio_mode, 338 + .set_dma_mode = palm_bk3710_set_dma_mode, 339 + .cable_detect = palm_bk3710_cable_detect, 340 + }; 341 + 328 342 static const struct ide_port_info __devinitdata palm_bk3710_port_info = { 329 - .init_hwif = palm_bk3710_init_hwif, 330 - .host_flags = IDE_HFLAG_NO_DMA, /* hack (no PCI) */ 343 + .init_dma = palm_bk3710_init_dma, 344 + .port_ops = &palm_bk3710_ports_ops, 331 345 .pio_mask = ATA_PIO4, 332 346 .udma_mask = ATA_UDMA4, /* (input clk 99MHz) */ 333 347 .mwdma_mask = ATA_MWDMA2, ··· 407 393 408 394 hwif->mmio = 1; 409 395 default_hwif_mmiops(hwif); 410 - 411 - ide_setup_dma(hwif, mem->start); 412 396 413 397 idx[0] = i; 414 398
-1
drivers/ide/arm/rapide.c
··· 53 53 54 54 ide_init_port_hw(hwif, &hw); 55 55 56 - hwif->mmio = 1; 57 56 default_hwif_mmiops(hwif); 58 57 59 58 idx[0] = hwif->index;
+19 -14
drivers/ide/cris/ide-cris.c
··· 673 673 return (unsigned char)cris_ide_inw(reg); 674 674 } 675 675 676 - static int cris_dma_end (ide_drive_t *drive); 677 - static int cris_dma_setup (ide_drive_t *drive); 678 - static void cris_dma_exec_cmd (ide_drive_t *drive, u8 command); 679 - static int cris_dma_test_irq(ide_drive_t *drive); 680 - static void cris_dma_start(ide_drive_t *drive); 681 676 static void cris_ide_input_data (ide_drive_t *drive, void *, unsigned int); 682 677 static void cris_ide_output_data (ide_drive_t *drive, void *, unsigned int); 683 678 static void cris_atapi_input_bytes(ide_drive_t *drive, void *, unsigned int); ··· 777 782 hw->ack_intr = cris_ide_ack_intr; 778 783 } 779 784 785 + static const struct ide_port_ops cris_port_ops = { 786 + .set_pio_mode = cris_set_pio_mode, 787 + .set_dma_mode = cris_set_dma_mode, 788 + }; 789 + 790 + static const struct ide_dma_ops cris_dma_ops; 791 + 780 792 static const struct ide_port_info cris_port_info __initdata = { 781 793 .chipset = ide_etrax100, 794 + .port_ops = &cris_port_ops, 795 + .dma_ops = &cris_dma_ops, 782 796 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | 783 797 IDE_HFLAG_NO_DMA, /* no SFF-style DMA */ 784 798 .pio_mask = ATA_PIO4, ··· 813 809 continue; 814 810 ide_init_port_data(hwif, hwif->index); 815 811 ide_init_port_hw(hwif, &hw); 816 - hwif->mmio = 1; 817 - hwif->set_pio_mode = &cris_set_pio_mode; 818 - hwif->set_dma_mode = &cris_set_dma_mode; 812 + 819 813 hwif->ata_input_data = &cris_ide_input_data; 820 814 hwif->ata_output_data = &cris_ide_output_data; 821 815 hwif->atapi_input_bytes = &cris_atapi_input_bytes; 822 816 hwif->atapi_output_bytes = &cris_atapi_output_bytes; 823 - hwif->dma_host_set = &cris_dma_host_set; 824 - hwif->ide_dma_end = &cris_dma_end; 825 - hwif->dma_setup = &cris_dma_setup; 826 - hwif->dma_exec_cmd = &cris_dma_exec_cmd; 827 - hwif->ide_dma_test_irq = &cris_dma_test_irq; 828 - hwif->dma_start = &cris_dma_start; 829 817 hwif->OUTB = &cris_ide_outb; 830 818 hwif->OUTW = &cris_ide_outw; 831 819 hwif->OUTBSYNC = &cris_ide_outbsync; ··· 1071 1075 LED_DISK_READ(1); 1072 1076 } 1073 1077 } 1078 + 1079 + static const struct ide_dma_ops cris_dma_ops = { 1080 + .dma_host_set = cris_dma_host_set, 1081 + .dma_setup = cris_dma_setup, 1082 + .dma_exec_cmd = cris_dma_exec_cmd, 1083 + .dma_start = cris_dma_start, 1084 + .dma_end = cris_dma_end, 1085 + .dma_test_irq = cris_dma_test_irq, 1086 + }; 1074 1087 1075 1088 module_init(init_e100_ide); 1076 1089
-1
drivers/ide/h8300/ide-h8300.c
··· 74 74 { 75 75 default_hwif_iops(hwif); 76 76 77 - hwif->mmio = 1; 78 77 hwif->OUTW = mm_outw; 79 78 hwif->OUTSW = mm_outsw; 80 79 hwif->INW = mm_inw;
+6 -6
drivers/ide/ide-acpi.c
··· 55 55 /* note: adds function name and KERN_DEBUG */ 56 56 #ifdef DEBUGGING 57 57 #define DEBPRINT(fmt, args...) \ 58 - printk(KERN_DEBUG "%s: " fmt, __FUNCTION__, ## args) 58 + printk(KERN_DEBUG "%s: " fmt, __func__, ## args) 59 59 #else 60 60 #define DEBPRINT(fmt, args...) do {} while (0) 61 61 #endif /* DEBUGGING */ ··· 309 309 if (ACPI_FAILURE(status)) { 310 310 printk(KERN_DEBUG 311 311 "%s: Run _GTF error: status = 0x%x\n", 312 - __FUNCTION__, status); 312 + __func__, status); 313 313 goto out; 314 314 } 315 315 ··· 335 335 out_obj->buffer.length % REGS_PER_GTF) { 336 336 printk(KERN_ERR 337 337 "%s: unexpected GTF length (%d) or addr (0x%p)\n", 338 - __FUNCTION__, out_obj->buffer.length, 338 + __func__, out_obj->buffer.length, 339 339 out_obj->buffer.pointer); 340 340 err = -ENOENT; 341 341 kfree(output.pointer); ··· 384 384 err = ide_no_data_taskfile(drive, &args); 385 385 if (err) 386 386 printk(KERN_ERR "%s: ide_no_data_taskfile failed: %u\n", 387 - __FUNCTION__, err); 387 + __func__, err); 388 388 389 389 return err; 390 390 } ··· 422 422 423 423 if (gtf_length % REGS_PER_GTF) { 424 424 printk(KERN_ERR "%s: unexpected GTF length (%d)\n", 425 - __FUNCTION__, gtf_length); 425 + __func__, gtf_length); 426 426 goto out; 427 427 } 428 428 ··· 547 547 printk(KERN_ERR 548 548 "%s: unexpected _GTM length (0x%x)[should be 0x%zx] or " 549 549 "addr (0x%p)\n", 550 - __FUNCTION__, out_obj->buffer.length, 550 + __func__, out_obj->buffer.length, 551 551 sizeof(struct GTM_buffer), out_obj->buffer.pointer); 552 552 return; 553 553 }
+293 -292
drivers/ide/ide-cd.c
··· 39 39 #include <linux/mutex.h> 40 40 #include <linux/bcd.h> 41 41 42 - #include <scsi/scsi.h> /* For SCSI -> ATAPI command conversion */ 42 + /* For SCSI -> ATAPI command conversion */ 43 + #include <scsi/scsi.h> 43 44 44 - #include <asm/irq.h> 45 - #include <asm/io.h> 45 + #include <linux/irq.h> 46 + #include <linux/io.h> 46 47 #include <asm/byteorder.h> 47 - #include <asm/uaccess.h> 48 + #include <linux/uaccess.h> 48 49 #include <asm/unaligned.h> 49 50 50 51 #include "ide-cd.h" ··· 78 77 mutex_unlock(&idecd_ref_mutex); 79 78 } 80 79 81 - /**************************************************************************** 80 + /* 82 81 * Generic packet command support and error handling routines. 83 82 */ 84 83 85 - /* Mark that we've seen a media change, and invalidate our internal 86 - buffers. */ 84 + /* Mark that we've seen a media change and invalidate our internal buffers. */ 87 85 static void cdrom_saw_media_change(ide_drive_t *drive) 88 86 { 89 87 struct cdrom_info *cd = drive->driver_data; ··· 105 105 break; 106 106 case NOT_READY: 107 107 /* 108 - * don't care about tray state messages for 109 - * e.g. capacity commands or in-progress or 110 - * becoming ready 108 + * don't care about tray state messages for e.g. capacity 109 + * commands or in-progress or becoming ready 111 110 */ 112 111 if (sense->asc == 0x3a || sense->asc == 0x04) 113 112 break; ··· 114 115 break; 115 116 case ILLEGAL_REQUEST: 116 117 /* 117 - * don't log START_STOP unit with LoEj set, since 118 - * we cannot reliably check if drive can auto-close 118 + * don't log START_STOP unit with LoEj set, since we cannot 119 + * reliably check if drive can auto-close 119 120 */ 120 121 if (rq->cmd[0] == GPCMD_START_STOP_UNIT && sense->asc == 0x24) 121 122 break; ··· 123 124 break; 124 125 case UNIT_ATTENTION: 125 126 /* 126 - * Make good and sure we've seen this potential media 127 - * change. Some drives (i.e. Creative) fail to present 128 - * the correct sense key in the error register. 127 + * Make good and sure we've seen this potential media change. 128 + * Some drives (i.e. Creative) fail to present the correct sense 129 + * key in the error register. 129 130 */ 130 131 cdrom_saw_media_change(drive); 131 132 break; ··· 136 137 return log; 137 138 } 138 139 139 - static 140 - void cdrom_analyze_sense_data(ide_drive_t *drive, 140 + static void cdrom_analyze_sense_data(ide_drive_t *drive, 141 141 struct request *failed_command, 142 142 struct request_sense *sense) 143 143 { ··· 149 151 return; 150 152 151 153 /* 152 - * If a read toc is executed for a CD-R or CD-RW medium where 153 - * the first toc has not been recorded yet, it will fail with 154 - * 05/24/00 (which is a confusing error) 154 + * If a read toc is executed for a CD-R or CD-RW medium where the first 155 + * toc has not been recorded yet, it will fail with 05/24/00 (which is a 156 + * confusing error) 155 157 */ 156 158 if (failed_command && failed_command->cmd[0] == GPCMD_READ_TOC_PMA_ATIP) 157 159 if (sense->sense_key == 0x05 && sense->asc == 0x24) 158 160 return; 159 161 160 - if (sense->error_code == 0x70) { /* Current Error */ 162 + /* current error */ 163 + if (sense->error_code == 0x70) { 161 164 switch (sense->sense_key) { 162 165 case MEDIUM_ERROR: 163 166 case VOLUME_OVERFLOW: ··· 177 178 if (bio_sectors < 4) 178 179 bio_sectors = 4; 179 180 if (drive->queue->hardsect_size == 2048) 180 - sector <<= 2; /* Device sector size is 2K */ 181 + /* device sector size is 2K */ 182 + sector <<= 2; 181 183 sector &= ~(bio_sectors - 1); 182 184 valid = (sector - failed_command->sector) << 9; 183 185 184 186 if (valid < 0) 185 187 valid = 0; 186 188 if (sector < get_capacity(info->disk) && 187 - drive->probed_capacity - sector < 4 * 75) { 189 + drive->probed_capacity - sector < 4 * 75) 188 190 set_capacity(info->disk, sector); 189 - } 190 191 } 191 192 } 192 193 193 194 ide_cd_log_error(drive->name, failed_command, sense); 194 195 } 195 196 196 - /* 197 - * Initialize a ide-cd packet command request 198 - */ 197 + /* Initialize a ide-cd packet command request */ 199 198 void ide_cd_init_rq(ide_drive_t *drive, struct request *rq) 200 199 { 201 200 struct cdrom_info *cd = drive->driver_data; ··· 217 220 218 221 rq->data = sense; 219 222 rq->cmd[0] = GPCMD_REQUEST_SENSE; 220 - rq->cmd[4] = rq->data_len = 18; 223 + rq->cmd[4] = 18; 224 + rq->data_len = 18; 221 225 222 226 rq->cmd_type = REQ_TYPE_SENSE; 223 227 ··· 250 252 } 251 253 cdrom_analyze_sense_data(drive, failed, sense); 252 254 /* 253 - * now end failed request 255 + * now end the failed request 254 256 */ 255 257 if (blk_fs_request(failed)) { 256 258 if (ide_end_dequeued_request(drive, failed, 0, ··· 278 280 ide_end_request(drive, uptodate, nsectors); 279 281 } 280 282 281 - static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 stat) 283 + static void ide_dump_status_no_sense(ide_drive_t *drive, const char *msg, u8 st) 282 284 { 283 - if (stat & 0x80) 285 + if (st & 0x80) 284 286 return; 285 - ide_dump_status(drive, msg, stat); 287 + ide_dump_status(drive, msg, st); 286 288 } 287 289 288 - /* Returns 0 if the request should be continued. 289 - Returns 1 if the request was ended. */ 290 + /* 291 + * Returns: 292 + * 0: if the request should be continued. 293 + * 1: if the request was ended. 294 + */ 290 295 static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) 291 296 { 292 297 struct request *rq = HWGROUP(drive)->rq; 293 298 int stat, err, sense_key; 294 299 295 - /* Check for errors. */ 300 + /* check for errors */ 296 301 stat = ide_read_status(drive); 297 302 298 303 if (stat_ret) ··· 304 303 if (OK_STAT(stat, good_stat, BAD_R_STAT)) 305 304 return 0; 306 305 307 - /* Get the IDE error register. */ 306 + /* get the IDE error register */ 308 307 err = ide_read_error(drive); 309 308 sense_key = err >> 4; 310 309 311 310 if (rq == NULL) { 312 - printk("%s: missing rq in cdrom_decode_status\n", drive->name); 311 + printk(KERN_ERR "%s: missing rq in %s\n", 312 + drive->name, __func__); 313 313 return 1; 314 314 } 315 315 316 316 if (blk_sense_request(rq)) { 317 - /* We got an error trying to get sense info 318 - from the drive (probably while trying 319 - to recover from a former error). Just give up. */ 320 - 317 + /* 318 + * We got an error trying to get sense info from the drive 319 + * (probably while trying to recover from a former error). 320 + * Just give up. 321 + */ 321 322 rq->cmd_flags |= REQ_FAILED; 322 323 cdrom_end_request(drive, 0); 323 324 ide_error(drive, "request sense failure", stat); ··· 335 332 if (blk_pc_request(rq) && !rq->errors) 336 333 rq->errors = SAM_STAT_CHECK_CONDITION; 337 334 338 - /* Check for tray open. */ 335 + /* check for tray open */ 339 336 if (sense_key == NOT_READY) { 340 337 cdrom_saw_media_change(drive); 341 338 } else if (sense_key == UNIT_ATTENTION) { 342 - /* Check for media change. */ 339 + /* check for media change */ 343 340 cdrom_saw_media_change(drive); 344 - /*printk("%s: media changed\n",drive->name);*/ 345 341 return 0; 346 342 } else if (sense_key == ILLEGAL_REQUEST && 347 343 rq->cmd[0] == GPCMD_START_STOP_UNIT) { ··· 352 350 * cdrom_log_sense() knows this! 353 351 */ 354 352 } else if (!(rq->cmd_flags & REQ_QUIET)) { 355 - /* Otherwise, print an error. */ 353 + /* otherwise, print an error */ 356 354 ide_dump_status(drive, "packet command error", stat); 357 355 } 358 356 ··· 368 366 } else if (blk_fs_request(rq)) { 369 367 int do_end_request = 0; 370 368 371 - /* Handle errors from READ and WRITE requests. */ 369 + /* handle errors from READ and WRITE requests */ 372 370 373 371 if (blk_noretry_request(rq)) 374 372 do_end_request = 1; 375 373 376 374 if (sense_key == NOT_READY) { 377 - /* Tray open. */ 375 + /* tray open */ 378 376 if (rq_data_dir(rq) == READ) { 379 377 cdrom_saw_media_change(drive); 380 378 381 - /* Fail the request. */ 382 - printk("%s: tray open\n", drive->name); 379 + /* fail the request */ 380 + printk(KERN_ERR "%s: tray open\n", drive->name); 383 381 do_end_request = 1; 384 382 } else { 385 383 struct cdrom_info *info = drive->driver_data; 386 384 387 - /* allow the drive 5 seconds to recover, some 385 + /* 386 + * Allow the drive 5 seconds to recover, some 388 387 * devices will return this error while flushing 389 - * data from cache */ 388 + * data from cache. 389 + */ 390 390 if (!rq->errors) 391 - info->write_timeout = jiffies + ATAPI_WAIT_WRITE_BUSY; 391 + info->write_timeout = jiffies + 392 + ATAPI_WAIT_WRITE_BUSY; 392 393 rq->errors = 1; 393 394 if (time_after(jiffies, info->write_timeout)) 394 395 do_end_request = 1; ··· 399 394 unsigned long flags; 400 395 401 396 /* 402 - * take a breather relying on the 403 - * unplug timer to kick us again 397 + * take a breather relying on the unplug 398 + * timer to kick us again 404 399 */ 405 400 spin_lock_irqsave(&ide_lock, flags); 406 401 blk_plug_device(drive->queue); 407 - spin_unlock_irqrestore(&ide_lock, flags); 402 + spin_unlock_irqrestore(&ide_lock, 403 + flags); 408 404 return 1; 409 405 } 410 406 } 411 407 } else if (sense_key == UNIT_ATTENTION) { 412 - /* Media change. */ 413 - cdrom_saw_media_change (drive); 408 + /* media change */ 409 + cdrom_saw_media_change(drive); 414 410 415 411 /* 416 - * Arrange to retry the request. 417 - * But be sure to give up if we've retried 418 - * too many times. 412 + * Arrange to retry the request but be sure to give up 413 + * if we've retried too many times. 419 414 */ 420 415 if (++rq->errors > ERROR_MAX) 421 416 do_end_request = 1; 422 417 } else if (sense_key == ILLEGAL_REQUEST || 423 418 sense_key == DATA_PROTECT) { 424 419 /* 425 - * No point in retrying after an illegal 426 - * request or data protect error. 420 + * No point in retrying after an illegal request or data 421 + * protect error. 427 422 */ 428 423 ide_dump_status_no_sense(drive, "command error", stat); 429 424 do_end_request = 1; 430 425 } else if (sense_key == MEDIUM_ERROR) { 431 426 /* 432 427 * No point in re-trying a zillion times on a bad 433 - * sector... If we got here the error is not correctable 428 + * sector. If we got here the error is not correctable. 434 429 */ 435 - ide_dump_status_no_sense(drive, "media error (bad sector)", stat); 430 + ide_dump_status_no_sense(drive, 431 + "media error (bad sector)", 432 + stat); 436 433 do_end_request = 1; 437 434 } else if (sense_key == BLANK_CHECK) { 438 - /* Disk appears blank ?? */ 439 - ide_dump_status_no_sense(drive, "media error (blank)", stat); 435 + /* disk appears blank ?? */ 436 + ide_dump_status_no_sense(drive, "media error (blank)", 437 + stat); 440 438 do_end_request = 1; 441 439 } else if ((err & ~ABRT_ERR) != 0) { 442 - /* Go to the default handler 443 - for other errors. */ 440 + /* go to the default handler for other errors */ 444 441 ide_error(drive, "cdrom_decode_status", stat); 445 442 return 1; 446 443 } else if ((++rq->errors > ERROR_MAX)) { 447 - /* We've racked up too many retries. Abort. */ 444 + /* we've racked up too many retries, abort */ 448 445 do_end_request = 1; 449 446 } 450 447 451 - /* End a request through request sense analysis when we have 452 - sense data. We need this in order to perform end of media 453 - processing */ 454 - 448 + /* 449 + * End a request through request sense analysis when we have 450 + * sense data. We need this in order to perform end of media 451 + * processing. 452 + */ 455 453 if (do_end_request) 456 454 goto end_request; 457 455 458 456 /* 459 - * If we got a CHECK_CONDITION status, 460 - * queue a request sense command. 457 + * If we got a CHECK_CONDITION status, queue 458 + * a request sense command. 461 459 */ 462 460 if (stat & ERR_STAT) 463 461 cdrom_queue_request_sense(drive, NULL, NULL); ··· 469 461 cdrom_end_request(drive, 0); 470 462 } 471 463 472 - /* Retry, or handle the next request. */ 464 + /* retry, or handle the next request */ 473 465 return 1; 474 466 475 467 end_request: ··· 494 486 unsigned long wait = 0; 495 487 496 488 /* 497 - * Some commands are *slow* and normally take a long time to 498 - * complete. Usually we can use the ATAPI "disconnect" to bypass 499 - * this, but not all commands/drives support that. Let 500 - * ide_timer_expiry keep polling us for these. 489 + * Some commands are *slow* and normally take a long time to complete. 490 + * Usually we can use the ATAPI "disconnect" to bypass this, but not all 491 + * commands/drives support that. Let ide_timer_expiry keep polling us 492 + * for these. 501 493 */ 502 494 switch (rq->cmd[0]) { 503 495 case GPCMD_BLANK: ··· 509 501 break; 510 502 default: 511 503 if (!(rq->cmd_flags & REQ_QUIET)) 512 - printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]); 504 + printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", 505 + rq->cmd[0]); 513 506 wait = 0; 514 507 break; 515 508 } 516 509 return wait; 517 510 } 518 511 519 - /* Set up the device registers for transferring a packet command on DEV, 520 - expecting to later transfer XFERLEN bytes. HANDLER is the routine 521 - which actually transfers the command to the drive. If this is a 522 - drq_interrupt device, this routine will arrange for HANDLER to be 523 - called when the interrupt from the drive arrives. Otherwise, HANDLER 524 - will be called immediately after the drive is prepared for the transfer. */ 525 - 512 + /* 513 + * Set up the device registers for transferring a packet command on DEV, 514 + * expecting to later transfer XFERLEN bytes. HANDLER is the routine 515 + * which actually transfers the command to the drive. If this is a 516 + * drq_interrupt device, this routine will arrange for HANDLER to be 517 + * called when the interrupt from the drive arrives. Otherwise, HANDLER 518 + * will be called immediately after the drive is prepared for the transfer. 519 + */ 526 520 static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, 527 521 int xferlen, 528 522 ide_handler_t *handler) ··· 533 523 struct cdrom_info *info = drive->driver_data; 534 524 ide_hwif_t *hwif = drive->hwif; 535 525 536 - /* Wait for the controller to be idle. */ 526 + /* wait for the controller to be idle */ 537 527 if (ide_wait_stat(&startstop, drive, 0, BUSY_STAT, WAIT_READY)) 538 528 return startstop; 539 529 540 530 /* FIXME: for Virtual DMA we must check harder */ 541 531 if (info->dma) 542 - info->dma = !hwif->dma_setup(drive); 532 + info->dma = !hwif->dma_ops->dma_setup(drive); 543 533 544 - /* Set up the controller registers. */ 534 + /* set up the controller registers */ 545 535 ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL | 546 536 IDE_TFLAG_NO_SELECT_MASK, xferlen, info->dma); 547 537 ··· 551 541 drive->waiting_for_dma = 0; 552 542 553 543 /* packet command */ 554 - ide_execute_command(drive, WIN_PACKETCMD, handler, ATAPI_WAIT_PC, cdrom_timer_expiry); 544 + ide_execute_command(drive, WIN_PACKETCMD, handler, 545 + ATAPI_WAIT_PC, cdrom_timer_expiry); 555 546 return ide_started; 556 547 } else { 557 548 unsigned long flags; ··· 568 557 } 569 558 } 570 559 571 - /* Send a packet command to DRIVE described by CMD_BUF and CMD_LEN. 572 - The device registers must have already been prepared 573 - by cdrom_start_packet_command. 574 - HANDLER is the interrupt handler to call when the command completes 575 - or there's data ready. */ 560 + /* 561 + * Send a packet command to DRIVE described by CMD_BUF and CMD_LEN. The device 562 + * registers must have already been prepared by cdrom_start_packet_command. 563 + * HANDLER is the interrupt handler to call when the command completes or 564 + * there's data ready. 565 + */ 576 566 #define ATAPI_MIN_CDB_BYTES 12 577 567 static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, 578 568 struct request *rq, ··· 585 573 ide_startstop_t startstop; 586 574 587 575 if (info->cd_flags & IDE_CD_FLAG_DRQ_INTERRUPT) { 588 - /* Here we should have been called after receiving an interrupt 589 - from the device. DRQ should how be set. */ 576 + /* 577 + * Here we should have been called after receiving an interrupt 578 + * from the device. DRQ should how be set. 579 + */ 590 580 591 - /* Check for errors. */ 581 + /* check for errors */ 592 582 if (cdrom_decode_status(drive, DRQ_STAT, NULL)) 593 583 return ide_stopped; 594 584 595 - /* Ok, next interrupt will be DMA interrupt. */ 585 + /* ok, next interrupt will be DMA interrupt */ 596 586 if (info->dma) 597 587 drive->waiting_for_dma = 1; 598 588 } else { 599 - /* Otherwise, we must wait for DRQ to get set. */ 589 + /* otherwise, we must wait for DRQ to get set */ 600 590 if (ide_wait_stat(&startstop, drive, DRQ_STAT, 601 591 BUSY_STAT, WAIT_READY)) 602 592 return startstop; 603 593 } 604 594 605 - /* Arm the interrupt handler. */ 595 + /* arm the interrupt handler */ 606 596 ide_set_handler(drive, handler, rq->timeout, cdrom_timer_expiry); 607 597 608 598 /* ATAPI commands get padded out to 12 bytes minimum */ ··· 612 598 if (cmd_len < ATAPI_MIN_CDB_BYTES) 613 599 cmd_len = ATAPI_MIN_CDB_BYTES; 614 600 615 - /* Send the command to the device. */ 601 + /* send the command to the device */ 616 602 HWIF(drive)->atapi_output_bytes(drive, rq->cmd, cmd_len); 617 603 618 - /* Start the DMA if need be */ 604 + /* start the DMA if need be */ 619 605 if (info->dma) 620 - hwif->dma_start(drive); 606 + hwif->dma_ops->dma_start(drive); 621 607 622 608 return ide_started; 623 609 } 624 610 625 - /**************************************************************************** 611 + /* 626 612 * Block read functions. 627 613 */ 628 - 629 614 static void ide_cd_pad_transfer(ide_drive_t *drive, xfer_func_t *xf, int len) 630 615 { 631 616 while (len > 0) { ··· 662 649 ide_hwif_t *hwif = drive->hwif; 663 650 xfer_func_t *xf; 664 651 665 - /* Whoops... */ 652 + /* whoops... */ 666 653 printk(KERN_ERR "%s: %s: wrong transfer direction!\n", 667 654 drive->name, __func__); 668 655 669 656 xf = rw ? hwif->atapi_output_bytes : hwif->atapi_input_bytes; 670 657 ide_cd_pad_transfer(drive, xf, len); 671 658 } else if (rw == 0 && ireason == 1) { 672 - /* Some drives (ASUS) seem to tell us that status 673 - * info is available. just get it and ignore. 659 + /* 660 + * Some drives (ASUS) seem to tell us that status info is 661 + * available. Just get it and ignore. 674 662 */ 675 663 (void)ide_read_status(drive); 676 664 return 0; 677 665 } else { 678 - /* Drive wants a command packet, or invalid ireason... */ 666 + /* drive wants a command packet, or invalid ireason... */ 679 667 printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", 680 668 drive->name, __func__, ireason); 681 669 } ··· 716 702 static ide_startstop_t cdrom_newpc_intr(ide_drive_t *); 717 703 718 704 /* 719 - * Routine to send a read/write packet command to the drive. 720 - * This is usually called directly from cdrom_start_{read,write}(). 721 - * However, for drq_interrupt devices, it is called from an interrupt 722 - * when the drive is ready to accept the command. 705 + * Routine to send a read/write packet command to the drive. This is usually 706 + * called directly from cdrom_start_{read,write}(). However, for drq_interrupt 707 + * devices, it is called from an interrupt when the drive is ready to accept 708 + * the command. 723 709 */ 724 710 static ide_startstop_t cdrom_start_rw_cont(ide_drive_t *drive) 725 711 { ··· 741 727 * is larger than the buffer size. 742 728 */ 743 729 if (nskip > 0) { 744 - /* Sanity check... */ 730 + /* sanity check... */ 745 731 if (rq->current_nr_sectors != 746 732 bio_cur_sectors(rq->bio)) { 747 733 printk(KERN_ERR "%s: %s: buffer botch (%u)\n", ··· 758 744 /* the immediate bit */ 759 745 rq->cmd[1] = 1 << 3; 760 746 #endif 761 - /* Set up the command */ 747 + /* set up the command */ 762 748 rq->timeout = ATAPI_WAIT_PC; 763 749 764 - /* Send the command to the drive and return. */ 750 + /* send the command to the drive and return */ 765 751 return cdrom_transfer_packet_command(drive, rq, cdrom_newpc_intr); 766 752 } 767 753 ··· 781 767 info->cd_flags |= IDE_CD_FLAG_SEEKING; 782 768 783 769 if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { 784 - if (--retry == 0) { 785 - /* 786 - * this condition is far too common, to bother 787 - * users about it 788 - */ 789 - /* printk("%s: disabled DSC seek overlap\n", drive->name);*/ 770 + if (--retry == 0) 790 771 drive->dsc_overlap = 0; 791 - } 792 772 } 793 773 return ide_stopped; 794 774 } ··· 808 800 809 801 info->dma = 0; 810 802 info->start_seek = jiffies; 811 - return cdrom_start_packet_command(drive, 0, cdrom_start_seek_continuation); 803 + return cdrom_start_packet_command(drive, 0, 804 + cdrom_start_seek_continuation); 812 805 } 813 806 814 807 /* 815 - * Fix up a possibly partially-processed request so that we can 816 - * start it over entirely, or even put it back on the request queue. 808 + * Fix up a possibly partially-processed request so that we can start it over 809 + * entirely, or even put it back on the request queue. 817 810 */ 818 811 static void restore_request(struct request *rq) 819 812 { 820 813 if (rq->buffer != bio_data(rq->bio)) { 821 - sector_t n = (rq->buffer - (char *) bio_data(rq->bio)) / SECTOR_SIZE; 814 + sector_t n = 815 + (rq->buffer - (char *)bio_data(rq->bio)) / SECTOR_SIZE; 822 816 823 817 rq->buffer = bio_data(rq->bio); 824 818 rq->nr_sectors += n; 825 819 rq->sector -= n; 826 820 } 827 - rq->hard_cur_sectors = rq->current_nr_sectors = bio_cur_sectors(rq->bio); 821 + rq->current_nr_sectors = bio_cur_sectors(rq->bio); 822 + rq->hard_cur_sectors = rq->current_nr_sectors; 828 823 rq->hard_nr_sectors = rq->nr_sectors; 829 824 rq->hard_sector = rq->sector; 830 825 rq->q->prep_rq_fn(rq->q, rq); 831 826 } 832 827 833 - /**************************************************************************** 834 - * Execute all other packet commands. 828 + /* 829 + * All other packet commands. 835 830 */ 836 - 837 831 static void ide_cd_request_sense_fixup(struct request *rq) 838 832 { 839 833 /* ··· 859 849 if (rq->sense == NULL) 860 850 rq->sense = &sense; 861 851 862 - /* Start of retry loop. */ 852 + /* start of retry loop */ 863 853 do { 864 854 int error; 865 855 unsigned long time = jiffies; ··· 868 858 error = ide_do_drive_cmd(drive, rq, ide_wait); 869 859 time = jiffies - time; 870 860 871 - /* FIXME: we should probably abort/retry or something 872 - * in case of failure */ 861 + /* 862 + * FIXME: we should probably abort/retry or something in case of 863 + * failure. 864 + */ 873 865 if (rq->cmd_flags & REQ_FAILED) { 874 - /* The request failed. Retry if it was due to a unit 875 - attention status 876 - (usually means media was changed). */ 866 + /* 867 + * The request failed. Retry if it was due to a unit 868 + * attention status (usually means media was changed). 869 + */ 877 870 struct request_sense *reqbuf = rq->sense; 878 871 879 872 if (reqbuf->sense_key == UNIT_ATTENTION) 880 873 cdrom_saw_media_change(drive); 881 874 else if (reqbuf->sense_key == NOT_READY && 882 875 reqbuf->asc == 4 && reqbuf->ascq != 4) { 883 - /* The drive is in the process of loading 884 - a disk. Retry, but wait a little to give 885 - the drive time to complete the load. */ 876 + /* 877 + * The drive is in the process of loading 878 + * a disk. Retry, but wait a little to give 879 + * the drive time to complete the load. 880 + */ 886 881 ssleep(2); 887 882 } else { 888 - /* Otherwise, don't retry. */ 883 + /* otherwise, don't retry */ 889 884 retries = 0; 890 885 } 891 886 --retries; 892 887 } 893 888 894 - /* End of retry loop. */ 889 + /* end of retry loop */ 895 890 } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); 896 891 897 - /* Return an error if the command failed. */ 892 + /* return an error if the command failed */ 898 893 return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; 899 894 } 900 895 901 896 /* 902 - * Called from blk_end_request_callback() after the data of the request 903 - * is completed and before the request is completed. 904 - * By returning value '1', blk_end_request_callback() returns immediately 905 - * without completing the request. 897 + * Called from blk_end_request_callback() after the data of the request is 898 + * completed and before the request itself is completed. By returning value '1', 899 + * blk_end_request_callback() returns immediately without completing it. 906 900 */ 907 901 static int cdrom_newpc_intr_dummy_cb(struct request *rq) 908 902 { ··· 925 911 unsigned int timeout; 926 912 u8 lowcyl, highcyl; 927 913 928 - /* Check for errors. */ 914 + /* check for errors */ 929 915 dma = info->dma; 930 916 if (dma) { 931 917 info->dma = 0; 932 - dma_error = HWIF(drive)->ide_dma_end(drive); 918 + dma_error = hwif->dma_ops->dma_end(drive); 933 919 if (dma_error) { 934 920 printk(KERN_ERR "%s: DMA %s error\n", drive->name, 935 921 write ? "write" : "read"); ··· 940 926 if (cdrom_decode_status(drive, 0, &stat)) 941 927 return ide_stopped; 942 928 943 - /* 944 - * using dma, transfer is complete now 945 - */ 929 + /* using dma, transfer is complete now */ 946 930 if (dma) { 947 931 if (dma_error) 948 932 return ide_error(drive, "dma error", stat); ··· 951 939 goto end_request; 952 940 } 953 941 954 - /* 955 - * ok we fall to pio :/ 956 - */ 942 + /* ok we fall to pio :/ */ 957 943 ireason = hwif->INB(hwif->io_ports[IDE_IREASON_OFFSET]) & 0x3; 958 944 lowcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTL_OFFSET]); 959 945 highcyl = hwif->INB(hwif->io_ports[IDE_BCOUNTH_OFFSET]); ··· 962 952 if (thislen > len) 963 953 thislen = len; 964 954 965 - /* 966 - * If DRQ is clear, the command has completed. 967 - */ 955 + /* If DRQ is clear, the command has completed. */ 968 956 if ((stat & DRQ_STAT) == 0) { 969 957 if (blk_fs_request(rq)) { 970 958 /* ··· 983 975 return ide_stopped; 984 976 } else if (!blk_pc_request(rq)) { 985 977 ide_cd_request_sense_fixup(rq); 986 - /* Complain if we still have data left to transfer. */ 978 + /* complain if we still have data left to transfer */ 987 979 uptodate = rq->data_len ? 0 : 1; 988 980 } 989 981 goto end_request; 990 982 } 991 983 992 - /* 993 - * check which way to transfer data 994 - */ 984 + /* check which way to transfer data */ 995 985 if (ide_cd_check_ireason(drive, rq, len, ireason, write)) 996 986 return ide_stopped; 997 987 ··· 1025 1019 xferfunc = HWIF(drive)->atapi_input_bytes; 1026 1020 } 1027 1021 1028 - /* 1029 - * transfer data 1030 - */ 1022 + /* transfer data */ 1031 1023 while (thislen > 0) { 1032 1024 u8 *ptr = blk_fs_request(rq) ? NULL : rq->data; 1033 1025 int blen = rq->data_len; 1034 1026 1035 - /* 1036 - * bio backed? 1037 - */ 1027 + /* bio backed? */ 1038 1028 if (rq->bio) { 1039 1029 if (blk_fs_request(rq)) { 1040 1030 ptr = rq->buffer; ··· 1045 1043 if (blk_fs_request(rq) && !write) 1046 1044 /* 1047 1045 * If the buffers are full, pipe the rest into 1048 - * oblivion. */ 1046 + * oblivion. 1047 + */ 1049 1048 ide_cd_drain_data(drive, thislen >> 9); 1050 1049 else { 1051 1050 printk(KERN_ERR "%s: confused, missing data\n", ··· 1093 1090 rq->sense_len += blen; 1094 1091 } 1095 1092 1096 - /* 1097 - * pad, if necessary 1098 - */ 1093 + /* pad, if necessary */ 1099 1094 if (!blk_fs_request(rq) && len > 0) 1100 1095 ide_cd_pad_transfer(drive, xferfunc, len); 1101 1096 ··· 1137 1136 queue_hardsect_size(drive->queue) >> SECTOR_BITS; 1138 1137 1139 1138 if (write) { 1140 - /* 1141 - * disk has become write protected 1142 - */ 1139 + /* disk has become write protected */ 1143 1140 if (cd->disk->policy) { 1144 1141 cdrom_end_request(drive, 0); 1145 1142 return ide_stopped; ··· 1150 1151 restore_request(rq); 1151 1152 } 1152 1153 1153 - /* 1154 - * use DMA, if possible / writes *must* be hardware frame aligned 1155 - */ 1154 + /* use DMA, if possible / writes *must* be hardware frame aligned */ 1156 1155 if ((rq->nr_sectors & (sectors_per_frame - 1)) || 1157 1156 (rq->sector & (sectors_per_frame - 1))) { 1158 1157 if (write) { ··· 1164 1167 if (write) 1165 1168 cd->devinfo.media_written = 1; 1166 1169 1167 - /* Start sending the read/write request to the drive. */ 1170 + /* start sending the read/write request to the drive */ 1168 1171 return cdrom_start_packet_command(drive, 32768, cdrom_start_rw_cont); 1169 1172 } 1170 1173 ··· 1189 1192 1190 1193 info->dma = 0; 1191 1194 1192 - /* 1193 - * sg request 1194 - */ 1195 + /* sg request */ 1195 1196 if (rq->bio) { 1196 1197 int mask = drive->queue->dma_alignment; 1197 - unsigned long addr = (unsigned long) page_address(bio_page(rq->bio)); 1198 + unsigned long addr = 1199 + (unsigned long)page_address(bio_page(rq->bio)); 1198 1200 1199 1201 info->dma = drive->using_dma; 1200 1202 ··· 1207 1211 info->dma = 0; 1208 1212 } 1209 1213 1210 - /* Start sending the command to the drive. */ 1211 - return cdrom_start_packet_command(drive, rq->data_len, cdrom_do_newpc_cont); 1214 + /* start sending the command to the drive */ 1215 + return cdrom_start_packet_command(drive, rq->data_len, 1216 + cdrom_do_newpc_cont); 1212 1217 } 1213 1218 1214 - /**************************************************************************** 1219 + /* 1215 1220 * cdrom driver request routine. 1216 1221 */ 1217 - static ide_startstop_t 1218 - ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, sector_t block) 1222 + static ide_startstop_t ide_do_rw_cdrom(ide_drive_t *drive, struct request *rq, 1223 + sector_t block) 1219 1224 { 1220 1225 ide_startstop_t action; 1221 1226 struct cdrom_info *info = drive->driver_data; ··· 1228 1231 1229 1232 if ((stat & SEEK_STAT) != SEEK_STAT) { 1230 1233 if (elapsed < IDECD_SEEK_TIMEOUT) { 1231 - ide_stall_queue(drive, IDECD_SEEK_TIMER); 1234 + ide_stall_queue(drive, 1235 + IDECD_SEEK_TIMER); 1232 1236 return ide_stopped; 1233 1237 } 1234 - printk(KERN_ERR "%s: DSC timeout\n", drive->name); 1238 + printk(KERN_ERR "%s: DSC timeout\n", 1239 + drive->name); 1235 1240 } 1236 1241 info->cd_flags &= ~IDE_CD_FLAG_SEEKING; 1237 1242 } 1238 - if ((rq_data_dir(rq) == READ) && IDE_LARGE_SEEK(info->last_block, block, IDECD_SEEK_THRESHOLD) && drive->dsc_overlap) 1243 + if (rq_data_dir(rq) == READ && 1244 + IDE_LARGE_SEEK(info->last_block, block, 1245 + IDECD_SEEK_THRESHOLD) && 1246 + drive->dsc_overlap) 1239 1247 action = cdrom_start_seek(drive, block); 1240 1248 else 1241 1249 action = cdrom_start_rw(drive, rq); ··· 1250 1248 rq->cmd_type == REQ_TYPE_ATA_PC) { 1251 1249 return cdrom_do_block_pc(drive, rq); 1252 1250 } else if (blk_special_request(rq)) { 1253 - /* 1254 - * right now this can only be a reset... 1255 - */ 1251 + /* right now this can only be a reset... */ 1256 1252 cdrom_end_request(drive, 1); 1257 1253 return ide_stopped; 1258 1254 } ··· 1262 1262 1263 1263 1264 1264 1265 - /**************************************************************************** 1265 + /* 1266 1266 * Ioctl handling. 1267 1267 * 1268 - * Routines which queue packet commands take as a final argument a pointer 1269 - * to a request_sense struct. If execution of the command results 1270 - * in an error with a CHECK CONDITION status, this structure will be filled 1271 - * with the results of the subsequent request sense command. The pointer 1272 - * can also be NULL, in which case no sense information is returned. 1268 + * Routines which queue packet commands take as a final argument a pointer to a 1269 + * request_sense struct. If execution of the command results in an error with a 1270 + * CHECK CONDITION status, this structure will be filled with the results of the 1271 + * subsequent request sense command. The pointer can also be NULL, in which case 1272 + * no sense information is returned. 1273 1273 */ 1274 - 1275 - static 1276 - void msf_from_bcd(struct atapi_msf *msf) 1274 + static void msf_from_bcd(struct atapi_msf *msf) 1277 1275 { 1278 1276 msf->minute = BCD2BIN(msf->minute); 1279 1277 msf->second = BCD2BIN(msf->second); ··· 1291 1293 req.cmd_flags |= REQ_QUIET; 1292 1294 1293 1295 /* 1294 - * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to 1295 - * switch CDs instead of supporting the LOAD_UNLOAD opcode. 1296 + * Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to switch CDs 1297 + * instead of supporting the LOAD_UNLOAD opcode. 1296 1298 */ 1297 1299 req.cmd[7] = cdi->sanyo_slot % 3; 1298 1300 ··· 1368 1370 unsigned long sectors_per_frame = SECTORS_PER_FRAME; 1369 1371 1370 1372 if (toc == NULL) { 1371 - /* Try to allocate space. */ 1373 + /* try to allocate space */ 1372 1374 toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); 1373 1375 if (toc == NULL) { 1374 - printk(KERN_ERR "%s: No cdrom TOC buffer!\n", drive->name); 1376 + printk(KERN_ERR "%s: No cdrom TOC buffer!\n", 1377 + drive->name); 1375 1378 return -ENOMEM; 1376 1379 } 1377 1380 info->toc = toc; 1378 1381 } 1379 1382 1380 - /* Check to see if the existing data is still valid. 1381 - If it is, just return. */ 1383 + /* 1384 + * Check to see if the existing data is still valid. If it is, 1385 + * just return. 1386 + */ 1382 1387 (void) cdrom_check_status(drive, sense); 1383 1388 1384 1389 if (info->cd_flags & IDE_CD_FLAG_TOC_VALID) 1385 1390 return 0; 1386 1391 1387 - /* Try to get the total cdrom capacity and sector size. */ 1392 + /* try to get the total cdrom capacity and sector size */ 1388 1393 stat = cdrom_read_capacity(drive, &toc->capacity, &sectors_per_frame, 1389 1394 sense); 1390 1395 if (stat) 1391 1396 toc->capacity = 0x1fffff; 1392 1397 1393 1398 set_capacity(info->disk, toc->capacity * sectors_per_frame); 1394 - /* Save a private copy of te TOC capacity for error handling */ 1399 + /* save a private copy of the TOC capacity for error handling */ 1395 1400 drive->probed_capacity = toc->capacity * sectors_per_frame; 1396 1401 1397 1402 blk_queue_hardsect_size(drive->queue, 1398 1403 sectors_per_frame << SECTOR_BITS); 1399 1404 1400 - /* First read just the header, so we know how long the TOC is. */ 1405 + /* first read just the header, so we know how long the TOC is */ 1401 1406 stat = cdrom_read_tocentry(drive, 0, 1, 0, (char *) &toc->hdr, 1402 1407 sizeof(struct atapi_toc_header), sense); 1403 1408 if (stat) ··· 1417 1416 if (ntracks > MAX_TRACKS) 1418 1417 ntracks = MAX_TRACKS; 1419 1418 1420 - /* Now read the whole schmeer. */ 1419 + /* now read the whole schmeer */ 1421 1420 stat = cdrom_read_tocentry(drive, toc->hdr.first_track, 1, 0, 1422 1421 (char *)&toc->hdr, 1423 1422 sizeof(struct atapi_toc_header) + ··· 1425 1424 sizeof(struct atapi_toc_entry), sense); 1426 1425 1427 1426 if (stat && toc->hdr.first_track > 1) { 1428 - /* Cds with CDI tracks only don't have any TOC entries, 1429 - despite of this the returned values are 1430 - first_track == last_track = number of CDI tracks + 1, 1431 - so that this case is indistinguishable from the same 1432 - layout plus an additional audio track. 1433 - If we get an error for the regular case, we assume 1434 - a CDI without additional audio tracks. In this case 1435 - the readable TOC is empty (CDI tracks are not included) 1436 - and only holds the Leadout entry. Heiko Eißfeldt */ 1427 + /* 1428 + * Cds with CDI tracks only don't have any TOC entries, despite 1429 + * of this the returned values are 1430 + * first_track == last_track = number of CDI tracks + 1, 1431 + * so that this case is indistinguishable from the same layout 1432 + * plus an additional audio track. If we get an error for the 1433 + * regular case, we assume a CDI without additional audio 1434 + * tracks. In this case the readable TOC is empty (CDI tracks 1435 + * are not included) and only holds the Leadout entry. 1436 + * 1437 + * Heiko Eißfeldt. 1438 + */ 1437 1439 ntracks = 0; 1438 1440 stat = cdrom_read_tocentry(drive, CDROM_LEADOUT, 1, 0, 1439 1441 (char *)&toc->hdr, ··· 1477 1473 toc->ent[i].addr.msf.frame); 1478 1474 } 1479 1475 1480 - /* Read the multisession information. */ 1481 1476 if (toc->hdr.first_track != CDROM_LEADOUT) { 1482 - /* Read the multisession information. */ 1477 + /* read the multisession information */ 1483 1478 stat = cdrom_read_tocentry(drive, 0, 0, 1, (char *)&ms_tmp, 1484 1479 sizeof(ms_tmp), sense); 1485 1480 if (stat) ··· 1486 1483 1487 1484 toc->last_session_lba = be32_to_cpu(ms_tmp.ent.addr.lba); 1488 1485 } else { 1489 - ms_tmp.hdr.first_track = ms_tmp.hdr.last_track = CDROM_LEADOUT; 1486 + ms_tmp.hdr.last_track = CDROM_LEADOUT; 1487 + ms_tmp.hdr.first_track = ms_tmp.hdr.last_track; 1490 1488 toc->last_session_lba = msf_to_lba(0, 2, 0); /* 0m 2s 0f */ 1491 1489 } 1492 1490 1493 1491 if (info->cd_flags & IDE_CD_FLAG_TOCADDR_AS_BCD) { 1494 - /* Re-read multisession information using MSF format */ 1492 + /* re-read multisession information using MSF format */ 1495 1493 stat = cdrom_read_tocentry(drive, 0, 1, 1, (char *)&ms_tmp, 1496 1494 sizeof(ms_tmp), sense); 1497 1495 if (stat) ··· 1506 1502 1507 1503 toc->xa_flag = (ms_tmp.hdr.first_track != ms_tmp.hdr.last_track); 1508 1504 1509 - /* Now try to get the total cdrom capacity. */ 1505 + /* now try to get the total cdrom capacity */ 1510 1506 stat = cdrom_get_last_written(cdi, &last_written); 1511 1507 if (!stat && (last_written > toc->capacity)) { 1512 1508 toc->capacity = last_written; ··· 1531 1527 size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; 1532 1528 1533 1529 init_cdrom_command(&cgc, buf, size, CGC_DATA_UNKNOWN); 1534 - do { /* we seem to get stat=0x01,err=0x00 the first time (??) */ 1530 + do { 1531 + /* we seem to get stat=0x01,err=0x00 the first time (??) */ 1535 1532 stat = cdrom_mode_sense(cdi, &cgc, GPMODE_CAPABILITIES_PAGE, 0); 1536 1533 if (!stat) 1537 1534 break; ··· 1601 1596 return register_cdrom(devinfo); 1602 1597 } 1603 1598 1604 - static 1605 - int ide_cdrom_probe_capabilities(ide_drive_t *drive) 1599 + static int ide_cdrom_probe_capabilities(ide_drive_t *drive) 1606 1600 { 1607 1601 struct cdrom_info *cd = drive->driver_data; 1608 1602 struct cdrom_device_info *cdi = &cd->devinfo; ··· 1615 1611 1616 1612 if (drive->media == ide_optical) { 1617 1613 cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); 1618 - printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", drive->name); 1614 + printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", 1615 + drive->name); 1619 1616 return nslots; 1620 1617 } 1621 1618 ··· 1627 1622 } 1628 1623 1629 1624 /* 1630 - * we have to cheat a little here. the packet will eventually 1631 - * be queued with ide_cdrom_packet(), which extracts the 1632 - * drive from cdi->handle. Since this device hasn't been 1633 - * registered with the Uniform layer yet, it can't do this. 1634 - * Same goes for cdi->ops. 1625 + * We have to cheat a little here. the packet will eventually be queued 1626 + * with ide_cdrom_packet(), which extracts the drive from cdi->handle. 1627 + * Since this device hasn't been registered with the Uniform layer yet, 1628 + * it can't do this. Same goes for cdi->ops. 1635 1629 */ 1636 1630 cdi->handle = drive; 1637 1631 cdi->ops = &ide_cdrom_dops; ··· 1699 1695 return nslots; 1700 1696 } 1701 1697 1702 - #ifdef CONFIG_IDE_PROC_FS 1703 - static void ide_cdrom_add_settings(ide_drive_t *drive) 1704 - { 1705 - ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->dsc_overlap, NULL); 1706 - } 1707 - #else 1708 - static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; } 1709 - #endif 1710 - 1711 - /* 1712 - * standard prep_rq_fn that builds 10 byte cmds 1713 - */ 1698 + /* standard prep_rq_fn that builds 10 byte cmds */ 1714 1699 static int ide_cdrom_prep_fs(struct request_queue *q, struct request *rq) 1715 1700 { 1716 1701 int hard_sect = queue_hardsect_size(q); ··· 1738 1745 { 1739 1746 u8 *c = rq->cmd; 1740 1747 1741 - /* 1742 - * Transform 6-byte read/write commands to the 10-byte version 1743 - */ 1748 + /* transform 6-byte read/write commands to the 10-byte version */ 1744 1749 if (c[0] == READ_6 || c[0] == WRITE_6) { 1745 1750 c[8] = c[4]; 1746 1751 c[5] = c[3]; ··· 1779 1788 const char *id_firmware; 1780 1789 unsigned int cd_flags; 1781 1790 }; 1791 + 1792 + #ifdef CONFIG_IDE_PROC_FS 1793 + static sector_t ide_cdrom_capacity(ide_drive_t *drive) 1794 + { 1795 + unsigned long capacity, sectors_per_frame; 1796 + 1797 + if (cdrom_read_capacity(drive, &capacity, &sectors_per_frame, NULL)) 1798 + return 0; 1799 + 1800 + return capacity * sectors_per_frame; 1801 + } 1802 + 1803 + static int proc_idecd_read_capacity(char *page, char **start, off_t off, 1804 + int count, int *eof, void *data) 1805 + { 1806 + ide_drive_t *drive = data; 1807 + int len; 1808 + 1809 + len = sprintf(page, "%llu\n", (long long)ide_cdrom_capacity(drive)); 1810 + PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 1811 + } 1812 + 1813 + static ide_proc_entry_t idecd_proc[] = { 1814 + { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL }, 1815 + { NULL, 0, NULL, NULL } 1816 + }; 1817 + 1818 + static void ide_cdrom_add_settings(ide_drive_t *drive) 1819 + { 1820 + ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, 1821 + &drive->dsc_overlap, NULL); 1822 + } 1823 + #else 1824 + static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; } 1825 + #endif 1782 1826 1783 1827 static const struct cd_list_entry ide_cd_quirks_list[] = { 1784 1828 /* Limit transfer size per interrupt. */ ··· 1872 1846 return 0; 1873 1847 } 1874 1848 1875 - static 1876 - int ide_cdrom_setup(ide_drive_t *drive) 1849 + static int ide_cdrom_setup(ide_drive_t *drive) 1877 1850 { 1878 1851 struct cdrom_info *cd = drive->driver_data; 1879 1852 struct cdrom_device_info *cdi = &cd->devinfo; ··· 1901 1876 id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') 1902 1877 cd->cd_flags |= IDE_CD_FLAG_TOCTRACKS_AS_BCD; 1903 1878 else if (cd->cd_flags & IDE_CD_FLAG_SANYO_3CD) 1904 - cdi->sanyo_slot = 3; /* 3 => use CD in slot 0 */ 1879 + /* 3 => use CD in slot 0 */ 1880 + cdi->sanyo_slot = 3; 1905 1881 1906 1882 nslots = ide_cdrom_probe_capabilities(drive); 1907 1883 1908 - /* 1909 - * set correct block size 1910 - */ 1884 + /* set correct block size */ 1911 1885 blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE); 1912 1886 1913 1887 if (drive->autotune == IDE_TUNE_DEFAULT || ··· 1914 1890 drive->dsc_overlap = (drive->next != drive); 1915 1891 1916 1892 if (ide_cdrom_register(drive, nslots)) { 1917 - printk(KERN_ERR "%s: ide_cdrom_setup failed to register device with the cdrom driver.\n", drive->name); 1893 + printk(KERN_ERR "%s: %s failed to register device with the" 1894 + " cdrom driver.\n", drive->name, __func__); 1918 1895 cd->devinfo.handle = NULL; 1919 1896 return 1; 1920 1897 } ··· 1953 1928 } 1954 1929 1955 1930 static int ide_cd_probe(ide_drive_t *); 1956 - 1957 - #ifdef CONFIG_IDE_PROC_FS 1958 - static sector_t ide_cdrom_capacity(ide_drive_t *drive) 1959 - { 1960 - unsigned long capacity, sectors_per_frame; 1961 - 1962 - if (cdrom_read_capacity(drive, &capacity, &sectors_per_frame, NULL)) 1963 - return 0; 1964 - 1965 - return capacity * sectors_per_frame; 1966 - } 1967 - 1968 - static int proc_idecd_read_capacity 1969 - (char *page, char **start, off_t off, int count, int *eof, void *data) 1970 - { 1971 - ide_drive_t *drive = data; 1972 - int len; 1973 - 1974 - len = sprintf(page, "%llu\n", (long long)ide_cdrom_capacity(drive)); 1975 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 1976 - } 1977 - 1978 - static ide_proc_entry_t idecd_proc[] = { 1979 - { "capacity", S_IFREG|S_IRUGO, proc_idecd_read_capacity, NULL }, 1980 - { NULL, 0, NULL, NULL } 1981 - }; 1982 - #endif 1983 1931 1984 1932 static ide_driver_t ide_cdrom_driver = { 1985 1933 .gen_driver = { ··· 2091 2093 .revalidate_disk = idecd_revalidate_disk 2092 2094 }; 2093 2095 2094 - /* options */ 2096 + /* module options */ 2095 2097 static char *ignore; 2096 2098 2097 2099 module_param(ignore, charp, 0400); ··· 2112 2114 /* skip drives that we were told to ignore */ 2113 2115 if (ignore != NULL) { 2114 2116 if (strstr(ignore, drive->name)) { 2115 - printk(KERN_INFO "ide-cd: ignoring drive %s\n", drive->name); 2117 + printk(KERN_INFO "ide-cd: ignoring drive %s\n", 2118 + drive->name); 2116 2119 goto failed; 2117 2120 } 2118 2121 } 2119 2122 if (drive->scsi) { 2120 - printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi emulation.\n", drive->name); 2123 + printk(KERN_INFO "ide-cd: passing drive %s to ide-scsi " 2124 + "emulation.\n", drive->name); 2121 2125 goto failed; 2122 2126 } 2123 2127 info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); 2124 2128 if (info == NULL) { 2125 - printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", drive->name); 2129 + printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", 2130 + drive->name); 2126 2131 goto failed; 2127 2132 } 2128 2133
+30 -108
drivers/ide/ide-dma.c
··· 102 102 { 103 103 u8 stat = 0, dma_stat = 0; 104 104 105 - dma_stat = HWIF(drive)->ide_dma_end(drive); 105 + dma_stat = drive->hwif->dma_ops->dma_end(drive); 106 106 stat = ide_read_status(drive); 107 107 108 108 if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { ··· 394 394 drive->using_dma = 0; 395 395 ide_toggle_bounce(drive, 0); 396 396 397 - drive->hwif->dma_host_set(drive, 0); 397 + drive->hwif->dma_ops->dma_host_set(drive, 0); 398 398 } 399 399 400 400 EXPORT_SYMBOL(ide_dma_off_quietly); ··· 427 427 drive->using_dma = 1; 428 428 ide_toggle_bounce(drive, 1); 429 429 430 - drive->hwif->dma_host_set(drive, 1); 430 + drive->hwif->dma_ops->dma_host_set(drive, 1); 431 431 } 432 432 433 433 #ifdef CONFIG_BLK_DEV_IDEDMA_SFF ··· 482 482 483 483 EXPORT_SYMBOL_GPL(ide_dma_setup); 484 484 485 - static void ide_dma_exec_cmd(ide_drive_t *drive, u8 command) 485 + void ide_dma_exec_cmd(ide_drive_t *drive, u8 command) 486 486 { 487 487 /* issue cmd to drive */ 488 488 ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry); 489 489 } 490 + EXPORT_SYMBOL_GPL(ide_dma_exec_cmd); 490 491 491 492 void ide_dma_start(ide_drive_t *drive) 492 493 { ··· 533 532 EXPORT_SYMBOL(__ide_dma_end); 534 533 535 534 /* returns 1 if dma irq issued, 0 otherwise */ 536 - static int __ide_dma_test_irq(ide_drive_t *drive) 535 + int ide_dma_test_irq(ide_drive_t *drive) 537 536 { 538 537 ide_hwif_t *hwif = HWIF(drive); 539 538 u8 dma_stat = hwif->INB(hwif->dma_status); ··· 543 542 return 1; 544 543 if (!drive->waiting_for_dma) 545 544 printk(KERN_WARNING "%s: (%s) called while not waiting\n", 546 - drive->name, __FUNCTION__); 545 + drive->name, __func__); 547 546 return 0; 548 547 } 548 + EXPORT_SYMBOL_GPL(ide_dma_test_irq); 549 549 #else 550 550 static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } 551 551 #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ ··· 576 574 { 577 575 struct hd_driveid *id = drive->id; 578 576 ide_hwif_t *hwif = drive->hwif; 577 + const struct ide_port_ops *port_ops = hwif->port_ops; 579 578 unsigned int mask = 0; 580 579 581 580 switch(base) { ··· 584 581 if ((id->field_valid & 4) == 0) 585 582 break; 586 583 587 - if (hwif->udma_filter) 588 - mask = hwif->udma_filter(drive); 584 + if (port_ops && port_ops->udma_filter) 585 + mask = port_ops->udma_filter(drive); 589 586 else 590 587 mask = hwif->ultra_mask; 591 588 mask &= id->dma_ultra; ··· 601 598 case XFER_MW_DMA_0: 602 599 if ((id->field_valid & 2) == 0) 603 600 break; 604 - if (hwif->mdma_filter) 605 - mask = hwif->mdma_filter(drive); 601 + if (port_ops && port_ops->mdma_filter) 602 + mask = port_ops->mdma_filter(drive); 606 603 else 607 604 mask = hwif->mwdma_mask; 608 605 mask &= id->dma_mword; ··· 804 801 805 802 printk(KERN_ERR "%s: timeout waiting for DMA\n", drive->name); 806 803 807 - if (hwif->ide_dma_test_irq(drive)) 804 + if (hwif->dma_ops->dma_test_irq(drive)) 808 805 return; 809 806 810 - hwif->ide_dma_end(drive); 807 + hwif->dma_ops->dma_end(drive); 811 808 } 812 809 813 810 EXPORT_SYMBOL(ide_dma_timeout); 814 811 815 - static void ide_release_dma_engine(ide_hwif_t *hwif) 812 + void ide_release_dma_engine(ide_hwif_t *hwif) 816 813 { 817 814 if (hwif->dmatable_cpu) { 818 815 struct pci_dev *pdev = to_pci_dev(hwif->dev); ··· 823 820 } 824 821 } 825 822 826 - static int ide_release_iomio_dma(ide_hwif_t *hwif) 827 - { 828 - release_region(hwif->dma_base, 8); 829 - if (hwif->extra_ports) 830 - release_region(hwif->extra_base, hwif->extra_ports); 831 - return 1; 832 - } 833 - 834 - /* 835 - * Needed for allowing full modular support of ide-driver 836 - */ 837 - int ide_release_dma(ide_hwif_t *hwif) 838 - { 839 - ide_release_dma_engine(hwif); 840 - 841 - if (hwif->mmio) 842 - return 1; 843 - else 844 - return ide_release_iomio_dma(hwif); 845 - } 846 - 847 - static int ide_allocate_dma_engine(ide_hwif_t *hwif) 823 + int ide_allocate_dma_engine(ide_hwif_t *hwif) 848 824 { 849 825 struct pci_dev *pdev = to_pci_dev(hwif->dev); 850 826 ··· 835 853 return 0; 836 854 837 855 printk(KERN_ERR "%s: -- Error, unable to allocate DMA table.\n", 838 - hwif->cds->name); 856 + hwif->name); 839 857 840 858 return 1; 841 859 } 860 + EXPORT_SYMBOL_GPL(ide_allocate_dma_engine); 842 861 843 - static int ide_mapped_mmio_dma(ide_hwif_t *hwif, unsigned long base) 844 - { 845 - printk(KERN_INFO " %s: MMIO-DMA ", hwif->name); 846 - 847 - return 0; 848 - } 849 - 850 - static int ide_iomio_dma(ide_hwif_t *hwif, unsigned long base) 851 - { 852 - printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", 853 - hwif->name, base, base + 7); 854 - 855 - if (!request_region(base, 8, hwif->name)) { 856 - printk(" -- Error, ports in use.\n"); 857 - return 1; 858 - } 859 - 860 - if (hwif->cds->extra) { 861 - hwif->extra_base = base + (hwif->channel ? 8 : 16); 862 - 863 - if (!hwif->mate || !hwif->mate->extra_ports) { 864 - if (!request_region(hwif->extra_base, 865 - hwif->cds->extra, hwif->cds->name)) { 866 - printk(" -- Error, extra ports in use.\n"); 867 - release_region(base, 8); 868 - return 1; 869 - } 870 - hwif->extra_ports = hwif->cds->extra; 871 - } 872 - } 873 - 874 - return 0; 875 - } 876 - 877 - static int ide_dma_iobase(ide_hwif_t *hwif, unsigned long base) 878 - { 879 - if (hwif->mmio) 880 - return ide_mapped_mmio_dma(hwif, base); 881 - 882 - return ide_iomio_dma(hwif, base); 883 - } 862 + static const struct ide_dma_ops sff_dma_ops = { 863 + .dma_host_set = ide_dma_host_set, 864 + .dma_setup = ide_dma_setup, 865 + .dma_exec_cmd = ide_dma_exec_cmd, 866 + .dma_start = ide_dma_start, 867 + .dma_end = __ide_dma_end, 868 + .dma_test_irq = ide_dma_test_irq, 869 + .dma_timeout = ide_dma_timeout, 870 + .dma_lost_irq = ide_dma_lost_irq, 871 + }; 884 872 885 873 void ide_setup_dma(ide_hwif_t *hwif, unsigned long base) 886 874 { 887 - u8 dma_stat; 888 - 889 - if (ide_dma_iobase(hwif, base)) 890 - return; 891 - 892 - if (ide_allocate_dma_engine(hwif)) { 893 - ide_release_dma(hwif); 894 - return; 895 - } 896 - 897 875 hwif->dma_base = base; 898 876 899 877 if (!hwif->dma_command) ··· 867 925 if (!hwif->dma_prdtable) 868 926 hwif->dma_prdtable = hwif->dma_base + 4; 869 927 870 - if (!hwif->dma_host_set) 871 - hwif->dma_host_set = &ide_dma_host_set; 872 - if (!hwif->dma_setup) 873 - hwif->dma_setup = &ide_dma_setup; 874 - if (!hwif->dma_exec_cmd) 875 - hwif->dma_exec_cmd = &ide_dma_exec_cmd; 876 - if (!hwif->dma_start) 877 - hwif->dma_start = &ide_dma_start; 878 - if (!hwif->ide_dma_end) 879 - hwif->ide_dma_end = &__ide_dma_end; 880 - if (!hwif->ide_dma_test_irq) 881 - hwif->ide_dma_test_irq = &__ide_dma_test_irq; 882 - if (!hwif->dma_timeout) 883 - hwif->dma_timeout = &ide_dma_timeout; 884 - if (!hwif->dma_lost_irq) 885 - hwif->dma_lost_irq = &ide_dma_lost_irq; 886 - 887 - dma_stat = hwif->INB(hwif->dma_status); 888 - printk(KERN_CONT ", BIOS settings: %s:%s, %s:%s\n", 889 - hwif->drives[0].name, (dma_stat & 0x20) ? "DMA" : "PIO", 890 - hwif->drives[1].name, (dma_stat & 0x40) ? "DMA" : "PIO"); 928 + hwif->dma_ops = &sff_dma_ops; 891 929 } 892 930 893 931 EXPORT_SYMBOL_GPL(ide_setup_dma);
+3 -3
drivers/ide/ide-floppy.c
··· 411 411 debug_log("Reached %s interrupt handler\n", __func__); 412 412 413 413 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { 414 - dma_error = hwif->ide_dma_end(drive); 414 + dma_error = hwif->dma_ops->dma_end(drive); 415 415 if (dma_error) { 416 416 printk(KERN_ERR "%s: DMA %s error\n", drive->name, 417 417 rq_data_dir(rq) ? "write" : "read"); ··· 663 663 dma = 0; 664 664 665 665 if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) 666 - dma = !hwif->dma_setup(drive); 666 + dma = !hwif->dma_ops->dma_setup(drive); 667 667 668 668 ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | 669 669 IDE_TFLAG_OUT_DEVICE, bcount, dma); ··· 671 671 if (dma) { 672 672 /* Begin DMA, if necessary */ 673 673 pc->flags |= PC_FLAG_DMA_IN_PROGRESS; 674 - hwif->dma_start(drive); 674 + hwif->dma_ops->dma_start(drive); 675 675 } 676 676 677 677 /* Can we transfer the packet when we get the interrupt or wait? */
+18 -2
drivers/ide/ide-generic.c
··· 94 94 unsigned long io_addr = ide_default_io_base(i); 95 95 hw_regs_t hw; 96 96 97 + idx[i] = 0xff; 98 + 97 99 if (io_addr) { 100 + if (!request_region(io_addr, 8, DRV_NAME)) { 101 + printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX " 102 + "not free.\n", 103 + DRV_NAME, io_addr, io_addr + 7); 104 + continue; 105 + } 106 + 107 + if (!request_region(io_addr + 0x206, 1, DRV_NAME)) { 108 + printk(KERN_ERR "%s: I/O resource 0x%lX " 109 + "not free.\n", 110 + DRV_NAME, io_addr + 0x206); 111 + release_region(io_addr, 8); 112 + continue; 113 + } 114 + 98 115 /* 99 116 * Skip probing if the corresponding 100 117 * slot is already occupied. ··· 128 111 ide_init_port_hw(hwif, &hw); 129 112 130 113 idx[i] = i; 131 - } else 132 - idx[i] = 0xff; 114 + } 133 115 } 134 116 135 117 ide_device_add_all(idx, NULL);
+7 -6
drivers/ide/ide-io.c
··· 218 218 * we could be smarter and check for current xfer_speed 219 219 * in struct drive etc... 220 220 */ 221 - if (drive->hwif->dma_host_set == NULL) 221 + if (drive->hwif->dma_ops == NULL) 222 222 break; 223 223 /* 224 224 * TODO: respect ->using_dma setting ··· 721 721 #endif 722 722 if (s->b.set_tune) { 723 723 ide_hwif_t *hwif = drive->hwif; 724 + const struct ide_port_ops *port_ops = hwif->port_ops; 724 725 u8 req_pio = drive->tune_req; 725 726 726 727 s->b.set_tune = 0; ··· 734 733 unsigned long flags; 735 734 736 735 spin_lock_irqsave(&ide_lock, flags); 737 - hwif->set_pio_mode(drive, req_pio); 736 + port_ops->set_pio_mode(drive, req_pio); 738 737 spin_unlock_irqrestore(&ide_lock, flags); 739 738 } else 740 - hwif->set_pio_mode(drive, req_pio); 739 + port_ops->set_pio_mode(drive, req_pio); 741 740 } else { 742 741 int keep_dma = drive->using_dma; 743 742 ··· 1238 1237 1239 1238 if (error < 0) { 1240 1239 printk(KERN_WARNING "%s: DMA timeout error\n", drive->name); 1241 - (void)HWIF(drive)->ide_dma_end(drive); 1240 + (void)hwif->dma_ops->dma_end(drive); 1242 1241 ret = ide_error(drive, "dma timeout error", 1243 1242 ide_read_status(drive)); 1244 1243 } else { 1245 1244 printk(KERN_WARNING "%s: DMA timeout retry\n", drive->name); 1246 - hwif->dma_timeout(drive); 1245 + hwif->dma_ops->dma_timeout(drive); 1247 1246 } 1248 1247 1249 1248 /* ··· 1355 1354 startstop = handler(drive); 1356 1355 } else if (drive_is_ready(drive)) { 1357 1356 if (drive->waiting_for_dma) 1358 - hwgroup->hwif->dma_lost_irq(drive); 1357 + hwif->dma_ops->dma_lost_irq(drive); 1359 1358 (void)ide_ack_intr(hwif); 1360 1359 printk(KERN_WARNING "%s: lost interrupt\n", drive->name); 1361 1360 startstop = handler(drive);
+23 -15
drivers/ide/ide-iops.c
··· 159 159 void SELECT_DRIVE (ide_drive_t *drive) 160 160 { 161 161 ide_hwif_t *hwif = drive->hwif; 162 + const struct ide_port_ops *port_ops = hwif->port_ops; 162 163 163 - if (hwif->selectproc) 164 - hwif->selectproc(drive); 164 + if (port_ops && port_ops->selectproc) 165 + port_ops->selectproc(drive); 165 166 166 167 hwif->OUTB(drive->select.all, hwif->io_ports[IDE_SELECT_OFFSET]); 167 168 } 168 169 169 170 void SELECT_MASK (ide_drive_t *drive, int mask) 170 171 { 171 - if (HWIF(drive)->maskproc) 172 - HWIF(drive)->maskproc(drive, mask); 172 + const struct ide_port_ops *port_ops = drive->hwif->port_ops; 173 + 174 + if (port_ops && port_ops->maskproc) 175 + port_ops->maskproc(drive, mask); 173 176 } 174 177 175 178 /* ··· 432 429 u8 stat = 0; 433 430 434 431 if (drive->waiting_for_dma) 435 - return hwif->ide_dma_test_irq(drive); 432 + return hwif->dma_ops->dma_test_irq(drive); 436 433 437 434 #if 0 438 435 /* need to guarantee 400ns since last command was issued */ ··· 703 700 // msleep(50); 704 701 705 702 #ifdef CONFIG_BLK_DEV_IDEDMA 706 - if (hwif->dma_host_set) /* check if host supports DMA */ 707 - hwif->dma_host_set(drive, 0); 703 + if (hwif->dma_ops) /* check if host supports DMA */ 704 + hwif->dma_ops->dma_host_set(drive, 0); 708 705 #endif 709 706 710 707 /* Skip setting PIO flow-control modes on pre-EIDE drives */ ··· 762 759 #ifdef CONFIG_BLK_DEV_IDEDMA 763 760 if ((speed >= XFER_SW_DMA_0 || (hwif->host_flags & IDE_HFLAG_VDMA)) && 764 761 drive->using_dma) 765 - hwif->dma_host_set(drive, 1); 766 - else if (hwif->dma_host_set) /* check if host supports DMA */ 762 + hwif->dma_ops->dma_host_set(drive, 1); 763 + else if (hwif->dma_ops) /* check if host supports DMA */ 767 764 ide_dma_off_quietly(drive); 768 765 #endif 769 766 ··· 908 905 { 909 906 ide_hwgroup_t *hwgroup = HWGROUP(drive); 910 907 ide_hwif_t *hwif = HWIF(drive); 908 + const struct ide_port_ops *port_ops = hwif->port_ops; 911 909 u8 tmp; 912 910 913 - if (hwif->reset_poll != NULL) { 914 - if (hwif->reset_poll(drive)) { 911 + if (port_ops && port_ops->reset_poll) { 912 + if (port_ops->reset_poll(drive)) { 915 913 printk(KERN_ERR "%s: host reset_poll failure for %s.\n", 916 914 hwif->name, drive->name); 917 915 return ide_stopped; ··· 978 974 979 975 static void pre_reset(ide_drive_t *drive) 980 976 { 977 + const struct ide_port_ops *port_ops = drive->hwif->port_ops; 978 + 981 979 if (drive->media == ide_disk) 982 980 ide_disk_pre_reset(drive); 983 981 else ··· 1000 994 return; 1001 995 } 1002 996 1003 - if (HWIF(drive)->pre_reset != NULL) 1004 - HWIF(drive)->pre_reset(drive); 997 + if (port_ops && port_ops->pre_reset) 998 + port_ops->pre_reset(drive); 1005 999 1006 1000 if (drive->current_speed != 0xff) 1007 1001 drive->desired_speed = drive->current_speed; ··· 1029 1023 unsigned long flags; 1030 1024 ide_hwif_t *hwif; 1031 1025 ide_hwgroup_t *hwgroup; 1026 + const struct ide_port_ops *port_ops; 1032 1027 u8 ctl; 1033 1028 1034 1029 spin_lock_irqsave(&ide_lock, flags); ··· 1096 1089 * state when the disks are reset this way. At least, the Winbond 1097 1090 * 553 documentation says that 1098 1091 */ 1099 - if (hwif->resetproc) 1100 - hwif->resetproc(drive); 1092 + port_ops = hwif->port_ops; 1093 + if (port_ops && port_ops->resetproc) 1094 + port_ops->resetproc(drive); 1101 1095 1102 1096 spin_unlock_irqrestore(&ide_lock, flags); 1103 1097 return ide_started;
+15 -11
drivers/ide/ide-lib.c
··· 85 85 mode = XFER_PIO_4; 86 86 } 87 87 88 - // printk("%s: mode 0x%02x, speed 0x%02x\n", __FUNCTION__, mode, speed); 88 + /* printk("%s: mode 0x%02x, speed 0x%02x\n", __func__, mode, speed); */ 89 89 90 90 return min(speed, mode); 91 91 } ··· 288 288 void ide_set_pio(ide_drive_t *drive, u8 req_pio) 289 289 { 290 290 ide_hwif_t *hwif = drive->hwif; 291 + const struct ide_port_ops *port_ops = hwif->port_ops; 291 292 u8 host_pio, pio; 292 293 293 - if (hwif->set_pio_mode == NULL || 294 + if (port_ops == NULL || port_ops->set_pio_mode == NULL || 294 295 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) 295 296 return; 296 297 ··· 344 343 int ide_set_pio_mode(ide_drive_t *drive, const u8 mode) 345 344 { 346 345 ide_hwif_t *hwif = drive->hwif; 346 + const struct ide_port_ops *port_ops = hwif->port_ops; 347 347 348 348 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) 349 349 return 0; 350 350 351 - if (hwif->set_pio_mode == NULL) 351 + if (port_ops == NULL || port_ops->set_pio_mode == NULL) 352 352 return -1; 353 353 354 354 /* 355 355 * TODO: temporary hack for some legacy host drivers that didn't 356 356 * set transfer mode on the device in ->set_pio_mode method... 357 357 */ 358 - if (hwif->set_dma_mode == NULL) { 359 - hwif->set_pio_mode(drive, mode - XFER_PIO_0); 358 + if (port_ops->set_dma_mode == NULL) { 359 + port_ops->set_pio_mode(drive, mode - XFER_PIO_0); 360 360 return 0; 361 361 } 362 362 363 363 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { 364 364 if (ide_config_drive_speed(drive, mode)) 365 365 return -1; 366 - hwif->set_pio_mode(drive, mode - XFER_PIO_0); 366 + port_ops->set_pio_mode(drive, mode - XFER_PIO_0); 367 367 return 0; 368 368 } else { 369 - hwif->set_pio_mode(drive, mode - XFER_PIO_0); 369 + port_ops->set_pio_mode(drive, mode - XFER_PIO_0); 370 370 return ide_config_drive_speed(drive, mode); 371 371 } 372 372 } ··· 375 373 int ide_set_dma_mode(ide_drive_t *drive, const u8 mode) 376 374 { 377 375 ide_hwif_t *hwif = drive->hwif; 376 + const struct ide_port_ops *port_ops = hwif->port_ops; 378 377 379 378 if (hwif->host_flags & IDE_HFLAG_NO_SET_MODE) 380 379 return 0; 381 380 382 - if (hwif->set_dma_mode == NULL) 381 + if (port_ops == NULL || port_ops->set_dma_mode == NULL) 383 382 return -1; 384 383 385 384 if (hwif->host_flags & IDE_HFLAG_POST_SET_MODE) { 386 385 if (ide_config_drive_speed(drive, mode)) 387 386 return -1; 388 - hwif->set_dma_mode(drive, mode); 387 + port_ops->set_dma_mode(drive, mode); 389 388 return 0; 390 389 } else { 391 - hwif->set_dma_mode(drive, mode); 390 + port_ops->set_dma_mode(drive, mode); 392 391 return ide_config_drive_speed(drive, mode); 393 392 } 394 393 } ··· 409 406 int ide_set_xfer_rate(ide_drive_t *drive, u8 rate) 410 407 { 411 408 ide_hwif_t *hwif = drive->hwif; 409 + const struct ide_port_ops *port_ops = hwif->port_ops; 412 410 413 - if (hwif->set_dma_mode == NULL || 411 + if (port_ops == NULL || port_ops->set_dma_mode == NULL || 414 412 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) 415 413 return -1; 416 414
+26 -2
drivers/ide/ide-pnp.c
··· 18 18 #include <linux/pnp.h> 19 19 #include <linux/ide.h> 20 20 21 + #define DRV_NAME "ide-pnp" 22 + 21 23 /* Add your devices here :)) */ 22 24 static struct pnp_device_id idepnp_devices[] = { 23 25 /* Generic ESDI/IDE/ATA compatible hard disk controller */ ··· 31 29 { 32 30 hw_regs_t hw; 33 31 ide_hwif_t *hwif; 32 + unsigned long base, ctl; 34 33 35 34 if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) 36 35 return -1; 37 36 37 + base = pnp_port_start(dev, 0); 38 + ctl = pnp_port_start(dev, 1); 39 + 40 + if (!request_region(base, 8, DRV_NAME)) { 41 + printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", 42 + DRV_NAME, base, base + 7); 43 + return -EBUSY; 44 + } 45 + 46 + if (!request_region(ctl, 1, DRV_NAME)) { 47 + printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", 48 + DRV_NAME, ctl); 49 + release_region(base, 8); 50 + return -EBUSY; 51 + } 52 + 38 53 memset(&hw, 0, sizeof(hw)); 39 - ide_std_init_ports(&hw, pnp_port_start(dev, 0), 40 - pnp_port_start(dev, 1)); 54 + ide_std_init_ports(&hw, base, ctl); 41 55 hw.irq = pnp_irq(dev, 0); 42 56 43 57 hwif = ide_find_port(); ··· 72 54 return 0; 73 55 } 74 56 57 + release_region(ctl, 1); 58 + release_region(base, 8); 59 + 75 60 return -1; 76 61 } 77 62 ··· 86 65 ide_unregister(hwif->index); 87 66 else 88 67 printk(KERN_ERR "idepnp: Unable to remove device, please report.\n"); 68 + 69 + release_region(pnp_port_start(dev, 1), 1); 70 + release_region(pnp_port_start(dev, 0), 8); 89 71 } 90 72 91 73 static struct pnp_driver idepnp_driver = {
+119 -45
drivers/ide/ide-probe.c
··· 644 644 ret = device_register(&hwif->gendev); 645 645 if (ret < 0) { 646 646 printk(KERN_WARNING "IDE: %s: device_register error: %d\n", 647 - __FUNCTION__, ret); 647 + __func__, ret); 648 648 goto out; 649 649 } 650 650 ··· 773 773 774 774 BUG_ON(hwif->present); 775 775 776 - if (hwif->noprobe || 777 - (hwif->drives[0].noprobe && hwif->drives[1].noprobe)) 776 + if (hwif->drives[0].noprobe && hwif->drives[1].noprobe) 778 777 return -EACCES; 779 778 780 779 /* ··· 820 821 821 822 static void ide_port_tune_devices(ide_hwif_t *hwif) 822 823 { 824 + const struct ide_port_ops *port_ops = hwif->port_ops; 823 825 int unit; 824 826 825 827 for (unit = 0; unit < MAX_DRIVES; unit++) { 826 828 ide_drive_t *drive = &hwif->drives[unit]; 827 829 828 - if (drive->present && hwif->quirkproc) 829 - hwif->quirkproc(drive); 830 + if (drive->present && port_ops && port_ops->quirkproc) 831 + port_ops->quirkproc(drive); 830 832 } 831 833 832 834 for (unit = 0; unit < MAX_DRIVES; ++unit) { ··· 843 843 844 844 drive->nice1 = 1; 845 845 846 - if (hwif->dma_host_set) 846 + if (hwif->dma_ops) 847 847 ide_set_dma(drive); 848 848 } 849 849 } ··· 1324 1324 1325 1325 static void ide_port_init_devices(ide_hwif_t *hwif) 1326 1326 { 1327 + const struct ide_port_ops *port_ops = hwif->port_ops; 1327 1328 int i; 1328 1329 1329 1330 for (i = 0; i < MAX_DRIVES; i++) { ··· 1340 1339 drive->autotune = 1; 1341 1340 } 1342 1341 1343 - if (hwif->port_init_devs) 1344 - hwif->port_init_devs(hwif); 1342 + if (port_ops && port_ops->port_init_devs) 1343 + port_ops->port_init_devs(hwif); 1345 1344 } 1346 1345 1347 1346 static void ide_init_port(ide_hwif_t *hwif, unsigned int port, ··· 1356 1355 if (d->init_iops) 1357 1356 d->init_iops(hwif); 1358 1357 1359 - if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) 1360 - ide_hwif_setup_dma(hwif, d); 1361 - 1362 1358 if ((!hwif->irq && (d->host_flags & IDE_HFLAG_LEGACY_IRQS)) || 1363 1359 (d->host_flags & IDE_HFLAG_FORCE_LEGACY_IRQS)) 1364 1360 hwif->irq = port ? 15 : 14; ··· 1363 1365 hwif->host_flags = d->host_flags; 1364 1366 hwif->pio_mask = d->pio_mask; 1365 1367 1366 - if ((d->host_flags & IDE_HFLAG_SERIALIZE) && hwif->mate) 1367 - hwif->mate->serialized = hwif->serialized = 1; 1368 + /* ->set_pio_mode for DTC2278 is currently limited to port 0 */ 1369 + if (hwif->chipset != ide_dtc2278 || hwif->channel == 0) 1370 + hwif->port_ops = d->port_ops; 1371 + 1372 + if ((d->host_flags & IDE_HFLAG_SERIALIZE) || 1373 + ((d->host_flags & IDE_HFLAG_SERIALIZE_DMA) && hwif->dma_base)) { 1374 + if (hwif->mate) 1375 + hwif->mate->serialized = hwif->serialized = 1; 1376 + } 1368 1377 1369 1378 hwif->swdma_mask = d->swdma_mask; 1370 1379 hwif->mwdma_mask = d->mwdma_mask; 1371 1380 hwif->ultra_mask = d->udma_mask; 1372 1381 1373 - /* reset DMA masks only for SFF-style DMA controllers */ 1374 - if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0 && hwif->dma_base == 0) 1375 - hwif->swdma_mask = hwif->mwdma_mask = hwif->ultra_mask = 0; 1382 + if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) { 1383 + int rc; 1384 + 1385 + if (d->init_dma) 1386 + rc = d->init_dma(hwif, d); 1387 + else 1388 + rc = ide_hwif_setup_dma(hwif, d); 1389 + 1390 + if (rc < 0) { 1391 + printk(KERN_INFO "%s: DMA disabled\n", hwif->name); 1392 + hwif->swdma_mask = 0; 1393 + hwif->mwdma_mask = 0; 1394 + hwif->ultra_mask = 0; 1395 + } else if (d->dma_ops) 1396 + hwif->dma_ops = d->dma_ops; 1397 + } 1376 1398 1377 1399 if (d->host_flags & IDE_HFLAG_RQSIZE_256) 1378 1400 hwif->rqsize = 256; ··· 1404 1386 1405 1387 static void ide_port_cable_detect(ide_hwif_t *hwif) 1406 1388 { 1407 - if (hwif->cable_detect && (hwif->ultra_mask & 0x78)) { 1389 + const struct ide_port_ops *port_ops = hwif->port_ops; 1390 + 1391 + if (port_ops && port_ops->cable_detect && (hwif->ultra_mask & 0x78)) { 1408 1392 if (hwif->cbl != ATA_CBL_PATA40_SHORT) 1409 - hwif->cbl = hwif->cable_detect(hwif); 1393 + hwif->cbl = port_ops->cable_detect(hwif); 1410 1394 } 1411 1395 } 1412 1396 ··· 1543 1523 1544 1524 hwif = &ide_hwifs[idx[i]]; 1545 1525 1546 - if ((hwif->chipset != ide_4drives || !hwif->mate || 1547 - !hwif->mate->present) && ide_hwif_request_regions(hwif)) { 1548 - printk(KERN_ERR "%s: ports already in use, " 1549 - "skipping probe\n", hwif->name); 1550 - continue; 1551 - } 1552 - 1553 - if (ide_probe_port(hwif) < 0) { 1554 - ide_hwif_release_regions(hwif); 1555 - continue; 1556 - } 1557 - 1558 - hwif->present = 1; 1526 + if (ide_probe_port(hwif) == 0) 1527 + hwif->present = 1; 1559 1528 1560 1529 if (hwif->chipset != ide_4drives || !hwif->mate || 1561 1530 !hwif->mate->present) 1562 1531 ide_register_port(hwif); 1563 1532 1564 - ide_port_tune_devices(hwif); 1533 + if (hwif->present) 1534 + ide_port_tune_devices(hwif); 1565 1535 } 1566 1536 1567 1537 for (i = 0; i < MAX_HWIFS; i++) { ··· 1559 1549 continue; 1560 1550 1561 1551 hwif = &ide_hwifs[idx[i]]; 1562 - 1563 - if (!hwif->present) 1564 - continue; 1565 1552 1566 1553 if (hwif_init(hwif) == 0) { 1567 1554 printk(KERN_INFO "%s: failed to initialize IDE " ··· 1568 1561 continue; 1569 1562 } 1570 1563 1571 - ide_port_setup_devices(hwif); 1564 + if (hwif->present) 1565 + ide_port_setup_devices(hwif); 1572 1566 1573 1567 ide_acpi_init(hwif); 1574 - ide_acpi_port_init_devices(hwif); 1568 + 1569 + if (hwif->present) 1570 + ide_acpi_port_init_devices(hwif); 1575 1571 } 1576 1572 1577 1573 for (i = 0; i < MAX_HWIFS; i++) { ··· 1583 1573 1584 1574 hwif = &ide_hwifs[idx[i]]; 1585 1575 1586 - if (hwif->present) { 1587 - if (hwif->chipset == ide_unknown) 1588 - hwif->chipset = ide_generic; 1576 + if (hwif->chipset == ide_unknown) 1577 + hwif->chipset = ide_generic; 1578 + 1579 + if (hwif->present) 1589 1580 hwif_register_devices(hwif); 1590 - } 1591 1581 } 1592 1582 1593 1583 for (i = 0; i < MAX_HWIFS; i++) { ··· 1596 1586 1597 1587 hwif = &ide_hwifs[idx[i]]; 1598 1588 1599 - if (hwif->present) { 1600 - ide_sysfs_register_port(hwif); 1601 - ide_proc_register_port(hwif); 1589 + ide_sysfs_register_port(hwif); 1590 + ide_proc_register_port(hwif); 1591 + 1592 + if (hwif->present) 1602 1593 ide_proc_port_register_devices(hwif); 1603 - } 1604 1594 } 1605 1595 1606 1596 return rc; ··· 1636 1626 ide_proc_port_register_devices(hwif); 1637 1627 } 1638 1628 EXPORT_SYMBOL_GPL(ide_port_scan); 1629 + 1630 + static void ide_legacy_init_one(u8 *idx, hw_regs_t *hw, u8 port_no, 1631 + const struct ide_port_info *d, 1632 + unsigned long config) 1633 + { 1634 + ide_hwif_t *hwif; 1635 + unsigned long base, ctl; 1636 + int irq; 1637 + 1638 + if (port_no == 0) { 1639 + base = 0x1f0; 1640 + ctl = 0x3f6; 1641 + irq = 14; 1642 + } else { 1643 + base = 0x170; 1644 + ctl = 0x376; 1645 + irq = 15; 1646 + } 1647 + 1648 + if (!request_region(base, 8, d->name)) { 1649 + printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", 1650 + d->name, base, base + 7); 1651 + return; 1652 + } 1653 + 1654 + if (!request_region(ctl, 1, d->name)) { 1655 + printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", 1656 + d->name, ctl); 1657 + release_region(base, 8); 1658 + return; 1659 + } 1660 + 1661 + ide_std_init_ports(hw, base, ctl); 1662 + hw->irq = irq; 1663 + 1664 + hwif = ide_find_port_slot(d); 1665 + if (hwif) { 1666 + ide_init_port_hw(hwif, hw); 1667 + if (config) 1668 + hwif->config_data = config; 1669 + idx[port_no] = hwif->index; 1670 + } 1671 + } 1672 + 1673 + int ide_legacy_device_add(const struct ide_port_info *d, unsigned long config) 1674 + { 1675 + u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 1676 + hw_regs_t hw[2]; 1677 + 1678 + memset(&hw, 0, sizeof(hw)); 1679 + 1680 + if ((d->host_flags & IDE_HFLAG_QD_2ND_PORT) == 0) 1681 + ide_legacy_init_one(idx, &hw[0], 0, d, config); 1682 + ide_legacy_init_one(idx, &hw[1], 1, d, config); 1683 + 1684 + if (idx[0] == 0xff && idx[1] == 0xff && 1685 + (d->host_flags & IDE_HFLAG_SINGLE)) 1686 + return -ENOENT; 1687 + 1688 + ide_device_add(idx, d); 1689 + 1690 + return 0; 1691 + } 1692 + EXPORT_SYMBOL_GPL(ide_legacy_device_add);
+3 -3
drivers/ide/ide-proc.c
··· 599 599 err = device_attach(dev); 600 600 if (err < 0) 601 601 printk(KERN_WARNING "IDE: %s: device_attach error: %d\n", 602 - __FUNCTION__, err); 602 + __func__, err); 603 603 drive->driver_req[0] = 0; 604 604 if (dev->driver == NULL) { 605 605 err = device_attach(dev); 606 606 if (err < 0) 607 607 printk(KERN_WARNING 608 608 "IDE: %s: device_attach(2) error: %d\n", 609 - __FUNCTION__, err); 609 + __func__, err); 610 610 } 611 611 if (dev->driver && !strcmp(dev->driver->name, driver)) 612 612 ret = 0; ··· 820 820 err = bus_for_each_drv(&ide_bus_type, NULL, s, proc_print_driver); 821 821 if (err < 0) 822 822 printk(KERN_WARNING "IDE: %s: bus_for_each_drv error: %d\n", 823 - __FUNCTION__, err); 823 + __func__, err); 824 824 return 0; 825 825 } 826 826
+1 -1
drivers/ide/ide-scan-pci.c
··· 102 102 if (__pci_register_driver(d, d->driver.owner, 103 103 d->driver.mod_name)) 104 104 printk(KERN_ERR "%s: failed to register %s driver\n", 105 - __FUNCTION__, d->driver.mod_name); 105 + __func__, d->driver.mod_name); 106 106 } 107 107 108 108 return 0;
+14 -21
drivers/ide/ide-tape.c
··· 993 993 stat = ide_read_status(drive); 994 994 995 995 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { 996 - if (hwif->ide_dma_end(drive) || (stat & ERR_STAT)) { 996 + if (hwif->dma_ops->dma_end(drive) || (stat & ERR_STAT)) { 997 997 /* 998 998 * A DMA error is sometimes expected. For example, 999 999 * if the tape is crossing a filemark during a ··· 1213 1213 #ifdef CONFIG_BLK_DEV_IDEDMA 1214 1214 /* Begin DMA, if necessary */ 1215 1215 if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) 1216 - hwif->dma_start(drive); 1216 + hwif->dma_ops->dma_start(drive); 1217 1217 #endif 1218 1218 /* Send the actual packet */ 1219 1219 HWIF(drive)->atapi_output_bytes(drive, pc->c, 12); ··· 1279 1279 ide_dma_off(drive); 1280 1280 } 1281 1281 if ((pc->flags & PC_FLAG_DMA_RECOMMENDED) && drive->using_dma) 1282 - dma_ok = !hwif->dma_setup(drive); 1282 + dma_ok = !hwif->dma_ops->dma_setup(drive); 1283 1283 1284 1284 ide_pktcmd_tf_load(drive, IDE_TFLAG_NO_SELECT_MASK | 1285 1285 IDE_TFLAG_OUT_DEVICE, bcount, dma_ok); ··· 1605 1605 } 1606 1606 1607 1607 /* Pipeline related functions */ 1608 - static inline int idetape_pipeline_active(idetape_tape_t *tape) 1609 - { 1610 - int rc1, rc2; 1611 - 1612 - rc1 = test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags); 1613 - rc2 = (tape->active_data_rq != NULL); 1614 - return rc1; 1615 - } 1616 1608 1617 1609 /* 1618 1610 * The function below uses __get_free_page to allocate a pipeline stage, along ··· 2050 2058 2051 2059 spin_lock_irqsave(&tape->lock, flags); 2052 2060 tape->next_stage = NULL; 2053 - if (idetape_pipeline_active(tape)) 2061 + if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) 2054 2062 idetape_wait_for_request(drive, tape->active_data_rq); 2055 2063 spin_unlock_irqrestore(&tape->lock, flags); 2056 2064 ··· 2123 2131 2124 2132 debug_log(DBG_SENSE, "%s: cmd=%d\n", __func__, cmd); 2125 2133 2126 - if (idetape_pipeline_active(tape)) { 2134 + if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) { 2127 2135 printk(KERN_ERR "ide-tape: bug: the pipeline is active in %s\n", 2128 2136 __func__); 2129 2137 return (0); ··· 2154 2162 2155 2163 if (tape->next_stage == NULL) 2156 2164 return; 2157 - if (!idetape_pipeline_active(tape)) { 2158 - set_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags); 2165 + if (!test_and_set_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) { 2159 2166 idetape_activate_next_stage(drive); 2160 2167 (void) ide_do_drive_cmd(drive, tape->active_data_rq, ide_end); 2161 2168 } ··· 2233 2242 /* Attempt to allocate a new stage. Beware possible race conditions. */ 2234 2243 while ((new_stage = idetape_kmalloc_stage(tape)) == NULL) { 2235 2244 spin_lock_irqsave(&tape->lock, flags); 2236 - if (idetape_pipeline_active(tape)) { 2245 + if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) { 2237 2246 idetape_wait_for_request(drive, tape->active_data_rq); 2238 2247 spin_unlock_irqrestore(&tape->lock, flags); 2239 2248 } else { 2240 2249 spin_unlock_irqrestore(&tape->lock, flags); 2241 2250 idetape_plug_pipeline(drive); 2242 - if (idetape_pipeline_active(tape)) 2251 + if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, 2252 + &tape->flags)) 2243 2253 continue; 2244 2254 /* 2245 2255 * The machine is short on memory. Fallback to non- ··· 2269 2277 * starting to service requests, so that we will be able to keep up with 2270 2278 * the higher speeds of the tape. 2271 2279 */ 2272 - if (!idetape_pipeline_active(tape)) { 2280 + if (!test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) { 2273 2281 if (tape->nr_stages >= tape->max_stages * 9 / 10 || 2274 2282 tape->nr_stages >= tape->max_stages - 2275 2283 tape->uncontrolled_pipeline_head_speed * 3 * 1024 / ··· 2296 2304 idetape_tape_t *tape = drive->driver_data; 2297 2305 unsigned long flags; 2298 2306 2299 - while (tape->next_stage || idetape_pipeline_active(tape)) { 2307 + while (tape->next_stage || test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, 2308 + &tape->flags)) { 2300 2309 idetape_plug_pipeline(drive); 2301 2310 spin_lock_irqsave(&tape->lock, flags); 2302 - if (idetape_pipeline_active(tape)) 2311 + if (test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) 2303 2312 idetape_wait_for_request(drive, tape->active_data_rq); 2304 2313 spin_unlock_irqrestore(&tape->lock, flags); 2305 2314 } ··· 2457 2464 new_stage = idetape_kmalloc_stage(tape); 2458 2465 } 2459 2466 } 2460 - if (!idetape_pipeline_active(tape)) { 2467 + if (!test_bit(IDETAPE_FLAG_PIPELINE_ACTIVE, &tape->flags)) { 2461 2468 if (tape->nr_pending_stages >= 3 * max_stages / 4) { 2462 2469 tape->measure_insert_time = 1; 2463 2470 tape->insert_time = jiffies;
+10 -9
drivers/ide/ide-taskfile.c
··· 135 135 ide_hwif_t *hwif = HWIF(drive); 136 136 struct ide_taskfile *tf = &task->tf; 137 137 ide_handler_t *handler = NULL; 138 + const struct ide_dma_ops *dma_ops = hwif->dma_ops; 138 139 139 140 if (task->data_phase == TASKFILE_MULTI_IN || 140 141 task->data_phase == TASKFILE_MULTI_OUT) { ··· 179 178 return ide_started; 180 179 default: 181 180 if (task_dma_ok(task) == 0 || drive->using_dma == 0 || 182 - hwif->dma_setup(drive)) 181 + dma_ops->dma_setup(drive)) 183 182 return ide_stopped; 184 - hwif->dma_exec_cmd(drive, tf->command); 185 - hwif->dma_start(drive); 183 + dma_ops->dma_exec_cmd(drive, tf->command); 184 + dma_ops->dma_start(drive); 186 185 return ide_started; 187 186 } 188 187 } ··· 456 455 457 456 /* Error? */ 458 457 if (stat & ERR_STAT) 459 - return task_error(drive, rq, __FUNCTION__, stat); 458 + return task_error(drive, rq, __func__, stat); 460 459 461 460 /* Didn't want any data? Odd. */ 462 461 if (!(stat & DRQ_STAT)) ··· 468 467 if (!hwif->nleft) { 469 468 stat = wait_drive_not_busy(drive); 470 469 if (!OK_STAT(stat, 0, BAD_STAT)) 471 - return task_error(drive, rq, __FUNCTION__, stat); 470 + return task_error(drive, rq, __func__, stat); 472 471 task_end_request(drive, rq, stat); 473 472 return ide_stopped; 474 473 } ··· 489 488 u8 stat = ide_read_status(drive); 490 489 491 490 if (!OK_STAT(stat, DRIVE_READY, drive->bad_wstat)) 492 - return task_error(drive, rq, __FUNCTION__, stat); 491 + return task_error(drive, rq, __func__, stat); 493 492 494 493 /* Deal with unexpected ATA data phase. */ 495 494 if (((stat & DRQ_STAT) == 0) ^ !hwif->nleft) 496 - return task_error(drive, rq, __FUNCTION__, stat); 495 + return task_error(drive, rq, __func__, stat); 497 496 498 497 if (!hwif->nleft) { 499 498 task_end_request(drive, rq, stat); ··· 676 675 /* (hs): give up if multcount is not set */ 677 676 printk(KERN_ERR "%s: %s Multimode Write " \ 678 677 "multcount is not set\n", 679 - drive->name, __FUNCTION__); 678 + drive->name, __func__); 680 679 err = -EPERM; 681 680 goto abort; 682 681 } ··· 693 692 /* (hs): give up if multcount is not set */ 694 693 printk(KERN_ERR "%s: %s Multimode Read failure " \ 695 694 "multcount is not set\n", 696 - drive->name, __FUNCTION__); 695 + drive->name, __func__); 697 696 err = -EPERM; 698 697 goto abort; 699 698 }
+4 -82
drivers/ide/ide.c
··· 227 227 return pci_dev_present(pci_default) ? 33 : 50; 228 228 } 229 229 230 - static struct resource* hwif_request_region(ide_hwif_t *hwif, 231 - unsigned long addr, int num) 232 - { 233 - struct resource *res = request_region(addr, num, hwif->name); 234 - 235 - if (!res) 236 - printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", 237 - hwif->name, addr, addr+num-1); 238 - return res; 239 - } 240 - 241 - /** 242 - * ide_hwif_request_regions - request resources for IDE 243 - * @hwif: interface to use 244 - * 245 - * Requests all the needed resources for an interface. 246 - * Right now core IDE code does this work which is deeply wrong. 247 - * MMIO leaves it to the controller driver, 248 - * PIO will migrate this way over time. 249 - */ 250 - 251 - int ide_hwif_request_regions(ide_hwif_t *hwif) 252 - { 253 - unsigned long addr; 254 - 255 - if (hwif->mmio) 256 - return 0; 257 - 258 - addr = hwif->io_ports[IDE_CONTROL_OFFSET]; 259 - 260 - if (addr && !hwif_request_region(hwif, addr, 1)) 261 - goto control_region_busy; 262 - 263 - addr = hwif->io_ports[IDE_DATA_OFFSET]; 264 - BUG_ON((addr | 7) != hwif->io_ports[IDE_STATUS_OFFSET]); 265 - 266 - if (!hwif_request_region(hwif, addr, 8)) 267 - goto data_region_busy; 268 - 269 - return 0; 270 - 271 - data_region_busy: 272 - addr = hwif->io_ports[IDE_CONTROL_OFFSET]; 273 - if (addr) 274 - release_region(addr, 1); 275 - control_region_busy: 276 - /* If any errors are return, we drop the hwif interface. */ 277 - return -EBUSY; 278 - } 279 - 280 - /** 281 - * ide_hwif_release_regions - free IDE resources 282 - * 283 - * Note that we only release the standard ports, 284 - * and do not even try to handle any extra ports 285 - * allocated for weird IDE interface chipsets. 286 - * 287 - * Note also that we don't yet handle mmio resources here. More 288 - * importantly our caller should be doing this so we need to 289 - * restructure this as a helper function for drivers. 290 - */ 291 - 292 - void ide_hwif_release_regions(ide_hwif_t *hwif) 293 - { 294 - if (hwif->mmio) 295 - return; 296 - 297 - if (hwif->io_ports[IDE_CONTROL_OFFSET]) 298 - release_region(hwif->io_ports[IDE_CONTROL_OFFSET], 1); 299 - 300 - release_region(hwif->io_ports[IDE_DATA_OFFSET], 8); 301 - } 302 - 303 230 void ide_remove_port_from_hwgroup(ide_hwif_t *hwif) 304 231 { 305 232 ide_hwgroup_t *hwgroup = hwif->hwgroup; ··· 363 436 spin_lock_irq(&ide_lock); 364 437 365 438 if (hwif->dma_base) 366 - (void)ide_release_dma(hwif); 367 - 368 - ide_hwif_release_regions(hwif); 439 + ide_release_dma_engine(hwif); 369 440 370 441 /* restore hwif data to pristine status */ 371 442 ide_init_port_data(hwif, index); ··· 379 454 { 380 455 memcpy(hwif->io_ports, hw->io_ports, sizeof(hwif->io_ports)); 381 456 hwif->irq = hw->irq; 382 - hwif->noprobe = 0; 383 457 hwif->chipset = hw->chipset; 384 458 hwif->gendev.parent = hw->dev; 385 459 hwif->ack_intr = hw->ack_intr; ··· 469 545 if (!drive->id || !(drive->id->capability & 1)) 470 546 goto out; 471 547 472 - if (hwif->dma_host_set == NULL) 548 + if (hwif->dma_ops == NULL) 473 549 goto out; 474 550 475 551 err = -EBUSY; ··· 509 585 { 510 586 struct request rq; 511 587 ide_hwif_t *hwif = drive->hwif; 588 + const struct ide_port_ops *port_ops = hwif->port_ops; 512 589 513 590 if (arg < 0 || arg > 255) 514 591 return -EINVAL; 515 592 516 - if (hwif->set_pio_mode == NULL || 593 + if (port_ops == NULL || port_ops->set_pio_mode == NULL || 517 594 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) 518 595 return -ENOSYS; 519 596 ··· 930 1005 goto done; 931 1006 case -3: /* "nowerr" */ 932 1007 drive->bad_wstat = BAD_R_STAT; 933 - hwif->noprobe = 0; 934 1008 goto done; 935 1009 case -4: /* "cdrom" */ 936 1010 drive->present = 1; 937 1011 drive->media = ide_cdrom; 938 1012 /* an ATAPI device ignores DRDY */ 939 1013 drive->ready_stat = 0; 940 - hwif->noprobe = 0; 941 1014 goto done; 942 1015 case -5: /* nodma */ 943 1016 drive->nodma = 1; ··· 966 1043 drive->sect = drive->bios_sect = vals[2]; 967 1044 drive->present = 1; 968 1045 drive->forced_geom = 1; 969 - hwif->noprobe = 0; 970 1046 goto done; 971 1047 default: 972 1048 goto bad_option;
+9 -29
drivers/ide/legacy/ali14xx.c
··· 49 49 50 50 #include <asm/io.h> 51 51 52 + #define DRV_NAME "ali14xx" 53 + 52 54 /* port addresses for auto-detection */ 53 55 #define ALI_NUM_PORTS 4 54 56 static const int ports[ALI_NUM_PORTS] __initdata = ··· 194 192 return t; 195 193 } 196 194 195 + static const struct ide_port_ops ali14xx_port_ops = { 196 + .set_pio_mode = ali14xx_set_pio_mode, 197 + }; 198 + 197 199 static const struct ide_port_info ali14xx_port_info = { 200 + .name = DRV_NAME, 198 201 .chipset = ide_ali14xx, 202 + .port_ops = &ali14xx_port_ops, 199 203 .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, 200 204 .pio_mask = ATA_PIO4, 201 205 }; 202 206 203 207 static int __init ali14xx_probe(void) 204 208 { 205 - ide_hwif_t *hwif, *mate; 206 - static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 207 - hw_regs_t hw[2]; 208 - 209 209 printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n", 210 210 basePort, regOn); 211 211 ··· 217 213 return 1; 218 214 } 219 215 220 - memset(&hw, 0, sizeof(hw)); 221 - 222 - ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); 223 - hw[0].irq = 14; 224 - 225 - ide_std_init_ports(&hw[1], 0x170, 0x376); 226 - hw[1].irq = 15; 227 - 228 - hwif = ide_find_port(); 229 - if (hwif) { 230 - ide_init_port_hw(hwif, &hw[0]); 231 - hwif->set_pio_mode = &ali14xx_set_pio_mode; 232 - idx[0] = hwif->index; 233 - } 234 - 235 - mate = ide_find_port(); 236 - if (mate) { 237 - ide_init_port_hw(mate, &hw[1]); 238 - mate->set_pio_mode = &ali14xx_set_pio_mode; 239 - idx[1] = mate->index; 240 - } 241 - 242 - ide_device_add(idx, &ali14xx_port_info); 243 - 244 - return 0; 216 + return ide_legacy_device_add(&ali14xx_port_info, 0); 245 217 } 246 218 247 219 int probe_ali14xx;
-2
drivers/ide/legacy/buddha.c
··· 228 228 ide_init_port_data(hwif, index); 229 229 ide_init_port_hw(hwif, &hw); 230 230 231 - hwif->mmio = 1; 232 - 233 231 idx[i] = index; 234 232 } 235 233 }
+9 -27
drivers/ide/legacy/dtc2278.c
··· 16 16 17 17 #include <asm/io.h> 18 18 19 + #define DRV_NAME "dtc2278" 20 + 19 21 /* 20 22 * Changing this #undef to #define may solve start up problems in some systems. 21 23 */ ··· 88 86 } 89 87 } 90 88 89 + static const struct ide_port_ops dtc2278_port_ops = { 90 + .set_pio_mode = dtc2278_set_pio_mode, 91 + }; 92 + 91 93 static const struct ide_port_info dtc2278_port_info __initdata = { 94 + .name = DRV_NAME, 92 95 .chipset = ide_dtc2278, 96 + .port_ops = &dtc2278_port_ops, 93 97 .host_flags = IDE_HFLAG_SERIALIZE | 94 98 IDE_HFLAG_NO_UNMASK_IRQS | 95 99 IDE_HFLAG_IO_32BIT | ··· 109 101 static int __init dtc2278_probe(void) 110 102 { 111 103 unsigned long flags; 112 - ide_hwif_t *hwif, *mate; 113 - static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 114 - hw_regs_t hw[2]; 115 104 116 105 local_irq_save(flags); 117 106 /* ··· 128 123 #endif 129 124 local_irq_restore(flags); 130 125 131 - memset(&hw, 0, sizeof(hw)); 132 - 133 - ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); 134 - hw[0].irq = 14; 135 - 136 - ide_std_init_ports(&hw[1], 0x170, 0x376); 137 - hw[1].irq = 15; 138 - 139 - hwif = ide_find_port(); 140 - if (hwif) { 141 - ide_init_port_hw(hwif, &hw[0]); 142 - hwif->set_pio_mode = dtc2278_set_pio_mode; 143 - idx[0] = hwif->index; 144 - } 145 - 146 - mate = ide_find_port(); 147 - if (mate) { 148 - ide_init_port_hw(mate, &hw[1]); 149 - idx[1] = mate->index; 150 - } 151 - 152 - ide_device_add(idx, &dtc2278_port_info); 153 - 154 - return 0; 126 + return ide_legacy_device_add(&dtc2278_port_info, 0); 155 127 } 156 128 157 129 int probe_dtc2278 = 0;
-1
drivers/ide/legacy/falconide.c
··· 89 89 90 90 ide_init_port_data(hwif, index); 91 91 ide_init_port_hw(hwif, &hw); 92 - hwif->mmio = 1; 93 92 94 93 ide_get_lock(NULL, NULL); 95 94 ide_device_add(idx, NULL);
-2
drivers/ide/legacy/gayle.c
··· 182 182 ide_init_port_data(hwif, index); 183 183 ide_init_port_hw(hwif, &hw); 184 184 185 - hwif->mmio = 1; 186 - 187 185 idx[i] = index; 188 186 } else 189 187 release_mem_region(res_start, res_n);
+11 -35
drivers/ide/legacy/ht6560b.c
··· 328 328 module_param_named(probe, probe_ht6560b, bool, 0); 329 329 MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); 330 330 331 + static const struct ide_port_ops ht6560b_port_ops = { 332 + .port_init_devs = ht6560b_port_init_devs, 333 + .set_pio_mode = ht6560b_set_pio_mode, 334 + .selectproc = ht6560b_selectproc, 335 + }; 336 + 331 337 static const struct ide_port_info ht6560b_port_info __initdata = { 338 + .name = DRV_NAME, 332 339 .chipset = ide_ht6560b, 340 + .port_ops = &ht6560b_port_ops, 333 341 .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */ 334 342 IDE_HFLAG_NO_DMA | 335 343 IDE_HFLAG_NO_AUTOTUNE | ··· 347 339 348 340 static int __init ht6560b_init(void) 349 341 { 350 - ide_hwif_t *hwif, *mate; 351 - static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 352 - hw_regs_t hw[2]; 353 - 354 342 if (probe_ht6560b == 0) 355 343 return -ENODEV; 356 344 357 345 if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) { 358 346 printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", 359 - __FUNCTION__); 347 + __func__); 360 348 return -ENODEV; 361 349 } 362 350 363 351 if (!try_to_init_ht6560b()) { 364 - printk(KERN_NOTICE "%s: HBA not found\n", __FUNCTION__); 352 + printk(KERN_NOTICE "%s: HBA not found\n", __func__); 365 353 goto release_region; 366 354 } 367 355 368 - memset(&hw, 0, sizeof(hw)); 369 - 370 - ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); 371 - hw[0].irq = 14; 372 - 373 - ide_std_init_ports(&hw[1], 0x170, 0x376); 374 - hw[1].irq = 15; 375 - 376 - hwif = ide_find_port(); 377 - if (hwif) { 378 - ide_init_port_hw(hwif, &hw[0]); 379 - hwif->selectproc = ht6560b_selectproc; 380 - hwif->set_pio_mode = ht6560b_set_pio_mode; 381 - hwif->port_init_devs = ht6560b_port_init_devs; 382 - idx[0] = hwif->index; 383 - } 384 - 385 - mate = ide_find_port(); 386 - if (mate) { 387 - ide_init_port_hw(mate, &hw[1]); 388 - mate->selectproc = ht6560b_selectproc; 389 - mate->set_pio_mode = ht6560b_set_pio_mode; 390 - mate->port_init_devs = ht6560b_port_init_devs; 391 - idx[1] = mate->index; 392 - } 393 - 394 - ide_device_add(idx, &ht6560b_port_info); 395 - 396 - return 0; 356 + return ide_legacy_device_add(&ht6560b_port_info, 0); 397 357 398 358 release_region: 399 359 release_region(HT_CONFIG_PORT, 1);
+17 -1
drivers/ide/legacy/ide-4drives.c
··· 4 4 #include <linux/module.h> 5 5 #include <linux/ide.h> 6 6 7 + #define DRV_NAME "ide-4drives" 8 + 7 9 int probe_4drives; 8 10 9 11 module_param_named(probe, probe_4drives, bool, 0); ··· 14 12 static int __init ide_4drives_init(void) 15 13 { 16 14 ide_hwif_t *hwif, *mate; 15 + unsigned long base = 0x1f0, ctl = 0x3f6; 17 16 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 18 17 hw_regs_t hw; 19 18 20 19 if (probe_4drives == 0) 21 20 return -ENODEV; 22 21 22 + if (!request_region(base, 8, DRV_NAME)) { 23 + printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", 24 + DRV_NAME, base, base + 7); 25 + return -EBUSY; 26 + } 27 + 28 + if (!request_region(ctl, 1, DRV_NAME)) { 29 + printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", 30 + DRV_NAME, ctl); 31 + release_region(base, 8); 32 + return -EBUSY; 33 + } 34 + 23 35 memset(&hw, 0, sizeof(hw)); 24 36 25 - ide_std_init_ports(&hw, 0x1f0, 0x3f6); 37 + ide_std_init_ports(&hw, base, ctl); 26 38 hw.irq = 14; 27 39 hw.chipset = ide_4drives; 28 40
+53 -23
drivers/ide/legacy/ide-cs.c
··· 51 51 #include <pcmcia/cisreg.h> 52 52 #include <pcmcia/ciscode.h> 53 53 54 + #define DRV_NAME "ide-cs" 55 + 54 56 /*====================================================================*/ 55 57 56 58 /* Module parameters */ ··· 74 72 75 73 /*====================================================================*/ 76 74 77 - static const char ide_major[] = { 78 - IDE0_MAJOR, IDE1_MAJOR, IDE2_MAJOR, IDE3_MAJOR, 79 - IDE4_MAJOR, IDE5_MAJOR 80 - }; 81 - 82 75 typedef struct ide_info_t { 83 76 struct pcmcia_device *p_dev; 77 + ide_hwif_t *hwif; 84 78 int ndev; 85 79 dev_node_t node; 86 - int hd; 87 80 } ide_info_t; 88 81 89 82 static void ide_release(struct pcmcia_device *); ··· 133 136 134 137 static void ide_detach(struct pcmcia_device *link) 135 138 { 139 + ide_info_t *info = link->priv; 140 + ide_hwif_t *hwif = info->hwif; 141 + 136 142 DEBUG(0, "ide_detach(0x%p)\n", link); 137 143 138 144 ide_release(link); 139 145 140 - kfree(link->priv); 146 + release_region(hwif->io_ports[IDE_CONTROL_OFFSET], 1); 147 + release_region(hwif->io_ports[IDE_DATA_OFFSET], 8); 148 + 149 + kfree(info); 141 150 } /* ide_detach */ 142 151 143 - static int idecs_register(unsigned long io, unsigned long ctl, unsigned long irq, struct pcmcia_device *handle) 152 + static const struct ide_port_ops idecs_port_ops = { 153 + .quirkproc = ide_undecoded_slave, 154 + }; 155 + 156 + static ide_hwif_t *idecs_register(unsigned long io, unsigned long ctl, 157 + unsigned long irq, struct pcmcia_device *handle) 144 158 { 145 159 ide_hwif_t *hwif; 146 160 hw_regs_t hw; 147 161 int i; 148 162 u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 163 + 164 + if (!request_region(io, 8, DRV_NAME)) { 165 + printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", 166 + DRV_NAME, io, io + 7); 167 + return NULL; 168 + } 169 + 170 + if (!request_region(ctl, 1, DRV_NAME)) { 171 + printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", 172 + DRV_NAME, ctl); 173 + release_region(io, 8); 174 + return NULL; 175 + } 149 176 150 177 memset(&hw, 0, sizeof(hw)); 151 178 ide_std_init_ports(&hw, io, ctl); ··· 179 158 180 159 hwif = ide_find_port(); 181 160 if (hwif == NULL) 182 - return -1; 161 + goto out_release; 183 162 184 163 i = hwif->index; 185 164 ··· 189 168 ide_init_port_data(hwif, i); 190 169 191 170 ide_init_port_hw(hwif, &hw); 192 - hwif->quirkproc = &ide_undecoded_slave; 171 + hwif->port_ops = &idecs_port_ops; 193 172 194 173 idx[0] = i; 195 174 196 175 ide_device_add(idx, NULL); 197 176 198 - return hwif->present ? i : -1; 177 + if (hwif->present) 178 + return hwif; 179 + 180 + out_release: 181 + release_region(ctl, 1); 182 + release_region(io, 8); 183 + return NULL; 199 184 } 200 185 201 186 /*====================================================================== ··· 226 199 cistpl_cftable_entry_t dflt; 227 200 } *stk = NULL; 228 201 cistpl_cftable_entry_t *cfg; 229 - int i, pass, last_ret = 0, last_fn = 0, hd, is_kme = 0; 202 + int i, pass, last_ret = 0, last_fn = 0, is_kme = 0; 230 203 unsigned long io_base, ctl_base; 204 + ide_hwif_t *hwif; 231 205 232 206 DEBUG(0, "ide_config(0x%p)\n", link); 233 207 ··· 324 296 outb(0x81, ctl_base+1); 325 297 326 298 /* retry registration in case device is still spinning up */ 327 - for (hd = -1, i = 0; i < 10; i++) { 328 - hd = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link); 329 - if (hd >= 0) break; 299 + for (i = 0; i < 10; i++) { 300 + hwif = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link); 301 + if (hwif) 302 + break; 330 303 if (link->io.NumPorts1 == 0x20) { 331 304 outb(0x02, ctl_base + 0x10); 332 - hd = idecs_register(io_base + 0x10, ctl_base + 0x10, 333 - link->irq.AssignedIRQ, link); 334 - if (hd >= 0) { 305 + hwif = idecs_register(io_base + 0x10, ctl_base + 0x10, 306 + link->irq.AssignedIRQ, link); 307 + if (hwif) { 335 308 io_base += 0x10; 336 309 ctl_base += 0x10; 337 310 break; ··· 341 312 msleep(100); 342 313 } 343 314 344 - if (hd < 0) { 315 + if (hwif == NULL) { 345 316 printk(KERN_NOTICE "ide-cs: ide_register() at 0x%3lx & 0x%3lx" 346 317 ", irq %u failed\n", io_base, ctl_base, 347 318 link->irq.AssignedIRQ); ··· 349 320 } 350 321 351 322 info->ndev = 1; 352 - sprintf(info->node.dev_name, "hd%c", 'a' + (hd * 2)); 353 - info->node.major = ide_major[hd]; 323 + sprintf(info->node.dev_name, "hd%c", 'a' + hwif->index * 2); 324 + info->node.major = hwif->major; 354 325 info->node.minor = 0; 355 - info->hd = hd; 326 + info->hwif = hwif; 356 327 link->dev_node = &info->node; 357 328 printk(KERN_INFO "ide-cs: %s: Vpp = %d.%d\n", 358 329 info->node.dev_name, link->conf.Vpp / 10, link->conf.Vpp % 10); ··· 383 354 void ide_release(struct pcmcia_device *link) 384 355 { 385 356 ide_info_t *info = link->priv; 357 + ide_hwif_t *hwif = info->hwif; 386 358 387 359 DEBUG(0, "ide_release(0x%p)\n", link); 388 360 389 361 if (info->ndev) { 390 362 /* FIXME: if this fails we need to queue the cleanup somehow 391 363 -- need to investigate the required PCMCIA magic */ 392 - ide_unregister(info->hd); 364 + ide_unregister(hwif->index); 393 365 } 394 366 info->ndev = 0; 395 367
-1
drivers/ide/legacy/ide_platform.c
··· 100 100 hw.dev = &pdev->dev; 101 101 102 102 ide_init_port_hw(hwif, &hw); 103 - hwif->mmio = 1; 104 103 105 104 if (mmio) 106 105 default_hwif_mmiops(hwif);
-2
drivers/ide/legacy/macide.c
··· 128 128 ide_init_port_data(hwif, index); 129 129 ide_init_port_hw(hwif, &hw); 130 130 131 - hwif->mmio = 1; 132 - 133 131 ide_device_add(idx, NULL); 134 132 } 135 133
-1
drivers/ide/legacy/q40ide.c
··· 141 141 if (hwif) { 142 142 ide_init_port_data(hwif, hwif->index); 143 143 ide_init_port_hw(hwif, &hw); 144 - hwif->mmio = 1; 145 144 146 145 idx[i] = hwif->index; 147 146 }
+37 -97
drivers/ide/legacy/qd65xx.c
··· 37 37 #include <asm/system.h> 38 38 #include <asm/io.h> 39 39 40 + #define DRV_NAME "qd65xx" 41 + 40 42 #include "qd65xx.h" 41 43 42 44 /* ··· 306 304 hwif->drives[1].drive_data = t2; 307 305 } 308 306 307 + static const struct ide_port_ops qd6500_port_ops = { 308 + .port_init_devs = qd6500_port_init_devs, 309 + .set_pio_mode = qd6500_set_pio_mode, 310 + .selectproc = qd65xx_select, 311 + }; 312 + 313 + static const struct ide_port_ops qd6580_port_ops = { 314 + .port_init_devs = qd6580_port_init_devs, 315 + .set_pio_mode = qd6580_set_pio_mode, 316 + .selectproc = qd65xx_select, 317 + }; 318 + 309 319 static const struct ide_port_info qd65xx_port_info __initdata = { 320 + .name = DRV_NAME, 310 321 .chipset = ide_qd65xx, 311 322 .host_flags = IDE_HFLAG_IO_32BIT | 312 323 IDE_HFLAG_NO_DMA | ··· 336 321 337 322 static int __init qd_probe(int base) 338 323 { 339 - ide_hwif_t *hwif; 340 - u8 config, unit; 341 - u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 342 - hw_regs_t hw[2]; 324 + int rc; 325 + u8 config, unit, control; 343 326 struct ide_port_info d = qd65xx_port_info; 344 327 345 328 config = inb(QD_CONFIG_PORT); ··· 350 337 if (unit) 351 338 d.host_flags |= IDE_HFLAG_QD_2ND_PORT; 352 339 353 - memset(&hw, 0, sizeof(hw)); 354 - 355 - ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); 356 - hw[0].irq = 14; 357 - 358 - ide_std_init_ports(&hw[1], 0x170, 0x376); 359 - hw[1].irq = 15; 360 - 361 - if ((config & 0xf0) == QD_CONFIG_QD6500) { 362 - 340 + switch (config & 0xf0) { 341 + case QD_CONFIG_QD6500: 363 342 if (qd_testreg(base)) 364 343 return -ENODEV; /* bad register */ 365 - 366 - /* qd6500 found */ 367 344 368 345 if (config & QD_CONFIG_DISABLED) { 369 346 printk(KERN_WARNING "qd6500 is disabled !\n"); ··· 364 361 printk(KERN_DEBUG "qd6500: config=%#x, ID3=%u\n", 365 362 config, QD_ID3); 366 363 364 + d.port_ops = &qd6500_port_ops; 367 365 d.host_flags |= IDE_HFLAG_SINGLE; 368 - 369 - hwif = ide_find_port_slot(&d); 370 - if (hwif == NULL) 371 - return -ENOENT; 372 - 373 - ide_init_port_hw(hwif, &hw[unit]); 374 - 375 - hwif->config_data = (base << 8) | config; 376 - 377 - hwif->port_init_devs = qd6500_port_init_devs; 378 - hwif->set_pio_mode = qd6500_set_pio_mode; 379 - hwif->selectproc = qd65xx_select; 380 - 381 - idx[unit] = hwif->index; 382 - 383 - ide_device_add(idx, &d); 384 - 385 - return 1; 386 - } 387 - 388 - if (((config & 0xf0) == QD_CONFIG_QD6580_A) || 389 - ((config & 0xf0) == QD_CONFIG_QD6580_B)) { 390 - 391 - u8 control; 392 - 366 + break; 367 + case QD_CONFIG_QD6580_A: 368 + case QD_CONFIG_QD6580_B: 393 369 if (qd_testreg(base) || qd_testreg(base + 0x02)) 394 370 return -ENODEV; /* bad registers */ 395 - 396 - /* qd6580 found */ 397 371 398 372 control = inb(QD_CONTROL_PORT); 399 373 ··· 380 400 381 401 outb(QD_DEF_CONTR, QD_CONTROL_PORT); 382 402 383 - if (control & QD_CONTR_SEC_DISABLED) { 384 - /* secondary disabled */ 385 - 386 - printk(KERN_INFO "qd6580: single IDE board\n"); 387 - 403 + d.port_ops = &qd6580_port_ops; 404 + if (control & QD_CONTR_SEC_DISABLED) 388 405 d.host_flags |= IDE_HFLAG_SINGLE; 389 406 390 - hwif = ide_find_port_slot(&d); 391 - if (hwif == NULL) 392 - return -ENOENT; 393 - 394 - ide_init_port_hw(hwif, &hw[unit]); 395 - 396 - hwif->config_data = (base << 8) | config; 397 - 398 - hwif->port_init_devs = qd6580_port_init_devs; 399 - hwif->set_pio_mode = qd6580_set_pio_mode; 400 - hwif->selectproc = qd65xx_select; 401 - 402 - idx[unit] = hwif->index; 403 - 404 - ide_device_add(idx, &d); 405 - 406 - return 1; 407 - } else { 408 - ide_hwif_t *mate; 409 - 410 - /* secondary enabled */ 411 - printk(KERN_INFO "qd6580: dual IDE board\n"); 412 - 413 - hwif = ide_find_port(); 414 - if (hwif) { 415 - ide_init_port_hw(hwif, &hw[0]); 416 - hwif->config_data = (base << 8) | config; 417 - hwif->port_init_devs = qd6580_port_init_devs; 418 - hwif->set_pio_mode = qd6580_set_pio_mode; 419 - hwif->selectproc = qd65xx_select; 420 - idx[0] = hwif->index; 421 - } 422 - 423 - mate = ide_find_port(); 424 - if (mate) { 425 - ide_init_port_hw(mate, &hw[1]); 426 - mate->config_data = (base << 8) | config; 427 - mate->port_init_devs = qd6580_port_init_devs; 428 - mate->set_pio_mode = qd6580_set_pio_mode; 429 - mate->selectproc = qd65xx_select; 430 - idx[1] = mate->index; 431 - } 432 - 433 - ide_device_add(idx, &qd65xx_port_info); 434 - 435 - return 0; /* no other qd65xx possible */ 436 - } 407 + printk(KERN_INFO "qd6580: %s IDE board\n", 408 + (control & QD_CONTR_SEC_DISABLED) ? "single" : "dual"); 409 + break; 410 + default: 411 + return -ENODEV; 437 412 } 438 - /* no qd65xx found */ 439 - return -ENODEV; 413 + 414 + rc = ide_legacy_device_add(&d, (base << 8) | config); 415 + 416 + if (d.host_flags & IDE_HFLAG_SINGLE) 417 + return (rc == 0) ? 1 : rc; 418 + 419 + return rc; 440 420 } 441 421 442 422 int probe_qd65xx = 0;
+9 -28
drivers/ide/legacy/umc8672.c
··· 51 51 52 52 #include <asm/io.h> 53 53 54 + #define DRV_NAME "umc8672" 55 + 54 56 /* 55 57 * Default speeds. These can be changed with "auto-tune" and/or hdparm. 56 58 */ ··· 122 120 spin_unlock_irqrestore(&ide_lock, flags); 123 121 } 124 122 123 + static const struct ide_port_ops umc8672_port_ops = { 124 + .set_pio_mode = umc_set_pio_mode, 125 + }; 126 + 125 127 static const struct ide_port_info umc8672_port_info __initdata = { 128 + .name = DRV_NAME, 126 129 .chipset = ide_umc8672, 130 + .port_ops = &umc8672_port_ops, 127 131 .host_flags = IDE_HFLAG_NO_DMA | IDE_HFLAG_NO_AUTOTUNE, 128 132 .pio_mask = ATA_PIO4, 129 133 }; 130 134 131 135 static int __init umc8672_probe(void) 132 136 { 133 - ide_hwif_t *hwif, *mate; 134 137 unsigned long flags; 135 - static u8 idx[4] = { 0xff, 0xff, 0xff, 0xff }; 136 - hw_regs_t hw[2]; 137 138 138 139 if (!request_region(0x108, 2, "umc8672")) { 139 140 printk(KERN_ERR "umc8672: ports 0x108-0x109 already in use.\n"); ··· 155 150 umc_set_speeds(current_speeds); 156 151 local_irq_restore(flags); 157 152 158 - memset(&hw, 0, sizeof(hw)); 159 - 160 - ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); 161 - hw[0].irq = 14; 162 - 163 - ide_std_init_ports(&hw[1], 0x170, 0x376); 164 - hw[1].irq = 15; 165 - 166 - hwif = ide_find_port(); 167 - if (hwif) { 168 - ide_init_port_hw(hwif, &hw[0]); 169 - hwif->set_pio_mode = umc_set_pio_mode; 170 - idx[0] = hwif->index; 171 - } 172 - 173 - mate = ide_find_port(); 174 - if (mate) { 175 - ide_init_port_hw(mate, &hw[1]); 176 - mate->set_pio_mode = umc_set_pio_mode; 177 - idx[1] = mate->index; 178 - } 179 - 180 - ide_device_add(idx, &umc8672_port_info); 181 - 182 - return 0; 153 + return ide_legacy_device_add(&umc8672_port_info, 0); 183 154 } 184 155 185 156 int probe_umc8672;
+35 -80
drivers/ide/mips/au1xxx-ide.c
··· 47 47 #define IDE_AU1XXX_BURSTMODE 1 48 48 49 49 static _auide_hwif auide_hwif; 50 - static int dbdma_init_done; 51 50 52 51 static int auide_ddma_init(_auide_hwif *auide); 53 52 ··· 60 61 61 62 if(!put_dest_flags(ahwif->rx_chan, (void*)addr, count << 1, 62 63 DDMA_FLAGS_NOIE)) { 63 - printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__); 64 + printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); 64 65 return; 65 66 } 66 67 ctp = *((chan_tab_t **)ahwif->rx_chan); ··· 78 79 79 80 if(!put_source_flags(ahwif->tx_chan, (void*)addr, 80 81 count << 1, DDMA_FLAGS_NOIE)) { 81 - printk(KERN_ERR "%s failed %d\n", __FUNCTION__, __LINE__); 82 + printk(KERN_ERR "%s failed %d\n", __func__, __LINE__); 82 83 return; 83 84 } 84 85 ctp = *((chan_tab_t **)ahwif->tx_chan); ··· 249 250 (void*) sg_virt(sg), 250 251 tc, flags)) { 251 252 printk(KERN_ERR "%s failed %d\n", 252 - __FUNCTION__, __LINE__); 253 + __func__, __LINE__); 253 254 } 254 255 } else 255 256 { ··· 257 258 (void*) sg_virt(sg), 258 259 tc, flags)) { 259 260 printk(KERN_ERR "%s failed %d\n", 260 - __FUNCTION__, __LINE__); 261 + __func__, __LINE__); 261 262 } 262 263 } 263 264 ··· 314 315 return 0; 315 316 } 316 317 317 - static u8 auide_mdma_filter(ide_drive_t *drive) 318 - { 319 - /* 320 - * FIXME: ->white_list and ->black_list are based on completely bogus 321 - * ->ide_dma_check implementation which didn't set neither the host 322 - * controller timings nor the device for the desired transfer mode. 323 - * 324 - * They should be either removed or 0x00 MWDMA mask should be 325 - * returned for devices on the ->black_list. 326 - */ 327 - 328 - if (dbdma_init_done == 0) { 329 - auide_hwif.white_list = ide_in_drive_list(drive->id, 330 - dma_white_list); 331 - auide_hwif.black_list = ide_in_drive_list(drive->id, 332 - dma_black_list); 333 - auide_hwif.drive = drive; 334 - auide_ddma_init(&auide_hwif); 335 - dbdma_init_done = 1; 336 - } 337 - 338 - /* Is the drive in our DMA black list? */ 339 - if (auide_hwif.black_list) 340 - printk(KERN_WARNING "%s: Disabling DMA for %s (blacklisted)\n", 341 - drive->name, drive->id->model); 342 - 343 - return drive->hwif->mwdma_mask; 344 - } 345 - 346 318 static int auide_dma_test_irq(ide_drive_t *drive) 347 319 { 348 320 if (drive->waiting_for_dma == 0) ··· 366 396 dev->dev_devwidth = devwidth; 367 397 dev->dev_flags = flags; 368 398 } 369 - 370 - #if defined(CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA) 371 399 400 + #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 372 401 static void auide_dma_timeout(ide_drive_t *drive) 373 402 { 374 403 ide_hwif_t *hwif = HWIF(drive); 375 404 376 405 printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name); 377 406 378 - if (hwif->ide_dma_test_irq(drive)) 407 + if (auide_dma_test_irq(drive)) 379 408 return; 380 409 381 - hwif->ide_dma_end(drive); 410 + auide_dma_end(drive); 382 411 } 383 - 384 412 385 - static int auide_ddma_init(_auide_hwif *auide) { 386 - 413 + static const struct ide_dma_ops au1xxx_dma_ops = { 414 + .dma_host_set = auide_dma_host_set, 415 + .dma_setup = auide_dma_setup, 416 + .dma_exec_cmd = auide_dma_exec_cmd, 417 + .dma_start = auide_dma_start, 418 + .dma_end = auide_dma_end, 419 + .dma_test_irq = auide_dma_test_irq, 420 + .dma_lost_irq = auide_dma_lost_irq, 421 + .dma_timeout = auide_dma_timeout, 422 + }; 423 + 424 + static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) 425 + { 426 + _auide_hwif *auide = (_auide_hwif *)hwif->hwif_data; 387 427 dbdev_tab_t source_dev_tab, target_dev_tab; 388 428 u32 dev_id, tsize, devwidth, flags; 389 - ide_hwif_t *hwif = auide->hwif; 390 429 391 430 dev_id = AU1XXX_ATA_DDMA_REQ; 392 431 393 - if (auide->white_list || auide->black_list) { 394 - tsize = 8; 395 - devwidth = 32; 396 - } 397 - else { 398 - tsize = 1; 399 - devwidth = 16; 400 - 401 - printk(KERN_ERR "au1xxx-ide: %s is not on ide driver whitelist.\n",auide_hwif.drive->id->model); 402 - printk(KERN_ERR " please read 'Documentation/mips/AU1xxx_IDE.README'"); 403 - } 432 + tsize = 8; /* 1 */ 433 + devwidth = 32; /* 16 */ 404 434 405 435 #ifdef IDE_AU1XXX_BURSTMODE 406 436 flags = DEV_FLAGS_SYNC | DEV_FLAGS_BURSTABLE; ··· 452 482 return 0; 453 483 } 454 484 #else 455 - 456 - static int auide_ddma_init( _auide_hwif *auide ) 485 + static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) 457 486 { 487 + _auide_hwif *auide = (_auide_hwif *)hwif->hwif_data; 458 488 dbdev_tab_t source_dev_tab; 459 489 int flags; 460 490 ··· 513 543 *ata_regs = ahwif->regbase + (14 << AU1XXX_ATA_REG_OFFSET); 514 544 } 515 545 546 + static const struct ide_port_ops au1xxx_port_ops = { 547 + .set_pio_mode = au1xxx_set_pio_mode, 548 + .set_dma_mode = auide_set_dma_mode, 549 + }; 550 + 516 551 static const struct ide_port_info au1xxx_port_info = { 552 + .init_dma = auide_ddma_init, 553 + .port_ops = &au1xxx_port_ops, 554 + #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 555 + .dma_ops = &au1xxx_dma_ops, 556 + #endif 517 557 .host_flags = IDE_HFLAG_POST_SET_MODE | 518 - IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ 519 558 IDE_HFLAG_NO_IO_32BIT | 520 559 IDE_HFLAG_UNMASK_IRQS, 521 560 .pio_mask = ATA_PIO4, ··· 594 615 595 616 hwif->dev = dev; 596 617 597 - hwif->mmio = 1; 598 - 599 618 /* If the user has selected DDMA assisted copies, 600 619 then set up a few local I/O function entry points 601 620 */ ··· 602 625 hwif->INSW = auide_insw; 603 626 hwif->OUTSW = auide_outsw; 604 627 #endif 605 - 606 - hwif->set_pio_mode = &au1xxx_set_pio_mode; 607 - hwif->set_dma_mode = &auide_set_dma_mode; 608 - 609 - #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 610 - hwif->dma_timeout = &auide_dma_timeout; 611 - 612 - hwif->mdma_filter = &auide_mdma_filter; 613 - 614 - hwif->dma_host_set = &auide_dma_host_set; 615 - hwif->dma_exec_cmd = &auide_dma_exec_cmd; 616 - hwif->dma_start = &auide_dma_start; 617 - hwif->ide_dma_end = &auide_dma_end; 618 - hwif->dma_setup = &auide_dma_setup; 619 - hwif->ide_dma_test_irq = &auide_dma_test_irq; 620 - hwif->dma_lost_irq = &auide_dma_lost_irq; 621 - #endif 622 628 hwif->select_data = 0; /* no chipset-specific code */ 623 629 hwif->config_data = 0; /* no chipset-specific code */ 624 630 625 631 auide_hwif.hwif = hwif; 626 632 hwif->hwif_data = &auide_hwif; 627 - 628 - #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_PIO_DBDMA 629 - auide_ddma_init(&auide_hwif); 630 - dbdma_init_done = 1; 631 - #endif 632 633 633 634 idx[0] = hwif->index; 634 635
+1 -3
drivers/ide/mips/swarm.c
··· 110 110 111 111 /* Setup MMIO ops. */ 112 112 default_hwif_mmiops(hwif); 113 - /* Prevent resource map manipulation. */ 114 - hwif->mmio = 1; 113 + 115 114 hwif->chipset = ide_generic; 116 - hwif->noprobe = 0; 117 115 118 116 for (i = IDE_DATA_OFFSET; i <= IDE_STATUS_OFFSET; i++) 119 117 hwif->io_ports[i] =
+15 -19
drivers/ide/pci/aec62xx.c
··· 135 135 136 136 static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) 137 137 { 138 - drive->hwif->set_dma_mode(drive, pio + XFER_PIO_0); 138 + drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); 139 139 } 140 140 141 141 static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) ··· 175 175 return (ata66 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 176 176 } 177 177 178 - static void __devinit init_hwif_aec62xx(ide_hwif_t *hwif) 179 - { 180 - struct pci_dev *dev = to_pci_dev(hwif->dev); 178 + static const struct ide_port_ops atp850_port_ops = { 179 + .set_pio_mode = aec_set_pio_mode, 180 + .set_dma_mode = aec6210_set_mode, 181 + }; 181 182 182 - hwif->set_pio_mode = &aec_set_pio_mode; 183 - 184 - if (dev->device == PCI_DEVICE_ID_ARTOP_ATP850UF) 185 - hwif->set_dma_mode = &aec6210_set_mode; 186 - else { 187 - hwif->set_dma_mode = &aec6260_set_mode; 188 - 189 - hwif->cable_detect = atp86x_cable_detect; 190 - } 191 - } 183 + static const struct ide_port_ops atp86x_port_ops = { 184 + .set_pio_mode = aec_set_pio_mode, 185 + .set_dma_mode = aec6260_set_mode, 186 + .cable_detect = atp86x_cable_detect, 187 + }; 192 188 193 189 static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { 194 190 { /* 0 */ 195 191 .name = "AEC6210", 196 192 .init_chipset = init_chipset_aec62xx, 197 - .init_hwif = init_hwif_aec62xx, 198 193 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 194 + .port_ops = &atp850_port_ops, 199 195 .host_flags = IDE_HFLAG_SERIALIZE | 200 196 IDE_HFLAG_NO_ATAPI_DMA | 201 197 IDE_HFLAG_NO_DSC | ··· 203 207 },{ /* 1 */ 204 208 .name = "AEC6260", 205 209 .init_chipset = init_chipset_aec62xx, 206 - .init_hwif = init_hwif_aec62xx, 210 + .port_ops = &atp86x_port_ops, 207 211 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | 208 212 IDE_HFLAG_ABUSE_SET_DMA_MODE | 209 213 IDE_HFLAG_OFF_BOARD, ··· 213 217 },{ /* 2 */ 214 218 .name = "AEC6260R", 215 219 .init_chipset = init_chipset_aec62xx, 216 - .init_hwif = init_hwif_aec62xx, 217 220 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 221 + .port_ops = &atp86x_port_ops, 218 222 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | 219 223 IDE_HFLAG_ABUSE_SET_DMA_MODE | 220 224 IDE_HFLAG_NON_BOOTABLE, ··· 224 228 },{ /* 3 */ 225 229 .name = "AEC6280", 226 230 .init_chipset = init_chipset_aec62xx, 227 - .init_hwif = init_hwif_aec62xx, 231 + .port_ops = &atp86x_port_ops, 228 232 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | 229 233 IDE_HFLAG_ABUSE_SET_DMA_MODE | 230 234 IDE_HFLAG_OFF_BOARD, ··· 234 238 },{ /* 4 */ 235 239 .name = "AEC6280R", 236 240 .init_chipset = init_chipset_aec62xx, 237 - .init_hwif = init_hwif_aec62xx, 238 241 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 242 + .port_ops = &atp86x_port_ops, 239 243 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | 240 244 IDE_HFLAG_ABUSE_SET_DMA_MODE | 241 245 IDE_HFLAG_OFF_BOARD,
+52 -37
drivers/ide/pci/alim15x3.c
··· 610 610 } 611 611 612 612 /** 613 - * ata66_ali15x3 - check for UDMA 66 support 613 + * ali_cable_detect - cable detection 614 614 * @hwif: IDE interface 615 615 * 616 616 * This checks if the controller and the cable are capable ··· 620 620 * FIXME: frobs bits that are not defined on newer ALi devicea 621 621 */ 622 622 623 - static u8 __devinit ata66_ali15x3(ide_hwif_t *hwif) 623 + static u8 __devinit ali_cable_detect(ide_hwif_t *hwif) 624 624 { 625 625 struct pci_dev *dev = to_pci_dev(hwif->dev); 626 626 unsigned long flags; ··· 652 652 return cbl; 653 653 } 654 654 655 - /** 656 - * init_hwif_common_ali15x3 - Set up ALI IDE hardware 657 - * @hwif: IDE interface 658 - * 659 - * Initialize the IDE structure side of the ALi 15x3 driver. 660 - */ 661 - 662 - static void __devinit init_hwif_common_ali15x3 (ide_hwif_t *hwif) 663 - { 664 - hwif->set_pio_mode = &ali_set_pio_mode; 665 - hwif->set_dma_mode = &ali_set_dma_mode; 666 - hwif->udma_filter = &ali_udma_filter; 667 - 668 - hwif->cable_detect = ata66_ali15x3; 669 - 670 - if (hwif->dma_base == 0) 671 - return; 672 - 673 - hwif->dma_setup = &ali15x3_dma_setup; 674 - } 675 - 655 + #ifndef CONFIG_SPARC64 676 656 /** 677 657 * init_hwif_ali15x3 - Initialize the ALI IDE x86 stuff 678 658 * @hwif: interface to configure ··· 702 722 if(irq >= 0) 703 723 hwif->irq = irq; 704 724 } 705 - 706 - init_hwif_common_ali15x3(hwif); 707 725 } 726 + #endif 708 727 709 728 /** 710 729 * init_dma_ali15x3 - set up DMA on ALi15x3 711 730 * @hwif: IDE interface 712 - * @dmabase: DMA interface base PCI address 731 + * @d: IDE port info 713 732 * 714 - * Set up the DMA functionality on the ALi 15x3. For the ALi 715 - * controllers this is generic so we can let the generic code do 716 - * the actual work. 733 + * Set up the DMA functionality on the ALi 15x3. 717 734 */ 718 735 719 - static void __devinit init_dma_ali15x3 (ide_hwif_t *hwif, unsigned long dmabase) 736 + static int __devinit init_dma_ali15x3(ide_hwif_t *hwif, 737 + const struct ide_port_info *d) 720 738 { 721 - if (m5229_revision < 0x20) 722 - return; 739 + struct pci_dev *dev = to_pci_dev(hwif->dev); 740 + unsigned long base = ide_pci_dma_base(hwif, d); 741 + 742 + if (base == 0 || ide_pci_set_master(dev, d->name) < 0) 743 + return -1; 744 + 723 745 if (!hwif->channel) 724 - outb(inb(dmabase + 2) & 0x60, dmabase + 2); 725 - ide_setup_dma(hwif, dmabase); 746 + outb(inb(base + 2) & 0x60, base + 2); 747 + 748 + printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", 749 + hwif->name, base, base + 7); 750 + 751 + if (ide_allocate_dma_engine(hwif)) 752 + return -1; 753 + 754 + ide_setup_dma(hwif, base); 755 + 756 + return 0; 726 757 } 758 + 759 + static const struct ide_port_ops ali_port_ops = { 760 + .set_pio_mode = ali_set_pio_mode, 761 + .set_dma_mode = ali_set_dma_mode, 762 + .udma_filter = ali_udma_filter, 763 + .cable_detect = ali_cable_detect, 764 + }; 765 + 766 + static const struct ide_dma_ops ali_dma_ops = { 767 + .dma_host_set = ide_dma_host_set, 768 + .dma_setup = ali15x3_dma_setup, 769 + .dma_exec_cmd = ide_dma_exec_cmd, 770 + .dma_start = ide_dma_start, 771 + .dma_end = __ide_dma_end, 772 + .dma_test_irq = ide_dma_test_irq, 773 + .dma_lost_irq = ide_dma_lost_irq, 774 + .dma_timeout = ide_dma_timeout, 775 + }; 727 776 728 777 static const struct ide_port_info ali15x3_chipset __devinitdata = { 729 778 .name = "ALI15X3", 730 779 .init_chipset = init_chipset_ali15x3, 780 + #ifndef CONFIG_SPARC64 731 781 .init_hwif = init_hwif_ali15x3, 782 + #endif 732 783 .init_dma = init_dma_ali15x3, 784 + .port_ops = &ali_port_ops, 733 785 .pio_mask = ATA_PIO5, 734 786 .swdma_mask = ATA_SWDMA2, 735 787 .mwdma_mask = ATA_MWDMA2, ··· 804 792 d.udma_mask = ATA_UDMA5; 805 793 else 806 794 d.udma_mask = ATA_UDMA6; 795 + 796 + d.dma_ops = &ali_dma_ops; 797 + } else { 798 + d.host_flags |= IDE_HFLAG_NO_DMA; 799 + 800 + d.mwdma_mask = d.swdma_mask = 0; 807 801 } 808 802 809 803 if (idx == 0) 810 804 d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; 811 805 812 - #if defined(CONFIG_SPARC64) 813 - d.init_hwif = init_hwif_common_ali15x3; 814 - #endif /* CONFIG_SPARC64 */ 815 806 return ide_setup_pci_device(dev, &d); 816 807 } 817 808
+8 -5
drivers/ide/pci/amd74xx.c
··· 210 210 211 211 if (hwif->irq == 0) /* 0 is bogus but will do for now */ 212 212 hwif->irq = pci_get_legacy_ide_irq(dev, hwif->channel); 213 - 214 - hwif->set_pio_mode = &amd_set_pio_mode; 215 - hwif->set_dma_mode = &amd_set_drive; 216 - 217 - hwif->cable_detect = amd_cable_detect; 218 213 } 214 + 215 + static const struct ide_port_ops amd_port_ops = { 216 + .set_pio_mode = amd_set_pio_mode, 217 + .set_dma_mode = amd_set_drive, 218 + .cable_detect = amd_cable_detect, 219 + }; 219 220 220 221 #define IDE_HFLAGS_AMD \ 221 222 (IDE_HFLAG_PIO_NO_BLACKLIST | \ ··· 231 230 .init_chipset = init_chipset_amd74xx, \ 232 231 .init_hwif = init_hwif_amd74xx, \ 233 232 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ 233 + .port_ops = &amd_port_ops, \ 234 234 .host_flags = IDE_HFLAGS_AMD, \ 235 235 .pio_mask = ATA_PIO5, \ 236 236 .swdma_mask = swdma, \ ··· 245 243 .init_chipset = init_chipset_amd74xx, \ 246 244 .init_hwif = init_hwif_amd74xx, \ 247 245 .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ 246 + .port_ops = &amd_port_ops, \ 248 247 .host_flags = IDE_HFLAGS_AMD, \ 249 248 .pio_mask = ATA_PIO5, \ 250 249 .swdma_mask = ATA_SWDMA2, \
+7 -17
drivers/ide/pci/atiixp.c
··· 130 130 return ATA_CBL_PATA40; 131 131 } 132 132 133 - /** 134 - * init_hwif_atiixp - fill in the hwif for the ATIIXP 135 - * @hwif: IDE interface 136 - * 137 - * Set up the ide_hwif_t for the ATIIXP interface according to the 138 - * capabilities of the hardware. 139 - */ 140 - 141 - static void __devinit init_hwif_atiixp(ide_hwif_t *hwif) 142 - { 143 - hwif->set_pio_mode = &atiixp_set_pio_mode; 144 - hwif->set_dma_mode = &atiixp_set_dma_mode; 145 - 146 - hwif->cable_detect = atiixp_cable_detect; 147 - } 133 + static const struct ide_port_ops atiixp_port_ops = { 134 + .set_pio_mode = atiixp_set_pio_mode, 135 + .set_dma_mode = atiixp_set_dma_mode, 136 + .cable_detect = atiixp_cable_detect, 137 + }; 148 138 149 139 static const struct ide_port_info atiixp_pci_info[] __devinitdata = { 150 140 { /* 0 */ 151 141 .name = "ATIIXP", 152 - .init_hwif = init_hwif_atiixp, 153 142 .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, 143 + .port_ops = &atiixp_port_ops, 154 144 .host_flags = IDE_HFLAG_LEGACY_IRQS, 155 145 .pio_mask = ATA_PIO4, 156 146 .mwdma_mask = ATA_MWDMA2, 157 147 .udma_mask = ATA_UDMA5, 158 148 },{ /* 1 */ 159 149 .name = "SB600_PATA", 160 - .init_hwif = init_hwif_atiixp, 161 150 .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, 151 + .port_ops = &atiixp_port_ops, 162 152 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS, 163 153 .pio_mask = ATA_PIO4, 164 154 .mwdma_mask = ATA_MWDMA2,
+36 -9
drivers/ide/pci/cmd640.c
··· 109 109 110 110 #include <asm/io.h> 111 111 112 + #define DRV_NAME "cmd640" 113 + 112 114 /* 113 115 * This flag is set in ide.c by the parameter: ide0=cmd640_vlb 114 116 */ ··· 635 633 display_clocks(index); 636 634 } 637 635 636 + static const struct ide_port_ops cmd640_port_ops = { 637 + .set_pio_mode = cmd640_set_pio_mode, 638 + }; 638 639 #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ 639 640 640 641 static int pci_conf1(void) ··· 683 678 IDE_HFLAG_ABUSE_PREFETCH | 684 679 IDE_HFLAG_ABUSE_FAST_DEVSEL, 685 680 #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED 681 + .port_ops = &cmd640_port_ops, 686 682 .pio_mask = ATA_PIO5, 687 683 #endif 688 684 }; 685 + 686 + static int cmd640x_init_one(unsigned long base, unsigned long ctl) 687 + { 688 + if (!request_region(base, 8, DRV_NAME)) { 689 + printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n", 690 + DRV_NAME, base, base + 7); 691 + return -EBUSY; 692 + } 693 + 694 + if (!request_region(ctl, 1, DRV_NAME)) { 695 + printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n", 696 + DRV_NAME, ctl); 697 + release_region(base, 8); 698 + return -EBUSY; 699 + } 700 + 701 + return 0; 702 + } 689 703 690 704 /* 691 705 * Probe for a cmd640 chipset, and initialize it if found. ··· 714 690 #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED 715 691 int second_port_toggled = 0; 716 692 #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ 717 - int second_port_cmd640 = 0; 693 + int second_port_cmd640 = 0, rc; 718 694 const char *bus_type, *port2; 719 695 unsigned int index; 720 696 u8 b, cfr; ··· 758 734 return 0; 759 735 } 760 736 737 + rc = cmd640x_init_one(0x1f0, 0x3f6); 738 + if (rc) 739 + return rc; 740 + 741 + rc = cmd640x_init_one(0x170, 0x376); 742 + if (rc) { 743 + release_region(0x3f6, 1); 744 + release_region(0x1f0, 8); 745 + return rc; 746 + } 747 + 761 748 memset(&hw, 0, sizeof(hw)); 762 749 763 750 ide_std_init_ports(&hw[0], 0x1f0, 0x3f6); ··· 787 752 */ 788 753 if (cmd_hwif0) { 789 754 ide_init_port_hw(cmd_hwif0, &hw[0]); 790 - #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED 791 - cmd_hwif0->set_pio_mode = &cmd640_set_pio_mode; 792 - #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ 793 - 794 755 idx[0] = cmd_hwif0->index; 795 756 } 796 757 ··· 839 808 */ 840 809 if (second_port_cmd640 && cmd_hwif1) { 841 810 ide_init_port_hw(cmd_hwif1, &hw[1]); 842 - #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED 843 - cmd_hwif1->set_pio_mode = &cmd640_set_pio_mode; 844 - #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ 845 - 846 811 idx[1] = cmd_hwif1->index; 847 812 } 848 813 printk(KERN_INFO "cmd640: %sserialized, secondary interface %s\n",
+78 -60
drivers/ide/pci/cmd64x.c
··· 223 223 (void) pci_write_config_byte(dev, pciU, regU); 224 224 } 225 225 226 - static int cmd648_ide_dma_end (ide_drive_t *drive) 226 + static int cmd648_dma_end(ide_drive_t *drive) 227 227 { 228 228 ide_hwif_t *hwif = HWIF(drive); 229 229 unsigned long base = hwif->dma_base - (hwif->channel * 8); ··· 239 239 return err; 240 240 } 241 241 242 - static int cmd64x_ide_dma_end (ide_drive_t *drive) 242 + static int cmd64x_dma_end(ide_drive_t *drive) 243 243 { 244 244 ide_hwif_t *hwif = HWIF(drive); 245 245 struct pci_dev *dev = to_pci_dev(hwif->dev); ··· 256 256 return err; 257 257 } 258 258 259 - static int cmd648_ide_dma_test_irq (ide_drive_t *drive) 259 + static int cmd648_dma_test_irq(ide_drive_t *drive) 260 260 { 261 261 ide_hwif_t *hwif = HWIF(drive); 262 262 unsigned long base = hwif->dma_base - (hwif->channel * 8); ··· 279 279 return 0; 280 280 } 281 281 282 - static int cmd64x_ide_dma_test_irq (ide_drive_t *drive) 282 + static int cmd64x_dma_test_irq(ide_drive_t *drive) 283 283 { 284 284 ide_hwif_t *hwif = HWIF(drive); 285 285 struct pci_dev *dev = to_pci_dev(hwif->dev); ··· 310 310 * event order for DMA transfers. 311 311 */ 312 312 313 - static int cmd646_1_ide_dma_end (ide_drive_t *drive) 313 + static int cmd646_1_dma_end(ide_drive_t *drive) 314 314 { 315 315 ide_hwif_t *hwif = HWIF(drive); 316 316 u8 dma_stat = 0, dma_cmd = 0; ··· 370 370 return 0; 371 371 } 372 372 373 - static u8 __devinit ata66_cmd64x(ide_hwif_t *hwif) 373 + static u8 __devinit cmd64x_cable_detect(ide_hwif_t *hwif) 374 374 { 375 375 struct pci_dev *dev = to_pci_dev(hwif->dev); 376 376 u8 bmidecsr = 0, mask = hwif->channel ? 0x02 : 0x01; ··· 385 385 } 386 386 } 387 387 388 - static void __devinit init_hwif_cmd64x(ide_hwif_t *hwif) 389 - { 390 - struct pci_dev *dev = to_pci_dev(hwif->dev); 388 + static const struct ide_port_ops cmd64x_port_ops = { 389 + .set_pio_mode = cmd64x_set_pio_mode, 390 + .set_dma_mode = cmd64x_set_dma_mode, 391 + .cable_detect = cmd64x_cable_detect, 392 + }; 391 393 392 - hwif->set_pio_mode = &cmd64x_set_pio_mode; 393 - hwif->set_dma_mode = &cmd64x_set_dma_mode; 394 + static const struct ide_dma_ops cmd64x_dma_ops = { 395 + .dma_host_set = ide_dma_host_set, 396 + .dma_setup = ide_dma_setup, 397 + .dma_exec_cmd = ide_dma_exec_cmd, 398 + .dma_start = ide_dma_start, 399 + .dma_end = cmd64x_dma_end, 400 + .dma_test_irq = cmd64x_dma_test_irq, 401 + .dma_lost_irq = ide_dma_lost_irq, 402 + .dma_timeout = ide_dma_timeout, 403 + }; 394 404 395 - hwif->cable_detect = ata66_cmd64x; 405 + static const struct ide_dma_ops cmd646_rev1_dma_ops = { 406 + .dma_host_set = ide_dma_host_set, 407 + .dma_setup = ide_dma_setup, 408 + .dma_exec_cmd = ide_dma_exec_cmd, 409 + .dma_start = ide_dma_start, 410 + .dma_end = cmd646_1_dma_end, 411 + .dma_test_irq = ide_dma_test_irq, 412 + .dma_lost_irq = ide_dma_lost_irq, 413 + .dma_timeout = ide_dma_timeout, 414 + }; 396 415 397 - if (!hwif->dma_base) 398 - return; 399 - 400 - /* 401 - * UltraDMA only supported on PCI646U and PCI646U2, which 402 - * correspond to revisions 0x03, 0x05 and 0x07 respectively. 403 - * Actually, although the CMD tech support people won't 404 - * tell me the details, the 0x03 revision cannot support 405 - * UDMA correctly without hardware modifications, and even 406 - * then it only works with Quantum disks due to some 407 - * hold time assumptions in the 646U part which are fixed 408 - * in the 646U2. 409 - * 410 - * So we only do UltraDMA on revision 0x05 and 0x07 chipsets. 411 - */ 412 - if (dev->device == PCI_DEVICE_ID_CMD_646 && dev->revision < 5) 413 - hwif->ultra_mask = 0x00; 414 - 415 - switch (dev->device) { 416 - case PCI_DEVICE_ID_CMD_648: 417 - case PCI_DEVICE_ID_CMD_649: 418 - alt_irq_bits: 419 - hwif->ide_dma_end = &cmd648_ide_dma_end; 420 - hwif->ide_dma_test_irq = &cmd648_ide_dma_test_irq; 421 - break; 422 - case PCI_DEVICE_ID_CMD_646: 423 - if (dev->revision == 0x01) { 424 - hwif->ide_dma_end = &cmd646_1_ide_dma_end; 425 - break; 426 - } else if (dev->revision >= 0x03) 427 - goto alt_irq_bits; 428 - /* fall thru */ 429 - default: 430 - hwif->ide_dma_end = &cmd64x_ide_dma_end; 431 - hwif->ide_dma_test_irq = &cmd64x_ide_dma_test_irq; 432 - break; 433 - } 434 - } 416 + static const struct ide_dma_ops cmd648_dma_ops = { 417 + .dma_host_set = ide_dma_host_set, 418 + .dma_setup = ide_dma_setup, 419 + .dma_exec_cmd = ide_dma_exec_cmd, 420 + .dma_start = ide_dma_start, 421 + .dma_end = cmd648_dma_end, 422 + .dma_test_irq = cmd648_dma_test_irq, 423 + .dma_lost_irq = ide_dma_lost_irq, 424 + .dma_timeout = ide_dma_timeout, 425 + }; 435 426 436 427 static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { 437 428 { /* 0 */ 438 429 .name = "CMD643", 439 430 .init_chipset = init_chipset_cmd64x, 440 - .init_hwif = init_hwif_cmd64x, 441 431 .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, 432 + .port_ops = &cmd64x_port_ops, 433 + .dma_ops = &cmd64x_dma_ops, 442 434 .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | 443 435 IDE_HFLAG_ABUSE_PREFETCH, 444 436 .pio_mask = ATA_PIO5, ··· 439 447 },{ /* 1 */ 440 448 .name = "CMD646", 441 449 .init_chipset = init_chipset_cmd64x, 442 - .init_hwif = init_hwif_cmd64x, 443 450 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 444 451 .chipset = ide_cmd646, 452 + .port_ops = &cmd64x_port_ops, 453 + .dma_ops = &cmd648_dma_ops, 445 454 .host_flags = IDE_HFLAG_ABUSE_PREFETCH, 446 455 .pio_mask = ATA_PIO5, 447 456 .mwdma_mask = ATA_MWDMA2, ··· 450 457 },{ /* 2 */ 451 458 .name = "CMD648", 452 459 .init_chipset = init_chipset_cmd64x, 453 - .init_hwif = init_hwif_cmd64x, 454 460 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 461 + .port_ops = &cmd64x_port_ops, 462 + .dma_ops = &cmd648_dma_ops, 455 463 .host_flags = IDE_HFLAG_ABUSE_PREFETCH, 456 464 .pio_mask = ATA_PIO5, 457 465 .mwdma_mask = ATA_MWDMA2, ··· 460 466 },{ /* 3 */ 461 467 .name = "CMD649", 462 468 .init_chipset = init_chipset_cmd64x, 463 - .init_hwif = init_hwif_cmd64x, 464 469 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 470 + .port_ops = &cmd64x_port_ops, 471 + .dma_ops = &cmd648_dma_ops, 465 472 .host_flags = IDE_HFLAG_ABUSE_PREFETCH, 466 473 .pio_mask = ATA_PIO5, 467 474 .mwdma_mask = ATA_MWDMA2, ··· 477 482 478 483 d = cmd64x_chipsets[idx]; 479 484 480 - /* 481 - * The original PCI0646 didn't have the primary channel enable bit, 482 - * it appeared starting with PCI0646U (i.e. revision ID 3). 483 - */ 484 - if (idx == 1 && dev->revision < 3) 485 - d.enablebits[0].reg = 0; 485 + if (idx == 1) { 486 + /* 487 + * UltraDMA only supported on PCI646U and PCI646U2, which 488 + * correspond to revisions 0x03, 0x05 and 0x07 respectively. 489 + * Actually, although the CMD tech support people won't 490 + * tell me the details, the 0x03 revision cannot support 491 + * UDMA correctly without hardware modifications, and even 492 + * then it only works with Quantum disks due to some 493 + * hold time assumptions in the 646U part which are fixed 494 + * in the 646U2. 495 + * 496 + * So we only do UltraDMA on revision 0x05 and 0x07 chipsets. 497 + */ 498 + if (dev->revision < 5) { 499 + d.udma_mask = 0x00; 500 + /* 501 + * The original PCI0646 didn't have the primary 502 + * channel enable bit, it appeared starting with 503 + * PCI0646U (i.e. revision ID 3). 504 + */ 505 + if (dev->revision < 3) { 506 + d.enablebits[0].reg = 0; 507 + if (dev->revision == 1) 508 + d.dma_ops = &cmd646_rev1_dma_ops; 509 + else 510 + d.dma_ops = &cmd64x_dma_ops; 511 + } 512 + } 513 + } 486 514 487 515 return ide_setup_pci_device(dev, &d); 488 516 }
+16 -10
drivers/ide/pci/cs5520.c
··· 103 103 ide_dma_host_set(drive, on); 104 104 } 105 105 106 - static void __devinit init_hwif_cs5520(ide_hwif_t *hwif) 107 - { 108 - hwif->set_pio_mode = &cs5520_set_pio_mode; 109 - hwif->set_dma_mode = &cs5520_set_dma_mode; 106 + static const struct ide_port_ops cs5520_port_ops = { 107 + .set_pio_mode = cs5520_set_pio_mode, 108 + .set_dma_mode = cs5520_set_dma_mode, 109 + }; 110 110 111 - if (hwif->dma_base == 0) 112 - return; 113 - 114 - hwif->dma_host_set = &cs5520_dma_host_set; 115 - } 111 + static const struct ide_dma_ops cs5520_dma_ops = { 112 + .dma_host_set = cs5520_dma_host_set, 113 + .dma_setup = ide_dma_setup, 114 + .dma_exec_cmd = ide_dma_exec_cmd, 115 + .dma_start = ide_dma_start, 116 + .dma_end = __ide_dma_end, 117 + .dma_test_irq = ide_dma_test_irq, 118 + .dma_lost_irq = ide_dma_lost_irq, 119 + .dma_timeout = ide_dma_timeout, 120 + }; 116 121 117 122 #define DECLARE_CS_DEV(name_str) \ 118 123 { \ 119 124 .name = name_str, \ 120 - .init_hwif = init_hwif_cs5520, \ 125 + .port_ops = &cs5520_port_ops, \ 126 + .dma_ops = &cs5520_dma_ops, \ 121 127 .host_flags = IDE_HFLAG_ISA_PORTS | \ 122 128 IDE_HFLAG_CS5520 | \ 123 129 IDE_HFLAG_VDMA | \
+7 -8
drivers/ide/pci/cs5530.c
··· 228 228 unsigned long basereg; 229 229 u32 d0_timings; 230 230 231 - hwif->set_pio_mode = &cs5530_set_pio_mode; 232 - hwif->set_dma_mode = &cs5530_set_dma_mode; 233 - 234 231 basereg = CS5530_BASEREG(hwif); 235 232 d0_timings = inl(basereg + 0); 236 233 if (CS5530_BAD_PIO(d0_timings)) 237 234 outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 0); 238 235 if (CS5530_BAD_PIO(inl(basereg + 8))) 239 236 outl(cs5530_pio_timings[(d0_timings >> 31) & 1][0], basereg + 8); 240 - 241 - if (hwif->dma_base == 0) 242 - return; 243 - 244 - hwif->udma_filter = cs5530_udma_filter; 245 237 } 238 + 239 + static const struct ide_port_ops cs5530_port_ops = { 240 + .set_pio_mode = cs5530_set_pio_mode, 241 + .set_dma_mode = cs5530_set_dma_mode, 242 + .udma_filter = cs5530_udma_filter, 243 + }; 246 244 247 245 static const struct ide_port_info cs5530_chipset __devinitdata = { 248 246 .name = "CS5530", 249 247 .init_chipset = init_chipset_cs5530, 250 248 .init_hwif = init_hwif_cs5530, 249 + .port_ops = &cs5530_port_ops, 251 250 .host_flags = IDE_HFLAG_SERIALIZE | 252 251 IDE_HFLAG_POST_SET_MODE, 253 252 .pio_mask = ATA_PIO4,
+6 -16
drivers/ide/pci/cs5535.c
··· 166 166 return (bit & 1) ? ATA_CBL_PATA80 : ATA_CBL_PATA40; 167 167 } 168 168 169 - /**** 170 - * init_hwif_cs5535 - Initialize one ide cannel 171 - * @hwif: Channel descriptor 172 - * 173 - * This gets invoked by the IDE driver once for each channel. It 174 - * performs channel-specific pre-initialization before drive probing. 175 - * 176 - */ 177 - static void __devinit init_hwif_cs5535(ide_hwif_t *hwif) 178 - { 179 - hwif->set_pio_mode = &cs5535_set_pio_mode; 180 - hwif->set_dma_mode = &cs5535_set_dma_mode; 181 - 182 - hwif->cable_detect = cs5535_cable_detect; 183 - } 169 + static const struct ide_port_ops cs5535_port_ops = { 170 + .set_pio_mode = cs5535_set_pio_mode, 171 + .set_dma_mode = cs5535_set_dma_mode, 172 + .cable_detect = cs5535_cable_detect, 173 + }; 184 174 185 175 static const struct ide_port_info cs5535_chipset __devinitdata = { 186 176 .name = "CS5535", 187 - .init_hwif = init_hwif_cs5535, 177 + .port_ops = &cs5535_port_ops, 188 178 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE | 189 179 IDE_HFLAG_ABUSE_SET_DMA_MODE, 190 180 .pio_mask = ATA_PIO4,
+6 -10
drivers/ide/pci/cy82c693.c
··· 382 382 return 0; 383 383 } 384 384 385 - /* 386 - * the init function - called for each ide channel once 387 - */ 388 - static void __devinit init_hwif_cy82c693(ide_hwif_t *hwif) 389 - { 390 - hwif->set_pio_mode = &cy82c693_set_pio_mode; 391 - hwif->set_dma_mode = &cy82c693_set_dma_mode; 392 - } 393 - 394 385 static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) 395 386 { 396 387 static ide_hwif_t *primary; ··· 395 404 } 396 405 } 397 406 407 + static const struct ide_port_ops cy82c693_port_ops = { 408 + .set_pio_mode = cy82c693_set_pio_mode, 409 + .set_dma_mode = cy82c693_set_dma_mode, 410 + }; 411 + 398 412 static const struct ide_port_info cy82c693_chipset __devinitdata = { 399 413 .name = "CY82C693", 400 414 .init_chipset = init_chipset_cy82c693, 401 415 .init_iops = init_iops_cy82c693, 402 - .init_hwif = init_hwif_cy82c693, 416 + .port_ops = &cy82c693_port_ops, 403 417 .chipset = ide_cy82c693, 404 418 .host_flags = IDE_HFLAG_SINGLE, 405 419 .pio_mask = ATA_PIO4,
+5 -2
drivers/ide/pci/delkin_cb.c
··· 43 43 0x00, 0x00, 0x00, 0x00, 0xa4, 0x83, 0x02, 0x13, 44 44 }; 45 45 46 + static const struct ide_port_ops delkin_cb_port_ops = { 47 + .quirkproc = ide_undecoded_slave, 48 + }; 49 + 46 50 static int __devinit 47 51 delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id) 48 52 { ··· 93 89 ide_init_port_data(hwif, i); 94 90 95 91 ide_init_port_hw(hwif, &hw); 96 - hwif->mmio = 1; 97 - hwif->quirkproc = &ide_undecoded_slave; 92 + hwif->port_ops = &delkin_cb_port_ops; 98 93 99 94 idx[0] = i; 100 95
+6 -9
drivers/ide/pci/hpt34x.c
··· 115 115 return dev->irq; 116 116 } 117 117 118 - static void __devinit init_hwif_hpt34x(ide_hwif_t *hwif) 119 - { 120 - hwif->set_pio_mode = &hpt34x_set_pio_mode; 121 - hwif->set_dma_mode = &hpt34x_set_mode; 122 - } 118 + static const struct ide_port_ops hpt34x_port_ops = { 119 + .set_pio_mode = hpt34x_set_pio_mode, 120 + .set_dma_mode = hpt34x_set_mode, 121 + }; 123 122 124 123 #define IDE_HFLAGS_HPT34X \ 125 124 (IDE_HFLAG_NO_ATAPI_DMA | \ ··· 130 131 { /* 0 */ 131 132 .name = "HPT343", 132 133 .init_chipset = init_chipset_hpt34x, 133 - .init_hwif = init_hwif_hpt34x, 134 - .extra = 16, 134 + .port_ops = &hpt34x_port_ops, 135 135 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE, 136 136 .pio_mask = ATA_PIO5, 137 137 }, 138 138 { /* 1 */ 139 139 .name = "HPT345", 140 140 .init_chipset = init_chipset_hpt34x, 141 - .init_hwif = init_hwif_hpt34x, 142 - .extra = 16, 141 + .port_ops = &hpt34x_port_ops, 143 142 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD, 144 143 .pio_mask = ATA_PIO5, 145 144 #ifdef CONFIG_HPT34X_AUTODMA
+85 -43
drivers/ide/pci/hpt366.c
··· 776 776 pci_read_config_byte(dev, 0x52, &mcr3); 777 777 pci_read_config_byte(dev, 0x5a, &scr1); 778 778 printk("%s: (%s) mcr1=0x%02x, mcr3=0x%02x, scr1=0x%02x\n", 779 - drive->name, __FUNCTION__, mcr1, mcr3, scr1); 779 + drive->name, __func__, mcr1, mcr3, scr1); 780 780 if (scr1 & 0x10) 781 781 pci_write_config_byte(dev, 0x5a, scr1 & ~0x10); 782 782 ide_dma_lost_irq(drive); ··· 808 808 hpt370_clear_engine(drive); 809 809 } 810 810 811 - static void hpt370_ide_dma_start(ide_drive_t *drive) 811 + static void hpt370_dma_start(ide_drive_t *drive) 812 812 { 813 813 #ifdef HPT_RESET_STATE_ENGINE 814 814 hpt370_clear_engine(drive); ··· 816 816 ide_dma_start(drive); 817 817 } 818 818 819 - static int hpt370_ide_dma_end(ide_drive_t *drive) 819 + static int hpt370_dma_end(ide_drive_t *drive) 820 820 { 821 821 ide_hwif_t *hwif = HWIF(drive); 822 822 u8 dma_stat = inb(hwif->dma_status); ··· 838 838 } 839 839 840 840 /* returns 1 if DMA IRQ issued, 0 otherwise */ 841 - static int hpt374_ide_dma_test_irq(ide_drive_t *drive) 841 + static int hpt374_dma_test_irq(ide_drive_t *drive) 842 842 { 843 843 ide_hwif_t *hwif = HWIF(drive); 844 844 struct pci_dev *dev = to_pci_dev(hwif->dev); ··· 858 858 859 859 if (!drive->waiting_for_dma) 860 860 printk(KERN_WARNING "%s: (%s) called while not waiting\n", 861 - drive->name, __FUNCTION__); 861 + drive->name, __func__); 862 862 return 0; 863 863 } 864 864 865 - static int hpt374_ide_dma_end(ide_drive_t *drive) 865 + static int hpt374_dma_end(ide_drive_t *drive) 866 866 { 867 867 ide_hwif_t *hwif = HWIF(drive); 868 868 struct pci_dev *dev = to_pci_dev(hwif->dev); ··· 1271 1271 /* Cache the channel's MISC. control registers' offset */ 1272 1272 hwif->select_data = hwif->channel ? 0x54 : 0x50; 1273 1273 1274 - hwif->set_pio_mode = &hpt3xx_set_pio_mode; 1275 - hwif->set_dma_mode = &hpt3xx_set_mode; 1276 - 1277 - hwif->quirkproc = &hpt3xx_quirkproc; 1278 - hwif->maskproc = &hpt3xx_maskproc; 1279 - 1280 - hwif->udma_filter = &hpt3xx_udma_filter; 1281 - hwif->mdma_filter = &hpt3xx_mdma_filter; 1282 - 1283 - hwif->cable_detect = hpt3xx_cable_detect; 1284 - 1285 1274 /* 1286 1275 * HPT3xxN chips have some complications: 1287 1276 * ··· 1312 1323 1313 1324 if (new_mcr != old_mcr) 1314 1325 pci_write_config_byte(dev, hwif->select_data + 1, new_mcr); 1315 - 1316 - if (hwif->dma_base == 0) 1317 - return; 1318 - 1319 - if (chip_type >= HPT374) { 1320 - hwif->ide_dma_test_irq = &hpt374_ide_dma_test_irq; 1321 - hwif->ide_dma_end = &hpt374_ide_dma_end; 1322 - } else if (chip_type >= HPT370) { 1323 - hwif->dma_start = &hpt370_ide_dma_start; 1324 - hwif->ide_dma_end = &hpt370_ide_dma_end; 1325 - hwif->dma_timeout = &hpt370_dma_timeout; 1326 - } else 1327 - hwif->dma_lost_irq = &hpt366_dma_lost_irq; 1328 1326 } 1329 1327 1330 - static void __devinit init_dma_hpt366(ide_hwif_t *hwif, unsigned long dmabase) 1328 + static int __devinit init_dma_hpt366(ide_hwif_t *hwif, 1329 + const struct ide_port_info *d) 1331 1330 { 1332 1331 struct pci_dev *dev = to_pci_dev(hwif->dev); 1333 - u8 masterdma = 0, slavedma = 0; 1334 - u8 dma_new = 0, dma_old = 0; 1335 - unsigned long flags; 1332 + unsigned long flags, base = ide_pci_dma_base(hwif, d); 1333 + u8 dma_old, dma_new, masterdma = 0, slavedma = 0; 1336 1334 1337 - dma_old = inb(dmabase + 2); 1335 + if (base == 0 || ide_pci_set_master(dev, d->name) < 0) 1336 + return -1; 1337 + 1338 + dma_old = inb(base + 2); 1338 1339 1339 1340 local_irq_save(flags); 1340 1341 ··· 1335 1356 if (masterdma & 0x30) dma_new |= 0x20; 1336 1357 if ( slavedma & 0x30) dma_new |= 0x40; 1337 1358 if (dma_new != dma_old) 1338 - outb(dma_new, dmabase + 2); 1359 + outb(dma_new, base + 2); 1339 1360 1340 1361 local_irq_restore(flags); 1341 1362 1342 - ide_setup_dma(hwif, dmabase); 1363 + printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", 1364 + hwif->name, base, base + 7); 1365 + 1366 + hwif->extra_base = base + (hwif->channel ? 8 : 16); 1367 + 1368 + if (ide_allocate_dma_engine(hwif)) 1369 + return -1; 1370 + 1371 + ide_setup_dma(hwif, base); 1372 + 1373 + return 0; 1343 1374 } 1344 1375 1345 1376 static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2) ··· 1405 1416 IDE_HFLAG_ABUSE_SET_DMA_MODE | \ 1406 1417 IDE_HFLAG_OFF_BOARD) 1407 1418 1419 + static const struct ide_port_ops hpt3xx_port_ops = { 1420 + .set_pio_mode = hpt3xx_set_pio_mode, 1421 + .set_dma_mode = hpt3xx_set_mode, 1422 + .quirkproc = hpt3xx_quirkproc, 1423 + .maskproc = hpt3xx_maskproc, 1424 + .mdma_filter = hpt3xx_mdma_filter, 1425 + .udma_filter = hpt3xx_udma_filter, 1426 + .cable_detect = hpt3xx_cable_detect, 1427 + }; 1428 + 1429 + static const struct ide_dma_ops hpt37x_dma_ops = { 1430 + .dma_host_set = ide_dma_host_set, 1431 + .dma_setup = ide_dma_setup, 1432 + .dma_exec_cmd = ide_dma_exec_cmd, 1433 + .dma_start = ide_dma_start, 1434 + .dma_end = hpt374_dma_end, 1435 + .dma_test_irq = hpt374_dma_test_irq, 1436 + .dma_lost_irq = ide_dma_lost_irq, 1437 + .dma_timeout = ide_dma_timeout, 1438 + }; 1439 + 1440 + static const struct ide_dma_ops hpt370_dma_ops = { 1441 + .dma_host_set = ide_dma_host_set, 1442 + .dma_setup = ide_dma_setup, 1443 + .dma_exec_cmd = ide_dma_exec_cmd, 1444 + .dma_start = hpt370_dma_start, 1445 + .dma_end = hpt370_dma_end, 1446 + .dma_test_irq = ide_dma_test_irq, 1447 + .dma_lost_irq = ide_dma_lost_irq, 1448 + .dma_timeout = hpt370_dma_timeout, 1449 + }; 1450 + 1451 + static const struct ide_dma_ops hpt36x_dma_ops = { 1452 + .dma_host_set = ide_dma_host_set, 1453 + .dma_setup = ide_dma_setup, 1454 + .dma_exec_cmd = ide_dma_exec_cmd, 1455 + .dma_start = ide_dma_start, 1456 + .dma_end = __ide_dma_end, 1457 + .dma_test_irq = ide_dma_test_irq, 1458 + .dma_lost_irq = hpt366_dma_lost_irq, 1459 + .dma_timeout = ide_dma_timeout, 1460 + }; 1461 + 1408 1462 static const struct ide_port_info hpt366_chipsets[] __devinitdata = { 1409 1463 { /* 0 */ 1410 1464 .name = "HPT36x", ··· 1461 1429 * Bit 4 is for the primary channel, bit 5 for the secondary. 1462 1430 */ 1463 1431 .enablebits = {{0x50,0x10,0x10}, {0x54,0x04,0x04}}, 1464 - .extra = 240, 1432 + .port_ops = &hpt3xx_port_ops, 1433 + .dma_ops = &hpt36x_dma_ops, 1465 1434 .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE, 1466 1435 .pio_mask = ATA_PIO4, 1467 1436 .mwdma_mask = ATA_MWDMA2, ··· 1472 1439 .init_hwif = init_hwif_hpt366, 1473 1440 .init_dma = init_dma_hpt366, 1474 1441 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, 1475 - .extra = 240, 1442 + .port_ops = &hpt3xx_port_ops, 1443 + .dma_ops = &hpt37x_dma_ops, 1476 1444 .host_flags = IDE_HFLAGS_HPT3XX, 1477 1445 .pio_mask = ATA_PIO4, 1478 1446 .mwdma_mask = ATA_MWDMA2, ··· 1483 1449 .init_hwif = init_hwif_hpt366, 1484 1450 .init_dma = init_dma_hpt366, 1485 1451 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, 1486 - .extra = 240, 1452 + .port_ops = &hpt3xx_port_ops, 1453 + .dma_ops = &hpt37x_dma_ops, 1487 1454 .host_flags = IDE_HFLAGS_HPT3XX, 1488 1455 .pio_mask = ATA_PIO4, 1489 1456 .mwdma_mask = ATA_MWDMA2, ··· 1494 1459 .init_hwif = init_hwif_hpt366, 1495 1460 .init_dma = init_dma_hpt366, 1496 1461 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, 1497 - .extra = 240, 1462 + .port_ops = &hpt3xx_port_ops, 1463 + .dma_ops = &hpt37x_dma_ops, 1498 1464 .host_flags = IDE_HFLAGS_HPT3XX, 1499 1465 .pio_mask = ATA_PIO4, 1500 1466 .mwdma_mask = ATA_MWDMA2, ··· 1506 1470 .init_dma = init_dma_hpt366, 1507 1471 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, 1508 1472 .udma_mask = ATA_UDMA5, 1509 - .extra = 240, 1473 + .port_ops = &hpt3xx_port_ops, 1474 + .dma_ops = &hpt37x_dma_ops, 1510 1475 .host_flags = IDE_HFLAGS_HPT3XX, 1511 1476 .pio_mask = ATA_PIO4, 1512 1477 .mwdma_mask = ATA_MWDMA2, ··· 1517 1480 .init_hwif = init_hwif_hpt366, 1518 1481 .init_dma = init_dma_hpt366, 1519 1482 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}}, 1520 - .extra = 240, 1483 + .port_ops = &hpt3xx_port_ops, 1484 + .dma_ops = &hpt37x_dma_ops, 1521 1485 .host_flags = IDE_HFLAGS_HPT3XX, 1522 1486 .pio_mask = ATA_PIO4, 1523 1487 .mwdma_mask = ATA_MWDMA2, ··· 1580 1542 1581 1543 d.name = info->chip_name; 1582 1544 d.udma_mask = info->udma_mask; 1545 + 1546 + /* fixup ->dma_ops for HPT370/HPT370A */ 1547 + if (info == &hpt370 || info == &hpt370a) 1548 + d.dma_ops = &hpt370_dma_ops; 1583 1549 1584 1550 pci_set_drvdata(dev, (void *)info); 1585 1551
+6 -16
drivers/ide/pci/it8213.c
··· 149 149 return (reg42h & 0x02) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 150 150 } 151 151 152 - /** 153 - * init_hwif_it8213 - set up hwif structs 154 - * @hwif: interface to set up 155 - * 156 - * We do the basic set up of the interface structure. 157 - */ 158 - 159 - static void __devinit init_hwif_it8213(ide_hwif_t *hwif) 160 - { 161 - hwif->set_dma_mode = &it8213_set_dma_mode; 162 - hwif->set_pio_mode = &it8213_set_pio_mode; 163 - 164 - hwif->cable_detect = it8213_cable_detect; 165 - } 166 - 152 + static const struct ide_port_ops it8213_port_ops = { 153 + .set_pio_mode = it8213_set_pio_mode, 154 + .set_dma_mode = it8213_set_dma_mode, 155 + .cable_detect = it8213_cable_detect, 156 + }; 167 157 168 158 #define DECLARE_ITE_DEV(name_str) \ 169 159 { \ 170 160 .name = name_str, \ 171 - .init_hwif = init_hwif_it8213, \ 172 161 .enablebits = { {0x41, 0x80, 0x80} }, \ 162 + .port_ops = &it8213_port_ops, \ 173 163 .host_flags = IDE_HFLAG_SINGLE, \ 174 164 .pio_mask = ATA_PIO4, \ 175 165 .swdma_mask = ATA_SWDMA2_ONLY, \
+16 -11
drivers/ide/pci/it821x.c
··· 418 418 } 419 419 420 420 /** 421 - * ata66_it821x - check for 80 pin cable 421 + * it821x_cable_detect - cable detection 422 422 * @hwif: interface to check 423 423 * 424 424 * Check for the presence of an ATA66 capable cable on the ··· 426 426 * the needed logic onboard. 427 427 */ 428 428 429 - static u8 __devinit ata66_it821x(ide_hwif_t *hwif) 429 + static u8 __devinit it821x_cable_detect(ide_hwif_t *hwif) 430 430 { 431 431 /* The reference driver also only does disk side */ 432 432 return ATA_CBL_PATA80; ··· 511 511 512 512 } 513 513 514 + static struct ide_dma_ops it821x_pass_through_dma_ops = { 515 + .dma_start = it821x_dma_start, 516 + .dma_end = it821x_dma_end, 517 + }; 518 + 514 519 /** 515 520 * init_hwif_it821x - set up hwif structs 516 521 * @hwif: interface to set up ··· 531 526 struct it821x_dev **itdevs = (struct it821x_dev **)pci_get_drvdata(dev); 532 527 struct it821x_dev *idev = itdevs[hwif->channel]; 533 528 u8 conf; 534 - 535 - hwif->quirkproc = &it821x_quirkproc; 536 529 537 530 ide_set_hwifdata(hwif, idev); 538 531 ··· 566 563 } 567 564 568 565 if (idev->smart == 0) { 569 - hwif->set_pio_mode = &it821x_set_pio_mode; 570 - hwif->set_dma_mode = &it821x_set_dma_mode; 571 - 572 566 /* MWDMA/PIO clock switching for pass through mode */ 573 - hwif->dma_start = &it821x_dma_start; 574 - hwif->ide_dma_end = &it821x_dma_end; 567 + hwif->dma_ops = &it821x_pass_through_dma_ops; 575 568 } else 576 569 hwif->host_flags |= IDE_HFLAG_NO_SET_MODE; 577 - 578 - hwif->cable_detect = ata66_it821x; 579 570 580 571 if (hwif->dma_base == 0) 581 572 return; ··· 610 613 return 0; 611 614 } 612 615 616 + static const struct ide_port_ops it821x_port_ops = { 617 + /* it821x_set_{pio,dma}_mode() are only used in pass-through mode */ 618 + .set_pio_mode = it821x_set_pio_mode, 619 + .set_dma_mode = it821x_set_dma_mode, 620 + .quirkproc = it821x_quirkproc, 621 + .cable_detect = it821x_cable_detect, 622 + }; 613 623 614 624 #define DECLARE_ITE_DEV(name_str) \ 615 625 { \ 616 626 .name = name_str, \ 617 627 .init_chipset = init_chipset_it821x, \ 618 628 .init_hwif = init_hwif_it821x, \ 629 + .port_ops = &it821x_port_ops, \ 619 630 .pio_mask = ATA_PIO4, \ 620 631 } 621 632
+8 -17
drivers/ide/pci/jmicron.c
··· 19 19 } port_type; 20 20 21 21 /** 22 - * ata66_jmicron - Cable check 22 + * jmicron_cable_detect - cable detection 23 23 * @hwif: IDE port 24 24 * 25 25 * Returns the cable type. 26 26 */ 27 27 28 - static u8 __devinit ata66_jmicron(ide_hwif_t *hwif) 28 + static u8 __devinit jmicron_cable_detect(ide_hwif_t *hwif) 29 29 { 30 30 struct pci_dev *pdev = to_pci_dev(hwif->dev); 31 31 ··· 95 95 { 96 96 } 97 97 98 - /** 99 - * init_hwif_jmicron - set up hwif structs 100 - * @hwif: interface to set up 101 - * 102 - * Minimal set up is required for the Jmicron hardware. 103 - */ 104 - 105 - static void __devinit init_hwif_jmicron(ide_hwif_t *hwif) 106 - { 107 - hwif->set_pio_mode = &jmicron_set_pio_mode; 108 - hwif->set_dma_mode = &jmicron_set_dma_mode; 109 - 110 - hwif->cable_detect = ata66_jmicron; 111 - } 98 + static const struct ide_port_ops jmicron_port_ops = { 99 + .set_pio_mode = jmicron_set_pio_mode, 100 + .set_dma_mode = jmicron_set_dma_mode, 101 + .cable_detect = jmicron_cable_detect, 102 + }; 112 103 113 104 static const struct ide_port_info jmicron_chipset __devinitdata = { 114 105 .name = "JMB", 115 - .init_hwif = init_hwif_jmicron, 116 106 .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } }, 107 + .port_ops = &jmicron_port_ops, 117 108 .pio_mask = ATA_PIO5, 118 109 .mwdma_mask = ATA_MWDMA2, 119 110 .udma_mask = ATA_UDMA6,
+19 -6
drivers/ide/pci/ns87415.c
··· 150 150 ns87415_prepare_drive (drive, drive->using_dma); 151 151 } 152 152 153 - static int ns87415_ide_dma_end (ide_drive_t *drive) 153 + static int ns87415_dma_end(ide_drive_t *drive) 154 154 { 155 155 ide_hwif_t *hwif = HWIF(drive); 156 156 u8 dma_stat = 0, dma_cmd = 0; ··· 170 170 return (dma_stat & 7) != 4; 171 171 } 172 172 173 - static int ns87415_ide_dma_setup(ide_drive_t *drive) 173 + static int ns87415_dma_setup(ide_drive_t *drive) 174 174 { 175 175 /* select DMA xfer */ 176 176 ns87415_prepare_drive(drive, 1); ··· 194 194 int timeout; 195 195 u8 stat; 196 196 #endif 197 - 198 - hwif->selectproc = &ns87415_selectproc; 199 197 200 198 /* 201 199 * We cannot probe for IRQ: both ports share common IRQ on INTA. ··· 252 254 return; 253 255 254 256 outb(0x60, hwif->dma_status); 255 - hwif->dma_setup = &ns87415_ide_dma_setup; 256 - hwif->ide_dma_end = &ns87415_ide_dma_end; 257 257 } 258 + 259 + static const struct ide_port_ops ns87415_port_ops = { 260 + .selectproc = ns87415_selectproc, 261 + }; 262 + 263 + static const struct ide_dma_ops ns87415_dma_ops = { 264 + .dma_host_set = ide_dma_host_set, 265 + .dma_setup = ns87415_dma_setup, 266 + .dma_exec_cmd = ide_dma_exec_cmd, 267 + .dma_start = ide_dma_start, 268 + .dma_end = ns87415_dma_end, 269 + .dma_test_irq = ide_dma_test_irq, 270 + .dma_lost_irq = ide_dma_lost_irq, 271 + .dma_timeout = ide_dma_timeout, 272 + }; 258 273 259 274 static const struct ide_port_info ns87415_chipset __devinitdata = { 260 275 .name = "NS87415", ··· 275 264 .init_iops = init_iops_ns87415, 276 265 #endif 277 266 .init_hwif = init_hwif_ns87415, 267 + .port_ops = &ns87415_port_ops, 268 + .dma_ops = &ns87415_dma_ops, 278 269 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | 279 270 IDE_HFLAG_NO_ATAPI_DMA, 280 271 };
+6 -10
drivers/ide/pci/opti621.c
··· 326 326 hwif->drives[1].drive_data = PIO_DONT_KNOW; 327 327 } 328 328 329 - /* 330 - * init_hwif_opti621() is called once for each hwif found at boot. 331 - */ 332 - static void __devinit init_hwif_opti621(ide_hwif_t *hwif) 333 - { 334 - hwif->port_init_devs = opti621_port_init_devs; 335 - hwif->set_pio_mode = &opti621_set_pio_mode; 336 - } 329 + static const struct ide_port_ops opti621_port_ops = { 330 + .port_init_devs = opti621_port_init_devs, 331 + .set_pio_mode = opti621_set_pio_mode, 332 + }; 337 333 338 334 static const struct ide_port_info opti621_chipsets[] __devinitdata = { 339 335 { /* 0 */ 340 336 .name = "OPTI621", 341 - .init_hwif = init_hwif_opti621, 342 337 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, 338 + .port_ops = &opti621_port_ops, 343 339 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, 344 340 .pio_mask = ATA_PIO3, 345 341 .swdma_mask = ATA_SWDMA2, 346 342 .mwdma_mask = ATA_MWDMA2, 347 343 }, { /* 1 */ 348 344 .name = "OPTI621X", 349 - .init_hwif = init_hwif_opti621, 350 345 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, 346 + .port_ops = &opti621_port_ops, 351 347 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, 352 348 .pio_mask = ATA_PIO3, 353 349 .swdma_mask = ATA_SWDMA2,
+10 -13
drivers/ide/pci/pdc202xx_new.c
··· 34 34 #undef DEBUG 35 35 36 36 #ifdef DEBUG 37 - #define DBG(fmt, args...) printk("%s: " fmt, __FUNCTION__, ## args) 37 + #define DBG(fmt, args...) printk("%s: " fmt, __func__, ## args) 38 38 #else 39 39 #define DBG(fmt, args...) 40 40 #endif ··· 442 442 return dev->irq; 443 443 } 444 444 445 - static void __devinit init_hwif_pdc202new(ide_hwif_t *hwif) 446 - { 447 - hwif->set_pio_mode = &pdcnew_set_pio_mode; 448 - hwif->set_dma_mode = &pdcnew_set_dma_mode; 449 - 450 - hwif->quirkproc = &pdcnew_quirkproc; 451 - hwif->resetproc = &pdcnew_reset; 452 - 453 - hwif->cable_detect = pdcnew_cable_detect; 454 - } 455 - 456 445 static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev) 457 446 { 458 447 struct pci_dev *dev2; ··· 465 476 return NULL; 466 477 } 467 478 479 + static const struct ide_port_ops pdcnew_port_ops = { 480 + .set_pio_mode = pdcnew_set_pio_mode, 481 + .set_dma_mode = pdcnew_set_dma_mode, 482 + .quirkproc = pdcnew_quirkproc, 483 + .resetproc = pdcnew_reset, 484 + .cable_detect = pdcnew_cable_detect, 485 + }; 486 + 468 487 #define DECLARE_PDCNEW_DEV(name_str, udma) \ 469 488 { \ 470 489 .name = name_str, \ 471 490 .init_chipset = init_chipset_pdcnew, \ 472 - .init_hwif = init_hwif_pdc202new, \ 491 + .port_ops = &pdcnew_port_ops, \ 473 492 .host_flags = IDE_HFLAG_POST_SET_MODE | \ 474 493 IDE_HFLAG_ERROR_STOPS_FIFO | \ 475 494 IDE_HFLAG_OFF_BOARD, \
+64 -72
drivers/ide/pci/pdc202xx_old.c
··· 115 115 pdc202xx_set_mode(drive, XFER_PIO_0 + pio); 116 116 } 117 117 118 - static u8 __devinit pdc2026x_old_cable_detect(ide_hwif_t *hwif) 118 + static u8 __devinit pdc2026x_cable_detect(ide_hwif_t *hwif) 119 119 { 120 120 struct pci_dev *dev = to_pci_dev(hwif->dev); 121 121 u16 CIS, mask = hwif->channel ? (1 << 11) : (1 << 10); ··· 163 163 drive->quirk_list = 0; 164 164 } 165 165 166 - static void pdc202xx_old_ide_dma_start(ide_drive_t *drive) 166 + static void pdc202xx_dma_start(ide_drive_t *drive) 167 167 { 168 168 if (drive->current_speed > XFER_UDMA_2) 169 169 pdc_old_enable_66MHz_clock(drive->hwif); ··· 185 185 ide_dma_start(drive); 186 186 } 187 187 188 - static int pdc202xx_old_ide_dma_end(ide_drive_t *drive) 188 + static int pdc202xx_dma_end(ide_drive_t *drive) 189 189 { 190 190 if (drive->media != ide_disk || drive->addressing == 1) { 191 191 ide_hwif_t *hwif = HWIF(drive); ··· 202 202 return __ide_dma_end(drive); 203 203 } 204 204 205 - static int pdc202xx_old_ide_dma_test_irq(ide_drive_t *drive) 205 + static int pdc202xx_dma_test_irq(ide_drive_t *drive) 206 206 { 207 207 ide_hwif_t *hwif = HWIF(drive); 208 208 unsigned long high_16 = hwif->extra_base - 16; ··· 224 224 } 225 225 somebody_else: 226 226 return (dma_stat & 4) == 4; /* return 1 if INTR asserted */ 227 - } 228 - 229 - static void pdc202xx_dma_lost_irq(ide_drive_t *drive) 230 - { 231 - ide_hwif_t *hwif = HWIF(drive); 232 - 233 - if (hwif->resetproc != NULL) 234 - hwif->resetproc(drive); 235 - 236 - ide_dma_lost_irq(drive); 237 - } 238 - 239 - static void pdc202xx_dma_timeout(ide_drive_t *drive) 240 - { 241 - ide_hwif_t *hwif = HWIF(drive); 242 - 243 - if (hwif->resetproc != NULL) 244 - hwif->resetproc(drive); 245 - 246 - ide_dma_timeout(drive); 247 227 } 248 228 249 229 static void pdc202xx_reset_host (ide_hwif_t *hwif) ··· 251 271 ide_set_max_pio(drive); 252 272 } 253 273 274 + static void pdc202xx_dma_lost_irq(ide_drive_t *drive) 275 + { 276 + pdc202xx_reset(drive); 277 + ide_dma_lost_irq(drive); 278 + } 279 + 280 + static void pdc202xx_dma_timeout(ide_drive_t *drive) 281 + { 282 + pdc202xx_reset(drive); 283 + ide_dma_timeout(drive); 284 + } 285 + 254 286 static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, 255 - const char *name) 287 + const char *name) 256 288 { 257 - return dev->irq; 258 - } 259 - 260 - static void __devinit init_hwif_pdc202xx(ide_hwif_t *hwif) 261 - { 262 - struct pci_dev *dev = to_pci_dev(hwif->dev); 263 - 264 - hwif->set_pio_mode = &pdc202xx_set_pio_mode; 265 - hwif->set_dma_mode = &pdc202xx_set_mode; 266 - 267 - hwif->quirkproc = &pdc202xx_quirkproc; 268 - 269 - if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { 270 - hwif->resetproc = &pdc202xx_reset; 271 - 272 - hwif->cable_detect = pdc2026x_old_cable_detect; 273 - } 274 - 275 - if (hwif->dma_base == 0) 276 - return; 277 - 278 - hwif->dma_lost_irq = &pdc202xx_dma_lost_irq; 279 - hwif->dma_timeout = &pdc202xx_dma_timeout; 280 - 281 - if (dev->device != PCI_DEVICE_ID_PROMISE_20246) { 282 - hwif->dma_start = &pdc202xx_old_ide_dma_start; 283 - hwif->ide_dma_end = &pdc202xx_old_ide_dma_end; 284 - } 285 - hwif->ide_dma_test_irq = &pdc202xx_old_ide_dma_test_irq; 286 - } 287 - 288 - static void __devinit init_dma_pdc202xx(ide_hwif_t *hwif, unsigned long dmabase) 289 - { 289 + unsigned long dmabase = pci_resource_start(dev, 4); 290 290 u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; 291 291 292 - if (hwif->channel) { 293 - ide_setup_dma(hwif, dmabase); 294 - return; 295 - } 292 + if (dmabase == 0) 293 + goto out; 296 294 297 295 udma_speed_flag = inb(dmabase | 0x1f); 298 296 primary_mode = inb(dmabase | 0x1a); 299 297 secondary_mode = inb(dmabase | 0x1b); 300 298 printk(KERN_INFO "%s: (U)DMA Burst Bit %sABLED " \ 301 299 "Primary %s Mode " \ 302 - "Secondary %s Mode.\n", hwif->cds->name, 300 + "Secondary %s Mode.\n", pci_name(dev), 303 301 (udma_speed_flag & 1) ? "EN" : "DIS", 304 302 (primary_mode & 1) ? "MASTER" : "PCI", 305 303 (secondary_mode & 1) ? "MASTER" : "PCI" ); 306 304 307 305 if (!(udma_speed_flag & 1)) { 308 306 printk(KERN_INFO "%s: FORCING BURST BIT 0x%02x->0x%02x ", 309 - hwif->cds->name, udma_speed_flag, 307 + pci_name(dev), udma_speed_flag, 310 308 (udma_speed_flag|1)); 311 309 outb(udma_speed_flag | 1, dmabase | 0x1f); 312 310 printk("%sACTIVE\n", (inb(dmabase | 0x1f) & 1) ? "" : "IN"); 313 311 } 314 - 315 - ide_setup_dma(hwif, dmabase); 312 + out: 313 + return dev->irq; 316 314 } 317 315 318 316 static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev, ··· 315 357 IDE_HFLAG_ABUSE_SET_DMA_MODE | \ 316 358 IDE_HFLAG_OFF_BOARD) 317 359 360 + static const struct ide_port_ops pdc20246_port_ops = { 361 + .set_pio_mode = pdc202xx_set_pio_mode, 362 + .set_dma_mode = pdc202xx_set_mode, 363 + .quirkproc = pdc202xx_quirkproc, 364 + }; 365 + 366 + static const struct ide_port_ops pdc2026x_port_ops = { 367 + .set_pio_mode = pdc202xx_set_pio_mode, 368 + .set_dma_mode = pdc202xx_set_mode, 369 + .quirkproc = pdc202xx_quirkproc, 370 + .resetproc = pdc202xx_reset, 371 + .cable_detect = pdc2026x_cable_detect, 372 + }; 373 + 374 + static const struct ide_dma_ops pdc20246_dma_ops = { 375 + .dma_host_set = ide_dma_host_set, 376 + .dma_setup = ide_dma_setup, 377 + .dma_exec_cmd = ide_dma_exec_cmd, 378 + .dma_start = ide_dma_start, 379 + .dma_end = __ide_dma_end, 380 + .dma_test_irq = pdc202xx_dma_test_irq, 381 + .dma_lost_irq = pdc202xx_dma_lost_irq, 382 + .dma_timeout = pdc202xx_dma_timeout, 383 + }; 384 + 385 + static const struct ide_dma_ops pdc2026x_dma_ops = { 386 + .dma_host_set = ide_dma_host_set, 387 + .dma_setup = ide_dma_setup, 388 + .dma_exec_cmd = ide_dma_exec_cmd, 389 + .dma_start = pdc202xx_dma_start, 390 + .dma_end = pdc202xx_dma_end, 391 + .dma_test_irq = pdc202xx_dma_test_irq, 392 + .dma_lost_irq = pdc202xx_dma_lost_irq, 393 + .dma_timeout = pdc202xx_dma_timeout, 394 + }; 395 + 318 396 #define DECLARE_PDC2026X_DEV(name_str, udma, extra_flags) \ 319 397 { \ 320 398 .name = name_str, \ 321 399 .init_chipset = init_chipset_pdc202xx, \ 322 - .init_hwif = init_hwif_pdc202xx, \ 323 - .init_dma = init_dma_pdc202xx, \ 324 - .extra = 48, \ 400 + .port_ops = &pdc2026x_port_ops, \ 401 + .dma_ops = &pdc2026x_dma_ops, \ 325 402 .host_flags = IDE_HFLAGS_PDC202XX | extra_flags, \ 326 403 .pio_mask = ATA_PIO4, \ 327 404 .mwdma_mask = ATA_MWDMA2, \ ··· 367 374 { /* 0 */ 368 375 .name = "PDC20246", 369 376 .init_chipset = init_chipset_pdc202xx, 370 - .init_hwif = init_hwif_pdc202xx, 371 - .init_dma = init_dma_pdc202xx, 372 - .extra = 16, 377 + .port_ops = &pdc20246_port_ops, 378 + .dma_ops = &pdc20246_dma_ops, 373 379 .host_flags = IDE_HFLAGS_PDC202XX, 374 380 .pio_mask = ATA_PIO4, 375 381 .mwdma_mask = ATA_MWDMA2,
+8 -5
drivers/ide/pci/piix.c
··· 285 285 286 286 static void __devinit init_hwif_piix(ide_hwif_t *hwif) 287 287 { 288 - hwif->set_pio_mode = &piix_set_pio_mode; 289 - hwif->set_dma_mode = &piix_set_dma_mode; 290 - 291 - hwif->cable_detect = piix_cable_detect; 292 - 293 288 if (!hwif->dma_base) 294 289 return; 295 290 ··· 301 306 hwif->ide_dma_clear_irq = &piix_dma_clear_irq; 302 307 } 303 308 309 + static const struct ide_port_ops piix_port_ops = { 310 + .set_pio_mode = piix_set_pio_mode, 311 + .set_dma_mode = piix_set_dma_mode, 312 + .cable_detect = piix_cable_detect, 313 + }; 314 + 304 315 #ifndef CONFIG_IA64 305 316 #define IDE_HFLAGS_PIIX IDE_HFLAG_LEGACY_IRQS 306 317 #else ··· 318 317 .name = name_str, \ 319 318 .init_hwif = init_hwif_piix, \ 320 319 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ 320 + .port_ops = &piix_port_ops, \ 321 321 .host_flags = IDE_HFLAGS_PIIX, \ 322 322 .pio_mask = ATA_PIO4, \ 323 323 .swdma_mask = ATA_SWDMA2_ONLY, \ ··· 332 330 .init_chipset = init_chipset_ich, \ 333 331 .init_hwif = init_hwif_ich, \ 334 332 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ 333 + .port_ops = &piix_port_ops, \ 335 334 .host_flags = IDE_HFLAGS_PIIX, \ 336 335 .pio_mask = ATA_PIO4, \ 337 336 .swdma_mask = ATA_SWDMA2_ONLY, \
+19 -17
drivers/ide/pci/sc1200.c
··· 165 165 * 166 166 * returns 1 on error, 0 otherwise 167 167 */ 168 - static int sc1200_ide_dma_end (ide_drive_t *drive) 168 + static int sc1200_dma_end(ide_drive_t *drive) 169 169 { 170 170 ide_hwif_t *hwif = HWIF(drive); 171 171 unsigned long dma_base = hwif->dma_base; ··· 214 214 printk("SC1200: %s: changing (U)DMA mode\n", drive->name); 215 215 ide_dma_off_quietly(drive); 216 216 if (ide_set_dma_mode(drive, mode) == 0 && drive->using_dma) 217 - hwif->dma_host_set(drive, 1); 217 + hwif->dma_ops->dma_host_set(drive, 1); 218 218 return; 219 219 } 220 220 ··· 286 286 } 287 287 #endif 288 288 289 - /* 290 - * This gets invoked by the IDE driver once for each channel, 291 - * and performs channel-specific pre-initialization before drive probing. 292 - */ 293 - static void __devinit init_hwif_sc1200 (ide_hwif_t *hwif) 294 - { 295 - hwif->set_pio_mode = &sc1200_set_pio_mode; 296 - hwif->set_dma_mode = &sc1200_set_dma_mode; 289 + static const struct ide_port_ops sc1200_port_ops = { 290 + .set_pio_mode = sc1200_set_pio_mode, 291 + .set_dma_mode = sc1200_set_dma_mode, 292 + .udma_filter = sc1200_udma_filter, 293 + }; 297 294 298 - if (hwif->dma_base == 0) 299 - return; 300 - 301 - hwif->udma_filter = sc1200_udma_filter; 302 - hwif->ide_dma_end = &sc1200_ide_dma_end; 303 - } 295 + static const struct ide_dma_ops sc1200_dma_ops = { 296 + .dma_host_set = ide_dma_host_set, 297 + .dma_setup = ide_dma_setup, 298 + .dma_exec_cmd = ide_dma_exec_cmd, 299 + .dma_start = ide_dma_start, 300 + .dma_end = sc1200_dma_end, 301 + .dma_test_irq = ide_dma_test_irq, 302 + .dma_lost_irq = ide_dma_lost_irq, 303 + .dma_timeout = ide_dma_timeout, 304 + }; 304 305 305 306 static const struct ide_port_info sc1200_chipset __devinitdata = { 306 307 .name = "SC1200", 307 - .init_hwif = init_hwif_sc1200, 308 + .port_ops = &sc1200_port_ops, 309 + .dma_ops = &sc1200_dma_ops, 308 310 .host_flags = IDE_HFLAG_SERIALIZE | 309 311 IDE_HFLAG_POST_SET_MODE | 310 312 IDE_HFLAG_ABUSE_DMA_MODES,
+32 -35
drivers/ide/pci/scc_pata.c
··· 317 317 318 318 319 319 /** 320 - * scc_ide_dma_end - Stop DMA 320 + * scc_dma_end - Stop DMA 321 321 * @drive: IDE drive 322 322 * 323 323 * Check and clear INT Status register. 324 324 * Then call __ide_dma_end(). 325 325 */ 326 326 327 - static int scc_ide_dma_end(ide_drive_t * drive) 327 + static int scc_dma_end(ide_drive_t *drive) 328 328 { 329 329 ide_hwif_t *hwif = HWIF(drive); 330 330 unsigned long intsts_port = hwif->dma_base + 0x014; ··· 449 449 450 450 if (!drive->waiting_for_dma) 451 451 printk(KERN_WARNING "%s: (%s) called while not waiting\n", 452 - drive->name, __FUNCTION__); 452 + drive->name, __func__); 453 453 return 0; 454 454 } 455 455 ··· 483 483 unsigned long dma_size = pci_resource_len(dev, 1); 484 484 void __iomem *ctl_addr; 485 485 void __iomem *dma_addr; 486 - int i; 486 + int i, ret; 487 487 488 488 for (i = 0; i < MAX_HWIFS; i++) { 489 489 if (scc_ports[i].ctl == 0) ··· 492 492 if (i >= MAX_HWIFS) 493 493 return -ENOMEM; 494 494 495 - if (!request_mem_region(ctl_base, ctl_size, name)) { 496 - printk(KERN_WARNING "%s: IDE controller MMIO ports not available.\n", SCC_PATA_NAME); 497 - goto fail_0; 498 - } 499 - 500 - if (!request_mem_region(dma_base, dma_size, name)) { 501 - printk(KERN_WARNING "%s: IDE controller MMIO ports not available.\n", SCC_PATA_NAME); 502 - goto fail_1; 495 + ret = pci_request_selected_regions(dev, (1 << 2) - 1, name); 496 + if (ret < 0) { 497 + printk(KERN_ERR "%s: can't reserve resources\n", name); 498 + return ret; 503 499 } 504 500 505 501 if ((ctl_addr = ioremap(ctl_base, ctl_size)) == NULL) 506 - goto fail_2; 502 + goto fail_0; 507 503 508 504 if ((dma_addr = ioremap(dma_base, dma_size)) == NULL) 509 - goto fail_3; 505 + goto fail_1; 510 506 511 507 pci_set_master(dev); 512 508 scc_ports[i].ctl = (unsigned long)ctl_addr; ··· 511 515 512 516 return 1; 513 517 514 - fail_3: 515 - iounmap(ctl_addr); 516 - fail_2: 517 - release_mem_region(dma_base, dma_size); 518 518 fail_1: 519 - release_mem_region(ctl_base, ctl_size); 519 + iounmap(ctl_addr); 520 520 fail_0: 521 521 return -ENOMEM; 522 522 } ··· 541 549 hw.chipset = ide_pci; 542 550 ide_init_port_hw(hwif, &hw); 543 551 hwif->dev = &dev->dev; 544 - hwif->cds = d; 545 552 546 553 idx[0] = hwif->index; 547 554 ··· 692 701 /* PTERADD */ 693 702 out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); 694 703 695 - hwif->dma_setup = scc_dma_setup; 696 - hwif->ide_dma_end = scc_ide_dma_end; 697 - hwif->set_pio_mode = scc_set_pio_mode; 698 - hwif->set_dma_mode = scc_set_dma_mode; 699 - hwif->ide_dma_test_irq = scc_dma_test_irq; 700 - hwif->udma_filter = scc_udma_filter; 701 - 702 704 if (in_be32((void __iomem *)(hwif->config_data + 0xff0)) & CCKCTRL_ATACLKOEN) 703 705 hwif->ultra_mask = ATA_UDMA6; /* 133MHz */ 704 706 else 705 707 hwif->ultra_mask = ATA_UDMA5; /* 100MHz */ 706 - 707 - hwif->cable_detect = scc_cable_detect; 708 708 } 709 + 710 + static const struct ide_port_ops scc_port_ops = { 711 + .set_pio_mode = scc_set_pio_mode, 712 + .set_dma_mode = scc_set_dma_mode, 713 + .udma_filter = scc_udma_filter, 714 + .cable_detect = scc_cable_detect, 715 + }; 716 + 717 + static const struct ide_dma_ops scc_dma_ops = { 718 + .dma_host_set = ide_dma_host_set, 719 + .dma_setup = scc_dma_setup, 720 + .dma_exec_cmd = ide_dma_exec_cmd, 721 + .dma_start = ide_dma_start, 722 + .dma_end = scc_dma_end, 723 + .dma_test_irq = scc_dma_test_irq, 724 + .dma_lost_irq = ide_dma_lost_irq, 725 + .dma_timeout = ide_dma_timeout, 726 + }; 709 727 710 728 #define DECLARE_SCC_DEV(name_str) \ 711 729 { \ 712 730 .name = name_str, \ 713 731 .init_iops = init_iops_scc, \ 714 732 .init_hwif = init_hwif_scc, \ 733 + .port_ops = &scc_port_ops, \ 734 + .dma_ops = &scc_dma_ops, \ 715 735 .host_flags = IDE_HFLAG_SINGLE, \ 716 736 .pio_mask = ATA_PIO4, \ 717 737 } ··· 756 754 { 757 755 struct scc_ports *ports = pci_get_drvdata(dev); 758 756 ide_hwif_t *hwif = ports->hwif; 759 - unsigned long ctl_base = pci_resource_start(dev, 0); 760 - unsigned long dma_base = pci_resource_start(dev, 1); 761 - unsigned long ctl_size = pci_resource_len(dev, 0); 762 - unsigned long dma_size = pci_resource_len(dev, 1); 763 757 764 758 if (hwif->dmatable_cpu) { 765 759 pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, ··· 768 770 hwif->chipset = ide_unknown; 769 771 iounmap((void*)ports->dma); 770 772 iounmap((void*)ports->ctl); 771 - release_mem_region(dma_base, dma_size); 772 - release_mem_region(ctl_base, ctl_size); 773 + pci_release_selected_regions(dev, (1 << 2) - 1); 773 774 memset(ports, 0, sizeof(*ports)); 774 775 } 775 776
+17 -16
drivers/ide/pci/serverworks.c
··· 312 312 return ATA_CBL_PATA40; 313 313 } 314 314 315 - static u8 __devinit ata66_svwks(ide_hwif_t *hwif) 315 + static u8 __devinit svwks_cable_detect(ide_hwif_t *hwif) 316 316 { 317 317 struct pci_dev *dev = to_pci_dev(hwif->dev); 318 318 ··· 336 336 return ATA_CBL_PATA40; 337 337 } 338 338 339 - static void __devinit init_hwif_svwks (ide_hwif_t *hwif) 340 - { 341 - struct pci_dev *dev = to_pci_dev(hwif->dev); 339 + static const struct ide_port_ops osb4_port_ops = { 340 + .set_pio_mode = svwks_set_pio_mode, 341 + .set_dma_mode = svwks_set_dma_mode, 342 + .udma_filter = svwks_udma_filter, 343 + }; 342 344 343 - hwif->set_pio_mode = &svwks_set_pio_mode; 344 - hwif->set_dma_mode = &svwks_set_dma_mode; 345 - hwif->udma_filter = &svwks_udma_filter; 346 - 347 - if (dev->device != PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) 348 - hwif->cable_detect = ata66_svwks; 349 - } 345 + static const struct ide_port_ops svwks_port_ops = { 346 + .set_pio_mode = svwks_set_pio_mode, 347 + .set_dma_mode = svwks_set_dma_mode, 348 + .udma_filter = svwks_udma_filter, 349 + .cable_detect = svwks_cable_detect, 350 + }; 350 351 351 352 #define IDE_HFLAGS_SVWKS \ 352 353 (IDE_HFLAG_LEGACY_IRQS | \ ··· 357 356 { /* 0 */ 358 357 .name = "SvrWks OSB4", 359 358 .init_chipset = init_chipset_svwks, 360 - .init_hwif = init_hwif_svwks, 359 + .port_ops = &osb4_port_ops, 361 360 .host_flags = IDE_HFLAGS_SVWKS, 362 361 .pio_mask = ATA_PIO4, 363 362 .mwdma_mask = ATA_MWDMA2, ··· 365 364 },{ /* 1 */ 366 365 .name = "SvrWks CSB5", 367 366 .init_chipset = init_chipset_svwks, 368 - .init_hwif = init_hwif_svwks, 367 + .port_ops = &svwks_port_ops, 369 368 .host_flags = IDE_HFLAGS_SVWKS, 370 369 .pio_mask = ATA_PIO4, 371 370 .mwdma_mask = ATA_MWDMA2, ··· 373 372 },{ /* 2 */ 374 373 .name = "SvrWks CSB6", 375 374 .init_chipset = init_chipset_svwks, 376 - .init_hwif = init_hwif_svwks, 375 + .port_ops = &svwks_port_ops, 377 376 .host_flags = IDE_HFLAGS_SVWKS, 378 377 .pio_mask = ATA_PIO4, 379 378 .mwdma_mask = ATA_MWDMA2, ··· 381 380 },{ /* 3 */ 382 381 .name = "SvrWks CSB6", 383 382 .init_chipset = init_chipset_svwks, 384 - .init_hwif = init_hwif_svwks, 383 + .port_ops = &svwks_port_ops, 385 384 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, 386 385 .pio_mask = ATA_PIO4, 387 386 .mwdma_mask = ATA_MWDMA2, ··· 389 388 },{ /* 4 */ 390 389 .name = "SvrWks HT1000", 391 390 .init_chipset = init_chipset_svwks, 392 - .init_hwif = init_hwif_svwks, 391 + .port_ops = &svwks_port_ops, 393 392 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, 394 393 .pio_mask = ATA_PIO4, 395 394 .mwdma_mask = ATA_MWDMA2,
+45 -58
drivers/ide/pci/sgiioc4.c
··· 170 170 printk(KERN_ERR 171 171 "%s(%s) : PCI Bus Error when doing DMA:" 172 172 " status-cmd reg is 0x%x\n", 173 - __FUNCTION__, drive->name, pci_stat_cmd_reg); 173 + __func__, drive->name, pci_stat_cmd_reg); 174 174 printk(KERN_ERR 175 175 "%s(%s) : PCI Error Address is 0x%x%x\n", 176 - __FUNCTION__, drive->name, 176 + __func__, drive->name, 177 177 pci_err_addr_high, pci_err_addr_low); 178 178 /* Clear the PCI Error indicator */ 179 179 pci_write_config_dword(dev, PCI_COMMAND, 0x00000146); ··· 188 188 return intr_reg & 3; 189 189 } 190 190 191 - static void sgiioc4_ide_dma_start(ide_drive_t * drive) 191 + static void sgiioc4_dma_start(ide_drive_t *drive) 192 192 { 193 193 ide_hwif_t *hwif = HWIF(drive); 194 194 unsigned long ioc4_dma_addr = hwif->dma_base + IOC4_DMA_CTRL * 4; ··· 215 215 } 216 216 217 217 /* Stops the IOC4 DMA Engine */ 218 - static int 219 - sgiioc4_ide_dma_end(ide_drive_t * drive) 218 + static int sgiioc4_dma_end(ide_drive_t *drive) 220 219 { 221 220 u32 ioc4_dma, bc_dev, bc_mem, num, valid = 0, cnt = 0; 222 221 ide_hwif_t *hwif = HWIF(drive); ··· 231 232 printk(KERN_ERR 232 233 "%s(%s): IOC4 DMA STOP bit is still 1 :" 233 234 "ioc4_dma_reg 0x%x\n", 234 - __FUNCTION__, drive->name, ioc4_dma); 235 + __func__, drive->name, ioc4_dma); 235 236 dma_stat = 1; 236 237 } 237 238 ··· 250 251 udelay(1); 251 252 } 252 253 if (!valid) { 253 - printk(KERN_ERR "%s(%s) : DMA incomplete\n", __FUNCTION__, 254 + printk(KERN_ERR "%s(%s) : DMA incomplete\n", __func__, 254 255 drive->name); 255 256 dma_stat = 1; 256 257 } ··· 263 264 printk(KERN_ERR 264 265 "%s(%s): WARNING!! byte_count_dev %d " 265 266 "!= byte_count_mem %d\n", 266 - __FUNCTION__, drive->name, bc_dev, bc_mem); 267 + __func__, drive->name, bc_dev, bc_mem); 267 268 } 268 269 } 269 270 ··· 278 279 } 279 280 280 281 /* returns 1 if dma irq issued, 0 otherwise */ 281 - static int 282 - sgiioc4_ide_dma_test_irq(ide_drive_t * drive) 282 + static int sgiioc4_dma_test_irq(ide_drive_t *drive) 283 283 { 284 284 return sgiioc4_checkirq(HWIF(drive)); 285 285 } ··· 292 294 static void 293 295 sgiioc4_resetproc(ide_drive_t * drive) 294 296 { 295 - sgiioc4_ide_dma_end(drive); 297 + sgiioc4_dma_end(drive); 296 298 sgiioc4_clearirq(drive); 297 299 } 298 300 ··· 327 329 328 330 /* Creates a dma map for the scatter-gather list entries */ 329 331 static int __devinit 330 - ide_dma_sgiioc4(ide_hwif_t * hwif, unsigned long dma_base) 332 + ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d) 331 333 { 332 334 struct pci_dev *dev = to_pci_dev(hwif->dev); 335 + unsigned long dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET; 333 336 void __iomem *virt_dma_base; 334 337 int num_ports = sizeof (ioc4_dma_regs_t); 335 338 void *pad; 339 + 340 + if (dma_base == 0) 341 + return -1; 336 342 337 343 printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name, 338 344 dma_base, dma_base + num_ports - 1); ··· 345 343 printk(KERN_ERR 346 344 "%s(%s) -- ERROR, Addresses 0x%p to 0x%p " 347 345 "ALREADY in use\n", 348 - __FUNCTION__, hwif->name, (void *) dma_base, 346 + __func__, hwif->name, (void *) dma_base, 349 347 (void *) dma_base + num_ports - 1); 350 348 return -1; 351 349 } ··· 354 352 if (virt_dma_base == NULL) { 355 353 printk(KERN_ERR 356 354 "%s(%s) -- ERROR, Unable to map addresses 0x%lx to 0x%lx\n", 357 - __FUNCTION__, hwif->name, dma_base, dma_base + num_ports - 1); 355 + __func__, hwif->name, dma_base, dma_base + num_ports - 1); 358 356 goto dma_remap_failure; 359 357 } 360 358 hwif->dma_base = (unsigned long) virt_dma_base; ··· 380 378 hwif->dmatable_cpu, hwif->dmatable_dma); 381 379 printk(KERN_INFO 382 380 "%s() -- Error! Unable to allocate DMA Maps for drive %s\n", 383 - __FUNCTION__, hwif->name); 381 + __func__, hwif->name); 384 382 printk(KERN_INFO 385 383 "Changing from DMA to PIO mode for Drive %s\n", hwif->name); 386 384 ··· 408 406 if (ioc4_dma & IOC4_S_DMA_ACTIVE) { 409 407 printk(KERN_WARNING 410 408 "%s(%s):Warning!! DMA from previous transfer was still active\n", 411 - __FUNCTION__, drive->name); 409 + __func__, drive->name); 412 410 writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr); 413 411 ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base); 414 412 415 413 if (ioc4_dma & IOC4_S_DMA_STOP) 416 414 printk(KERN_ERR 417 415 "%s(%s) : IOC4 Dma STOP bit is still 1\n", 418 - __FUNCTION__, drive->name); 416 + __func__, drive->name); 419 417 } 420 418 421 419 ioc4_dma = readl((void __iomem *)ioc4_dma_addr); ··· 423 421 printk(KERN_WARNING 424 422 "%s(%s) : Warning!! - DMA Error during Previous" 425 423 " transfer | status 0x%x\n", 426 - __FUNCTION__, drive->name, ioc4_dma); 424 + __func__, drive->name, ioc4_dma); 427 425 writel(IOC4_S_DMA_STOP, (void __iomem *)ioc4_dma_addr); 428 426 ioc4_dma = sgiioc4_ide_dma_stop(hwif, dma_base); 429 427 430 428 if (ioc4_dma & IOC4_S_DMA_STOP) 431 429 printk(KERN_ERR 432 430 "%s(%s) : IOC4 DMA STOP bit is still 1\n", 433 - __FUNCTION__, drive->name); 431 + __func__, drive->name); 434 432 } 435 433 436 434 /* Address of the Scatter Gather List */ ··· 521 519 return 0; /* revert to PIO for this request */ 522 520 } 523 521 524 - static int sgiioc4_ide_dma_setup(ide_drive_t *drive) 522 + static int sgiioc4_dma_setup(ide_drive_t *drive) 525 523 { 526 524 struct request *rq = HWGROUP(drive)->rq; 527 525 unsigned int count = 0; ··· 550 548 return 0; 551 549 } 552 550 553 - static void __devinit 554 - ide_init_sgiioc4(ide_hwif_t * hwif) 555 - { 556 - hwif->mmio = 1; 557 - hwif->set_pio_mode = NULL; /* Sets timing for PIO mode */ 558 - hwif->set_dma_mode = &sgiioc4_set_dma_mode; 559 - hwif->selectproc = NULL;/* Use the default routine to select drive */ 560 - hwif->reset_poll = NULL;/* No HBA specific reset_poll needed */ 561 - hwif->pre_reset = NULL; /* No HBA specific pre_set needed */ 562 - hwif->resetproc = &sgiioc4_resetproc;/* Reset DMA engine, 563 - clear interrupts */ 564 - hwif->maskproc = &sgiioc4_maskproc; /* Mask on/off NIEN register */ 565 - hwif->quirkproc = NULL; 551 + static const struct ide_port_ops sgiioc4_port_ops = { 552 + .set_dma_mode = sgiioc4_set_dma_mode, 553 + /* reset DMA engine, clear IRQs */ 554 + .resetproc = sgiioc4_resetproc, 555 + /* mask on/off NIEN register */ 556 + .maskproc = sgiioc4_maskproc, 557 + }; 566 558 567 - hwif->INB = &sgiioc4_INB; 568 - 569 - if (hwif->dma_base == 0) 570 - return; 571 - 572 - hwif->dma_host_set = &sgiioc4_dma_host_set; 573 - hwif->dma_setup = &sgiioc4_ide_dma_setup; 574 - hwif->dma_start = &sgiioc4_ide_dma_start; 575 - hwif->ide_dma_end = &sgiioc4_ide_dma_end; 576 - hwif->ide_dma_test_irq = &sgiioc4_ide_dma_test_irq; 577 - hwif->dma_lost_irq = &sgiioc4_dma_lost_irq; 578 - hwif->dma_timeout = &ide_dma_timeout; 579 - } 559 + static const struct ide_dma_ops sgiioc4_dma_ops = { 560 + .dma_host_set = sgiioc4_dma_host_set, 561 + .dma_setup = sgiioc4_dma_setup, 562 + .dma_start = sgiioc4_dma_start, 563 + .dma_end = sgiioc4_dma_end, 564 + .dma_test_irq = sgiioc4_dma_test_irq, 565 + .dma_lost_irq = sgiioc4_dma_lost_irq, 566 + .dma_timeout = ide_dma_timeout, 567 + }; 580 568 581 569 static const struct ide_port_info sgiioc4_port_info __devinitdata = { 582 570 .chipset = ide_pci, 583 - .host_flags = IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ 584 - IDE_HFLAG_NO_AUTOTUNE, 571 + .init_dma = ide_dma_sgiioc4, 572 + .port_ops = &sgiioc4_port_ops, 573 + .dma_ops = &sgiioc4_dma_ops, 574 + .host_flags = IDE_HFLAG_NO_AUTOTUNE, 585 575 .mwdma_mask = ATA_MWDMA2_ONLY, 586 576 }; 587 577 588 578 static int __devinit 589 579 sgiioc4_ide_setup_pci_device(struct pci_dev *dev) 590 580 { 591 - unsigned long cmd_base, dma_base, irqport; 581 + unsigned long cmd_base, irqport; 592 582 unsigned long bar0, cmd_phys_base, ctl; 593 583 void __iomem *virt_base; 594 584 ide_hwif_t *hwif; ··· 606 612 cmd_base = (unsigned long) virt_base + IOC4_CMD_OFFSET; 607 613 ctl = (unsigned long) virt_base + IOC4_CTRL_OFFSET; 608 614 irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET; 609 - dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET; 610 615 611 616 cmd_phys_base = bar0 + IOC4_CMD_OFFSET; 612 617 if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE, ··· 613 620 printk(KERN_ERR 614 621 "%s : %s -- ERROR, Addresses " 615 622 "0x%p to 0x%p ALREADY in use\n", 616 - __FUNCTION__, hwif->name, (void *) cmd_phys_base, 623 + __func__, hwif->name, (void *) cmd_phys_base, 617 624 (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); 618 625 return -ENOMEM; 619 626 } ··· 634 641 /* Initializing chipset IRQ Registers */ 635 642 writel(0x03, (void __iomem *)(irqport + IOC4_INTR_SET * 4)); 636 643 637 - if (dma_base == 0 || ide_dma_sgiioc4(hwif, dma_base)) { 638 - printk(KERN_INFO "%s: %s Bus-Master DMA disabled\n", 639 - hwif->name, DRV_NAME); 640 - d.mwdma_mask = 0; 641 - } 642 - 643 - ide_init_sgiioc4(hwif); 644 + hwif->INB = &sgiioc4_INB; 644 645 645 646 idx[0] = hwif->index; 646 647
+58 -56
drivers/ide/pci/siimage.c
··· 301 301 } 302 302 303 303 /* returns 1 if dma irq issued, 0 otherwise */ 304 - static int siimage_io_ide_dma_test_irq (ide_drive_t *drive) 304 + static int siimage_io_dma_test_irq(ide_drive_t *drive) 305 305 { 306 306 ide_hwif_t *hwif = HWIF(drive); 307 307 struct pci_dev *dev = to_pci_dev(hwif->dev); ··· 320 320 } 321 321 322 322 /** 323 - * siimage_mmio_ide_dma_test_irq - check we caused an IRQ 323 + * siimage_mmio_dma_test_irq - check we caused an IRQ 324 324 * @drive: drive we are testing 325 325 * 326 326 * Check if we caused an IDE DMA interrupt. We may also have caused 327 327 * SATA status interrupts, if so we clean them up and continue. 328 328 */ 329 - 330 - static int siimage_mmio_ide_dma_test_irq (ide_drive_t *drive) 329 + 330 + static int siimage_mmio_dma_test_irq(ide_drive_t *drive) 331 331 { 332 332 ide_hwif_t *hwif = HWIF(drive); 333 333 unsigned long addr = siimage_selreg(hwif, 0x1); ··· 347 347 printk(KERN_WARNING "%s: sata_error = 0x%08x, " 348 348 "watchdog = %d, %s\n", 349 349 drive->name, sata_error, watchdog, 350 - __FUNCTION__); 350 + __func__); 351 351 352 352 } else { 353 353 watchdog = (ext_stat & 0x8000) ? 1 : 0; ··· 367 367 return 0; //return 1; 368 368 369 369 return 0; 370 + } 371 + 372 + static int siimage_dma_test_irq(ide_drive_t *drive) 373 + { 374 + if (drive->hwif->mmio) 375 + return siimage_mmio_dma_test_irq(drive); 376 + else 377 + return siimage_io_dma_test_irq(drive); 370 378 } 371 379 372 380 /** ··· 743 735 } 744 736 745 737 /** 746 - * ata66_siimage - check for 80 pin cable 738 + * sil_cable_detect - cable detection 747 739 * @hwif: interface to check 748 740 * 749 741 * Check for the presence of an ATA66 capable cable on the 750 742 * interface. 751 743 */ 752 744 753 - static u8 __devinit ata66_siimage(ide_hwif_t *hwif) 745 + static u8 __devinit sil_cable_detect(ide_hwif_t *hwif) 754 746 { 755 747 struct pci_dev *dev = to_pci_dev(hwif->dev); 756 748 unsigned long addr = siimage_selreg(hwif, 0); ··· 764 756 return (ata66 & 0x01) ? ATA_CBL_PATA80 : ATA_CBL_PATA40; 765 757 } 766 758 767 - /** 768 - * init_hwif_siimage - set up hwif structs 769 - * @hwif: interface to set up 770 - * 771 - * We do the basic set up of the interface structure. The SIIMAGE 772 - * requires several custom handlers so we override the default 773 - * ide DMA handlers appropriately 774 - */ 759 + static const struct ide_port_ops sil_pata_port_ops = { 760 + .set_pio_mode = sil_set_pio_mode, 761 + .set_dma_mode = sil_set_dma_mode, 762 + .quirkproc = sil_quirkproc, 763 + .udma_filter = sil_pata_udma_filter, 764 + .cable_detect = sil_cable_detect, 765 + }; 775 766 776 - static void __devinit init_hwif_siimage(ide_hwif_t *hwif) 777 - { 778 - u8 sata = is_sata(hwif); 767 + static const struct ide_port_ops sil_sata_port_ops = { 768 + .set_pio_mode = sil_set_pio_mode, 769 + .set_dma_mode = sil_set_dma_mode, 770 + .reset_poll = sil_sata_reset_poll, 771 + .pre_reset = sil_sata_pre_reset, 772 + .quirkproc = sil_quirkproc, 773 + .udma_filter = sil_sata_udma_filter, 774 + .cable_detect = sil_cable_detect, 775 + }; 779 776 780 - hwif->set_pio_mode = &sil_set_pio_mode; 781 - hwif->set_dma_mode = &sil_set_dma_mode; 782 - hwif->quirkproc = &sil_quirkproc; 777 + static struct ide_dma_ops sil_dma_ops = { 778 + .dma_test_irq = siimage_dma_test_irq, 779 + }; 783 780 784 - if (sata) { 785 - static int first = 1; 786 - 787 - hwif->reset_poll = &sil_sata_reset_poll; 788 - hwif->pre_reset = &sil_sata_pre_reset; 789 - hwif->udma_filter = &sil_sata_udma_filter; 790 - 791 - if (first) { 792 - printk(KERN_INFO "siimage: For full SATA support you should use the libata sata_sil module.\n"); 793 - first = 0; 794 - } 795 - } else 796 - hwif->udma_filter = &sil_pata_udma_filter; 797 - 798 - hwif->cable_detect = ata66_siimage; 799 - 800 - if (hwif->dma_base == 0) 801 - return; 802 - 803 - if (sata) 804 - hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; 805 - 806 - if (hwif->mmio) { 807 - hwif->ide_dma_test_irq = &siimage_mmio_ide_dma_test_irq; 808 - } else { 809 - hwif->ide_dma_test_irq = & siimage_io_ide_dma_test_irq; 810 - } 811 - } 812 - 813 - #define DECLARE_SII_DEV(name_str) \ 781 + #define DECLARE_SII_DEV(name_str, p_ops) \ 814 782 { \ 815 783 .name = name_str, \ 816 784 .init_chipset = init_chipset_siimage, \ 817 785 .init_iops = init_iops_siimage, \ 818 - .init_hwif = init_hwif_siimage, \ 786 + .port_ops = p_ops, \ 787 + .dma_ops = &sil_dma_ops, \ 819 788 .pio_mask = ATA_PIO4, \ 820 789 .mwdma_mask = ATA_MWDMA2, \ 821 790 .udma_mask = ATA_UDMA6, \ 822 791 } 823 792 824 793 static const struct ide_port_info siimage_chipsets[] __devinitdata = { 825 - /* 0 */ DECLARE_SII_DEV("SiI680"), 826 - /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA"), 827 - /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA") 794 + /* 0 */ DECLARE_SII_DEV("SiI680", &sil_pata_port_ops), 795 + /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA", &sil_sata_port_ops), 796 + /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA", &sil_sata_port_ops) 828 797 }; 829 798 830 799 /** ··· 815 830 816 831 static int __devinit siimage_init_one(struct pci_dev *dev, const struct pci_device_id *id) 817 832 { 818 - return ide_setup_pci_device(dev, &siimage_chipsets[id->driver_data]); 833 + struct ide_port_info d; 834 + u8 idx = id->driver_data; 835 + 836 + d = siimage_chipsets[idx]; 837 + 838 + if (idx) { 839 + static int first = 1; 840 + 841 + if (first) { 842 + printk(KERN_INFO "siimage: For full SATA support you " 843 + "should use the libata sata_sil module.\n"); 844 + first = 0; 845 + } 846 + 847 + d.host_flags |= IDE_HFLAG_NO_ATAPI_DMA; 848 + } 849 + 850 + return ide_setup_pci_device(dev, &d); 819 851 } 820 852 821 853 static const struct pci_device_id siimage_pci_tbl[] = {
+18 -12
drivers/ide/pci/sis5513.c
··· 347 347 sis_program_timings(drive, speed); 348 348 } 349 349 350 - static u8 sis5513_ata133_udma_filter(ide_drive_t *drive) 350 + static u8 sis_ata133_udma_filter(ide_drive_t *drive) 351 351 { 352 352 struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 353 353 u32 regdw = 0; ··· 514 514 { 0, } 515 515 }; 516 516 517 - static u8 __devinit ata66_sis5513(ide_hwif_t *hwif) 517 + static u8 __devinit sis_cable_detect(ide_hwif_t *hwif) 518 518 { 519 519 struct pci_dev *pdev = to_pci_dev(hwif->dev); 520 520 const struct sis_laptop *lap = &sis_laptop[0]; ··· 543 543 return ata66 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; 544 544 } 545 545 546 - static void __devinit init_hwif_sis5513(ide_hwif_t *hwif) 547 - { 548 - hwif->set_pio_mode = &sis_set_pio_mode; 549 - hwif->set_dma_mode = &sis_set_dma_mode; 546 + static const struct ide_port_ops sis_port_ops = { 547 + .set_pio_mode = sis_set_pio_mode, 548 + .set_dma_mode = sis_set_dma_mode, 549 + .cable_detect = sis_cable_detect, 550 + }; 550 551 551 - if (chipset_family >= ATA_133) 552 - hwif->udma_filter = sis5513_ata133_udma_filter; 553 - 554 - hwif->cable_detect = ata66_sis5513; 555 - } 552 + static const struct ide_port_ops sis_ata133_port_ops = { 553 + .set_pio_mode = sis_set_pio_mode, 554 + .set_dma_mode = sis_set_dma_mode, 555 + .udma_filter = sis_ata133_udma_filter, 556 + .cable_detect = sis_cable_detect, 557 + }; 556 558 557 559 static const struct ide_port_info sis5513_chipset __devinitdata = { 558 560 .name = "SIS5513", 559 561 .init_chipset = init_chipset_sis5513, 560 - .init_hwif = init_hwif_sis5513, 561 562 .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, 562 563 .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, 563 564 .pio_mask = ATA_PIO4, ··· 572 571 573 572 if (sis_find_family(dev) == 0) 574 573 return -ENOTSUPP; 574 + 575 + if (chipset_family >= ATA_133) 576 + d.port_ops = &sis_ata133_port_ops; 577 + else 578 + d.port_ops = &sis_port_ops; 575 579 576 580 d.udma_mask = udma_rates[chipset_family]; 577 581
+38 -42
drivers/ide/pci/sl82c105.c
··· 179 179 struct pci_dev *dev = to_pci_dev(hwif->dev); 180 180 int reg = 0x44 + drive->dn * 4; 181 181 182 - DBG(("%s(drive:%s)\n", __FUNCTION__, drive->name)); 182 + DBG(("%s(drive:%s)\n", __func__, drive->name)); 183 183 184 184 pci_write_config_word(dev, reg, drive->drive_data >> 16); 185 185 ··· 203 203 int reg = 0x44 + drive->dn * 4; 204 204 int ret; 205 205 206 - DBG(("%s(drive:%s)\n", __FUNCTION__, drive->name)); 206 + DBG(("%s(drive:%s)\n", __func__, drive->name)); 207 207 208 208 ret = __ide_dma_end(drive); 209 209 ··· 232 232 * Return the revision of the Winbond bridge 233 233 * which this function is part of. 234 234 */ 235 - static unsigned int sl82c105_bridge_revision(struct pci_dev *dev) 235 + static u8 sl82c105_bridge_revision(struct pci_dev *dev) 236 236 { 237 237 struct pci_dev *bridge; 238 238 ··· 282 282 return dev->irq; 283 283 } 284 284 285 - /* 286 - * Initialise IDE channel 287 - */ 288 - static void __devinit init_hwif_sl82c105(ide_hwif_t *hwif) 289 - { 290 - struct pci_dev *dev = to_pci_dev(hwif->dev); 291 - unsigned int rev; 285 + static const struct ide_port_ops sl82c105_port_ops = { 286 + .set_pio_mode = sl82c105_set_pio_mode, 287 + .set_dma_mode = sl82c105_set_dma_mode, 288 + .resetproc = sl82c105_resetproc, 289 + }; 292 290 293 - DBG(("init_hwif_sl82c105(hwif: ide%d)\n", hwif->index)); 294 - 295 - hwif->set_pio_mode = &sl82c105_set_pio_mode; 296 - hwif->set_dma_mode = &sl82c105_set_dma_mode; 297 - hwif->resetproc = &sl82c105_resetproc; 298 - 299 - if (!hwif->dma_base) 300 - return; 301 - 302 - rev = sl82c105_bridge_revision(dev); 303 - if (rev <= 5) { 304 - /* 305 - * Never ever EVER under any circumstances enable 306 - * DMA when the bridge is this old. 307 - */ 308 - printk(" %s: Winbond W83C553 bridge revision %d, " 309 - "BM-DMA disabled\n", hwif->name, rev); 310 - return; 311 - } 312 - 313 - hwif->mwdma_mask = ATA_MWDMA2; 314 - 315 - hwif->dma_lost_irq = &sl82c105_dma_lost_irq; 316 - hwif->dma_start = &sl82c105_dma_start; 317 - hwif->ide_dma_end = &sl82c105_dma_end; 318 - hwif->dma_timeout = &sl82c105_dma_timeout; 319 - 320 - if (hwif->mate) 321 - hwif->serialized = hwif->mate->serialized = 1; 322 - } 291 + static const struct ide_dma_ops sl82c105_dma_ops = { 292 + .dma_host_set = ide_dma_host_set, 293 + .dma_setup = ide_dma_setup, 294 + .dma_exec_cmd = ide_dma_exec_cmd, 295 + .dma_start = sl82c105_dma_start, 296 + .dma_end = sl82c105_dma_end, 297 + .dma_test_irq = ide_dma_test_irq, 298 + .dma_lost_irq = sl82c105_dma_lost_irq, 299 + .dma_timeout = sl82c105_dma_timeout, 300 + }; 323 301 324 302 static const struct ide_port_info sl82c105_chipset __devinitdata = { 325 303 .name = "W82C105", 326 304 .init_chipset = init_chipset_sl82c105, 327 - .init_hwif = init_hwif_sl82c105, 328 305 .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, 306 + .port_ops = &sl82c105_port_ops, 307 + .dma_ops = &sl82c105_dma_ops, 329 308 .host_flags = IDE_HFLAG_IO_32BIT | 330 309 IDE_HFLAG_UNMASK_IRQS | 331 310 /* FIXME: check for Compatibility mode in generic IDE PCI code */ 332 311 #if defined(CONFIG_LOPEC) || defined(CONFIG_SANDPOINT) 333 312 IDE_HFLAG_FORCE_LEGACY_IRQS | 334 313 #endif 314 + IDE_HFLAG_SERIALIZE_DMA | 335 315 IDE_HFLAG_NO_AUTODMA, 336 316 .pio_mask = ATA_PIO5, 317 + .mwdma_mask = ATA_MWDMA2, 337 318 }; 338 319 339 320 static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_device_id *id) 340 321 { 341 - return ide_setup_pci_device(dev, &sl82c105_chipset); 322 + struct ide_port_info d = sl82c105_chipset; 323 + u8 rev = sl82c105_bridge_revision(dev); 324 + 325 + if (rev <= 5) { 326 + /* 327 + * Never ever EVER under any circumstances enable 328 + * DMA when the bridge is this old. 329 + */ 330 + printk(KERN_INFO "W82C105_IDE: Winbond W83C553 bridge " 331 + "revision %d, BM-DMA disabled\n", rev); 332 + d.dma_ops = NULL; 333 + d.mwdma_mask = 0; 334 + d.host_flags &= ~IDE_HFLAG_SERIALIZE_DMA; 335 + } 336 + 337 + return ide_setup_pci_device(dev, &d); 342 338 } 343 339 344 340 static const struct pci_device_id sl82c105_pci_tbl[] = {
+6 -8
drivers/ide/pci/slc90e66.c
··· 125 125 return (reg47 & mask) ? ATA_CBL_PATA40 : ATA_CBL_PATA80; 126 126 } 127 127 128 - static void __devinit init_hwif_slc90e66(ide_hwif_t *hwif) 129 - { 130 - hwif->set_pio_mode = &slc90e66_set_pio_mode; 131 - hwif->set_dma_mode = &slc90e66_set_dma_mode; 132 - 133 - hwif->cable_detect = slc90e66_cable_detect; 134 - } 128 + static const struct ide_port_ops slc90e66_port_ops = { 129 + .set_pio_mode = slc90e66_set_pio_mode, 130 + .set_dma_mode = slc90e66_set_dma_mode, 131 + .cable_detect = slc90e66_cable_detect, 132 + }; 135 133 136 134 static const struct ide_port_info slc90e66_chipset __devinitdata = { 137 135 .name = "SLC90E66", 138 - .init_hwif = init_hwif_slc90e66, 139 136 .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, 137 + .port_ops = &slc90e66_port_ops, 140 138 .host_flags = IDE_HFLAG_LEGACY_IRQS, 141 139 .pio_mask = ATA_PIO4, 142 140 .swdma_mask = ATA_SWDMA2_ONLY,
+19 -7
drivers/ide/pci/tc86c001.c
··· 157 157 /* Store the system control register base for convenience... */ 158 158 hwif->config_data = sc_base; 159 159 160 - hwif->set_pio_mode = &tc86c001_set_pio_mode; 161 - hwif->set_dma_mode = &tc86c001_set_mode; 162 - 163 - hwif->cable_detect = tc86c001_cable_detect; 164 - 165 160 if (!hwif->dma_base) 166 161 return; 167 162 ··· 168 173 169 174 /* Sector Count Register limit */ 170 175 hwif->rqsize = 0xffff; 171 - 172 - hwif->dma_start = &tc86c001_dma_start; 173 176 } 174 177 175 178 static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev, ··· 180 187 return err; 181 188 } 182 189 190 + static const struct ide_port_ops tc86c001_port_ops = { 191 + .set_pio_mode = tc86c001_set_pio_mode, 192 + .set_dma_mode = tc86c001_set_mode, 193 + .cable_detect = tc86c001_cable_detect, 194 + }; 195 + 196 + static const struct ide_dma_ops tc86c001_dma_ops = { 197 + .dma_host_set = ide_dma_host_set, 198 + .dma_setup = ide_dma_setup, 199 + .dma_exec_cmd = ide_dma_exec_cmd, 200 + .dma_start = tc86c001_dma_start, 201 + .dma_end = __ide_dma_end, 202 + .dma_test_irq = ide_dma_test_irq, 203 + .dma_lost_irq = ide_dma_lost_irq, 204 + .dma_timeout = ide_dma_timeout, 205 + }; 206 + 183 207 static const struct ide_port_info tc86c001_chipset __devinitdata = { 184 208 .name = "TC86C001", 185 209 .init_chipset = init_chipset_tc86c001, 186 210 .init_hwif = init_hwif_tc86c001, 211 + .port_ops = &tc86c001_port_ops, 212 + .dma_ops = &tc86c001_dma_ops, 187 213 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_OFF_BOARD | 188 214 IDE_HFLAG_ABUSE_SET_DMA_MODE, 189 215 .pio_mask = ATA_PIO4,
+5 -6
drivers/ide/pci/triflex.c
··· 87 87 triflex_set_mode(drive, XFER_PIO_0 + pio); 88 88 } 89 89 90 - static void __devinit init_hwif_triflex(ide_hwif_t *hwif) 91 - { 92 - hwif->set_pio_mode = &triflex_set_pio_mode; 93 - hwif->set_dma_mode = &triflex_set_mode; 94 - } 90 + static const struct ide_port_ops triflex_port_ops = { 91 + .set_pio_mode = triflex_set_pio_mode, 92 + .set_dma_mode = triflex_set_mode, 93 + }; 95 94 96 95 static const struct ide_port_info triflex_device __devinitdata = { 97 96 .name = "TRIFLEX", 98 - .init_hwif = init_hwif_triflex, 99 97 .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, 98 + .port_ops = &triflex_port_ops, 100 99 .pio_mask = ATA_PIO4, 101 100 .swdma_mask = ATA_SWDMA2, 102 101 .mwdma_mask = ATA_MWDMA2,
+21 -23
drivers/ide/pci/trm290.c
··· 214 214 { 215 215 } 216 216 217 - static int trm290_ide_dma_end (ide_drive_t *drive) 217 + static int trm290_dma_end(ide_drive_t *drive) 218 218 { 219 219 u16 status; 220 220 ··· 225 225 return status != 0x00ff; 226 226 } 227 227 228 - static int trm290_ide_dma_test_irq (ide_drive_t *drive) 228 + static int trm290_dma_test_irq(ide_drive_t *drive) 229 229 { 230 230 u16 status; 231 231 ··· 254 254 hwif->config_data = cfg_base; 255 255 hwif->dma_base = (cfg_base + 4) ^ (hwif->channel ? 0x80 : 0); 256 256 257 - printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx", 257 + printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", 258 258 hwif->name, hwif->dma_base, hwif->dma_base + 3); 259 259 260 - if (!request_region(hwif->dma_base, 4, hwif->name)) { 261 - printk(KERN_CONT " -- Error, ports in use.\n"); 260 + if (ide_allocate_dma_engine(hwif)) 262 261 return; 263 - } 264 - 265 - hwif->dmatable_cpu = pci_alloc_consistent(dev, PRD_ENTRIES * PRD_BYTES, 266 - &hwif->dmatable_dma); 267 - if (!hwif->dmatable_cpu) { 268 - printk(KERN_CONT " -- Error, unable to allocate DMA table.\n"); 269 - release_region(hwif->dma_base, 4); 270 - return; 271 - } 272 - printk(KERN_CONT "\n"); 273 262 274 263 local_irq_save(flags); 275 264 /* put config reg into first byte of hwif->select_data */ ··· 280 291 /* sharing IRQ with mate */ 281 292 hwif->irq = hwif->mate->irq; 282 293 283 - hwif->dma_host_set = &trm290_dma_host_set; 284 - hwif->dma_setup = &trm290_dma_setup; 285 - hwif->dma_exec_cmd = &trm290_dma_exec_cmd; 286 - hwif->dma_start = &trm290_dma_start; 287 - hwif->ide_dma_end = &trm290_ide_dma_end; 288 - hwif->ide_dma_test_irq = &trm290_ide_dma_test_irq; 289 - 290 - hwif->selectproc = &trm290_selectproc; 291 294 #if 1 292 295 { 293 296 /* ··· 309 328 #endif 310 329 } 311 330 331 + static const struct ide_port_ops trm290_port_ops = { 332 + .selectproc = trm290_selectproc, 333 + }; 334 + 335 + static struct ide_dma_ops trm290_dma_ops = { 336 + .dma_host_set = trm290_dma_host_set, 337 + .dma_setup = trm290_dma_setup, 338 + .dma_exec_cmd = trm290_dma_exec_cmd, 339 + .dma_start = trm290_dma_start, 340 + .dma_end = trm290_dma_end, 341 + .dma_test_irq = trm290_dma_test_irq, 342 + .dma_lost_irq = ide_dma_lost_irq, 343 + .dma_timeout = ide_dma_timeout, 344 + }; 345 + 312 346 static const struct ide_port_info trm290_chipset __devinitdata = { 313 347 .name = "TRM290", 314 348 .init_hwif = init_hwif_trm290, 315 349 .chipset = ide_trm290, 350 + .port_ops = &trm290_port_ops, 351 + .dma_ops = &trm290_dma_ops, 316 352 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | 317 353 #if 0 /* play it safe for now */ 318 354 IDE_HFLAG_TRUST_BIOS_FOR_DMA |
+6 -8
drivers/ide/pci/via82cxxx.c
··· 415 415 return ATA_CBL_PATA40; 416 416 } 417 417 418 - static void __devinit init_hwif_via82cxxx(ide_hwif_t *hwif) 419 - { 420 - hwif->set_pio_mode = &via_set_pio_mode; 421 - hwif->set_dma_mode = &via_set_drive; 422 - 423 - hwif->cable_detect = via82cxxx_cable_detect; 424 - } 418 + static const struct ide_port_ops via_port_ops = { 419 + .set_pio_mode = via_set_pio_mode, 420 + .set_dma_mode = via_set_drive, 421 + .cable_detect = via82cxxx_cable_detect, 422 + }; 425 423 426 424 static const struct ide_port_info via82cxxx_chipset __devinitdata = { 427 425 .name = "VP_IDE", 428 426 .init_chipset = init_chipset_via82cxxx, 429 - .init_hwif = init_hwif_via82cxxx, 430 427 .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, 428 + .port_ops = &via_port_ops, 431 429 .host_flags = IDE_HFLAG_PIO_NO_BLACKLIST | 432 430 IDE_HFLAG_ABUSE_SET_DMA_MODE | 433 431 IDE_HFLAG_POST_SET_MODE |
+7 -5
drivers/ide/ppc/mpc8xx.c
··· 438 438 #elif defined(CONFIG_IDE_EXT_DIRECT) 439 439 440 440 printk("%s[%d] %s: not implemented yet!\n", 441 - __FILE__,__LINE__,__FUNCTION__); 441 + __FILE__, __LINE__, __func__); 442 442 #endif /* defined(CONFIG_IDE_8xx_PCCARD) || defined(CONFIG_IDE_8xx_PCMCIA */ 443 443 } 444 + 445 + static const struct ide_port_ops m8xx_port_ops = { 446 + .set_pio_mode = m8xx_ide_set_pio_mode, 447 + }; 444 448 445 449 static void 446 450 ide_interrupt_ack (void *dev) ··· 814 810 ide_hwif_t *hwif = &ide_hwifs[0]; 815 811 816 812 ide_init_port_hw(hwif, &hw); 817 - hwif->mmio = 1; 818 813 hwif->pio_mask = ATA_PIO4; 819 - hwif->set_pio_mode = m8xx_ide_set_pio_mode; 814 + hwif->port_ops = &m8xx_port_ops; 820 815 821 816 idx[0] = 0; 822 817 } ··· 825 822 ide_hwif_t *mate = &ide_hwifs[1]; 826 823 827 824 ide_init_port_hw(mate, &hw); 828 - mate->mmio = 1; 829 825 mate->pio_mask = ATA_PIO4; 830 - mate->set_pio_mode = m8xx_ide_set_pio_mode; 826 + mate->port_ops = &m8xx_port_ops; 831 827 832 828 idx[1] = 1; 833 829 }
+54 -32
drivers/ide/ppc/pmac.c
··· 409 409 */ 410 410 #define IDE_WAKEUP_DELAY (1*HZ) 411 411 412 - static int pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif); 412 + static int pmac_ide_init_dma(ide_hwif_t *, const struct ide_port_info *); 413 413 static int pmac_ide_build_dmatable(ide_drive_t *drive, struct request *rq); 414 414 static void pmac_ide_selectproc(ide_drive_t *drive); 415 415 static void pmac_ide_kauai_selectproc(ide_drive_t *drive); ··· 918 918 return 0; 919 919 } 920 920 921 + static const struct ide_port_ops pmac_ide_ata6_port_ops = { 922 + .set_pio_mode = pmac_ide_set_pio_mode, 923 + .set_dma_mode = pmac_ide_set_dma_mode, 924 + .selectproc = pmac_ide_kauai_selectproc, 925 + }; 926 + 927 + static const struct ide_port_ops pmac_ide_port_ops = { 928 + .set_pio_mode = pmac_ide_set_pio_mode, 929 + .set_dma_mode = pmac_ide_set_dma_mode, 930 + .selectproc = pmac_ide_selectproc, 931 + }; 932 + 933 + static const struct ide_dma_ops pmac_dma_ops; 934 + 921 935 static const struct ide_port_info pmac_port_info = { 936 + .init_dma = pmac_ide_init_dma, 922 937 .chipset = ide_pmac, 938 + #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC 939 + .dma_ops = &pmac_dma_ops, 940 + #endif 941 + .port_ops = &pmac_ide_port_ops, 923 942 .host_flags = IDE_HFLAG_SET_PIO_MODE_KEEP_DMA | 924 943 IDE_HFLAG_POST_SET_MODE | 925 - IDE_HFLAG_NO_DMA | /* no SFF-style DMA */ 926 944 IDE_HFLAG_UNMASK_IRQS, 927 945 .pio_mask = ATA_PIO4, 928 946 .mwdma_mask = ATA_MWDMA2, ··· 965 947 pmif->broken_dma = pmif->broken_dma_warn = 0; 966 948 if (of_device_is_compatible(np, "shasta-ata")) { 967 949 pmif->kind = controller_sh_ata6; 950 + d.port_ops = &pmac_ide_ata6_port_ops; 968 951 d.udma_mask = ATA_UDMA6; 969 952 } else if (of_device_is_compatible(np, "kauai-ata")) { 970 953 pmif->kind = controller_un_ata6; 954 + d.port_ops = &pmac_ide_ata6_port_ops; 971 955 d.udma_mask = ATA_UDMA5; 972 956 } else if (of_device_is_compatible(np, "K2-UATA")) { 973 957 pmif->kind = controller_k2_ata6; 958 + d.port_ops = &pmac_ide_ata6_port_ops; 974 959 d.udma_mask = ATA_UDMA5; 975 960 } else if (of_device_is_compatible(np, "keylargo-ata")) { 976 961 if (strcmp(np->name, "ata-4") == 0) { ··· 1050 1029 default_hwif_mmiops(hwif); 1051 1030 hwif->OUTBSYNC = pmac_outbsync; 1052 1031 1053 - /* Tell common code _not_ to mess with resources */ 1054 - hwif->mmio = 1; 1055 1032 hwif->hwif_data = pmif; 1056 1033 ide_init_port_hw(hwif, hw); 1057 - hwif->noprobe = pmif->mediabay; 1058 1034 hwif->cbl = pmif->cable_80 ? ATA_CBL_PATA80 : ATA_CBL_PATA40; 1059 - hwif->set_pio_mode = pmac_ide_set_pio_mode; 1060 - if (pmif->kind == controller_un_ata6 1061 - || pmif->kind == controller_k2_ata6 1062 - || pmif->kind == controller_sh_ata6) 1063 - hwif->selectproc = pmac_ide_kauai_selectproc; 1064 - else 1065 - hwif->selectproc = pmac_ide_selectproc; 1066 - hwif->set_dma_mode = pmac_ide_set_dma_mode; 1067 1035 1068 1036 printk(KERN_INFO "ide%d: Found Apple %s controller, bus ID %d%s, irq %d\n", 1069 1037 hwif->index, model_name[pmif->kind], pmif->aapl_bus_id, 1070 1038 pmif->mediabay ? " (mediabay)" : "", hwif->irq); 1071 - 1039 + 1040 + if (pmif->mediabay) { 1072 1041 #ifdef CONFIG_PMAC_MEDIABAY 1073 - if (pmif->mediabay && check_media_bay_by_base(pmif->regbase, MB_CD) == 0) 1074 - hwif->noprobe = 0; 1075 - #endif /* CONFIG_PMAC_MEDIABAY */ 1042 + if (check_media_bay_by_base(pmif->regbase, MB_CD)) { 1043 + #else 1044 + if (1) { 1045 + #endif 1046 + hwif->drives[0].noprobe = 1; 1047 + hwif->drives[1].noprobe = 1; 1048 + } 1049 + } 1076 1050 1077 1051 #ifdef CONFIG_BLK_DEV_IDEDMA_PMAC 1078 1052 if (pmif->cable_80 == 0) 1079 1053 d.udma_mask &= ATA_UDMA2; 1080 - /* has a DBDMA controller channel */ 1081 - if (pmif->dma_regs == 0 || pmac_ide_setup_dma(pmif, hwif) < 0) 1082 1054 #endif 1083 - d.udma_mask = d.mwdma_mask = 0; 1084 1055 1085 1056 idx[0] = hwif->index; 1086 1057 ··· 1675 1662 printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status); 1676 1663 } 1677 1664 1665 + static const struct ide_dma_ops pmac_dma_ops = { 1666 + .dma_host_set = pmac_ide_dma_host_set, 1667 + .dma_setup = pmac_ide_dma_setup, 1668 + .dma_exec_cmd = pmac_ide_dma_exec_cmd, 1669 + .dma_start = pmac_ide_dma_start, 1670 + .dma_end = pmac_ide_dma_end, 1671 + .dma_test_irq = pmac_ide_dma_test_irq, 1672 + .dma_timeout = ide_dma_timeout, 1673 + .dma_lost_irq = pmac_ide_dma_lost_irq, 1674 + }; 1675 + 1678 1676 /* 1679 1677 * Allocate the data structures needed for using DMA with an interface 1680 1678 * and fill the proper list of functions pointers 1681 1679 */ 1682 - static int __devinit pmac_ide_setup_dma(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif) 1680 + static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif, 1681 + const struct ide_port_info *d) 1683 1682 { 1683 + pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)hwif->hwif_data; 1684 1684 struct pci_dev *dev = to_pci_dev(hwif->dev); 1685 1685 1686 1686 /* We won't need pci_dev if we switch to generic consistent 1687 1687 * DMA routines ... 1688 1688 */ 1689 - if (dev == NULL) 1689 + if (dev == NULL || pmif->dma_regs == 0) 1690 1690 return -ENODEV; 1691 1691 /* 1692 1692 * Allocate space for the DBDMA commands. ··· 1718 1692 1719 1693 hwif->sg_max_nents = MAX_DCMDS; 1720 1694 1721 - hwif->dma_host_set = &pmac_ide_dma_host_set; 1722 - hwif->dma_setup = &pmac_ide_dma_setup; 1723 - hwif->dma_exec_cmd = &pmac_ide_dma_exec_cmd; 1724 - hwif->dma_start = &pmac_ide_dma_start; 1725 - hwif->ide_dma_end = &pmac_ide_dma_end; 1726 - hwif->ide_dma_test_irq = &pmac_ide_dma_test_irq; 1727 - hwif->dma_timeout = &ide_dma_timeout; 1728 - hwif->dma_lost_irq = &pmac_ide_dma_lost_irq; 1729 - 1730 1695 return 0; 1731 1696 } 1732 - 1697 + #else 1698 + static int __devinit pmac_ide_init_dma(ide_hwif_t *hwif, 1699 + const struct ide_port_info *d) 1700 + { 1701 + return -EOPNOTSUPP; 1702 + } 1733 1703 #endif /* CONFIG_BLK_DEV_IDEDMA_PMAC */ 1734 1704 1735 1705 module_init(pmac_ide_probe);
+63 -38
drivers/ide/setup-pci.c
··· 72 72 } 73 73 74 74 /** 75 - * ide_get_or_set_dma_base - setup BMIBA 76 - * @d: IDE port info 75 + * ide_pci_dma_base - setup BMIBA 77 76 * @hwif: IDE interface 77 + * @d: IDE port info 78 78 * 79 79 * Fetch the DMA Bus-Master-I/O-Base-Address (BMIBA) from PCI space. 80 80 * Where a device has a partner that is already in DMA mode we check 81 81 * and enforce IDE simplex rules. 82 82 */ 83 83 84 - static unsigned long ide_get_or_set_dma_base(const struct ide_port_info *d, ide_hwif_t *hwif) 84 + unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d) 85 85 { 86 86 struct pci_dev *dev = to_pci_dev(hwif->dev); 87 87 unsigned long dma_base = 0; ··· 132 132 out: 133 133 return dma_base; 134 134 } 135 + EXPORT_SYMBOL_GPL(ide_pci_dma_base); 136 + 137 + /* 138 + * Set up BM-DMA capability (PnP BIOS should have done this) 139 + */ 140 + int ide_pci_set_master(struct pci_dev *dev, const char *name) 141 + { 142 + u16 pcicmd; 143 + 144 + pci_read_config_word(dev, PCI_COMMAND, &pcicmd); 145 + 146 + if ((pcicmd & PCI_COMMAND_MASTER) == 0) { 147 + pci_set_master(dev); 148 + 149 + if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || 150 + (pcicmd & PCI_COMMAND_MASTER) == 0) { 151 + printk(KERN_ERR "%s: error updating PCICMD on %s\n", 152 + name, pci_name(dev)); 153 + return -EIO; 154 + } 155 + } 156 + 157 + return 0; 158 + } 159 + EXPORT_SYMBOL_GPL(ide_pci_set_master); 135 160 #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ 136 161 137 162 void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) ··· 183 158 184 159 static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d) 185 160 { 186 - int ret; 161 + int ret, bars; 187 162 188 163 if (pci_enable_device(dev)) { 189 164 ret = pci_enable_device_io(dev); ··· 206 181 goto out; 207 182 } 208 183 209 - /* FIXME: Temporary - until we put in the hotplug interface logic 210 - Check that the bits we want are not in use by someone else. */ 211 - ret = pci_request_region(dev, 4, "ide_tmp"); 212 - if (ret < 0) 213 - goto out; 184 + if (d->host_flags & IDE_HFLAG_SINGLE) 185 + bars = (1 << 2) - 1; 186 + else 187 + bars = (1 << 4) - 1; 214 188 215 - pci_release_region(dev, 4); 189 + if ((d->host_flags & IDE_HFLAG_NO_DMA) == 0) { 190 + if (d->host_flags & IDE_HFLAG_CS5520) 191 + bars |= (1 << 2); 192 + else 193 + bars |= (1 << 4); 194 + } 195 + 196 + ret = pci_request_selected_regions(dev, bars, d->name); 197 + if (ret < 0) 198 + printk(KERN_ERR "%s: can't reserve resources\n", d->name); 216 199 out: 217 200 return ret; 218 201 } ··· 347 314 ide_init_port_hw(hwif, &hw); 348 315 349 316 hwif->dev = &dev->dev; 350 - hwif->cds = d; 351 317 352 318 return hwif; 353 319 } ··· 362 330 * state 363 331 */ 364 332 365 - void ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) 333 + int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d) 366 334 { 367 335 struct pci_dev *dev = to_pci_dev(hwif->dev); 368 - u16 pcicmd; 369 - 370 - pci_read_config_word(dev, PCI_COMMAND, &pcicmd); 371 336 372 337 if ((d->host_flags & IDE_HFLAG_NO_AUTODMA) == 0 || 373 338 ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && 374 339 (dev->class & 0x80))) { 375 - unsigned long dma_base = ide_get_or_set_dma_base(d, hwif); 376 - if (dma_base && !(pcicmd & PCI_COMMAND_MASTER)) { 377 - /* 378 - * Set up BM-DMA capability 379 - * (PnP BIOS should have done this) 380 - */ 381 - pci_set_master(dev); 382 - if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || !(pcicmd & PCI_COMMAND_MASTER)) { 383 - printk(KERN_ERR "%s: %s error updating PCICMD\n", 384 - hwif->name, d->name); 385 - dma_base = 0; 386 - } 387 - } 388 - if (dma_base) { 389 - if (d->init_dma) { 390 - d->init_dma(hwif, dma_base); 391 - } else { 392 - ide_setup_dma(hwif, dma_base); 393 - } 394 - } else { 395 - printk(KERN_INFO "%s: %s Bus-Master DMA disabled " 396 - "(BIOS)\n", hwif->name, d->name); 397 - } 340 + unsigned long base = ide_pci_dma_base(hwif, d); 341 + 342 + if (base == 0 || ide_pci_set_master(dev, d->name) < 0) 343 + return -1; 344 + 345 + if (hwif->mmio) 346 + printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); 347 + else 348 + printk(KERN_INFO " %s: BM-DMA at 0x%04lx-0x%04lx\n", 349 + hwif->name, base, base + 7); 350 + 351 + hwif->extra_base = base + (hwif->channel ? 8 : 16); 352 + 353 + if (ide_allocate_dma_engine(hwif)) 354 + return -1; 355 + 356 + ide_setup_dma(hwif, base); 398 357 } 358 + 359 + return 0; 399 360 } 400 361 #endif /* CONFIG_BLK_DEV_IDEDMA_PCI */ 401 362
+3 -3
drivers/scsi/ide-scsi.c
··· 393 393 printk ("ide-scsi: %s: DMA complete\n", drive->name); 394 394 #endif /* IDESCSI_DEBUG_LOG */ 395 395 pc->xferred = pc->req_xfer; 396 - (void) HWIF(drive)->ide_dma_end(drive); 396 + (void)hwif->dma_ops->dma_end(drive); 397 397 } 398 398 399 399 /* Clear the interrupt */ ··· 498 498 drive->hwif->atapi_output_bytes(drive, scsi->pc->c, 12); 499 499 if (pc->flags & PC_FLAG_DMA_OK) { 500 500 pc->flags |= PC_FLAG_DMA_IN_PROGRESS; 501 - hwif->dma_start(drive); 501 + hwif->dma_ops->dma_start(drive); 502 502 } 503 503 return ide_started; 504 504 } ··· 560 560 561 561 if (drive->using_dma && !idescsi_map_sg(drive, pc)) { 562 562 hwif->sg_mapped = 1; 563 - dma = !hwif->dma_setup(drive); 563 + dma = !hwif->dma_ops->dma_setup(drive); 564 564 hwif->sg_mapped = 0; 565 565 } 566 566
-42
include/asm-mips/mach-au1x00/au1xxx_ide.h
··· 70 70 ide_hwif_t *hwif; 71 71 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 72 72 ide_drive_t *drive; 73 - u8 white_list, black_list; 74 73 struct dbdma_cmd *dma_table_cpu; 75 74 dma_addr_t dma_table_dma; 76 75 #endif ··· 79 80 pm_state pm; 80 81 #endif 81 82 } _auide_hwif; 82 - 83 - #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 84 - /* HD white list */ 85 - static const struct drive_list_entry dma_white_list [] = { 86 - /* 87 - * Hitachi 88 - */ 89 - { "HITACHI_DK14FA-20" , NULL }, 90 - { "HTS726060M9AT00" , NULL }, 91 - /* 92 - * Maxtor 93 - */ 94 - { "Maxtor 6E040L0" , NULL }, 95 - { "Maxtor 6Y080P0" , NULL }, 96 - { "Maxtor 6Y160P0" , NULL }, 97 - /* 98 - * Seagate 99 - */ 100 - { "ST3120026A" , NULL }, 101 - { "ST320014A" , NULL }, 102 - { "ST94011A" , NULL }, 103 - { "ST340016A" , NULL }, 104 - /* 105 - * Western Digital 106 - */ 107 - { "WDC WD400UE-00HCT0" , NULL }, 108 - { "WDC WD400JB-00JJC0" , NULL }, 109 - { NULL , NULL } 110 - }; 111 - 112 - /* HD black list */ 113 - static const struct drive_list_entry dma_black_list [] = { 114 - /* 115 - * Western Digital 116 - */ 117 - { "WDC WD100EB-00CGH0" , NULL }, 118 - { "WDC WD200BB-00AUA1" , NULL }, 119 - { "WDC AC24300L" , NULL }, 120 - { NULL , NULL } 121 - }; 122 - #endif 123 83 124 84 /******************************************************************************* 125 85 * PIO Mode timing calculation : *
+62 -47
include/linux/ide.h
··· 387 387 388 388 struct ide_port_info; 389 389 390 + struct ide_port_ops { 391 + /* host specific initialization of devices on a port */ 392 + void (*port_init_devs)(struct hwif_s *); 393 + /* routine to program host for PIO mode */ 394 + void (*set_pio_mode)(ide_drive_t *, const u8); 395 + /* routine to program host for DMA mode */ 396 + void (*set_dma_mode)(ide_drive_t *, const u8); 397 + /* tweaks hardware to select drive */ 398 + void (*selectproc)(ide_drive_t *); 399 + /* chipset polling based on hba specifics */ 400 + int (*reset_poll)(ide_drive_t *); 401 + /* chipset specific changes to default for device-hba resets */ 402 + void (*pre_reset)(ide_drive_t *); 403 + /* routine to reset controller after a disk reset */ 404 + void (*resetproc)(ide_drive_t *); 405 + /* special host masking for drive selection */ 406 + void (*maskproc)(ide_drive_t *, int); 407 + /* check host's drive quirk list */ 408 + void (*quirkproc)(ide_drive_t *); 409 + 410 + u8 (*mdma_filter)(ide_drive_t *); 411 + u8 (*udma_filter)(ide_drive_t *); 412 + 413 + u8 (*cable_detect)(struct hwif_s *); 414 + }; 415 + 416 + struct ide_dma_ops { 417 + void (*dma_host_set)(struct ide_drive_s *, int); 418 + int (*dma_setup)(struct ide_drive_s *); 419 + void (*dma_exec_cmd)(struct ide_drive_s *, u8); 420 + void (*dma_start)(struct ide_drive_s *); 421 + int (*dma_end)(struct ide_drive_s *); 422 + int (*dma_test_irq)(struct ide_drive_s *); 423 + void (*dma_lost_irq)(struct ide_drive_s *); 424 + void (*dma_timeout)(struct ide_drive_s *); 425 + }; 426 + 390 427 typedef struct hwif_s { 391 428 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 392 429 struct hwif_s *mate; /* other hwif from same PCI chip */ ··· 457 420 458 421 struct device *dev; 459 422 460 - const struct ide_port_info *cds; /* chipset device struct */ 461 - 462 423 ide_ack_intr_t *ack_intr; 463 424 464 425 void (*rw_disk)(ide_drive_t *, struct request *); 465 426 466 - #if 0 467 - ide_hwif_ops_t *hwifops; 468 - #else 469 - /* host specific initialization of devices on a port */ 470 - void (*port_init_devs)(struct hwif_s *); 471 - /* routine to program host for PIO mode */ 472 - void (*set_pio_mode)(ide_drive_t *, const u8); 473 - /* routine to program host for DMA mode */ 474 - void (*set_dma_mode)(ide_drive_t *, const u8); 475 - /* tweaks hardware to select drive */ 476 - void (*selectproc)(ide_drive_t *); 477 - /* chipset polling based on hba specifics */ 478 - int (*reset_poll)(ide_drive_t *); 479 - /* chipset specific changes to default for device-hba resets */ 480 - void (*pre_reset)(ide_drive_t *); 481 - /* routine to reset controller after a disk reset */ 482 - void (*resetproc)(ide_drive_t *); 483 - /* special host masking for drive selection */ 484 - void (*maskproc)(ide_drive_t *, int); 485 - /* check host's drive quirk list */ 486 - void (*quirkproc)(ide_drive_t *); 487 - #endif 488 - u8 (*mdma_filter)(ide_drive_t *); 489 - u8 (*udma_filter)(ide_drive_t *); 490 - 491 - u8 (*cable_detect)(struct hwif_s *); 427 + const struct ide_port_ops *port_ops; 428 + const struct ide_dma_ops *dma_ops; 492 429 493 430 void (*ata_input_data)(ide_drive_t *, void *, u32); 494 431 void (*ata_output_data)(ide_drive_t *, void *, u32); ··· 470 459 void (*atapi_input_bytes)(ide_drive_t *, void *, u32); 471 460 void (*atapi_output_bytes)(ide_drive_t *, void *, u32); 472 461 473 - void (*dma_host_set)(ide_drive_t *, int); 474 - int (*dma_setup)(ide_drive_t *); 475 - void (*dma_exec_cmd)(ide_drive_t *, u8); 476 - void (*dma_start)(ide_drive_t *); 477 - int (*ide_dma_end)(ide_drive_t *drive); 478 - int (*ide_dma_test_irq)(ide_drive_t *drive); 479 462 void (*ide_dma_clear_irq)(ide_drive_t *drive); 480 - void (*dma_lost_irq)(ide_drive_t *drive); 481 - void (*dma_timeout)(ide_drive_t *drive); 482 463 483 464 void (*OUTB)(u8 addr, unsigned long port); 484 465 void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port); ··· 517 514 unsigned long extra_base; /* extra addr for dma ports */ 518 515 unsigned extra_ports; /* number of extra dma ports */ 519 516 520 - unsigned noprobe : 1; /* don't probe for this interface */ 521 517 unsigned present : 1; /* this interface exists */ 522 518 unsigned serialized : 1; /* serialized all channel operation */ 523 519 unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ ··· 1011 1009 void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); 1012 1010 1013 1011 #ifdef CONFIG_BLK_DEV_IDEDMA_PCI 1014 - void ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); 1012 + int ide_pci_set_master(struct pci_dev *, const char *); 1013 + unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *); 1014 + int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); 1015 1015 #else 1016 - static inline void ide_hwif_setup_dma(ide_hwif_t *hwif, 1017 - const struct ide_port_info *d) { } 1016 + static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, 1017 + const struct ide_port_info *d) 1018 + { 1019 + return -EINVAL; 1020 + } 1018 1021 #endif 1019 1022 1020 1023 extern void default_hwif_iops(ide_hwif_t *); ··· 1091 1084 /* unmask IRQs */ 1092 1085 IDE_HFLAG_UNMASK_IRQS = (1 << 25), 1093 1086 IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26), 1087 + /* serialize ports if DMA is possible (for sl82c105) */ 1088 + IDE_HFLAG_SERIALIZE_DMA = (1 << 27), 1094 1089 /* force host out of "simplex" mode */ 1095 1090 IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28), 1096 1091 /* DSC overlap is unsupported */ ··· 1114 1105 unsigned int (*init_chipset)(struct pci_dev *, const char *); 1115 1106 void (*init_iops)(ide_hwif_t *); 1116 1107 void (*init_hwif)(ide_hwif_t *); 1117 - void (*init_dma)(ide_hwif_t *, unsigned long); 1108 + int (*init_dma)(ide_hwif_t *, 1109 + const struct ide_port_info *); 1110 + 1111 + const struct ide_port_ops *port_ops; 1112 + const struct ide_dma_ops *dma_ops; 1113 + 1118 1114 ide_pci_enablebit_t enablebits[2]; 1119 1115 hwif_chipset_t chipset; 1120 - u8 extra; 1121 1116 u32 host_flags; 1122 1117 u8 pio_mask; 1123 1118 u8 swdma_mask; ··· 1168 1155 1169 1156 #ifdef CONFIG_BLK_DEV_IDEDMA_SFF 1170 1157 extern int ide_build_dmatable(ide_drive_t *, struct request *); 1171 - extern int ide_release_dma(ide_hwif_t *); 1172 - extern void ide_setup_dma(ide_hwif_t *, unsigned long); 1158 + int ide_allocate_dma_engine(ide_hwif_t *); 1159 + void ide_release_dma_engine(ide_hwif_t *); 1160 + void ide_setup_dma(ide_hwif_t *, unsigned long); 1173 1161 1174 1162 void ide_dma_host_set(ide_drive_t *, int); 1175 1163 extern int ide_dma_setup(ide_drive_t *); 1164 + void ide_dma_exec_cmd(ide_drive_t *, u8); 1176 1165 extern void ide_dma_start(ide_drive_t *); 1177 1166 extern int __ide_dma_end(ide_drive_t *); 1167 + int ide_dma_test_irq(ide_drive_t *); 1178 1168 extern void ide_dma_lost_irq(ide_drive_t *); 1179 1169 extern void ide_dma_timeout(ide_drive_t *); 1180 1170 #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ ··· 1195 1179 #endif /* CONFIG_BLK_DEV_IDEDMA */ 1196 1180 1197 1181 #ifndef CONFIG_BLK_DEV_IDEDMA_SFF 1198 - static inline void ide_release_dma(ide_hwif_t *drive) {;} 1182 + static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } 1199 1183 #endif 1200 1184 1201 1185 #ifdef CONFIG_BLK_DEV_IDEACPI ··· 1215 1199 #endif 1216 1200 1217 1201 void ide_remove_port_from_hwgroup(ide_hwif_t *); 1218 - extern int ide_hwif_request_regions(ide_hwif_t *hwif); 1219 - extern void ide_hwif_release_regions(ide_hwif_t* hwif); 1220 1202 void ide_unregister(unsigned int); 1221 1203 1222 1204 void ide_register_region(struct gendisk *); ··· 1224 1210 1225 1211 int ide_device_add_all(u8 *idx, const struct ide_port_info *); 1226 1212 int ide_device_add(u8 idx[4], const struct ide_port_info *); 1213 + int ide_legacy_device_add(const struct ide_port_info *, unsigned long); 1227 1214 void ide_port_unregister_devices(ide_hwif_t *); 1228 1215 void ide_port_scan(ide_hwif_t *); 1229 1216