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: (66 commits)
ata: Add documentation for hard disk shock protection interface (v3)
ide: Implement disk shock protection support (v4)
ide-cd: fix printk format warning
piix: add Hercules EC-900 mini-notebook to ich_laptop short cable list
ide-atapi: assign taskfile flags per device type
ide-cd: move cdrom_info.dma to ide_drive_t.dma
ide: add ide_drive_t.dma flag
ide-cd: add a debug_mask module parameter
ide-cd: convert driver to new ide debugging macro (v3)
ide: move SFF DMA code to ide-dma-sff.c
ide: cleanup ide-dma.c
ide: cleanup ide_build_dmatable()
ide: remove needless includes from ide-dma.c
ide: switch to DMA-mapping API part #2
ide: make ide_dma_timeout() available also for CONFIG_BLK_DEV_IDEDMA_SFF=n
ide: make ide_dma_lost_irq() available also for CONFIG_BLK_DEV_IDEDMA_SFF=n
ide: __ide_dma_end() -> ide_dma_end()
pmac: remove needless pmac_ide_destroy_dmatable() wrapper
pmac: remove superfluous pmif == NULL checks
ide: Two fixes regarding memory allocation
...

+3127 -3045
+149
Documentation/laptops/disk-shock-protection.txt
··· 1 + Hard disk shock protection 2 + ========================== 3 + 4 + Author: Elias Oltmanns <eo@nebensachen.de> 5 + Last modified: 2008-10-03 6 + 7 + 8 + 0. Contents 9 + ----------- 10 + 11 + 1. Intro 12 + 2. The interface 13 + 3. References 14 + 4. CREDITS 15 + 16 + 17 + 1. Intro 18 + -------- 19 + 20 + ATA/ATAPI-7 specifies the IDLE IMMEDIATE command with unload feature. 21 + Issuing this command should cause the drive to switch to idle mode and 22 + unload disk heads. This feature is being used in modern laptops in 23 + conjunction with accelerometers and appropriate software to implement 24 + a shock protection facility. The idea is to stop all I/O operations on 25 + the internal hard drive and park its heads on the ramp when critical 26 + situations are anticipated. The desire to have such a feature 27 + available on GNU/Linux systems has been the original motivation to 28 + implement a generic disk head parking interface in the Linux kernel. 29 + Please note, however, that other components have to be set up on your 30 + system in order to get disk shock protection working (see 31 + section 3. References below for pointers to more information about 32 + that). 33 + 34 + 35 + 2. The interface 36 + ---------------- 37 + 38 + For each ATA device, the kernel exports the file 39 + block/*/device/unload_heads in sysfs (here assumed to be mounted under 40 + /sys). Access to /sys/block/*/device/unload_heads is denied with 41 + -EOPNOTSUPP if the device does not support the unload feature. 42 + Otherwise, writing an integer value to this file will take the heads 43 + of the respective drive off the platter and block all I/O operations 44 + for the specified number of milliseconds. When the timeout expires and 45 + no further disk head park request has been issued in the meantime, 46 + normal operation will be resumed. The maximal value accepted for a 47 + timeout is 30000 milliseconds. Exceeding this limit will return 48 + -EOVERFLOW, but heads will be parked anyway and the timeout will be 49 + set to 30 seconds. However, you can always change a timeout to any 50 + value between 0 and 30000 by issuing a subsequent head park request 51 + before the timeout of the previous one has expired. In particular, the 52 + total timeout can exceed 30 seconds and, more importantly, you can 53 + cancel a previously set timeout and resume normal operation 54 + immediately by specifying a timeout of 0. Values below -2 are rejected 55 + with -EINVAL (see below for the special meaning of -1 and -2). If the 56 + timeout specified for a recent head park request has not yet expired, 57 + reading from /sys/block/*/device/unload_heads will report the number 58 + of milliseconds remaining until normal operation will be resumed; 59 + otherwise, reading the unload_heads attribute will return 0. 60 + 61 + For example, do the following in order to park the heads of drive 62 + /dev/sda and stop all I/O operations for five seconds: 63 + 64 + # echo 5000 > /sys/block/sda/device/unload_heads 65 + 66 + A simple 67 + 68 + # cat /sys/block/sda/device/unload_heads 69 + 70 + will show you how many milliseconds are left before normal operation 71 + will be resumed. 72 + 73 + A word of caution: The fact that the interface operates on a basis of 74 + milliseconds may raise expectations that cannot be satisfied in 75 + reality. In fact, the ATA specs clearly state that the time for an 76 + unload operation to complete is vendor specific. The hint in ATA-7 77 + that this will typically be within 500 milliseconds apparently has 78 + been dropped in ATA-8. 79 + 80 + There is a technical detail of this implementation that may cause some 81 + confusion and should be discussed here. When a head park request has 82 + been issued to a device successfully, all I/O operations on the 83 + controller port this device is attached to will be deferred. That is 84 + to say, any other device that may be connected to the same port will 85 + be affected too. The only exception is that a subsequent head unload 86 + request to that other device will be executed immediately. Further 87 + operations on that port will be deferred until the timeout specified 88 + for either device on the port has expired. As far as PATA (old style 89 + IDE) configurations are concerned, there can only be two devices 90 + attached to any single port. In SATA world we have port multipliers 91 + which means that a user-issued head parking request to one device may 92 + actually result in stopping I/O to a whole bunch of devices. However, 93 + since this feature is supposed to be used on laptops and does not seem 94 + to be very useful in any other environment, there will be mostly one 95 + device per port. Even if the CD/DVD writer happens to be connected to 96 + the same port as the hard drive, it generally *should* recover just 97 + fine from the occasional buffer under-run incurred by a head park 98 + request to the HD. Actually, when you are using an ide driver rather 99 + than its libata counterpart (i.e. your disk is called /dev/hda 100 + instead of /dev/sda), then parking the heads of one drive (drive X) 101 + will generally not affect the mode of operation of another drive 102 + (drive Y) on the same port as described above. It is only when a port 103 + reset is required to recover from an exception on drive Y that further 104 + I/O operations on that drive (and the reset itself) will be delayed 105 + until drive X is no longer in the parked state. 106 + 107 + Finally, there are some hard drives that only comply with an earlier 108 + version of the ATA standard than ATA-7, but do support the unload 109 + feature nonetheless. Unfortunately, there is no safe way Linux can 110 + detect these devices, so you won't be able to write to the 111 + unload_heads attribute. If you know that your device really does 112 + support the unload feature (for instance, because the vendor of your 113 + laptop or the hard drive itself told you so), then you can tell the 114 + kernel to enable the usage of this feature for that drive by writing 115 + the special value -1 to the unload_heads attribute: 116 + 117 + # echo -1 > /sys/block/sda/device/unload_heads 118 + 119 + will enable the feature for /dev/sda, and giving -2 instead of -1 will 120 + disable it again. 121 + 122 + 123 + 3. References 124 + ------------- 125 + 126 + There are several laptops from different vendors featuring shock 127 + protection capabilities. As manufacturers have refused to support open 128 + source development of the required software components so far, Linux 129 + support for shock protection varies considerably between different 130 + hardware implementations. Ideally, this section should contain a list 131 + of pointers at different projects aiming at an implementation of shock 132 + protection on different systems. Unfortunately, I only know of a 133 + single project which, although still considered experimental, is fit 134 + for use. Please feel free to add projects that have been the victims 135 + of my ignorance. 136 + 137 + - http://www.thinkwiki.org/wiki/HDAPS 138 + See this page for information about Linux support of the hard disk 139 + active protection system as implemented in IBM/Lenovo Thinkpads. 140 + 141 + 142 + 4. CREDITS 143 + ---------- 144 + 145 + This implementation of disk head parking has been inspired by a patch 146 + originally published by Jon Escombe <lists@dresco.co.uk>. My efforts 147 + to develop an implementation of this feature that is fit to be merged 148 + into mainline have been aided by various kernel developers, in 149 + particular by Tejun Heo and Bartlomiej Zolnierkiewicz.
-29
arch/mips/include/asm/mach-generic/ide.h
··· 19 19 #include <linux/stddef.h> 20 20 #include <asm/processor.h> 21 21 22 - static __inline__ int ide_probe_legacy(void) 23 - { 24 - #ifdef CONFIG_PCI 25 - struct pci_dev *dev; 26 - /* 27 - * This can be called on the ide_setup() path, super-early in 28 - * boot. But the down_read() will enable local interrupts, 29 - * which can cause some machines to crash. So here we detect 30 - * and flag that situation and bail out early. 31 - */ 32 - if (no_pci_devices()) 33 - return 0; 34 - dev = pci_get_class(PCI_CLASS_BRIDGE_EISA << 8, NULL); 35 - if (dev) 36 - goto found; 37 - dev = pci_get_class(PCI_CLASS_BRIDGE_ISA << 8, NULL); 38 - if (dev) 39 - goto found; 40 - return 0; 41 - found: 42 - pci_dev_put(dev); 43 - return 1; 44 - #elif defined(CONFIG_EISA) || defined(CONFIG_ISA) 45 - return 1; 46 - #else 47 - return 0; 48 - #endif 49 - } 50 - 51 22 /* MIPS port and memory-mapped I/O string operations. */ 52 23 static inline void __ide_flush_prologue(void) 53 24 {
-5
arch/xtensa/kernel/setup.c
··· 53 53 struct fd_ops *fd_ops; 54 54 #endif 55 55 56 - #if defined(CONFIG_BLK_DEV_IDE) || defined(CONFIG_BLK_DEV_IDE_MODULE) 57 - extern struct ide_ops no_ide_ops; 58 - struct ide_ops *ide_ops; 59 - #endif 60 - 61 56 extern struct rtc_ops no_rtc_ops; 62 57 struct rtc_ops *rtc_ops; 63 58
+2 -36
drivers/ide/Kconfig
··· 54 54 55 55 if IDE 56 56 57 - config BLK_DEV_IDE 58 - tristate "Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support" 59 - ---help--- 60 - If you say Y here, you will use the full-featured IDE driver to 61 - control up to ten ATA/IDE interfaces, each being able to serve a 62 - "master" and a "slave" device, for a total of up to twenty ATA/IDE 63 - disk/cdrom/tape/floppy drives. 64 - 65 - Useful information about large (>540 MB) IDE disks, multiple 66 - interfaces, what to do if ATA/IDE devices are not automatically 67 - detected, sound card ATA/IDE ports, module support, and other 68 - topics, is contained in <file:Documentation/ide/ide.txt>. For detailed 69 - information about hard drives, consult the Disk-HOWTO and the 70 - Multi-Disk-HOWTO, available from 71 - <http://www.tldp.org/docs.html#howto>. 72 - 73 - To fine-tune ATA/IDE drive/interface parameters for improved 74 - performance, look for the hdparm package at 75 - <ftp://ibiblio.org/pub/Linux/system/hardware/>. 76 - 77 - To compile this driver as a module, choose M here and read 78 - <file:Documentation/ide/ide.txt>. The module will be called ide-mod. 79 - Do not compile this driver as a module if your root file system (the 80 - one containing the directory /) is located on an IDE device. 81 - 82 - If you have one or more IDE drives, say Y or M here. If your system 83 - has no IDE drives, or if memory requirements are really tight, you 84 - could say N here, and select the "Old hard disk driver" below 85 - instead to save about 13 KB of memory in the kernel. 86 - 87 - if BLK_DEV_IDE 88 - 89 57 comment "Please see Documentation/ide/ide.txt for help/info on IDE drives" 90 58 91 59 config IDE_TIMINGS ··· 316 348 317 349 config IDEPCI_PCIBUS_ORDER 318 350 bool "Probe IDE PCI devices in the PCI bus order (DEPRECATED)" 319 - depends on BLK_DEV_IDE=y && BLK_DEV_IDEPCI 351 + depends on IDE=y && BLK_DEV_IDEPCI 320 352 default y 321 353 help 322 354 Probe IDE PCI devices in the order in which they appear on the ··· 697 729 698 730 config BLK_DEV_IDE_PMAC 699 731 tristate "PowerMac on-board IDE support" 700 - depends on PPC_PMAC && IDE=y && BLK_DEV_IDE=y 732 + depends on PPC_PMAC && IDE=y 701 733 select IDE_TIMINGS 702 734 help 703 735 This driver provides support for the on-board IDE controller on ··· 930 962 config BLK_DEV_IDEDMA 931 963 def_bool BLK_DEV_IDEDMA_SFF || BLK_DEV_IDEDMA_PMAC || \ 932 964 BLK_DEV_IDEDMA_ICS || BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 933 - 934 - endif 935 965 936 966 endif # IDE
+13 -6
drivers/ide/Makefile
··· 5 5 EXTRA_CFLAGS += -Idrivers/ide 6 6 7 7 ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ 8 - ide-taskfile.o ide-pio-blacklist.o 8 + ide-taskfile.o ide-park.o ide-pio-blacklist.o 9 9 10 10 # core IDE code 11 11 ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o 12 12 ide-core-$(CONFIG_IDE_ATAPI) += ide-atapi.o 13 13 ide-core-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o 14 14 ide-core-$(CONFIG_BLK_DEV_IDEDMA) += ide-dma.o 15 + ide-core-$(CONFIG_BLK_DEV_IDEDMA_SFF) += ide-dma-sff.o 15 16 ide-core-$(CONFIG_IDE_PROC_FS) += ide-proc.o 16 17 ide-core-$(CONFIG_BLK_DEV_IDEACPI) += ide-acpi.o 17 18 18 - obj-$(CONFIG_BLK_DEV_IDE) += ide-core.o 19 + obj-$(CONFIG_IDE) += ide-core.o 19 20 20 21 ifeq ($(CONFIG_IDE_ARM), y) 21 22 ide-arm-core-y += arm/ide_arm.o 22 23 obj-y += ide-arm-core.o 23 24 endif 24 25 25 - obj-$(CONFIG_BLK_DEV_IDE) += legacy/ pci/ 26 + obj-$(CONFIG_IDE) += legacy/ pci/ 26 27 27 28 obj-$(CONFIG_IDEPCI_PCIBUS_ORDER) += ide-scan-pci.o 28 29 ··· 32 31 obj-y += cmd640-core.o 33 32 endif 34 33 35 - obj-$(CONFIG_BLK_DEV_IDE) += ppc/ 34 + obj-$(CONFIG_IDE) += ppc/ 36 35 obj-$(CONFIG_IDE_H8300) += h8300/ 37 36 obj-$(CONFIG_IDE_GENERIC) += ide-generic.o 38 37 obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o 39 38 39 + ide-disk_mod-y += ide-disk.o ide-disk_ioctl.o 40 40 ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o 41 41 ide-floppy_mod-y += ide-floppy.o ide-floppy_ioctl.o 42 42 43 - obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o 43 + ifeq ($(CONFIG_IDE_PROC_FS), y) 44 + ide-disk_mod-y += ide-disk_proc.o 45 + ide-floppy_mod-y += ide-floppy_proc.o 46 + endif 47 + 48 + obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk_mod.o 44 49 obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o 45 50 obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy_mod.o 46 51 obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o ··· 61 54 obj-y += ide-platform-core.o 62 55 endif 63 56 64 - obj-$(CONFIG_BLK_DEV_IDE) += arm/ mips/ 57 + obj-$(CONFIG_IDE) += arm/ mips/
+2 -21
drivers/ide/arm/icside.c
··· 372 372 ICS_ARCIN_V6_INTRSTAT_1)) & 1; 373 373 } 374 374 375 - static void icside_dma_timeout(ide_drive_t *drive) 376 - { 377 - ide_hwif_t *hwif = drive->hwif; 378 - 379 - printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name); 380 - 381 - if (icside_dma_test_irq(drive)) 382 - return; 383 - 384 - ide_dump_status(drive, "DMA timeout", hwif->tp_ops->read_status(hwif)); 385 - 386 - icside_dma_end(drive); 387 - } 388 - 389 - static void icside_dma_lost_irq(ide_drive_t *drive) 390 - { 391 - printk(KERN_ERR "%s: IRQ lost\n", drive->name); 392 - } 393 - 394 375 static int icside_dma_init(ide_hwif_t *hwif, const struct ide_port_info *d) 395 376 { 396 377 hwif->dmatable_cpu = NULL; ··· 387 406 .dma_start = icside_dma_start, 388 407 .dma_end = icside_dma_end, 389 408 .dma_test_irq = icside_dma_test_irq, 390 - .dma_timeout = icside_dma_timeout, 391 - .dma_lost_irq = icside_dma_lost_irq, 409 + .dma_timeout = ide_dma_timeout, 410 + .dma_lost_irq = ide_dma_lost_irq, 392 411 }; 393 412 #else 394 413 #define icside_v6_dma_ops NULL
+1 -1
drivers/ide/h8300/ide-h8300.c
··· 80 80 outb(tf->lbah, io_ports->lbah_addr); 81 81 82 82 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) 83 - outb((tf->device & HIHI) | drive->select.all, 83 + outb((tf->device & HIHI) | drive->select, 84 84 io_ports->device_addr); 85 85 } 86 86
+7 -5
drivers/ide/ide-acpi.c
··· 290 290 DEBPRINT("ENTER: %s at %s, port#: %d, hard_port#: %d\n", 291 291 hwif->name, dev->bus_id, port, hwif->channel); 292 292 293 - if (!drive->present) { 293 + if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) { 294 294 DEBPRINT("%s drive %d:%d not present\n", 295 295 hwif->name, hwif->channel, port); 296 296 goto out; ··· 420 420 421 421 DEBPRINT("ENTER: %s, hard_port#: %d\n", drive->name, drive->dn); 422 422 423 - if (!drive->present) 423 + if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 424 424 goto out; 425 + 425 426 if (!gtf_count) /* shouldn't be here */ 426 427 goto out; 427 428 ··· 661 660 if (!drive->acpidata->obj_handle) 662 661 drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive); 663 662 664 - if (drive->acpidata->obj_handle && drive->present) { 663 + if (drive->acpidata->obj_handle && 664 + (drive->dev_flags & IDE_DFLAG_PRESENT)) { 665 665 acpi_bus_set_power(drive->acpidata->obj_handle, 666 666 on? ACPI_STATE_D0: ACPI_STATE_D3); 667 667 } ··· 722 720 723 721 memset(drive->acpidata, 0, sizeof(*drive->acpidata)); 724 722 725 - if (!drive->present) 723 + if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 726 724 continue; 727 725 728 726 err = taskfile_lib_get_identify(drive, drive->acpidata->idbuff); ··· 747 745 for (i = 0; i < MAX_DRIVES; i++) { 748 746 drive = &hwif->drives[i]; 749 747 750 - if (drive->present) 748 + if (drive->dev_flags & IDE_DFLAG_PRESENT) 751 749 /* Execute ACPI startup code */ 752 750 ide_acpi_exec_tfs(drive); 753 751 }
+135 -48
drivers/ide/ide-atapi.c
··· 124 124 * the current request, so that it will be processed immediately, on the next 125 125 * pass through the driver. 126 126 */ 127 - void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk, 128 - struct ide_atapi_pc *pc, struct request *rq) 127 + static void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk, 128 + struct ide_atapi_pc *pc, struct request *rq) 129 129 { 130 130 blk_rq_init(NULL, rq); 131 131 rq->cmd_type = REQ_TYPE_SPECIAL; ··· 137 137 rq->cmd[13] = REQ_IDETAPE_PC1; 138 138 ide_do_drive_cmd(drive, rq); 139 139 } 140 - EXPORT_SYMBOL_GPL(ide_queue_pc_head); 141 140 142 141 /* 143 142 * Add a special packet command request to the tail of the request queue, ··· 202 203 } 203 204 EXPORT_SYMBOL_GPL(ide_set_media_lock); 204 205 205 - /* TODO: unify the code thus making some arguments go away */ 206 - ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, 207 - ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, 208 - void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), 209 - void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), 210 - int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) 206 + void ide_create_request_sense_cmd(ide_drive_t *drive, struct ide_atapi_pc *pc) 211 207 { 208 + ide_init_pc(pc); 209 + pc->c[0] = REQUEST_SENSE; 210 + if (drive->media == ide_floppy) { 211 + pc->c[4] = 255; 212 + pc->req_xfer = 18; 213 + } else { 214 + pc->c[4] = 20; 215 + pc->req_xfer = 20; 216 + } 217 + } 218 + EXPORT_SYMBOL_GPL(ide_create_request_sense_cmd); 219 + 220 + /* 221 + * Called when an error was detected during the last packet command. 222 + * We queue a request sense packet command in the head of the request list. 223 + */ 224 + void ide_retry_pc(ide_drive_t *drive, struct gendisk *disk) 225 + { 226 + struct request *rq = &drive->request_sense_rq; 227 + struct ide_atapi_pc *pc = &drive->request_sense_pc; 228 + 229 + (void)ide_read_error(drive); 230 + ide_create_request_sense_cmd(drive, pc); 231 + if (drive->media == ide_tape) 232 + set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 233 + ide_queue_pc_head(drive, disk, pc, rq); 234 + } 235 + EXPORT_SYMBOL_GPL(ide_retry_pc); 236 + 237 + int ide_scsi_expiry(ide_drive_t *drive) 238 + { 239 + struct ide_atapi_pc *pc = drive->pc; 240 + 241 + debug_log("%s called for %lu at %lu\n", __func__, 242 + pc->scsi_cmd->serial_number, jiffies); 243 + 244 + pc->flags |= PC_FLAG_TIMEDOUT; 245 + 246 + return 0; /* we do not want the IDE subsystem to retry */ 247 + } 248 + EXPORT_SYMBOL_GPL(ide_scsi_expiry); 249 + 250 + /* 251 + * This is the usual interrupt handler which will be called during a packet 252 + * command. We will transfer some of the data (as requested by the drive) 253 + * and will re-point interrupt handler to us. 254 + */ 255 + static ide_startstop_t ide_pc_intr(ide_drive_t *drive) 256 + { 257 + struct ide_atapi_pc *pc = drive->pc; 212 258 ide_hwif_t *hwif = drive->hwif; 213 259 struct request *rq = hwif->hwgroup->rq; 214 260 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 215 261 xfer_func_t *xferfunc; 216 - unsigned int temp; 262 + ide_expiry_t *expiry; 263 + unsigned int timeout, temp; 217 264 u16 bcount; 218 - u8 stat, ireason, scsi = drive->scsi; 265 + u8 stat, ireason, scsi = !!(drive->dev_flags & IDE_DFLAG_SCSI), dsc = 0; 219 266 220 267 debug_log("Enter %s - interrupt handler\n", __func__); 221 268 269 + if (scsi) { 270 + timeout = ide_scsi_get_timeout(pc); 271 + expiry = ide_scsi_expiry; 272 + } else { 273 + timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD 274 + : WAIT_TAPE_CMD; 275 + expiry = NULL; 276 + } 277 + 222 278 if (pc->flags & PC_FLAG_TIMEDOUT) { 223 - drive->pc_callback(drive); 279 + drive->pc_callback(drive, 0); 224 280 return ide_stopped; 225 281 } 226 282 ··· 292 238 pc->flags |= PC_FLAG_DMA_ERROR; 293 239 } else { 294 240 pc->xferred = pc->req_xfer; 295 - if (update_buffers) 296 - update_buffers(drive, pc); 241 + if (drive->pc_update_buffers) 242 + drive->pc_update_buffers(drive, pc); 297 243 } 298 244 debug_log("%s: DMA finished\n", drive->name); 299 245 } ··· 330 276 debug_log("[cmd %x]: check condition\n", rq->cmd[0]); 331 277 332 278 /* Retry operation */ 333 - retry_pc(drive); 279 + ide_retry_pc(drive, rq->rq_disk); 334 280 335 281 /* queued, but not started */ 336 282 return ide_stopped; 337 283 } 338 284 cmd_finished: 339 285 pc->error = 0; 340 - if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && 341 - (stat & ATA_DSC) == 0) { 342 - dsc_handle(drive); 343 - return ide_stopped; 344 - } 286 + 287 + if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && (stat & ATA_DSC) == 0) 288 + dsc = 1; 345 289 346 290 /* Command finished - Call the callback function */ 347 - drive->pc_callback(drive); 291 + drive->pc_callback(drive, dsc); 348 292 349 293 return ide_stopped; 350 294 } ··· 388 336 temp = 0; 389 337 if (temp) { 390 338 if (pc->sg) 391 - io_buffers(drive, pc, temp, 0); 339 + drive->pc_io_buffers(drive, pc, 340 + temp, 0); 392 341 else 393 342 tp_ops->input_data(drive, NULL, 394 343 pc->cur_pos, temp); ··· 401 348 pc->xferred += temp; 402 349 pc->cur_pos += temp; 403 350 ide_pad_transfer(drive, 0, bcount - temp); 404 - ide_set_handler(drive, handler, timeout, 405 - expiry); 406 - return ide_started; 351 + goto next_irq; 407 352 } 408 353 debug_log("The device wants to send us more data than " 409 354 "expected - allowing transfer\n"); ··· 413 362 if ((drive->media == ide_floppy && !scsi && !pc->buf) || 414 363 (drive->media == ide_tape && !scsi && pc->bh) || 415 364 (scsi && pc->sg)) { 416 - int done = io_buffers(drive, pc, bcount, 365 + int done = drive->pc_io_buffers(drive, pc, bcount, 417 366 !!(pc->flags & PC_FLAG_WRITING)); 418 367 419 368 /* FIXME: don't do partial completions */ ··· 428 377 429 378 debug_log("[cmd %x] transferred %d bytes on that intr.\n", 430 379 rq->cmd[0], bcount); 431 - 380 + next_irq: 432 381 /* And set the interrupt handler again */ 433 - ide_set_handler(drive, handler, timeout, expiry); 382 + ide_set_handler(drive, ide_pc_intr, timeout, expiry); 434 383 return ide_started; 435 384 } 436 - EXPORT_SYMBOL_GPL(ide_pc_intr); 437 385 438 386 static u8 ide_read_ireason(ide_drive_t *drive) 439 387 { ··· 468 418 return ireason; 469 419 } 470 420 471 - ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, 472 - ide_handler_t *handler, unsigned int timeout, 473 - ide_expiry_t *expiry) 421 + static int ide_delayed_transfer_pc(ide_drive_t *drive) 474 422 { 423 + /* Send the actual packet */ 424 + drive->hwif->tp_ops->output_data(drive, NULL, drive->pc->c, 12); 425 + 426 + /* Timeout for the packet command */ 427 + return WAIT_FLOPPY_CMD; 428 + } 429 + 430 + static ide_startstop_t ide_transfer_pc(ide_drive_t *drive) 431 + { 432 + struct ide_atapi_pc *pc = drive->pc; 475 433 ide_hwif_t *hwif = drive->hwif; 476 434 struct request *rq = hwif->hwgroup->rq; 435 + ide_expiry_t *expiry; 436 + unsigned int timeout; 477 437 ide_startstop_t startstop; 478 438 u8 ireason; 479 439 ··· 494 434 } 495 435 496 436 ireason = ide_read_ireason(drive); 497 - if (drive->media == ide_tape && !drive->scsi) 437 + if (drive->media == ide_tape && 438 + (drive->dev_flags & IDE_DFLAG_SCSI) == 0) 498 439 ireason = ide_wait_ireason(drive, ireason); 499 440 500 441 if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) { ··· 504 443 return ide_do_reset(drive); 505 444 } 506 445 446 + /* 447 + * If necessary schedule the packet transfer to occur 'timeout' 448 + * miliseconds later in ide_delayed_transfer_pc() after the device 449 + * says it's ready for a packet. 450 + */ 451 + if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) { 452 + timeout = drive->pc_delay; 453 + expiry = &ide_delayed_transfer_pc; 454 + } else { 455 + if (drive->dev_flags & IDE_DFLAG_SCSI) { 456 + timeout = ide_scsi_get_timeout(pc); 457 + expiry = ide_scsi_expiry; 458 + } else { 459 + timeout = (drive->media == ide_floppy) ? WAIT_FLOPPY_CMD 460 + : WAIT_TAPE_CMD; 461 + expiry = NULL; 462 + } 463 + } 464 + 507 465 /* Set the interrupt routine */ 508 - ide_set_handler(drive, handler, timeout, expiry); 466 + ide_set_handler(drive, ide_pc_intr, timeout, expiry); 509 467 510 468 /* Begin DMA, if necessary */ 511 469 if (pc->flags & PC_FLAG_DMA_OK) { ··· 538 458 539 459 return ide_started; 540 460 } 541 - EXPORT_SYMBOL_GPL(ide_transfer_pc); 542 461 543 - ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, 544 - ide_handler_t *handler, unsigned int timeout, 462 + ide_startstop_t ide_issue_pc(ide_drive_t *drive, unsigned int timeout, 545 463 ide_expiry_t *expiry) 546 464 { 465 + struct ide_atapi_pc *pc = drive->pc; 547 466 ide_hwif_t *hwif = drive->hwif; 467 + u32 tf_flags; 548 468 u16 bcount; 549 - u8 dma = 0; 469 + u8 scsi = !!(drive->dev_flags & IDE_DFLAG_SCSI); 550 470 551 471 /* We haven't transferred any data yet */ 552 472 pc->xferred = 0; 553 473 pc->cur_pos = pc->buf; 554 474 555 475 /* Request to transfer the entire buffer at once */ 556 - if (drive->media == ide_tape && !drive->scsi) 476 + if (drive->media == ide_tape && scsi == 0) 557 477 bcount = pc->req_xfer; 558 478 else 559 479 bcount = min(pc->req_xfer, 63 * 1024); ··· 563 483 ide_dma_off(drive); 564 484 } 565 485 566 - if ((pc->flags & PC_FLAG_DMA_OK) && drive->using_dma) { 567 - if (drive->scsi) 486 + if ((pc->flags & PC_FLAG_DMA_OK) && 487 + (drive->dev_flags & IDE_DFLAG_USING_DMA)) { 488 + if (scsi) 568 489 hwif->sg_mapped = 1; 569 - dma = !hwif->dma_ops->dma_setup(drive); 570 - if (drive->scsi) 490 + drive->dma = !hwif->dma_ops->dma_setup(drive); 491 + if (scsi) 571 492 hwif->sg_mapped = 0; 572 493 } 573 494 574 - if (!dma) 495 + if (!drive->dma) 575 496 pc->flags &= ~PC_FLAG_DMA_OK; 576 497 577 - ide_pktcmd_tf_load(drive, drive->scsi ? 0 : IDE_TFLAG_OUT_DEVICE, 578 - bcount, dma); 498 + if (scsi) 499 + tf_flags = 0; 500 + else if (drive->media == ide_cdrom || drive->media == ide_optical) 501 + tf_flags = IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL; 502 + else 503 + tf_flags = IDE_TFLAG_OUT_DEVICE; 504 + 505 + ide_pktcmd_tf_load(drive, tf_flags, bcount, drive->dma); 579 506 580 507 /* Issue the packet command */ 581 508 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { 582 - ide_execute_command(drive, ATA_CMD_PACKET, handler, 509 + ide_execute_command(drive, ATA_CMD_PACKET, ide_transfer_pc, 583 510 timeout, NULL); 584 511 return ide_started; 585 512 } else { 586 513 ide_execute_pkt_cmd(drive); 587 - return (*handler)(drive); 514 + return ide_transfer_pc(drive); 588 515 } 589 516 } 590 517 EXPORT_SYMBOL_GPL(ide_issue_pc);
+185 -78
drivers/ide/ide-cd.c
··· 23 23 * Documentation/ide/ChangeLog.ide-cd.1994-2004 24 24 */ 25 25 26 + #define DRV_NAME "ide-cd" 27 + #define PFX DRV_NAME ": " 28 + 26 29 #define IDECD_VERSION "5.00" 27 30 28 31 #include <linux/module.h> ··· 53 50 54 51 #include "ide-cd.h" 55 52 53 + #define IDECD_DEBUG_LOG 1 54 + 55 + #if IDECD_DEBUG_LOG 56 + #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args) 57 + #else 58 + #define ide_debug_log(lvl, fmt, args...) do {} while (0) 59 + #endif 60 + 56 61 static DEFINE_MUTEX(idecd_ref_mutex); 57 - 58 - #define to_ide_cd(obj) container_of(obj, struct cdrom_info, kref) 59 - 60 - #define ide_cd_g(disk) \ 61 - container_of((disk)->private_data, struct cdrom_info, driver) 62 62 63 63 static void ide_cd_release(struct kref *); 64 64 ··· 70 64 struct cdrom_info *cd = NULL; 71 65 72 66 mutex_lock(&idecd_ref_mutex); 73 - cd = ide_cd_g(disk); 67 + cd = ide_drv_g(disk, cdrom_info); 74 68 if (cd) { 75 69 if (ide_device_get(cd->drive)) 76 70 cd = NULL; ··· 107 101 struct request_sense *sense) 108 102 { 109 103 int log = 0; 104 + 105 + ide_debug_log(IDE_DBG_SENSE, "Call %s, sense_key: 0x%x\n", __func__, 106 + sense->sense_key); 110 107 111 108 if (!sense || !rq || (rq->cmd_flags & REQ_QUIET)) 112 109 return 0; ··· 158 149 unsigned long sector; 159 150 unsigned long bio_sectors; 160 151 struct cdrom_info *info = drive->driver_data; 152 + 153 + ide_debug_log(IDE_DBG_SENSE, "Call %s, error_code: 0x%x, " 154 + "sense_key: 0x%x\n", __func__, sense->error_code, 155 + sense->sense_key); 156 + 157 + if (failed_command) 158 + ide_debug_log(IDE_DBG_SENSE, "%s: failed cmd: 0x%x\n", 159 + __func__, failed_command->cmd[0]); 161 160 162 161 if (!cdrom_log_sense(drive, failed_command, sense)) 163 162 return; ··· 217 200 struct cdrom_info *info = drive->driver_data; 218 201 struct request *rq = &info->request_sense_request; 219 202 203 + ide_debug_log(IDE_DBG_SENSE, "Call %s\n", __func__); 204 + 220 205 if (sense == NULL) 221 206 sense = &info->sense_data; 222 207 ··· 238 219 /* NOTE! Save the failed command in "rq->buffer" */ 239 220 rq->buffer = (void *) failed_command; 240 221 222 + if (failed_command) 223 + ide_debug_log(IDE_DBG_SENSE, "failed_cmd: 0x%x\n", 224 + failed_command->cmd[0]); 225 + 241 226 ide_do_drive_cmd(drive, rq); 242 227 } 243 228 ··· 249 226 { 250 227 struct request *rq = HWGROUP(drive)->rq; 251 228 int nsectors = rq->hard_cur_sectors; 229 + 230 + ide_debug_log(IDE_DBG_FUNC, "Call %s, cmd: 0x%x, uptodate: 0x%x, " 231 + "nsectors: %d\n", __func__, rq->cmd[0], uptodate, 232 + nsectors); 252 233 253 234 if (blk_sense_request(rq) && uptodate) { 254 235 /* ··· 296 269 if (!nsectors) 297 270 nsectors = 1; 298 271 272 + ide_debug_log(IDE_DBG_FUNC, "Exit %s, uptodate: 0x%x, nsectors: %d\n", 273 + __func__, uptodate, nsectors); 274 + 299 275 ide_end_request(drive, uptodate, nsectors); 300 276 } 301 277 ··· 334 304 sense_key = err >> 4; 335 305 336 306 if (rq == NULL) { 337 - printk(KERN_ERR "%s: missing rq in %s\n", 307 + printk(KERN_ERR PFX "%s: missing rq in %s\n", 338 308 drive->name, __func__); 339 309 return 1; 340 310 } 311 + 312 + ide_debug_log(IDE_DBG_RQ, "%s: stat: 0x%x, good_stat: 0x%x, " 313 + "rq->cmd_type: 0x%x, err: 0x%x\n", __func__, stat, 314 + good_stat, rq->cmd_type, err); 341 315 342 316 if (blk_sense_request(rq)) { 343 317 /* ··· 408 374 cdrom_saw_media_change(drive); 409 375 410 376 /* fail the request */ 411 - printk(KERN_ERR "%s: tray open\n", drive->name); 377 + printk(KERN_ERR PFX "%s: tray open\n", 378 + drive->name); 412 379 do_end_request = 1; 413 380 } else { 414 381 struct cdrom_info *info = drive->driver_data; ··· 495 460 if (stat & ATA_ERR) 496 461 cdrom_queue_request_sense(drive, NULL, NULL); 497 462 } else { 498 - blk_dump_rq_flags(rq, "ide-cd: bad rq"); 463 + blk_dump_rq_flags(rq, PFX "bad rq"); 499 464 cdrom_end_request(drive, 0); 500 465 } 501 466 ··· 523 488 struct request *rq = HWGROUP(drive)->rq; 524 489 unsigned long wait = 0; 525 490 491 + ide_debug_log(IDE_DBG_RQ, "Call %s: rq->cmd[0]: 0x%x\n", __func__, 492 + rq->cmd[0]); 493 + 526 494 /* 527 495 * Some commands are *slow* and normally take a long time to complete. 528 496 * Usually we can use the ATAPI "disconnect" to bypass this, but not all ··· 542 504 break; 543 505 default: 544 506 if (!(rq->cmd_flags & REQ_QUIET)) 545 - printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", 507 + printk(KERN_INFO PFX "cmd 0x%x timed out\n", 546 508 rq->cmd[0]); 547 509 wait = 0; 548 510 break; ··· 562 524 int xferlen, 563 525 ide_handler_t *handler) 564 526 { 565 - struct cdrom_info *info = drive->driver_data; 566 527 ide_hwif_t *hwif = drive->hwif; 567 528 529 + ide_debug_log(IDE_DBG_PC, "Call %s, xferlen: %d\n", __func__, xferlen); 530 + 568 531 /* FIXME: for Virtual DMA we must check harder */ 569 - if (info->dma) 570 - info->dma = !hwif->dma_ops->dma_setup(drive); 532 + if (drive->dma) 533 + drive->dma = !hwif->dma_ops->dma_setup(drive); 571 534 572 535 /* set up the controller registers */ 573 536 ide_pktcmd_tf_load(drive, IDE_TFLAG_OUT_NSECT | IDE_TFLAG_OUT_LBAL, 574 - xferlen, info->dma); 537 + xferlen, drive->dma); 575 538 576 539 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { 577 540 /* waiting for CDB interrupt, not DMA yet. */ 578 - if (info->dma) 541 + if (drive->dma) 579 542 drive->waiting_for_dma = 0; 580 543 581 544 /* packet command */ ··· 603 564 { 604 565 ide_hwif_t *hwif = drive->hwif; 605 566 int cmd_len; 606 - struct cdrom_info *info = drive->driver_data; 607 567 ide_startstop_t startstop; 568 + 569 + ide_debug_log(IDE_DBG_PC, "Call %s\n", __func__); 608 570 609 571 if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { 610 572 /* ··· 618 578 return ide_stopped; 619 579 620 580 /* ok, next interrupt will be DMA interrupt */ 621 - if (info->dma) 581 + if (drive->dma) 622 582 drive->waiting_for_dma = 1; 623 583 } else { 624 584 /* otherwise, we must wait for DRQ to get set */ ··· 639 599 hwif->tp_ops->output_data(drive, NULL, rq->cmd, cmd_len); 640 600 641 601 /* start the DMA if need be */ 642 - if (info->dma) 602 + if (drive->dma) 643 603 hwif->dma_ops->dma_start(drive); 644 604 645 605 return ide_started; ··· 655 615 { 656 616 ide_hwif_t *hwif = drive->hwif; 657 617 618 + ide_debug_log(IDE_DBG_FUNC, "Call %s, ireason: 0x%x, rw: 0x%x\n", 619 + __func__, ireason, rw); 620 + 658 621 /* 659 622 * ireason == 0: the drive wants to receive data from us 660 623 * ireason == 2: the drive is expecting to transfer data to us ··· 667 624 else if (ireason == (rw << 1)) { 668 625 669 626 /* whoops... */ 670 - printk(KERN_ERR "%s: %s: wrong transfer direction!\n", 627 + printk(KERN_ERR PFX "%s: %s: wrong transfer direction!\n", 671 628 drive->name, __func__); 672 629 673 630 ide_pad_transfer(drive, rw, len); ··· 680 637 return 0; 681 638 } else { 682 639 /* drive wants a command packet, or invalid ireason... */ 683 - printk(KERN_ERR "%s: %s: bad interrupt reason 0x%02x\n", 640 + printk(KERN_ERR PFX "%s: %s: bad interrupt reason 0x%02x\n", 684 641 drive->name, __func__, ireason); 685 642 } 686 643 ··· 697 654 */ 698 655 static int ide_cd_check_transfer_size(ide_drive_t *drive, int len) 699 656 { 657 + ide_debug_log(IDE_DBG_FUNC, "Call %s, len: %d\n", __func__, len); 658 + 700 659 if ((len % SECTOR_SIZE) == 0) 701 660 return 0; 702 661 703 - printk(KERN_ERR "%s: %s: Bad transfer size %d\n", 704 - drive->name, __func__, len); 662 + printk(KERN_ERR PFX "%s: %s: Bad transfer size %d\n", drive->name, 663 + __func__, len); 705 664 706 665 if (drive->atapi_flags & IDE_AFLAG_LIMIT_NFRAMES) 707 - printk(KERN_ERR " This drive is not supported by " 708 - "this version of the driver\n"); 666 + printk(KERN_ERR PFX "This drive is not supported by this " 667 + "version of the driver\n"); 709 668 else { 710 - printk(KERN_ERR " Trying to limit transfer sizes\n"); 669 + printk(KERN_ERR PFX "Trying to limit transfer sizes\n"); 711 670 drive->atapi_flags |= IDE_AFLAG_LIMIT_NFRAMES; 712 671 } 713 672 ··· 721 676 static ide_startstop_t ide_cd_prepare_rw_request(ide_drive_t *drive, 722 677 struct request *rq) 723 678 { 679 + ide_debug_log(IDE_DBG_RQ, "Call %s: rq->cmd_flags: 0x%x\n", __func__, 680 + rq->cmd_flags); 681 + 724 682 if (rq_data_dir(rq) == READ) { 725 683 unsigned short sectors_per_frame = 726 684 queue_hardsect_size(drive->queue) >> SECTOR_BITS; ··· 743 695 /* sanity check... */ 744 696 if (rq->current_nr_sectors != 745 697 bio_cur_sectors(rq->bio)) { 746 - printk(KERN_ERR "%s: %s: buffer botch (%u)\n", 698 + printk(KERN_ERR PFX "%s: %s: buffer botch (%u)\n", 747 699 drive->name, __func__, 748 700 rq->current_nr_sectors); 749 701 cdrom_end_request(drive, 0); ··· 752 704 rq->current_nr_sectors += nskip; 753 705 } 754 706 } 755 - #if 0 756 - else 757 - /* the immediate bit */ 758 - rq->cmd[1] = 1 << 3; 759 - #endif 707 + 760 708 /* set up the command */ 761 709 rq->timeout = ATAPI_WAIT_PC; 762 710 ··· 783 739 int stat; 784 740 static int retry = 10; 785 741 742 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 743 + 786 744 if (cdrom_decode_status(drive, 0, &stat)) 787 745 return ide_stopped; 788 746 ··· 792 746 793 747 if (retry && time_after(jiffies, info->start_seek + IDECD_SEEK_TIMER)) { 794 748 if (--retry == 0) 795 - drive->dsc_overlap = 0; 749 + drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 796 750 } 797 751 return ide_stopped; 798 752 } ··· 800 754 static void ide_cd_prepare_seek_request(ide_drive_t *drive, struct request *rq) 801 755 { 802 756 sector_t frame = rq->sector; 757 + 758 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 803 759 804 760 sector_div(frame, queue_hardsect_size(drive->queue) >> SECTOR_BITS); 805 761 ··· 823 775 * Fix up a possibly partially-processed request so that we can start it over 824 776 * entirely, or even put it back on the request queue. 825 777 */ 826 - static void restore_request(struct request *rq) 778 + static void ide_cd_restore_request(ide_drive_t *drive, struct request *rq) 827 779 { 780 + 781 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 782 + 828 783 if (rq->buffer != bio_data(rq->bio)) { 829 784 sector_t n = 830 785 (rq->buffer - (char *)bio_data(rq->bio)) / SECTOR_SIZE; ··· 846 795 /* 847 796 * All other packet commands. 848 797 */ 849 - static void ide_cd_request_sense_fixup(struct request *rq) 798 + static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct request *rq) 850 799 { 800 + 801 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 802 + 851 803 /* 852 804 * Some of the trailing request sense fields are optional, 853 805 * and some drives don't send them. Sigh. ··· 875 821 876 822 if (!sense) 877 823 sense = &local_sense; 824 + 825 + ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd[0]: 0x%x, write: 0x%x, " 826 + "timeout: %d, cmd_flags: 0x%x\n", __func__, cmd[0], write, 827 + timeout, cmd_flags); 878 828 879 829 /* start of retry loop */ 880 830 do { ··· 953 895 static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) 954 896 { 955 897 ide_hwif_t *hwif = drive->hwif; 956 - struct cdrom_info *info = drive->driver_data; 957 898 struct request *rq = HWGROUP(drive)->rq; 958 899 xfer_func_t *xferfunc; 959 900 ide_expiry_t *expiry = NULL; ··· 962 905 u16 len; 963 906 u8 ireason; 964 907 908 + ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd[0]: 0x%x, write: 0x%x\n", 909 + __func__, rq->cmd[0], write); 910 + 965 911 /* check for errors */ 966 - dma = info->dma; 912 + dma = drive->dma; 967 913 if (dma) { 968 - info->dma = 0; 914 + drive->dma = 0; 969 915 dma_error = hwif->dma_ops->dma_end(drive); 970 916 if (dma_error) { 971 - printk(KERN_ERR "%s: DMA %s error\n", drive->name, 917 + printk(KERN_ERR PFX "%s: DMA %s error\n", drive->name, 972 918 write ? "write" : "read"); 973 919 ide_dma_off(drive); 974 920 } ··· 997 937 if (thislen > len) 998 938 thislen = len; 999 939 940 + ide_debug_log(IDE_DBG_PC, "%s: DRQ: stat: 0x%x, thislen: %d\n", 941 + __func__, stat, thislen); 942 + 1000 943 /* If DRQ is clear, the command has completed. */ 1001 944 if ((stat & ATA_DRQ) == 0) { 1002 945 if (blk_fs_request(rq)) { ··· 1009 946 */ 1010 947 uptodate = 1; 1011 948 if (rq->current_nr_sectors > 0) { 1012 - printk(KERN_ERR "%s: %s: data underrun " 949 + printk(KERN_ERR PFX "%s: %s: data underrun " 1013 950 "(%d blocks)\n", 1014 951 drive->name, __func__, 1015 952 rq->current_nr_sectors); ··· 1020 957 cdrom_end_request(drive, uptodate); 1021 958 return ide_stopped; 1022 959 } else if (!blk_pc_request(rq)) { 1023 - ide_cd_request_sense_fixup(rq); 960 + ide_cd_request_sense_fixup(drive, rq); 1024 961 /* complain if we still have data left to transfer */ 1025 962 uptodate = rq->data_len ? 0 : 1; 1026 963 } ··· 1063 1000 xferfunc = hwif->tp_ops->input_data; 1064 1001 } 1065 1002 1003 + ide_debug_log(IDE_DBG_PC, "%s: data transfer, rq->cmd_type: 0x%x, " 1004 + "ireason: 0x%x\n", __func__, rq->cmd_type, ireason); 1005 + 1066 1006 /* transfer data */ 1067 1007 while (thislen > 0) { 1068 1008 u8 *ptr = blk_fs_request(rq) ? NULL : rq->data; ··· 1090 1024 */ 1091 1025 ide_pad_transfer(drive, 0, thislen); 1092 1026 else { 1093 - printk(KERN_ERR "%s: confused, missing data\n", 1027 + printk(KERN_ERR PFX "%s: confused, missing data\n", 1094 1028 drive->name); 1095 1029 blk_dump_rq_flags(rq, rq_data_dir(rq) 1096 1030 ? "cdrom_newpc_intr, write" ··· 1177 1111 unsigned short sectors_per_frame = 1178 1112 queue_hardsect_size(drive->queue) >> SECTOR_BITS; 1179 1113 1114 + ide_debug_log(IDE_DBG_RQ, "Call %s, write: 0x%x, secs_per_frame: %u\n", 1115 + __func__, write, sectors_per_frame); 1116 + 1180 1117 if (write) { 1181 1118 /* disk has become write protected */ 1182 1119 if (get_disk_ro(cd->disk)) { ··· 1191 1122 * We may be retrying this request after an error. Fix up any 1192 1123 * weirdness which might be present in the request packet. 1193 1124 */ 1194 - restore_request(rq); 1125 + ide_cd_restore_request(drive, rq); 1195 1126 } 1196 1127 1197 1128 /* use DMA, if possible / writes *must* be hardware frame aligned */ ··· 1201 1132 cdrom_end_request(drive, 0); 1202 1133 return ide_stopped; 1203 1134 } 1204 - cd->dma = 0; 1135 + drive->dma = 0; 1205 1136 } else 1206 - cd->dma = drive->using_dma; 1137 + drive->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); 1207 1138 1208 1139 if (write) 1209 1140 cd->devinfo.media_written = 1; ··· 1220 1151 1221 1152 static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) 1222 1153 { 1223 - struct cdrom_info *info = drive->driver_data; 1154 + 1155 + ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd_type: 0x%x\n", __func__, 1156 + rq->cmd_type); 1224 1157 1225 1158 if (blk_pc_request(rq)) 1226 1159 rq->cmd_flags |= REQ_QUIET; 1227 1160 else 1228 1161 rq->cmd_flags &= ~REQ_FAILED; 1229 1162 1230 - info->dma = 0; 1163 + drive->dma = 0; 1231 1164 1232 1165 /* sg request */ 1233 1166 if (rq->bio || ((rq->cmd_type == REQ_TYPE_ATA_PC) && rq->data_len)) { ··· 1242 1171 else 1243 1172 buf = rq->data; 1244 1173 1245 - info->dma = drive->using_dma; 1174 + drive->dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); 1246 1175 1247 1176 /* 1248 1177 * check if dma is safe ··· 1253 1182 alignment = queue_dma_alignment(q) | q->dma_pad_mask; 1254 1183 if ((unsigned long)buf & alignment || rq->data_len & alignment 1255 1184 || object_is_on_stack(buf)) 1256 - info->dma = 0; 1185 + drive->dma = 0; 1257 1186 } 1258 1187 } 1259 1188 ··· 1267 1196 ide_handler_t *fn; 1268 1197 int xferlen; 1269 1198 1199 + ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd_type: 0x%x, block: %llu\n", 1200 + __func__, rq->cmd_type, (unsigned long long)block); 1201 + 1270 1202 if (blk_fs_request(rq)) { 1271 1203 if (drive->atapi_flags & IDE_AFLAG_SEEKING) { 1272 1204 ide_hwif_t *hwif = drive->hwif; ··· 1282 1208 IDECD_SEEK_TIMER); 1283 1209 return ide_stopped; 1284 1210 } 1285 - printk(KERN_ERR "%s: DSC timeout\n", 1211 + printk(KERN_ERR PFX "%s: DSC timeout\n", 1286 1212 drive->name); 1287 1213 } 1288 1214 drive->atapi_flags &= ~IDE_AFLAG_SEEKING; ··· 1290 1216 if (rq_data_dir(rq) == READ && 1291 1217 IDE_LARGE_SEEK(info->last_block, block, 1292 1218 IDECD_SEEK_THRESHOLD) && 1293 - drive->dsc_overlap) { 1219 + (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP)) { 1294 1220 xferlen = 0; 1295 1221 fn = cdrom_start_seek_continuation; 1296 1222 1297 - info->dma = 0; 1223 + drive->dma = 0; 1298 1224 info->start_seek = jiffies; 1299 1225 1300 1226 ide_cd_prepare_seek_request(drive, rq); ··· 1323 1249 cdrom_end_request(drive, 1); 1324 1250 return ide_stopped; 1325 1251 } else { 1326 - blk_dump_rq_flags(rq, "ide-cd bad flags"); 1252 + blk_dump_rq_flags(rq, DRV_NAME " bad flags"); 1327 1253 cdrom_end_request(drive, 0); 1328 1254 return ide_stopped; 1329 1255 } ··· 1353 1279 struct cdrom_device_info *cdi = &info->devinfo; 1354 1280 unsigned char cmd[BLK_MAX_CDB]; 1355 1281 1282 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 1283 + 1356 1284 memset(cmd, 0, BLK_MAX_CDB); 1357 1285 cmd[0] = GPCMD_TEST_UNIT_READY; 1358 1286 ··· 1381 1305 unsigned len = sizeof(capbuf); 1382 1306 u32 blocklen; 1383 1307 1308 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 1309 + 1384 1310 memset(cmd, 0, BLK_MAX_CDB); 1385 1311 cmd[0] = GPCMD_READ_CDVD_CAPACITY; 1386 1312 ··· 1402 1324 case 4096: 1403 1325 break; 1404 1326 default: 1405 - printk(KERN_ERR "%s: weird block size %u\n", 1406 - drive->name, blocklen); 1407 - printk(KERN_ERR "%s: default to 2kb block size\n", 1408 - drive->name); 1327 + printk(KERN_ERR PFX "%s: weird block size %u\n", 1328 + drive->name, blocklen); 1329 + printk(KERN_ERR PFX "%s: default to 2kb block size\n", 1330 + drive->name); 1409 1331 blocklen = 2048; 1410 1332 break; 1411 1333 } ··· 1420 1342 struct request_sense *sense) 1421 1343 { 1422 1344 unsigned char cmd[BLK_MAX_CDB]; 1345 + 1346 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 1423 1347 1424 1348 memset(cmd, 0, BLK_MAX_CDB); 1425 1349 ··· 1451 1371 long last_written; 1452 1372 unsigned long sectors_per_frame = SECTORS_PER_FRAME; 1453 1373 1374 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 1375 + 1454 1376 if (toc == NULL) { 1455 1377 /* try to allocate space */ 1456 1378 toc = kmalloc(sizeof(struct atapi_toc), GFP_KERNEL); 1457 1379 if (toc == NULL) { 1458 - printk(KERN_ERR "%s: No cdrom TOC buffer!\n", 1380 + printk(KERN_ERR PFX "%s: No cdrom TOC buffer!\n", 1459 1381 drive->name); 1460 1382 return -ENOMEM; 1461 1383 } ··· 1613 1531 struct packet_command cgc; 1614 1532 int stat, attempts = 3, size = ATAPI_CAPABILITIES_PAGE_SIZE; 1615 1533 1534 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 1535 + 1616 1536 if ((drive->atapi_flags & IDE_AFLAG_FULL_CAPS_PAGE) == 0) 1617 1537 size -= ATAPI_CAPABILITIES_PAGE_PAD_SIZE; 1618 1538 ··· 1632 1548 { 1633 1549 struct cdrom_info *cd = drive->driver_data; 1634 1550 u16 curspeed, maxspeed; 1551 + 1552 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 1635 1553 1636 1554 if (drive->atapi_flags & IDE_AFLAG_LE_SPEED_FIELDS) { 1637 1555 curspeed = le16_to_cpup((__le16 *)&buf[8 + 14]); ··· 1675 1589 struct cdrom_info *info = drive->driver_data; 1676 1590 struct cdrom_device_info *devinfo = &info->devinfo; 1677 1591 1592 + ide_debug_log(IDE_DBG_PROBE, "Call %s, nslots: %d\n", __func__, nslots); 1593 + 1678 1594 devinfo->ops = &ide_cdrom_dops; 1679 1595 devinfo->speed = info->current_speed; 1680 1596 devinfo->capacity = nslots; ··· 1698 1610 mechtype_t mechtype; 1699 1611 int nslots = 1; 1700 1612 1613 + ide_debug_log(IDE_DBG_PROBE, "Call %s, drive->media: 0x%x, " 1614 + "drive->atapi_flags: 0x%lx\n", __func__, drive->media, 1615 + drive->atapi_flags); 1616 + 1701 1617 cdi->mask = (CDC_CD_R | CDC_CD_RW | CDC_DVD | CDC_DVD_R | 1702 1618 CDC_DVD_RAM | CDC_SELECT_DISC | CDC_PLAY_AUDIO | 1703 1619 CDC_MO_DRIVE | CDC_RAM); 1704 1620 1705 1621 if (drive->media == ide_optical) { 1706 1622 cdi->mask &= ~(CDC_MO_DRIVE | CDC_RAM); 1707 - printk(KERN_ERR "%s: ATAPI magneto-optical drive\n", 1623 + printk(KERN_ERR PFX "%s: ATAPI magneto-optical drive\n", 1708 1624 drive->name); 1709 1625 return nslots; 1710 1626 } ··· 1766 1674 1767 1675 ide_cdrom_update_speed(drive, buf); 1768 1676 1769 - printk(KERN_INFO "%s: ATAPI", drive->name); 1677 + printk(KERN_INFO PFX "%s: ATAPI", drive->name); 1770 1678 1771 1679 /* don't print speed if the drive reported 0 */ 1772 1680 if (cd->max_speed) ··· 1789 1697 else 1790 1698 printk(KERN_CONT " drive"); 1791 1699 1792 - printk(KERN_CONT ", %dkB Cache\n", be16_to_cpup((__be16 *)&buf[8 + 12])); 1700 + printk(KERN_CONT ", %dkB Cache\n", 1701 + be16_to_cpup((__be16 *)&buf[8 + 12])); 1793 1702 1794 1703 return nslots; 1795 1704 } ··· 1902 1809 { NULL, 0, NULL, NULL } 1903 1810 }; 1904 1811 1905 - ide_devset_rw_field(dsc_overlap, dsc_overlap); 1812 + ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP); 1906 1813 1907 1814 static const struct ide_proc_devset idecd_settings[] = { 1908 1815 IDE_PROC_DEVSET(dsc_overlap, 0, 1), ··· 1977 1884 char *fw_rev = (char *)&id[ATA_ID_FW_REV]; 1978 1885 int nslots; 1979 1886 1887 + ide_debug_log(IDE_DBG_PROBE, "Call %s\n", __func__); 1888 + 1980 1889 blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); 1981 1890 blk_queue_dma_alignment(drive->queue, 31); 1982 1891 blk_queue_update_dma_pad(drive->queue, 15); ··· 1986 1891 if (!drive->queue->unplug_delay) 1987 1892 drive->queue->unplug_delay = 1; 1988 1893 1989 - drive->special.all = 0; 1990 - 1991 1894 drive->atapi_flags = IDE_AFLAG_MEDIA_CHANGED | IDE_AFLAG_NO_EJECT | 1992 1895 ide_cd_flags(id); 1993 - 1994 - if ((id[ATA_ID_CONFIG] & 0x0060) == 0x20) 1995 - drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; 1996 1896 1997 1897 if ((drive->atapi_flags & IDE_AFLAG_VERTOS_300_SSD) && 1998 1898 fw_rev[4] == '1' && fw_rev[6] <= '2') ··· 2005 1915 /* set correct block size */ 2006 1916 blk_queue_hardsect_size(drive->queue, CD_FRAMESIZE); 2007 1917 2008 - drive->dsc_overlap = (drive->next != drive); 1918 + if (drive->next != drive) 1919 + drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; 1920 + else 1921 + drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 2009 1922 2010 1923 if (ide_cdrom_register(drive, nslots)) { 2011 - printk(KERN_ERR "%s: %s failed to register device with the" 1924 + printk(KERN_ERR PFX "%s: %s failed to register device with the" 2012 1925 " cdrom driver.\n", drive->name, __func__); 2013 1926 cd->devinfo.handle = NULL; 2014 1927 return 1; ··· 2025 1932 { 2026 1933 struct cdrom_info *info = drive->driver_data; 2027 1934 1935 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 1936 + 2028 1937 ide_proc_unregister_driver(drive, info->driver); 2029 1938 2030 1939 del_gendisk(info->disk); ··· 2036 1941 2037 1942 static void ide_cd_release(struct kref *kref) 2038 1943 { 2039 - struct cdrom_info *info = to_ide_cd(kref); 1944 + struct cdrom_info *info = to_ide_drv(kref, cdrom_info); 2040 1945 struct cdrom_device_info *devinfo = &info->devinfo; 2041 1946 ide_drive_t *drive = info->drive; 2042 1947 struct gendisk *g = info->disk; 2043 1948 1949 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 1950 + 2044 1951 kfree(info->toc); 2045 1952 if (devinfo->handle == drive) 2046 1953 unregister_cdrom(devinfo); 2047 - drive->dsc_overlap = 0; 1954 + drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 2048 1955 drive->driver_data = NULL; 2049 1956 blk_queue_prep_rq(drive->queue, NULL); 2050 1957 g->private_data = NULL; ··· 2065 1968 .probe = ide_cd_probe, 2066 1969 .remove = ide_cd_remove, 2067 1970 .version = IDECD_VERSION, 2068 - .media = ide_cdrom, 2069 1971 .do_request = ide_cd_do_request, 2070 1972 .end_request = ide_end_request, 2071 1973 .error = __ide_error, ··· 2095 1999 static int idecd_release(struct inode *inode, struct file *file) 2096 2000 { 2097 2001 struct gendisk *disk = inode->i_bdev->bd_disk; 2098 - struct cdrom_info *info = ide_cd_g(disk); 2002 + struct cdrom_info *info = ide_drv_g(disk, cdrom_info); 2099 2003 2100 2004 cdrom_release(&info->devinfo, file); 2101 2005 ··· 2147 2051 unsigned int cmd, unsigned long arg) 2148 2052 { 2149 2053 struct block_device *bdev = inode->i_bdev; 2150 - struct cdrom_info *info = ide_cd_g(bdev->bd_disk); 2054 + struct cdrom_info *info = ide_drv_g(bdev->bd_disk, cdrom_info); 2151 2055 int err; 2152 2056 2153 2057 switch (cmd) { ··· 2168 2072 2169 2073 static int idecd_media_changed(struct gendisk *disk) 2170 2074 { 2171 - struct cdrom_info *info = ide_cd_g(disk); 2075 + struct cdrom_info *info = ide_drv_g(disk, cdrom_info); 2172 2076 return cdrom_media_changed(&info->devinfo); 2173 2077 } 2174 2078 2175 2079 static int idecd_revalidate_disk(struct gendisk *disk) 2176 2080 { 2177 - struct cdrom_info *info = ide_cd_g(disk); 2081 + struct cdrom_info *info = ide_drv_g(disk, cdrom_info); 2178 2082 struct request_sense sense; 2179 2083 2180 2084 ide_cd_read_toc(info->drive, &sense); ··· 2193 2097 2194 2098 /* module options */ 2195 2099 static char *ignore; 2196 - 2197 2100 module_param(ignore, charp, 0400); 2101 + 2102 + static unsigned long debug_mask; 2103 + module_param(debug_mask, ulong, 0644); 2104 + 2198 2105 MODULE_DESCRIPTION("ATAPI CD-ROM Driver"); 2199 2106 2200 2107 static int ide_cd_probe(ide_drive_t *drive) ··· 2205 2106 struct cdrom_info *info; 2206 2107 struct gendisk *g; 2207 2108 struct request_sense sense; 2109 + 2110 + ide_debug_log(IDE_DBG_PROBE, "Call %s, drive->driver_req: %s, " 2111 + "drive->media: 0x%x\n", __func__, drive->driver_req, 2112 + drive->media); 2208 2113 2209 2114 if (!strstr("ide-cdrom", drive->driver_req)) 2210 2115 goto failed; ··· 2219 2116 /* skip drives that we were told to ignore */ 2220 2117 if (ignore != NULL) { 2221 2118 if (strstr(ignore, drive->name)) { 2222 - printk(KERN_INFO "ide-cd: ignoring drive %s\n", 2119 + printk(KERN_INFO PFX "ignoring drive %s\n", 2223 2120 drive->name); 2224 2121 goto failed; 2225 2122 } 2226 2123 } 2124 + 2125 + drive->debug_mask = debug_mask; 2126 + 2227 2127 info = kzalloc(sizeof(struct cdrom_info), GFP_KERNEL); 2228 2128 if (info == NULL) { 2229 - printk(KERN_ERR "%s: Can't allocate a cdrom structure\n", 2129 + printk(KERN_ERR PFX "%s: Can't allocate a cdrom structure\n", 2230 2130 drive->name); 2231 2131 goto failed; 2232 2132 } ··· 2277 2171 2278 2172 static int __init ide_cdrom_init(void) 2279 2173 { 2174 + printk(KERN_INFO DRV_NAME " driver " IDECD_VERSION "\n"); 2280 2175 return driver_register(&ide_cdrom_driver.gen_driver); 2281 2176 } 2282 2177
-1
drivers/ide/ide-cd.h
··· 88 88 struct request_sense sense_data; 89 89 90 90 struct request request_sense_request; 91 - int dma; 92 91 unsigned long last_block; 93 92 unsigned long start_seek; 94 93
+115 -246
drivers/ide/ide-disk.c
··· 45 45 #define IDE_DISK_MINORS 0 46 46 #endif 47 47 48 - struct ide_disk_obj { 49 - ide_drive_t *drive; 50 - ide_driver_t *driver; 51 - struct gendisk *disk; 52 - struct kref kref; 53 - unsigned int openers; /* protected by BKL for now */ 54 - }; 48 + #include "ide-disk.h" 55 49 56 50 static DEFINE_MUTEX(idedisk_ref_mutex); 57 51 58 52 #define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref) 59 - 60 - #define ide_disk_g(disk) \ 61 - container_of((disk)->private_data, struct ide_disk_obj, driver) 62 53 63 54 static void ide_disk_release(struct kref *); 64 55 ··· 131 140 sector_t block) 132 141 { 133 142 ide_hwif_t *hwif = HWIF(drive); 134 - unsigned int dma = drive->using_dma; 135 143 u16 nsectors = (u16)rq->nr_sectors; 136 - u8 lba48 = (drive->addressing == 1) ? 1 : 0; 144 + u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48); 145 + u8 dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); 137 146 ide_task_t task; 138 147 struct ide_taskfile *tf = &task.tf; 139 148 ide_startstop_t rc; ··· 153 162 memset(&task, 0, sizeof(task)); 154 163 task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 155 164 156 - if (drive->select.b.lba) { 165 + if (drive->dev_flags & IDE_DFLAG_LBA) { 157 166 if (lba48) { 158 167 pr_debug("%s: LBA=0x%012llx\n", drive->name, 159 168 (unsigned long long)block); ··· 178 187 tf->lbah = block >>= 8; 179 188 tf->device = (block >> 8) & 0xf; 180 189 } 190 + 191 + tf->device |= ATA_LBA; 181 192 } else { 182 193 unsigned int sect, head, cyl, track; 183 194 ··· 230 237 { 231 238 ide_hwif_t *hwif = HWIF(drive); 232 239 233 - BUG_ON(drive->blocked); 240 + BUG_ON(drive->dev_flags & IDE_DFLAG_BLOCKED); 234 241 235 242 if (!blk_fs_request(rq)) { 236 243 blk_dump_rq_flags(rq, "ide_do_rw_disk - bad command"); ··· 377 384 static void init_idedisk_capacity(ide_drive_t *drive) 378 385 { 379 386 u16 *id = drive->id; 380 - /* 381 - * If this drive supports the Host Protected Area feature set, 382 - * then we may need to change our opinion about the drive's capacity. 383 - */ 384 - int hpa = ata_id_hpa_enabled(id); 387 + int lba; 385 388 386 389 if (ata_id_lba48_enabled(id)) { 387 390 /* drive speaks 48-bit LBA */ 388 - drive->select.b.lba = 1; 391 + lba = 1; 389 392 drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); 390 - if (hpa) 391 - idedisk_check_hpa(drive); 392 393 } else if (ata_id_has_lba(id) && ata_id_is_lba_capacity_ok(id)) { 393 394 /* drive speaks 28-bit LBA */ 394 - drive->select.b.lba = 1; 395 + lba = 1; 395 396 drive->capacity64 = ata_id_u32(id, ATA_ID_LBA_CAPACITY); 396 - if (hpa) 397 - idedisk_check_hpa(drive); 398 397 } else { 399 398 /* drive speaks boring old 28-bit CHS */ 399 + lba = 0; 400 400 drive->capacity64 = drive->cyl * drive->head * drive->sect; 401 + } 402 + 403 + if (lba) { 404 + drive->dev_flags |= IDE_DFLAG_LBA; 405 + 406 + /* 407 + * If this device supports the Host Protected Area feature set, 408 + * then we may need to change our opinion about its capacity. 409 + */ 410 + if (ata_id_hpa_enabled(id)) 411 + idedisk_check_hpa(drive); 401 412 } 402 413 } 403 414 404 - static sector_t idedisk_capacity(ide_drive_t *drive) 415 + sector_t ide_disk_capacity(ide_drive_t *drive) 405 416 { 406 417 return drive->capacity64; 407 418 } 408 - 409 - #ifdef CONFIG_IDE_PROC_FS 410 - static int smart_enable(ide_drive_t *drive) 411 - { 412 - ide_task_t args; 413 - struct ide_taskfile *tf = &args.tf; 414 - 415 - memset(&args, 0, sizeof(ide_task_t)); 416 - tf->feature = ATA_SMART_ENABLE; 417 - tf->lbam = ATA_SMART_LBAM_PASS; 418 - tf->lbah = ATA_SMART_LBAH_PASS; 419 - tf->command = ATA_CMD_SMART; 420 - args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 421 - return ide_no_data_taskfile(drive, &args); 422 - } 423 - 424 - static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) 425 - { 426 - ide_task_t args; 427 - struct ide_taskfile *tf = &args.tf; 428 - 429 - memset(&args, 0, sizeof(ide_task_t)); 430 - tf->feature = sub_cmd; 431 - tf->nsect = 0x01; 432 - tf->lbam = ATA_SMART_LBAM_PASS; 433 - tf->lbah = ATA_SMART_LBAH_PASS; 434 - tf->command = ATA_CMD_SMART; 435 - args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 436 - args.data_phase = TASKFILE_IN; 437 - (void) smart_enable(drive); 438 - return ide_raw_taskfile(drive, &args, buf, 1); 439 - } 440 - 441 - static int proc_idedisk_read_cache 442 - (char *page, char **start, off_t off, int count, int *eof, void *data) 443 - { 444 - ide_drive_t *drive = (ide_drive_t *) data; 445 - char *out = page; 446 - int len; 447 - 448 - if (drive->id_read) 449 - len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2); 450 - else 451 - len = sprintf(out, "(none)\n"); 452 - 453 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 454 - } 455 - 456 - static int proc_idedisk_read_capacity 457 - (char *page, char **start, off_t off, int count, int *eof, void *data) 458 - { 459 - ide_drive_t*drive = (ide_drive_t *)data; 460 - int len; 461 - 462 - len = sprintf(page, "%llu\n", (long long)idedisk_capacity(drive)); 463 - 464 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 465 - } 466 - 467 - static int proc_idedisk_read_smart(char *page, char **start, off_t off, 468 - int count, int *eof, void *data, u8 sub_cmd) 469 - { 470 - ide_drive_t *drive = (ide_drive_t *)data; 471 - int len = 0, i = 0; 472 - 473 - if (get_smart_data(drive, page, sub_cmd) == 0) { 474 - unsigned short *val = (unsigned short *) page; 475 - char *out = (char *)val + SECTOR_SIZE; 476 - 477 - page = out; 478 - do { 479 - out += sprintf(out, "%04x%c", le16_to_cpu(*val), 480 - (++i & 7) ? ' ' : '\n'); 481 - val += 1; 482 - } while (i < SECTOR_SIZE / 2); 483 - len = out - page; 484 - } 485 - 486 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 487 - } 488 - 489 - static int proc_idedisk_read_sv 490 - (char *page, char **start, off_t off, int count, int *eof, void *data) 491 - { 492 - return proc_idedisk_read_smart(page, start, off, count, eof, data, 493 - ATA_SMART_READ_VALUES); 494 - } 495 - 496 - static int proc_idedisk_read_st 497 - (char *page, char **start, off_t off, int count, int *eof, void *data) 498 - { 499 - return proc_idedisk_read_smart(page, start, off, count, eof, data, 500 - ATA_SMART_READ_THRESHOLDS); 501 - } 502 - 503 - static ide_proc_entry_t idedisk_proc[] = { 504 - { "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL }, 505 - { "capacity", S_IFREG|S_IRUGO, proc_idedisk_read_capacity, NULL }, 506 - { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, 507 - { "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_sv, NULL }, 508 - { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_st, NULL }, 509 - { NULL, 0, NULL, NULL } 510 - }; 511 - #endif /* CONFIG_IDE_PROC_FS */ 512 419 513 420 static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) 514 421 { ··· 461 568 return (drive->mult_count == arg) ? 0 : -EIO; 462 569 } 463 570 464 - ide_devset_get(nowerr, nowerr); 571 + ide_devset_get_flag(nowerr, IDE_DFLAG_NOWERR); 465 572 466 573 static int set_nowerr(ide_drive_t *drive, int arg) 467 574 { 468 575 if (arg < 0 || arg > 1) 469 576 return -EINVAL; 470 577 471 - drive->nowerr = arg; 578 + if (arg) 579 + drive->dev_flags |= IDE_DFLAG_NOWERR; 580 + else 581 + drive->dev_flags &= ~IDE_DFLAG_NOWERR; 582 + 472 583 drive->bad_wstat = arg ? BAD_R_STAT : BAD_W_STAT; 584 + 473 585 return 0; 586 + } 587 + 588 + static int ide_do_setfeature(ide_drive_t *drive, u8 feature, u8 nsect) 589 + { 590 + ide_task_t task; 591 + 592 + memset(&task, 0, sizeof(task)); 593 + task.tf.feature = feature; 594 + task.tf.nsect = nsect; 595 + task.tf.command = ATA_CMD_SET_FEATURES; 596 + task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 597 + 598 + return ide_no_data_taskfile(drive, &task); 474 599 } 475 600 476 601 static void update_ordered(ide_drive_t *drive) ··· 497 586 unsigned ordered = QUEUE_ORDERED_NONE; 498 587 prepare_flush_fn *prep_fn = NULL; 499 588 500 - if (drive->wcache) { 589 + if (drive->dev_flags & IDE_DFLAG_WCACHE) { 501 590 unsigned long long capacity; 502 591 int barrier; 503 592 /* ··· 508 597 * time we have trimmed the drive capacity if LBA48 is 509 598 * not available so we don't need to recheck that. 510 599 */ 511 - capacity = idedisk_capacity(drive); 512 - barrier = ata_id_flush_enabled(id) && !drive->noflush && 513 - (drive->addressing == 0 || capacity <= (1ULL << 28) || 600 + capacity = ide_disk_capacity(drive); 601 + barrier = ata_id_flush_enabled(id) && 602 + (drive->dev_flags & IDE_DFLAG_NOFLUSH) == 0 && 603 + ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 || 604 + capacity <= (1ULL << 28) || 514 605 ata_id_flush_ext_enabled(id)); 515 606 516 607 printk(KERN_INFO "%s: cache flushes %ssupported\n", ··· 528 615 blk_queue_ordered(drive->queue, ordered, prep_fn); 529 616 } 530 617 531 - ide_devset_get(wcache, wcache); 618 + ide_devset_get_flag(wcache, IDE_DFLAG_WCACHE); 532 619 533 620 static int set_wcache(ide_drive_t *drive, int arg) 534 621 { 535 - ide_task_t args; 536 622 int err = 1; 537 623 538 624 if (arg < 0 || arg > 1) 539 625 return -EINVAL; 540 626 541 627 if (ata_id_flush_enabled(drive->id)) { 542 - memset(&args, 0, sizeof(ide_task_t)); 543 - args.tf.feature = arg ? 544 - SETFEATURES_WC_ON : SETFEATURES_WC_OFF; 545 - args.tf.command = ATA_CMD_SET_FEATURES; 546 - args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 547 - err = ide_no_data_taskfile(drive, &args); 548 - if (err == 0) 549 - drive->wcache = arg; 628 + err = ide_do_setfeature(drive, 629 + arg ? SETFEATURES_WC_ON : SETFEATURES_WC_OFF, 0); 630 + if (err == 0) { 631 + if (arg) 632 + drive->dev_flags |= IDE_DFLAG_WCACHE; 633 + else 634 + drive->dev_flags &= ~IDE_DFLAG_WCACHE; 635 + } 550 636 } 551 637 552 638 update_ordered(drive); ··· 570 658 571 659 static int set_acoustic(ide_drive_t *drive, int arg) 572 660 { 573 - ide_task_t args; 574 - 575 661 if (arg < 0 || arg > 254) 576 662 return -EINVAL; 577 663 578 - memset(&args, 0, sizeof(ide_task_t)); 579 - args.tf.feature = arg ? SETFEATURES_AAM_ON : SETFEATURES_AAM_OFF; 580 - args.tf.nsect = arg; 581 - args.tf.command = ATA_CMD_SET_FEATURES; 582 - args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 583 - ide_no_data_taskfile(drive, &args); 664 + ide_do_setfeature(drive, 665 + arg ? SETFEATURES_AAM_ON : SETFEATURES_AAM_OFF, arg); 666 + 584 667 drive->acoustic = arg; 668 + 585 669 return 0; 586 670 } 587 671 588 - ide_devset_get(addressing, addressing); 672 + ide_devset_get_flag(addressing, IDE_DFLAG_LBA48); 589 673 590 674 /* 591 675 * drive->addressing: ··· 594 686 if (arg < 0 || arg > 2) 595 687 return -EINVAL; 596 688 597 - drive->addressing = 0; 598 - 599 - if (drive->hwif->host_flags & IDE_HFLAG_NO_LBA48) 600 - return 0; 601 - 602 - if (ata_id_lba48_enabled(drive->id) == 0) 689 + if (arg && ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48) || 690 + ata_id_lba48_enabled(drive->id) == 0)) 603 691 return -EIO; 604 692 605 - drive->addressing = arg; 693 + if (arg == 2) 694 + arg = 0; 695 + 696 + if (arg) 697 + drive->dev_flags |= IDE_DFLAG_LBA48; 698 + else 699 + drive->dev_flags &= ~IDE_DFLAG_LBA48; 606 700 607 701 return 0; 608 702 } 609 703 610 - ide_devset_rw(acoustic, acoustic); 611 - ide_devset_rw(address, addressing); 612 - ide_devset_rw(multcount, multcount); 613 - ide_devset_rw(wcache, wcache); 704 + ide_ext_devset_rw(acoustic, acoustic); 705 + ide_ext_devset_rw(address, addressing); 706 + ide_ext_devset_rw(multcount, multcount); 707 + ide_ext_devset_rw(wcache, wcache); 614 708 615 - ide_devset_rw_sync(nowerr, nowerr); 616 - 617 - #ifdef CONFIG_IDE_PROC_FS 618 - ide_devset_rw_field(bios_cyl, bios_cyl); 619 - ide_devset_rw_field(bios_head, bios_head); 620 - ide_devset_rw_field(bios_sect, bios_sect); 621 - ide_devset_rw_field(failures, failures); 622 - ide_devset_rw_field(lun, lun); 623 - ide_devset_rw_field(max_failures, max_failures); 624 - 625 - static const struct ide_proc_devset idedisk_settings[] = { 626 - IDE_PROC_DEVSET(acoustic, 0, 254), 627 - IDE_PROC_DEVSET(address, 0, 2), 628 - IDE_PROC_DEVSET(bios_cyl, 0, 65535), 629 - IDE_PROC_DEVSET(bios_head, 0, 255), 630 - IDE_PROC_DEVSET(bios_sect, 0, 63), 631 - IDE_PROC_DEVSET(failures, 0, 65535), 632 - IDE_PROC_DEVSET(lun, 0, 7), 633 - IDE_PROC_DEVSET(max_failures, 0, 65535), 634 - IDE_PROC_DEVSET(multcount, 0, 16), 635 - IDE_PROC_DEVSET(nowerr, 0, 1), 636 - IDE_PROC_DEVSET(wcache, 0, 1), 637 - { 0 }, 638 - }; 639 - #endif 709 + ide_ext_devset_rw_sync(nowerr, nowerr); 640 710 641 711 static void idedisk_setup(ide_drive_t *drive) 642 712 { ··· 626 740 627 741 ide_proc_register_driver(drive, idkp->driver); 628 742 629 - if (drive->id_read == 0) 743 + if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) 630 744 return; 631 745 632 - if (drive->removable) { 746 + if (drive->dev_flags & IDE_DFLAG_REMOVABLE) { 633 747 /* 634 748 * Removable disks (eg. SYQUEST); ignore 'WD' drives 635 749 */ 636 750 if (m[0] != 'W' || m[1] != 'D') 637 - drive->doorlocking = 1; 751 + drive->dev_flags |= IDE_DFLAG_DOORLOCKING; 638 752 } 639 753 640 754 (void)set_addressing(drive, 1); 641 755 642 - if (drive->addressing == 1) { 756 + if (drive->dev_flags & IDE_DFLAG_LBA48) { 643 757 int max_s = 2048; 644 758 645 759 if (max_s > hwif->rqsize) ··· 655 769 init_idedisk_capacity(drive); 656 770 657 771 /* limit drive capacity to 137GB if LBA48 cannot be used */ 658 - if (drive->addressing == 0 && drive->capacity64 > 1ULL << 28) { 772 + if ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 && 773 + drive->capacity64 > 1ULL << 28) { 659 774 printk(KERN_WARNING "%s: cannot use LBA48 - full capacity " 660 775 "%llu sectors (%llu MB)\n", 661 776 drive->name, (unsigned long long)drive->capacity64, ··· 664 777 drive->capacity64 = 1ULL << 28; 665 778 } 666 779 667 - if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && drive->addressing) { 780 + if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) && 781 + (drive->dev_flags & IDE_DFLAG_LBA48)) { 668 782 if (drive->capacity64 > 1ULL << 28) { 669 783 printk(KERN_INFO "%s: cannot use LBA48 DMA - PIO mode" 670 784 " will be used for accessing sectors " 671 785 "> %u\n", drive->name, 1 << 28); 672 786 } else 673 - drive->addressing = 0; 787 + drive->dev_flags &= ~IDE_DFLAG_LBA48; 674 788 } 675 789 676 790 /* 677 791 * if possible, give fdisk access to more of the drive, 678 792 * by correcting bios_cyls: 679 793 */ 680 - capacity = idedisk_capacity(drive); 794 + capacity = ide_disk_capacity(drive); 681 795 682 - if (!drive->forced_geom) { 796 + if ((drive->dev_flags & IDE_DFLAG_FORCED_GEOM) == 0) { 683 797 if (ata_id_lba48_enabled(drive->id)) { 684 798 /* compatibility */ 685 799 drive->bios_sect = 63; ··· 715 827 716 828 /* write cache enabled? */ 717 829 if ((id[ATA_ID_CSFO] & 1) || ata_id_wcache_enabled(id)) 718 - drive->wcache = 1; 830 + drive->dev_flags |= IDE_DFLAG_WCACHE; 719 831 720 832 set_wcache(drive, 1); 721 833 } 722 834 723 835 static void ide_cacheflush_p(ide_drive_t *drive) 724 836 { 725 - if (!drive->wcache || ata_id_flush_enabled(drive->id) == 0) 837 + if (ata_id_flush_enabled(drive->id) == 0 || 838 + (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) 726 839 return; 727 840 728 841 if (do_idedisk_flushcache(drive)) ··· 807 918 .resume = ide_disk_resume, 808 919 .shutdown = ide_device_shutdown, 809 920 .version = IDEDISK_VERSION, 810 - .media = ide_disk, 811 921 .do_request = ide_do_rw_disk, 812 922 .end_request = ide_end_request, 813 923 .error = __ide_error, 814 924 #ifdef CONFIG_IDE_PROC_FS 815 - .proc = idedisk_proc, 816 - .settings = idedisk_settings, 925 + .proc = ide_disk_proc, 926 + .settings = ide_disk_settings, 817 927 #endif 818 928 }; 819 929 ··· 841 953 842 954 idkp->openers++; 843 955 844 - if (drive->removable && idkp->openers == 1) { 956 + if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) { 845 957 check_disk_change(inode->i_bdev); 846 958 /* 847 959 * Ignore the return code from door_lock, 848 960 * since the open() has already succeeded, 849 961 * and the door_lock is irrelevant at this point. 850 962 */ 851 - if (drive->doorlocking && idedisk_set_doorlock(drive, 1)) 852 - drive->doorlocking = 0; 963 + if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) && 964 + idedisk_set_doorlock(drive, 1)) 965 + drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING; 853 966 } 854 967 return 0; 855 968 } ··· 864 975 if (idkp->openers == 1) 865 976 ide_cacheflush_p(drive); 866 977 867 - if (drive->removable && idkp->openers == 1) { 868 - if (drive->doorlocking && idedisk_set_doorlock(drive, 0)) 869 - drive->doorlocking = 0; 978 + if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) { 979 + if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) && 980 + idedisk_set_doorlock(drive, 0)) 981 + drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING; 870 982 } 871 983 872 984 idkp->openers--; ··· 888 998 return 0; 889 999 } 890 1000 891 - static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = { 892 - { HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address }, 893 - { HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount }, 894 - { HDIO_GET_NOWERR, HDIO_SET_NOWERR, &ide_devset_nowerr }, 895 - { HDIO_GET_WCACHE, HDIO_SET_WCACHE, &ide_devset_wcache }, 896 - { HDIO_GET_ACOUSTIC, HDIO_SET_ACOUSTIC, &ide_devset_acoustic }, 897 - { 0 } 898 - }; 899 - 900 - static int idedisk_ioctl(struct inode *inode, struct file *file, 901 - unsigned int cmd, unsigned long arg) 902 - { 903 - struct block_device *bdev = inode->i_bdev; 904 - struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk); 905 - ide_drive_t *drive = idkp->drive; 906 - int err; 907 - 908 - err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); 909 - if (err != -EOPNOTSUPP) 910 - return err; 911 - 912 - return generic_ide_ioctl(drive, file, bdev, cmd, arg); 913 - } 914 - 915 1001 static int idedisk_media_changed(struct gendisk *disk) 916 1002 { 917 1003 struct ide_disk_obj *idkp = ide_disk_g(disk); 918 1004 ide_drive_t *drive = idkp->drive; 919 1005 920 1006 /* do not scan partitions twice if this is a removable device */ 921 - if (drive->attach) { 922 - drive->attach = 0; 1007 + if (drive->dev_flags & IDE_DFLAG_ATTACH) { 1008 + drive->dev_flags &= ~IDE_DFLAG_ATTACH; 923 1009 return 0; 924 1010 } 1011 + 925 1012 /* if removable, always assume it was changed */ 926 - return drive->removable; 1013 + return !!(drive->dev_flags & IDE_DFLAG_REMOVABLE); 927 1014 } 928 1015 929 1016 static int idedisk_revalidate_disk(struct gendisk *disk) 930 1017 { 931 1018 struct ide_disk_obj *idkp = ide_disk_g(disk); 932 - set_capacity(disk, idedisk_capacity(idkp->drive)); 1019 + set_capacity(disk, ide_disk_capacity(idkp->drive)); 933 1020 return 0; 934 1021 } 935 1022 ··· 914 1047 .owner = THIS_MODULE, 915 1048 .open = idedisk_open, 916 1049 .release = idedisk_release, 917 - .ioctl = idedisk_ioctl, 1050 + .ioctl = ide_disk_ioctl, 918 1051 .getgeo = idedisk_getgeo, 919 1052 .media_changed = idedisk_media_changed, 920 1053 .revalidate_disk = idedisk_revalidate_disk ··· 955 1088 drive->driver_data = idkp; 956 1089 957 1090 idedisk_setup(drive); 958 - if ((!drive->head || drive->head > 16) && !drive->select.b.lba) { 1091 + if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 && 1092 + (drive->head == 0 || drive->head > 16)) { 959 1093 printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n", 960 1094 drive->name, drive->head); 961 - drive->attach = 0; 1095 + drive->dev_flags &= ~IDE_DFLAG_ATTACH; 962 1096 } else 963 - drive->attach = 1; 1097 + drive->dev_flags |= IDE_DFLAG_ATTACH; 964 1098 965 1099 g->minors = IDE_DISK_MINORS; 966 1100 g->driverfs_dev = &drive->gendev; 967 1101 g->flags |= GENHD_FL_EXT_DEVT; 968 - if (drive->removable) 969 - g->flags |= GENHD_FL_REMOVABLE; 970 - set_capacity(g, idedisk_capacity(drive)); 1102 + if (drive->dev_flags & IDE_DFLAG_REMOVABLE) 1103 + g->flags = GENHD_FL_REMOVABLE; 1104 + set_capacity(g, ide_disk_capacity(drive)); 971 1105 g->fops = &idedisk_ops; 972 1106 add_disk(g); 973 1107 return 0; ··· 990 1122 } 991 1123 992 1124 MODULE_ALIAS("ide:*m-disk*"); 1125 + MODULE_ALIAS("ide-disk"); 993 1126 module_init(idedisk_init); 994 1127 module_exit(idedisk_exit); 995 1128 MODULE_LICENSE("GPL");
+32
drivers/ide/ide-disk.h
··· 1 + #ifndef __IDE_DISK_H 2 + #define __IDE_DISK_H 3 + 4 + struct ide_disk_obj { 5 + ide_drive_t *drive; 6 + ide_driver_t *driver; 7 + struct gendisk *disk; 8 + struct kref kref; 9 + unsigned int openers; /* protected by BKL for now */ 10 + }; 11 + 12 + #define ide_disk_g(disk) \ 13 + container_of((disk)->private_data, struct ide_disk_obj, driver) 14 + 15 + /* ide-disk.c */ 16 + sector_t ide_disk_capacity(ide_drive_t *); 17 + ide_decl_devset(address); 18 + ide_decl_devset(multcount); 19 + ide_decl_devset(nowerr); 20 + ide_decl_devset(wcache); 21 + ide_decl_devset(acoustic); 22 + 23 + /* ide-disk_ioctl.c */ 24 + int ide_disk_ioctl(struct inode *, struct file *, unsigned int, unsigned long); 25 + 26 + #ifdef CONFIG_IDE_PROC_FS 27 + /* ide-disk_proc.c */ 28 + extern ide_proc_entry_t ide_disk_proc[]; 29 + extern const struct ide_proc_devset ide_disk_settings[]; 30 + #endif 31 + 32 + #endif /* __IDE_DISK_H */
+29
drivers/ide/ide-disk_ioctl.c
··· 1 + #include <linux/kernel.h> 2 + #include <linux/ide.h> 3 + #include <linux/hdreg.h> 4 + 5 + #include "ide-disk.h" 6 + 7 + static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = { 8 + { HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address }, 9 + { HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount }, 10 + { HDIO_GET_NOWERR, HDIO_SET_NOWERR, &ide_devset_nowerr }, 11 + { HDIO_GET_WCACHE, HDIO_SET_WCACHE, &ide_devset_wcache }, 12 + { HDIO_GET_ACOUSTIC, HDIO_SET_ACOUSTIC, &ide_devset_acoustic }, 13 + { 0 } 14 + }; 15 + 16 + int ide_disk_ioctl(struct inode *inode, struct file *file, 17 + unsigned int cmd, unsigned long arg) 18 + { 19 + struct block_device *bdev = inode->i_bdev; 20 + struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk); 21 + ide_drive_t *drive = idkp->drive; 22 + int err; 23 + 24 + err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); 25 + if (err != -EOPNOTSUPP) 26 + return err; 27 + 28 + return generic_ide_ioctl(drive, file, bdev, cmd, arg); 29 + }
+129
drivers/ide/ide-disk_proc.c
··· 1 + #include <linux/kernel.h> 2 + #include <linux/ide.h> 3 + #include <linux/hdreg.h> 4 + 5 + #include "ide-disk.h" 6 + 7 + static int smart_enable(ide_drive_t *drive) 8 + { 9 + ide_task_t args; 10 + struct ide_taskfile *tf = &args.tf; 11 + 12 + memset(&args, 0, sizeof(ide_task_t)); 13 + tf->feature = ATA_SMART_ENABLE; 14 + tf->lbam = ATA_SMART_LBAM_PASS; 15 + tf->lbah = ATA_SMART_LBAH_PASS; 16 + tf->command = ATA_CMD_SMART; 17 + args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 18 + return ide_no_data_taskfile(drive, &args); 19 + } 20 + 21 + static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) 22 + { 23 + ide_task_t args; 24 + struct ide_taskfile *tf = &args.tf; 25 + 26 + memset(&args, 0, sizeof(ide_task_t)); 27 + tf->feature = sub_cmd; 28 + tf->nsect = 0x01; 29 + tf->lbam = ATA_SMART_LBAM_PASS; 30 + tf->lbah = ATA_SMART_LBAH_PASS; 31 + tf->command = ATA_CMD_SMART; 32 + args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 33 + args.data_phase = TASKFILE_IN; 34 + (void) smart_enable(drive); 35 + return ide_raw_taskfile(drive, &args, buf, 1); 36 + } 37 + 38 + static int proc_idedisk_read_cache 39 + (char *page, char **start, off_t off, int count, int *eof, void *data) 40 + { 41 + ide_drive_t *drive = (ide_drive_t *) data; 42 + char *out = page; 43 + int len; 44 + 45 + if (drive->dev_flags & IDE_DFLAG_ID_READ) 46 + len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2); 47 + else 48 + len = sprintf(out, "(none)\n"); 49 + 50 + PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 51 + } 52 + 53 + static int proc_idedisk_read_capacity 54 + (char *page, char **start, off_t off, int count, int *eof, void *data) 55 + { 56 + ide_drive_t*drive = (ide_drive_t *)data; 57 + int len; 58 + 59 + len = sprintf(page, "%llu\n", (long long)ide_disk_capacity(drive)); 60 + 61 + PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 62 + } 63 + 64 + static int proc_idedisk_read_smart(char *page, char **start, off_t off, 65 + int count, int *eof, void *data, u8 sub_cmd) 66 + { 67 + ide_drive_t *drive = (ide_drive_t *)data; 68 + int len = 0, i = 0; 69 + 70 + if (get_smart_data(drive, page, sub_cmd) == 0) { 71 + unsigned short *val = (unsigned short *) page; 72 + char *out = (char *)val + SECTOR_SIZE; 73 + 74 + page = out; 75 + do { 76 + out += sprintf(out, "%04x%c", le16_to_cpu(*val), 77 + (++i & 7) ? ' ' : '\n'); 78 + val += 1; 79 + } while (i < SECTOR_SIZE / 2); 80 + len = out - page; 81 + } 82 + 83 + PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 84 + } 85 + 86 + static int proc_idedisk_read_sv 87 + (char *page, char **start, off_t off, int count, int *eof, void *data) 88 + { 89 + return proc_idedisk_read_smart(page, start, off, count, eof, data, 90 + ATA_SMART_READ_VALUES); 91 + } 92 + 93 + static int proc_idedisk_read_st 94 + (char *page, char **start, off_t off, int count, int *eof, void *data) 95 + { 96 + return proc_idedisk_read_smart(page, start, off, count, eof, data, 97 + ATA_SMART_READ_THRESHOLDS); 98 + } 99 + 100 + ide_proc_entry_t ide_disk_proc[] = { 101 + { "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL }, 102 + { "capacity", S_IFREG|S_IRUGO, proc_idedisk_read_capacity, NULL }, 103 + { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, 104 + { "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_sv, NULL }, 105 + { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_st, NULL }, 106 + { NULL, 0, NULL, NULL } 107 + }; 108 + 109 + ide_devset_rw_field(bios_cyl, bios_cyl); 110 + ide_devset_rw_field(bios_head, bios_head); 111 + ide_devset_rw_field(bios_sect, bios_sect); 112 + ide_devset_rw_field(failures, failures); 113 + ide_devset_rw_field(lun, lun); 114 + ide_devset_rw_field(max_failures, max_failures); 115 + 116 + const struct ide_proc_devset ide_disk_settings[] = { 117 + IDE_PROC_DEVSET(acoustic, 0, 254), 118 + IDE_PROC_DEVSET(address, 0, 2), 119 + IDE_PROC_DEVSET(bios_cyl, 0, 65535), 120 + IDE_PROC_DEVSET(bios_head, 0, 255), 121 + IDE_PROC_DEVSET(bios_sect, 0, 63), 122 + IDE_PROC_DEVSET(failures, 0, 65535), 123 + IDE_PROC_DEVSET(lun, 0, 7), 124 + IDE_PROC_DEVSET(max_failures, 0, 65535), 125 + IDE_PROC_DEVSET(multcount, 0, 16), 126 + IDE_PROC_DEVSET(nowerr, 0, 1), 127 + IDE_PROC_DEVSET(wcache, 0, 1), 128 + { 0 }, 129 + };
+356
drivers/ide/ide-dma-sff.c
··· 1 + #include <linux/types.h> 2 + #include <linux/kernel.h> 3 + #include <linux/ide.h> 4 + #include <linux/scatterlist.h> 5 + #include <linux/dma-mapping.h> 6 + #include <linux/io.h> 7 + 8 + /** 9 + * config_drive_for_dma - attempt to activate IDE DMA 10 + * @drive: the drive to place in DMA mode 11 + * 12 + * If the drive supports at least mode 2 DMA or UDMA of any kind 13 + * then attempt to place it into DMA mode. Drives that are known to 14 + * support DMA but predate the DMA properties or that are known 15 + * to have DMA handling bugs are also set up appropriately based 16 + * on the good/bad drive lists. 17 + */ 18 + 19 + int config_drive_for_dma(ide_drive_t *drive) 20 + { 21 + ide_hwif_t *hwif = drive->hwif; 22 + u16 *id = drive->id; 23 + 24 + if (drive->media != ide_disk) { 25 + if (hwif->host_flags & IDE_HFLAG_NO_ATAPI_DMA) 26 + return 0; 27 + } 28 + 29 + /* 30 + * Enable DMA on any drive that has 31 + * UltraDMA (mode 0/1/2/3/4/5/6) enabled 32 + */ 33 + if ((id[ATA_ID_FIELD_VALID] & 4) && 34 + ((id[ATA_ID_UDMA_MODES] >> 8) & 0x7f)) 35 + return 1; 36 + 37 + /* 38 + * Enable DMA on any drive that has mode2 DMA 39 + * (multi or single) enabled 40 + */ 41 + if (id[ATA_ID_FIELD_VALID] & 2) /* regular DMA */ 42 + if ((id[ATA_ID_MWDMA_MODES] & 0x404) == 0x404 || 43 + (id[ATA_ID_SWDMA_MODES] & 0x404) == 0x404) 44 + return 1; 45 + 46 + /* Consult the list of known "good" drives */ 47 + if (ide_dma_good_drive(drive)) 48 + return 1; 49 + 50 + return 0; 51 + } 52 + 53 + /** 54 + * ide_dma_host_set - Enable/disable DMA on a host 55 + * @drive: drive to control 56 + * 57 + * Enable/disable DMA on an IDE controller following generic 58 + * bus-mastering IDE controller behaviour. 59 + */ 60 + 61 + void ide_dma_host_set(ide_drive_t *drive, int on) 62 + { 63 + ide_hwif_t *hwif = drive->hwif; 64 + u8 unit = drive->dn & 1; 65 + u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 66 + 67 + if (on) 68 + dma_stat |= (1 << (5 + unit)); 69 + else 70 + dma_stat &= ~(1 << (5 + unit)); 71 + 72 + if (hwif->host_flags & IDE_HFLAG_MMIO) 73 + writeb(dma_stat, 74 + (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); 75 + else 76 + outb(dma_stat, hwif->dma_base + ATA_DMA_STATUS); 77 + } 78 + EXPORT_SYMBOL_GPL(ide_dma_host_set); 79 + 80 + /** 81 + * ide_build_dmatable - build IDE DMA table 82 + * 83 + * ide_build_dmatable() prepares a dma request. We map the command 84 + * to get the pci bus addresses of the buffers and then build up 85 + * the PRD table that the IDE layer wants to be fed. 86 + * 87 + * Most chipsets correctly interpret a length of 0x0000 as 64KB, 88 + * but at least one (e.g. CS5530) misinterprets it as zero (!). 89 + * So we break the 64KB entry into two 32KB entries instead. 90 + * 91 + * Returns the number of built PRD entries if all went okay, 92 + * returns 0 otherwise. 93 + * 94 + * May also be invoked from trm290.c 95 + */ 96 + 97 + int ide_build_dmatable(ide_drive_t *drive, struct request *rq) 98 + { 99 + ide_hwif_t *hwif = drive->hwif; 100 + __le32 *table = (__le32 *)hwif->dmatable_cpu; 101 + unsigned int is_trm290 = (hwif->chipset == ide_trm290) ? 1 : 0; 102 + unsigned int count = 0; 103 + int i; 104 + struct scatterlist *sg; 105 + 106 + hwif->sg_nents = ide_build_sglist(drive, rq); 107 + if (hwif->sg_nents == 0) 108 + return 0; 109 + 110 + for_each_sg(hwif->sg_table, sg, hwif->sg_nents, i) { 111 + u32 cur_addr, cur_len, xcount, bcount; 112 + 113 + cur_addr = sg_dma_address(sg); 114 + cur_len = sg_dma_len(sg); 115 + 116 + /* 117 + * Fill in the dma table, without crossing any 64kB boundaries. 118 + * Most hardware requires 16-bit alignment of all blocks, 119 + * but the trm290 requires 32-bit alignment. 120 + */ 121 + 122 + while (cur_len) { 123 + if (count++ >= PRD_ENTRIES) 124 + goto use_pio_instead; 125 + 126 + bcount = 0x10000 - (cur_addr & 0xffff); 127 + if (bcount > cur_len) 128 + bcount = cur_len; 129 + *table++ = cpu_to_le32(cur_addr); 130 + xcount = bcount & 0xffff; 131 + if (is_trm290) 132 + xcount = ((xcount >> 2) - 1) << 16; 133 + if (xcount == 0x0000) { 134 + if (count++ >= PRD_ENTRIES) 135 + goto use_pio_instead; 136 + *table++ = cpu_to_le32(0x8000); 137 + *table++ = cpu_to_le32(cur_addr + 0x8000); 138 + xcount = 0x8000; 139 + } 140 + *table++ = cpu_to_le32(xcount); 141 + cur_addr += bcount; 142 + cur_len -= bcount; 143 + } 144 + } 145 + 146 + if (count) { 147 + if (!is_trm290) 148 + *--table |= cpu_to_le32(0x80000000); 149 + return count; 150 + } 151 + 152 + use_pio_instead: 153 + printk(KERN_ERR "%s: %s\n", drive->name, 154 + count ? "DMA table too small" : "empty DMA table?"); 155 + 156 + ide_destroy_dmatable(drive); 157 + 158 + return 0; /* revert to PIO for this request */ 159 + } 160 + EXPORT_SYMBOL_GPL(ide_build_dmatable); 161 + 162 + /** 163 + * ide_dma_setup - begin a DMA phase 164 + * @drive: target device 165 + * 166 + * Build an IDE DMA PRD (IDE speak for scatter gather table) 167 + * and then set up the DMA transfer registers for a device 168 + * that follows generic IDE PCI DMA behaviour. Controllers can 169 + * override this function if they need to 170 + * 171 + * Returns 0 on success. If a PIO fallback is required then 1 172 + * is returned. 173 + */ 174 + 175 + int ide_dma_setup(ide_drive_t *drive) 176 + { 177 + ide_hwif_t *hwif = drive->hwif; 178 + struct request *rq = hwif->hwgroup->rq; 179 + unsigned int reading; 180 + u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; 181 + u8 dma_stat; 182 + 183 + if (rq_data_dir(rq)) 184 + reading = 0; 185 + else 186 + reading = 1 << 3; 187 + 188 + /* fall back to pio! */ 189 + if (!ide_build_dmatable(drive, rq)) { 190 + ide_map_sg(drive, rq); 191 + return 1; 192 + } 193 + 194 + /* PRD table */ 195 + if (hwif->host_flags & IDE_HFLAG_MMIO) 196 + writel(hwif->dmatable_dma, 197 + (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); 198 + else 199 + outl(hwif->dmatable_dma, hwif->dma_base + ATA_DMA_TABLE_OFS); 200 + 201 + /* specify r/w */ 202 + if (mmio) 203 + writeb(reading, (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); 204 + else 205 + outb(reading, hwif->dma_base + ATA_DMA_CMD); 206 + 207 + /* read DMA status for INTR & ERROR flags */ 208 + dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 209 + 210 + /* clear INTR & ERROR flags */ 211 + if (mmio) 212 + writeb(dma_stat | 6, 213 + (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); 214 + else 215 + outb(dma_stat | 6, hwif->dma_base + ATA_DMA_STATUS); 216 + 217 + drive->waiting_for_dma = 1; 218 + return 0; 219 + } 220 + EXPORT_SYMBOL_GPL(ide_dma_setup); 221 + 222 + /** 223 + * dma_timer_expiry - handle a DMA timeout 224 + * @drive: Drive that timed out 225 + * 226 + * An IDE DMA transfer timed out. In the event of an error we ask 227 + * the driver to resolve the problem, if a DMA transfer is still 228 + * in progress we continue to wait (arguably we need to add a 229 + * secondary 'I don't care what the drive thinks' timeout here) 230 + * Finally if we have an interrupt we let it complete the I/O. 231 + * But only one time - we clear expiry and if it's still not 232 + * completed after WAIT_CMD, we error and retry in PIO. 233 + * This can occur if an interrupt is lost or due to hang or bugs. 234 + */ 235 + 236 + static int dma_timer_expiry(ide_drive_t *drive) 237 + { 238 + ide_hwif_t *hwif = drive->hwif; 239 + u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 240 + 241 + printk(KERN_WARNING "%s: %s: DMA status (0x%02x)\n", 242 + drive->name, __func__, dma_stat); 243 + 244 + if ((dma_stat & 0x18) == 0x18) /* BUSY Stupid Early Timer !! */ 245 + return WAIT_CMD; 246 + 247 + hwif->hwgroup->expiry = NULL; /* one free ride for now */ 248 + 249 + /* 1 dmaing, 2 error, 4 intr */ 250 + if (dma_stat & 2) /* ERROR */ 251 + return -1; 252 + 253 + if (dma_stat & 1) /* DMAing */ 254 + return WAIT_CMD; 255 + 256 + if (dma_stat & 4) /* Got an Interrupt */ 257 + return WAIT_CMD; 258 + 259 + return 0; /* Status is unknown -- reset the bus */ 260 + } 261 + 262 + void ide_dma_exec_cmd(ide_drive_t *drive, u8 command) 263 + { 264 + /* issue cmd to drive */ 265 + ide_execute_command(drive, command, &ide_dma_intr, 2 * WAIT_CMD, 266 + dma_timer_expiry); 267 + } 268 + EXPORT_SYMBOL_GPL(ide_dma_exec_cmd); 269 + 270 + void ide_dma_start(ide_drive_t *drive) 271 + { 272 + ide_hwif_t *hwif = drive->hwif; 273 + u8 dma_cmd; 274 + 275 + /* Note that this is done *after* the cmd has 276 + * been issued to the drive, as per the BM-IDE spec. 277 + * The Promise Ultra33 doesn't work correctly when 278 + * we do this part before issuing the drive cmd. 279 + */ 280 + if (hwif->host_flags & IDE_HFLAG_MMIO) { 281 + dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); 282 + /* start DMA */ 283 + writeb(dma_cmd | 1, 284 + (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); 285 + } else { 286 + dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); 287 + outb(dma_cmd | 1, hwif->dma_base + ATA_DMA_CMD); 288 + } 289 + 290 + wmb(); 291 + } 292 + EXPORT_SYMBOL_GPL(ide_dma_start); 293 + 294 + /* returns 1 on error, 0 otherwise */ 295 + int ide_dma_end(ide_drive_t *drive) 296 + { 297 + ide_hwif_t *hwif = drive->hwif; 298 + u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; 299 + u8 dma_stat = 0, dma_cmd = 0; 300 + 301 + drive->waiting_for_dma = 0; 302 + 303 + if (mmio) { 304 + /* get DMA command mode */ 305 + dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); 306 + /* stop DMA */ 307 + writeb(dma_cmd & ~1, 308 + (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); 309 + } else { 310 + dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); 311 + outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD); 312 + } 313 + 314 + /* get DMA status */ 315 + dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 316 + 317 + if (mmio) 318 + /* clear the INTR & ERROR bits */ 319 + writeb(dma_stat | 6, 320 + (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); 321 + else 322 + outb(dma_stat | 6, hwif->dma_base + ATA_DMA_STATUS); 323 + 324 + /* purge DMA mappings */ 325 + ide_destroy_dmatable(drive); 326 + /* verify good DMA status */ 327 + wmb(); 328 + return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0; 329 + } 330 + EXPORT_SYMBOL_GPL(ide_dma_end); 331 + 332 + /* returns 1 if dma irq issued, 0 otherwise */ 333 + int ide_dma_test_irq(ide_drive_t *drive) 334 + { 335 + ide_hwif_t *hwif = drive->hwif; 336 + u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 337 + 338 + /* return 1 if INTR asserted */ 339 + if ((dma_stat & 4) == 4) 340 + return 1; 341 + 342 + return 0; 343 + } 344 + EXPORT_SYMBOL_GPL(ide_dma_test_irq); 345 + 346 + const struct ide_dma_ops sff_dma_ops = { 347 + .dma_host_set = ide_dma_host_set, 348 + .dma_setup = ide_dma_setup, 349 + .dma_exec_cmd = ide_dma_exec_cmd, 350 + .dma_start = ide_dma_start, 351 + .dma_end = ide_dma_end, 352 + .dma_test_irq = ide_dma_test_irq, 353 + .dma_timeout = ide_dma_timeout, 354 + .dma_lost_irq = ide_dma_lost_irq, 355 + }; 356 + EXPORT_SYMBOL_GPL(sff_dma_ops);
+45 -436
drivers/ide/ide-dma.c
··· 28 28 * for supplying a Promise UDMA board & WD UDMA drive for this work! 29 29 */ 30 30 31 - #include <linux/module.h> 32 31 #include <linux/types.h> 33 32 #include <linux/kernel.h> 34 - #include <linux/timer.h> 35 - #include <linux/mm.h> 36 - #include <linux/interrupt.h> 37 - #include <linux/pci.h> 38 - #include <linux/init.h> 39 33 #include <linux/ide.h> 40 - #include <linux/delay.h> 41 34 #include <linux/scatterlist.h> 42 35 #include <linux/dma-mapping.h> 43 36 44 - #include <asm/io.h> 45 - #include <asm/irq.h> 46 - 47 - static const struct drive_list_entry drive_whitelist [] = { 48 - 37 + static const struct drive_list_entry drive_whitelist[] = { 49 38 { "Micropolis 2112A" , NULL }, 50 39 { "CONNER CTMA 4000" , NULL }, 51 40 { "CONNER CTT8000-A" , NULL }, ··· 42 53 { NULL , NULL } 43 54 }; 44 55 45 - static const struct drive_list_entry drive_blacklist [] = { 46 - 56 + static const struct drive_list_entry drive_blacklist[] = { 47 57 { "WDC AC11000H" , NULL }, 48 58 { "WDC AC22100H" , NULL }, 49 59 { "WDC AC32500H" , NULL }, ··· 82 94 * ide_dma_intr - IDE DMA interrupt handler 83 95 * @drive: the drive the interrupt is for 84 96 * 85 - * Handle an interrupt completing a read/write DMA transfer on an 97 + * Handle an interrupt completing a read/write DMA transfer on an 86 98 * IDE device 87 99 */ 88 - 89 - ide_startstop_t ide_dma_intr (ide_drive_t *drive) 100 + 101 + ide_startstop_t ide_dma_intr(ide_drive_t *drive) 90 102 { 91 103 ide_hwif_t *hwif = drive->hwif; 92 104 u8 stat = 0, dma_stat = 0; ··· 96 108 97 109 if (OK_STAT(stat, DRIVE_READY, drive->bad_wstat | ATA_DRQ)) { 98 110 if (!dma_stat) { 99 - struct request *rq = HWGROUP(drive)->rq; 111 + struct request *rq = hwif->hwgroup->rq; 100 112 101 113 task_end_request(drive, rq, stat); 102 114 return ide_stopped; 103 115 } 104 - printk(KERN_ERR "%s: dma_intr: bad DMA status (dma_stat=%x)\n", 105 - drive->name, dma_stat); 116 + printk(KERN_ERR "%s: %s: bad DMA status (0x%02x)\n", 117 + drive->name, __func__, dma_stat); 106 118 } 107 119 return ide_error(drive, "dma_intr", stat); 108 120 } 109 - 110 121 EXPORT_SYMBOL_GPL(ide_dma_intr); 111 122 112 - static int ide_dma_good_drive(ide_drive_t *drive) 123 + int ide_dma_good_drive(ide_drive_t *drive) 113 124 { 114 125 return ide_in_drive_list(drive->id, drive_whitelist); 115 126 } ··· 126 139 127 140 int ide_build_sglist(ide_drive_t *drive, struct request *rq) 128 141 { 129 - ide_hwif_t *hwif = HWIF(drive); 142 + ide_hwif_t *hwif = drive->hwif; 130 143 struct scatterlist *sg = hwif->sg_table; 131 144 132 145 ide_map_sg(drive, rq); ··· 139 152 return dma_map_sg(hwif->dev, sg, hwif->sg_nents, 140 153 hwif->sg_dma_direction); 141 154 } 142 - 143 155 EXPORT_SYMBOL_GPL(ide_build_sglist); 144 - 145 - #ifdef CONFIG_BLK_DEV_IDEDMA_SFF 146 - /** 147 - * ide_build_dmatable - build IDE DMA table 148 - * 149 - * ide_build_dmatable() prepares a dma request. We map the command 150 - * to get the pci bus addresses of the buffers and then build up 151 - * the PRD table that the IDE layer wants to be fed. The code 152 - * knows about the 64K wrap bug in the CS5530. 153 - * 154 - * Returns the number of built PRD entries if all went okay, 155 - * returns 0 otherwise. 156 - * 157 - * May also be invoked from trm290.c 158 - */ 159 - 160 - int ide_build_dmatable (ide_drive_t *drive, struct request *rq) 161 - { 162 - ide_hwif_t *hwif = HWIF(drive); 163 - __le32 *table = (__le32 *)hwif->dmatable_cpu; 164 - unsigned int is_trm290 = (hwif->chipset == ide_trm290) ? 1 : 0; 165 - unsigned int count = 0; 166 - int i; 167 - struct scatterlist *sg; 168 - 169 - hwif->sg_nents = i = ide_build_sglist(drive, rq); 170 - 171 - if (!i) 172 - return 0; 173 - 174 - sg = hwif->sg_table; 175 - while (i) { 176 - u32 cur_addr; 177 - u32 cur_len; 178 - 179 - cur_addr = sg_dma_address(sg); 180 - cur_len = sg_dma_len(sg); 181 - 182 - /* 183 - * Fill in the dma table, without crossing any 64kB boundaries. 184 - * Most hardware requires 16-bit alignment of all blocks, 185 - * but the trm290 requires 32-bit alignment. 186 - */ 187 - 188 - while (cur_len) { 189 - if (count++ >= PRD_ENTRIES) { 190 - printk(KERN_ERR "%s: DMA table too small\n", drive->name); 191 - goto use_pio_instead; 192 - } else { 193 - u32 xcount, bcount = 0x10000 - (cur_addr & 0xffff); 194 - 195 - if (bcount > cur_len) 196 - bcount = cur_len; 197 - *table++ = cpu_to_le32(cur_addr); 198 - xcount = bcount & 0xffff; 199 - if (is_trm290) 200 - xcount = ((xcount >> 2) - 1) << 16; 201 - else if (xcount == 0x0000) { 202 - /* 203 - * Most chipsets correctly interpret a length of 0x0000 as 64KB, 204 - * but at least one (e.g. CS5530) misinterprets it as zero (!). 205 - * So here we break the 64KB entry into two 32KB entries instead. 206 - */ 207 - if (count++ >= PRD_ENTRIES) { 208 - printk(KERN_ERR "%s: DMA table too small\n", drive->name); 209 - goto use_pio_instead; 210 - } 211 - *table++ = cpu_to_le32(0x8000); 212 - *table++ = cpu_to_le32(cur_addr + 0x8000); 213 - xcount = 0x8000; 214 - } 215 - *table++ = cpu_to_le32(xcount); 216 - cur_addr += bcount; 217 - cur_len -= bcount; 218 - } 219 - } 220 - 221 - sg = sg_next(sg); 222 - i--; 223 - } 224 - 225 - if (count) { 226 - if (!is_trm290) 227 - *--table |= cpu_to_le32(0x80000000); 228 - return count; 229 - } 230 - 231 - printk(KERN_ERR "%s: empty DMA table?\n", drive->name); 232 - 233 - use_pio_instead: 234 - ide_destroy_dmatable(drive); 235 - 236 - return 0; /* revert to PIO for this request */ 237 - } 238 - 239 - EXPORT_SYMBOL_GPL(ide_build_dmatable); 240 - #endif 241 156 242 157 /** 243 158 * ide_destroy_dmatable - clean up DMA mapping ··· 151 262 * an oops as only one mapping can be live for each target at a given 152 263 * time. 153 264 */ 154 - 155 - void ide_destroy_dmatable (ide_drive_t *drive) 265 + 266 + void ide_destroy_dmatable(ide_drive_t *drive) 156 267 { 157 268 ide_hwif_t *hwif = drive->hwif; 158 269 159 270 dma_unmap_sg(hwif->dev, hwif->sg_table, hwif->sg_nents, 160 271 hwif->sg_dma_direction); 161 272 } 162 - 163 273 EXPORT_SYMBOL_GPL(ide_destroy_dmatable); 164 - 165 - #ifdef CONFIG_BLK_DEV_IDEDMA_SFF 166 - /** 167 - * config_drive_for_dma - attempt to activate IDE DMA 168 - * @drive: the drive to place in DMA mode 169 - * 170 - * If the drive supports at least mode 2 DMA or UDMA of any kind 171 - * then attempt to place it into DMA mode. Drives that are known to 172 - * support DMA but predate the DMA properties or that are known 173 - * to have DMA handling bugs are also set up appropriately based 174 - * on the good/bad drive lists. 175 - */ 176 - 177 - static int config_drive_for_dma (ide_drive_t *drive) 178 - { 179 - ide_hwif_t *hwif = drive->hwif; 180 - u16 *id = drive->id; 181 - 182 - if (drive->media != ide_disk) { 183 - if (hwif->host_flags & IDE_HFLAG_NO_ATAPI_DMA) 184 - return 0; 185 - } 186 - 187 - /* 188 - * Enable DMA on any drive that has 189 - * UltraDMA (mode 0/1/2/3/4/5/6) enabled 190 - */ 191 - if ((id[ATA_ID_FIELD_VALID] & 4) && 192 - ((id[ATA_ID_UDMA_MODES] >> 8) & 0x7f)) 193 - return 1; 194 - 195 - /* 196 - * Enable DMA on any drive that has mode2 DMA 197 - * (multi or single) enabled 198 - */ 199 - if (id[ATA_ID_FIELD_VALID] & 2) /* regular DMA */ 200 - if ((id[ATA_ID_MWDMA_MODES] & 0x404) == 0x404 || 201 - (id[ATA_ID_SWDMA_MODES] & 0x404) == 0x404) 202 - return 1; 203 - 204 - /* Consult the list of known "good" drives */ 205 - if (ide_dma_good_drive(drive)) 206 - return 1; 207 - 208 - return 0; 209 - } 210 - 211 - /** 212 - * dma_timer_expiry - handle a DMA timeout 213 - * @drive: Drive that timed out 214 - * 215 - * An IDE DMA transfer timed out. In the event of an error we ask 216 - * the driver to resolve the problem, if a DMA transfer is still 217 - * in progress we continue to wait (arguably we need to add a 218 - * secondary 'I don't care what the drive thinks' timeout here) 219 - * Finally if we have an interrupt we let it complete the I/O. 220 - * But only one time - we clear expiry and if it's still not 221 - * completed after WAIT_CMD, we error and retry in PIO. 222 - * This can occur if an interrupt is lost or due to hang or bugs. 223 - */ 224 - 225 - static int dma_timer_expiry (ide_drive_t *drive) 226 - { 227 - ide_hwif_t *hwif = HWIF(drive); 228 - u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 229 - 230 - printk(KERN_WARNING "%s: dma_timer_expiry: dma status == 0x%02x\n", 231 - drive->name, dma_stat); 232 - 233 - if ((dma_stat & 0x18) == 0x18) /* BUSY Stupid Early Timer !! */ 234 - return WAIT_CMD; 235 - 236 - HWGROUP(drive)->expiry = NULL; /* one free ride for now */ 237 - 238 - /* 1 dmaing, 2 error, 4 intr */ 239 - if (dma_stat & 2) /* ERROR */ 240 - return -1; 241 - 242 - if (dma_stat & 1) /* DMAing */ 243 - return WAIT_CMD; 244 - 245 - if (dma_stat & 4) /* Got an Interrupt */ 246 - return WAIT_CMD; 247 - 248 - return 0; /* Status is unknown -- reset the bus */ 249 - } 250 - 251 - /** 252 - * ide_dma_host_set - Enable/disable DMA on a host 253 - * @drive: drive to control 254 - * 255 - * Enable/disable DMA on an IDE controller following generic 256 - * bus-mastering IDE controller behaviour. 257 - */ 258 - 259 - void ide_dma_host_set(ide_drive_t *drive, int on) 260 - { 261 - ide_hwif_t *hwif = HWIF(drive); 262 - u8 unit = (drive->select.b.unit & 0x01); 263 - u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 264 - 265 - if (on) 266 - dma_stat |= (1 << (5 + unit)); 267 - else 268 - dma_stat &= ~(1 << (5 + unit)); 269 - 270 - if (hwif->host_flags & IDE_HFLAG_MMIO) 271 - writeb(dma_stat, 272 - (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); 273 - else 274 - outb(dma_stat, hwif->dma_base + ATA_DMA_STATUS); 275 - } 276 - 277 - EXPORT_SYMBOL_GPL(ide_dma_host_set); 278 - #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ 279 274 280 275 /** 281 276 * ide_dma_off_quietly - Generic DMA kill 282 277 * @drive: drive to control 283 278 * 284 - * Turn off the current DMA on this IDE controller. 279 + * Turn off the current DMA on this IDE controller. 285 280 */ 286 281 287 282 void ide_dma_off_quietly(ide_drive_t *drive) 288 283 { 289 - drive->using_dma = 0; 284 + drive->dev_flags &= ~IDE_DFLAG_USING_DMA; 290 285 ide_toggle_bounce(drive, 0); 291 286 292 287 drive->hwif->dma_ops->dma_host_set(drive, 0); 293 288 } 294 - 295 289 EXPORT_SYMBOL(ide_dma_off_quietly); 296 290 297 291 /** ··· 190 418 printk(KERN_INFO "%s: DMA disabled\n", drive->name); 191 419 ide_dma_off_quietly(drive); 192 420 } 193 - 194 421 EXPORT_SYMBOL(ide_dma_off); 195 422 196 423 /** ··· 201 430 202 431 void ide_dma_on(ide_drive_t *drive) 203 432 { 204 - drive->using_dma = 1; 433 + drive->dev_flags |= IDE_DFLAG_USING_DMA; 205 434 ide_toggle_bounce(drive, 1); 206 435 207 436 drive->hwif->dma_ops->dma_host_set(drive, 1); 208 437 } 209 438 210 - #ifdef CONFIG_BLK_DEV_IDEDMA_SFF 211 - /** 212 - * ide_dma_setup - begin a DMA phase 213 - * @drive: target device 214 - * 215 - * Build an IDE DMA PRD (IDE speak for scatter gather table) 216 - * and then set up the DMA transfer registers for a device 217 - * that follows generic IDE PCI DMA behaviour. Controllers can 218 - * override this function if they need to 219 - * 220 - * Returns 0 on success. If a PIO fallback is required then 1 221 - * is returned. 222 - */ 223 - 224 - int ide_dma_setup(ide_drive_t *drive) 225 - { 226 - ide_hwif_t *hwif = drive->hwif; 227 - struct request *rq = HWGROUP(drive)->rq; 228 - unsigned int reading; 229 - u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; 230 - u8 dma_stat; 231 - 232 - if (rq_data_dir(rq)) 233 - reading = 0; 234 - else 235 - reading = 1 << 3; 236 - 237 - /* fall back to pio! */ 238 - if (!ide_build_dmatable(drive, rq)) { 239 - ide_map_sg(drive, rq); 240 - return 1; 241 - } 242 - 243 - /* PRD table */ 244 - if (hwif->host_flags & IDE_HFLAG_MMIO) 245 - writel(hwif->dmatable_dma, 246 - (void __iomem *)(hwif->dma_base + ATA_DMA_TABLE_OFS)); 247 - else 248 - outl(hwif->dmatable_dma, hwif->dma_base + ATA_DMA_TABLE_OFS); 249 - 250 - /* specify r/w */ 251 - if (mmio) 252 - writeb(reading, (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); 253 - else 254 - outb(reading, hwif->dma_base + ATA_DMA_CMD); 255 - 256 - /* read DMA status for INTR & ERROR flags */ 257 - dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 258 - 259 - /* clear INTR & ERROR flags */ 260 - if (mmio) 261 - writeb(dma_stat | 6, 262 - (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); 263 - else 264 - outb(dma_stat | 6, hwif->dma_base + ATA_DMA_STATUS); 265 - 266 - drive->waiting_for_dma = 1; 267 - return 0; 268 - } 269 - 270 - EXPORT_SYMBOL_GPL(ide_dma_setup); 271 - 272 - void ide_dma_exec_cmd(ide_drive_t *drive, u8 command) 273 - { 274 - /* issue cmd to drive */ 275 - ide_execute_command(drive, command, &ide_dma_intr, 2*WAIT_CMD, dma_timer_expiry); 276 - } 277 - EXPORT_SYMBOL_GPL(ide_dma_exec_cmd); 278 - 279 - void ide_dma_start(ide_drive_t *drive) 280 - { 281 - ide_hwif_t *hwif = drive->hwif; 282 - u8 dma_cmd; 283 - 284 - /* Note that this is done *after* the cmd has 285 - * been issued to the drive, as per the BM-IDE spec. 286 - * The Promise Ultra33 doesn't work correctly when 287 - * we do this part before issuing the drive cmd. 288 - */ 289 - if (hwif->host_flags & IDE_HFLAG_MMIO) { 290 - dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); 291 - /* start DMA */ 292 - writeb(dma_cmd | 1, 293 - (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); 294 - } else { 295 - dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); 296 - outb(dma_cmd | 1, hwif->dma_base + ATA_DMA_CMD); 297 - } 298 - 299 - hwif->dma = 1; 300 - wmb(); 301 - } 302 - 303 - EXPORT_SYMBOL_GPL(ide_dma_start); 304 - 305 - /* returns 1 on error, 0 otherwise */ 306 - int __ide_dma_end (ide_drive_t *drive) 307 - { 308 - ide_hwif_t *hwif = drive->hwif; 309 - u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; 310 - u8 dma_stat = 0, dma_cmd = 0; 311 - 312 - drive->waiting_for_dma = 0; 313 - 314 - if (mmio) { 315 - /* get DMA command mode */ 316 - dma_cmd = readb((void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); 317 - /* stop DMA */ 318 - writeb(dma_cmd & ~1, 319 - (void __iomem *)(hwif->dma_base + ATA_DMA_CMD)); 320 - } else { 321 - dma_cmd = inb(hwif->dma_base + ATA_DMA_CMD); 322 - outb(dma_cmd & ~1, hwif->dma_base + ATA_DMA_CMD); 323 - } 324 - 325 - /* get DMA status */ 326 - dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 327 - 328 - if (mmio) 329 - /* clear the INTR & ERROR bits */ 330 - writeb(dma_stat | 6, 331 - (void __iomem *)(hwif->dma_base + ATA_DMA_STATUS)); 332 - else 333 - outb(dma_stat | 6, hwif->dma_base + ATA_DMA_STATUS); 334 - 335 - /* purge DMA mappings */ 336 - ide_destroy_dmatable(drive); 337 - /* verify good DMA status */ 338 - hwif->dma = 0; 339 - wmb(); 340 - return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0; 341 - } 342 - 343 - EXPORT_SYMBOL(__ide_dma_end); 344 - 345 - /* returns 1 if dma irq issued, 0 otherwise */ 346 - int ide_dma_test_irq(ide_drive_t *drive) 347 - { 348 - ide_hwif_t *hwif = HWIF(drive); 349 - u8 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 350 - 351 - /* return 1 if INTR asserted */ 352 - if ((dma_stat & 4) == 4) 353 - return 1; 354 - if (!drive->waiting_for_dma) 355 - printk(KERN_WARNING "%s: (%s) called while not waiting\n", 356 - drive->name, __func__); 357 - return 0; 358 - } 359 - EXPORT_SYMBOL_GPL(ide_dma_test_irq); 360 - #else 361 - static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } 362 - #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ 363 - 364 - int __ide_dma_bad_drive (ide_drive_t *drive) 439 + int __ide_dma_bad_drive(ide_drive_t *drive) 365 440 { 366 441 u16 *id = drive->id; 367 442 ··· 219 602 } 220 603 return 0; 221 604 } 222 - 223 605 EXPORT_SYMBOL(__ide_dma_bad_drive); 224 606 225 607 static const u8 xfer_mode_bases[] = { ··· 234 618 const struct ide_port_ops *port_ops = hwif->port_ops; 235 619 unsigned int mask = 0; 236 620 237 - switch(base) { 621 + switch (base) { 238 622 case XFER_UDMA_0: 239 623 if ((id[ATA_ID_FIELD_VALID] & 4) == 0) 240 624 break; ··· 335 719 336 720 return mode; 337 721 } 338 - 339 722 EXPORT_SYMBOL_GPL(ide_find_dma_mode); 340 723 341 724 static int ide_tune_dma(ide_drive_t *drive) ··· 342 727 ide_hwif_t *hwif = drive->hwif; 343 728 u8 speed; 344 729 345 - if (drive->nodma || ata_id_has_dma(drive->id) == 0) 730 + if (ata_id_has_dma(drive->id) == 0 || 731 + (drive->dev_flags & IDE_DFLAG_NODMA)) 346 732 return 0; 347 733 348 734 /* consult the list of known "bad" drives */ ··· 443 827 ide_dma_on(drive); 444 828 } 445 829 446 - #ifdef CONFIG_BLK_DEV_IDEDMA_SFF 447 - void ide_dma_lost_irq (ide_drive_t *drive) 830 + void ide_dma_lost_irq(ide_drive_t *drive) 448 831 { 449 - printk("%s: DMA interrupt recovery\n", drive->name); 832 + printk(KERN_ERR "%s: DMA interrupt recovery\n", drive->name); 450 833 } 834 + EXPORT_SYMBOL_GPL(ide_dma_lost_irq); 451 835 452 - EXPORT_SYMBOL(ide_dma_lost_irq); 453 - 454 - void ide_dma_timeout (ide_drive_t *drive) 836 + void ide_dma_timeout(ide_drive_t *drive) 455 837 { 456 - ide_hwif_t *hwif = HWIF(drive); 838 + ide_hwif_t *hwif = drive->hwif; 457 839 458 840 printk(KERN_ERR "%s: timeout waiting for DMA\n", drive->name); 459 841 460 842 if (hwif->dma_ops->dma_test_irq(drive)) 461 843 return; 462 844 845 + ide_dump_status(drive, "DMA timeout", hwif->tp_ops->read_status(hwif)); 846 + 463 847 hwif->dma_ops->dma_end(drive); 464 848 } 465 - 466 - EXPORT_SYMBOL(ide_dma_timeout); 849 + EXPORT_SYMBOL_GPL(ide_dma_timeout); 467 850 468 851 void ide_release_dma_engine(ide_hwif_t *hwif) 469 852 { 470 853 if (hwif->dmatable_cpu) { 471 - struct pci_dev *pdev = to_pci_dev(hwif->dev); 854 + int prd_size = hwif->prd_max_nents * hwif->prd_ent_size; 472 855 473 - pci_free_consistent(pdev, PRD_ENTRIES * PRD_BYTES, 474 - hwif->dmatable_cpu, hwif->dmatable_dma); 856 + dma_free_coherent(hwif->dev, prd_size, 857 + hwif->dmatable_cpu, hwif->dmatable_dma); 475 858 hwif->dmatable_cpu = NULL; 476 859 } 477 860 } 861 + EXPORT_SYMBOL_GPL(ide_release_dma_engine); 478 862 479 863 int ide_allocate_dma_engine(ide_hwif_t *hwif) 480 864 { 481 - struct pci_dev *pdev = to_pci_dev(hwif->dev); 865 + int prd_size; 482 866 483 - hwif->dmatable_cpu = pci_alloc_consistent(pdev, 484 - PRD_ENTRIES * PRD_BYTES, 485 - &hwif->dmatable_dma); 867 + if (hwif->prd_max_nents == 0) 868 + hwif->prd_max_nents = PRD_ENTRIES; 869 + if (hwif->prd_ent_size == 0) 870 + hwif->prd_ent_size = PRD_BYTES; 486 871 487 - if (hwif->dmatable_cpu) 488 - return 0; 872 + prd_size = hwif->prd_max_nents * hwif->prd_ent_size; 489 873 490 - printk(KERN_ERR "%s: -- Error, unable to allocate DMA table.\n", 874 + hwif->dmatable_cpu = dma_alloc_coherent(hwif->dev, prd_size, 875 + &hwif->dmatable_dma, 876 + GFP_ATOMIC); 877 + if (hwif->dmatable_cpu == NULL) { 878 + printk(KERN_ERR "%s: unable to allocate PRD table\n", 491 879 hwif->name); 880 + return -ENOMEM; 881 + } 492 882 493 - return 1; 883 + return 0; 494 884 } 495 885 EXPORT_SYMBOL_GPL(ide_allocate_dma_engine); 496 - 497 - const struct ide_dma_ops sff_dma_ops = { 498 - .dma_host_set = ide_dma_host_set, 499 - .dma_setup = ide_dma_setup, 500 - .dma_exec_cmd = ide_dma_exec_cmd, 501 - .dma_start = ide_dma_start, 502 - .dma_end = __ide_dma_end, 503 - .dma_test_irq = ide_dma_test_irq, 504 - .dma_timeout = ide_dma_timeout, 505 - .dma_lost_irq = ide_dma_lost_irq, 506 - }; 507 - EXPORT_SYMBOL_GPL(sff_dma_ops); 508 - #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */
+114 -278
drivers/ide/ide-floppy.c
··· 16 16 */ 17 17 18 18 #define DRV_NAME "ide-floppy" 19 + #define PFX DRV_NAME ": " 19 20 20 21 #define IDEFLOPPY_VERSION "1.00" 21 22 ··· 49 48 50 49 #include "ide-floppy.h" 51 50 52 - /* define to see debug info */ 53 - #define IDEFLOPPY_DEBUG_LOG 0 51 + /* module parameters */ 52 + static unsigned long debug_mask; 53 + module_param(debug_mask, ulong, 0644); 54 54 55 - /* #define IDEFLOPPY_DEBUG(fmt, args...) printk(KERN_INFO fmt, ## args) */ 56 - #define IDEFLOPPY_DEBUG(fmt, args...) 55 + /* define to see debug info */ 56 + #define IDEFLOPPY_DEBUG_LOG 0 57 57 58 58 #if IDEFLOPPY_DEBUG_LOG 59 - #define debug_log(fmt, args...) \ 60 - printk(KERN_INFO "ide-floppy: " fmt, ## args) 59 + #define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args) 61 60 #else 62 - #define debug_log(fmt, args...) do {} while (0) 61 + #define ide_debug_log(lvl, fmt, args...) do {} while (0) 63 62 #endif 64 63 65 64 /* ··· 74 73 #define CAPACITY_CURRENT 0x02 75 74 #define CAPACITY_NO_CARTRIDGE 0x03 76 75 77 - #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ 76 + /* 77 + * The following delay solves a problem with ATAPI Zip 100 drive where BSY bit 78 + * was apparently being deasserted before the unit was ready to receive data. 79 + */ 80 + #define IDEFLOPPY_PC_DELAY (HZ/20) /* default delay for ZIP 100 (50ms) */ 78 81 79 82 /* Error code returned in rq->errors to the higher part of the driver. */ 80 83 #define IDEFLOPPY_ERROR_GENERAL 101 81 84 82 85 static DEFINE_MUTEX(idefloppy_ref_mutex); 83 - 84 - #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) 85 - 86 - #define ide_floppy_g(disk) \ 87 - container_of((disk)->private_data, struct ide_floppy_obj, driver) 88 86 89 87 static void idefloppy_cleanup_obj(struct kref *); 90 88 ··· 92 92 struct ide_floppy_obj *floppy = NULL; 93 93 94 94 mutex_lock(&idefloppy_ref_mutex); 95 - floppy = ide_floppy_g(disk); 95 + floppy = ide_drv_g(disk, ide_floppy_obj); 96 96 if (floppy) { 97 97 if (ide_device_get(floppy->drive)) 98 98 floppy = NULL; ··· 123 123 struct request *rq = HWGROUP(drive)->rq; 124 124 int error; 125 125 126 - debug_log("Reached %s\n", __func__); 126 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 127 127 128 128 switch (uptodate) { 129 - case 0: error = IDEFLOPPY_ERROR_GENERAL; break; 130 - case 1: error = 0; break; 131 - default: error = uptodate; 129 + case 0: 130 + error = IDEFLOPPY_ERROR_GENERAL; 131 + break; 132 + 133 + case 1: 134 + error = 0; 135 + break; 136 + 137 + default: 138 + error = uptodate; 132 139 } 140 + 133 141 if (error) 134 142 floppy->failed_pc = NULL; 135 143 /* Why does this happen? */ ··· 164 156 idefloppy_end_request(drive, 1, 0); 165 157 } 166 158 167 - static void ide_floppy_callback(ide_drive_t *drive) 159 + static void ide_floppy_callback(ide_drive_t *drive, int dsc) 168 160 { 169 161 idefloppy_floppy_t *floppy = drive->driver_data; 170 - struct ide_atapi_pc *pc = floppy->pc; 162 + struct ide_atapi_pc *pc = drive->pc; 171 163 int uptodate = pc->error ? 0 : 1; 172 164 173 - debug_log("Reached %s\n", __func__); 165 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 174 166 175 167 if (floppy->failed_pc == pc) 176 168 floppy->failed_pc = NULL; ··· 179 171 (pc->rq && blk_pc_request(pc->rq))) 180 172 uptodate = 1; /* FIXME */ 181 173 else if (pc->c[0] == GPCMD_REQUEST_SENSE) { 182 - u8 *buf = floppy->pc->buf; 174 + u8 *buf = pc->buf; 183 175 184 176 if (!pc->error) { 185 177 floppy->sense_key = buf[2] & 0x0F; ··· 189 181 (u16)get_unaligned((u16 *)&buf[16]) : 0x10000; 190 182 191 183 if (floppy->failed_pc) 192 - debug_log("pc = %x, ", floppy->failed_pc->c[0]); 184 + ide_debug_log(IDE_DBG_PC, "pc = %x, ", 185 + floppy->failed_pc->c[0]); 193 186 194 - debug_log("sense key = %x, asc = %x, ascq = %x\n", 195 - floppy->sense_key, floppy->asc, floppy->ascq); 187 + ide_debug_log(IDE_DBG_SENSE, "sense key = %x, asc = %x," 188 + "ascq = %x\n", floppy->sense_key, 189 + floppy->asc, floppy->ascq); 196 190 } else 197 - printk(KERN_ERR "Error in REQUEST SENSE itself - " 198 - "Aborting request!\n"); 191 + printk(KERN_ERR PFX "Error in REQUEST SENSE itself - " 192 + "Aborting request!\n"); 199 193 } 200 194 201 195 idefloppy_end_request(drive, uptodate, 0); 202 - } 203 - 204 - void ide_floppy_create_request_sense_cmd(struct ide_atapi_pc *pc) 205 - { 206 - ide_init_pc(pc); 207 - pc->c[0] = GPCMD_REQUEST_SENSE; 208 - pc->c[4] = 255; 209 - pc->req_xfer = 18; 210 - } 211 - 212 - /* 213 - * Called when an error was detected during the last packet command. We queue a 214 - * request sense packet command in the head of the request list. 215 - */ 216 - static void idefloppy_retry_pc(ide_drive_t *drive) 217 - { 218 - struct ide_floppy_obj *floppy = drive->driver_data; 219 - struct request *rq = &floppy->request_sense_rq; 220 - struct ide_atapi_pc *pc = &floppy->request_sense_pc; 221 - 222 - (void)ide_read_error(drive); 223 - ide_floppy_create_request_sense_cmd(pc); 224 - ide_queue_pc_head(drive, floppy->disk, pc, rq); 225 - } 226 - 227 - /* The usual interrupt handler called during a packet command. */ 228 - static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) 229 - { 230 - idefloppy_floppy_t *floppy = drive->driver_data; 231 - 232 - return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr, 233 - WAIT_FLOPPY_CMD, NULL, idefloppy_update_buffers, 234 - idefloppy_retry_pc, NULL, ide_io_buffers); 235 - } 236 - 237 - /* 238 - * What we have here is a classic case of a top half / bottom half interrupt 239 - * service routine. In interrupt mode, the device sends an interrupt to signal 240 - * that it is ready to receive a packet. However, we need to delay about 2-3 241 - * ticks before issuing the packet or we gets in trouble. 242 - */ 243 - static int idefloppy_transfer_pc(ide_drive_t *drive) 244 - { 245 - idefloppy_floppy_t *floppy = drive->driver_data; 246 - 247 - /* Send the actual packet */ 248 - drive->hwif->tp_ops->output_data(drive, NULL, floppy->pc->c, 12); 249 - 250 - /* Timeout for the packet command */ 251 - return WAIT_FLOPPY_CMD; 252 - } 253 - 254 - /* 255 - * Called as an interrupt (or directly). When the device says it's ready for a 256 - * packet, we schedule the packet transfer to occur about 2-3 ticks later in 257 - * transfer_pc. 258 - */ 259 - static ide_startstop_t idefloppy_start_pc_transfer(ide_drive_t *drive) 260 - { 261 - idefloppy_floppy_t *floppy = drive->driver_data; 262 - struct ide_atapi_pc *pc = floppy->pc; 263 - ide_expiry_t *expiry; 264 - unsigned int timeout; 265 - 266 - /* 267 - * The following delay solves a problem with ATAPI Zip 100 drives 268 - * where the Busy flag was apparently being deasserted before the 269 - * unit was ready to receive data. This was happening on a 270 - * 1200 MHz Athlon system. 10/26/01 25msec is too short, 271 - * 40 and 50msec work well. idefloppy_pc_intr will not be actually 272 - * used until after the packet is moved in about 50 msec. 273 - */ 274 - if (drive->atapi_flags & IDE_AFLAG_ZIP_DRIVE) { 275 - timeout = floppy->ticks; 276 - expiry = &idefloppy_transfer_pc; 277 - } else { 278 - timeout = WAIT_FLOPPY_CMD; 279 - expiry = NULL; 280 - } 281 - 282 - return ide_transfer_pc(drive, pc, idefloppy_pc_intr, timeout, expiry); 283 196 } 284 197 285 198 static void ide_floppy_report_error(idefloppy_floppy_t *floppy, ··· 212 283 floppy->ascq == 0x00) 213 284 return; 214 285 215 - printk(KERN_ERR "ide-floppy: %s: I/O error, pc = %2x, key = %2x, " 286 + printk(KERN_ERR PFX "%s: I/O error, pc = %2x, key = %2x, " 216 287 "asc = %2x, ascq = %2x\n", 217 288 floppy->drive->name, pc->c[0], floppy->sense_key, 218 289 floppy->asc, floppy->ascq); ··· 227 298 if (floppy->failed_pc == NULL && 228 299 pc->c[0] != GPCMD_REQUEST_SENSE) 229 300 floppy->failed_pc = pc; 301 + 230 302 /* Set the current packet command */ 231 - floppy->pc = pc; 303 + drive->pc = pc; 232 304 233 305 if (pc->retries > IDEFLOPPY_MAX_PC_RETRIES) { 234 306 if (!(pc->flags & PC_FLAG_SUPPRESS_ERROR)) ··· 238 308 pc->error = IDEFLOPPY_ERROR_GENERAL; 239 309 240 310 floppy->failed_pc = NULL; 241 - drive->pc_callback(drive); 311 + drive->pc_callback(drive, 0); 242 312 return ide_stopped; 243 313 } 244 314 245 - debug_log("Retry number - %d\n", pc->retries); 315 + ide_debug_log(IDE_DBG_FUNC, "%s: Retry #%d\n", __func__, pc->retries); 246 316 247 317 pc->retries++; 248 318 249 - return ide_issue_pc(drive, pc, idefloppy_start_pc_transfer, 250 - WAIT_FLOPPY_CMD, NULL); 319 + return ide_issue_pc(drive, WAIT_FLOPPY_CMD, NULL); 251 320 } 252 321 253 322 void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *pc) ··· 276 347 length += 32; 277 348 break; 278 349 default: 279 - printk(KERN_ERR "ide-floppy: unsupported page code " 280 - "in create_mode_sense_cmd\n"); 350 + printk(KERN_ERR PFX "unsupported page code in %s\n", __func__); 281 351 } 282 352 put_unaligned(cpu_to_be16(length), (u16 *) &pc->c[7]); 283 353 pc->req_xfer = length; 284 354 } 285 355 286 - static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, 356 + static void idefloppy_create_rw_cmd(ide_drive_t *drive, 287 357 struct ide_atapi_pc *pc, struct request *rq, 288 358 unsigned long sector) 289 359 { 360 + idefloppy_floppy_t *floppy = drive->driver_data; 290 361 int block = sector / floppy->bs_factor; 291 362 int blocks = rq->nr_sectors / floppy->bs_factor; 292 363 int cmd = rq_data_dir(rq); 293 364 294 - debug_log("create_rw10_cmd: block == %d, blocks == %d\n", 295 - block, blocks); 365 + ide_debug_log(IDE_DBG_FUNC, "%s: block: %d, blocks: %d\n", __func__, 366 + block, blocks); 296 367 297 368 ide_init_pc(pc); 298 369 pc->c[0] = cmd == READ ? GPCMD_READ_10 : GPCMD_WRITE_10; ··· 337 408 struct ide_atapi_pc *pc; 338 409 unsigned long block = (unsigned long)block_s; 339 410 340 - debug_log("%s: dev: %s, cmd: 0x%x, cmd_type: %x, errors: %d\n", 341 - __func__, rq->rq_disk ? rq->rq_disk->disk_name : "?", 342 - rq->cmd[0], rq->cmd_type, rq->errors); 411 + ide_debug_log(IDE_DBG_FUNC, "%s: dev: %s, cmd: 0x%x, cmd_type: %x, " 412 + "errors: %d\n", 413 + __func__, rq->rq_disk ? rq->rq_disk->disk_name : "?", 414 + rq->cmd[0], rq->cmd_type, rq->errors); 343 415 344 - debug_log("%s: sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n", 345 - __func__, (long)rq->sector, rq->nr_sectors, 346 - rq->current_nr_sectors); 416 + ide_debug_log(IDE_DBG_FUNC, "%s: sector: %ld, nr_sectors: %ld, " 417 + "current_nr_sectors: %d\n", 418 + __func__, (long)rq->sector, rq->nr_sectors, 419 + rq->current_nr_sectors); 347 420 348 421 if (rq->errors >= ERROR_MAX) { 349 422 if (floppy->failed_pc) 350 423 ide_floppy_report_error(floppy, floppy->failed_pc); 351 424 else 352 - printk(KERN_ERR "ide-floppy: %s: I/O error\n", 353 - drive->name); 425 + printk(KERN_ERR PFX "%s: I/O error\n", drive->name); 426 + 354 427 idefloppy_end_request(drive, 0, 0); 355 428 return ide_stopped; 356 429 } 357 430 if (blk_fs_request(rq)) { 358 431 if (((long)rq->sector % floppy->bs_factor) || 359 432 (rq->nr_sectors % floppy->bs_factor)) { 360 - printk(KERN_ERR "%s: unsupported r/w request size\n", 361 - drive->name); 433 + printk(KERN_ERR PFX "%s: unsupported r/w rq size\n", 434 + drive->name); 362 435 idefloppy_end_request(drive, 0, 0); 363 436 return ide_stopped; 364 437 } 365 438 pc = &floppy->queued_pc; 366 - idefloppy_create_rw_cmd(floppy, pc, rq, block); 439 + idefloppy_create_rw_cmd(drive, pc, rq, block); 367 440 } else if (blk_special_request(rq)) { 368 441 pc = (struct ide_atapi_pc *) rq->buffer; 369 442 } else if (blk_pc_request(rq)) { 370 443 pc = &floppy->queued_pc; 371 444 idefloppy_blockpc_cmd(floppy, pc, rq); 372 445 } else { 373 - blk_dump_rq_flags(rq, 374 - "ide-floppy: unsupported command in queue"); 446 + blk_dump_rq_flags(rq, PFX "unsupported command in queue"); 375 447 idefloppy_end_request(drive, 0, 0); 376 448 return ide_stopped; 377 449 } ··· 405 475 ide_floppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); 406 476 407 477 if (ide_queue_pc_tail(drive, disk, &pc)) { 408 - printk(KERN_ERR "ide-floppy: Can't get flexible disk page" 409 - " parameters\n"); 478 + printk(KERN_ERR PFX "Can't get flexible disk page params\n"); 410 479 return 1; 411 480 } 412 481 ··· 428 499 capacity = cyls * heads * sectors * sector_size; 429 500 430 501 if (memcmp(page, &floppy->flexible_disk_page, 32)) 431 - printk(KERN_INFO "%s: %dkB, %d/%d/%d CHS, %d kBps, " 502 + printk(KERN_INFO PFX "%s: %dkB, %d/%d/%d CHS, %d kBps, " 432 503 "%d sector size, %d rpm\n", 433 504 drive->name, capacity / 1024, cyls, heads, 434 505 sectors, transfer_rate / 8, sector_size, rpm); ··· 440 511 lba_capacity = floppy->blocks * floppy->block_size; 441 512 442 513 if (capacity < lba_capacity) { 443 - printk(KERN_NOTICE "%s: The disk reports a capacity of %d " 514 + printk(KERN_NOTICE PFX "%s: The disk reports a capacity of %d " 444 515 "bytes, but the drive only handles %d\n", 445 516 drive->name, lba_capacity, capacity); 446 517 floppy->blocks = floppy->block_size ? ··· 470 541 471 542 ide_floppy_create_read_capacity_cmd(&pc); 472 543 if (ide_queue_pc_tail(drive, disk, &pc)) { 473 - printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); 544 + printk(KERN_ERR PFX "Can't get floppy parameters\n"); 474 545 return 1; 475 546 } 476 547 header_len = pc.buf[3]; ··· 483 554 blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]); 484 555 length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]); 485 556 486 - debug_log("Descriptor %d: %dkB, %d blocks, %d sector size\n", 487 - i, blocks * length / 1024, blocks, length); 557 + ide_debug_log(IDE_DBG_PROBE, "Descriptor %d: %dkB, %d blocks, " 558 + "%d sector size\n", 559 + i, blocks * length / 1024, blocks, length); 488 560 489 561 if (i) 490 562 continue; ··· 505 575 case CAPACITY_CURRENT: 506 576 /* Normal Zip/LS-120 disks */ 507 577 if (memcmp(cap_desc, &floppy->cap_desc, 8)) 508 - printk(KERN_INFO "%s: %dkB, %d blocks, %d " 509 - "sector size\n", drive->name, 510 - blocks * length / 1024, blocks, length); 578 + printk(KERN_INFO PFX "%s: %dkB, %d blocks, %d " 579 + "sector size\n", 580 + drive->name, blocks * length / 1024, 581 + blocks, length); 511 582 memcpy(&floppy->cap_desc, cap_desc, 8); 512 583 513 584 if (!length || length % 512) { 514 - printk(KERN_NOTICE "%s: %d bytes block size " 515 - "not supported\n", drive->name, length); 585 + printk(KERN_NOTICE PFX "%s: %d bytes block size" 586 + " not supported\n", drive->name, length); 516 587 } else { 517 588 floppy->blocks = blocks; 518 589 floppy->block_size = length; 519 590 floppy->bs_factor = length / 512; 520 591 if (floppy->bs_factor != 1) 521 - printk(KERN_NOTICE "%s: warning: non " 522 - "512 bytes block size not " 523 - "fully supported\n", 524 - drive->name); 592 + printk(KERN_NOTICE PFX "%s: Warning: " 593 + "non 512 bytes block size not " 594 + "fully supported\n", 595 + drive->name); 525 596 rc = 0; 526 597 } 527 598 break; ··· 531 600 * This is a KERN_ERR so it appears on screen 532 601 * for the user to see 533 602 */ 534 - printk(KERN_ERR "%s: No disk in drive\n", drive->name); 603 + printk(KERN_ERR PFX "%s: No disk in drive\n", 604 + drive->name); 535 605 break; 536 606 case CAPACITY_INVALID: 537 - printk(KERN_ERR "%s: Invalid capacity for disk " 607 + printk(KERN_ERR PFX "%s: Invalid capacity for disk " 538 608 "in drive\n", drive->name); 539 609 break; 540 610 } 541 - debug_log("Descriptor 0 Code: %d\n", 542 - pc.buf[desc_start + 4] & 0x03); 611 + ide_debug_log(IDE_DBG_PROBE, "Descriptor 0 Code: %d\n", 612 + pc.buf[desc_start + 4] & 0x03); 543 613 } 544 614 545 615 /* Clik! disk does not support get_flexible_disk_page */ ··· 552 620 return rc; 553 621 } 554 622 555 - static sector_t idefloppy_capacity(ide_drive_t *drive) 623 + sector_t ide_floppy_capacity(ide_drive_t *drive) 556 624 { 557 625 idefloppy_floppy_t *floppy = drive->driver_data; 558 626 unsigned long capacity = floppy->blocks * floppy->bs_factor; ··· 560 628 return capacity; 561 629 } 562 630 563 - #ifdef CONFIG_IDE_PROC_FS 564 - ide_devset_rw_field(bios_cyl, bios_cyl); 565 - ide_devset_rw_field(bios_head, bios_head); 566 - ide_devset_rw_field(bios_sect, bios_sect); 567 - 568 - static int get_ticks(ide_drive_t *drive) 569 - { 570 - idefloppy_floppy_t *floppy = drive->driver_data; 571 - return floppy->ticks; 572 - } 573 - 574 - static int set_ticks(ide_drive_t *drive, int arg) 575 - { 576 - idefloppy_floppy_t *floppy = drive->driver_data; 577 - floppy->ticks = arg; 578 - return 0; 579 - } 580 - 581 - IDE_DEVSET(ticks, DS_SYNC, get_ticks, set_ticks); 582 - 583 - static const struct ide_proc_devset idefloppy_settings[] = { 584 - IDE_PROC_DEVSET(bios_cyl, 0, 1023), 585 - IDE_PROC_DEVSET(bios_head, 0, 255), 586 - IDE_PROC_DEVSET(bios_sect, 0, 63), 587 - IDE_PROC_DEVSET(ticks, 0, 255), 588 - { 0 }, 589 - }; 590 - #endif 591 - 592 631 static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) 593 632 { 594 633 u16 *id = drive->id; 595 - u8 gcw[2]; 596 634 597 - *((u16 *)&gcw) = id[ATA_ID_CONFIG]; 635 + drive->pc_callback = ide_floppy_callback; 636 + drive->pc_update_buffers = idefloppy_update_buffers; 637 + drive->pc_io_buffers = ide_io_buffers; 598 638 599 - drive->pc_callback = ide_floppy_callback; 600 - 601 - if (((gcw[0] & 0x60) >> 5) == 1) 602 - drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; 603 639 /* 604 640 * We used to check revisions here. At this point however I'm giving up. 605 641 * Just assume they are all broken, its easier. ··· 580 680 if (!strncmp((char *)&id[ATA_ID_PROD], "IOMEGA ZIP 100 ATAPI", 20)) { 581 681 drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE; 582 682 /* This value will be visible in the /proc/ide/hdx/settings */ 583 - floppy->ticks = IDEFLOPPY_TICKS_DELAY; 683 + drive->pc_delay = IDEFLOPPY_PC_DELAY; 584 684 blk_queue_max_sectors(drive->queue, 64); 585 685 } 586 686 ··· 614 714 615 715 static void idefloppy_cleanup_obj(struct kref *kref) 616 716 { 617 - struct ide_floppy_obj *floppy = to_ide_floppy(kref); 717 + struct ide_floppy_obj *floppy = to_ide_drv(kref, ide_floppy_obj); 618 718 ide_drive_t *drive = floppy->drive; 619 719 struct gendisk *g = floppy->disk; 620 720 ··· 623 723 put_disk(g); 624 724 kfree(floppy); 625 725 } 626 - 627 - #ifdef CONFIG_IDE_PROC_FS 628 - static int proc_idefloppy_read_capacity(char *page, char **start, off_t off, 629 - int count, int *eof, void *data) 630 - { 631 - ide_drive_t*drive = (ide_drive_t *)data; 632 - int len; 633 - 634 - len = sprintf(page, "%llu\n", (long long)idefloppy_capacity(drive)); 635 - PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 636 - } 637 - 638 - static ide_proc_entry_t idefloppy_proc[] = { 639 - { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, 640 - { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, 641 - { NULL, 0, NULL, NULL } 642 - }; 643 - #endif /* CONFIG_IDE_PROC_FS */ 644 726 645 727 static int ide_floppy_probe(ide_drive_t *); 646 728 ··· 635 753 .probe = ide_floppy_probe, 636 754 .remove = ide_floppy_remove, 637 755 .version = IDEFLOPPY_VERSION, 638 - .media = ide_floppy, 639 756 .do_request = idefloppy_do_request, 640 757 .end_request = idefloppy_end_request, 641 758 .error = __ide_error, 642 759 #ifdef CONFIG_IDE_PROC_FS 643 - .proc = idefloppy_proc, 644 - .settings = idefloppy_settings, 760 + .proc = ide_floppy_proc, 761 + .settings = ide_floppy_settings, 645 762 #endif 646 763 }; 647 764 ··· 651 770 ide_drive_t *drive; 652 771 int ret = 0; 653 772 654 - debug_log("Reached %s\n", __func__); 655 - 656 773 floppy = ide_floppy_get(disk); 657 774 if (!floppy) 658 775 return -ENXIO; 659 776 660 777 drive = floppy->drive; 778 + 779 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 661 780 662 781 floppy->openers++; 663 782 ··· 703 822 static int idefloppy_release(struct inode *inode, struct file *filp) 704 823 { 705 824 struct gendisk *disk = inode->i_bdev->bd_disk; 706 - struct ide_floppy_obj *floppy = ide_floppy_g(disk); 825 + struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); 707 826 ide_drive_t *drive = floppy->drive; 708 827 709 - debug_log("Reached %s\n", __func__); 828 + ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 710 829 711 830 if (floppy->openers == 1) { 712 831 ide_set_media_lock(drive, disk, 0); ··· 722 841 723 842 static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo) 724 843 { 725 - struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk); 844 + struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk, 845 + ide_floppy_obj); 726 846 ide_drive_t *drive = floppy->drive; 727 847 728 848 geo->heads = drive->bios_head; ··· 732 850 return 0; 733 851 } 734 852 735 - static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, 736 - unsigned long arg, unsigned int cmd) 737 - { 738 - idefloppy_floppy_t *floppy = drive->driver_data; 739 - struct gendisk *disk = floppy->disk; 740 - int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0; 741 - 742 - if (floppy->openers > 1) 743 - return -EBUSY; 744 - 745 - ide_set_media_lock(drive, disk, prevent); 746 - 747 - if (cmd == CDROMEJECT) 748 - ide_do_start_stop(drive, disk, 2); 749 - 750 - return 0; 751 - } 752 - 753 - static int idefloppy_ioctl(struct inode *inode, struct file *file, 754 - unsigned int cmd, unsigned long arg) 755 - { 756 - struct block_device *bdev = inode->i_bdev; 757 - struct ide_floppy_obj *floppy = ide_floppy_g(bdev->bd_disk); 758 - ide_drive_t *drive = floppy->drive; 759 - struct ide_atapi_pc pc; 760 - void __user *argp = (void __user *)arg; 761 - int err; 762 - 763 - if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) 764 - return ide_floppy_lockdoor(drive, &pc, arg, cmd); 765 - 766 - err = ide_floppy_format_ioctl(drive, file, cmd, argp); 767 - if (err != -ENOTTY) 768 - return err; 769 - 770 - /* 771 - * skip SCSI_IOCTL_SEND_COMMAND (deprecated) 772 - * and CDROM_SEND_PACKET (legacy) ioctls 773 - */ 774 - if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND) 775 - err = scsi_cmd_ioctl(file, bdev->bd_disk->queue, 776 - bdev->bd_disk, cmd, argp); 777 - 778 - if (err == -ENOTTY) 779 - err = generic_ide_ioctl(drive, file, bdev, cmd, arg); 780 - 781 - return err; 782 - } 783 - 784 853 static int idefloppy_media_changed(struct gendisk *disk) 785 854 { 786 - struct ide_floppy_obj *floppy = ide_floppy_g(disk); 855 + struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); 787 856 ide_drive_t *drive = floppy->drive; 788 857 int ret; 789 858 790 859 /* do not scan partitions twice if this is a removable device */ 791 - if (drive->attach) { 792 - drive->attach = 0; 860 + if (drive->dev_flags & IDE_DFLAG_ATTACH) { 861 + drive->dev_flags &= ~IDE_DFLAG_ATTACH; 793 862 return 0; 794 863 } 795 864 ret = !!(drive->atapi_flags & IDE_AFLAG_MEDIA_CHANGED); ··· 750 917 751 918 static int idefloppy_revalidate_disk(struct gendisk *disk) 752 919 { 753 - struct ide_floppy_obj *floppy = ide_floppy_g(disk); 754 - set_capacity(disk, idefloppy_capacity(floppy->drive)); 920 + struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); 921 + set_capacity(disk, ide_floppy_capacity(floppy->drive)); 755 922 return 0; 756 923 } 757 924 ··· 759 926 .owner = THIS_MODULE, 760 927 .open = idefloppy_open, 761 928 .release = idefloppy_release, 762 - .ioctl = idefloppy_ioctl, 929 + .ioctl = ide_floppy_ioctl, 763 930 .getgeo = idefloppy_getgeo, 764 931 .media_changed = idefloppy_media_changed, 765 932 .revalidate_disk = idefloppy_revalidate_disk ··· 777 944 goto failed; 778 945 779 946 if (!ide_check_atapi_device(drive, DRV_NAME)) { 780 - printk(KERN_ERR "ide-floppy: %s: not supported by this version" 781 - " of ide-floppy\n", drive->name); 947 + printk(KERN_ERR PFX "%s: not supported by this version of " 948 + DRV_NAME "\n", drive->name); 782 949 goto failed; 783 950 } 784 951 floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL); 785 952 if (!floppy) { 786 - printk(KERN_ERR "ide-floppy: %s: Can't allocate a floppy" 787 - " structure\n", drive->name); 953 + printk(KERN_ERR PFX "%s: Can't allocate a floppy structure\n", 954 + drive->name); 788 955 goto failed; 789 956 } 790 957 ··· 804 971 805 972 drive->driver_data = floppy; 806 973 974 + drive->debug_mask = debug_mask; 975 + 807 976 idefloppy_setup(drive, floppy); 977 + drive->dev_flags |= IDE_DFLAG_ATTACH; 808 978 809 979 g->minors = 1 << PARTN_BITS; 810 980 g->driverfs_dev = &drive->gendev; 811 - g->flags = drive->removable ? GENHD_FL_REMOVABLE : 0; 981 + if (drive->dev_flags & IDE_DFLAG_REMOVABLE) 982 + g->flags = GENHD_FL_REMOVABLE; 812 983 g->fops = &idefloppy_ops; 813 - drive->attach = 1; 814 984 add_disk(g); 815 985 return 0; 816 986 ··· 830 994 831 995 static int __init idefloppy_init(void) 832 996 { 833 - printk("ide-floppy driver " IDEFLOPPY_VERSION "\n"); 997 + printk(KERN_INFO DRV_NAME " driver " IDEFLOPPY_VERSION "\n"); 834 998 return driver_register(&idefloppy_driver.gen_driver); 835 999 } 836 1000
+9 -10
drivers/ide/ide-floppy.h
··· 13 13 struct kref kref; 14 14 unsigned int openers; /* protected by BKL for now */ 15 15 16 - /* Current packet command */ 17 - struct ide_atapi_pc *pc; 18 16 /* Last failed packet command */ 19 17 struct ide_atapi_pc *failed_pc; 20 18 /* used for blk_{fs,pc}_request() requests */ 21 19 struct ide_atapi_pc queued_pc; 22 20 23 - struct ide_atapi_pc request_sense_pc; 24 - struct request request_sense_rq; 25 - 26 21 /* Last error information */ 27 22 u8 sense_key, asc, ascq; 28 - /* delay this long before sending packet command */ 29 - u8 ticks; 23 + 30 24 int progress_indication; 31 25 32 26 /* Device information */ ··· 48 54 /* ide-floppy.c */ 49 55 void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8); 50 56 void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *); 51 - void ide_floppy_create_request_sense_cmd(struct ide_atapi_pc *); 57 + sector_t ide_floppy_capacity(ide_drive_t *); 52 58 53 59 /* ide-floppy_ioctl.c */ 54 - int ide_floppy_format_ioctl(ide_drive_t *, struct file *, unsigned int, 55 - void __user *); 60 + int ide_floppy_ioctl(struct inode *, struct file *, unsigned, unsigned long); 61 + 62 + #ifdef CONFIG_IDE_PROC_FS 63 + /* ide-floppy_proc.c */ 64 + extern ide_proc_entry_t ide_floppy_proc[]; 65 + extern const struct ide_proc_devset ide_floppy_settings[]; 66 + #endif 56 67 57 68 #endif /*__IDE_FLOPPY_H */
+53 -3
drivers/ide/ide-floppy_ioctl.c
··· 195 195 int progress_indication = 0x10000; 196 196 197 197 if (drive->atapi_flags & IDE_AFLAG_SRFP) { 198 - ide_floppy_create_request_sense_cmd(&pc); 198 + ide_create_request_sense_cmd(drive, &pc); 199 199 if (ide_queue_pc_tail(drive, floppy->disk, &pc)) 200 200 return -EIO; 201 201 ··· 223 223 return 0; 224 224 } 225 225 226 - int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file, 227 - unsigned int cmd, void __user *argp) 226 + static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, 227 + unsigned long arg, unsigned int cmd) 228 + { 229 + idefloppy_floppy_t *floppy = drive->driver_data; 230 + struct gendisk *disk = floppy->disk; 231 + int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0; 232 + 233 + if (floppy->openers > 1) 234 + return -EBUSY; 235 + 236 + ide_set_media_lock(drive, disk, prevent); 237 + 238 + if (cmd == CDROMEJECT) 239 + ide_do_start_stop(drive, disk, 2); 240 + 241 + return 0; 242 + } 243 + 244 + static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file, 245 + unsigned int cmd, void __user *argp) 228 246 { 229 247 switch (cmd) { 230 248 case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: ··· 258 240 default: 259 241 return -ENOTTY; 260 242 } 243 + } 244 + 245 + int ide_floppy_ioctl(struct inode *inode, struct file *file, 246 + unsigned int cmd, unsigned long arg) 247 + { 248 + struct block_device *bdev = inode->i_bdev; 249 + struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk, 250 + ide_floppy_obj); 251 + ide_drive_t *drive = floppy->drive; 252 + struct ide_atapi_pc pc; 253 + void __user *argp = (void __user *)arg; 254 + int err; 255 + 256 + if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) 257 + return ide_floppy_lockdoor(drive, &pc, arg, cmd); 258 + 259 + err = ide_floppy_format_ioctl(drive, file, cmd, argp); 260 + if (err != -ENOTTY) 261 + return err; 262 + 263 + /* 264 + * skip SCSI_IOCTL_SEND_COMMAND (deprecated) 265 + * and CDROM_SEND_PACKET (legacy) ioctls 266 + */ 267 + if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND) 268 + err = scsi_cmd_ioctl(file, bdev->bd_disk->queue, 269 + bdev->bd_disk, cmd, argp); 270 + 271 + if (err == -ENOTTY) 272 + err = generic_ide_ioctl(drive, file, bdev, cmd, arg); 273 + 274 + return err; 261 275 }
+33
drivers/ide/ide-floppy_proc.c
··· 1 + #include <linux/kernel.h> 2 + #include <linux/ide.h> 3 + 4 + #include "ide-floppy.h" 5 + 6 + static int proc_idefloppy_read_capacity(char *page, char **start, off_t off, 7 + int count, int *eof, void *data) 8 + { 9 + ide_drive_t*drive = (ide_drive_t *)data; 10 + int len; 11 + 12 + len = sprintf(page, "%llu\n", (long long)ide_floppy_capacity(drive)); 13 + PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 14 + } 15 + 16 + ide_proc_entry_t ide_floppy_proc[] = { 17 + { "capacity", S_IFREG|S_IRUGO, proc_idefloppy_read_capacity, NULL }, 18 + { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, 19 + { NULL, 0, NULL, NULL } 20 + }; 21 + 22 + ide_devset_rw_field(bios_cyl, bios_cyl); 23 + ide_devset_rw_field(bios_head, bios_head); 24 + ide_devset_rw_field(bios_sect, bios_sect); 25 + ide_devset_rw_field(ticks, pc_delay); 26 + 27 + const struct ide_proc_devset ide_floppy_settings[] = { 28 + IDE_PROC_DEVSET(bios_cyl, 0, 1023), 29 + IDE_PROC_DEVSET(bios_head, 0, 255), 30 + IDE_PROC_DEVSET(bios_sect, 0, 63), 31 + IDE_PROC_DEVSET(ticks, 0, 255), 32 + { 0 }, 33 + };
+12 -39
drivers/ide/ide-generic.c
··· 137 137 138 138 static int __init ide_generic_init(void) 139 139 { 140 - hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS]; 141 - struct ide_host *host; 140 + hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 142 141 unsigned long io_addr; 143 - int i, rc, primary = 0, secondary = 0; 142 + int i, rc = 0, primary = 0, secondary = 0; 144 143 145 - #ifdef CONFIG_MIPS 146 - if (!ide_probe_legacy()) 147 - return -ENODEV; 148 - #endif 149 144 ide_generic_check_pci_legacy_iobases(&primary, &secondary); 150 145 151 146 if (!probe_mask) { ··· 156 161 printk(KERN_INFO DRV_NAME ": enforcing probing of I/O ports " 157 162 "upon user request\n"); 158 163 159 - memset(hws, 0, sizeof(hw_regs_t *) * MAX_HWIFS); 160 - 161 164 for (i = 0; i < ARRAY_SIZE(legacy_bases); i++) { 162 165 io_addr = legacy_bases[i]; 163 - 164 - hws[i] = NULL; 165 166 166 167 if ((probe_mask & (1 << i)) && io_addr) { 167 168 if (!request_region(io_addr, 8, DRV_NAME)) { ··· 175 184 continue; 176 185 } 177 186 178 - memset(&hw[i], 0, sizeof(hw[i])); 179 - ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206); 187 + memset(&hw, 0, sizeof(hw)); 188 + ide_std_init_ports(&hw, io_addr, io_addr + 0x206); 180 189 #ifdef CONFIG_IA64 181 - hw[i].irq = isa_irq_to_vector(legacy_irqs[i]); 190 + hw.irq = isa_irq_to_vector(legacy_irqs[i]); 182 191 #else 183 - hw[i].irq = legacy_irqs[i]; 192 + hw.irq = legacy_irqs[i]; 184 193 #endif 185 - hw[i].chipset = ide_generic; 194 + hw.chipset = ide_generic; 186 195 187 - hws[i] = &hw[i]; 196 + rc = ide_host_add(NULL, hws, NULL); 197 + if (rc) { 198 + release_region(io_addr + 0x206, 1); 199 + release_region(io_addr, 8); 200 + } 188 201 } 189 202 } 190 - 191 - host = ide_host_alloc_all(NULL, hws); 192 - if (host == NULL) { 193 - rc = -ENOMEM; 194 - goto err; 195 - } 196 - 197 - rc = ide_host_register(host, NULL, hws); 198 - if (rc) 199 - goto err_free; 200 203 201 204 if (ide_generic_sysfs_init()) 202 205 printk(KERN_ERR DRV_NAME ": failed to create ide_generic " 203 206 "class\n"); 204 207 205 - return 0; 206 - err_free: 207 - ide_host_free(host); 208 - err: 209 - for (i = 0; i < MAX_HWIFS; i++) { 210 - if (hws[i] == NULL) 211 - continue; 212 - 213 - io_addr = hws[i]->io_ports.data_addr; 214 - release_region(io_addr + 0x206, 1); 215 - release_region(io_addr, 8); 216 - } 217 208 return rc; 218 209 } 219 210
+95 -142
drivers/ide/ide-io.c
··· 78 78 * decide whether to reenable DMA -- 3 is a random magic for now, 79 79 * if we DMA timeout more than 3 times, just stay in PIO 80 80 */ 81 - if (drive->state == DMA_PIO_RETRY && drive->retry_pio <= 3) { 82 - drive->state = 0; 81 + if ((drive->dev_flags & IDE_DFLAG_DMA_PIO_RETRY) && 82 + drive->retry_pio <= 3) { 83 + drive->dev_flags &= ~IDE_DFLAG_DMA_PIO_RETRY; 83 84 ide_dma_on(drive); 84 85 } 85 86 ··· 132 131 } 133 132 EXPORT_SYMBOL(ide_end_request); 134 133 135 - /* 136 - * Power Management state machine. This one is rather trivial for now, 137 - * we should probably add more, like switching back to PIO on suspend 138 - * to help some BIOSes, re-do the door locking on resume, etc... 139 - */ 140 - 141 - enum { 142 - ide_pm_flush_cache = ide_pm_state_start_suspend, 143 - idedisk_pm_standby, 144 - 145 - idedisk_pm_restore_pio = ide_pm_state_start_resume, 146 - idedisk_pm_idle, 147 - ide_pm_restore_dma, 148 - }; 149 - 150 134 static void ide_complete_power_step(ide_drive_t *drive, struct request *rq, u8 stat, u8 error) 151 135 { 152 136 struct request_pm_state *pm = rq->data; ··· 140 154 return; 141 155 142 156 switch (pm->pm_step) { 143 - case ide_pm_flush_cache: /* Suspend step 1 (flush cache) complete */ 157 + case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */ 144 158 if (pm->pm_state == PM_EVENT_FREEZE) 145 - pm->pm_step = ide_pm_state_completed; 159 + pm->pm_step = IDE_PM_COMPLETED; 146 160 else 147 - pm->pm_step = idedisk_pm_standby; 161 + pm->pm_step = IDE_PM_STANDBY; 148 162 break; 149 - case idedisk_pm_standby: /* Suspend step 2 (standby) complete */ 150 - pm->pm_step = ide_pm_state_completed; 163 + case IDE_PM_STANDBY: /* Suspend step 2 (standby) */ 164 + pm->pm_step = IDE_PM_COMPLETED; 151 165 break; 152 - case idedisk_pm_restore_pio: /* Resume step 1 complete */ 153 - pm->pm_step = idedisk_pm_idle; 166 + case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */ 167 + pm->pm_step = IDE_PM_IDLE; 154 168 break; 155 - case idedisk_pm_idle: /* Resume step 2 (idle) complete */ 156 - pm->pm_step = ide_pm_restore_dma; 169 + case IDE_PM_IDLE: /* Resume step 2 (idle)*/ 170 + pm->pm_step = IDE_PM_RESTORE_DMA; 157 171 break; 158 172 } 159 173 } ··· 166 180 memset(args, 0, sizeof(*args)); 167 181 168 182 switch (pm->pm_step) { 169 - case ide_pm_flush_cache: /* Suspend step 1 (flush cache) */ 183 + case IDE_PM_FLUSH_CACHE: /* Suspend step 1 (flush cache) */ 170 184 if (drive->media != ide_disk) 171 185 break; 172 186 /* Not supported? Switch to next step now. */ 173 - if (!drive->wcache || ata_id_flush_enabled(drive->id) == 0) { 187 + if (ata_id_flush_enabled(drive->id) == 0 || 188 + (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) { 174 189 ide_complete_power_step(drive, rq, 0, 0); 175 190 return ide_stopped; 176 191 } ··· 180 193 else 181 194 args->tf.command = ATA_CMD_FLUSH; 182 195 goto out_do_tf; 183 - 184 - case idedisk_pm_standby: /* Suspend step 2 (standby) */ 196 + case IDE_PM_STANDBY: /* Suspend step 2 (standby) */ 185 197 args->tf.command = ATA_CMD_STANDBYNOW1; 186 198 goto out_do_tf; 187 - 188 - case idedisk_pm_restore_pio: /* Resume step 1 (restore PIO) */ 199 + case IDE_PM_RESTORE_PIO: /* Resume step 1 (restore PIO) */ 189 200 ide_set_max_pio(drive); 190 201 /* 191 - * skip idedisk_pm_idle for ATAPI devices 202 + * skip IDE_PM_IDLE for ATAPI devices 192 203 */ 193 204 if (drive->media != ide_disk) 194 - pm->pm_step = ide_pm_restore_dma; 205 + pm->pm_step = IDE_PM_RESTORE_DMA; 195 206 else 196 207 ide_complete_power_step(drive, rq, 0, 0); 197 208 return ide_stopped; 198 - 199 - case idedisk_pm_idle: /* Resume step 2 (idle) */ 209 + case IDE_PM_IDLE: /* Resume step 2 (idle) */ 200 210 args->tf.command = ATA_CMD_IDLEIMMEDIATE; 201 211 goto out_do_tf; 202 - 203 - case ide_pm_restore_dma: /* Resume step 3 (restore DMA) */ 212 + case IDE_PM_RESTORE_DMA: /* Resume step 3 (restore DMA) */ 204 213 /* 205 214 * Right now, all we do is call ide_set_dma(drive), 206 215 * we could be smarter and check for current xfer_speed ··· 205 222 if (drive->hwif->dma_ops == NULL) 206 223 break; 207 224 /* 208 - * TODO: respect ->using_dma setting 225 + * TODO: respect IDE_DFLAG_USING_DMA 209 226 */ 210 227 ide_set_dma(drive); 211 228 break; 212 229 } 213 - pm->pm_step = ide_pm_state_completed; 230 + 231 + pm->pm_step = IDE_PM_COMPLETED; 214 232 return ide_stopped; 215 233 216 234 out_do_tf: ··· 271 287 if (blk_pm_suspend_request(rq)) { 272 288 blk_stop_queue(drive->queue); 273 289 } else { 274 - drive->blocked = 0; 290 + drive->dev_flags &= ~IDE_DFLAG_BLOCKED; 275 291 blk_start_queue(drive->queue); 276 292 } 277 293 HWGROUP(drive)->rq = NULL; ··· 327 343 drive->name, rq->pm->pm_step, stat, err); 328 344 #endif 329 345 ide_complete_power_step(drive, rq, stat, err); 330 - if (pm->pm_step == ide_pm_state_completed) 346 + if (pm->pm_step == IDE_PM_COMPLETED) 331 347 ide_complete_pm_request(drive, rq); 332 348 return; 333 349 } ··· 358 374 { 359 375 ide_hwif_t *hwif = drive->hwif; 360 376 361 - if ((stat & ATA_BUSY) || ((stat & ATA_DF) && !drive->nowerr)) { 377 + if ((stat & ATA_BUSY) || 378 + ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) { 362 379 /* other bits are useless when BUSY */ 363 380 rq->errors |= ERROR_RESET; 364 381 } else if (stat & ATA_ERR) { 365 382 /* err has different meaning on cdrom and tape */ 366 383 if (err == ATA_ABORTED) { 367 - if (drive->select.b.lba && 384 + if ((drive->dev_flags & IDE_DFLAG_LBA) && 368 385 /* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */ 369 386 hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS) 370 387 return ide_stopped; ··· 413 428 { 414 429 ide_hwif_t *hwif = drive->hwif; 415 430 416 - if ((stat & ATA_BUSY) || ((stat & ATA_DF) && !drive->nowerr)) { 431 + if ((stat & ATA_BUSY) || 432 + ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) { 417 433 /* other bits are useless when BUSY */ 418 434 rq->errors |= ERROR_RESET; 419 435 } else { ··· 495 509 tf->lbal = drive->sect; 496 510 tf->lbam = drive->cyl; 497 511 tf->lbah = drive->cyl >> 8; 498 - tf->device = ((drive->head - 1) | drive->select.all) & ~ATA_LBA; 512 + tf->device = (drive->head - 1) | drive->select; 499 513 tf->command = ATA_CMD_INIT_DEV_PARAMS; 500 514 } 501 515 ··· 543 557 return ide_started; 544 558 } 545 559 546 - /* 547 - * handle HDIO_SET_PIO_MODE ioctl abusers here, eventually it will go away 548 - */ 549 - static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio) 550 - { 551 - switch (req_pio) { 552 - case 202: 553 - case 201: 554 - case 200: 555 - case 102: 556 - case 101: 557 - case 100: 558 - return (hwif->host_flags & IDE_HFLAG_ABUSE_DMA_MODES) ? 1 : 0; 559 - case 9: 560 - case 8: 561 - return (hwif->host_flags & IDE_HFLAG_ABUSE_PREFETCH) ? 1 : 0; 562 - case 7: 563 - case 6: 564 - return (hwif->host_flags & IDE_HFLAG_ABUSE_FAST_DEVSEL) ? 1 : 0; 565 - default: 566 - return 0; 567 - } 568 - } 569 - 570 560 /** 571 561 * do_special - issue some special commands 572 562 * @drive: drive the command is for ··· 560 598 #ifdef DEBUG 561 599 printk("%s: do_special: 0x%02x\n", drive->name, s->all); 562 600 #endif 563 - if (s->b.set_tune) { 564 - ide_hwif_t *hwif = drive->hwif; 565 - const struct ide_port_ops *port_ops = hwif->port_ops; 566 - u8 req_pio = drive->tune_req; 601 + if (drive->media == ide_disk) 602 + return ide_disk_special(drive); 567 603 568 - s->b.set_tune = 0; 569 - 570 - if (set_pio_mode_abuse(drive->hwif, req_pio)) { 571 - /* 572 - * take ide_lock for drive->[no_]unmask/[no_]io_32bit 573 - */ 574 - if (req_pio == 8 || req_pio == 9) { 575 - unsigned long flags; 576 - 577 - spin_lock_irqsave(&ide_lock, flags); 578 - port_ops->set_pio_mode(drive, req_pio); 579 - spin_unlock_irqrestore(&ide_lock, flags); 580 - } else 581 - port_ops->set_pio_mode(drive, req_pio); 582 - } else { 583 - int keep_dma = drive->using_dma; 584 - 585 - ide_set_pio(drive, req_pio); 586 - 587 - if (hwif->host_flags & IDE_HFLAG_SET_PIO_MODE_KEEP_DMA) { 588 - if (keep_dma) 589 - ide_dma_on(drive); 590 - } 591 - } 592 - 593 - return ide_stopped; 594 - } else { 595 - if (drive->media == ide_disk) 596 - return ide_disk_special(drive); 597 - 598 - s->all = 0; 599 - drive->mult_req = 0; 600 - return ide_stopped; 601 - } 604 + s->all = 0; 605 + drive->mult_req = 0; 606 + return ide_stopped; 602 607 } 603 608 604 609 void ide_map_sg(ide_drive_t *drive, struct request *rq) ··· 655 726 if (!(setting->flags & DS_SYNC)) 656 727 return setting->set(drive, arg); 657 728 658 - rq = blk_get_request(q, READ, GFP_KERNEL); 659 - if (!rq) 660 - return -ENOMEM; 661 - 729 + rq = blk_get_request(q, READ, __GFP_WAIT); 662 730 rq->cmd_type = REQ_TYPE_SPECIAL; 663 731 rq->cmd_len = 5; 664 732 rq->cmd[0] = REQ_DEVSET_EXEC; ··· 672 746 673 747 static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq) 674 748 { 675 - switch (rq->cmd[0]) { 749 + u8 cmd = rq->cmd[0]; 750 + 751 + if (cmd == REQ_PARK_HEADS || cmd == REQ_UNPARK_HEADS) { 752 + ide_task_t task; 753 + struct ide_taskfile *tf = &task.tf; 754 + 755 + memset(&task, 0, sizeof(task)); 756 + if (cmd == REQ_PARK_HEADS) { 757 + drive->sleep = *(unsigned long *)rq->special; 758 + drive->dev_flags |= IDE_DFLAG_SLEEPING; 759 + tf->command = ATA_CMD_IDLEIMMEDIATE; 760 + tf->feature = 0x44; 761 + tf->lbal = 0x4c; 762 + tf->lbam = 0x4e; 763 + tf->lbah = 0x55; 764 + task.tf_flags |= IDE_TFLAG_CUSTOM_HANDLER; 765 + } else /* cmd == REQ_UNPARK_HEADS */ 766 + tf->command = ATA_CMD_CHK_POWER; 767 + 768 + task.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 769 + task.rq = rq; 770 + drive->hwif->data_phase = task.data_phase = TASKFILE_NO_DATA; 771 + return do_rw_taskfile(drive, &task); 772 + } 773 + 774 + switch (cmd) { 676 775 case REQ_DEVSET_EXEC: 677 776 { 678 777 int err, (*setfunc)(ide_drive_t *, int) = rq->special; ··· 724 773 struct request_pm_state *pm = rq->data; 725 774 726 775 if (blk_pm_suspend_request(rq) && 727 - pm->pm_step == ide_pm_state_start_suspend) 776 + pm->pm_step == IDE_PM_START_SUSPEND) 728 777 /* Mark drive blocked when starting the suspend sequence. */ 729 - drive->blocked = 1; 778 + drive->dev_flags |= IDE_DFLAG_BLOCKED; 730 779 else if (blk_pm_resume_request(rq) && 731 - pm->pm_step == ide_pm_state_start_resume) { 780 + pm->pm_step == IDE_PM_START_RESUME) { 732 781 /* 733 782 * The first thing we do on wakeup is to wait for BSY bit to 734 783 * go away (with a looong timeout) as a drive on this hwif may ··· 808 857 #endif 809 858 startstop = ide_start_power_step(drive, rq); 810 859 if (startstop == ide_stopped && 811 - pm->pm_step == ide_pm_state_completed) 860 + pm->pm_step == IDE_PM_COMPLETED) 812 861 ide_complete_pm_request(drive, rq); 813 862 return startstop; 814 863 } else if (!rq->rq_disk && blk_special_request(rq)) ··· 846 895 if (timeout > WAIT_WORSTCASE) 847 896 timeout = WAIT_WORSTCASE; 848 897 drive->sleep = timeout + jiffies; 849 - drive->sleeping = 1; 898 + drive->dev_flags |= IDE_DFLAG_SLEEPING; 850 899 } 851 900 852 901 EXPORT_SYMBOL(ide_stall_queue); ··· 886 935 } 887 936 888 937 do { 889 - if ((!drive->sleeping || time_after_eq(jiffies, drive->sleep)) 890 - && !elv_queue_empty(drive->queue)) { 891 - if (!best 892 - || (drive->sleeping && (!best->sleeping || time_before(drive->sleep, best->sleep))) 893 - || (!best->sleeping && time_before(WAKEUP(drive), WAKEUP(best)))) 894 - { 938 + u8 dev_s = !!(drive->dev_flags & IDE_DFLAG_SLEEPING); 939 + u8 best_s = (best && !!(best->dev_flags & IDE_DFLAG_SLEEPING)); 940 + 941 + if ((dev_s == 0 || time_after_eq(jiffies, drive->sleep)) && 942 + !elv_queue_empty(drive->queue)) { 943 + if (best == NULL || 944 + (dev_s && (best_s == 0 || time_before(drive->sleep, best->sleep))) || 945 + (best_s == 0 && time_before(WAKEUP(drive), WAKEUP(best)))) { 895 946 if (!blk_queue_plugged(drive->queue)) 896 947 best = drive; 897 948 } 898 949 } 899 950 } while ((drive = drive->next) != hwgroup->drive); 900 - if (best && best->nice1 && !best->sleeping && best != hwgroup->drive && best->service_time > WAIT_MIN_SLEEP) { 951 + 952 + if (best && (best->dev_flags & IDE_DFLAG_NICE1) && 953 + (best->dev_flags & IDE_DFLAG_SLEEPING) == 0 && 954 + best != hwgroup->drive && best->service_time > WAIT_MIN_SLEEP) { 901 955 long t = (signed long)(WAKEUP(best) - jiffies); 902 956 if (t >= WAIT_MIN_SLEEP) { 903 957 /* ··· 911 955 */ 912 956 drive = best->next; 913 957 do { 914 - if (!drive->sleeping 958 + if ((drive->dev_flags & IDE_DFLAG_SLEEPING) == 0 915 959 && time_before(jiffies - best->service_time, WAKEUP(drive)) 916 960 && time_before(WAKEUP(drive), jiffies + t)) 917 961 { ··· 982 1026 hwgroup->rq = NULL; 983 1027 drive = hwgroup->drive; 984 1028 do { 985 - if (drive->sleeping && (!sleeping || time_before(drive->sleep, sleep))) { 1029 + if ((drive->dev_flags & IDE_DFLAG_SLEEPING) && 1030 + (sleeping == 0 || 1031 + time_before(drive->sleep, sleep))) { 986 1032 sleeping = 1; 987 1033 sleep = drive->sleep; 988 1034 } ··· 1033 1075 } 1034 1076 hwgroup->hwif = hwif; 1035 1077 hwgroup->drive = drive; 1036 - drive->sleeping = 0; 1078 + drive->dev_flags &= ~(IDE_DFLAG_SLEEPING | IDE_DFLAG_PARKED); 1037 1079 drive->service_start = jiffies; 1038 1080 1039 1081 if (blk_queue_plugged(drive->queue)) { ··· 1067 1109 * We count how many times we loop here to make sure we service 1068 1110 * all drives in the hwgroup without looping for ever 1069 1111 */ 1070 - if (drive->blocked && !blk_pm_request(rq) && !(rq->cmd_flags & REQ_PREEMPT)) { 1112 + if ((drive->dev_flags & IDE_DFLAG_BLOCKED) && 1113 + blk_pm_request(rq) == 0 && 1114 + (rq->cmd_flags & REQ_PREEMPT) == 0) { 1071 1115 drive = drive->next ? drive->next : hwgroup->drive; 1072 1116 if (loops++ < 4 && !blk_queue_plugged(drive->queue)) 1073 1117 goto again; ··· 1142 1182 * a timeout -- we'll reenable after we finish this next request 1143 1183 * (or rather the first chunk of it) in pio. 1144 1184 */ 1185 + drive->dev_flags |= IDE_DFLAG_DMA_PIO_RETRY; 1145 1186 drive->retry_pio++; 1146 - drive->state = DMA_PIO_RETRY; 1147 1187 ide_dma_off_quietly(drive); 1148 1188 1149 1189 /* ··· 1440 1480 del_timer(&hwgroup->timer); 1441 1481 spin_unlock(&ide_lock); 1442 1482 1443 - /* Some controllers might set DMA INTR no matter DMA or PIO; 1444 - * bmdma status might need to be cleared even for 1445 - * PIO interrupts to prevent spurious/lost irq. 1446 - */ 1447 - if (hwif->ide_dma_clear_irq && !(drive->waiting_for_dma)) 1448 - /* ide_dma_end() needs bmdma status for error checking. 1449 - * So, skip clearing bmdma status here and leave it 1450 - * to ide_dma_end() if this is dma interrupt. 1451 - */ 1452 - hwif->ide_dma_clear_irq(drive); 1483 + if (hwif->port_ops && hwif->port_ops->clear_irq) 1484 + hwif->port_ops->clear_irq(drive); 1453 1485 1454 - if (drive->unmask) 1486 + if (drive->dev_flags & IDE_DFLAG_UNMASK) 1455 1487 local_irq_enable_in_hardirq(); 1488 + 1456 1489 /* service this interrupt, may set handler for next interrupt */ 1457 1490 startstop = handler(drive); 1458 - spin_lock_irq(&ide_lock); 1459 1491 1492 + spin_lock_irq(&ide_lock); 1460 1493 /* 1461 1494 * Note that handler() may have set things up for another 1462 1495 * interrupt to occur soon, but it cannot happen until
+15 -6
drivers/ide/ide-ioctls.c
··· 62 62 int size = (cmd == HDIO_GET_IDENTITY) ? (ATA_ID_WORDS * 2) : 142; 63 63 int rc = 0; 64 64 65 - if (drive->id_read == 0) { 65 + if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { 66 66 rc = -ENOMSG; 67 67 goto out; 68 68 } ··· 86 86 87 87 static int ide_get_nice_ioctl(ide_drive_t *drive, unsigned long arg) 88 88 { 89 - return put_user((drive->dsc_overlap << IDE_NICE_DSC_OVERLAP) | 90 - (drive->nice1 << IDE_NICE_1), (long __user *)arg); 89 + return put_user((!!(drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) 90 + << IDE_NICE_DSC_OVERLAP) | 91 + (!!(drive->dev_flags & IDE_DFLAG_NICE1) 92 + << IDE_NICE_1), (long __user *)arg); 91 93 } 92 94 93 95 static int ide_set_nice_ioctl(ide_drive_t *drive, unsigned long arg) ··· 99 97 100 98 if (((arg >> IDE_NICE_DSC_OVERLAP) & 1) && 101 99 (drive->media == ide_disk || drive->media == ide_floppy || 102 - drive->scsi)) 100 + (drive->dev_flags & IDE_DFLAG_SCSI))) 103 101 return -EPERM; 104 102 105 - drive->dsc_overlap = (arg >> IDE_NICE_DSC_OVERLAP) & 1; 106 - drive->nice1 = (arg >> IDE_NICE_1) & 1; 103 + if ((arg >> IDE_NICE_DSC_OVERLAP) & 1) 104 + drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; 105 + else 106 + drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 107 + 108 + if ((arg >> IDE_NICE_1) & 1) 109 + drive->dev_flags |= IDE_DFLAG_NICE1; 110 + else 111 + drive->dev_flags &= ~IDE_DFLAG_NICE1; 107 112 108 113 return 0; 109 114 }
+64 -31
drivers/ide/ide-iops.c
··· 181 181 tf_outb(tf->lbah, io_ports->lbah_addr); 182 182 183 183 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) 184 - tf_outb((tf->device & HIHI) | drive->select.all, 184 + tf_outb((tf->device & HIHI) | drive->select, 185 185 io_ports->device_addr); 186 186 } 187 187 EXPORT_SYMBOL_GPL(ide_tf_load); ··· 647 647 return 1; 648 648 649 649 no_80w: 650 - if (drive->udma33_warned == 1) 650 + if (drive->dev_flags & IDE_DFLAG_UDMA33_WARNED) 651 651 return 0; 652 652 653 653 printk(KERN_WARNING "%s: %s side 80-wire cable detection failed, " ··· 655 655 drive->name, 656 656 hwif->cbl == ATA_CBL_PATA80 ? "drive" : "host"); 657 657 658 - drive->udma33_warned = 1; 658 + drive->dev_flags |= IDE_DFLAG_UDMA33_WARNED; 659 659 660 660 return 0; 661 661 } ··· 711 711 712 712 kfree(id); 713 713 714 - if (drive->using_dma && ide_id_dma_bug(drive)) 714 + if ((drive->dev_flags & IDE_DFLAG_USING_DMA) && ide_id_dma_bug(drive)) 715 715 ide_dma_off(drive); 716 716 717 717 return 1; ··· 790 790 791 791 skip: 792 792 #ifdef CONFIG_BLK_DEV_IDEDMA 793 - if (speed >= XFER_SW_DMA_0 && drive->using_dma) 793 + if (speed >= XFER_SW_DMA_0 && (drive->dev_flags & IDE_DFLAG_USING_DMA)) 794 794 hwif->dma_ops->dma_host_set(drive, 1); 795 795 else if (hwif->dma_ops) /* check if host supports DMA */ 796 796 ide_dma_off_quietly(drive); ··· 940 940 return ide_stopped; 941 941 } 942 942 943 + static void ide_reset_report_error(ide_hwif_t *hwif, u8 err) 944 + { 945 + static const char *err_master_vals[] = 946 + { NULL, "passed", "formatter device error", 947 + "sector buffer error", "ECC circuitry error", 948 + "controlling MPU error" }; 949 + 950 + u8 err_master = err & 0x7f; 951 + 952 + printk(KERN_ERR "%s: reset: master: ", hwif->name); 953 + if (err_master && err_master < 6) 954 + printk(KERN_CONT "%s", err_master_vals[err_master]); 955 + else 956 + printk(KERN_CONT "error (0x%02x?)", err); 957 + if (err & 0x80) 958 + printk(KERN_CONT "; slave: failed"); 959 + printk(KERN_CONT "\n"); 960 + } 961 + 943 962 /* 944 963 * reset_pollfunc() gets invoked to poll the interface for completion every 50ms 945 964 * during an ide reset operation. If the drives have not yet responded, ··· 994 975 drive->failures++; 995 976 err = -EIO; 996 977 } else { 997 - printk("%s: reset: ", hwif->name); 998 978 tmp = ide_read_error(drive); 999 979 1000 980 if (tmp == 1) { 1001 - printk("success\n"); 981 + printk(KERN_INFO "%s: reset: success\n", hwif->name); 1002 982 drive->failures = 0; 1003 983 } else { 984 + ide_reset_report_error(hwif, tmp); 1004 985 drive->failures++; 1005 - printk("master: "); 1006 - switch (tmp & 0x7f) { 1007 - case 1: printk("passed"); 1008 - break; 1009 - case 2: printk("formatter device error"); 1010 - break; 1011 - case 3: printk("sector buffer error"); 1012 - break; 1013 - case 4: printk("ECC circuitry error"); 1014 - break; 1015 - case 5: printk("controlling MPU error"); 1016 - break; 1017 - default:printk("error (0x%02x?)", tmp); 1018 - } 1019 - if (tmp & 0x80) 1020 - printk("; slave: failed"); 1021 - printk("\n"); 1022 986 err = -EIO; 1023 987 } 1024 988 } ··· 1018 1016 drive->special.all = 0; 1019 1017 drive->special.b.set_geometry = legacy; 1020 1018 drive->special.b.recalibrate = legacy; 1019 + 1021 1020 drive->mult_count = 0; 1022 - if (!drive->keep_settings && !drive->using_dma) 1021 + drive->dev_flags &= ~IDE_DFLAG_PARKED; 1022 + 1023 + if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0 && 1024 + (drive->dev_flags & IDE_DFLAG_USING_DMA) == 0) 1023 1025 drive->mult_req = 0; 1026 + 1024 1027 if (drive->mult_req != drive->mult_count) 1025 1028 drive->special.b.set_multmode = 1; 1026 1029 } ··· 1037 1030 if (drive->media == ide_disk) 1038 1031 ide_disk_pre_reset(drive); 1039 1032 else 1040 - drive->post_reset = 1; 1033 + drive->dev_flags |= IDE_DFLAG_POST_RESET; 1041 1034 1042 - if (drive->using_dma) { 1035 + if (drive->dev_flags & IDE_DFLAG_USING_DMA) { 1043 1036 if (drive->crc_count) 1044 1037 ide_check_dma_crc(drive); 1045 1038 else 1046 1039 ide_dma_off(drive); 1047 1040 } 1048 1041 1049 - if (!drive->keep_settings) { 1050 - if (!drive->using_dma) { 1051 - drive->unmask = 0; 1042 + if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0) { 1043 + if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0) { 1044 + drive->dev_flags &= ~IDE_DFLAG_UNMASK; 1052 1045 drive->io_32bit = 0; 1053 1046 } 1054 1047 return; ··· 1080 1073 static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) 1081 1074 { 1082 1075 unsigned int unit; 1083 - unsigned long flags; 1076 + unsigned long flags, timeout; 1084 1077 ide_hwif_t *hwif; 1085 1078 ide_hwgroup_t *hwgroup; 1086 1079 struct ide_io_ports *io_ports; 1087 1080 const struct ide_tp_ops *tp_ops; 1088 1081 const struct ide_port_ops *port_ops; 1082 + DEFINE_WAIT(wait); 1089 1083 1090 1084 spin_lock_irqsave(&ide_lock, flags); 1091 1085 hwif = HWIF(drive); ··· 1112 1104 spin_unlock_irqrestore(&ide_lock, flags); 1113 1105 return ide_started; 1114 1106 } 1107 + 1108 + /* We must not disturb devices in the IDE_DFLAG_PARKED state. */ 1109 + do { 1110 + unsigned long now; 1111 + 1112 + prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE); 1113 + timeout = jiffies; 1114 + for (unit = 0; unit < MAX_DRIVES; unit++) { 1115 + ide_drive_t *tdrive = &hwif->drives[unit]; 1116 + 1117 + if (tdrive->dev_flags & IDE_DFLAG_PRESENT && 1118 + tdrive->dev_flags & IDE_DFLAG_PARKED && 1119 + time_after(tdrive->sleep, timeout)) 1120 + timeout = tdrive->sleep; 1121 + } 1122 + 1123 + now = jiffies; 1124 + if (time_before_eq(timeout, now)) 1125 + break; 1126 + 1127 + spin_unlock_irqrestore(&ide_lock, flags); 1128 + timeout = schedule_timeout_uninterruptible(timeout - now); 1129 + spin_lock_irqsave(&ide_lock, flags); 1130 + } while (timeout); 1131 + finish_wait(&ide_park_wq, &wait); 1115 1132 1116 1133 /* 1117 1134 * First, reset any device state data we were maintaining
+1 -1
drivers/ide/ide-lib.c
··· 317 317 { 318 318 ide_task_t task; 319 319 struct ide_taskfile *tf = &task.tf; 320 - int lba48 = (drive->addressing == 1) ? 1 : 0; 320 + u8 lba48 = !!(drive->dev_flags & IDE_DFLAG_LBA48); 321 321 322 322 memset(&task, 0, sizeof(task)); 323 323 if (lba48)
+121
drivers/ide/ide-park.c
··· 1 + #include <linux/kernel.h> 2 + #include <linux/ide.h> 3 + #include <linux/jiffies.h> 4 + #include <linux/blkdev.h> 5 + 6 + DECLARE_WAIT_QUEUE_HEAD(ide_park_wq); 7 + 8 + static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout) 9 + { 10 + struct request_queue *q = drive->queue; 11 + struct request *rq; 12 + int rc; 13 + 14 + timeout += jiffies; 15 + spin_lock_irq(&ide_lock); 16 + if (drive->dev_flags & IDE_DFLAG_PARKED) { 17 + ide_hwgroup_t *hwgroup = drive->hwif->hwgroup; 18 + int reset_timer; 19 + 20 + reset_timer = time_before(timeout, drive->sleep); 21 + drive->sleep = timeout; 22 + wake_up_all(&ide_park_wq); 23 + if (reset_timer && hwgroup->sleeping && 24 + del_timer(&hwgroup->timer)) { 25 + hwgroup->sleeping = 0; 26 + hwgroup->busy = 0; 27 + blk_start_queueing(q); 28 + } 29 + spin_unlock_irq(&ide_lock); 30 + return; 31 + } 32 + spin_unlock_irq(&ide_lock); 33 + 34 + rq = blk_get_request(q, READ, __GFP_WAIT); 35 + rq->cmd[0] = REQ_PARK_HEADS; 36 + rq->cmd_len = 1; 37 + rq->cmd_type = REQ_TYPE_SPECIAL; 38 + rq->special = &timeout; 39 + rc = blk_execute_rq(q, NULL, rq, 1); 40 + blk_put_request(rq); 41 + if (rc) 42 + goto out; 43 + 44 + /* 45 + * Make sure that *some* command is sent to the drive after the 46 + * timeout has expired, so power management will be reenabled. 47 + */ 48 + rq = blk_get_request(q, READ, GFP_NOWAIT); 49 + if (unlikely(!rq)) 50 + goto out; 51 + 52 + rq->cmd[0] = REQ_UNPARK_HEADS; 53 + rq->cmd_len = 1; 54 + rq->cmd_type = REQ_TYPE_SPECIAL; 55 + elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 1); 56 + 57 + out: 58 + return; 59 + } 60 + 61 + ssize_t ide_park_show(struct device *dev, struct device_attribute *attr, 62 + char *buf) 63 + { 64 + ide_drive_t *drive = to_ide_device(dev); 65 + unsigned long now; 66 + unsigned int msecs; 67 + 68 + if (drive->dev_flags & IDE_DFLAG_NO_UNLOAD) 69 + return -EOPNOTSUPP; 70 + 71 + spin_lock_irq(&ide_lock); 72 + now = jiffies; 73 + if (drive->dev_flags & IDE_DFLAG_PARKED && 74 + time_after(drive->sleep, now)) 75 + msecs = jiffies_to_msecs(drive->sleep - now); 76 + else 77 + msecs = 0; 78 + spin_unlock_irq(&ide_lock); 79 + 80 + return snprintf(buf, 20, "%u\n", msecs); 81 + } 82 + 83 + ssize_t ide_park_store(struct device *dev, struct device_attribute *attr, 84 + const char *buf, size_t len) 85 + { 86 + #define MAX_PARK_TIMEOUT 30000 87 + ide_drive_t *drive = to_ide_device(dev); 88 + long int input; 89 + int rc; 90 + 91 + rc = strict_strtol(buf, 10, &input); 92 + if (rc || input < -2) 93 + return -EINVAL; 94 + if (input > MAX_PARK_TIMEOUT) { 95 + input = MAX_PARK_TIMEOUT; 96 + rc = -EOVERFLOW; 97 + } 98 + 99 + mutex_lock(&ide_setting_mtx); 100 + if (input >= 0) { 101 + if (drive->dev_flags & IDE_DFLAG_NO_UNLOAD) 102 + rc = -EOPNOTSUPP; 103 + else if (input || drive->dev_flags & IDE_DFLAG_PARKED) 104 + issue_park_cmd(drive, msecs_to_jiffies(input)); 105 + } else { 106 + if (drive->media == ide_disk) 107 + switch (input) { 108 + case -1: 109 + drive->dev_flags &= ~IDE_DFLAG_NO_UNLOAD; 110 + break; 111 + case -2: 112 + drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; 113 + break; 114 + } 115 + else 116 + rc = -EOPNOTSUPP; 117 + } 118 + mutex_unlock(&ide_setting_mtx); 119 + 120 + return rc ? rc : len; 121 + }
+112 -105
drivers/ide/ide-probe.c
··· 121 121 /* read 512 bytes of id info */ 122 122 hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); 123 123 124 - drive->id_read = 1; 124 + drive->dev_flags |= IDE_DFLAG_ID_READ; 125 + 125 126 local_irq_enable(); 126 127 #ifdef DEBUG 127 128 printk(KERN_INFO "%s: dumping identify data\n", drive->name); ··· 154 153 155 154 printk(KERN_INFO "%s: %s, ", drive->name, m); 156 155 157 - drive->present = 1; 158 - drive->dead = 0; 156 + drive->dev_flags |= IDE_DFLAG_PRESENT; 157 + drive->dev_flags &= ~IDE_DFLAG_DEAD; 159 158 160 159 /* 161 160 * Check for an ATAPI device ··· 173 172 printk(KERN_CONT "cdrom or floppy?, assuming "); 174 173 if (drive->media != ide_cdrom) { 175 174 printk(KERN_CONT "FLOPPY"); 176 - drive->removable = 1; 175 + drive->dev_flags |= IDE_DFLAG_REMOVABLE; 177 176 break; 178 177 } 179 178 } 180 179 /* Early cdrom models used zero */ 181 180 type = ide_cdrom; 182 181 case ide_cdrom: 183 - drive->removable = 1; 182 + drive->dev_flags |= IDE_DFLAG_REMOVABLE; 184 183 #ifdef CONFIG_PPC 185 184 /* kludge for Apple PowerBook internal zip */ 186 185 if (!strstr(m, "CD-ROM") && strstr(m, "ZIP")) { ··· 196 195 break; 197 196 case ide_optical: 198 197 printk(KERN_CONT "OPTICAL"); 199 - drive->removable = 1; 198 + drive->dev_flags |= IDE_DFLAG_REMOVABLE; 200 199 break; 201 200 default: 202 201 printk(KERN_CONT "UNKNOWN (type %d)", type); ··· 206 205 drive->media = type; 207 206 /* an ATAPI device ignores DRDY */ 208 207 drive->ready_stat = 0; 208 + if (ata_id_cdb_intr(id)) 209 + drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; 210 + /* we don't do head unloading on ATAPI devices */ 211 + drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; 209 212 return; 210 213 } 211 214 ··· 221 216 222 217 /* CF devices are *not* removable in Linux definition of the term */ 223 218 if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7))) 224 - drive->removable = 1; 219 + drive->dev_flags |= IDE_DFLAG_REMOVABLE; 225 220 226 221 drive->media = ide_disk; 222 + 223 + if (!ata_id_has_unload(drive->id)) 224 + drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; 227 225 228 226 printk(KERN_CONT "%s DISK drive\n", is_cfa ? "CFA" : "ATA"); 229 227 ··· 234 226 235 227 err_misc: 236 228 kfree(id); 237 - drive->present = 0; 229 + drive->dev_flags &= ~IDE_DFLAG_PRESENT; 238 230 return; 239 231 } 240 232 ··· 434 426 ide_hwif_t *hwif = HWIF(drive); 435 427 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 436 428 int rc; 437 - u8 stat; 429 + u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; 438 430 439 - if (drive->present) { 440 - /* avoid waiting for inappropriate probes */ 441 - if (drive->media != ide_disk && cmd == ATA_CMD_ID_ATA) 442 - return 4; 443 - } 431 + /* avoid waiting for inappropriate probes */ 432 + if (present && drive->media != ide_disk && cmd == ATA_CMD_ID_ATA) 433 + return 4; 434 + 444 435 #ifdef DEBUG 445 436 printk(KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n", 446 - drive->name, drive->present, drive->media, 437 + drive->name, present, drive->media, 447 438 (cmd == ATA_CMD_ID_ATA) ? "ATA" : "ATAPI"); 448 439 #endif 449 440 ··· 453 446 SELECT_DRIVE(drive); 454 447 msleep(50); 455 448 456 - if (ide_read_device(drive) != drive->select.all && !drive->present) { 457 - if (drive->select.b.unit != 0) { 449 + if (ide_read_device(drive) != drive->select && present == 0) { 450 + if (drive->dn & 1) { 458 451 /* exit with drive0 selected */ 459 452 SELECT_DRIVE(&hwif->drives[0]); 460 453 /* allow ATA_BUSY to assert & clear */ ··· 467 460 stat = tp_ops->read_status(hwif); 468 461 469 462 if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || 470 - drive->present || cmd == ATA_CMD_ID_ATAPI) { 463 + present || cmd == ATA_CMD_ID_ATAPI) { 471 464 /* send cmd and wait */ 472 465 if ((rc = try_to_identify(drive, cmd))) { 473 466 /* failed: try again */ ··· 500 493 /* not present or maybe ATAPI */ 501 494 rc = 3; 502 495 } 503 - if (drive->select.b.unit != 0) { 496 + if (drive->dn & 1) { 504 497 /* exit with drive0 selected */ 505 498 SELECT_DRIVE(&hwif->drives[0]); 506 499 msleep(50); ··· 549 542 * and presents things to the user as needed. 550 543 * 551 544 * Returns: 0 no device was found 552 - * 1 device was found (note: drive->present might 553 - * still be 0) 545 + * 1 device was found 546 + * (note: IDE_DFLAG_PRESENT might still be not set) 554 547 */ 555 548 556 549 static inline u8 probe_for_drive (ide_drive_t *drive) ··· 566 559 * Also note that 0 everywhere means "can't do X" 567 560 */ 568 561 562 + drive->dev_flags &= ~IDE_DFLAG_ID_READ; 563 + 569 564 drive->id = kzalloc(SECTOR_SIZE, GFP_KERNEL); 570 - drive->id_read = 0; 571 - if(drive->id == NULL) 572 - { 565 + if (drive->id == NULL) { 573 566 printk(KERN_ERR "ide: out of memory for id data.\n"); 574 567 return 0; 575 568 } ··· 578 571 strcpy(m, "UNKNOWN"); 579 572 580 573 /* skip probing? */ 581 - if (!drive->noprobe) { 574 + if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) { 582 575 retry: 583 576 /* if !(success||timed-out) */ 584 577 if (do_probe(drive, ATA_CMD_ID_ATA) >= 2) 585 578 /* look for ATAPI device */ 586 579 (void)do_probe(drive, ATA_CMD_ID_ATAPI); 587 580 588 - if (!drive->present) 581 + if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 589 582 /* drive not found */ 590 583 return 0; 591 584 ··· 595 588 } 596 589 597 590 /* identification failed? */ 598 - if (!drive->id_read) { 591 + if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { 599 592 if (drive->media == ide_disk) { 600 593 printk(KERN_INFO "%s: non-IDE drive, CHS=%d/%d/%d\n", 601 594 drive->name, drive->cyl, ··· 605 598 } else { 606 599 /* nuke it */ 607 600 printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name); 608 - drive->present = 0; 601 + drive->dev_flags &= ~IDE_DFLAG_PRESENT; 609 602 } 610 603 } 611 604 /* drive was found */ 612 605 } 613 - if(!drive->present) 606 + 607 + if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 614 608 return 0; 609 + 615 610 /* The drive wasn't being helpful. Add generic info only */ 616 - if (drive->id_read == 0) { 611 + if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) { 617 612 generic_id(drive); 618 613 return 1; 619 614 } ··· 625 616 ide_disk_init_mult_count(drive); 626 617 } 627 618 628 - return drive->present; 619 + return !!(drive->dev_flags & IDE_DFLAG_PRESENT); 629 620 } 630 621 631 622 static void hwif_release_dev(struct device *dev) ··· 716 707 ide_drive_t *drive = &hwif->drives[unit]; 717 708 718 709 /* Ignore disks that we will not probe for later. */ 719 - if (!drive->noprobe || drive->present) { 710 + if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0 || 711 + (drive->dev_flags & IDE_DFLAG_PRESENT)) { 720 712 SELECT_DRIVE(drive); 721 713 hwif->tp_ops->set_irq(hwif, 1); 722 714 mdelay(2); ··· 749 739 { 750 740 ide_drive_t *dev0 = &dev1->hwif->drives[0]; 751 741 752 - if ((dev1->dn & 1) == 0 || dev0->present == 0) 742 + if ((dev1->dn & 1) == 0 || (dev0->dev_flags & IDE_DFLAG_PRESENT) == 0) 753 743 return; 754 744 755 745 /* If the models don't match they are not the same product */ ··· 769 759 /* Appears to be an IDE flash adapter with decode bugs */ 770 760 printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n"); 771 761 772 - dev1->present = 0; 762 + dev1->dev_flags &= ~IDE_DFLAG_PRESENT; 773 763 } 774 764 775 765 EXPORT_SYMBOL_GPL(ide_undecoded_slave); ··· 782 772 783 773 BUG_ON(hwif->present); 784 774 785 - if (hwif->drives[0].noprobe && hwif->drives[1].noprobe) 775 + if ((hwif->drives[0].dev_flags & IDE_DFLAG_NOPROBE) && 776 + (hwif->drives[1].dev_flags & IDE_DFLAG_NOPROBE)) 786 777 return -EACCES; 787 778 788 779 /* ··· 805 794 */ 806 795 for (unit = 0; unit < MAX_DRIVES; ++unit) { 807 796 ide_drive_t *drive = &hwif->drives[unit]; 808 - drive->dn = (hwif->channel ? 2 : 0) + unit; 797 + 809 798 (void) probe_for_drive(drive); 810 - if (drive->present) 799 + if (drive->dev_flags & IDE_DFLAG_PRESENT) 811 800 rc = 0; 812 801 } 813 802 ··· 831 820 for (unit = 0; unit < MAX_DRIVES; unit++) { 832 821 ide_drive_t *drive = &hwif->drives[unit]; 833 822 834 - if (drive->present && port_ops && port_ops->quirkproc) 835 - port_ops->quirkproc(drive); 823 + if (drive->dev_flags & IDE_DFLAG_PRESENT) { 824 + if (port_ops && port_ops->quirkproc) 825 + port_ops->quirkproc(drive); 826 + } 836 827 } 837 828 838 829 for (unit = 0; unit < MAX_DRIVES; ++unit) { 839 830 ide_drive_t *drive = &hwif->drives[unit]; 840 831 841 - if (drive->present) { 832 + if (drive->dev_flags & IDE_DFLAG_PRESENT) { 842 833 ide_set_max_pio(drive); 843 834 844 - drive->nice1 = 1; 835 + drive->dev_flags |= IDE_DFLAG_NICE1; 845 836 846 837 if (hwif->dma_ops) 847 838 ide_set_dma(drive); ··· 853 840 for (unit = 0; unit < MAX_DRIVES; ++unit) { 854 841 ide_drive_t *drive = &hwif->drives[unit]; 855 842 856 - if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) 857 - drive->no_io_32bit = 1; 843 + if ((hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) || 844 + drive->id[ATA_ID_DWORD_IO]) 845 + drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; 858 846 else 859 - drive->no_io_32bit = drive->id[ATA_ID_DWORD_IO] ? 1 : 0; 847 + drive->dev_flags &= ~IDE_DFLAG_NO_IO_32BIT; 860 848 } 861 849 } 862 850 863 - #if MAX_HWIFS > 1 864 851 /* 865 852 * save_match() is used to simplify logic in init_irq() below. 866 853 * ··· 885 872 if (!m || m->irq != hwif->irq) /* don't undo a prior perfect match */ 886 873 *match = new; 887 874 } 888 - #endif /* MAX_HWIFS > 1 */ 889 875 890 876 /* 891 877 * init request queue ··· 963 951 * - allocate the block device queue 964 952 * - link drive into the hwgroup 965 953 */ 966 - static void ide_port_setup_devices(ide_hwif_t *hwif) 954 + static int ide_port_setup_devices(ide_hwif_t *hwif) 967 955 { 968 - int i; 956 + int i, j = 0; 969 957 970 958 mutex_lock(&ide_cfg_mtx); 971 959 for (i = 0; i < MAX_DRIVES; i++) { 972 960 ide_drive_t *drive = &hwif->drives[i]; 973 961 974 - if (!drive->present) 962 + if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 975 963 continue; 976 964 977 965 if (ide_init_queue(drive)) { 978 966 printk(KERN_ERR "ide: failed to init %s\n", 979 967 drive->name); 968 + kfree(drive->id); 969 + drive->id = NULL; 970 + drive->dev_flags &= ~IDE_DFLAG_PRESENT; 980 971 continue; 981 972 } 973 + 974 + j++; 982 975 983 976 ide_add_drive_to_hwgroup(drive); 984 977 } 985 978 mutex_unlock(&ide_cfg_mtx); 979 + 980 + return j; 986 981 } 987 982 988 983 static ide_hwif_t *ide_ports[MAX_HWIFS]; ··· 1048 1029 1049 1030 mutex_lock(&ide_cfg_mtx); 1050 1031 hwif->hwgroup = NULL; 1051 - #if MAX_HWIFS > 1 1032 + 1052 1033 /* 1053 1034 * Group up with any other hwifs that share our irq(s). 1054 1035 */ ··· 1073 1054 } 1074 1055 } 1075 1056 } 1076 - #endif /* MAX_HWIFS > 1 */ 1057 + 1077 1058 /* 1078 1059 * If we are still without a hwgroup, then form a new one 1079 1060 */ ··· 1172 1153 ide_hwif_t *hwif = data; 1173 1154 int unit = *part >> PARTN_BITS; 1174 1155 ide_drive_t *drive = &hwif->drives[unit]; 1175 - if (!drive->present) 1156 + 1157 + if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 1176 1158 return NULL; 1177 1159 1178 1160 if (drive->media == ide_disk) 1179 1161 request_module("ide-disk"); 1180 - if (drive->scsi) 1162 + if (drive->dev_flags & IDE_DFLAG_SCSI) 1181 1163 request_module("ide-scsi"); 1182 1164 if (drive->media == ide_cdrom || drive->media == ide_optical) 1183 1165 request_module("ide-cd"); ··· 1225 1205 void ide_init_disk(struct gendisk *disk, ide_drive_t *drive) 1226 1206 { 1227 1207 ide_hwif_t *hwif = drive->hwif; 1228 - unsigned int unit = (drive->select.all >> 4) & 1; 1208 + unsigned int unit = drive->dn & 1; 1229 1209 1230 1210 disk->major = hwif->major; 1231 1211 disk->first_minor = unit << PARTN_BITS; ··· 1268 1248 ide_remove_drive_from_hwgroup(drive); 1269 1249 kfree(drive->id); 1270 1250 drive->id = NULL; 1271 - drive->present = 0; 1251 + drive->dev_flags &= ~IDE_DFLAG_PRESENT; 1272 1252 /* Messed up locking ... */ 1273 1253 spin_unlock_irq(&ide_lock); 1274 1254 blk_cleanup_queue(drive->queue); ··· 1347 1327 struct device *dev = &drive->gendev; 1348 1328 int ret; 1349 1329 1350 - if (!drive->present) 1330 + if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 1351 1331 continue; 1352 1332 1353 1333 snprintf(dev->bus_id, BUS_ID_SIZE, "%u.%u", hwif->index, i); ··· 1371 1351 for (i = 0; i < MAX_DRIVES; i++) { 1372 1352 ide_drive_t *drive = &hwif->drives[i]; 1373 1353 1354 + drive->dn = i + hwif->channel * 2; 1355 + 1374 1356 if (hwif->host_flags & IDE_HFLAG_IO_32BIT) 1375 1357 drive->io_32bit = 1; 1376 1358 if (hwif->host_flags & IDE_HFLAG_UNMASK_IRQS) 1377 - drive->unmask = 1; 1359 + drive->dev_flags |= IDE_DFLAG_UNMASK; 1378 1360 if (hwif->host_flags & IDE_HFLAG_NO_UNMASK_IRQS) 1379 - drive->no_unmask = 1; 1361 + drive->dev_flags |= IDE_DFLAG_NO_UNMASK; 1380 1362 1381 1363 if (port_ops && port_ops->init_dev) 1382 1364 port_ops->init_dev(drive); ··· 1535 1513 * ports 0x1f0/0x170 (the ide0/ide1 defaults). 1536 1514 */ 1537 1515 mutex_lock(&ide_cfg_mtx); 1538 - if (MAX_HWIFS == 1) { 1539 - if (ide_indexes == 0 && i == 0) 1540 - idx = 1; 1516 + if (bootable) { 1517 + if ((ide_indexes | i) != (1 << MAX_HWIFS) - 1) 1518 + idx = ffz(ide_indexes | i); 1541 1519 } else { 1542 - if (bootable) { 1543 - if ((ide_indexes | i) != (1 << MAX_HWIFS) - 1) 1544 - idx = ffz(ide_indexes | i); 1545 - } else { 1546 - if ((ide_indexes | 3) != (1 << MAX_HWIFS) - 1) 1547 - idx = ffz(ide_indexes | 3); 1548 - else if ((ide_indexes & 3) != 3) 1549 - idx = ffz(ide_indexes); 1550 - } 1520 + if ((ide_indexes | 3) != (1 << MAX_HWIFS) - 1) 1521 + idx = ffz(ide_indexes | 3); 1522 + else if ((ide_indexes & 3) != 3) 1523 + idx = ffz(ide_indexes); 1551 1524 } 1552 1525 if (idx >= 0) 1553 1526 ide_indexes |= (1 << idx); ··· 1558 1541 mutex_unlock(&ide_cfg_mtx); 1559 1542 } 1560 1543 1561 - struct ide_host *ide_host_alloc_all(const struct ide_port_info *d, 1562 - hw_regs_t **hws) 1544 + struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) 1563 1545 { 1564 1546 struct ide_host *host; 1565 1547 int i; ··· 1567 1551 if (host == NULL) 1568 1552 return NULL; 1569 1553 1570 - for (i = 0; i < MAX_HWIFS; i++) { 1554 + for (i = 0; i < MAX_HOST_PORTS; i++) { 1571 1555 ide_hwif_t *hwif; 1572 1556 int idx; 1573 1557 ··· 1609 1593 1610 1594 return host; 1611 1595 } 1612 - EXPORT_SYMBOL_GPL(ide_host_alloc_all); 1613 - 1614 - struct ide_host *ide_host_alloc(const struct ide_port_info *d, hw_regs_t **hws) 1615 - { 1616 - hw_regs_t *hws_all[MAX_HWIFS]; 1617 - int i; 1618 - 1619 - for (i = 0; i < MAX_HWIFS; i++) 1620 - hws_all[i] = (i < 4) ? hws[i] : NULL; 1621 - 1622 - return ide_host_alloc_all(d, hws_all); 1623 - } 1624 1596 EXPORT_SYMBOL_GPL(ide_host_alloc); 1625 1597 1626 1598 int ide_host_register(struct ide_host *host, const struct ide_port_info *d, ··· 1617 1613 ide_hwif_t *hwif, *mate = NULL; 1618 1614 int i, j = 0; 1619 1615 1620 - for (i = 0; i < MAX_HWIFS; i++) { 1616 + for (i = 0; i < MAX_HOST_PORTS; i++) { 1621 1617 hwif = host->ports[i]; 1622 1618 1623 1619 if (hwif == NULL) { ··· 1630 1626 1631 1627 if (d == NULL) { 1632 1628 mate = NULL; 1633 - continue; 1629 + } else { 1630 + if ((i & 1) && mate) { 1631 + hwif->mate = mate; 1632 + mate->mate = hwif; 1633 + } 1634 + 1635 + mate = (i & 1) ? NULL : hwif; 1636 + 1637 + ide_init_port(hwif, i & 1, d); 1638 + ide_port_cable_detect(hwif); 1634 1639 } 1635 1640 1636 - if ((i & 1) && mate) { 1637 - hwif->mate = mate; 1638 - mate->mate = hwif; 1639 - } 1640 - 1641 - mate = (i & 1) ? NULL : hwif; 1642 - 1643 - ide_init_port(hwif, i & 1, d); 1644 - ide_port_cable_detect(hwif); 1645 1641 ide_port_init_devices(hwif); 1646 1642 } 1647 1643 1648 - for (i = 0; i < MAX_HWIFS; i++) { 1644 + for (i = 0; i < MAX_HOST_PORTS; i++) { 1649 1645 hwif = host->ports[i]; 1650 1646 1651 1647 if (hwif == NULL) ··· 1662 1658 ide_port_tune_devices(hwif); 1663 1659 } 1664 1660 1665 - for (i = 0; i < MAX_HWIFS; i++) { 1661 + for (i = 0; i < MAX_HOST_PORTS; i++) { 1666 1662 hwif = host->ports[i]; 1667 1663 1668 1664 if (hwif == NULL) ··· 1675 1671 continue; 1676 1672 } 1677 1673 1678 - j++; 1679 - 1680 1674 if (hwif->present) 1681 - ide_port_setup_devices(hwif); 1675 + if (ide_port_setup_devices(hwif) == 0) { 1676 + hwif->present = 0; 1677 + continue; 1678 + } 1679 + 1680 + j++; 1682 1681 1683 1682 ide_acpi_init(hwif); 1684 1683 ··· 1689 1682 ide_acpi_port_init_devices(hwif); 1690 1683 } 1691 1684 1692 - for (i = 0; i < MAX_HWIFS; i++) { 1685 + for (i = 0; i < MAX_HOST_PORTS; i++) { 1693 1686 hwif = host->ports[i]; 1694 1687 1695 1688 if (hwif == NULL) ··· 1702 1695 hwif_register_devices(hwif); 1703 1696 } 1704 1697 1705 - for (i = 0; i < MAX_HWIFS; i++) { 1698 + for (i = 0; i < MAX_HOST_PORTS; i++) { 1706 1699 hwif = host->ports[i]; 1707 1700 1708 1701 if (hwif == NULL) ··· 1747 1740 ide_hwif_t *hwif; 1748 1741 int i; 1749 1742 1750 - for (i = 0; i < MAX_HWIFS; i++) { 1743 + for (i = 0; i < MAX_HOST_PORTS; i++) { 1751 1744 hwif = host->ports[i]; 1752 1745 1753 1746 if (hwif == NULL) ··· 1765 1758 { 1766 1759 int i; 1767 1760 1768 - for (i = 0; i < MAX_HWIFS; i++) { 1761 + for (i = 0; i < MAX_HOST_PORTS; i++) { 1769 1762 if (host->ports[i]) 1770 1763 ide_unregister(host->ports[i]); 1771 1764 }
+2 -4
drivers/ide/ide-proc.c
··· 227 227 228 228 ide_devset_rw(current_speed, xfer_rate); 229 229 ide_devset_rw_field(init_speed, init_speed); 230 - ide_devset_rw_field(nice1, nice1); 230 + ide_devset_rw_flag(nice1, IDE_DFLAG_NICE1); 231 231 ide_devset_rw_field(number, dn); 232 232 233 233 static const struct ide_proc_devset ide_generic_settings[] = { ··· 622 622 for (d = 0; d < MAX_DRIVES; d++) { 623 623 ide_drive_t *drive = &hwif->drives[d]; 624 624 625 - if (!drive->present) 626 - continue; 627 - if (drive->proc) 625 + if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0 || drive->proc) 628 626 continue; 629 627 630 628 drive->proc = proc_mkdir(drive->name, parent);
+49 -106
drivers/ide/ide-tape.c
··· 172 172 struct kref kref; 173 173 174 174 /* 175 - * pc points to the current processed packet command. 176 - * 177 175 * failed_pc points to the last failed packet command, or contains 178 176 * NULL if we do not need to retry any packet command. This is 179 177 * required since an additional packet command is needed before the 180 178 * retry, to get detailed information on what went wrong. 181 179 */ 182 - /* Current packet command */ 183 - struct ide_atapi_pc *pc; 184 180 /* Last failed packet command */ 185 181 struct ide_atapi_pc *failed_pc; 186 182 /* used by REQ_IDETAPE_{READ,WRITE} requests */ 187 183 struct ide_atapi_pc queued_pc; 188 - 189 - struct ide_atapi_pc request_sense_pc; 190 - struct request request_sense_rq; 191 184 192 185 /* 193 186 * DSC polling variables. ··· 267 274 268 275 static struct class *idetape_sysfs_class; 269 276 270 - #define to_ide_tape(obj) container_of(obj, struct ide_tape_obj, kref) 271 - 272 - #define ide_tape_g(disk) \ 273 - container_of((disk)->private_data, struct ide_tape_obj, driver) 274 - 275 277 static void ide_tape_release(struct kref *); 276 278 277 279 static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) ··· 274 286 struct ide_tape_obj *tape = NULL; 275 287 276 288 mutex_lock(&idetape_ref_mutex); 277 - tape = ide_tape_g(disk); 289 + tape = ide_drv_g(disk, ide_tape_obj); 278 290 if (tape) { 279 291 if (ide_device_get(tape->drive)) 280 292 tape = NULL; ··· 300 312 * state variables are defined in our ide_drive_t structure. 301 313 */ 302 314 static struct ide_tape_obj *idetape_devs[MAX_HWIFS * MAX_DRIVES]; 303 - 304 - #define ide_tape_f(file) ((file)->private_data) 305 315 306 316 static struct ide_tape_obj *ide_tape_chrdev_get(unsigned int i) 307 317 { ··· 508 522 return 0; 509 523 } 510 524 511 - static void ide_tape_callback(ide_drive_t *drive) 525 + static void ide_tape_handle_dsc(ide_drive_t *); 526 + 527 + static void ide_tape_callback(ide_drive_t *drive, int dsc) 512 528 { 513 529 idetape_tape_t *tape = drive->driver_data; 514 - struct ide_atapi_pc *pc = tape->pc; 530 + struct ide_atapi_pc *pc = drive->pc; 515 531 int uptodate = pc->error ? 0 : 1; 516 532 517 533 debug_log(DBG_PROCS, "Enter %s\n", __func__); 534 + 535 + if (dsc) 536 + ide_tape_handle_dsc(drive); 518 537 519 538 if (tape->failed_pc == pc) 520 539 tape->failed_pc = NULL; ··· 549 558 if (pc->error) 550 559 uptodate = pc->error; 551 560 } else if (pc->c[0] == READ_POSITION && uptodate) { 552 - u8 *readpos = tape->pc->buf; 561 + u8 *readpos = pc->buf; 553 562 554 563 debug_log(DBG_SENSE, "BOP - %s\n", 555 564 (readpos[0] & 0x80) ? "Yes" : "No"); ··· 572 581 } 573 582 574 583 idetape_end_request(drive, uptodate, 0); 575 - } 576 - 577 - static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) 578 - { 579 - ide_init_pc(pc); 580 - pc->c[0] = REQUEST_SENSE; 581 - pc->c[4] = 20; 582 - pc->req_xfer = 20; 583 - } 584 - 585 - /* 586 - * idetape_retry_pc is called when an error was detected during the 587 - * last packet command. We queue a request sense packet command in 588 - * the head of the request list. 589 - */ 590 - static void idetape_retry_pc(ide_drive_t *drive) 591 - { 592 - struct ide_tape_obj *tape = drive->driver_data; 593 - struct request *rq = &tape->request_sense_rq; 594 - struct ide_atapi_pc *pc = &tape->request_sense_pc; 595 - 596 - (void)ide_read_error(drive); 597 - idetape_create_request_sense_cmd(pc); 598 - set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 599 - ide_queue_pc_head(drive, tape->disk, pc, rq); 600 584 } 601 585 602 586 /* ··· 612 646 } 613 647 614 648 /* 615 - * This is the usual interrupt handler which will be called during a packet 616 - * command. We will transfer some of the data (as requested by the drive) and 617 - * will re-point interrupt handler to us. When data transfer is finished, we 618 - * will act according to the algorithm described before 619 - * idetape_issue_pc. 620 - */ 621 - static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) 622 - { 623 - idetape_tape_t *tape = drive->driver_data; 624 - 625 - return ide_pc_intr(drive, tape->pc, idetape_pc_intr, WAIT_TAPE_CMD, 626 - NULL, idetape_update_buffers, idetape_retry_pc, 627 - ide_tape_handle_dsc, ide_tape_io_buffers); 628 - } 629 - 630 - /* 631 649 * Packet Command Interface 632 650 * 633 - * The current Packet Command is available in tape->pc, and will not change 651 + * The current Packet Command is available in drive->pc, and will not change 634 652 * until we finish handling it. Each packet command is associated with a 635 653 * callback function that will be called when the command is finished. 636 654 * 637 655 * The handling will be done in three stages: 638 656 * 639 657 * 1. idetape_issue_pc will send the packet command to the drive, and will set 640 - * the interrupt handler to idetape_pc_intr. 658 + * the interrupt handler to ide_pc_intr. 641 659 * 642 - * 2. On each interrupt, idetape_pc_intr will be called. This step will be 660 + * 2. On each interrupt, ide_pc_intr will be called. This step will be 643 661 * repeated until the device signals us that no more interrupts will be issued. 644 662 * 645 663 * 3. ATAPI Tape media access commands have immediate status with a delayed ··· 647 697 * again, the callback function will be called and then we will handle the next 648 698 * request. 649 699 */ 650 - static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) 651 - { 652 - idetape_tape_t *tape = drive->driver_data; 653 - 654 - return ide_transfer_pc(drive, tape->pc, idetape_pc_intr, 655 - WAIT_TAPE_CMD, NULL); 656 - } 657 700 658 701 static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, 659 702 struct ide_atapi_pc *pc) 660 703 { 661 704 idetape_tape_t *tape = drive->driver_data; 662 705 663 - if (tape->pc->c[0] == REQUEST_SENSE && 706 + if (drive->pc->c[0] == REQUEST_SENSE && 664 707 pc->c[0] == REQUEST_SENSE) { 665 708 printk(KERN_ERR "ide-tape: possible ide-tape.c bug - " 666 709 "Two request sense in serial were issued\n"); ··· 661 718 662 719 if (tape->failed_pc == NULL && pc->c[0] != REQUEST_SENSE) 663 720 tape->failed_pc = pc; 721 + 664 722 /* Set the current packet command */ 665 - tape->pc = pc; 723 + drive->pc = pc; 666 724 667 725 if (pc->retries > IDETAPE_MAX_PC_RETRIES || 668 726 (pc->flags & PC_FLAG_ABORT)) { ··· 687 743 pc->error = IDETAPE_ERROR_GENERAL; 688 744 } 689 745 tape->failed_pc = NULL; 690 - drive->pc_callback(drive); 746 + drive->pc_callback(drive, 0); 691 747 return ide_stopped; 692 748 } 693 749 debug_log(DBG_SENSE, "Retry #%d, cmd = %02X\n", pc->retries, pc->c[0]); 694 750 695 751 pc->retries++; 696 752 697 - return ide_issue_pc(drive, pc, idetape_transfer_pc, 698 - WAIT_TAPE_CMD, NULL); 753 + return ide_issue_pc(drive, WAIT_TAPE_CMD, NULL); 699 754 } 700 755 701 756 /* A mode sense command is used to "sense" tape parameters. */ ··· 728 785 { 729 786 ide_hwif_t *hwif = drive->hwif; 730 787 idetape_tape_t *tape = drive->driver_data; 731 - struct ide_atapi_pc *pc = tape->pc; 788 + struct ide_atapi_pc *pc = drive->pc; 732 789 u8 stat; 733 790 734 791 stat = hwif->tp_ops->read_status(hwif); ··· 740 797 printk(KERN_ERR "ide-tape: %s: I/O error, ", 741 798 tape->name); 742 799 /* Retry operation */ 743 - idetape_retry_pc(drive); 800 + ide_retry_pc(drive, tape->disk); 744 801 return ide_stopped; 745 802 } 746 803 pc->error = 0; ··· 748 805 pc->error = IDETAPE_ERROR_GENERAL; 749 806 tape->failed_pc = NULL; 750 807 } 751 - drive->pc_callback(drive); 808 + drive->pc_callback(drive, 0); 752 809 return ide_stopped; 753 810 } 754 811 ··· 805 862 } 806 863 807 864 /* Retry a failed packet command */ 808 - if (tape->failed_pc && tape->pc->c[0] == REQUEST_SENSE) { 865 + if (tape->failed_pc && drive->pc->c[0] == REQUEST_SENSE) { 809 866 pc = tape->failed_pc; 810 867 goto out; 811 868 } ··· 826 883 */ 827 884 stat = hwif->tp_ops->read_status(hwif); 828 885 829 - if (!drive->dsc_overlap && !(rq->cmd[13] & REQ_IDETAPE_PC2)) 886 + if ((drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) == 0 && 887 + (rq->cmd[13] & REQ_IDETAPE_PC2) == 0) 830 888 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 831 889 832 - if (drive->post_reset == 1) { 890 + if (drive->dev_flags & IDE_DFLAG_POST_RESET) { 833 891 set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); 834 - drive->post_reset = 0; 892 + drive->dev_flags &= ~IDE_DFLAG_POST_RESET; 835 893 } 836 894 837 895 if (!test_and_clear_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags) && ··· 1355 1411 * No point in issuing this if DSC overlap isn't supported, some 1356 1412 * drives (Seagate STT3401A) will return an error. 1357 1413 */ 1358 - if (drive->dsc_overlap) { 1414 + if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) { 1359 1415 bytes_read = idetape_queue_rw_tail(drive, 1360 1416 REQ_IDETAPE_READ, 0, 1361 1417 tape->merge_bh); ··· 1536 1592 static ssize_t idetape_chrdev_read(struct file *file, char __user *buf, 1537 1593 size_t count, loff_t *ppos) 1538 1594 { 1539 - struct ide_tape_obj *tape = ide_tape_f(file); 1595 + struct ide_tape_obj *tape = file->private_data; 1540 1596 ide_drive_t *drive = tape->drive; 1541 1597 ssize_t bytes_read, temp, actually_read = 0, rc; 1542 1598 ssize_t ret = 0; ··· 1598 1654 static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, 1599 1655 size_t count, loff_t *ppos) 1600 1656 { 1601 - struct ide_tape_obj *tape = ide_tape_f(file); 1657 + struct ide_tape_obj *tape = file->private_data; 1602 1658 ide_drive_t *drive = tape->drive; 1603 1659 ssize_t actually_written = 0; 1604 1660 ssize_t ret = 0; ··· 1631 1687 * point in issuing this if DSC overlap isn't supported, some 1632 1688 * drives (Seagate STT3401A) will return an error. 1633 1689 */ 1634 - if (drive->dsc_overlap) { 1690 + if (drive->dev_flags & IDE_DFLAG_DSC_OVERLAP) { 1635 1691 ssize_t retval = idetape_queue_rw_tail(drive, 1636 1692 REQ_IDETAPE_WRITE, 0, 1637 1693 tape->merge_bh); ··· 1830 1886 static int idetape_chrdev_ioctl(struct inode *inode, struct file *file, 1831 1887 unsigned int cmd, unsigned long arg) 1832 1888 { 1833 - struct ide_tape_obj *tape = ide_tape_f(file); 1889 + struct ide_tape_obj *tape = file->private_data; 1834 1890 ide_drive_t *drive = tape->drive; 1835 1891 struct mtop mtop; 1836 1892 struct mtget mtget; ··· 2007 2063 2008 2064 static int idetape_chrdev_release(struct inode *inode, struct file *filp) 2009 2065 { 2010 - struct ide_tape_obj *tape = ide_tape_f(filp); 2066 + struct ide_tape_obj *tape = filp->private_data; 2011 2067 ide_drive_t *drive = tape->drive; 2012 2068 unsigned int minor = iminor(inode); 2013 2069 ··· 2146 2202 static int divf_buffer(ide_drive_t *drive) { return 2; } 2147 2203 static int divf_buffer_size(ide_drive_t *drive) { return 1024; } 2148 2204 2149 - ide_devset_rw_field(dsc_overlap, dsc_overlap); 2205 + ide_devset_rw_flag(dsc_overlap, IDE_DFLAG_DSC_OVERLAP); 2150 2206 2151 2207 ide_tape_devset_rw_field(debug_mask, debug_mask); 2152 2208 ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq); ··· 2185 2241 unsigned long t; 2186 2242 int speed; 2187 2243 int buffer_size; 2188 - u8 gcw[2]; 2189 2244 u16 *ctl = (u16 *)&tape->caps[12]; 2190 2245 2191 - drive->pc_callback = ide_tape_callback; 2246 + drive->pc_callback = ide_tape_callback; 2247 + drive->pc_update_buffers = idetape_update_buffers; 2248 + drive->pc_io_buffers = ide_tape_io_buffers; 2192 2249 2193 2250 spin_lock_init(&tape->lock); 2194 - drive->dsc_overlap = 1; 2251 + 2252 + drive->dev_flags |= IDE_DFLAG_DSC_OVERLAP; 2253 + 2195 2254 if (drive->hwif->host_flags & IDE_HFLAG_NO_DSC) { 2196 2255 printk(KERN_INFO "ide-tape: %s: disabling DSC overlap\n", 2197 2256 tape->name); 2198 - drive->dsc_overlap = 0; 2257 + drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 2199 2258 } 2259 + 2200 2260 /* Seagate Travan drives do not support DSC overlap. */ 2201 2261 if (strstr((char *)&drive->id[ATA_ID_PROD], "Seagate STT3401")) 2202 - drive->dsc_overlap = 0; 2262 + drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 2263 + 2203 2264 tape->minor = minor; 2204 2265 tape->name[0] = 'h'; 2205 2266 tape->name[1] = 't'; 2206 2267 tape->name[2] = '0' + minor; 2207 2268 tape->chrdev_dir = IDETAPE_DIR_NONE; 2208 - 2209 - *((u16 *)&gcw) = drive->id[ATA_ID_CONFIG]; 2210 - 2211 - /* Command packet DRQ type */ 2212 - if (((gcw[0] & 0x60) >> 5) == 1) 2213 - set_bit(IDE_AFLAG_DRQ_INTERRUPT, &drive->atapi_flags); 2214 2269 2215 2270 idetape_get_inquiry_results(drive); 2216 2271 idetape_get_mode_sense_results(drive); ··· 2245 2302 (*(u16 *)&tape->caps[16] * 512) / tape->buffer_size, 2246 2303 tape->buffer_size / 1024, 2247 2304 tape->best_dsc_rw_freq * 1000 / HZ, 2248 - drive->using_dma ? ", DMA":""); 2305 + (drive->dev_flags & IDE_DFLAG_USING_DMA) ? ", DMA" : ""); 2249 2306 2250 2307 ide_proc_register_driver(drive, tape->driver); 2251 2308 } ··· 2263 2320 2264 2321 static void ide_tape_release(struct kref *kref) 2265 2322 { 2266 - struct ide_tape_obj *tape = to_ide_tape(kref); 2323 + struct ide_tape_obj *tape = to_ide_drv(kref, ide_tape_obj); 2267 2324 ide_drive_t *drive = tape->drive; 2268 2325 struct gendisk *g = tape->disk; 2269 2326 2270 2327 BUG_ON(tape->merge_bh_size); 2271 2328 2272 - drive->dsc_overlap = 0; 2329 + drive->dev_flags &= ~IDE_DFLAG_DSC_OVERLAP; 2273 2330 drive->driver_data = NULL; 2274 2331 device_destroy(idetape_sysfs_class, MKDEV(IDETAPE_MAJOR, tape->minor)); 2275 2332 device_destroy(idetape_sysfs_class, ··· 2311 2368 .probe = ide_tape_probe, 2312 2369 .remove = ide_tape_remove, 2313 2370 .version = IDETAPE_VERSION, 2314 - .media = ide_tape, 2315 2371 .do_request = idetape_do_request, 2316 2372 .end_request = idetape_end_request, 2317 2373 .error = __ide_error, ··· 2345 2403 static int idetape_release(struct inode *inode, struct file *filp) 2346 2404 { 2347 2405 struct gendisk *disk = inode->i_bdev->bd_disk; 2348 - struct ide_tape_obj *tape = ide_tape_g(disk); 2406 + struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); 2349 2407 2350 2408 ide_tape_put(tape); 2351 2409 ··· 2356 2414 unsigned int cmd, unsigned long arg) 2357 2415 { 2358 2416 struct block_device *bdev = inode->i_bdev; 2359 - struct ide_tape_obj *tape = ide_tape_g(bdev->bd_disk); 2417 + struct ide_tape_obj *tape = ide_drv_g(bdev->bd_disk, ide_tape_obj); 2360 2418 ide_drive_t *drive = tape->drive; 2361 2419 int err = generic_ide_ioctl(drive, file, bdev, cmd, arg); 2362 2420 if (err == -EINVAL) ··· 2383 2441 if (drive->media != ide_tape) 2384 2442 goto failed; 2385 2443 2386 - if (drive->id_read == 1 && !ide_check_atapi_device(drive, DRV_NAME)) { 2444 + if ((drive->dev_flags & IDE_DFLAG_ID_READ) && 2445 + ide_check_atapi_device(drive, DRV_NAME) == 0) { 2387 2446 printk(KERN_ERR "ide-tape: %s: not supported by this version of" 2388 2447 " the driver\n", drive->name); 2389 2448 goto failed;
+41 -87
drivers/ide/ide-taskfile.c
··· 53 53 } 54 54 55 55 static ide_startstop_t task_no_data_intr(ide_drive_t *); 56 - static ide_startstop_t set_geometry_intr(ide_drive_t *); 57 - static ide_startstop_t recal_intr(ide_drive_t *); 58 - static ide_startstop_t set_multmode_intr(ide_drive_t *); 59 56 static ide_startstop_t pre_task_out_intr(ide_drive_t *, struct request *); 60 57 static ide_startstop_t task_in_intr(ide_drive_t *); 61 58 ··· 76 79 if (task->tf_flags & IDE_TFLAG_FLAGGED) 77 80 task->tf_flags |= IDE_TFLAG_FLAGGED_SET_IN_FLAGS; 78 81 82 + memcpy(&hwif->task, task, sizeof(*task)); 83 + 79 84 if ((task->tf_flags & IDE_TFLAG_DMA_PIO_FALLBACK) == 0) { 80 85 ide_tf_dump(drive->name, tf); 81 86 tp_ops->set_irq(hwif, 1); ··· 98 99 case TASKFILE_NO_DATA: 99 100 if (handler == NULL) 100 101 handler = task_no_data_intr; 101 - if (task->tf_flags & IDE_TFLAG_CUSTOM_HANDLER) { 102 - switch (tf->command) { 103 - case ATA_CMD_INIT_DEV_PARAMS: 104 - handler = set_geometry_intr; 105 - break; 106 - case ATA_CMD_RESTORE: 107 - handler = recal_intr; 108 - break; 109 - case ATA_CMD_SET_MULTI: 110 - handler = set_multmode_intr; 111 - break; 112 - } 113 - } 114 102 ide_execute_command(drive, tf->command, handler, 115 103 WAIT_WORSTCASE, NULL); 116 104 return ide_started; 117 105 default: 118 - if (drive->using_dma == 0 || dma_ops->dma_setup(drive)) 106 + if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0 || 107 + dma_ops->dma_setup(drive)) 119 108 return ide_stopped; 120 109 dma_ops->dma_exec_cmd(drive, tf->command); 121 110 dma_ops->dma_start(drive); ··· 113 126 EXPORT_SYMBOL_GPL(do_rw_taskfile); 114 127 115 128 /* 116 - * set_multmode_intr() is invoked on completion of a ATA_CMD_SET_MULTI cmd. 129 + * Handler for commands without a data phase 117 130 */ 118 - static ide_startstop_t set_multmode_intr(ide_drive_t *drive) 131 + static ide_startstop_t task_no_data_intr(ide_drive_t *drive) 119 132 { 120 133 ide_hwif_t *hwif = drive->hwif; 121 - u8 stat; 122 - 123 - local_irq_enable_in_hardirq(); 124 - stat = hwif->tp_ops->read_status(hwif); 125 - 126 - if (OK_STAT(stat, ATA_DRDY, BAD_STAT)) 127 - drive->mult_count = drive->mult_req; 128 - else { 129 - drive->mult_req = drive->mult_count = 0; 130 - drive->special.b.recalibrate = 1; 131 - (void) ide_dump_status(drive, "set_multmode", stat); 132 - } 133 - return ide_stopped; 134 - } 135 - 136 - /* 137 - * set_geometry_intr() is invoked on completion of a ATA_CMD_INIT_DEV_PARAMS cmd. 138 - */ 139 - static ide_startstop_t set_geometry_intr(ide_drive_t *drive) 140 - { 141 - ide_hwif_t *hwif = drive->hwif; 142 - int retries = 5; 134 + ide_task_t *task = &hwif->task; 135 + struct ide_taskfile *tf = &task->tf; 136 + int custom = (task->tf_flags & IDE_TFLAG_CUSTOM_HANDLER) ? 1 : 0; 137 + int retries = (custom && tf->command == ATA_CMD_INIT_DEV_PARAMS) ? 5 : 1; 143 138 u8 stat; 144 139 145 140 local_irq_enable_in_hardirq(); ··· 133 164 udelay(10); 134 165 }; 135 166 136 - if (OK_STAT(stat, ATA_DRDY, BAD_STAT)) 137 - return ide_stopped; 138 - 139 - if (stat & (ATA_ERR | ATA_DRQ)) 140 - return ide_error(drive, "set_geometry_intr", stat); 141 - 142 - ide_set_handler(drive, &set_geometry_intr, WAIT_WORSTCASE, NULL); 143 - return ide_started; 144 - } 145 - 146 - /* 147 - * recal_intr() is invoked on completion of a ATA_CMD_RESTORE (recalibrate) cmd. 148 - */ 149 - static ide_startstop_t recal_intr(ide_drive_t *drive) 150 - { 151 - ide_hwif_t *hwif = drive->hwif; 152 - u8 stat; 153 - 154 - local_irq_enable_in_hardirq(); 155 - stat = hwif->tp_ops->read_status(hwif); 156 - 157 - if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) 158 - return ide_error(drive, "recal_intr", stat); 159 - return ide_stopped; 160 - } 161 - 162 - /* 163 - * Handler for commands without a data phase 164 - */ 165 - static ide_startstop_t task_no_data_intr(ide_drive_t *drive) 166 - { 167 - ide_hwif_t *hwif = drive->hwif; 168 - ide_task_t *args = hwif->hwgroup->rq->special; 169 - u8 stat; 170 - 171 - local_irq_enable_in_hardirq(); 172 - stat = hwif->tp_ops->read_status(hwif); 173 - 174 - if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) 167 + if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) { 168 + if (custom && tf->command == ATA_CMD_SET_MULTI) { 169 + drive->mult_req = drive->mult_count = 0; 170 + drive->special.b.recalibrate = 1; 171 + (void)ide_dump_status(drive, __func__, stat); 172 + return ide_stopped; 173 + } else if (custom && tf->command == ATA_CMD_INIT_DEV_PARAMS) { 174 + if ((stat & (ATA_ERR | ATA_DRQ)) == 0) { 175 + ide_set_handler(drive, &task_no_data_intr, 176 + WAIT_WORSTCASE, NULL); 177 + return ide_started; 178 + } 179 + } 175 180 return ide_error(drive, "task_no_data_intr", stat); 176 181 /* calls ide_end_drive_cmd */ 182 + } 177 183 178 - if (args) 184 + if (!custom) 179 185 ide_end_drive_cmd(drive, stat, ide_read_error(drive)); 186 + else if (tf->command == ATA_CMD_IDLEIMMEDIATE) { 187 + hwif->tp_ops->tf_read(drive, task); 188 + if (tf->lbal != 0xc4) { 189 + printk(KERN_ERR "%s: head unload failed!\n", 190 + drive->name); 191 + ide_tf_dump(drive->name, tf); 192 + } else 193 + drive->dev_flags |= IDE_DFLAG_PARKED; 194 + ide_end_drive_cmd(drive, stat, ide_read_error(drive)); 195 + } else if (tf->command == ATA_CMD_SET_MULTI) 196 + drive->mult_count = drive->mult_req; 180 197 181 198 return ide_stopped; 182 199 } ··· 424 469 if (ide_wait_stat(&startstop, drive, ATA_DRQ, 425 470 drive->bad_wstat, WAIT_DRQ)) { 426 471 printk(KERN_ERR "%s: no DRQ after issuing %sWRITE%s\n", 427 - drive->name, 428 - drive->hwif->data_phase ? "MULT" : "", 429 - drive->addressing ? "_EXT" : ""); 472 + drive->name, drive->hwif->data_phase ? "MULT" : "", 473 + (drive->dev_flags & IDE_DFLAG_LBA48) ? "_EXT" : ""); 430 474 return startstop; 431 475 } 432 476 433 - if (!drive->unmask) 477 + if ((drive->dev_flags & IDE_DFLAG_UNMASK) == 0) 434 478 local_irq_disable(); 435 479 436 480 ide_set_handler(drive, &task_out_intr, WAIT_WORSTCASE, NULL); ··· 545 591 546 592 args.tf_flags = IDE_TFLAG_IO_16BIT | IDE_TFLAG_DEVICE | 547 593 IDE_TFLAG_IN_TF; 548 - if (drive->addressing == 1) 594 + if (drive->dev_flags & IDE_DFLAG_LBA48) 549 595 args.tf_flags |= (IDE_TFLAG_LBA48 | IDE_TFLAG_IN_HOB); 550 596 551 597 if (req_task->out_flags.all) { ··· 648 694 if ((args.tf_flags & IDE_TFLAG_FLAGGED_SET_IN_FLAGS) && 649 695 req_task->in_flags.all == 0) { 650 696 req_task->in_flags.all = IDE_TASKFILE_STD_IN_FLAGS; 651 - if (drive->addressing == 1) 697 + if (drive->dev_flags & IDE_DFLAG_LBA48) 652 698 req_task->in_flags.all |= (IDE_HOB_STD_IN_FLAGS << 8); 653 699 } 654 700
+85 -50
drivers/ide/ide.c
··· 114 114 memset(drive, 0, sizeof(*drive)); 115 115 116 116 drive->media = ide_disk; 117 - drive->select.all = (unit<<4)|0xa0; 117 + drive->select = (unit << 4) | ATA_DEVICE_OBS; 118 118 drive->hwif = hwif; 119 119 drive->ready_stat = ATA_DRDY; 120 120 drive->bad_wstat = BAD_W_STAT; ··· 138 138 for (i = 0; i < MAX_DRIVES; i++) { 139 139 ide_drive_t *drive = &hwif->drives[i]; 140 140 141 - if (drive->present) { 141 + if (drive->dev_flags & IDE_DFLAG_PRESENT) { 142 142 spin_unlock_irq(&ide_lock); 143 143 device_unregister(&drive->gendev); 144 144 wait_for_completion(&drive->gendev_rel_comp); ··· 227 227 kfree(hwif->sg_table); 228 228 unregister_blkdev(hwif->major, hwif->name); 229 229 230 - if (hwif->dma_base) 231 - ide_release_dma_engine(hwif); 230 + ide_release_dma_engine(hwif); 232 231 233 232 mutex_unlock(&ide_cfg_mtx); 234 233 } ··· 253 254 254 255 static int set_io_32bit(ide_drive_t *drive, int arg) 255 256 { 256 - if (drive->no_io_32bit) 257 + if (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT) 257 258 return -EPERM; 258 259 259 260 if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1)) ··· 264 265 return 0; 265 266 } 266 267 267 - ide_devset_get(ksettings, keep_settings); 268 + ide_devset_get_flag(ksettings, IDE_DFLAG_KEEP_SETTINGS); 268 269 269 270 static int set_ksettings(ide_drive_t *drive, int arg) 270 271 { 271 272 if (arg < 0 || arg > 1) 272 273 return -EINVAL; 273 274 274 - drive->keep_settings = arg; 275 + if (arg) 276 + drive->dev_flags |= IDE_DFLAG_KEEP_SETTINGS; 277 + else 278 + drive->dev_flags &= ~IDE_DFLAG_KEEP_SETTINGS; 275 279 276 280 return 0; 277 281 } 278 282 279 - ide_devset_get(using_dma, using_dma); 283 + ide_devset_get_flag(using_dma, IDE_DFLAG_USING_DMA); 280 284 281 285 static int set_using_dma(ide_drive_t *drive, int arg) 282 286 { ··· 313 311 #endif 314 312 } 315 313 314 + /* 315 + * handle HDIO_SET_PIO_MODE ioctl abusers here, eventually it will go away 316 + */ 317 + static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio) 318 + { 319 + switch (req_pio) { 320 + case 202: 321 + case 201: 322 + case 200: 323 + case 102: 324 + case 101: 325 + case 100: 326 + return (hwif->host_flags & IDE_HFLAG_ABUSE_DMA_MODES) ? 1 : 0; 327 + case 9: 328 + case 8: 329 + return (hwif->host_flags & IDE_HFLAG_ABUSE_PREFETCH) ? 1 : 0; 330 + case 7: 331 + case 6: 332 + return (hwif->host_flags & IDE_HFLAG_ABUSE_FAST_DEVSEL) ? 1 : 0; 333 + default: 334 + return 0; 335 + } 336 + } 337 + 316 338 static int set_pio_mode(ide_drive_t *drive, int arg) 317 339 { 318 - struct request *rq; 319 340 ide_hwif_t *hwif = drive->hwif; 320 341 const struct ide_port_ops *port_ops = hwif->port_ops; 321 342 ··· 349 324 (hwif->host_flags & IDE_HFLAG_NO_SET_MODE)) 350 325 return -ENOSYS; 351 326 352 - if (drive->special.b.set_tune) 353 - return -EBUSY; 327 + if (set_pio_mode_abuse(drive->hwif, arg)) { 328 + if (arg == 8 || arg == 9) { 329 + unsigned long flags; 354 330 355 - rq = blk_get_request(drive->queue, READ, __GFP_WAIT); 356 - rq->cmd_type = REQ_TYPE_ATA_TASKFILE; 331 + /* take lock for IDE_DFLAG_[NO_]UNMASK/[NO_]IO_32BIT */ 332 + spin_lock_irqsave(&ide_lock, flags); 333 + port_ops->set_pio_mode(drive, arg); 334 + spin_unlock_irqrestore(&ide_lock, flags); 335 + } else 336 + port_ops->set_pio_mode(drive, arg); 337 + } else { 338 + int keep_dma = !!(drive->dev_flags & IDE_DFLAG_USING_DMA); 357 339 358 - drive->tune_req = (u8) arg; 359 - drive->special.b.set_tune = 1; 340 + ide_set_pio(drive, arg); 360 341 361 - blk_execute_rq(drive->queue, NULL, rq, 0); 362 - blk_put_request(rq); 342 + if (hwif->host_flags & IDE_HFLAG_SET_PIO_MODE_KEEP_DMA) { 343 + if (keep_dma) 344 + ide_dma_on(drive); 345 + } 346 + } 363 347 364 348 return 0; 365 349 } 366 350 367 - ide_devset_get(unmaskirq, unmask); 351 + ide_devset_get_flag(unmaskirq, IDE_DFLAG_UNMASK); 368 352 369 353 static int set_unmaskirq(ide_drive_t *drive, int arg) 370 354 { 371 - if (drive->no_unmask) 355 + if (drive->dev_flags & IDE_DFLAG_NO_UNMASK) 372 356 return -EPERM; 373 357 374 358 if (arg < 0 || arg > 1) 375 359 return -EINVAL; 376 360 377 - drive->unmask = arg; 361 + if (arg) 362 + drive->dev_flags |= IDE_DFLAG_UNMASK; 363 + else 364 + drive->dev_flags &= ~IDE_DFLAG_UNMASK; 378 365 379 366 return 0; 380 367 } 381 368 382 - #define ide_gen_devset_rw(_name, _func) \ 383 - __IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) 384 - 385 - ide_gen_devset_rw(io_32bit, io_32bit); 386 - ide_gen_devset_rw(keepsettings, ksettings); 387 - ide_gen_devset_rw(unmaskirq, unmaskirq); 388 - ide_gen_devset_rw(using_dma, using_dma); 389 - __IDE_DEVSET(pio_mode, 0, NULL, set_pio_mode); 369 + ide_ext_devset_rw_sync(io_32bit, io_32bit); 370 + ide_ext_devset_rw_sync(keepsettings, ksettings); 371 + ide_ext_devset_rw_sync(unmaskirq, unmaskirq); 372 + ide_ext_devset_rw_sync(using_dma, using_dma); 373 + __IDE_DEVSET(pio_mode, DS_SYNC, NULL, set_pio_mode); 390 374 391 375 static int generic_ide_suspend(struct device *dev, pm_message_t mesg) 392 376 { 393 - ide_drive_t *drive = dev->driver_data; 377 + ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive); 394 378 ide_hwif_t *hwif = HWIF(drive); 395 379 struct request *rq; 396 380 struct request_pm_state rqpm; 397 381 ide_task_t args; 398 382 int ret; 399 383 400 - /* Call ACPI _GTM only once */ 401 - if (!(drive->dn % 2)) 384 + /* call ACPI _GTM only once */ 385 + if ((drive->dn & 1) == 0 || pair == NULL) 402 386 ide_acpi_get_timing(hwif); 403 387 404 388 memset(&rqpm, 0, sizeof(rqpm)); ··· 416 382 rq->cmd_type = REQ_TYPE_PM_SUSPEND; 417 383 rq->special = &args; 418 384 rq->data = &rqpm; 419 - rqpm.pm_step = ide_pm_state_start_suspend; 385 + rqpm.pm_step = IDE_PM_START_SUSPEND; 420 386 if (mesg.event == PM_EVENT_PRETHAW) 421 387 mesg.event = PM_EVENT_FREEZE; 422 388 rqpm.pm_state = mesg.event; 423 389 424 390 ret = blk_execute_rq(drive->queue, NULL, rq, 0); 425 391 blk_put_request(rq); 426 - /* only call ACPI _PS3 after both drivers are suspended */ 427 - if (!ret && (((drive->dn % 2) && hwif->drives[0].present 428 - && hwif->drives[1].present) 429 - || !hwif->drives[0].present 430 - || !hwif->drives[1].present)) 392 + 393 + /* call ACPI _PS3 only after both devices are suspended */ 394 + if (ret == 0 && ((drive->dn & 1) || pair == NULL)) 431 395 ide_acpi_set_state(hwif, 0); 396 + 432 397 return ret; 433 398 } 434 399 435 400 static int generic_ide_resume(struct device *dev) 436 401 { 437 - ide_drive_t *drive = dev->driver_data; 402 + ide_drive_t *drive = dev->driver_data, *pair = ide_get_pair_dev(drive); 438 403 ide_hwif_t *hwif = HWIF(drive); 439 404 struct request *rq; 440 405 struct request_pm_state rqpm; 441 406 ide_task_t args; 442 407 int err; 443 408 444 - /* Call ACPI _STM only once */ 445 - if (!(drive->dn % 2)) { 409 + /* call ACPI _PS0 / _STM only once */ 410 + if ((drive->dn & 1) == 0 || pair == NULL) { 446 411 ide_acpi_set_state(hwif, 1); 447 412 ide_acpi_push_timing(hwif); 448 413 } ··· 455 422 rq->cmd_flags |= REQ_PREEMPT; 456 423 rq->special = &args; 457 424 rq->data = &rqpm; 458 - rqpm.pm_step = ide_pm_state_start_resume; 425 + rqpm.pm_step = IDE_PM_START_RESUME; 459 426 rqpm.pm_state = PM_EVENT_ON; 460 427 461 428 err = blk_execute_rq(drive->queue, NULL, rq, 1); ··· 587 554 __ATTR_RO(model), 588 555 __ATTR_RO(firmware), 589 556 __ATTR(serial, 0400, serial_show, NULL), 557 + __ATTR(unload_heads, 0644, ide_park_show, ide_park_store), 590 558 __ATTR_NULL 591 559 }; 592 560 ··· 742 708 module_param_call(chs, ide_set_disk_chs, NULL, NULL, 0); 743 709 MODULE_PARM_DESC(chs, "force device as a disk (using CHS)"); 744 710 745 - static void ide_dev_apply_params(ide_drive_t *drive) 711 + static void ide_dev_apply_params(ide_drive_t *drive, u8 unit) 746 712 { 747 - int i = drive->hwif->index * MAX_DRIVES + drive->select.b.unit; 713 + int i = drive->hwif->index * MAX_DRIVES + unit; 748 714 749 715 if (ide_nodma & (1 << i)) { 750 716 printk(KERN_INFO "ide: disallowing DMA for %s\n", drive->name); 751 - drive->nodma = 1; 717 + drive->dev_flags |= IDE_DFLAG_NODMA; 752 718 } 753 719 if (ide_noflush & (1 << i)) { 754 720 printk(KERN_INFO "ide: disabling flush requests for %s\n", 755 721 drive->name); 756 - drive->noflush = 1; 722 + drive->dev_flags |= IDE_DFLAG_NOFLUSH; 757 723 } 758 724 if (ide_noprobe & (1 << i)) { 759 725 printk(KERN_INFO "ide: skipping probe for %s\n", drive->name); 760 - drive->noprobe = 1; 726 + drive->dev_flags |= IDE_DFLAG_NOPROBE; 761 727 } 762 728 if (ide_nowerr & (1 << i)) { 763 729 printk(KERN_INFO "ide: ignoring the ATA_DF bit for %s\n", ··· 766 732 } 767 733 if (ide_cdroms & (1 << i)) { 768 734 printk(KERN_INFO "ide: forcing %s as a CD-ROM\n", drive->name); 769 - drive->present = 1; 735 + drive->dev_flags |= IDE_DFLAG_PRESENT; 770 736 drive->media = ide_cdrom; 771 737 /* an ATAPI device ignores DRDY */ 772 738 drive->ready_stat = 0; ··· 775 741 drive->cyl = drive->bios_cyl = ide_disks_chs[i].cyl; 776 742 drive->head = drive->bios_head = ide_disks_chs[i].head; 777 743 drive->sect = drive->bios_sect = ide_disks_chs[i].sect; 778 - drive->forced_geom = 1; 744 + 779 745 printk(KERN_INFO "ide: forcing %s as a disk (%d/%d/%d)\n", 780 746 drive->name, 781 747 drive->cyl, drive->head, drive->sect); 782 - drive->present = 1; 748 + 749 + drive->dev_flags |= IDE_DFLAG_FORCED_GEOM | IDE_DFLAG_PRESENT; 783 750 drive->media = ide_disk; 784 751 drive->ready_stat = ATA_DRDY; 785 752 } ··· 820 785 } 821 786 822 787 for (i = 0; i < MAX_DRIVES; i++) 823 - ide_dev_apply_params(&hwif->drives[i]); 788 + ide_dev_apply_params(&hwif->drives[i], i); 824 789 } 825 790 826 791 /*
+1 -1
drivers/ide/legacy/ali14xx.c
··· 131 131 drive->name, pio, time1, time2, param1, param2, param3, param4); 132 132 133 133 /* stuff timing parameters into controller registers */ 134 - driveNum = (HWIF(drive)->index << 1) + drive->select.b.unit; 134 + driveNum = (drive->hwif->index << 1) + (drive->dn & 1); 135 135 spin_lock_irqsave(&ali14xx_lock, flags); 136 136 outb_p(regOn, basePort); 137 137 outReg(param1, regTab[driveNum].reg1);
+5 -4
drivers/ide/legacy/ht6560b.c
··· 120 120 * Need to enforce prefetch sometimes because otherwise 121 121 * it'll hang (hard). 122 122 */ 123 - if (drive->media != ide_disk || !drive->present) 123 + if (drive->media != ide_disk || 124 + (drive->dev_flags & IDE_DFLAG_PRESENT) == 0) 124 125 select |= HT_PREFETCH_MODE; 125 126 126 127 if (select != current_select || timing != current_timing) { ··· 250 249 */ 251 250 if (state) { 252 251 drive->drive_data |= t; /* enable prefetch mode */ 253 - drive->no_unmask = 1; 254 - drive->unmask = 0; 252 + drive->dev_flags |= IDE_DFLAG_NO_UNMASK; 253 + drive->dev_flags &= ~IDE_DFLAG_UNMASK; 255 254 } else { 256 255 drive->drive_data &= ~t; /* disable prefetch mode */ 257 - drive->no_unmask = 0; 256 + drive->dev_flags &= ~IDE_DFLAG_NO_UNMASK; 258 257 } 259 258 260 259 spin_unlock_irqrestore(&ht6560b_lock, flags);
+1 -1
drivers/ide/legacy/ide-4drives.c
··· 14 14 static void ide_4drives_init_dev(ide_drive_t *drive) 15 15 { 16 16 if (drive->hwif->channel) 17 - drive->select.all ^= 0x20; 17 + drive->select ^= 0x20; 18 18 } 19 19 20 20 static const struct ide_port_ops ide_4drives_port_ops = {
+1 -1
drivers/ide/legacy/qd65xx.c
··· 305 305 } else 306 306 t2 = t1 = hwif->channel ? QD6580_DEF_DATA2 : QD6580_DEF_DATA; 307 307 308 - drive->drive_data = drive->select.b.unit ? t2 : t1; 308 + drive->drive_data = (drive->dn & 1) ? t2 : t1; 309 309 } 310 310 311 311 static const struct ide_port_ops qd6500_port_ops = {
+6 -28
drivers/ide/mips/au1xxx-ide.c
··· 322 322 } 323 323 324 324 static int auide_dma_test_irq(ide_drive_t *drive) 325 - { 326 - if (drive->waiting_for_dma == 0) 327 - printk(KERN_WARNING "%s: ide_dma_test_irq \ 328 - called while not waiting\n", drive->name); 329 - 325 + { 330 326 /* If dbdma didn't execute the STOP command yet, the 331 327 * active bit is still set 332 328 */ ··· 338 342 339 343 static void auide_dma_host_set(ide_drive_t *drive, int on) 340 344 { 341 - } 342 - 343 - static void auide_dma_lost_irq(ide_drive_t *drive) 344 - { 345 - printk(KERN_ERR "%s: IRQ lost\n", drive->name); 346 345 } 347 346 348 347 static void auide_ddma_tx_callback(int irq, void *param) ··· 366 375 } 367 376 368 377 #ifdef CONFIG_BLK_DEV_IDE_AU1XXX_MDMA2_DBDMA 369 - static void auide_dma_timeout(ide_drive_t *drive) 370 - { 371 - ide_hwif_t *hwif = HWIF(drive); 372 - 373 - printk(KERN_ERR "%s: DMA timeout occurred: ", drive->name); 374 - 375 - if (auide_dma_test_irq(drive)) 376 - return; 377 - 378 - auide_dma_end(drive); 379 - } 380 - 381 378 static const struct ide_dma_ops au1xxx_dma_ops = { 382 379 .dma_host_set = auide_dma_host_set, 383 380 .dma_setup = auide_dma_setup, ··· 373 394 .dma_start = auide_dma_start, 374 395 .dma_end = auide_dma_end, 375 396 .dma_test_irq = auide_dma_test_irq, 376 - .dma_lost_irq = auide_dma_lost_irq, 377 - .dma_timeout = auide_dma_timeout, 397 + .dma_lost_irq = ide_dma_lost_irq, 398 + .dma_timeout = ide_dma_timeout, 378 399 }; 379 400 380 401 static int auide_ddma_init(ide_hwif_t *hwif, const struct ide_port_info *d) ··· 427 448 NUM_DESCRIPTORS); 428 449 auide->rx_desc_head = (void*)au1xxx_dbdma_ring_alloc(auide->rx_chan, 429 450 NUM_DESCRIPTORS); 430 - 431 - hwif->dmatable_cpu = dma_alloc_coherent(hwif->dev, 432 - PRD_ENTRIES * PRD_BYTES, /* 1 Page */ 433 - &hwif->dmatable_dma, GFP_KERNEL); 451 + 452 + /* FIXME: check return value */ 453 + (void)ide_allocate_dma_engine(hwif); 434 454 435 455 au1xxx_dbdma_start( auide->tx_chan ); 436 456 au1xxx_dbdma_start( auide->rx_chan );
+4 -4
drivers/ide/pci/aec62xx.c
··· 115 115 struct pci_dev *dev = to_pci_dev(hwif->dev); 116 116 struct ide_host *host = pci_get_drvdata(dev); 117 117 struct chipset_bus_clock_list_entry *bus_clock = host->host_priv; 118 - u8 unit = (drive->select.b.unit & 0x01); 118 + u8 unit = drive->dn & 1; 119 119 u8 tmp1 = 0, tmp2 = 0; 120 120 u8 ultra = 0, drive_conf = 0, ultra_conf = 0; 121 121 unsigned long flags; ··· 302 302 }; 303 303 MODULE_DEVICE_TABLE(pci, aec62xx_pci_tbl); 304 304 305 - static struct pci_driver driver = { 305 + static struct pci_driver aec62xx_pci_driver = { 306 306 .name = "AEC62xx_IDE", 307 307 .id_table = aec62xx_pci_tbl, 308 308 .probe = aec62xx_init_one, ··· 313 313 314 314 static int __init aec62xx_ide_init(void) 315 315 { 316 - return ide_pci_register_driver(&driver); 316 + return ide_pci_register_driver(&aec62xx_pci_driver); 317 317 } 318 318 319 319 static void __exit aec62xx_ide_exit(void) 320 320 { 321 - pci_unregister_driver(&driver); 321 + pci_unregister_driver(&aec62xx_pci_driver); 322 322 } 323 323 324 324 module_init(aec62xx_ide_init);
+7 -8
drivers/ide/pci/alim15x3.c
··· 77 77 int bus_speed = ide_pci_clk ? ide_pci_clk : 33; 78 78 int port = hwif->channel ? 0x5c : 0x58; 79 79 int portFIFO = hwif->channel ? 0x55 : 0x54; 80 - u8 cd_dma_fifo = 0; 81 - int unit = drive->select.b.unit & 1; 80 + u8 cd_dma_fifo = 0, unit = drive->dn & 1; 82 81 83 82 if ((s_clc = (s_time * bus_speed + 999) / 1000) >= 8) 84 83 s_clc = 0; ··· 111 112 } 112 113 113 114 pci_write_config_byte(dev, port, s_clc); 114 - pci_write_config_byte(dev, port+drive->select.b.unit+2, (a_clc << 4) | r_clc); 115 + pci_write_config_byte(dev, port + unit + 2, (a_clc << 4) | r_clc); 115 116 local_irq_restore(flags); 116 117 } 117 118 ··· 153 154 ide_hwif_t *hwif = HWIF(drive); 154 155 struct pci_dev *dev = to_pci_dev(hwif->dev); 155 156 u8 speed1 = speed; 156 - u8 unit = (drive->select.b.unit & 0x01); 157 + u8 unit = drive->dn & 1; 157 158 u8 tmpbyte = 0x00; 158 159 int m5229_udma = (hwif->channel) ? 0x57 : 0x56; 159 160 ··· 507 508 .dma_setup = ali15x3_dma_setup, 508 509 .dma_exec_cmd = ide_dma_exec_cmd, 509 510 .dma_start = ide_dma_start, 510 - .dma_end = __ide_dma_end, 511 + .dma_end = ide_dma_end, 511 512 .dma_test_irq = ide_dma_test_irq, 512 513 .dma_lost_irq = ide_dma_lost_irq, 513 514 .dma_timeout = ide_dma_timeout, ··· 575 576 }; 576 577 MODULE_DEVICE_TABLE(pci, alim15x3_pci_tbl); 577 578 578 - static struct pci_driver driver = { 579 + static struct pci_driver alim15x3_pci_driver = { 579 580 .name = "ALI15x3_IDE", 580 581 .id_table = alim15x3_pci_tbl, 581 582 .probe = alim15x3_init_one, ··· 586 587 587 588 static int __init ali15x3_ide_init(void) 588 589 { 589 - return ide_pci_register_driver(&driver); 590 + return ide_pci_register_driver(&alim15x3_pci_driver); 590 591 } 591 592 592 593 static void __exit ali15x3_ide_exit(void) 593 594 { 594 - return pci_unregister_driver(&driver); 595 + return pci_unregister_driver(&alim15x3_pci_driver); 595 596 } 596 597 597 598 module_init(ali15x3_ide_init);
+4 -4
drivers/ide/pci/amd74xx.c
··· 92 92 93 93 ide_timing_compute(drive, speed, &t, T, UT); 94 94 95 - if (peer->present) { 95 + if (peer->dev_flags & IDE_DFLAG_PRESENT) { 96 96 ide_timing_compute(peer, peer->current_speed, &p, T, UT); 97 97 ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); 98 98 } ··· 319 319 }; 320 320 MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 321 321 322 - static struct pci_driver driver = { 322 + static struct pci_driver amd74xx_pci_driver = { 323 323 .name = "AMD_IDE", 324 324 .id_table = amd74xx_pci_tbl, 325 325 .probe = amd74xx_probe, ··· 330 330 331 331 static int __init amd74xx_ide_init(void) 332 332 { 333 - return ide_pci_register_driver(&driver); 333 + return ide_pci_register_driver(&amd74xx_pci_driver); 334 334 } 335 335 336 336 static void __exit amd74xx_ide_exit(void) 337 337 { 338 - pci_unregister_driver(&driver); 338 + pci_unregister_driver(&amd74xx_pci_driver); 339 339 } 340 340 341 341 module_init(amd74xx_ide_init);
+3 -3
drivers/ide/pci/atiixp.c
··· 182 182 }; 183 183 MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl); 184 184 185 - static struct pci_driver driver = { 185 + static struct pci_driver atiixp_pci_driver = { 186 186 .name = "ATIIXP_IDE", 187 187 .id_table = atiixp_pci_tbl, 188 188 .probe = atiixp_init_one, ··· 193 193 194 194 static int __init atiixp_ide_init(void) 195 195 { 196 - return ide_pci_register_driver(&driver); 196 + return ide_pci_register_driver(&atiixp_pci_driver); 197 197 } 198 198 199 199 static void __exit atiixp_ide_exit(void) 200 200 { 201 - pci_unregister_driver(&driver); 201 + pci_unregister_driver(&atiixp_pci_driver); 202 202 } 203 203 204 204 module_init(atiixp_ide_init);
+9 -9
drivers/ide/pci/cmd640.c
··· 378 378 { 379 379 if (mode) { /* want prefetch on? */ 380 380 #if CMD640_PREFETCH_MASKS 381 - drive->no_unmask = 1; 382 - drive->unmask = 0; 381 + drive->dev_flags |= IDE_DFLAG_NO_UNMASK; 382 + drive->dev_flags &= ~IDE_DFLAG_UNMASK; 383 383 #endif 384 - drive->no_io_32bit = 0; 384 + drive->dev_flags &= ~IDE_DFLAG_NO_IO_32BIT; 385 385 } else { 386 - drive->no_unmask = 0; 387 - drive->no_io_32bit = 1; 386 + drive->dev_flags &= ~IDE_DFLAG_NO_UNMASK; 387 + drive->dev_flags |= IDE_DFLAG_NO_IO_32BIT; 388 388 drive->io_32bit = 0; 389 389 } 390 390 } ··· 468 468 */ 469 469 if (index > 1) { 470 470 ide_hwif_t *hwif = drive->hwif; 471 - ide_drive_t *peer = &hwif->drives[!drive->select.b.unit]; 471 + ide_drive_t *peer = &hwif->drives[!(drive->dn & 1)]; 472 472 unsigned int mate = index ^ 1; 473 473 474 - if (peer->present) { 474 + if (peer->dev_flags & IDE_DFLAG_PRESENT) { 475 475 if (setup_count < setup_counts[mate]) 476 476 setup_count = setup_counts[mate]; 477 477 if (active_count < active_counts[mate]) ··· 607 607 608 608 static void cmd640_init_dev(ide_drive_t *drive) 609 609 { 610 - unsigned int i = drive->hwif->channel * 2 + drive->select.b.unit; 610 + unsigned int i = drive->hwif->channel * 2 + (drive->dn & 1); 611 611 612 612 #ifdef CONFIG_BLK_DEV_CMD640_ENHANCED 613 613 /* ··· 626 626 */ 627 627 check_prefetch(drive, i); 628 628 printk(KERN_INFO DRV_NAME ": drive%d timings/prefetch(%s) preserved\n", 629 - i, drive->no_io_32bit ? "off" : "on"); 629 + i, (drive->dev_flags & IDE_DFLAG_NO_IO_32BIT) ? "off" : "on"); 630 630 #endif /* CONFIG_BLK_DEV_CMD640_ENHANCED */ 631 631 } 632 632
+5 -5
drivers/ide/pci/cmd64x.c
··· 228 228 { 229 229 ide_hwif_t *hwif = HWIF(drive); 230 230 unsigned long base = hwif->dma_base - (hwif->channel * 8); 231 - int err = __ide_dma_end(drive); 231 + int err = ide_dma_end(drive); 232 232 u8 irq_mask = hwif->channel ? MRDMODE_INTR_CH1 : 233 233 MRDMODE_INTR_CH0; 234 234 u8 mrdmode = inb(base + 1); ··· 248 248 u8 irq_mask = hwif->channel ? ARTTIM23_INTR_CH1 : 249 249 CFR_INTR_CH0; 250 250 u8 irq_stat = 0; 251 - int err = __ide_dma_end(drive); 251 + int err = ide_dma_end(drive); 252 252 253 253 (void) pci_read_config_byte(dev, irq_reg, &irq_stat); 254 254 /* clear the interrupt bit */ ··· 505 505 }; 506 506 MODULE_DEVICE_TABLE(pci, cmd64x_pci_tbl); 507 507 508 - static struct pci_driver driver = { 508 + static struct pci_driver cmd64x_pci_driver = { 509 509 .name = "CMD64x_IDE", 510 510 .id_table = cmd64x_pci_tbl, 511 511 .probe = cmd64x_init_one, ··· 516 516 517 517 static int __init cmd64x_ide_init(void) 518 518 { 519 - return ide_pci_register_driver(&driver); 519 + return ide_pci_register_driver(&cmd64x_pci_driver); 520 520 } 521 521 522 522 static void __exit cmd64x_ide_exit(void) 523 523 { 524 - pci_unregister_driver(&driver); 524 + pci_unregister_driver(&cmd64x_pci_driver); 525 525 } 526 526 527 527 module_init(cmd64x_ide_init);
+2 -2
drivers/ide/pci/cs5520.c
··· 145 145 }; 146 146 MODULE_DEVICE_TABLE(pci, cs5520_pci_tbl); 147 147 148 - static struct pci_driver driver = { 148 + static struct pci_driver cs5520_pci_driver = { 149 149 .name = "Cyrix_IDE", 150 150 .id_table = cs5520_pci_tbl, 151 151 .probe = cs5520_init_one, ··· 155 155 156 156 static int __init cs5520_ide_init(void) 157 157 { 158 - return ide_pci_register_driver(&driver); 158 + return ide_pci_register_driver(&cs5520_pci_driver); 159 159 } 160 160 161 161 module_init(cs5520_ide_init);
+3 -3
drivers/ide/pci/cs5530.c
··· 267 267 }; 268 268 MODULE_DEVICE_TABLE(pci, cs5530_pci_tbl); 269 269 270 - static struct pci_driver driver = { 270 + static struct pci_driver cs5530_pci_driver = { 271 271 .name = "CS5530 IDE", 272 272 .id_table = cs5530_pci_tbl, 273 273 .probe = cs5530_init_one, ··· 278 278 279 279 static int __init cs5530_ide_init(void) 280 280 { 281 - return ide_pci_register_driver(&driver); 281 + return ide_pci_register_driver(&cs5530_pci_driver); 282 282 } 283 283 284 284 static void __exit cs5530_ide_exit(void) 285 285 { 286 - pci_unregister_driver(&driver); 286 + pci_unregister_driver(&cs5530_pci_driver); 287 287 } 288 288 289 289 module_init(cs5530_ide_init);
+4 -4
drivers/ide/pci/cs5535.c
··· 76 76 static void cs5535_set_speed(ide_drive_t *drive, const u8 speed) 77 77 { 78 78 u32 reg = 0, dummy; 79 - int unit = drive->select.b.unit; 79 + u8 unit = drive->dn & 1; 80 80 81 81 /* Set the PIO timings */ 82 82 if (speed < XFER_SW_DMA_0) { ··· 192 192 193 193 MODULE_DEVICE_TABLE(pci, cs5535_pci_tbl); 194 194 195 - static struct pci_driver driver = { 195 + static struct pci_driver cs5535_pci_driver = { 196 196 .name = "CS5535_IDE", 197 197 .id_table = cs5535_pci_tbl, 198 198 .probe = cs5535_init_one, ··· 203 203 204 204 static int __init cs5535_ide_init(void) 205 205 { 206 - return ide_pci_register_driver(&driver); 206 + return ide_pci_register_driver(&cs5535_pci_driver); 207 207 } 208 208 209 209 static void __exit cs5535_ide_exit(void) 210 210 { 211 - pci_unregister_driver(&driver); 211 + pci_unregister_driver(&cs5535_pci_driver); 212 212 } 213 213 214 214 module_init(cs5535_ide_init);
+6 -118
drivers/ide/pci/cy82c693.c
··· 50 50 51 51 #define DRV_NAME "cy82c693" 52 52 53 - /* the current version */ 54 - #define CY82_VERSION "CY82C693U driver v0.34 99-13-12 Andreas S. Krebs (akrebs@altavista.net)" 55 - 56 53 /* 57 54 * The following are used to debug the driver. 58 55 */ 59 - #define CY82C693_DEBUG_LOGS 0 60 56 #define CY82C693_DEBUG_INFO 0 61 - 62 - /* define CY82C693_SETDMA_CLOCK to set DMA Controller Clock Speed to ATCLK */ 63 - #undef CY82C693_SETDMA_CLOCK 64 57 65 58 /* 66 59 * NOTE: the value for busmaster timeout is tricky and I got it by ··· 82 89 #define CY82_INDEX_PORT 0x22 83 90 #define CY82_DATA_PORT 0x23 84 91 85 - #define CY82_INDEX_CTRLREG1 0x01 86 92 #define CY82_INDEX_CHANNEL0 0x30 87 93 #define CY82_INDEX_CHANNEL1 0x31 88 94 #define CY82_INDEX_TIMEOUT 0x32 ··· 171 179 172 180 index = hwif->channel ? CY82_INDEX_CHANNEL1 : CY82_INDEX_CHANNEL0; 173 181 174 - #if CY82C693_DEBUG_LOGS 175 - /* for debug let's show the previous values */ 176 - 177 - outb(index, CY82_INDEX_PORT); 178 - data = inb(CY82_DATA_PORT); 179 - 180 - printk(KERN_INFO "%s (ch=%d, dev=%d): DMA mode is %d (single=%d)\n", 181 - drive->name, HWIF(drive)->channel, drive->select.b.unit, 182 - (data&0x3), ((data>>2)&1)); 183 - #endif /* CY82C693_DEBUG_LOGS */ 184 - 185 182 data = (mode & 3) | (single << 2); 186 183 187 184 outb(index, CY82_INDEX_PORT); ··· 178 197 179 198 #if CY82C693_DEBUG_INFO 180 199 printk(KERN_INFO "%s (ch=%d, dev=%d): set DMA mode to %d (single=%d)\n", 181 - drive->name, HWIF(drive)->channel, drive->select.b.unit, 182 - mode & 3, single); 200 + drive->name, hwif->channel, drive->dn & 1, mode & 3, single); 183 201 #endif /* CY82C693_DEBUG_INFO */ 184 202 185 203 /* ··· 219 239 } 220 240 } 221 241 222 - #if CY82C693_DEBUG_LOGS 223 - /* for debug let's show the register values */ 224 - 225 - if (drive->select.b.unit == 0) { 226 - /* 227 - * get master drive registers 228 - * address setup control register 229 - * is 32 bit !!! 230 - */ 231 - pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); 232 - addrCtrl &= 0x0F; 233 - 234 - /* now let's get the remaining registers */ 235 - pci_read_config_byte(dev, CY82_IDE_MASTER_IOR, &pclk.time_16r); 236 - pci_read_config_byte(dev, CY82_IDE_MASTER_IOW, &pclk.time_16w); 237 - pci_read_config_byte(dev, CY82_IDE_MASTER_8BIT, &pclk.time_8); 238 - } else { 239 - /* 240 - * set slave drive registers 241 - * address setup control register 242 - * is 32 bit !!! 243 - */ 244 - pci_read_config_dword(dev, CY82_IDE_ADDRSETUP, &addrCtrl); 245 - 246 - addrCtrl &= 0xF0; 247 - addrCtrl >>= 4; 248 - 249 - /* now let's get the remaining registers */ 250 - pci_read_config_byte(dev, CY82_IDE_SLAVE_IOR, &pclk.time_16r); 251 - pci_read_config_byte(dev, CY82_IDE_SLAVE_IOW, &pclk.time_16w); 252 - pci_read_config_byte(dev, CY82_IDE_SLAVE_8BIT, &pclk.time_8); 253 - } 254 - 255 - printk(KERN_INFO "%s (ch=%d, dev=%d): PIO timing is " 256 - "(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n", 257 - drive->name, hwif->channel, drive->select.b.unit, 258 - addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8); 259 - #endif /* CY82C693_DEBUG_LOGS */ 260 - 261 242 /* let's calc the values for this PIO mode */ 262 243 compute_clocks(pio, &pclk); 263 244 264 245 /* now let's write the clocks registers */ 265 - if (drive->select.b.unit == 0) { 246 + if ((drive->dn & 1) == 0) { 266 247 /* 267 248 * set master drive 268 249 * address setup control register ··· 265 324 #if CY82C693_DEBUG_INFO 266 325 printk(KERN_INFO "%s (ch=%d, dev=%d): set PIO timing to " 267 326 "(addr=0x%X, ior=0x%X, iow=0x%X, 8bit=0x%X)\n", 268 - drive->name, hwif->channel, drive->select.b.unit, 327 + drive->name, hwif->channel, drive->dn & 1, 269 328 addrCtrl, pclk.time_16r, pclk.time_16w, pclk.time_8); 270 329 #endif /* CY82C693_DEBUG_INFO */ 271 - } 272 - 273 - /* 274 - * this function is called during init and is used to setup the cy82c693 chip 275 - */ 276 - static unsigned int init_chipset_cy82c693(struct pci_dev *dev) 277 - { 278 - if (PCI_FUNC(dev->devfn) != 1) 279 - return 0; 280 - 281 - #ifdef CY82C693_SETDMA_CLOCK 282 - u8 data = 0; 283 - #endif /* CY82C693_SETDMA_CLOCK */ 284 - 285 - /* write info about this verion of the driver */ 286 - printk(KERN_INFO CY82_VERSION "\n"); 287 - 288 - #ifdef CY82C693_SETDMA_CLOCK 289 - /* okay let's set the DMA clock speed */ 290 - 291 - outb(CY82_INDEX_CTRLREG1, CY82_INDEX_PORT); 292 - data = inb(CY82_DATA_PORT); 293 - 294 - #if CY82C693_DEBUG_INFO 295 - printk(KERN_INFO DRV_NAME ": Peripheral Configuration Register: 0x%X\n", 296 - data); 297 - #endif /* CY82C693_DEBUG_INFO */ 298 - 299 - /* 300 - * for some reason sometimes the DMA controller 301 - * speed is set to ATCLK/2 ???? - we fix this here 302 - * 303 - * note: i don't know what causes this strange behaviour, 304 - * but even changing the dma speed doesn't solve it :-( 305 - * the ide performance is still only half the normal speed 306 - * 307 - * if anybody knows what goes wrong with my machine, please 308 - * let me know - ASK 309 - */ 310 - 311 - data |= 0x03; 312 - 313 - outb(CY82_INDEX_CTRLREG1, CY82_INDEX_PORT); 314 - outb(data, CY82_DATA_PORT); 315 - 316 - #if CY82C693_DEBUG_INFO 317 - printk(KERN_INFO ": New Peripheral Configuration Register: 0x%X\n", 318 - data); 319 - #endif /* CY82C693_DEBUG_INFO */ 320 - 321 - #endif /* CY82C693_SETDMA_CLOCK */ 322 - return 0; 323 330 } 324 331 325 332 static void __devinit init_iops_cy82c693(ide_hwif_t *hwif) ··· 290 401 291 402 static const struct ide_port_info cy82c693_chipset __devinitdata = { 292 403 .name = DRV_NAME, 293 - .init_chipset = init_chipset_cy82c693, 294 404 .init_iops = init_iops_cy82c693, 295 405 .port_ops = &cy82c693_port_ops, 296 406 .chipset = ide_cy82c693, ··· 331 443 }; 332 444 MODULE_DEVICE_TABLE(pci, cy82c693_pci_tbl); 333 445 334 - static struct pci_driver driver = { 446 + static struct pci_driver cy82c693_pci_driver = { 335 447 .name = "Cypress_IDE", 336 448 .id_table = cy82c693_pci_tbl, 337 449 .probe = cy82c693_init_one, ··· 342 454 343 455 static int __init cy82c693_ide_init(void) 344 456 { 345 - return ide_pci_register_driver(&driver); 457 + return ide_pci_register_driver(&cy82c693_pci_driver); 346 458 } 347 459 348 460 static void __exit cy82c693_ide_exit(void) 349 461 { 350 - pci_unregister_driver(&driver); 462 + pci_unregister_driver(&cy82c693_pci_driver); 351 463 } 352 464 353 465 module_init(cy82c693_ide_init);
+3 -3
drivers/ide/pci/delkin_cb.c
··· 117 117 }; 118 118 MODULE_DEVICE_TABLE(pci, delkin_cb_pci_tbl); 119 119 120 - static struct pci_driver driver = { 120 + static struct pci_driver delkin_cb_pci_driver = { 121 121 .name = "Delkin-ASKA-Workbit Cardbus IDE", 122 122 .id_table = delkin_cb_pci_tbl, 123 123 .probe = delkin_cb_probe, ··· 126 126 127 127 static int __init delkin_cb_init(void) 128 128 { 129 - return pci_register_driver(&driver); 129 + return pci_register_driver(&delkin_cb_pci_driver); 130 130 } 131 131 132 132 static void __exit delkin_cb_exit(void) 133 133 { 134 - pci_unregister_driver(&driver); 134 + pci_unregister_driver(&delkin_cb_pci_driver); 135 135 } 136 136 137 137 module_init(delkin_cb_init);
+3 -3
drivers/ide/pci/generic.c
··· 166 166 }; 167 167 MODULE_DEVICE_TABLE(pci, generic_pci_tbl); 168 168 169 - static struct pci_driver driver = { 169 + static struct pci_driver generic_pci_driver = { 170 170 .name = "PCI_IDE", 171 171 .id_table = generic_pci_tbl, 172 172 .probe = generic_init_one, ··· 177 177 178 178 static int __init generic_ide_init(void) 179 179 { 180 - return ide_pci_register_driver(&driver); 180 + return ide_pci_register_driver(&generic_pci_driver); 181 181 } 182 182 183 183 static void __exit generic_ide_exit(void) 184 184 { 185 - pci_unregister_driver(&driver); 185 + pci_unregister_driver(&generic_pci_driver); 186 186 } 187 187 188 188 module_init(generic_ide_init);
+3 -3
drivers/ide/pci/hpt34x.c
··· 166 166 }; 167 167 MODULE_DEVICE_TABLE(pci, hpt34x_pci_tbl); 168 168 169 - static struct pci_driver driver = { 169 + static struct pci_driver hpt34x_pci_driver = { 170 170 .name = "HPT34x_IDE", 171 171 .id_table = hpt34x_pci_tbl, 172 172 .probe = hpt34x_init_one, ··· 177 177 178 178 static int __init hpt34x_ide_init(void) 179 179 { 180 - return ide_pci_register_driver(&driver); 180 + return ide_pci_register_driver(&hpt34x_pci_driver); 181 181 } 182 182 183 183 static void __exit hpt34x_ide_exit(void) 184 184 { 185 - pci_unregister_driver(&driver); 185 + pci_unregister_driver(&hpt34x_pci_driver); 186 186 } 187 187 188 188 module_init(hpt34x_ide_init);
+6 -9
drivers/ide/pci/hpt366.c
··· 835 835 if (dma_stat & 0x01) 836 836 hpt370_irq_timeout(drive); 837 837 } 838 - return __ide_dma_end(drive); 838 + return ide_dma_end(drive); 839 839 } 840 840 841 841 static void hpt370_dma_timeout(ide_drive_t *drive) ··· 863 863 if (dma_stat & 4) 864 864 return 1; 865 865 866 - if (!drive->waiting_for_dma) 867 - printk(KERN_WARNING "%s: (%s) called while not waiting\n", 868 - drive->name, __func__); 869 866 return 0; 870 867 } 871 868 ··· 877 880 pci_read_config_byte(dev, mcr_addr, &mcr); 878 881 if (bwsr & mask) 879 882 pci_write_config_byte(dev, mcr_addr, mcr | 0x30); 880 - return __ide_dma_end(drive); 883 + return ide_dma_end(drive); 881 884 } 882 885 883 886 /** ··· 1453 1456 .dma_setup = ide_dma_setup, 1454 1457 .dma_exec_cmd = ide_dma_exec_cmd, 1455 1458 .dma_start = ide_dma_start, 1456 - .dma_end = __ide_dma_end, 1459 + .dma_end = ide_dma_end, 1457 1460 .dma_test_irq = ide_dma_test_irq, 1458 1461 .dma_lost_irq = hpt366_dma_lost_irq, 1459 1462 .dma_timeout = ide_dma_timeout, ··· 1619 1622 }; 1620 1623 MODULE_DEVICE_TABLE(pci, hpt366_pci_tbl); 1621 1624 1622 - static struct pci_driver driver = { 1625 + static struct pci_driver hpt366_pci_driver = { 1623 1626 .name = "HPT366_IDE", 1624 1627 .id_table = hpt366_pci_tbl, 1625 1628 .probe = hpt366_init_one, ··· 1630 1633 1631 1634 static int __init hpt366_ide_init(void) 1632 1635 { 1633 - return ide_pci_register_driver(&driver); 1636 + return ide_pci_register_driver(&hpt366_pci_driver); 1634 1637 } 1635 1638 1636 1639 static void __exit hpt366_ide_exit(void) 1637 1640 { 1638 - pci_unregister_driver(&driver); 1641 + pci_unregister_driver(&hpt366_pci_driver); 1639 1642 } 1640 1643 1641 1644 module_init(hpt366_ide_init);
+3 -3
drivers/ide/pci/it8213.c
··· 189 189 190 190 MODULE_DEVICE_TABLE(pci, it8213_pci_tbl); 191 191 192 - static struct pci_driver driver = { 192 + static struct pci_driver it8213_pci_driver = { 193 193 .name = "ITE8213_IDE", 194 194 .id_table = it8213_pci_tbl, 195 195 .probe = it8213_init_one, ··· 200 200 201 201 static int __init it8213_ide_init(void) 202 202 { 203 - return ide_pci_register_driver(&driver); 203 + return ide_pci_register_driver(&it8213_pci_driver); 204 204 } 205 205 206 206 static void __exit it8213_ide_exit(void) 207 207 { 208 - pci_unregister_driver(&driver); 208 + pci_unregister_driver(&it8213_pci_driver); 209 209 } 210 210 211 211 module_init(it8213_ide_init);
+21 -25
drivers/ide/pci/it821x.c
··· 138 138 struct pci_dev *dev = to_pci_dev(hwif->dev); 139 139 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 140 140 int channel = hwif->channel; 141 - int unit = drive->select.b.unit; 142 - u8 conf; 141 + u8 unit = drive->dn & 1, conf; 143 142 144 143 /* Program UDMA timing bits */ 145 144 if(itdev->clock_mode == ATA_66) ··· 167 168 ide_hwif_t *hwif = drive->hwif; 168 169 struct pci_dev *dev = to_pci_dev(hwif->dev); 169 170 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 171 + ide_drive_t *pair; 172 + int clock, altclock, sel = 0; 173 + u8 unit = drive->dn & 1, v; 170 174 171 - u8 unit = drive->select.b.unit; 172 - ide_drive_t *pair = &hwif->drives[1-unit]; 173 - 174 - int clock, altclock; 175 - u8 v; 176 - int sel = 0; 175 + pair = &hwif->drives[1 - unit]; 177 176 178 177 if(itdev->want[0][0] > itdev->want[1][0]) { 179 178 clock = itdev->want[0][1]; ··· 237 240 238 241 static void it821x_set_pio_mode(ide_drive_t *drive, const u8 pio) 239 242 { 240 - ide_hwif_t *hwif = drive->hwif; 243 + ide_hwif_t *hwif = drive->hwif; 241 244 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 242 - int unit = drive->select.b.unit; 243 - ide_drive_t *pair = &hwif->drives[1 - unit]; 244 - u8 set_pio = pio; 245 + ide_drive_t *pair; 246 + u8 unit = drive->dn & 1, set_pio = pio; 245 247 246 248 /* Spec says 89 ref driver uses 88 */ 247 249 static u16 pio_timings[]= { 0xAA88, 0xA382, 0xA181, 0x3332, 0x3121 }; 248 250 static u8 pio_want[] = { ATA_66, ATA_66, ATA_66, ATA_66, ATA_ANY }; 251 + 252 + pair = &hwif->drives[1 - unit]; 249 253 250 254 /* 251 255 * Compute the best PIO mode we can for a given device. We must ··· 284 286 ide_hwif_t *hwif = drive->hwif; 285 287 struct pci_dev *dev = to_pci_dev(hwif->dev); 286 288 struct it821x_dev *itdev = (void *)ide_get_hwifdata(hwif); 287 - int unit = drive->select.b.unit; 288 - int channel = hwif->channel; 289 - u8 conf; 289 + u8 unit = drive->dn & 1, channel = hwif->channel, conf; 290 290 291 291 static u16 dma[] = { 0x8866, 0x3222, 0x3121 }; 292 292 static u8 mwdma_want[] = { ATA_ANY, ATA_66, ATA_ANY }; ··· 321 325 ide_hwif_t *hwif = drive->hwif; 322 326 struct pci_dev *dev = to_pci_dev(hwif->dev); 323 327 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 324 - int unit = drive->select.b.unit; 325 - int channel = hwif->channel; 326 - u8 conf; 328 + u8 unit = drive->dn & 1, channel = hwif->channel, conf; 327 329 328 330 static u16 udma[] = { 0x4433, 0x4231, 0x3121, 0x2121, 0x1111, 0x2211, 0x1111 }; 329 331 static u8 udma_want[] = { ATA_ANY, ATA_50, ATA_ANY, ATA_66, ATA_66, ATA_50, ATA_66 }; ··· 363 369 { 364 370 ide_hwif_t *hwif = drive->hwif; 365 371 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 366 - int unit = drive->select.b.unit; 372 + u8 unit = drive->dn & 1; 373 + 367 374 if(itdev->mwdma[unit] != MWDMA_OFF) 368 375 it821x_program(drive, itdev->mwdma[unit]); 369 376 else if(itdev->udma[unit] != UDMA_OFF && itdev->timing10) ··· 384 389 static int it821x_dma_end(ide_drive_t *drive) 385 390 { 386 391 ide_hwif_t *hwif = drive->hwif; 387 - int unit = drive->select.b.unit; 388 392 struct it821x_dev *itdev = ide_get_hwifdata(hwif); 389 - int ret = __ide_dma_end(drive); 393 + int ret = ide_dma_end(drive); 394 + u8 unit = drive->dn & 1; 395 + 390 396 if(itdev->mwdma[unit] != MWDMA_OFF) 391 397 it821x_program(drive, itdev->pio[unit]); 392 398 return ret; ··· 450 454 * IRQ mask as we may well be in PIO (eg rev 0x10) 451 455 * for now and we know unmasking is safe on this chipset. 452 456 */ 453 - drive->unmask = 1; 457 + drive->dev_flags |= IDE_DFLAG_UNMASK; 454 458 } else { 455 459 /* 456 460 * Perform fixups on smart mode. We need to "lose" some ··· 676 680 677 681 MODULE_DEVICE_TABLE(pci, it821x_pci_tbl); 678 682 679 - static struct pci_driver driver = { 683 + static struct pci_driver it821x_pci_driver = { 680 684 .name = "ITE821x IDE", 681 685 .id_table = it821x_pci_tbl, 682 686 .probe = it821x_init_one, ··· 687 691 688 692 static int __init it821x_ide_init(void) 689 693 { 690 - return ide_pci_register_driver(&driver); 694 + return ide_pci_register_driver(&it821x_pci_driver); 691 695 } 692 696 693 697 static void __exit it821x_ide_exit(void) 694 698 { 695 - pci_unregister_driver(&driver); 699 + pci_unregister_driver(&it821x_pci_driver); 696 700 } 697 701 698 702 module_init(it821x_ide_init);
+3 -3
drivers/ide/pci/jmicron.c
··· 149 149 150 150 MODULE_DEVICE_TABLE(pci, jmicron_pci_tbl); 151 151 152 - static struct pci_driver driver = { 152 + static struct pci_driver jmicron_pci_driver = { 153 153 .name = "JMicron IDE", 154 154 .id_table = jmicron_pci_tbl, 155 155 .probe = jmicron_init_one, ··· 160 160 161 161 static int __init jmicron_ide_init(void) 162 162 { 163 - return ide_pci_register_driver(&driver); 163 + return ide_pci_register_driver(&jmicron_pci_driver); 164 164 } 165 165 166 166 static void __exit jmicron_ide_exit(void) 167 167 { 168 - pci_unregister_driver(&driver); 168 + pci_unregister_driver(&jmicron_pci_driver); 169 169 } 170 170 171 171 module_init(jmicron_ide_init);
+13 -8
drivers/ide/pci/ns87415.c
··· 137 137 static unsigned int ns87415_count = 0, ns87415_control[MAX_HWIFS] = { 0 }; 138 138 139 139 /* 140 - * This routine either enables/disables (according to drive->present) 140 + * This routine either enables/disables (according to IDE_DFLAG_PRESENT) 141 141 * the IRQ associated with the port (HWIF(drive)), 142 142 * and selects either PIO or DMA handshaking for the next I/O operation. 143 143 */ ··· 153 153 154 154 /* Adjust IRQ enable bit */ 155 155 bit = 1 << (8 + hwif->channel); 156 - new = drive->present ? (new & ~bit) : (new | bit); 156 + 157 + if (drive->dev_flags & IDE_DFLAG_PRESENT) 158 + new &= ~bit; 159 + else 160 + new |= bit; 157 161 158 162 /* Select PIO or DMA, DMA may only be selected for one drive/channel. */ 159 - bit = 1 << (20 + drive->select.b.unit + (hwif->channel << 1)); 160 - other = 1 << (20 + (1 - drive->select.b.unit) + (hwif->channel << 1)); 163 + bit = 1 << (20 + (drive->dn & 1) + (hwif->channel << 1)); 164 + other = 1 << (20 + (1 - (drive->dn & 1)) + (hwif->channel << 1)); 161 165 new = use_dma ? ((new & ~other) | bit) : (new & ~bit); 162 166 163 167 if (new != *old) { ··· 191 187 192 188 static void ns87415_selectproc (ide_drive_t *drive) 193 189 { 194 - ns87415_prepare_drive (drive, drive->using_dma); 190 + ns87415_prepare_drive(drive, 191 + !!(drive->dev_flags & IDE_DFLAG_USING_DMA)); 195 192 } 196 193 197 194 static int ns87415_dma_end(ide_drive_t *drive) ··· 339 334 }; 340 335 MODULE_DEVICE_TABLE(pci, ns87415_pci_tbl); 341 336 342 - static struct pci_driver driver = { 337 + static struct pci_driver ns87415_pci_driver = { 343 338 .name = "NS87415_IDE", 344 339 .id_table = ns87415_pci_tbl, 345 340 .probe = ns87415_init_one, ··· 350 345 351 346 static int __init ns87415_ide_init(void) 352 347 { 353 - return ide_pci_register_driver(&driver); 348 + return ide_pci_register_driver(&ns87415_pci_driver); 354 349 } 355 350 356 351 static void __exit ns87415_ide_exit(void) 357 352 { 358 - pci_unregister_driver(&driver); 353 + pci_unregister_driver(&ns87415_pci_driver); 359 354 } 360 355 361 356 module_init(ns87415_ide_init);
+4 -4
drivers/ide/pci/opti621.c
··· 179 179 misc = addr_timings[clk][addr_pio]; 180 180 181 181 /* select Index-0/1 for Register-A/B */ 182 - write_reg(drive->select.b.unit, MISC_REG); 182 + write_reg(drive->dn & 1, MISC_REG); 183 183 /* set read cycle timings */ 184 184 write_reg(tim, READ_REG); 185 185 /* set write cycle timings */ ··· 220 220 }; 221 221 MODULE_DEVICE_TABLE(pci, opti621_pci_tbl); 222 222 223 - static struct pci_driver driver = { 223 + static struct pci_driver opti621_pci_driver = { 224 224 .name = "Opti621_IDE", 225 225 .id_table = opti621_pci_tbl, 226 226 .probe = opti621_init_one, ··· 231 231 232 232 static int __init opti621_ide_init(void) 233 233 { 234 - return ide_pci_register_driver(&driver); 234 + return ide_pci_register_driver(&opti621_pci_driver); 235 235 } 236 236 237 237 static void __exit opti621_ide_exit(void) 238 238 { 239 - pci_unregister_driver(&driver); 239 + pci_unregister_driver(&opti621_pci_driver); 240 240 } 241 241 242 242 module_init(opti621_ide_init);
+3 -3
drivers/ide/pci/pdc202xx_new.c
··· 561 561 }; 562 562 MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl); 563 563 564 - static struct pci_driver driver = { 564 + static struct pci_driver pdc202new_pci_driver = { 565 565 .name = "Promise_IDE", 566 566 .id_table = pdc202new_pci_tbl, 567 567 .probe = pdc202new_init_one, ··· 572 572 573 573 static int __init pdc202new_ide_init(void) 574 574 { 575 - return ide_pci_register_driver(&driver); 575 + return ide_pci_register_driver(&pdc202new_pci_driver); 576 576 } 577 577 578 578 static void __exit pdc202new_ide_exit(void) 579 579 { 580 - pci_unregister_driver(&driver); 580 + pci_unregister_driver(&pdc202new_pci_driver); 581 581 } 582 582 583 583 module_init(pdc202new_ide_init);
+7 -7
drivers/ide/pci/pdc202xx_old.c
··· 168 168 { 169 169 if (drive->current_speed > XFER_UDMA_2) 170 170 pdc_old_enable_66MHz_clock(drive->hwif); 171 - if (drive->media != ide_disk || drive->addressing == 1) { 171 + if (drive->media != ide_disk || (drive->dev_flags & IDE_DFLAG_LBA48)) { 172 172 struct request *rq = HWGROUP(drive)->rq; 173 173 ide_hwif_t *hwif = HWIF(drive); 174 174 unsigned long high_16 = hwif->extra_base - 16; ··· 188 188 189 189 static int pdc202xx_dma_end(ide_drive_t *drive) 190 190 { 191 - if (drive->media != ide_disk || drive->addressing == 1) { 191 + if (drive->media != ide_disk || (drive->dev_flags & IDE_DFLAG_LBA48)) { 192 192 ide_hwif_t *hwif = HWIF(drive); 193 193 unsigned long high_16 = hwif->extra_base - 16; 194 194 unsigned long atapi_reg = high_16 + (hwif->channel ? 0x24 : 0x20); ··· 200 200 } 201 201 if (drive->current_speed > XFER_UDMA_2) 202 202 pdc_old_disable_66MHz_clock(drive->hwif); 203 - return __ide_dma_end(drive); 203 + return ide_dma_end(drive); 204 204 } 205 205 206 206 static int pdc202xx_dma_test_irq(ide_drive_t *drive) ··· 333 333 .dma_setup = ide_dma_setup, 334 334 .dma_exec_cmd = ide_dma_exec_cmd, 335 335 .dma_start = ide_dma_start, 336 - .dma_end = __ide_dma_end, 336 + .dma_end = ide_dma_end, 337 337 .dma_test_irq = pdc202xx_dma_test_irq, 338 338 .dma_lost_irq = pdc202xx_dma_lost_irq, 339 339 .dma_timeout = pdc202xx_dma_timeout, ··· 426 426 }; 427 427 MODULE_DEVICE_TABLE(pci, pdc202xx_pci_tbl); 428 428 429 - static struct pci_driver driver = { 429 + static struct pci_driver pdc202xx_pci_driver = { 430 430 .name = "Promise_Old_IDE", 431 431 .id_table = pdc202xx_pci_tbl, 432 432 .probe = pdc202xx_init_one, ··· 437 437 438 438 static int __init pdc202xx_ide_init(void) 439 439 { 440 - return ide_pci_register_driver(&driver); 440 + return ide_pci_register_driver(&pdc202xx_pci_driver); 441 441 } 442 442 443 443 static void __exit pdc202xx_ide_exit(void) 444 444 { 445 - pci_unregister_driver(&driver); 445 + pci_unregister_driver(&pdc202xx_pci_driver); 446 446 } 447 447 448 448 module_init(pdc202xx_ide_init);
+27 -19
drivers/ide/pci/piix.c
··· 215 215 } 216 216 217 217 /** 218 - * piix_dma_clear_irq - clear BMDMA status 219 - * @drive: IDE drive to clear 218 + * ich_clear_irq - clear BMDMA status 219 + * @drive: IDE drive 220 220 * 221 - * Called from ide_intr() for PIO interrupts 222 - * to clear BMDMA status as needed by ICHx 221 + * ICHx contollers set DMA INTR no matter DMA or PIO. 222 + * BMDMA status might need to be cleared even for 223 + * PIO interrupts to prevent spurious/lost IRQ. 223 224 */ 224 - static void piix_dma_clear_irq(ide_drive_t *drive) 225 + static void ich_clear_irq(ide_drive_t *drive) 225 226 { 226 227 ide_hwif_t *hwif = HWIF(drive); 227 228 u8 dma_stat; 229 + 230 + /* 231 + * ide_dma_end() needs BMDMA status for error checking. 232 + * So, skip clearing BMDMA status here and leave it 233 + * to ide_dma_end() if this is DMA interrupt. 234 + */ 235 + if (drive->waiting_for_dma || hwif->dma_base == 0) 236 + return; 228 237 229 238 /* clear the INTR & ERROR bits */ 230 239 dma_stat = inb(hwif->dma_base + ATA_DMA_STATUS); ··· 258 249 { 0x27DF, 0x1025, 0x0110 }, /* ICH7 on Acer 3682WLMi */ 259 250 { 0x27DF, 0x1043, 0x1267 }, /* ICH7 on Asus W5F */ 260 251 { 0x27DF, 0x103C, 0x30A1 }, /* ICH7 on HP Compaq nc2400 */ 252 + { 0x27DF, 0x1071, 0xD221 }, /* ICH7 on Hercules EC-900 */ 261 253 { 0x24CA, 0x1025, 0x0061 }, /* ICH4 on Acer Aspire 2023WLMi */ 262 254 { 0x2653, 0x1043, 0x82D8 }, /* ICH6M on Asus Eee 701 */ 263 255 /* end marker */ ··· 303 293 hwif->ultra_mask = hwif->mwdma_mask = hwif->swdma_mask = 0; 304 294 } 305 295 306 - static void __devinit init_hwif_ich(ide_hwif_t *hwif) 307 - { 308 - init_hwif_piix(hwif); 309 - 310 - /* ICHx need to clear the BMDMA status for all interrupts */ 311 - if (hwif->dma_base) 312 - hwif->ide_dma_clear_irq = &piix_dma_clear_irq; 313 - } 314 - 315 296 static const struct ide_port_ops piix_port_ops = { 316 297 .set_pio_mode = piix_set_pio_mode, 317 298 .set_dma_mode = piix_set_dma_mode, 299 + .cable_detect = piix_cable_detect, 300 + }; 301 + 302 + static const struct ide_port_ops ich_port_ops = { 303 + .set_pio_mode = piix_set_pio_mode, 304 + .set_dma_mode = piix_set_dma_mode, 305 + .clear_irq = ich_clear_irq, 318 306 .cable_detect = piix_cable_detect, 319 307 }; 320 308 ··· 339 331 { \ 340 332 .name = DRV_NAME, \ 341 333 .init_chipset = init_chipset_ich, \ 342 - .init_hwif = init_hwif_ich, \ 334 + .init_hwif = init_hwif_piix, \ 343 335 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ 344 - .port_ops = &piix_port_ops, \ 336 + .port_ops = &ich_port_ops, \ 345 337 .host_flags = IDE_HFLAGS_PIIX, \ 346 338 .pio_mask = ATA_PIO4, \ 347 339 .swdma_mask = ATA_SWDMA2_ONLY, \ ··· 452 444 }; 453 445 MODULE_DEVICE_TABLE(pci, piix_pci_tbl); 454 446 455 - static struct pci_driver driver = { 447 + static struct pci_driver piix_pci_driver = { 456 448 .name = "PIIX_IDE", 457 449 .id_table = piix_pci_tbl, 458 450 .probe = piix_init_one, ··· 464 456 static int __init piix_ide_init(void) 465 457 { 466 458 piix_check_450nx(); 467 - return ide_pci_register_driver(&driver); 459 + return ide_pci_register_driver(&piix_pci_driver); 468 460 } 469 461 470 462 static void __exit piix_ide_exit(void) 471 463 { 472 - pci_unregister_driver(&driver); 464 + pci_unregister_driver(&piix_pci_driver); 473 465 } 474 466 475 467 module_init(piix_ide_init);
+3 -3
drivers/ide/pci/rz1000.c
··· 59 59 }; 60 60 MODULE_DEVICE_TABLE(pci, rz1000_pci_tbl); 61 61 62 - static struct pci_driver driver = { 62 + static struct pci_driver rz1000_pci_driver = { 63 63 .name = "RZ1000_IDE", 64 64 .id_table = rz1000_pci_tbl, 65 65 .probe = rz1000_init_one, ··· 68 68 69 69 static int __init rz1000_ide_init(void) 70 70 { 71 - return ide_pci_register_driver(&driver); 71 + return ide_pci_register_driver(&rz1000_pci_driver); 72 72 } 73 73 74 74 static void __exit rz1000_ide_exit(void) 75 75 { 76 - pci_unregister_driver(&driver); 76 + pci_unregister_driver(&rz1000_pci_driver); 77 77 } 78 78 79 79 module_init(rz1000_ide_init);
+6 -6
drivers/ide/pci/sc1200.c
··· 126 126 { 127 127 ide_hwif_t *hwif = HWIF(drive); 128 128 struct pci_dev *dev = to_pci_dev(hwif->dev); 129 - int unit = drive->select.b.unit; 130 129 unsigned int reg, timings; 131 130 unsigned short pci_clock; 132 131 unsigned int basereg = hwif->channel ? 0x50 : 0x40; ··· 154 155 else 155 156 timings = mwdma_timing[pci_clock][mode - XFER_MW_DMA_0]; 156 157 157 - if (unit == 0) { /* are we configuring drive0? */ 158 + if ((drive->dn & 1) == 0) { 158 159 pci_read_config_dword(dev, basereg + 4, &reg); 159 160 timings |= reg & 0x80000000; /* preserve PIO format bit */ 160 161 pci_write_config_dword(dev, basereg + 4, timings); ··· 215 216 if (mode != -1) { 216 217 printk("SC1200: %s: changing (U)DMA mode\n", drive->name); 217 218 ide_dma_off_quietly(drive); 218 - if (ide_set_dma_mode(drive, mode) == 0 && drive->using_dma) 219 + if (ide_set_dma_mode(drive, mode) == 0 && 220 + (drive->dev_flags & IDE_DFLAG_USING_DMA)) 219 221 hwif->dma_ops->dma_host_set(drive, 1); 220 222 return; 221 223 } ··· 328 328 }; 329 329 MODULE_DEVICE_TABLE(pci, sc1200_pci_tbl); 330 330 331 - static struct pci_driver driver = { 331 + static struct pci_driver sc1200_pci_driver = { 332 332 .name = "SC1200_IDE", 333 333 .id_table = sc1200_pci_tbl, 334 334 .probe = sc1200_init_one, ··· 341 341 342 342 static int __init sc1200_ide_init(void) 343 343 { 344 - return ide_pci_register_driver(&driver); 344 + return ide_pci_register_driver(&sc1200_pci_driver); 345 345 } 346 346 347 347 static void __exit sc1200_ide_exit(void) 348 348 { 349 - pci_unregister_driver(&driver); 349 + pci_unregister_driver(&sc1200_pci_driver); 350 350 } 351 351 352 352 module_init(sc1200_ide_init);
+12 -17
drivers/ide/pci/scc_pata.c
··· 291 291 static void scc_dma_host_set(ide_drive_t *drive, int on) 292 292 { 293 293 ide_hwif_t *hwif = drive->hwif; 294 - u8 unit = (drive->select.b.unit & 0x01); 294 + u8 unit = drive->dn & 1; 295 295 u8 dma_stat = scc_ide_inb(hwif->dma_base + 4); 296 296 297 297 if (on) ··· 353 353 354 354 /* start DMA */ 355 355 scc_ide_outb(dma_cmd | 1, hwif->dma_base); 356 - hwif->dma = 1; 357 356 wmb(); 358 357 } 359 358 ··· 373 374 /* purge DMA mappings */ 374 375 ide_destroy_dmatable(drive); 375 376 /* verify good DMA status */ 376 - hwif->dma = 0; 377 377 wmb(); 378 378 return (dma_stat & 7) != 4 ? (0x10 | dma_stat) : 0; 379 379 } ··· 509 511 if (int_stat & INTSTS_IOIRQS) 510 512 return 1; 511 513 512 - if (!drive->waiting_for_dma) 513 - printk(KERN_WARNING "%s: (%s) called while not waiting\n", 514 - drive->name, __func__); 515 514 return 0; 516 515 } 517 516 ··· 705 710 scc_ide_outb(tf->lbah, io_ports->lbah_addr); 706 711 707 712 if (task->tf_flags & IDE_TFLAG_OUT_DEVICE) 708 - scc_ide_outb((tf->device & HIHI) | drive->select.all, 713 + scc_ide_outb((tf->device & HIHI) | drive->select, 709 714 io_ports->device_addr); 710 715 } 711 716 ··· 821 826 init_mmio_iops_scc(hwif); 822 827 } 823 828 829 + static int __devinit scc_init_dma(ide_hwif_t *hwif, 830 + const struct ide_port_info *d) 831 + { 832 + return ide_allocate_dma_engine(hwif); 833 + } 834 + 824 835 static u8 scc_cable_detect(ide_hwif_t *hwif) 825 836 { 826 837 return ATA_CBL_PATA80; ··· 891 890 { \ 892 891 .name = name_str, \ 893 892 .init_iops = init_iops_scc, \ 893 + .init_dma = scc_init_dma, \ 894 894 .init_hwif = init_hwif_scc, \ 895 895 .tp_ops = &scc_tp_ops, \ 896 896 .port_ops = &scc_port_ops, \ ··· 929 927 { 930 928 struct scc_ports *ports = pci_get_drvdata(dev); 931 929 struct ide_host *host = ports->host; 932 - ide_hwif_t *hwif = host->ports[0]; 933 - 934 - if (hwif->dmatable_cpu) { 935 - pci_free_consistent(dev, PRD_ENTRIES * PRD_BYTES, 936 - hwif->dmatable_cpu, hwif->dmatable_dma); 937 - hwif->dmatable_cpu = NULL; 938 - } 939 930 940 931 ide_host_remove(host); 941 932 ··· 944 949 }; 945 950 MODULE_DEVICE_TABLE(pci, scc_pci_tbl); 946 951 947 - static struct pci_driver driver = { 952 + static struct pci_driver scc_pci_driver = { 948 953 .name = "SCC IDE", 949 954 .id_table = scc_pci_tbl, 950 955 .probe = scc_init_one, ··· 953 958 954 959 static int scc_ide_init(void) 955 960 { 956 - return ide_pci_register_driver(&driver); 961 + return ide_pci_register_driver(&scc_pci_driver); 957 962 } 958 963 959 964 module_init(scc_ide_init); 960 965 /* -- No exit code? 961 966 static void scc_ide_exit(void) 962 967 { 963 - ide_pci_unregister_driver(&driver); 968 + ide_pci_unregister_driver(&scc_pci_driver); 964 969 } 965 970 module_exit(scc_ide_exit); 966 971 */
+4 -4
drivers/ide/pci/serverworks.c
··· 153 153 154 154 ide_hwif_t *hwif = HWIF(drive); 155 155 struct pci_dev *dev = to_pci_dev(hwif->dev); 156 - u8 unit = (drive->select.b.unit & 0x01); 156 + u8 unit = drive->dn & 1; 157 157 158 158 u8 ultra_enable = 0, ultra_timing = 0, dma_timing = 0; 159 159 ··· 443 443 }; 444 444 MODULE_DEVICE_TABLE(pci, svwks_pci_tbl); 445 445 446 - static struct pci_driver driver = { 446 + static struct pci_driver svwks_pci_driver = { 447 447 .name = "Serverworks_IDE", 448 448 .id_table = svwks_pci_tbl, 449 449 .probe = svwks_init_one, ··· 454 454 455 455 static int __init svwks_ide_init(void) 456 456 { 457 - return ide_pci_register_driver(&driver); 457 + return ide_pci_register_driver(&svwks_pci_driver); 458 458 } 459 459 460 460 static void __exit svwks_ide_exit(void) 461 461 { 462 - pci_unregister_driver(&driver); 462 + pci_unregister_driver(&svwks_pci_driver); 463 463 } 464 464 465 465 module_init(svwks_ide_init);
+27 -34
drivers/ide/pci/sgiioc4.c
··· 1 1 /* 2 2 * Copyright (c) 2003-2006 Silicon Graphics, Inc. All Rights Reserved. 3 + * Copyright (C) 2008 MontaVista Software, Inc. 3 4 * 4 5 * This program is free software; you can redistribute it and/or modify it 5 6 * under the terms of version 2 of the GNU General Public License ··· 151 150 int count = 0; 152 151 153 152 stat = sgiioc4_read_status(hwif); 154 - while ((stat & 0x80) && (count++ < 100)) { 153 + while ((stat & ATA_BUSY) && (count++ < 100)) { 155 154 udelay(1); 156 155 stat = sgiioc4_read_status(hwif); 157 156 } ··· 311 310 u8 reg = (u8) readb((void __iomem *) port); 312 311 313 312 if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */ 314 - if (reg & 0x51) { /* Not busy...check for interrupt */ 313 + if (!(reg & ATA_BUSY)) { /* Not busy... check for interrupt */ 315 314 unsigned long other_ir = port - 0x110; 316 315 unsigned int intr_reg = (u32) readl((void __iomem *) other_ir); 317 316 ··· 339 338 if (dma_base == 0) 340 339 return -1; 341 340 342 - printk(KERN_INFO "%s: BM-DMA at 0x%04lx-0x%04lx\n", hwif->name, 343 - dma_base, dma_base + num_ports - 1); 341 + printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); 344 342 345 - if (!request_mem_region(dma_base, num_ports, hwif->name)) { 346 - printk(KERN_ERR 347 - "%s(%s) -- ERROR, Addresses 0x%p to 0x%p " 348 - "ALREADY in use\n", 349 - __func__, hwif->name, (void *) dma_base, 350 - (void *) dma_base + num_ports - 1); 343 + if (request_mem_region(dma_base, num_ports, hwif->name) == NULL) { 344 + printk(KERN_ERR "%s(%s) -- ERROR: addresses 0x%08lx to 0x%08lx " 345 + "already in use\n", __func__, hwif->name, 346 + dma_base, dma_base + num_ports - 1); 351 347 return -1; 352 348 } 353 349 354 350 virt_dma_base = ioremap(dma_base, num_ports); 355 351 if (virt_dma_base == NULL) { 356 - printk(KERN_ERR 357 - "%s(%s) -- ERROR, Unable to map addresses 0x%lx to 0x%lx\n", 358 - __func__, hwif->name, dma_base, dma_base + num_ports - 1); 352 + printk(KERN_ERR "%s(%s) -- ERROR: unable to map addresses " 353 + "0x%lx to 0x%lx\n", __func__, hwif->name, 354 + dma_base, dma_base + num_ports - 1); 359 355 goto dma_remap_failure; 360 356 } 361 357 hwif->dma_base = (unsigned long) virt_dma_base; 362 358 363 - hwif->dmatable_cpu = pci_alloc_consistent(dev, 364 - IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, 365 - &hwif->dmatable_dma); 366 - 367 - if (!hwif->dmatable_cpu) 368 - goto dma_pci_alloc_failure; 369 - 370 359 hwif->sg_max_nents = IOC4_PRD_ENTRIES; 360 + 361 + hwif->prd_max_nents = IOC4_PRD_ENTRIES; 362 + hwif->prd_ent_size = IOC4_PRD_BYTES; 363 + 364 + if (ide_allocate_dma_engine(hwif)) 365 + goto dma_pci_alloc_failure; 371 366 372 367 pad = pci_alloc_consistent(dev, IOC4_IDE_CACHELINE_SIZE, 373 368 (dma_addr_t *)&hwif->extra_base); ··· 372 375 return 0; 373 376 } 374 377 375 - pci_free_consistent(dev, IOC4_PRD_ENTRIES * IOC4_PRD_BYTES, 376 - hwif->dmatable_cpu, hwif->dmatable_dma); 377 - printk(KERN_INFO 378 - "%s() -- Error! Unable to allocate DMA Maps for drive %s\n", 378 + ide_release_dma_engine(hwif); 379 + 380 + printk(KERN_ERR "%s(%s) -- ERROR: Unable to allocate DMA maps\n", 379 381 __func__, hwif->name); 380 - printk(KERN_INFO 381 - "Changing from DMA to PIO mode for Drive %s\n", hwif->name); 382 + printk(KERN_INFO "%s: changing from DMA to PIO mode", hwif->name); 382 383 383 384 dma_pci_alloc_failure: 384 385 iounmap(virt_dma_base); ··· 612 617 irqport = (unsigned long) virt_base + IOC4_INTR_OFFSET; 613 618 614 619 cmd_phys_base = bar0 + IOC4_CMD_OFFSET; 615 - if (!request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE, 616 - DRV_NAME)) { 617 - printk(KERN_ERR 618 - "%s %s: -- ERROR, Addresses " 619 - "0x%p to 0x%p ALREADY in use\n", 620 - DRV_NAME, pci_name(dev), (void *)cmd_phys_base, 621 - (void *) cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); 622 - return -ENOMEM; 620 + if (request_mem_region(cmd_phys_base, IOC4_CMD_CTL_BLK_SIZE, 621 + DRV_NAME) == NULL) { 622 + printk(KERN_ERR "%s %s -- ERROR: addresses 0x%08lx to 0x%08lx " 623 + "already in use\n", DRV_NAME, pci_name(dev), 624 + cmd_phys_base, cmd_phys_base + IOC4_CMD_CTL_BLK_SIZE); 625 + return -EBUSY; 623 626 } 624 627 625 628 /* Initialize the IO registers */
+9 -8
drivers/ide/pci/siimage.c
··· 116 116 { 117 117 ide_hwif_t *hwif = HWIF(drive); 118 118 unsigned long base = (unsigned long)hwif->hwif_data; 119 + u8 unit = drive->dn & 1; 119 120 120 121 base += 0xA0 + r; 121 122 if (hwif->host_flags & IDE_HFLAG_MMIO) 122 123 base += hwif->channel << 6; 123 124 else 124 125 base += hwif->channel << 4; 125 - base |= drive->select.b.unit << drive->select.b.unit; 126 + base |= unit << unit; 126 127 return base; 127 128 } 128 129 ··· 256 255 u8 addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) 257 256 : (mmio ? 0xB4 : 0x80); 258 257 u8 mode = 0; 259 - u8 unit = drive->select.b.unit; 258 + u8 unit = drive->dn & 1; 260 259 261 260 /* trim *taskfile* PIO to the slowest of the master/slave */ 262 261 if (pair) { ··· 302 301 303 302 ide_hwif_t *hwif = HWIF(drive); 304 303 struct pci_dev *dev = to_pci_dev(hwif->dev); 305 - u16 ultra = 0, multi = 0; 306 - u8 mode = 0, unit = drive->select.b.unit; 307 304 unsigned long base = (unsigned long)hwif->hwif_data; 305 + u16 ultra = 0, multi = 0; 306 + u8 mode = 0, unit = drive->dn & 1; 308 307 u8 mmio = (hwif->host_flags & IDE_HFLAG_MMIO) ? 1 : 0; 309 308 u8 scsc = 0, addr_mask = hwif->channel ? (mmio ? 0xF4 : 0x84) 310 309 : (mmio ? 0xB4 : 0x80); ··· 713 712 .dma_setup = ide_dma_setup, 714 713 .dma_exec_cmd = ide_dma_exec_cmd, 715 714 .dma_start = ide_dma_start, 716 - .dma_end = __ide_dma_end, 715 + .dma_end = ide_dma_end, 717 716 .dma_test_irq = siimage_dma_test_irq, 718 717 .dma_timeout = ide_dma_timeout, 719 718 .dma_lost_irq = ide_dma_lost_irq, ··· 830 829 }; 831 830 MODULE_DEVICE_TABLE(pci, siimage_pci_tbl); 832 831 833 - static struct pci_driver driver = { 832 + static struct pci_driver siimage_pci_driver = { 834 833 .name = "SiI_IDE", 835 834 .id_table = siimage_pci_tbl, 836 835 .probe = siimage_init_one, ··· 841 840 842 841 static int __init siimage_ide_init(void) 843 842 { 844 - return ide_pci_register_driver(&driver); 843 + return ide_pci_register_driver(&siimage_pci_driver); 845 844 } 846 845 847 846 static void __exit siimage_ide_exit(void) 848 847 { 849 - pci_unregister_driver(&driver); 848 + pci_unregister_driver(&siimage_pci_driver); 850 849 } 851 850 852 851 module_init(siimage_ide_init);
+3 -3
drivers/ide/pci/sis5513.c
··· 605 605 }; 606 606 MODULE_DEVICE_TABLE(pci, sis5513_pci_tbl); 607 607 608 - static struct pci_driver driver = { 608 + static struct pci_driver sis5513_pci_driver = { 609 609 .name = "SIS_IDE", 610 610 .id_table = sis5513_pci_tbl, 611 611 .probe = sis5513_init_one, ··· 616 616 617 617 static int __init sis5513_ide_init(void) 618 618 { 619 - return ide_pci_register_driver(&driver); 619 + return ide_pci_register_driver(&sis5513_pci_driver); 620 620 } 621 621 622 622 static void __exit sis5513_ide_exit(void) 623 623 { 624 - pci_unregister_driver(&driver); 624 + pci_unregister_driver(&sis5513_pci_driver); 625 625 } 626 626 627 627 module_init(sis5513_ide_init);
+4 -4
drivers/ide/pci/sl82c105.c
··· 207 207 208 208 DBG(("%s(drive:%s)\n", __func__, drive->name)); 209 209 210 - ret = __ide_dma_end(drive); 210 + ret = ide_dma_end(drive); 211 211 212 212 pci_write_config_word(dev, reg, drive->drive_data); 213 213 ··· 345 345 }; 346 346 MODULE_DEVICE_TABLE(pci, sl82c105_pci_tbl); 347 347 348 - static struct pci_driver driver = { 348 + static struct pci_driver sl82c105_pci_driver = { 349 349 .name = "W82C105_IDE", 350 350 .id_table = sl82c105_pci_tbl, 351 351 .probe = sl82c105_init_one, ··· 356 356 357 357 static int __init sl82c105_ide_init(void) 358 358 { 359 - return ide_pci_register_driver(&driver); 359 + return ide_pci_register_driver(&sl82c105_pci_driver); 360 360 } 361 361 362 362 static void __exit sl82c105_ide_exit(void) 363 363 { 364 - pci_unregister_driver(&driver); 364 + pci_unregister_driver(&sl82c105_pci_driver); 365 365 } 366 366 367 367 module_init(sl82c105_ide_init);
+3 -3
drivers/ide/pci/slc90e66.c
··· 154 154 }; 155 155 MODULE_DEVICE_TABLE(pci, slc90e66_pci_tbl); 156 156 157 - static struct pci_driver driver = { 157 + static struct pci_driver slc90e66_pci_driver = { 158 158 .name = "SLC90e66_IDE", 159 159 .id_table = slc90e66_pci_tbl, 160 160 .probe = slc90e66_init_one, ··· 165 165 166 166 static int __init slc90e66_ide_init(void) 167 167 { 168 - return ide_pci_register_driver(&driver); 168 + return ide_pci_register_driver(&slc90e66_pci_driver); 169 169 } 170 170 171 171 static void __exit slc90e66_ide_exit(void) 172 172 { 173 - pci_unregister_driver(&driver); 173 + pci_unregister_driver(&slc90e66_pci_driver); 174 174 } 175 175 176 176 module_init(slc90e66_ide_init);
+4 -4
drivers/ide/pci/tc86c001.c
··· 186 186 .dma_setup = ide_dma_setup, 187 187 .dma_exec_cmd = ide_dma_exec_cmd, 188 188 .dma_start = tc86c001_dma_start, 189 - .dma_end = __ide_dma_end, 189 + .dma_end = ide_dma_end, 190 190 .dma_test_irq = ide_dma_test_irq, 191 191 .dma_lost_irq = ide_dma_lost_irq, 192 192 .dma_timeout = ide_dma_timeout, ··· 245 245 }; 246 246 MODULE_DEVICE_TABLE(pci, tc86c001_pci_tbl); 247 247 248 - static struct pci_driver driver = { 248 + static struct pci_driver tc86c001_pci_driver = { 249 249 .name = "TC86C001", 250 250 .id_table = tc86c001_pci_tbl, 251 251 .probe = tc86c001_init_one, ··· 254 254 255 255 static int __init tc86c001_ide_init(void) 256 256 { 257 - return ide_pci_register_driver(&driver); 257 + return ide_pci_register_driver(&tc86c001_pci_driver); 258 258 } 259 259 260 260 static void __exit tc86c001_ide_exit(void) 261 261 { 262 - pci_unregister_driver(&driver); 262 + pci_unregister_driver(&tc86c001_pci_driver); 263 263 } 264 264 265 265 module_init(tc86c001_ide_init);
+7 -8
drivers/ide/pci/triflex.c
··· 38 38 { 39 39 ide_hwif_t *hwif = HWIF(drive); 40 40 struct pci_dev *dev = to_pci_dev(hwif->dev); 41 - u8 channel_offset = hwif->channel ? 0x74 : 0x70; 42 - u16 timing = 0; 43 41 u32 triflex_timings = 0; 44 - u8 unit = (drive->select.b.unit & 0x01); 45 - 42 + u16 timing = 0; 43 + u8 channel_offset = hwif->channel ? 0x74 : 0x70, unit = drive->dn & 1; 44 + 46 45 pci_read_config_dword(dev, channel_offset, &triflex_timings); 47 - 46 + 48 47 switch(speed) { 49 48 case XFER_MW_DMA_2: 50 49 timing = 0x0103; ··· 113 114 }; 114 115 MODULE_DEVICE_TABLE(pci, triflex_pci_tbl); 115 116 116 - static struct pci_driver driver = { 117 + static struct pci_driver triflex_pci_driver = { 117 118 .name = "TRIFLEX_IDE", 118 119 .id_table = triflex_pci_tbl, 119 120 .probe = triflex_init_one, ··· 124 125 125 126 static int __init triflex_ide_init(void) 126 127 { 127 - return ide_pci_register_driver(&driver); 128 + return ide_pci_register_driver(&triflex_pci_driver); 128 129 } 129 130 130 131 static void __exit triflex_ide_exit(void) 131 132 { 132 - pci_unregister_driver(&driver); 133 + pci_unregister_driver(&triflex_pci_driver); 133 134 } 134 135 135 136 module_init(triflex_ide_init);
+5 -5
drivers/ide/pci/trm290.c
··· 161 161 } 162 162 163 163 /* enable IRQ if not probing */ 164 - if (drive->present) { 164 + if (drive->dev_flags & IDE_DFLAG_PRESENT) { 165 165 reg = inw(hwif->config_data + 3); 166 166 reg &= 0x13; 167 167 reg &= ~(1 << hwif->channel); ··· 173 173 174 174 static void trm290_selectproc (ide_drive_t *drive) 175 175 { 176 - trm290_prepare_drive(drive, drive->using_dma); 176 + trm290_prepare_drive(drive, !!(drive->dev_flags & IDE_DFLAG_USING_DMA)); 177 177 } 178 178 179 179 static void trm290_dma_exec_cmd(ide_drive_t *drive, u8 command) ··· 350 350 }; 351 351 MODULE_DEVICE_TABLE(pci, trm290_pci_tbl); 352 352 353 - static struct pci_driver driver = { 353 + static struct pci_driver trm290_pci_driver = { 354 354 .name = "TRM290_IDE", 355 355 .id_table = trm290_pci_tbl, 356 356 .probe = trm290_init_one, ··· 359 359 360 360 static int __init trm290_ide_init(void) 361 361 { 362 - return ide_pci_register_driver(&driver); 362 + return ide_pci_register_driver(&trm290_pci_driver); 363 363 } 364 364 365 365 static void __exit trm290_ide_exit(void) 366 366 { 367 - pci_unregister_driver(&driver); 367 + pci_unregister_driver(&trm290_pci_driver); 368 368 } 369 369 370 370 module_init(trm290_ide_init);
+3 -3
drivers/ide/pci/via82cxxx.c
··· 487 487 }; 488 488 MODULE_DEVICE_TABLE(pci, via_pci_tbl); 489 489 490 - static struct pci_driver driver = { 490 + static struct pci_driver via_pci_driver = { 491 491 .name = "VIA_IDE", 492 492 .id_table = via_pci_tbl, 493 493 .probe = via_init_one, ··· 498 498 499 499 static int __init via_ide_init(void) 500 500 { 501 - return ide_pci_register_driver(&driver); 501 + return ide_pci_register_driver(&via_pci_driver); 502 502 } 503 503 504 504 static void __exit via_ide_exit(void) 505 505 { 506 - pci_unregister_driver(&driver); 506 + pci_unregister_driver(&via_pci_driver); 507 507 } 508 508 509 509 module_init(via_ide_init);
+14 -57
drivers/ide/ppc/pmac.c
··· 430 430 pmac_ide_hwif_t *pmif = 431 431 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 432 432 433 - if (pmif == NULL) 434 - return; 435 - 436 - if (drive->select.b.unit & 0x01) 433 + if (drive->dn & 1) 437 434 writel(pmif->timings[1], PMAC_IDE_REG(IDE_TIMING_CONFIG)); 438 435 else 439 436 writel(pmif->timings[0], PMAC_IDE_REG(IDE_TIMING_CONFIG)); ··· 449 452 pmac_ide_hwif_t *pmif = 450 453 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 451 454 452 - if (pmif == NULL) 453 - return; 454 - 455 - if (drive->select.b.unit & 0x01) { 455 + if (drive->dn & 1) { 456 456 writel(pmif->timings[1], PMAC_IDE_REG(IDE_KAUAI_PIO_CONFIG)); 457 457 writel(pmif->timings[3], PMAC_IDE_REG(IDE_KAUAI_ULTRA_CONFIG)); 458 458 } else { ··· 468 474 ide_hwif_t *hwif = drive->hwif; 469 475 pmac_ide_hwif_t *pmif = 470 476 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 471 - 472 - if (pmif == NULL) 473 - return; 474 477 475 478 if (pmif->kind == controller_sh_ata6 || 476 479 pmif->kind == controller_un_ata6 || ··· 515 524 unsigned accessTime, recTime; 516 525 unsigned int cycle_time; 517 526 518 - if (pmif == NULL) 519 - return; 520 - 521 527 /* which drive is it ? */ 522 - timings = &pmif->timings[drive->select.b.unit & 0x01]; 528 + timings = &pmif->timings[drive->dn & 1]; 523 529 t = *timings; 524 530 525 531 cycle_time = ide_pio_cycle_time(drive, pio); ··· 793 805 ide_hwif_t *hwif = drive->hwif; 794 806 pmac_ide_hwif_t *pmif = 795 807 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 796 - int unit = (drive->select.b.unit & 0x01); 797 808 int ret = 0; 798 809 u32 *timings, *timings2, tl[2]; 810 + u8 unit = drive->dn & 1; 799 811 800 812 timings = &pmif->timings[unit]; 801 813 timings2 = &pmif->timings[unit+2]; ··· 954 966 if (pmif->mediabay) { 955 967 #ifdef CONFIG_PMAC_MEDIABAY 956 968 if (check_media_bay_by_base(pmif->regbase, MB_CD) == 0) { 957 - drive->noprobe = 0; 969 + drive->dev_flags &= ~IDE_DFLAG_NOPROBE; 958 970 return; 959 971 } 960 972 #endif 961 - drive->noprobe = 1; 973 + drive->dev_flags |= IDE_DFLAG_NOPROBE; 962 974 } 963 975 } 964 976 ··· 1523 1535 return 0; /* revert to PIO for this request */ 1524 1536 } 1525 1537 1526 - /* Teardown mappings after DMA has completed. */ 1527 - static void 1528 - pmac_ide_destroy_dmatable (ide_drive_t *drive) 1529 - { 1530 - ide_hwif_t *hwif = drive->hwif; 1531 - 1532 - if (hwif->sg_nents) { 1533 - ide_destroy_dmatable(drive); 1534 - hwif->sg_nents = 0; 1535 - } 1536 - } 1537 - 1538 1538 /* 1539 1539 * Prepare a DMA transfer. We build the DMA table, adjust the timings for 1540 1540 * a read on KeyLargo ATA/66 and mark us as waiting for DMA completion ··· 1534 1558 pmac_ide_hwif_t *pmif = 1535 1559 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 1536 1560 struct request *rq = HWGROUP(drive)->rq; 1537 - u8 unit = (drive->select.b.unit & 0x01); 1538 - u8 ata4; 1539 - 1540 - if (pmif == NULL) 1541 - return 1; 1542 - ata4 = (pmif->kind == controller_kl_ata4); 1561 + u8 unit = drive->dn & 1, ata4 = (pmif->kind == controller_kl_ata4); 1543 1562 1544 1563 if (!pmac_ide_build_dmatable(drive, rq)) { 1545 1564 ide_map_sg(drive, rq); ··· 1588 1617 ide_hwif_t *hwif = drive->hwif; 1589 1618 pmac_ide_hwif_t *pmif = 1590 1619 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 1591 - volatile struct dbdma_regs __iomem *dma; 1620 + volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; 1592 1621 u32 dstat; 1593 - 1594 - if (pmif == NULL) 1595 - return 0; 1596 - dma = pmif->dma_regs; 1597 1622 1598 1623 drive->waiting_for_dma = 0; 1599 1624 dstat = readl(&dma->status); 1600 1625 writel(((RUN|WAKE|DEAD) << 16), &dma->control); 1601 - pmac_ide_destroy_dmatable(drive); 1626 + 1627 + ide_destroy_dmatable(drive); 1628 + 1602 1629 /* verify good dma status. we don't check for ACTIVE beeing 0. We should... 1603 1630 * in theory, but with ATAPI decices doing buffer underruns, that would 1604 1631 * cause us to disable DMA, which isn't what we want ··· 1616 1647 ide_hwif_t *hwif = drive->hwif; 1617 1648 pmac_ide_hwif_t *pmif = 1618 1649 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 1619 - volatile struct dbdma_regs __iomem *dma; 1650 + volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; 1620 1651 unsigned long status, timeout; 1621 - 1622 - if (pmif == NULL) 1623 - return 0; 1624 - dma = pmif->dma_regs; 1625 1652 1626 1653 /* We have to things to deal with here: 1627 1654 * ··· 1637 1672 status = readl(&dma->status); 1638 1673 if (!(status & ACTIVE)) 1639 1674 return 1; 1640 - if (!drive->waiting_for_dma) 1641 - printk(KERN_WARNING "ide%d, ide_dma_test_irq \ 1642 - called while not waiting\n", HWIF(drive)->index); 1643 1675 1644 1676 /* If dbdma didn't execute the STOP command yet, the 1645 1677 * active bit is still set. We consider that we aren't ··· 1671 1709 ide_hwif_t *hwif = drive->hwif; 1672 1710 pmac_ide_hwif_t *pmif = 1673 1711 (pmac_ide_hwif_t *)dev_get_drvdata(hwif->gendev.parent); 1674 - volatile struct dbdma_regs __iomem *dma; 1675 - unsigned long status; 1712 + volatile struct dbdma_regs __iomem *dma = pmif->dma_regs; 1713 + unsigned long status = readl(&dma->status); 1676 1714 1677 - if (pmif == NULL) 1678 - return; 1679 - dma = pmif->dma_regs; 1680 - 1681 - status = readl(&dma->status); 1682 1715 printk(KERN_ERR "ide-pmac lost interrupt, dma status: %lx\n", status); 1683 1716 } 1684 1717
+33 -69
drivers/scsi/ide-scsi.c
··· 82 82 struct gendisk *disk; 83 83 struct Scsi_Host *host; 84 84 85 - struct ide_atapi_pc *pc; /* Current packet command */ 86 85 unsigned long transform; /* SCSI cmd translation layer */ 87 86 unsigned long log; /* log flags */ 88 87 } idescsi_scsi_t; ··· 136 137 137 138 static int idescsi_end_request(ide_drive_t *, int, int); 138 139 139 - static void ide_scsi_callback(ide_drive_t *drive) 140 + static void ide_scsi_callback(ide_drive_t *drive, int dsc) 140 141 { 141 142 idescsi_scsi_t *scsi = drive_to_idescsi(drive); 142 - struct ide_atapi_pc *pc = scsi->pc; 143 + struct ide_atapi_pc *pc = drive->pc; 143 144 144 145 if (pc->flags & PC_FLAG_TIMEDOUT) 145 146 debug_log("%s: got timed out packet %lu at %lu\n", __func__, ··· 266 267 spin_unlock_irqrestore(host->host_lock, flags); 267 268 kfree(pc); 268 269 blk_put_request(rq); 269 - scsi->pc = NULL; 270 + drive->pc = NULL; 270 271 return 0; 271 - } 272 - 273 - static inline unsigned long get_timeout(struct ide_atapi_pc *pc) 274 - { 275 - return max_t(unsigned long, WAIT_CMD, pc->timeout - jiffies); 276 - } 277 - 278 - static int idescsi_expiry(ide_drive_t *drive) 279 - { 280 - idescsi_scsi_t *scsi = drive_to_idescsi(drive); 281 - struct ide_atapi_pc *pc = scsi->pc; 282 - 283 - debug_log("%s called for %lu at %lu\n", __func__, 284 - pc->scsi_cmd->serial_number, jiffies); 285 - 286 - pc->flags |= PC_FLAG_TIMEDOUT; 287 - 288 - return 0; /* we do not want the ide subsystem to retry */ 289 - } 290 - 291 - /* 292 - * Our interrupt handler. 293 - */ 294 - static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) 295 - { 296 - idescsi_scsi_t *scsi = drive_to_idescsi(drive); 297 - struct ide_atapi_pc *pc = scsi->pc; 298 - 299 - return ide_pc_intr(drive, pc, idescsi_pc_intr, get_timeout(pc), 300 - idescsi_expiry, NULL, NULL, NULL, 301 - ide_io_buffers); 302 - } 303 - 304 - static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) 305 - { 306 - idescsi_scsi_t *scsi = drive_to_idescsi(drive); 307 - 308 - return ide_transfer_pc(drive, scsi->pc, idescsi_pc_intr, 309 - get_timeout(scsi->pc), idescsi_expiry); 310 272 } 311 273 312 274 static inline int idescsi_set_direction(struct ide_atapi_pc *pc) ··· 312 352 static ide_startstop_t idescsi_issue_pc(ide_drive_t *drive, 313 353 struct ide_atapi_pc *pc) 314 354 { 315 - idescsi_scsi_t *scsi = drive_to_idescsi(drive); 316 - 317 355 /* Set the current packet command */ 318 - scsi->pc = pc; 356 + drive->pc = pc; 319 357 320 - return ide_issue_pc(drive, pc, idescsi_transfer_pc, 321 - get_timeout(pc), idescsi_expiry); 358 + return ide_issue_pc(drive, ide_scsi_get_timeout(pc), ide_scsi_expiry); 322 359 } 323 360 324 361 /* ··· 331 374 if (blk_sense_request(rq) || blk_special_request(rq)) { 332 375 struct ide_atapi_pc *pc = (struct ide_atapi_pc *)rq->special; 333 376 334 - if (drive->using_dma && !idescsi_map_sg(drive, pc)) 377 + if ((drive->dev_flags & IDE_DFLAG_USING_DMA) && 378 + idescsi_map_sg(drive, pc) == 0) 335 379 pc->flags |= PC_FLAG_DMA_OK; 336 380 337 381 return idescsi_issue_pc(drive, pc); ··· 385 427 */ 386 428 static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi) 387 429 { 388 - if ((drive->id[ATA_ID_CONFIG] & 0x0060) == 0x20) 389 - set_bit(IDE_AFLAG_DRQ_INTERRUPT, &drive->atapi_flags); 390 430 clear_bit(IDESCSI_SG_TRANSFORM, &scsi->transform); 391 431 #if IDESCSI_DEBUG_LOG 392 432 set_bit(IDESCSI_LOG_CMD, &scsi->log); 393 433 #endif /* IDESCSI_DEBUG_LOG */ 394 434 395 - drive->pc_callback = ide_scsi_callback; 435 + drive->pc_callback = ide_scsi_callback; 436 + drive->pc_update_buffers = NULL; 437 + drive->pc_io_buffers = ide_io_buffers; 396 438 397 439 ide_proc_register_driver(drive, scsi->driver); 398 440 } ··· 414 456 415 457 ide_scsi_put(scsi); 416 458 417 - drive->scsi = 0; 459 + drive->dev_flags &= ~IDE_DFLAG_SCSI; 418 460 } 419 461 420 462 static int ide_scsi_probe(ide_drive_t *); ··· 435 477 .probe = ide_scsi_probe, 436 478 .remove = ide_scsi_remove, 437 479 .version = IDESCSI_VERSION, 438 - .media = ide_scsi, 439 480 .do_request = idescsi_do_request, 440 481 .end_request = idescsi_end_request, 441 482 .error = idescsi_atapi_error, ··· 579 622 int busy; 580 623 int ret = FAILED; 581 624 625 + struct ide_atapi_pc *pc; 626 + 582 627 /* In idescsi_eh_abort we try to gently pry our command from the ide subsystem */ 583 628 584 629 if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) ··· 601 642 spin_lock_irq(&ide_lock); 602 643 603 644 /* If there is no pc running we're done (our interrupt took care of it) */ 604 - if (!scsi->pc) { 645 + pc = drive->pc; 646 + if (pc == NULL) { 605 647 ret = SUCCESS; 606 648 goto ide_unlock; 607 649 } 608 650 609 651 /* It's somewhere in flight. Does ide subsystem agree? */ 610 - if (scsi->pc->scsi_cmd->serial_number == cmd->serial_number && !busy && 611 - elv_queue_empty(drive->queue) && HWGROUP(drive)->rq != scsi->pc->rq) { 652 + if (pc->scsi_cmd->serial_number == cmd->serial_number && !busy && 653 + elv_queue_empty(drive->queue) && HWGROUP(drive)->rq != pc->rq) { 612 654 /* 613 655 * FIXME - not sure this condition can ever occur 614 656 */ 615 657 printk (KERN_ERR "ide-scsi: cmd aborted!\n"); 616 658 617 - if (blk_sense_request(scsi->pc->rq)) 618 - kfree(scsi->pc->buf); 659 + if (blk_sense_request(pc->rq)) 660 + kfree(pc->buf); 619 661 /* we need to call blk_put_request twice. */ 620 - blk_put_request(scsi->pc->rq); 621 - blk_put_request(scsi->pc->rq); 622 - kfree(scsi->pc); 623 - scsi->pc = NULL; 662 + blk_put_request(pc->rq); 663 + blk_put_request(pc->rq); 664 + kfree(pc); 665 + drive->pc = NULL; 624 666 625 667 ret = SUCCESS; 626 668 } ··· 643 683 int ready = 0; 644 684 int ret = SUCCESS; 645 685 686 + struct ide_atapi_pc *pc; 687 + 646 688 /* In idescsi_eh_reset we forcefully remove the command from the ide subsystem and reset the device. */ 647 689 648 690 if (test_bit(IDESCSI_LOG_CMD, &scsi->log)) ··· 659 697 spin_lock_irq(cmd->device->host->host_lock); 660 698 spin_lock(&ide_lock); 661 699 662 - if (!scsi->pc || (req = scsi->pc->rq) != HWGROUP(drive)->rq || !HWGROUP(drive)->handler) { 700 + pc = drive->pc; 701 + 702 + if (pc == NULL || (req = pc->rq) != HWGROUP(drive)->rq || !HWGROUP(drive)->handler) { 663 703 printk (KERN_WARNING "ide-scsi: No active request in idescsi_eh_reset\n"); 664 704 spin_unlock(&ide_lock); 665 705 spin_unlock_irq(cmd->device->host->host_lock); ··· 672 708 if (__blk_end_request(req, -EIO, 0)) 673 709 BUG(); 674 710 if (blk_sense_request(req)) 675 - kfree(scsi->pc->buf); 676 - kfree(scsi->pc); 677 - scsi->pc = NULL; 711 + kfree(pc->buf); 712 + kfree(pc); 713 + drive->pc = NULL; 678 714 blk_put_request(req); 679 715 680 716 /* now nuke the drive queue */ ··· 765 801 !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t)))) 766 802 return -ENODEV; 767 803 768 - drive->scsi = 1; 804 + drive->dev_flags |= IDE_DFLAG_SCSI; 769 805 770 806 g = alloc_disk(1 << PARTN_BITS); 771 807 if (!g) ··· 806 842 807 843 put_disk(g); 808 844 out_host_put: 809 - drive->scsi = 0; 845 + drive->dev_flags &= ~IDE_DFLAG_SCSI; 810 846 scsi_host_put(host); 811 847 return err; 812 848 }
+827 -758
include/linux/ide.h
··· 48 48 #define ERROR_RESET 3 /* Reset controller every 4th retry */ 49 49 #define ERROR_RECAL 1 /* Recalibrate every 2nd retry */ 50 50 51 - /* 52 - * state flags 53 - */ 54 - 55 - #define DMA_PIO_RETRY 1 /* retrying in PIO */ 56 - 57 51 #define HWIF(drive) ((ide_hwif_t *)((drive)->hwif)) 58 52 #define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup)) 59 53 ··· 156 162 */ 157 163 #define REQ_DRIVE_RESET 0x20 158 164 #define REQ_DEVSET_EXEC 0x21 165 + #define REQ_PARK_HEADS 0x22 166 + #define REQ_UNPARK_HEADS 0x23 159 167 160 168 /* 161 169 * Check for an interrupt and acknowledge the interrupt status ··· 264 268 * set_geometry : respecify drive geometry 265 269 * recalibrate : seek to cyl 0 266 270 * set_multmode : set multmode count 267 - * set_tune : tune interface for drive 268 - * serviced : service command 269 271 * reserved : unused 270 272 */ 271 273 typedef union { ··· 272 278 unsigned set_geometry : 1; 273 279 unsigned recalibrate : 1; 274 280 unsigned set_multmode : 1; 275 - unsigned set_tune : 1; 276 - unsigned serviced : 1; 277 - unsigned reserved : 3; 281 + unsigned reserved : 5; 278 282 } b; 279 283 } special_t; 280 - 281 - /* 282 - * ATA-IDE Select Register, aka Device-Head 283 - * 284 - * head : always zeros here 285 - * unit : drive select number: 0/1 286 - * bit5 : always 1 287 - * lba : using LBA instead of CHS 288 - * bit7 : always 1 289 - */ 290 - typedef union { 291 - unsigned all : 8; 292 - struct { 293 - #if defined(__LITTLE_ENDIAN_BITFIELD) 294 - unsigned head : 4; 295 - unsigned unit : 1; 296 - unsigned bit5 : 1; 297 - unsigned lba : 1; 298 - unsigned bit7 : 1; 299 - #elif defined(__BIG_ENDIAN_BITFIELD) 300 - unsigned bit7 : 1; 301 - unsigned lba : 1; 302 - unsigned bit5 : 1; 303 - unsigned unit : 1; 304 - unsigned head : 4; 305 - #else 306 - #error "Please fix <asm/byteorder.h>" 307 - #endif 308 - } b; 309 - } select_t, ata_select_t; 310 284 311 285 /* 312 286 * Status returned from various ide_ functions ··· 283 321 ide_stopped, /* no drive operation was started */ 284 322 ide_started, /* a drive operation was started, handler was set */ 285 323 } ide_startstop_t; 286 - 287 - struct ide_devset; 288 - struct ide_driver_s; 289 - 290 - #ifdef CONFIG_BLK_DEV_IDEACPI 291 - struct ide_acpi_drive_link; 292 - struct ide_acpi_hwif_link; 293 - #endif 294 - 295 - /* ATAPI device flags */ 296 - enum { 297 - IDE_AFLAG_DRQ_INTERRUPT = (1 << 0), 298 - IDE_AFLAG_MEDIA_CHANGED = (1 << 1), 299 - /* Drive cannot lock the door. */ 300 - IDE_AFLAG_NO_DOORLOCK = (1 << 2), 301 - 302 - /* ide-cd */ 303 - /* Drive cannot eject the disc. */ 304 - IDE_AFLAG_NO_EJECT = (1 << 3), 305 - /* Drive is a pre ATAPI 1.2 drive. */ 306 - IDE_AFLAG_PRE_ATAPI12 = (1 << 4), 307 - /* TOC addresses are in BCD. */ 308 - IDE_AFLAG_TOCADDR_AS_BCD = (1 << 5), 309 - /* TOC track numbers are in BCD. */ 310 - IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 6), 311 - /* 312 - * Drive does not provide data in multiples of SECTOR_SIZE 313 - * when more than one interrupt is needed. 314 - */ 315 - IDE_AFLAG_LIMIT_NFRAMES = (1 << 7), 316 - /* Seeking in progress. */ 317 - IDE_AFLAG_SEEKING = (1 << 8), 318 - /* Saved TOC information is current. */ 319 - IDE_AFLAG_TOC_VALID = (1 << 9), 320 - /* We think that the drive door is locked. */ 321 - IDE_AFLAG_DOOR_LOCKED = (1 << 10), 322 - /* SET_CD_SPEED command is unsupported. */ 323 - IDE_AFLAG_NO_SPEED_SELECT = (1 << 11), 324 - IDE_AFLAG_VERTOS_300_SSD = (1 << 12), 325 - IDE_AFLAG_VERTOS_600_ESD = (1 << 13), 326 - IDE_AFLAG_SANYO_3CD = (1 << 14), 327 - IDE_AFLAG_FULL_CAPS_PAGE = (1 << 15), 328 - IDE_AFLAG_PLAY_AUDIO_OK = (1 << 16), 329 - IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17), 330 - 331 - /* ide-floppy */ 332 - /* Format in progress */ 333 - IDE_AFLAG_FORMAT_IN_PROGRESS = (1 << 18), 334 - /* Avoid commands not supported in Clik drive */ 335 - IDE_AFLAG_CLIK_DRIVE = (1 << 19), 336 - /* Requires BH algorithm for packets */ 337 - IDE_AFLAG_ZIP_DRIVE = (1 << 20), 338 - /* Write protect */ 339 - IDE_AFLAG_WP = (1 << 21), 340 - /* Supports format progress report */ 341 - IDE_AFLAG_SRFP = (1 << 22), 342 - 343 - /* ide-tape */ 344 - IDE_AFLAG_IGNORE_DSC = (1 << 23), 345 - /* 0 When the tape position is unknown */ 346 - IDE_AFLAG_ADDRESS_VALID = (1 << 24), 347 - /* Device already opened */ 348 - IDE_AFLAG_BUSY = (1 << 25), 349 - /* Attempt to auto-detect the current user block size */ 350 - IDE_AFLAG_DETECT_BS = (1 << 26), 351 - /* Currently on a filemark */ 352 - IDE_AFLAG_FILEMARK = (1 << 27), 353 - /* 0 = no tape is loaded, so we don't rewind after ejecting */ 354 - IDE_AFLAG_MEDIUM_PRESENT = (1 << 28), 355 - 356 - IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), 357 - }; 358 - 359 - struct ide_drive_s { 360 - char name[4]; /* drive name, such as "hda" */ 361 - char driver_req[10]; /* requests specific driver */ 362 - 363 - struct request_queue *queue; /* request queue */ 364 - 365 - struct request *rq; /* current request */ 366 - struct ide_drive_s *next; /* circular list of hwgroup drives */ 367 - void *driver_data; /* extra driver data */ 368 - u16 *id; /* identification info */ 369 - #ifdef CONFIG_IDE_PROC_FS 370 - struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 371 - const struct ide_proc_devset *settings; /* /proc/ide/ drive settings */ 372 - #endif 373 - struct hwif_s *hwif; /* actually (ide_hwif_t *) */ 374 - 375 - unsigned long sleep; /* sleep until this time */ 376 - unsigned long service_start; /* time we started last request */ 377 - unsigned long service_time; /* service time of last request */ 378 - unsigned long timeout; /* max time to wait for irq */ 379 - 380 - special_t special; /* special action flags */ 381 - select_t select; /* basic drive/head select reg value */ 382 - 383 - u8 retry_pio; /* retrying dma capable host in pio */ 384 - u8 state; /* retry state */ 385 - u8 waiting_for_dma; /* dma currently in progress */ 386 - 387 - unsigned keep_settings : 1; /* restore settings after drive reset */ 388 - unsigned using_dma : 1; /* disk is using dma for read/write */ 389 - unsigned unmask : 1; /* okay to unmask other irqs */ 390 - unsigned noflush : 1; /* don't attempt flushes */ 391 - unsigned dsc_overlap : 1; /* DSC overlap */ 392 - unsigned nice1 : 1; /* give potential excess bandwidth */ 393 - unsigned present : 1; /* drive is physically present */ 394 - unsigned dead : 1; /* device ejected hint */ 395 - unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ 396 - unsigned noprobe : 1; /* from: hdx=noprobe */ 397 - unsigned removable : 1; /* 1 if need to do check_media_change */ 398 - unsigned attach : 1; /* needed for removable devices */ 399 - unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */ 400 - unsigned no_unmask : 1; /* disallow setting unmask bit */ 401 - unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ 402 - unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ 403 - unsigned nodma : 1; /* disallow DMA */ 404 - unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ 405 - unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ 406 - unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ 407 - unsigned post_reset : 1; 408 - unsigned udma33_warned : 1; 409 - unsigned addressing : 2; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */ 410 - unsigned wcache : 1; /* status of write cache */ 411 - unsigned nowerr : 1; /* used for ignoring ATA_DF */ 412 - 413 - u8 quirk_list; /* considered quirky, set for a specific host */ 414 - u8 init_speed; /* transfer rate set at boot */ 415 - u8 current_speed; /* current transfer rate set */ 416 - u8 desired_speed; /* desired transfer rate set */ 417 - u8 dn; /* now wide spread use */ 418 - u8 acoustic; /* acoustic management */ 419 - u8 media; /* disk, cdrom, tape, floppy, ... */ 420 - u8 ready_stat; /* min status value for drive ready */ 421 - u8 mult_count; /* current multiple sector setting */ 422 - u8 mult_req; /* requested multiple sector setting */ 423 - u8 tune_req; /* requested drive tuning setting */ 424 - u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ 425 - u8 bad_wstat; /* used for ignoring ATA_DF */ 426 - u8 head; /* "real" number of heads */ 427 - u8 sect; /* "real" sectors per track */ 428 - u8 bios_head; /* BIOS/fdisk/LILO number of heads */ 429 - u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */ 430 - 431 - unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ 432 - unsigned int cyl; /* "real" number of cyls */ 433 - unsigned int drive_data; /* used by set_pio_mode/selectproc */ 434 - unsigned int failures; /* current failure count */ 435 - unsigned int max_failures; /* maximum allowed failure count */ 436 - u64 probed_capacity;/* initial reported media capacity (ide-cd only currently) */ 437 - 438 - u64 capacity64; /* total number of sectors */ 439 - 440 - int lun; /* logical unit */ 441 - int crc_count; /* crc counter to reduce drive speed */ 442 - #ifdef CONFIG_BLK_DEV_IDEACPI 443 - struct ide_acpi_drive_link *acpidata; 444 - #endif 445 - struct list_head list; 446 - struct device gendev; 447 - struct completion gendev_rel_comp; /* to deal with device release() */ 448 - 449 - /* callback for packet commands */ 450 - void (*pc_callback)(struct ide_drive_s *); 451 - 452 - unsigned long atapi_flags; 453 - }; 454 - 455 - typedef struct ide_drive_s ide_drive_t; 456 - 457 - #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) 458 - 459 - struct ide_task_s; 460 - struct ide_port_info; 461 - 462 - struct ide_tp_ops { 463 - void (*exec_command)(struct hwif_s *, u8); 464 - u8 (*read_status)(struct hwif_s *); 465 - u8 (*read_altstatus)(struct hwif_s *); 466 - u8 (*read_sff_dma_status)(struct hwif_s *); 467 - 468 - void (*set_irq)(struct hwif_s *, int); 469 - 470 - void (*tf_load)(ide_drive_t *, struct ide_task_s *); 471 - void (*tf_read)(ide_drive_t *, struct ide_task_s *); 472 - 473 - void (*input_data)(ide_drive_t *, struct request *, void *, 474 - unsigned int); 475 - void (*output_data)(ide_drive_t *, struct request *, void *, 476 - unsigned int); 477 - }; 478 - 479 - extern const struct ide_tp_ops default_tp_ops; 480 - 481 - /** 482 - * struct ide_port_ops - IDE port operations 483 - * 484 - * @init_dev: host specific initialization of a device 485 - * @set_pio_mode: routine to program host for PIO mode 486 - * @set_dma_mode: routine to program host for DMA mode 487 - * @selectproc: tweaks hardware to select drive 488 - * @reset_poll: chipset polling based on hba specifics 489 - * @pre_reset: chipset specific changes to default for device-hba resets 490 - * @resetproc: routine to reset controller after a disk reset 491 - * @maskproc: special host masking for drive selection 492 - * @quirkproc: check host's drive quirk list 493 - * 494 - * @mdma_filter: filter MDMA modes 495 - * @udma_filter: filter UDMA modes 496 - * 497 - * @cable_detect: detect cable type 498 - */ 499 - struct ide_port_ops { 500 - void (*init_dev)(ide_drive_t *); 501 - void (*set_pio_mode)(ide_drive_t *, const u8); 502 - void (*set_dma_mode)(ide_drive_t *, const u8); 503 - void (*selectproc)(ide_drive_t *); 504 - int (*reset_poll)(ide_drive_t *); 505 - void (*pre_reset)(ide_drive_t *); 506 - void (*resetproc)(ide_drive_t *); 507 - void (*maskproc)(ide_drive_t *, int); 508 - void (*quirkproc)(ide_drive_t *); 509 - 510 - u8 (*mdma_filter)(ide_drive_t *); 511 - u8 (*udma_filter)(ide_drive_t *); 512 - 513 - u8 (*cable_detect)(struct hwif_s *); 514 - }; 515 - 516 - struct ide_dma_ops { 517 - void (*dma_host_set)(struct ide_drive_s *, int); 518 - int (*dma_setup)(struct ide_drive_s *); 519 - void (*dma_exec_cmd)(struct ide_drive_s *, u8); 520 - void (*dma_start)(struct ide_drive_s *); 521 - int (*dma_end)(struct ide_drive_s *); 522 - int (*dma_test_irq)(struct ide_drive_s *); 523 - void (*dma_lost_irq)(struct ide_drive_s *); 524 - void (*dma_timeout)(struct ide_drive_s *); 525 - }; 526 - 527 - struct ide_host; 528 - 529 - typedef struct hwif_s { 530 - struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 531 - struct hwif_s *mate; /* other hwif from same PCI chip */ 532 - struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */ 533 - struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 534 - 535 - struct ide_host *host; 536 - 537 - char name[6]; /* name of interface, eg. "ide0" */ 538 - 539 - struct ide_io_ports io_ports; 540 - 541 - unsigned long sata_scr[SATA_NR_PORTS]; 542 - 543 - ide_drive_t drives[MAX_DRIVES]; /* drive info */ 544 - 545 - u8 major; /* our major number */ 546 - u8 index; /* 0 for ide0; 1 for ide1; ... */ 547 - u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ 548 - 549 - u32 host_flags; 550 - 551 - u8 pio_mask; 552 - 553 - u8 ultra_mask; 554 - u8 mwdma_mask; 555 - u8 swdma_mask; 556 - 557 - u8 cbl; /* cable type */ 558 - 559 - hwif_chipset_t chipset; /* sub-module for tuning.. */ 560 - 561 - struct device *dev; 562 - 563 - ide_ack_intr_t *ack_intr; 564 - 565 - void (*rw_disk)(ide_drive_t *, struct request *); 566 - 567 - const struct ide_tp_ops *tp_ops; 568 - const struct ide_port_ops *port_ops; 569 - const struct ide_dma_ops *dma_ops; 570 - 571 - void (*ide_dma_clear_irq)(ide_drive_t *drive); 572 - 573 - /* dma physical region descriptor table (cpu view) */ 574 - unsigned int *dmatable_cpu; 575 - /* dma physical region descriptor table (dma view) */ 576 - dma_addr_t dmatable_dma; 577 - /* Scatter-gather list used to build the above */ 578 - struct scatterlist *sg_table; 579 - int sg_max_nents; /* Maximum number of entries in it */ 580 - int sg_nents; /* Current number of entries in it */ 581 - int sg_dma_direction; /* dma transfer direction */ 582 - 583 - /* data phase of the active command (currently only valid for PIO/DMA) */ 584 - int data_phase; 585 - 586 - unsigned int nsect; 587 - unsigned int nleft; 588 - struct scatterlist *cursg; 589 - unsigned int cursg_ofs; 590 - 591 - int rqsize; /* max sectors per request */ 592 - int irq; /* our irq number */ 593 - 594 - unsigned long dma_base; /* base addr for dma ports */ 595 - 596 - unsigned long config_data; /* for use by chipset-specific code */ 597 - unsigned long select_data; /* for use by chipset-specific code */ 598 - 599 - unsigned long extra_base; /* extra addr for dma ports */ 600 - unsigned extra_ports; /* number of extra dma ports */ 601 - 602 - unsigned present : 1; /* this interface exists */ 603 - unsigned serialized : 1; /* serialized all channel operation */ 604 - unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ 605 - unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 606 - 607 - struct device gendev; 608 - struct device *portdev; 609 - 610 - struct completion gendev_rel_comp; /* To deal with device release() */ 611 - 612 - void *hwif_data; /* extra hwif data */ 613 - 614 - unsigned dma; 615 - 616 - #ifdef CONFIG_BLK_DEV_IDEACPI 617 - struct ide_acpi_hwif_link *acpidata; 618 - #endif 619 - } ____cacheline_internodealigned_in_smp ide_hwif_t; 620 - 621 - struct ide_host { 622 - ide_hwif_t *ports[MAX_HWIFS]; 623 - unsigned int n_ports; 624 - struct device *dev[2]; 625 - unsigned int (*init_chipset)(struct pci_dev *); 626 - unsigned long host_flags; 627 - void *host_priv; 628 - }; 629 - 630 - /* 631 - * internal ide interrupt handler type 632 - */ 633 - typedef ide_startstop_t (ide_handler_t)(ide_drive_t *); 634 - typedef int (ide_expiry_t)(ide_drive_t *); 635 - 636 - /* used by ide-cd, ide-floppy, etc. */ 637 - typedef void (xfer_func_t)(ide_drive_t *, struct request *rq, void *, unsigned); 638 - 639 - typedef struct hwgroup_s { 640 - /* irq handler, if active */ 641 - ide_startstop_t (*handler)(ide_drive_t *); 642 - 643 - /* BOOL: protects all fields below */ 644 - volatile int busy; 645 - /* BOOL: wake us up on timer expiry */ 646 - unsigned int sleeping : 1; 647 - /* BOOL: polling active & poll_timeout field valid */ 648 - unsigned int polling : 1; 649 - 650 - /* current drive */ 651 - ide_drive_t *drive; 652 - /* ptr to current hwif in linked-list */ 653 - ide_hwif_t *hwif; 654 - 655 - /* current request */ 656 - struct request *rq; 657 - 658 - /* failsafe timer */ 659 - struct timer_list timer; 660 - /* timeout value during long polls */ 661 - unsigned long poll_timeout; 662 - /* queried upon timeouts */ 663 - int (*expiry)(ide_drive_t *); 664 - 665 - int req_gen; 666 - int req_gen_timer; 667 - } ide_hwgroup_t; 668 - 669 - typedef struct ide_driver_s ide_driver_t; 670 - 671 - extern struct mutex ide_setting_mtx; 672 - 673 - /* 674 - * configurable drive settings 675 - */ 676 - 677 - #define DS_SYNC (1 << 0) 678 - 679 - struct ide_devset { 680 - int (*get)(ide_drive_t *); 681 - int (*set)(ide_drive_t *, int); 682 - unsigned int flags; 683 - }; 684 - 685 - #define __DEVSET(_flags, _get, _set) { \ 686 - .flags = _flags, \ 687 - .get = _get, \ 688 - .set = _set, \ 689 - } 690 - 691 - #define ide_devset_get(name, field) \ 692 - static int get_##name(ide_drive_t *drive) \ 693 - { \ 694 - return drive->field; \ 695 - } 696 - 697 - #define ide_devset_set(name, field) \ 698 - static int set_##name(ide_drive_t *drive, int arg) \ 699 - { \ 700 - drive->field = arg; \ 701 - return 0; \ 702 - } 703 - 704 - #define __IDE_DEVSET(_name, _flags, _get, _set) \ 705 - const struct ide_devset ide_devset_##_name = \ 706 - __DEVSET(_flags, _get, _set) 707 - 708 - #define IDE_DEVSET(_name, _flags, _get, _set) \ 709 - static __IDE_DEVSET(_name, _flags, _get, _set) 710 - 711 - #define ide_devset_rw(_name, _func) \ 712 - IDE_DEVSET(_name, 0, get_##_func, set_##_func) 713 - 714 - #define ide_devset_w(_name, _func) \ 715 - IDE_DEVSET(_name, 0, NULL, set_##_func) 716 - 717 - #define ide_devset_rw_sync(_name, _func) \ 718 - IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) 719 - 720 - #define ide_decl_devset(_name) \ 721 - extern const struct ide_devset ide_devset_##_name 722 - 723 - ide_decl_devset(io_32bit); 724 - ide_decl_devset(keepsettings); 725 - ide_decl_devset(pio_mode); 726 - ide_decl_devset(unmaskirq); 727 - ide_decl_devset(using_dma); 728 - 729 - /* ATAPI packet command flags */ 730 - enum { 731 - /* set when an error is considered normal - no retry (ide-tape) */ 732 - PC_FLAG_ABORT = (1 << 0), 733 - PC_FLAG_SUPPRESS_ERROR = (1 << 1), 734 - PC_FLAG_WAIT_FOR_DSC = (1 << 2), 735 - PC_FLAG_DMA_OK = (1 << 3), 736 - PC_FLAG_DMA_IN_PROGRESS = (1 << 4), 737 - PC_FLAG_DMA_ERROR = (1 << 5), 738 - PC_FLAG_WRITING = (1 << 6), 739 - /* command timed out */ 740 - PC_FLAG_TIMEDOUT = (1 << 7), 741 - }; 742 - 743 - /* 744 - * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes. 745 - * This is used for several packet commands (not for READ/WRITE commands). 746 - */ 747 - #define IDE_PC_BUFFER_SIZE 256 748 - 749 - struct ide_atapi_pc { 750 - /* actual packet bytes */ 751 - u8 c[12]; 752 - /* incremented on each retry */ 753 - int retries; 754 - int error; 755 - 756 - /* bytes to transfer */ 757 - int req_xfer; 758 - /* bytes actually transferred */ 759 - int xferred; 760 - 761 - /* data buffer */ 762 - u8 *buf; 763 - /* current buffer position */ 764 - u8 *cur_pos; 765 - int buf_size; 766 - /* missing/available data on the current buffer */ 767 - int b_count; 768 - 769 - /* the corresponding request */ 770 - struct request *rq; 771 - 772 - unsigned long flags; 773 - 774 - /* 775 - * those are more or less driver-specific and some of them are subject 776 - * to change/removal later. 777 - */ 778 - u8 pc_buf[IDE_PC_BUFFER_SIZE]; 779 - 780 - /* idetape only */ 781 - struct idetape_bh *bh; 782 - char *b_data; 783 - 784 - /* idescsi only for now */ 785 - struct scatterlist *sg; 786 - unsigned int sg_cnt; 787 - 788 - struct scsi_cmnd *scsi_cmd; 789 - void (*done) (struct scsi_cmnd *); 790 - 791 - unsigned long timeout; 792 - }; 793 - 794 - #ifdef CONFIG_IDE_PROC_FS 795 - /* 796 - * /proc/ide interface 797 - */ 798 - 799 - #define ide_devset_rw_field(_name, _field) \ 800 - ide_devset_get(_name, _field); \ 801 - ide_devset_set(_name, _field); \ 802 - IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 803 - 804 - struct ide_proc_devset { 805 - const char *name; 806 - const struct ide_devset *setting; 807 - int min, max; 808 - int (*mulf)(ide_drive_t *); 809 - int (*divf)(ide_drive_t *); 810 - }; 811 - 812 - #define __IDE_PROC_DEVSET(_name, _min, _max, _mulf, _divf) { \ 813 - .name = __stringify(_name), \ 814 - .setting = &ide_devset_##_name, \ 815 - .min = _min, \ 816 - .max = _max, \ 817 - .mulf = _mulf, \ 818 - .divf = _divf, \ 819 - } 820 - 821 - #define IDE_PROC_DEVSET(_name, _min, _max) \ 822 - __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL) 823 - 824 - typedef struct { 825 - const char *name; 826 - mode_t mode; 827 - read_proc_t *read_proc; 828 - write_proc_t *write_proc; 829 - } ide_proc_entry_t; 830 - 831 - void proc_ide_create(void); 832 - void proc_ide_destroy(void); 833 - void ide_proc_register_port(ide_hwif_t *); 834 - void ide_proc_port_register_devices(ide_hwif_t *); 835 - void ide_proc_unregister_device(ide_drive_t *); 836 - void ide_proc_unregister_port(ide_hwif_t *); 837 - void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); 838 - void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); 839 - 840 - read_proc_t proc_ide_read_capacity; 841 - read_proc_t proc_ide_read_geometry; 842 - 843 - /* 844 - * Standard exit stuff: 845 - */ 846 - #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) \ 847 - { \ 848 - len -= off; \ 849 - if (len < count) { \ 850 - *eof = 1; \ 851 - if (len <= 0) \ 852 - return 0; \ 853 - } else \ 854 - len = count; \ 855 - *start = page + off; \ 856 - return len; \ 857 - } 858 - #else 859 - static inline void proc_ide_create(void) { ; } 860 - static inline void proc_ide_destroy(void) { ; } 861 - static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; } 862 - static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; } 863 - static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } 864 - static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } 865 - static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 866 - static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 867 - #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; 868 - #endif 869 - 870 - /* 871 - * Power Management step value (rq->pm->pm_step). 872 - * 873 - * The step value starts at 0 (ide_pm_state_start_suspend) for a 874 - * suspend operation or 1000 (ide_pm_state_start_resume) for a 875 - * resume operation. 876 - * 877 - * For each step, the core calls the subdriver start_power_step() first. 878 - * This can return: 879 - * - ide_stopped : In this case, the core calls us back again unless 880 - * step have been set to ide_power_state_completed. 881 - * - ide_started : In this case, the channel is left busy until an 882 - * async event (interrupt) occurs. 883 - * Typically, start_power_step() will issue a taskfile request with 884 - * do_rw_taskfile(). 885 - * 886 - * Upon reception of the interrupt, the core will call complete_power_step() 887 - * with the error code if any. This routine should update the step value 888 - * and return. It should not start a new request. The core will call 889 - * start_power_step for the new step value, unless step have been set to 890 - * ide_power_state_completed. 891 - * 892 - * Subdrivers are expected to define their own additional power 893 - * steps from 1..999 for suspend and from 1001..1999 for resume, 894 - * other values are reserved for future use. 895 - */ 896 - 897 - enum { 898 - ide_pm_state_completed = -1, 899 - ide_pm_state_start_suspend = 0, 900 - ide_pm_state_start_resume = 1000, 901 - }; 902 - 903 - /* 904 - * Subdrivers support. 905 - * 906 - * The gendriver.owner field should be set to the module owner of this driver. 907 - * The gendriver.name field should be set to the name of this driver 908 - */ 909 - struct ide_driver_s { 910 - const char *version; 911 - u8 media; 912 - ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); 913 - int (*end_request)(ide_drive_t *, int, int); 914 - ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); 915 - struct device_driver gen_driver; 916 - int (*probe)(ide_drive_t *); 917 - void (*remove)(ide_drive_t *); 918 - void (*resume)(ide_drive_t *); 919 - void (*shutdown)(ide_drive_t *); 920 - #ifdef CONFIG_IDE_PROC_FS 921 - ide_proc_entry_t *proc; 922 - const struct ide_proc_devset *settings; 923 - #endif 924 - }; 925 - 926 - #define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver) 927 - 928 - int ide_device_get(ide_drive_t *); 929 - void ide_device_put(ide_drive_t *); 930 - 931 - struct ide_ioctl_devset { 932 - unsigned int get_ioctl; 933 - unsigned int set_ioctl; 934 - const struct ide_devset *setting; 935 - }; 936 - 937 - int ide_setting_ioctl(ide_drive_t *, struct block_device *, unsigned int, 938 - unsigned long, const struct ide_ioctl_devset *); 939 - 940 - int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, 941 - unsigned, unsigned long); 942 - 943 - extern int ide_vlb_clk; 944 - extern int ide_pci_clk; 945 - 946 - extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs); 947 - int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, 948 - int uptodate, int nr_sectors); 949 - 950 - extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry); 951 - 952 - void ide_execute_command(ide_drive_t *, u8, ide_handler_t *, unsigned int, 953 - ide_expiry_t *); 954 - 955 - void ide_execute_pkt_cmd(ide_drive_t *); 956 - 957 - void ide_pad_transfer(ide_drive_t *, int, int); 958 - 959 - ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); 960 - 961 - ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); 962 - 963 - void ide_fix_driveid(u16 *); 964 - 965 - extern void ide_fixstring(u8 *, const int, const int); 966 - 967 - int ide_busy_sleep(ide_hwif_t *, unsigned long, int); 968 - 969 - int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); 970 - 971 - extern ide_startstop_t ide_do_reset (ide_drive_t *); 972 - 973 - extern int ide_devset_execute(ide_drive_t *drive, 974 - const struct ide_devset *setting, int arg); 975 - 976 - extern void ide_do_drive_cmd(ide_drive_t *, struct request *); 977 - 978 - extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); 979 324 980 325 enum { 981 326 IDE_TFLAG_LBA48 = (1 << 0), ··· 388 1119 void *special; /* valid_t generally */ 389 1120 } ide_task_t; 390 1121 1122 + /* ATAPI packet command flags */ 1123 + enum { 1124 + /* set when an error is considered normal - no retry (ide-tape) */ 1125 + PC_FLAG_ABORT = (1 << 0), 1126 + PC_FLAG_SUPPRESS_ERROR = (1 << 1), 1127 + PC_FLAG_WAIT_FOR_DSC = (1 << 2), 1128 + PC_FLAG_DMA_OK = (1 << 3), 1129 + PC_FLAG_DMA_IN_PROGRESS = (1 << 4), 1130 + PC_FLAG_DMA_ERROR = (1 << 5), 1131 + PC_FLAG_WRITING = (1 << 6), 1132 + /* command timed out */ 1133 + PC_FLAG_TIMEDOUT = (1 << 7), 1134 + }; 1135 + 1136 + /* 1137 + * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes. 1138 + * This is used for several packet commands (not for READ/WRITE commands). 1139 + */ 1140 + #define IDE_PC_BUFFER_SIZE 256 1141 + 1142 + struct ide_atapi_pc { 1143 + /* actual packet bytes */ 1144 + u8 c[12]; 1145 + /* incremented on each retry */ 1146 + int retries; 1147 + int error; 1148 + 1149 + /* bytes to transfer */ 1150 + int req_xfer; 1151 + /* bytes actually transferred */ 1152 + int xferred; 1153 + 1154 + /* data buffer */ 1155 + u8 *buf; 1156 + /* current buffer position */ 1157 + u8 *cur_pos; 1158 + int buf_size; 1159 + /* missing/available data on the current buffer */ 1160 + int b_count; 1161 + 1162 + /* the corresponding request */ 1163 + struct request *rq; 1164 + 1165 + unsigned long flags; 1166 + 1167 + /* 1168 + * those are more or less driver-specific and some of them are subject 1169 + * to change/removal later. 1170 + */ 1171 + u8 pc_buf[IDE_PC_BUFFER_SIZE]; 1172 + 1173 + /* idetape only */ 1174 + struct idetape_bh *bh; 1175 + char *b_data; 1176 + 1177 + /* idescsi only for now */ 1178 + struct scatterlist *sg; 1179 + unsigned int sg_cnt; 1180 + 1181 + struct scsi_cmnd *scsi_cmd; 1182 + void (*done) (struct scsi_cmnd *); 1183 + 1184 + unsigned long timeout; 1185 + }; 1186 + 1187 + struct ide_devset; 1188 + struct ide_driver_s; 1189 + 1190 + #ifdef CONFIG_BLK_DEV_IDEACPI 1191 + struct ide_acpi_drive_link; 1192 + struct ide_acpi_hwif_link; 1193 + #endif 1194 + 1195 + /* ATAPI device flags */ 1196 + enum { 1197 + IDE_AFLAG_DRQ_INTERRUPT = (1 << 0), 1198 + IDE_AFLAG_MEDIA_CHANGED = (1 << 1), 1199 + /* Drive cannot lock the door. */ 1200 + IDE_AFLAG_NO_DOORLOCK = (1 << 2), 1201 + 1202 + /* ide-cd */ 1203 + /* Drive cannot eject the disc. */ 1204 + IDE_AFLAG_NO_EJECT = (1 << 3), 1205 + /* Drive is a pre ATAPI 1.2 drive. */ 1206 + IDE_AFLAG_PRE_ATAPI12 = (1 << 4), 1207 + /* TOC addresses are in BCD. */ 1208 + IDE_AFLAG_TOCADDR_AS_BCD = (1 << 5), 1209 + /* TOC track numbers are in BCD. */ 1210 + IDE_AFLAG_TOCTRACKS_AS_BCD = (1 << 6), 1211 + /* 1212 + * Drive does not provide data in multiples of SECTOR_SIZE 1213 + * when more than one interrupt is needed. 1214 + */ 1215 + IDE_AFLAG_LIMIT_NFRAMES = (1 << 7), 1216 + /* Seeking in progress. */ 1217 + IDE_AFLAG_SEEKING = (1 << 8), 1218 + /* Saved TOC information is current. */ 1219 + IDE_AFLAG_TOC_VALID = (1 << 9), 1220 + /* We think that the drive door is locked. */ 1221 + IDE_AFLAG_DOOR_LOCKED = (1 << 10), 1222 + /* SET_CD_SPEED command is unsupported. */ 1223 + IDE_AFLAG_NO_SPEED_SELECT = (1 << 11), 1224 + IDE_AFLAG_VERTOS_300_SSD = (1 << 12), 1225 + IDE_AFLAG_VERTOS_600_ESD = (1 << 13), 1226 + IDE_AFLAG_SANYO_3CD = (1 << 14), 1227 + IDE_AFLAG_FULL_CAPS_PAGE = (1 << 15), 1228 + IDE_AFLAG_PLAY_AUDIO_OK = (1 << 16), 1229 + IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17), 1230 + 1231 + /* ide-floppy */ 1232 + /* Format in progress */ 1233 + IDE_AFLAG_FORMAT_IN_PROGRESS = (1 << 18), 1234 + /* Avoid commands not supported in Clik drive */ 1235 + IDE_AFLAG_CLIK_DRIVE = (1 << 19), 1236 + /* Requires BH algorithm for packets */ 1237 + IDE_AFLAG_ZIP_DRIVE = (1 << 20), 1238 + /* Write protect */ 1239 + IDE_AFLAG_WP = (1 << 21), 1240 + /* Supports format progress report */ 1241 + IDE_AFLAG_SRFP = (1 << 22), 1242 + 1243 + /* ide-tape */ 1244 + IDE_AFLAG_IGNORE_DSC = (1 << 23), 1245 + /* 0 When the tape position is unknown */ 1246 + IDE_AFLAG_ADDRESS_VALID = (1 << 24), 1247 + /* Device already opened */ 1248 + IDE_AFLAG_BUSY = (1 << 25), 1249 + /* Attempt to auto-detect the current user block size */ 1250 + IDE_AFLAG_DETECT_BS = (1 << 26), 1251 + /* Currently on a filemark */ 1252 + IDE_AFLAG_FILEMARK = (1 << 27), 1253 + /* 0 = no tape is loaded, so we don't rewind after ejecting */ 1254 + IDE_AFLAG_MEDIUM_PRESENT = (1 << 28), 1255 + 1256 + IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), 1257 + }; 1258 + 1259 + /* device flags */ 1260 + enum { 1261 + /* restore settings after device reset */ 1262 + IDE_DFLAG_KEEP_SETTINGS = (1 << 0), 1263 + /* device is using DMA for read/write */ 1264 + IDE_DFLAG_USING_DMA = (1 << 1), 1265 + /* okay to unmask other IRQs */ 1266 + IDE_DFLAG_UNMASK = (1 << 2), 1267 + /* don't attempt flushes */ 1268 + IDE_DFLAG_NOFLUSH = (1 << 3), 1269 + /* DSC overlap */ 1270 + IDE_DFLAG_DSC_OVERLAP = (1 << 4), 1271 + /* give potential excess bandwidth */ 1272 + IDE_DFLAG_NICE1 = (1 << 5), 1273 + /* device is physically present */ 1274 + IDE_DFLAG_PRESENT = (1 << 6), 1275 + /* device ejected hint */ 1276 + IDE_DFLAG_DEAD = (1 << 7), 1277 + /* id read from device (synthetic if not set) */ 1278 + IDE_DFLAG_ID_READ = (1 << 8), 1279 + IDE_DFLAG_NOPROBE = (1 << 9), 1280 + /* need to do check_media_change() */ 1281 + IDE_DFLAG_REMOVABLE = (1 << 10), 1282 + /* needed for removable devices */ 1283 + IDE_DFLAG_ATTACH = (1 << 11), 1284 + IDE_DFLAG_FORCED_GEOM = (1 << 12), 1285 + /* disallow setting unmask bit */ 1286 + IDE_DFLAG_NO_UNMASK = (1 << 13), 1287 + /* disallow enabling 32-bit I/O */ 1288 + IDE_DFLAG_NO_IO_32BIT = (1 << 14), 1289 + /* for removable only: door lock/unlock works */ 1290 + IDE_DFLAG_DOORLOCKING = (1 << 15), 1291 + /* disallow DMA */ 1292 + IDE_DFLAG_NODMA = (1 << 16), 1293 + /* powermanagment told us not to do anything, so sleep nicely */ 1294 + IDE_DFLAG_BLOCKED = (1 << 17), 1295 + /* ide-scsi emulation */ 1296 + IDE_DFLAG_SCSI = (1 << 18), 1297 + /* sleeping & sleep field valid */ 1298 + IDE_DFLAG_SLEEPING = (1 << 19), 1299 + IDE_DFLAG_POST_RESET = (1 << 20), 1300 + IDE_DFLAG_UDMA33_WARNED = (1 << 21), 1301 + IDE_DFLAG_LBA48 = (1 << 22), 1302 + /* status of write cache */ 1303 + IDE_DFLAG_WCACHE = (1 << 23), 1304 + /* used for ignoring ATA_DF */ 1305 + IDE_DFLAG_NOWERR = (1 << 24), 1306 + /* retrying in PIO */ 1307 + IDE_DFLAG_DMA_PIO_RETRY = (1 << 25), 1308 + IDE_DFLAG_LBA = (1 << 26), 1309 + /* don't unload heads */ 1310 + IDE_DFLAG_NO_UNLOAD = (1 << 27), 1311 + /* heads unloaded, please don't reset port */ 1312 + IDE_DFLAG_PARKED = (1 << 28) 1313 + }; 1314 + 1315 + struct ide_drive_s { 1316 + char name[4]; /* drive name, such as "hda" */ 1317 + char driver_req[10]; /* requests specific driver */ 1318 + 1319 + struct request_queue *queue; /* request queue */ 1320 + 1321 + struct request *rq; /* current request */ 1322 + struct ide_drive_s *next; /* circular list of hwgroup drives */ 1323 + void *driver_data; /* extra driver data */ 1324 + u16 *id; /* identification info */ 1325 + #ifdef CONFIG_IDE_PROC_FS 1326 + struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 1327 + const struct ide_proc_devset *settings; /* /proc/ide/ drive settings */ 1328 + #endif 1329 + struct hwif_s *hwif; /* actually (ide_hwif_t *) */ 1330 + 1331 + unsigned long dev_flags; 1332 + 1333 + unsigned long sleep; /* sleep until this time */ 1334 + unsigned long service_start; /* time we started last request */ 1335 + unsigned long service_time; /* service time of last request */ 1336 + unsigned long timeout; /* max time to wait for irq */ 1337 + 1338 + special_t special; /* special action flags */ 1339 + 1340 + u8 select; /* basic drive/head select reg value */ 1341 + u8 retry_pio; /* retrying dma capable host in pio */ 1342 + u8 waiting_for_dma; /* dma currently in progress */ 1343 + u8 dma; /* atapi dma flag */ 1344 + 1345 + u8 quirk_list; /* considered quirky, set for a specific host */ 1346 + u8 init_speed; /* transfer rate set at boot */ 1347 + u8 current_speed; /* current transfer rate set */ 1348 + u8 desired_speed; /* desired transfer rate set */ 1349 + u8 dn; /* now wide spread use */ 1350 + u8 acoustic; /* acoustic management */ 1351 + u8 media; /* disk, cdrom, tape, floppy, ... */ 1352 + u8 ready_stat; /* min status value for drive ready */ 1353 + u8 mult_count; /* current multiple sector setting */ 1354 + u8 mult_req; /* requested multiple sector setting */ 1355 + u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ 1356 + u8 bad_wstat; /* used for ignoring ATA_DF */ 1357 + u8 head; /* "real" number of heads */ 1358 + u8 sect; /* "real" sectors per track */ 1359 + u8 bios_head; /* BIOS/fdisk/LILO number of heads */ 1360 + u8 bios_sect; /* BIOS/fdisk/LILO sectors per track */ 1361 + 1362 + /* delay this long before sending packet command */ 1363 + u8 pc_delay; 1364 + 1365 + unsigned int bios_cyl; /* BIOS/fdisk/LILO number of cyls */ 1366 + unsigned int cyl; /* "real" number of cyls */ 1367 + unsigned int drive_data; /* used by set_pio_mode/selectproc */ 1368 + unsigned int failures; /* current failure count */ 1369 + unsigned int max_failures; /* maximum allowed failure count */ 1370 + u64 probed_capacity;/* initial reported media capacity (ide-cd only currently) */ 1371 + 1372 + u64 capacity64; /* total number of sectors */ 1373 + 1374 + int lun; /* logical unit */ 1375 + int crc_count; /* crc counter to reduce drive speed */ 1376 + 1377 + unsigned long debug_mask; /* debugging levels switch */ 1378 + 1379 + #ifdef CONFIG_BLK_DEV_IDEACPI 1380 + struct ide_acpi_drive_link *acpidata; 1381 + #endif 1382 + struct list_head list; 1383 + struct device gendev; 1384 + struct completion gendev_rel_comp; /* to deal with device release() */ 1385 + 1386 + /* current packet command */ 1387 + struct ide_atapi_pc *pc; 1388 + 1389 + /* callback for packet commands */ 1390 + void (*pc_callback)(struct ide_drive_s *, int); 1391 + 1392 + void (*pc_update_buffers)(struct ide_drive_s *, struct ide_atapi_pc *); 1393 + int (*pc_io_buffers)(struct ide_drive_s *, struct ide_atapi_pc *, 1394 + unsigned int, int); 1395 + 1396 + unsigned long atapi_flags; 1397 + 1398 + struct ide_atapi_pc request_sense_pc; 1399 + struct request request_sense_rq; 1400 + }; 1401 + 1402 + typedef struct ide_drive_s ide_drive_t; 1403 + 1404 + #define to_ide_device(dev) container_of(dev, ide_drive_t, gendev) 1405 + 1406 + #define to_ide_drv(obj, cont_type) \ 1407 + container_of(obj, struct cont_type, kref) 1408 + 1409 + #define ide_drv_g(disk, cont_type) \ 1410 + container_of((disk)->private_data, struct cont_type, driver) 1411 + 1412 + struct ide_port_info; 1413 + 1414 + struct ide_tp_ops { 1415 + void (*exec_command)(struct hwif_s *, u8); 1416 + u8 (*read_status)(struct hwif_s *); 1417 + u8 (*read_altstatus)(struct hwif_s *); 1418 + u8 (*read_sff_dma_status)(struct hwif_s *); 1419 + 1420 + void (*set_irq)(struct hwif_s *, int); 1421 + 1422 + void (*tf_load)(ide_drive_t *, struct ide_task_s *); 1423 + void (*tf_read)(ide_drive_t *, struct ide_task_s *); 1424 + 1425 + void (*input_data)(ide_drive_t *, struct request *, void *, 1426 + unsigned int); 1427 + void (*output_data)(ide_drive_t *, struct request *, void *, 1428 + unsigned int); 1429 + }; 1430 + 1431 + extern const struct ide_tp_ops default_tp_ops; 1432 + 1433 + /** 1434 + * struct ide_port_ops - IDE port operations 1435 + * 1436 + * @init_dev: host specific initialization of a device 1437 + * @set_pio_mode: routine to program host for PIO mode 1438 + * @set_dma_mode: routine to program host for DMA mode 1439 + * @selectproc: tweaks hardware to select drive 1440 + * @reset_poll: chipset polling based on hba specifics 1441 + * @pre_reset: chipset specific changes to default for device-hba resets 1442 + * @resetproc: routine to reset controller after a disk reset 1443 + * @maskproc: special host masking for drive selection 1444 + * @quirkproc: check host's drive quirk list 1445 + * @clear_irq: clear IRQ 1446 + * 1447 + * @mdma_filter: filter MDMA modes 1448 + * @udma_filter: filter UDMA modes 1449 + * 1450 + * @cable_detect: detect cable type 1451 + */ 1452 + struct ide_port_ops { 1453 + void (*init_dev)(ide_drive_t *); 1454 + void (*set_pio_mode)(ide_drive_t *, const u8); 1455 + void (*set_dma_mode)(ide_drive_t *, const u8); 1456 + void (*selectproc)(ide_drive_t *); 1457 + int (*reset_poll)(ide_drive_t *); 1458 + void (*pre_reset)(ide_drive_t *); 1459 + void (*resetproc)(ide_drive_t *); 1460 + void (*maskproc)(ide_drive_t *, int); 1461 + void (*quirkproc)(ide_drive_t *); 1462 + void (*clear_irq)(ide_drive_t *); 1463 + 1464 + u8 (*mdma_filter)(ide_drive_t *); 1465 + u8 (*udma_filter)(ide_drive_t *); 1466 + 1467 + u8 (*cable_detect)(struct hwif_s *); 1468 + }; 1469 + 1470 + struct ide_dma_ops { 1471 + void (*dma_host_set)(struct ide_drive_s *, int); 1472 + int (*dma_setup)(struct ide_drive_s *); 1473 + void (*dma_exec_cmd)(struct ide_drive_s *, u8); 1474 + void (*dma_start)(struct ide_drive_s *); 1475 + int (*dma_end)(struct ide_drive_s *); 1476 + int (*dma_test_irq)(struct ide_drive_s *); 1477 + void (*dma_lost_irq)(struct ide_drive_s *); 1478 + void (*dma_timeout)(struct ide_drive_s *); 1479 + }; 1480 + 1481 + struct ide_host; 1482 + 1483 + typedef struct hwif_s { 1484 + struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 1485 + struct hwif_s *mate; /* other hwif from same PCI chip */ 1486 + struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */ 1487 + struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 1488 + 1489 + struct ide_host *host; 1490 + 1491 + char name[6]; /* name of interface, eg. "ide0" */ 1492 + 1493 + struct ide_io_ports io_ports; 1494 + 1495 + unsigned long sata_scr[SATA_NR_PORTS]; 1496 + 1497 + ide_drive_t drives[MAX_DRIVES]; /* drive info */ 1498 + 1499 + u8 major; /* our major number */ 1500 + u8 index; /* 0 for ide0; 1 for ide1; ... */ 1501 + u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ 1502 + 1503 + u32 host_flags; 1504 + 1505 + u8 pio_mask; 1506 + 1507 + u8 ultra_mask; 1508 + u8 mwdma_mask; 1509 + u8 swdma_mask; 1510 + 1511 + u8 cbl; /* cable type */ 1512 + 1513 + hwif_chipset_t chipset; /* sub-module for tuning.. */ 1514 + 1515 + struct device *dev; 1516 + 1517 + ide_ack_intr_t *ack_intr; 1518 + 1519 + void (*rw_disk)(ide_drive_t *, struct request *); 1520 + 1521 + const struct ide_tp_ops *tp_ops; 1522 + const struct ide_port_ops *port_ops; 1523 + const struct ide_dma_ops *dma_ops; 1524 + 1525 + /* dma physical region descriptor table (cpu view) */ 1526 + unsigned int *dmatable_cpu; 1527 + /* dma physical region descriptor table (dma view) */ 1528 + dma_addr_t dmatable_dma; 1529 + 1530 + /* maximum number of PRD table entries */ 1531 + int prd_max_nents; 1532 + /* PRD entry size in bytes */ 1533 + int prd_ent_size; 1534 + 1535 + /* Scatter-gather list used to build the above */ 1536 + struct scatterlist *sg_table; 1537 + int sg_max_nents; /* Maximum number of entries in it */ 1538 + int sg_nents; /* Current number of entries in it */ 1539 + int sg_dma_direction; /* dma transfer direction */ 1540 + 1541 + /* data phase of the active command (currently only valid for PIO/DMA) */ 1542 + int data_phase; 1543 + 1544 + struct ide_task_s task; /* current command */ 1545 + 1546 + unsigned int nsect; 1547 + unsigned int nleft; 1548 + struct scatterlist *cursg; 1549 + unsigned int cursg_ofs; 1550 + 1551 + int rqsize; /* max sectors per request */ 1552 + int irq; /* our irq number */ 1553 + 1554 + unsigned long dma_base; /* base addr for dma ports */ 1555 + 1556 + unsigned long config_data; /* for use by chipset-specific code */ 1557 + unsigned long select_data; /* for use by chipset-specific code */ 1558 + 1559 + unsigned long extra_base; /* extra addr for dma ports */ 1560 + unsigned extra_ports; /* number of extra dma ports */ 1561 + 1562 + unsigned present : 1; /* this interface exists */ 1563 + unsigned serialized : 1; /* serialized all channel operation */ 1564 + unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ 1565 + unsigned sg_mapped : 1; /* sg_table and sg_nents are ready */ 1566 + 1567 + struct device gendev; 1568 + struct device *portdev; 1569 + 1570 + struct completion gendev_rel_comp; /* To deal with device release() */ 1571 + 1572 + void *hwif_data; /* extra hwif data */ 1573 + 1574 + #ifdef CONFIG_BLK_DEV_IDEACPI 1575 + struct ide_acpi_hwif_link *acpidata; 1576 + #endif 1577 + } ____cacheline_internodealigned_in_smp ide_hwif_t; 1578 + 1579 + #define MAX_HOST_PORTS 4 1580 + 1581 + struct ide_host { 1582 + ide_hwif_t *ports[MAX_HOST_PORTS]; 1583 + unsigned int n_ports; 1584 + struct device *dev[2]; 1585 + unsigned int (*init_chipset)(struct pci_dev *); 1586 + unsigned long host_flags; 1587 + void *host_priv; 1588 + }; 1589 + 1590 + /* 1591 + * internal ide interrupt handler type 1592 + */ 1593 + typedef ide_startstop_t (ide_handler_t)(ide_drive_t *); 1594 + typedef int (ide_expiry_t)(ide_drive_t *); 1595 + 1596 + /* used by ide-cd, ide-floppy, etc. */ 1597 + typedef void (xfer_func_t)(ide_drive_t *, struct request *rq, void *, unsigned); 1598 + 1599 + typedef struct hwgroup_s { 1600 + /* irq handler, if active */ 1601 + ide_startstop_t (*handler)(ide_drive_t *); 1602 + 1603 + /* BOOL: protects all fields below */ 1604 + volatile int busy; 1605 + /* BOOL: wake us up on timer expiry */ 1606 + unsigned int sleeping : 1; 1607 + /* BOOL: polling active & poll_timeout field valid */ 1608 + unsigned int polling : 1; 1609 + 1610 + /* current drive */ 1611 + ide_drive_t *drive; 1612 + /* ptr to current hwif in linked-list */ 1613 + ide_hwif_t *hwif; 1614 + 1615 + /* current request */ 1616 + struct request *rq; 1617 + 1618 + /* failsafe timer */ 1619 + struct timer_list timer; 1620 + /* timeout value during long polls */ 1621 + unsigned long poll_timeout; 1622 + /* queried upon timeouts */ 1623 + int (*expiry)(ide_drive_t *); 1624 + 1625 + int req_gen; 1626 + int req_gen_timer; 1627 + } ide_hwgroup_t; 1628 + 1629 + typedef struct ide_driver_s ide_driver_t; 1630 + 1631 + extern struct mutex ide_setting_mtx; 1632 + 1633 + /* 1634 + * configurable drive settings 1635 + */ 1636 + 1637 + #define DS_SYNC (1 << 0) 1638 + 1639 + struct ide_devset { 1640 + int (*get)(ide_drive_t *); 1641 + int (*set)(ide_drive_t *, int); 1642 + unsigned int flags; 1643 + }; 1644 + 1645 + #define __DEVSET(_flags, _get, _set) { \ 1646 + .flags = _flags, \ 1647 + .get = _get, \ 1648 + .set = _set, \ 1649 + } 1650 + 1651 + #define ide_devset_get(name, field) \ 1652 + static int get_##name(ide_drive_t *drive) \ 1653 + { \ 1654 + return drive->field; \ 1655 + } 1656 + 1657 + #define ide_devset_set(name, field) \ 1658 + static int set_##name(ide_drive_t *drive, int arg) \ 1659 + { \ 1660 + drive->field = arg; \ 1661 + return 0; \ 1662 + } 1663 + 1664 + #define ide_devset_get_flag(name, flag) \ 1665 + static int get_##name(ide_drive_t *drive) \ 1666 + { \ 1667 + return !!(drive->dev_flags & flag); \ 1668 + } 1669 + 1670 + #define ide_devset_set_flag(name, flag) \ 1671 + static int set_##name(ide_drive_t *drive, int arg) \ 1672 + { \ 1673 + if (arg) \ 1674 + drive->dev_flags |= flag; \ 1675 + else \ 1676 + drive->dev_flags &= ~flag; \ 1677 + return 0; \ 1678 + } 1679 + 1680 + #define __IDE_DEVSET(_name, _flags, _get, _set) \ 1681 + const struct ide_devset ide_devset_##_name = \ 1682 + __DEVSET(_flags, _get, _set) 1683 + 1684 + #define IDE_DEVSET(_name, _flags, _get, _set) \ 1685 + static __IDE_DEVSET(_name, _flags, _get, _set) 1686 + 1687 + #define ide_devset_rw(_name, _func) \ 1688 + IDE_DEVSET(_name, 0, get_##_func, set_##_func) 1689 + 1690 + #define ide_devset_w(_name, _func) \ 1691 + IDE_DEVSET(_name, 0, NULL, set_##_func) 1692 + 1693 + #define ide_ext_devset_rw(_name, _func) \ 1694 + __IDE_DEVSET(_name, 0, get_##_func, set_##_func) 1695 + 1696 + #define ide_ext_devset_rw_sync(_name, _func) \ 1697 + __IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) 1698 + 1699 + #define ide_decl_devset(_name) \ 1700 + extern const struct ide_devset ide_devset_##_name 1701 + 1702 + ide_decl_devset(io_32bit); 1703 + ide_decl_devset(keepsettings); 1704 + ide_decl_devset(pio_mode); 1705 + ide_decl_devset(unmaskirq); 1706 + ide_decl_devset(using_dma); 1707 + 1708 + #ifdef CONFIG_IDE_PROC_FS 1709 + /* 1710 + * /proc/ide interface 1711 + */ 1712 + 1713 + #define ide_devset_rw_field(_name, _field) \ 1714 + ide_devset_get(_name, _field); \ 1715 + ide_devset_set(_name, _field); \ 1716 + IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 1717 + 1718 + #define ide_devset_rw_flag(_name, _field) \ 1719 + ide_devset_get_flag(_name, _field); \ 1720 + ide_devset_set_flag(_name, _field); \ 1721 + IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) 1722 + 1723 + struct ide_proc_devset { 1724 + const char *name; 1725 + const struct ide_devset *setting; 1726 + int min, max; 1727 + int (*mulf)(ide_drive_t *); 1728 + int (*divf)(ide_drive_t *); 1729 + }; 1730 + 1731 + #define __IDE_PROC_DEVSET(_name, _min, _max, _mulf, _divf) { \ 1732 + .name = __stringify(_name), \ 1733 + .setting = &ide_devset_##_name, \ 1734 + .min = _min, \ 1735 + .max = _max, \ 1736 + .mulf = _mulf, \ 1737 + .divf = _divf, \ 1738 + } 1739 + 1740 + #define IDE_PROC_DEVSET(_name, _min, _max) \ 1741 + __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL) 1742 + 1743 + typedef struct { 1744 + const char *name; 1745 + mode_t mode; 1746 + read_proc_t *read_proc; 1747 + write_proc_t *write_proc; 1748 + } ide_proc_entry_t; 1749 + 1750 + void proc_ide_create(void); 1751 + void proc_ide_destroy(void); 1752 + void ide_proc_register_port(ide_hwif_t *); 1753 + void ide_proc_port_register_devices(ide_hwif_t *); 1754 + void ide_proc_unregister_device(ide_drive_t *); 1755 + void ide_proc_unregister_port(ide_hwif_t *); 1756 + void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); 1757 + void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); 1758 + 1759 + read_proc_t proc_ide_read_capacity; 1760 + read_proc_t proc_ide_read_geometry; 1761 + 1762 + /* 1763 + * Standard exit stuff: 1764 + */ 1765 + #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) \ 1766 + { \ 1767 + len -= off; \ 1768 + if (len < count) { \ 1769 + *eof = 1; \ 1770 + if (len <= 0) \ 1771 + return 0; \ 1772 + } else \ 1773 + len = count; \ 1774 + *start = page + off; \ 1775 + return len; \ 1776 + } 1777 + #else 1778 + static inline void proc_ide_create(void) { ; } 1779 + static inline void proc_ide_destroy(void) { ; } 1780 + static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; } 1781 + static inline void ide_proc_port_register_devices(ide_hwif_t *hwif) { ; } 1782 + static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } 1783 + static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } 1784 + static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 1785 + static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 1786 + #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; 1787 + #endif 1788 + 1789 + enum { 1790 + /* enter/exit functions */ 1791 + IDE_DBG_FUNC = (1 << 0), 1792 + /* sense key/asc handling */ 1793 + IDE_DBG_SENSE = (1 << 1), 1794 + /* packet commands handling */ 1795 + IDE_DBG_PC = (1 << 2), 1796 + /* request handling */ 1797 + IDE_DBG_RQ = (1 << 3), 1798 + /* driver probing/setup */ 1799 + IDE_DBG_PROBE = (1 << 4), 1800 + }; 1801 + 1802 + /* DRV_NAME has to be defined in the driver before using the macro below */ 1803 + #define __ide_debug_log(lvl, fmt, args...) \ 1804 + { \ 1805 + if (unlikely(drive->debug_mask & lvl)) \ 1806 + printk(KERN_INFO DRV_NAME ": " fmt, ## args); \ 1807 + } 1808 + 1809 + /* 1810 + * Power Management state machine (rq->pm->pm_step). 1811 + * 1812 + * For each step, the core calls ide_start_power_step() first. 1813 + * This can return: 1814 + * - ide_stopped : In this case, the core calls us back again unless 1815 + * step have been set to ide_power_state_completed. 1816 + * - ide_started : In this case, the channel is left busy until an 1817 + * async event (interrupt) occurs. 1818 + * Typically, ide_start_power_step() will issue a taskfile request with 1819 + * do_rw_taskfile(). 1820 + * 1821 + * Upon reception of the interrupt, the core will call ide_complete_power_step() 1822 + * with the error code if any. This routine should update the step value 1823 + * and return. It should not start a new request. The core will call 1824 + * ide_start_power_step() for the new step value, unless step have been 1825 + * set to IDE_PM_COMPLETED. 1826 + */ 1827 + enum { 1828 + IDE_PM_START_SUSPEND, 1829 + IDE_PM_FLUSH_CACHE = IDE_PM_START_SUSPEND, 1830 + IDE_PM_STANDBY, 1831 + 1832 + IDE_PM_START_RESUME, 1833 + IDE_PM_RESTORE_PIO = IDE_PM_START_RESUME, 1834 + IDE_PM_IDLE, 1835 + IDE_PM_RESTORE_DMA, 1836 + 1837 + IDE_PM_COMPLETED, 1838 + }; 1839 + 1840 + /* 1841 + * Subdrivers support. 1842 + * 1843 + * The gendriver.owner field should be set to the module owner of this driver. 1844 + * The gendriver.name field should be set to the name of this driver 1845 + */ 1846 + struct ide_driver_s { 1847 + const char *version; 1848 + ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); 1849 + int (*end_request)(ide_drive_t *, int, int); 1850 + ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); 1851 + struct device_driver gen_driver; 1852 + int (*probe)(ide_drive_t *); 1853 + void (*remove)(ide_drive_t *); 1854 + void (*resume)(ide_drive_t *); 1855 + void (*shutdown)(ide_drive_t *); 1856 + #ifdef CONFIG_IDE_PROC_FS 1857 + ide_proc_entry_t *proc; 1858 + const struct ide_proc_devset *settings; 1859 + #endif 1860 + }; 1861 + 1862 + #define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver) 1863 + 1864 + int ide_device_get(ide_drive_t *); 1865 + void ide_device_put(ide_drive_t *); 1866 + 1867 + struct ide_ioctl_devset { 1868 + unsigned int get_ioctl; 1869 + unsigned int set_ioctl; 1870 + const struct ide_devset *setting; 1871 + }; 1872 + 1873 + int ide_setting_ioctl(ide_drive_t *, struct block_device *, unsigned int, 1874 + unsigned long, const struct ide_ioctl_devset *); 1875 + 1876 + int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, 1877 + unsigned, unsigned long); 1878 + 1879 + extern int ide_vlb_clk; 1880 + extern int ide_pci_clk; 1881 + 1882 + extern int ide_end_request (ide_drive_t *drive, int uptodate, int nrsecs); 1883 + int ide_end_dequeued_request(ide_drive_t *drive, struct request *rq, 1884 + int uptodate, int nr_sectors); 1885 + 1886 + extern void ide_set_handler (ide_drive_t *drive, ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry); 1887 + 1888 + void ide_execute_command(ide_drive_t *, u8, ide_handler_t *, unsigned int, 1889 + ide_expiry_t *); 1890 + 1891 + void ide_execute_pkt_cmd(ide_drive_t *); 1892 + 1893 + void ide_pad_transfer(ide_drive_t *, int, int); 1894 + 1895 + ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); 1896 + 1897 + ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); 1898 + 1899 + void ide_fix_driveid(u16 *); 1900 + 1901 + extern void ide_fixstring(u8 *, const int, const int); 1902 + 1903 + int ide_busy_sleep(ide_hwif_t *, unsigned long, int); 1904 + 1905 + int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); 1906 + 1907 + extern ide_startstop_t ide_do_reset (ide_drive_t *); 1908 + 1909 + extern int ide_devset_execute(ide_drive_t *drive, 1910 + const struct ide_devset *setting, int arg); 1911 + 1912 + extern void ide_do_drive_cmd(ide_drive_t *, struct request *); 1913 + 1914 + extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); 1915 + 391 1916 void ide_tf_dump(const char *, struct ide_taskfile *); 392 1917 393 1918 void ide_exec_command(ide_hwif_t *, u8); ··· 1213 1150 1214 1151 void ide_init_pc(struct ide_atapi_pc *); 1215 1152 1153 + /* Disk head parking */ 1154 + extern wait_queue_head_t ide_park_wq; 1155 + ssize_t ide_park_show(struct device *dev, struct device_attribute *attr, 1156 + char *buf); 1157 + ssize_t ide_park_store(struct device *dev, struct device_attribute *attr, 1158 + const char *buf, size_t len); 1159 + 1216 1160 /* 1217 1161 * Special requests for ide-tape block device strategy routine. 1218 1162 * ··· 1233 1163 REQ_IDETAPE_WRITE = (1 << 3), 1234 1164 }; 1235 1165 1236 - void ide_queue_pc_head(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *, 1237 - struct request *); 1238 1166 int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *); 1239 1167 1240 1168 int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *); 1241 1169 int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); 1242 1170 int ide_set_media_lock(ide_drive_t *, struct gendisk *, int); 1171 + void ide_create_request_sense_cmd(ide_drive_t *, struct ide_atapi_pc *); 1172 + void ide_retry_pc(ide_drive_t *, struct gendisk *); 1243 1173 1244 - ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, 1245 - ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, 1246 - void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), 1247 - void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), 1248 - int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, 1249 - int)); 1250 - ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, 1251 - ide_handler_t *, unsigned int, ide_expiry_t *); 1252 - ide_startstop_t ide_issue_pc(ide_drive_t *, struct ide_atapi_pc *, 1253 - ide_handler_t *, unsigned int, ide_expiry_t *); 1174 + static inline unsigned long ide_scsi_get_timeout(struct ide_atapi_pc *pc) 1175 + { 1176 + return max_t(unsigned long, WAIT_CMD, pc->timeout - jiffies); 1177 + } 1178 + 1179 + int ide_scsi_expiry(ide_drive_t *); 1180 + 1181 + ide_startstop_t ide_issue_pc(ide_drive_t *, unsigned int, ide_expiry_t *); 1254 1182 1255 1183 ide_startstop_t do_rw_taskfile(ide_drive_t *, ide_task_t *); 1256 1184 ··· 1426 1358 int ide_in_drive_list(u16 *, const struct drive_list_entry *); 1427 1359 1428 1360 #ifdef CONFIG_BLK_DEV_IDEDMA 1361 + int ide_dma_good_drive(ide_drive_t *); 1429 1362 int __ide_dma_bad_drive(ide_drive_t *); 1430 1363 int ide_id_dma_bug(ide_drive_t *); 1431 1364 ··· 1444 1375 void ide_check_dma_crc(ide_drive_t *); 1445 1376 ide_startstop_t ide_dma_intr(ide_drive_t *); 1446 1377 1378 + int ide_allocate_dma_engine(ide_hwif_t *); 1379 + void ide_release_dma_engine(ide_hwif_t *); 1380 + 1447 1381 int ide_build_sglist(ide_drive_t *, struct request *); 1448 1382 void ide_destroy_dmatable(ide_drive_t *); 1449 1383 1450 1384 #ifdef CONFIG_BLK_DEV_IDEDMA_SFF 1385 + int config_drive_for_dma(ide_drive_t *); 1451 1386 extern int ide_build_dmatable(ide_drive_t *, struct request *); 1452 - int ide_allocate_dma_engine(ide_hwif_t *); 1453 - void ide_release_dma_engine(ide_hwif_t *); 1454 - 1455 1387 void ide_dma_host_set(ide_drive_t *, int); 1456 1388 extern int ide_dma_setup(ide_drive_t *); 1457 1389 void ide_dma_exec_cmd(ide_drive_t *, u8); 1458 1390 extern void ide_dma_start(ide_drive_t *); 1459 - extern int __ide_dma_end(ide_drive_t *); 1391 + int ide_dma_end(ide_drive_t *); 1460 1392 int ide_dma_test_irq(ide_drive_t *); 1461 - extern void ide_dma_lost_irq(ide_drive_t *); 1462 - extern void ide_dma_timeout(ide_drive_t *); 1463 1393 extern const struct ide_dma_ops sff_dma_ops; 1394 + #else 1395 + static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } 1464 1396 #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ 1397 + 1398 + void ide_dma_lost_irq(ide_drive_t *); 1399 + void ide_dma_timeout(ide_drive_t *); 1465 1400 1466 1401 #else 1467 1402 static inline int ide_id_dma_bug(ide_drive_t *drive) { return 0; } ··· 1477 1404 static inline void ide_dma_verbose(ide_drive_t *drive) { ; } 1478 1405 static inline int ide_set_dma(ide_drive_t *drive) { return 1; } 1479 1406 static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } 1480 - #endif /* CONFIG_BLK_DEV_IDEDMA */ 1481 - 1482 - #ifndef CONFIG_BLK_DEV_IDEDMA_SFF 1483 1407 static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } 1484 - #endif 1408 + #endif /* CONFIG_BLK_DEV_IDEDMA */ 1485 1409 1486 1410 #ifdef CONFIG_BLK_DEV_IDEACPI 1487 1411 extern int ide_acpi_exec_tfs(ide_drive_t *drive); ··· 1506 1436 1507 1437 void ide_port_apply_params(ide_hwif_t *); 1508 1438 1509 - struct ide_host *ide_host_alloc_all(const struct ide_port_info *, hw_regs_t **); 1510 1439 struct ide_host *ide_host_alloc(const struct ide_port_info *, hw_regs_t **); 1511 1440 void ide_host_free(struct ide_host *); 1512 1441 int ide_host_register(struct ide_host *, const struct ide_port_info *, ··· 1616 1547 { 1617 1548 ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1]; 1618 1549 1619 - return peer->present ? peer : NULL; 1550 + return (peer->dev_flags & IDE_DFLAG_PRESENT) ? peer : NULL; 1620 1551 } 1621 1552 #endif /* _IDE_H */