diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-11 16:22:33 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-10-11 16:22:33 -0400 |
| commit | 5c3c4d9b5810c9aabd8c05219c62ca088aa83eb0 (patch) | |
| tree | f1122247e0b6d6269588702738df9c46061e280d | |
| parent | ead9d23d803ea3a73766c3cb27bf7563ac8d7266 (diff) | |
| parent | 92f1f8fd8040e7b50a67a850a935509bb01201bb (diff) | |
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: (71 commits)
ide: Remove ide_spin_wait_hwgroup() and use special requests instead
ide: move IDE{FLOPPY,TAPE}_WAIT_CMD defines to <linux/ide.h>
ide: add ide_do_test_unit_ready() helper
ide: add ide_do_start_stop() helper
ide: add ide_set_media_lock() helper
ide-floppy: move floppy ioctls handling to ide-floppy_ioctl.c
ide-floppy: ->{srfp,wp} -> IDE_AFLAG_{SRFP,WP}
ide: add ide_queue_pc_tail() helper
ide: add ide_queue_pc_head() helper
ide: add ide_init_pc() helper
ide-tape: add ide_tape_set_media_lock() helper
ide-floppy: add ide_floppy_set_media_lock() helper
ide: add ide_io_buffers() helper
ide-scsi: cleanup ide_scsi_io_buffers()
ide-floppy: remove MODE_SENSE_* defines
ide-{floppy,tape}: remove packet command stack
ide-{floppy,tape}: remove request stack
ide-generic: handle probing of legacy io-ports v5
ide-floppy: use scatterlists for pio transfers
ide-tape: remove idetape_init_rq()
...
75 files changed, 2388 insertions, 2566 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 59fe051957ef..5d312dc9be9f 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
| @@ -503,7 +503,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) | |||
| 503 | scsi_cmd[0] = ATA_16; | 503 | scsi_cmd[0] = ATA_16; |
| 504 | 504 | ||
| 505 | scsi_cmd[4] = args[2]; | 505 | scsi_cmd[4] = args[2]; |
| 506 | if (args[0] == WIN_SMART) { /* hack -- ide driver does this too... */ | 506 | if (args[0] == ATA_CMD_SMART) { /* hack -- ide driver does this too */ |
| 507 | scsi_cmd[6] = args[3]; | 507 | scsi_cmd[6] = args[3]; |
| 508 | scsi_cmd[8] = args[1]; | 508 | scsi_cmd[8] = args[1]; |
| 509 | scsi_cmd[10] = 0x4f; | 509 | scsi_cmd[10] = 0x4f; |
diff --git a/drivers/block/hd.c b/drivers/block/hd.c index 682243bf2e46..482c0c4b964f 100644 --- a/drivers/block/hd.c +++ b/drivers/block/hd.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include <linux/ioport.h> | 39 | #include <linux/ioport.h> |
| 40 | #include <linux/init.h> | 40 | #include <linux/init.h> |
| 41 | #include <linux/blkpg.h> | 41 | #include <linux/blkpg.h> |
| 42 | #include <linux/ata.h> | ||
| 42 | #include <linux/hdreg.h> | 43 | #include <linux/hdreg.h> |
| 43 | 44 | ||
| 44 | #define REALLY_SLOW_IO | 45 | #define REALLY_SLOW_IO |
| @@ -370,7 +371,7 @@ repeat: | |||
| 370 | struct hd_i_struct *disk = &hd_info[i]; | 371 | struct hd_i_struct *disk = &hd_info[i]; |
| 371 | disk->special_op = disk->recalibrate = 1; | 372 | disk->special_op = disk->recalibrate = 1; |
| 372 | hd_out(disk, disk->sect, disk->sect, disk->head-1, | 373 | hd_out(disk, disk->sect, disk->sect, disk->head-1, |
| 373 | disk->cyl, WIN_SPECIFY, &reset_hd); | 374 | disk->cyl, ATA_CMD_INIT_DEV_PARAMS, &reset_hd); |
| 374 | if (reset) | 375 | if (reset) |
| 375 | goto repeat; | 376 | goto repeat; |
| 376 | } else | 377 | } else |
| @@ -558,7 +559,7 @@ static int do_special_op(struct hd_i_struct *disk, struct request *req) | |||
| 558 | { | 559 | { |
| 559 | if (disk->recalibrate) { | 560 | if (disk->recalibrate) { |
| 560 | disk->recalibrate = 0; | 561 | disk->recalibrate = 0; |
| 561 | hd_out(disk, disk->sect, 0, 0, 0, WIN_RESTORE, &recal_intr); | 562 | hd_out(disk, disk->sect, 0, 0, 0, ATA_CMD_RESTORE, &recal_intr); |
| 562 | return reset; | 563 | return reset; |
| 563 | } | 564 | } |
| 564 | if (disk->head > 16) { | 565 | if (disk->head > 16) { |
| @@ -631,13 +632,13 @@ repeat: | |||
| 631 | if (blk_fs_request(req)) { | 632 | if (blk_fs_request(req)) { |
| 632 | switch (rq_data_dir(req)) { | 633 | switch (rq_data_dir(req)) { |
| 633 | case READ: | 634 | case READ: |
| 634 | hd_out(disk, nsect, sec, head, cyl, WIN_READ, | 635 | hd_out(disk, nsect, sec, head, cyl, ATA_CMD_PIO_READ, |
| 635 | &read_intr); | 636 | &read_intr); |
| 636 | if (reset) | 637 | if (reset) |
| 637 | goto repeat; | 638 | goto repeat; |
| 638 | break; | 639 | break; |
| 639 | case WRITE: | 640 | case WRITE: |
| 640 | hd_out(disk, nsect, sec, head, cyl, WIN_WRITE, | 641 | hd_out(disk, nsect, sec, head, cyl, ATA_CMD_PIO_WRITE, |
| 641 | &write_intr); | 642 | &write_intr); |
| 642 | if (reset) | 643 | if (reset) |
| 643 | goto repeat; | 644 | goto repeat; |
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 052879a6f853..b50b5dac95b0 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
| @@ -131,29 +131,6 @@ config BLK_DEV_IDEDISK | |||
| 131 | 131 | ||
| 132 | If unsure, say Y. | 132 | If unsure, say Y. |
| 133 | 133 | ||
| 134 | config IDEDISK_MULTI_MODE | ||
| 135 | bool "Use multiple sector mode for Programmed Input/Output by default" | ||
| 136 | help | ||
| 137 | This setting is irrelevant for most IDE disks, with direct memory | ||
| 138 | access, to which multiple sector mode does not apply. Multiple sector | ||
| 139 | mode is a feature of most modern IDE hard drives, permitting the | ||
| 140 | transfer of multiple sectors per Programmed Input/Output interrupt, | ||
| 141 | rather than the usual one sector per interrupt. When this feature is | ||
| 142 | enabled, it can reduce operating system overhead for disk Programmed | ||
| 143 | Input/Output. On some systems, it also can increase the data | ||
| 144 | throughput of Programmed Input/Output. Some drives, however, seemed | ||
| 145 | to run slower with multiple sector mode enabled. Some drives claimed | ||
| 146 | to support multiple sector mode, but lost data at some settings. | ||
| 147 | Under rare circumstances, such failures could result in massive | ||
| 148 | filesystem corruption. | ||
| 149 | |||
| 150 | If you get the following error, try to say Y here: | ||
| 151 | |||
| 152 | hda: set_multmode: status=0x51 { DriveReady SeekComplete Error } | ||
| 153 | hda: set_multmode: error=0x04 { DriveStatusError } | ||
| 154 | |||
| 155 | If in doubt, say N. | ||
| 156 | |||
| 157 | config BLK_DEV_IDECS | 134 | config BLK_DEV_IDECS |
| 158 | tristate "PCMCIA IDE support" | 135 | tristate "PCMCIA IDE support" |
| 159 | depends on PCMCIA | 136 | depends on PCMCIA |
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile index 64e0ecdc4ed5..308b8a12f314 100644 --- a/drivers/ide/Makefile +++ b/drivers/ide/Makefile | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | EXTRA_CFLAGS += -Idrivers/ide | 5 | EXTRA_CFLAGS += -Idrivers/ide |
| 6 | 6 | ||
| 7 | ide-core-y += ide.o ide-io.o ide-iops.o ide-lib.o ide-probe.o ide-taskfile.o \ | 7 | ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ |
| 8 | ide-pio-blacklist.o | 8 | ide-taskfile.o ide-pio-blacklist.o |
| 9 | 9 | ||
| 10 | # core IDE code | 10 | # core IDE code |
| 11 | ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o | 11 | ide-core-$(CONFIG_IDE_TIMINGS) += ide-timings.o |
| @@ -37,11 +37,12 @@ obj-$(CONFIG_IDE_GENERIC) += ide-generic.o | |||
| 37 | obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o | 37 | obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o |
| 38 | 38 | ||
| 39 | ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o | 39 | ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o |
| 40 | ide-floppy_mod-y += ide-floppy.o ide-floppy_ioctl.o | ||
| 40 | 41 | ||
| 41 | obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o | 42 | obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o |
| 42 | obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o | 43 | obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o |
| 44 | obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy_mod.o | ||
| 43 | obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o | 45 | obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o |
| 44 | obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o | ||
| 45 | 46 | ||
| 46 | ifeq ($(CONFIG_BLK_DEV_IDECS), y) | 47 | ifeq ($(CONFIG_BLK_DEV_IDECS), y) |
| 47 | ide-cs-core-y += legacy/ide-cs.o | 48 | ide-cs-core-y += legacy/ide-cs.o |
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c index df4af4083954..70f5b164828b 100644 --- a/drivers/ide/arm/icside.c +++ b/drivers/ide/arm/icside.c | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | #include <linux/slab.h> | 10 | #include <linux/slab.h> |
| 11 | #include <linux/blkdev.h> | 11 | #include <linux/blkdev.h> |
| 12 | #include <linux/errno.h> | 12 | #include <linux/errno.h> |
| 13 | #include <linux/hdreg.h> | ||
| 14 | #include <linux/ide.h> | 13 | #include <linux/ide.h> |
| 15 | #include <linux/dma-mapping.h> | 14 | #include <linux/dma-mapping.h> |
| 16 | #include <linux/device.h> | 15 | #include <linux/device.h> |
| @@ -265,8 +264,8 @@ static void icside_set_dma_mode(ide_drive_t *drive, const u8 xfer_mode) | |||
| 265 | * If we're going to be doing MW_DMA_1 or MW_DMA_2, we should | 264 | * If we're going to be doing MW_DMA_1 or MW_DMA_2, we should |
| 266 | * take care to note the values in the ID... | 265 | * take care to note the values in the ID... |
| 267 | */ | 266 | */ |
| 268 | if (use_dma_info && drive->id->eide_dma_time > cycle_time) | 267 | if (use_dma_info && drive->id[ATA_ID_EIDE_DMA_TIME] > cycle_time) |
| 269 | cycle_time = drive->id->eide_dma_time; | 268 | cycle_time = drive->id[ATA_ID_EIDE_DMA_TIME]; |
| 270 | 269 | ||
| 271 | drive->drive_data = cycle_time; | 270 | drive->drive_data = cycle_time; |
| 272 | 271 | ||
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c index 4fd91dcf1dc2..122ed3c072fd 100644 --- a/drivers/ide/arm/palm_bk3710.c +++ b/drivers/ide/arm/palm_bk3710.c | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
| 28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
| 29 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
| 30 | #include <linux/hdreg.h> | ||
| 31 | #include <linux/ide.h> | 30 | #include <linux/ide.h> |
| 32 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
| 33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
| @@ -180,7 +179,7 @@ static void palm_bk3710_setpiomode(void __iomem *base, ide_drive_t *mate, | |||
| 180 | val32 |= (t2i << (dev ? 8 : 0)); | 179 | val32 |= (t2i << (dev ? 8 : 0)); |
| 181 | writel(val32, base + BK3710_DATRCVR); | 180 | writel(val32, base + BK3710_DATRCVR); |
| 182 | 181 | ||
| 183 | if (mate && mate->present) { | 182 | if (mate) { |
| 184 | u8 mode2 = ide_get_best_pio_mode(mate, 255, 4); | 183 | u8 mode2 = ide_get_best_pio_mode(mate, 255, 4); |
| 185 | 184 | ||
| 186 | if (mode2 < mode) | 185 | if (mode2 < mode) |
| @@ -213,7 +212,8 @@ static void palm_bk3710_set_dma_mode(ide_drive_t *drive, u8 xferspeed) | |||
| 213 | palm_bk3710_setudmamode(base, is_slave, | 212 | palm_bk3710_setudmamode(base, is_slave, |
| 214 | xferspeed - XFER_UDMA_0); | 213 | xferspeed - XFER_UDMA_0); |
| 215 | } else { | 214 | } else { |
| 216 | palm_bk3710_setdmamode(base, is_slave, drive->id->eide_dma_min, | 215 | palm_bk3710_setdmamode(base, is_slave, |
| 216 | drive->id[ATA_ID_EIDE_DMA_MIN], | ||
| 217 | xferspeed); | 217 | xferspeed); |
| 218 | } | 218 | } |
| 219 | } | 219 | } |
| @@ -229,7 +229,7 @@ static void palm_bk3710_set_pio_mode(ide_drive_t *drive, u8 pio) | |||
| 229 | * Obtain the drive PIO data for tuning the Palm Chip registers | 229 | * Obtain the drive PIO data for tuning the Palm Chip registers |
| 230 | */ | 230 | */ |
| 231 | cycle_time = ide_pio_cycle_time(drive, pio); | 231 | cycle_time = ide_pio_cycle_time(drive, pio); |
| 232 | mate = ide_get_paired_drive(drive); | 232 | mate = ide_get_pair_dev(drive); |
| 233 | palm_bk3710_setpiomode(base, mate, is_slave, cycle_time, pio); | 233 | palm_bk3710_setpiomode(base, mate, is_slave, cycle_time, pio); |
| 234 | } | 234 | } |
| 235 | 235 | ||
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c index 6f704628c27d..2427c380b3dc 100644 --- a/drivers/ide/ide-acpi.c +++ b/drivers/ide/ide-acpi.c | |||
| @@ -584,7 +584,7 @@ void ide_acpi_get_timing(ide_hwif_t *hwif) | |||
| 584 | * This function executes the _STM ACPI method for the target channel. | 584 | * This function executes the _STM ACPI method for the target channel. |
| 585 | * | 585 | * |
| 586 | * _STM requires Identify Drive data, which has to passed as an argument. | 586 | * _STM requires Identify Drive data, which has to passed as an argument. |
| 587 | * Unfortunately hd_driveid is a mangled version which we can't readily | 587 | * Unfortunately drive->id is a mangled version which we can't readily |
| 588 | * use; hence we'll get the information afresh. | 588 | * use; hence we'll get the information afresh. |
| 589 | */ | 589 | */ |
| 590 | void ide_acpi_push_timing(ide_hwif_t *hwif) | 590 | void ide_acpi_push_timing(ide_hwif_t *hwif) |
| @@ -614,10 +614,10 @@ void ide_acpi_push_timing(ide_hwif_t *hwif) | |||
| 614 | in_params[0].buffer.length = sizeof(struct GTM_buffer); | 614 | in_params[0].buffer.length = sizeof(struct GTM_buffer); |
| 615 | in_params[0].buffer.pointer = (u8 *)&hwif->acpidata->gtm; | 615 | in_params[0].buffer.pointer = (u8 *)&hwif->acpidata->gtm; |
| 616 | in_params[1].type = ACPI_TYPE_BUFFER; | 616 | in_params[1].type = ACPI_TYPE_BUFFER; |
| 617 | in_params[1].buffer.length = sizeof(struct hd_driveid); | 617 | in_params[1].buffer.length = sizeof(ATA_ID_WORDS * 2); |
| 618 | in_params[1].buffer.pointer = (u8 *)&master->idbuff; | 618 | in_params[1].buffer.pointer = (u8 *)&master->idbuff; |
| 619 | in_params[2].type = ACPI_TYPE_BUFFER; | 619 | in_params[2].type = ACPI_TYPE_BUFFER; |
| 620 | in_params[2].buffer.length = sizeof(struct hd_driveid); | 620 | in_params[2].buffer.length = sizeof(ATA_ID_WORDS * 2); |
| 621 | in_params[2].buffer.pointer = (u8 *)&slave->idbuff; | 621 | in_params[2].buffer.pointer = (u8 *)&slave->idbuff; |
| 622 | /* Output buffer: _STM has no output */ | 622 | /* Output buffer: _STM has no output */ |
| 623 | 623 | ||
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index adf04f99cdeb..608c5bade929 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c | |||
| @@ -14,12 +14,201 @@ | |||
| 14 | #define debug_log(fmt, args...) do {} while (0) | 14 | #define debug_log(fmt, args...) do {} while (0) |
| 15 | #endif | 15 | #endif |
| 16 | 16 | ||
| 17 | /* | ||
| 18 | * Check whether we can support a device, | ||
| 19 | * based on the ATAPI IDENTIFY command results. | ||
| 20 | */ | ||
| 21 | int ide_check_atapi_device(ide_drive_t *drive, const char *s) | ||
| 22 | { | ||
| 23 | u16 *id = drive->id; | ||
| 24 | u8 gcw[2], protocol, device_type, removable, drq_type, packet_size; | ||
| 25 | |||
| 26 | *((u16 *)&gcw) = id[ATA_ID_CONFIG]; | ||
| 27 | |||
| 28 | protocol = (gcw[1] & 0xC0) >> 6; | ||
| 29 | device_type = gcw[1] & 0x1F; | ||
| 30 | removable = (gcw[0] & 0x80) >> 7; | ||
| 31 | drq_type = (gcw[0] & 0x60) >> 5; | ||
| 32 | packet_size = gcw[0] & 0x03; | ||
| 33 | |||
| 34 | #ifdef CONFIG_PPC | ||
| 35 | /* kludge for Apple PowerBook internal zip */ | ||
| 36 | if (drive->media == ide_floppy && device_type == 5 && | ||
| 37 | !strstr((char *)&id[ATA_ID_PROD], "CD-ROM") && | ||
| 38 | strstr((char *)&id[ATA_ID_PROD], "ZIP")) | ||
| 39 | device_type = 0; | ||
| 40 | #endif | ||
| 41 | |||
| 42 | if (protocol != 2) | ||
| 43 | printk(KERN_ERR "%s: %s: protocol (0x%02x) is not ATAPI\n", | ||
| 44 | s, drive->name, protocol); | ||
| 45 | else if ((drive->media == ide_floppy && device_type != 0) || | ||
| 46 | (drive->media == ide_tape && device_type != 1)) | ||
| 47 | printk(KERN_ERR "%s: %s: invalid device type (0x%02x)\n", | ||
| 48 | s, drive->name, device_type); | ||
| 49 | else if (removable == 0) | ||
| 50 | printk(KERN_ERR "%s: %s: the removable flag is not set\n", | ||
| 51 | s, drive->name); | ||
| 52 | else if (drive->media == ide_floppy && drq_type == 3) | ||
| 53 | printk(KERN_ERR "%s: %s: sorry, DRQ type (0x%02x) not " | ||
| 54 | "supported\n", s, drive->name, drq_type); | ||
| 55 | else if (packet_size != 0) | ||
| 56 | printk(KERN_ERR "%s: %s: packet size (0x%02x) is not 12 " | ||
| 57 | "bytes\n", s, drive->name, packet_size); | ||
| 58 | else | ||
| 59 | return 1; | ||
| 60 | return 0; | ||
| 61 | } | ||
| 62 | EXPORT_SYMBOL_GPL(ide_check_atapi_device); | ||
| 63 | |||
| 64 | /* PIO data transfer routine using the scatter gather table. */ | ||
| 65 | int ide_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
| 66 | unsigned int bcount, int write) | ||
| 67 | { | ||
| 68 | ide_hwif_t *hwif = drive->hwif; | ||
| 69 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
| 70 | xfer_func_t *xf = write ? tp_ops->output_data : tp_ops->input_data; | ||
| 71 | struct scatterlist *sg = pc->sg; | ||
| 72 | char *buf; | ||
| 73 | int count, done = 0; | ||
| 74 | |||
| 75 | while (bcount) { | ||
| 76 | count = min(sg->length - pc->b_count, bcount); | ||
| 77 | |||
| 78 | if (PageHighMem(sg_page(sg))) { | ||
| 79 | unsigned long flags; | ||
| 80 | |||
| 81 | local_irq_save(flags); | ||
| 82 | buf = kmap_atomic(sg_page(sg), KM_IRQ0) + sg->offset; | ||
| 83 | xf(drive, NULL, buf + pc->b_count, count); | ||
| 84 | kunmap_atomic(buf - sg->offset, KM_IRQ0); | ||
| 85 | local_irq_restore(flags); | ||
| 86 | } else { | ||
| 87 | buf = sg_virt(sg); | ||
| 88 | xf(drive, NULL, buf + pc->b_count, count); | ||
| 89 | } | ||
| 90 | |||
| 91 | bcount -= count; | ||
| 92 | pc->b_count += count; | ||
| 93 | done += count; | ||
| 94 | |||
| 95 | if (pc->b_count == sg->length) { | ||
| 96 | if (!--pc->sg_cnt) | ||
| 97 | break; | ||
| 98 | pc->sg = sg = sg_next(sg); | ||
| 99 | pc->b_count = 0; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 103 | if (bcount) { | ||
| 104 | printk(KERN_ERR "%s: %d leftover bytes, %s\n", drive->name, | ||
| 105 | bcount, write ? "padding with zeros" | ||
| 106 | : "discarding data"); | ||
| 107 | ide_pad_transfer(drive, write, bcount); | ||
| 108 | } | ||
| 109 | |||
| 110 | return done; | ||
| 111 | } | ||
| 112 | EXPORT_SYMBOL_GPL(ide_io_buffers); | ||
| 113 | |||
| 114 | void ide_init_pc(struct ide_atapi_pc *pc) | ||
| 115 | { | ||
| 116 | memset(pc, 0, sizeof(*pc)); | ||
| 117 | pc->buf = pc->pc_buf; | ||
| 118 | pc->buf_size = IDE_PC_BUFFER_SIZE; | ||
| 119 | } | ||
| 120 | EXPORT_SYMBOL_GPL(ide_init_pc); | ||
| 121 | |||
| 122 | /* | ||
| 123 | * Generate a new packet command request in front of the request queue, before | ||
| 124 | * the current request, so that it will be processed immediately, on the next | ||
| 125 | * pass through the driver. | ||
| 126 | */ | ||
| 127 | void ide_queue_pc_head(ide_drive_t *drive, struct gendisk *disk, | ||
| 128 | struct ide_atapi_pc *pc, struct request *rq) | ||
| 129 | { | ||
| 130 | blk_rq_init(NULL, rq); | ||
| 131 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
| 132 | rq->cmd_flags |= REQ_PREEMPT; | ||
| 133 | rq->buffer = (char *)pc; | ||
| 134 | rq->rq_disk = disk; | ||
| 135 | memcpy(rq->cmd, pc->c, 12); | ||
| 136 | if (drive->media == ide_tape) | ||
| 137 | rq->cmd[13] = REQ_IDETAPE_PC1; | ||
| 138 | ide_do_drive_cmd(drive, rq); | ||
| 139 | } | ||
| 140 | EXPORT_SYMBOL_GPL(ide_queue_pc_head); | ||
| 141 | |||
| 142 | /* | ||
| 143 | * Add a special packet command request to the tail of the request queue, | ||
| 144 | * and wait for it to be serviced. | ||
| 145 | */ | ||
| 146 | int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk, | ||
| 147 | struct ide_atapi_pc *pc) | ||
| 148 | { | ||
| 149 | struct request *rq; | ||
| 150 | int error; | ||
| 151 | |||
| 152 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | ||
| 153 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
| 154 | rq->buffer = (char *)pc; | ||
| 155 | memcpy(rq->cmd, pc->c, 12); | ||
| 156 | if (drive->media == ide_tape) | ||
| 157 | rq->cmd[13] = REQ_IDETAPE_PC1; | ||
| 158 | error = blk_execute_rq(drive->queue, disk, rq, 0); | ||
| 159 | blk_put_request(rq); | ||
| 160 | |||
| 161 | return error; | ||
| 162 | } | ||
| 163 | EXPORT_SYMBOL_GPL(ide_queue_pc_tail); | ||
| 164 | |||
| 165 | int ide_do_test_unit_ready(ide_drive_t *drive, struct gendisk *disk) | ||
| 166 | { | ||
| 167 | struct ide_atapi_pc pc; | ||
| 168 | |||
| 169 | ide_init_pc(&pc); | ||
| 170 | pc.c[0] = TEST_UNIT_READY; | ||
| 171 | |||
| 172 | return ide_queue_pc_tail(drive, disk, &pc); | ||
| 173 | } | ||
| 174 | EXPORT_SYMBOL_GPL(ide_do_test_unit_ready); | ||
| 175 | |||
| 176 | int ide_do_start_stop(ide_drive_t *drive, struct gendisk *disk, int start) | ||
| 177 | { | ||
| 178 | struct ide_atapi_pc pc; | ||
| 179 | |||
| 180 | ide_init_pc(&pc); | ||
| 181 | pc.c[0] = START_STOP; | ||
| 182 | pc.c[4] = start; | ||
| 183 | |||
| 184 | if (drive->media == ide_tape) | ||
| 185 | pc.flags |= PC_FLAG_WAIT_FOR_DSC; | ||
| 186 | |||
| 187 | return ide_queue_pc_tail(drive, disk, &pc); | ||
| 188 | } | ||
| 189 | EXPORT_SYMBOL_GPL(ide_do_start_stop); | ||
| 190 | |||
| 191 | int ide_set_media_lock(ide_drive_t *drive, struct gendisk *disk, int on) | ||
| 192 | { | ||
| 193 | struct ide_atapi_pc pc; | ||
| 194 | |||
| 195 | if (drive->atapi_flags & IDE_AFLAG_NO_DOORLOCK) | ||
| 196 | return 0; | ||
| 197 | |||
| 198 | ide_init_pc(&pc); | ||
| 199 | pc.c[0] = ALLOW_MEDIUM_REMOVAL; | ||
| 200 | pc.c[4] = on; | ||
| 201 | |||
| 202 | return ide_queue_pc_tail(drive, disk, &pc); | ||
| 203 | } | ||
| 204 | EXPORT_SYMBOL_GPL(ide_set_media_lock); | ||
| 205 | |||
| 17 | /* TODO: unify the code thus making some arguments go away */ | 206 | /* TODO: unify the code thus making some arguments go away */ |
| 18 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | 207 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, |
| 19 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | 208 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, |
| 20 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | 209 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), |
| 21 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), | 210 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), |
| 22 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) | 211 | int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned, int)) |
| 23 | { | 212 | { |
| 24 | ide_hwif_t *hwif = drive->hwif; | 213 | ide_hwif_t *hwif = drive->hwif; |
| 25 | struct request *rq = hwif->hwgroup->rq; | 214 | struct request *rq = hwif->hwgroup->rq; |
| @@ -41,7 +230,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 41 | 230 | ||
| 42 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { | 231 | if (pc->flags & PC_FLAG_DMA_IN_PROGRESS) { |
| 43 | if (hwif->dma_ops->dma_end(drive) || | 232 | if (hwif->dma_ops->dma_end(drive) || |
| 44 | (drive->media == ide_tape && !scsi && (stat & ERR_STAT))) { | 233 | (drive->media == ide_tape && !scsi && (stat & ATA_ERR))) { |
| 45 | if (drive->media == ide_floppy && !scsi) | 234 | if (drive->media == ide_floppy && !scsi) |
| 46 | printk(KERN_ERR "%s: DMA %s error\n", | 235 | printk(KERN_ERR "%s: DMA %s error\n", |
| 47 | drive->name, rq_data_dir(pc->rq) | 236 | drive->name, rq_data_dir(pc->rq) |
| @@ -56,7 +245,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 56 | } | 245 | } |
| 57 | 246 | ||
| 58 | /* No more interrupts */ | 247 | /* No more interrupts */ |
| 59 | if ((stat & DRQ_STAT) == 0) { | 248 | if ((stat & ATA_DRQ) == 0) { |
| 60 | debug_log("Packet command completed, %d bytes transferred\n", | 249 | debug_log("Packet command completed, %d bytes transferred\n", |
| 61 | pc->xferred); | 250 | pc->xferred); |
| 62 | 251 | ||
| @@ -65,10 +254,10 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 65 | local_irq_enable_in_hardirq(); | 254 | local_irq_enable_in_hardirq(); |
| 66 | 255 | ||
| 67 | if (drive->media == ide_tape && !scsi && | 256 | if (drive->media == ide_tape && !scsi && |
| 68 | (stat & ERR_STAT) && rq->cmd[0] == REQUEST_SENSE) | 257 | (stat & ATA_ERR) && rq->cmd[0] == REQUEST_SENSE) |
| 69 | stat &= ~ERR_STAT; | 258 | stat &= ~ATA_ERR; |
| 70 | 259 | ||
| 71 | if ((stat & ERR_STAT) || (pc->flags & PC_FLAG_DMA_ERROR)) { | 260 | if ((stat & ATA_ERR) || (pc->flags & PC_FLAG_DMA_ERROR)) { |
| 72 | /* Error detected */ | 261 | /* Error detected */ |
| 73 | debug_log("%s: I/O error\n", drive->name); | 262 | debug_log("%s: I/O error\n", drive->name); |
| 74 | 263 | ||
| @@ -95,7 +284,7 @@ ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 95 | cmd_finished: | 284 | cmd_finished: |
| 96 | pc->error = 0; | 285 | pc->error = 0; |
| 97 | if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && | 286 | if ((pc->flags & PC_FLAG_WAIT_FOR_DSC) && |
| 98 | (stat & SEEK_STAT) == 0) { | 287 | (stat & ATA_DSC) == 0) { |
| 99 | dsc_handle(drive); | 288 | dsc_handle(drive); |
| 100 | return ide_stopped; | 289 | return ide_stopped; |
| 101 | } | 290 | } |
| @@ -117,17 +306,18 @@ cmd_finished: | |||
| 117 | /* Get the number of bytes to transfer on this interrupt. */ | 306 | /* Get the number of bytes to transfer on this interrupt. */ |
| 118 | ide_read_bcount_and_ireason(drive, &bcount, &ireason); | 307 | ide_read_bcount_and_ireason(drive, &bcount, &ireason); |
| 119 | 308 | ||
| 120 | if (ireason & CD) { | 309 | if (ireason & ATAPI_COD) { |
| 121 | printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__); | 310 | printk(KERN_ERR "%s: CoD != 0 in %s\n", drive->name, __func__); |
| 122 | return ide_do_reset(drive); | 311 | return ide_do_reset(drive); |
| 123 | } | 312 | } |
| 124 | 313 | ||
| 125 | if (((ireason & IO) == IO) == !!(pc->flags & PC_FLAG_WRITING)) { | 314 | if (((ireason & ATAPI_IO) == ATAPI_IO) == |
| 315 | !!(pc->flags & PC_FLAG_WRITING)) { | ||
| 126 | /* Hopefully, we will never get here */ | 316 | /* Hopefully, we will never get here */ |
| 127 | printk(KERN_ERR "%s: We wanted to %s, but the device wants us " | 317 | printk(KERN_ERR "%s: We wanted to %s, but the device wants us " |
| 128 | "to %s!\n", drive->name, | 318 | "to %s!\n", drive->name, |
| 129 | (ireason & IO) ? "Write" : "Read", | 319 | (ireason & ATAPI_IO) ? "Write" : "Read", |
| 130 | (ireason & IO) ? "Read" : "Write"); | 320 | (ireason & ATAPI_IO) ? "Read" : "Write"); |
| 131 | return ide_do_reset(drive); | 321 | return ide_do_reset(drive); |
| 132 | } | 322 | } |
| 133 | 323 | ||
| @@ -171,9 +361,14 @@ cmd_finished: | |||
| 171 | 361 | ||
| 172 | if ((drive->media == ide_floppy && !scsi && !pc->buf) || | 362 | if ((drive->media == ide_floppy && !scsi && !pc->buf) || |
| 173 | (drive->media == ide_tape && !scsi && pc->bh) || | 363 | (drive->media == ide_tape && !scsi && pc->bh) || |
| 174 | (scsi && pc->sg)) | 364 | (scsi && pc->sg)) { |
| 175 | io_buffers(drive, pc, bcount, !!(pc->flags & PC_FLAG_WRITING)); | 365 | int done = io_buffers(drive, pc, bcount, |
| 176 | else | 366 | !!(pc->flags & PC_FLAG_WRITING)); |
| 367 | |||
| 368 | /* FIXME: don't do partial completions */ | ||
| 369 | if (drive->media == ide_floppy && !scsi) | ||
| 370 | ide_end_request(drive, 1, done >> 9); | ||
| 371 | } else | ||
| 177 | xferfunc(drive, NULL, pc->cur_pos, bcount); | 372 | xferfunc(drive, NULL, pc->cur_pos, bcount); |
| 178 | 373 | ||
| 179 | /* Update the current position */ | 374 | /* Update the current position */ |
| @@ -205,7 +400,8 @@ static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason) | |||
| 205 | { | 400 | { |
| 206 | int retries = 100; | 401 | int retries = 100; |
| 207 | 402 | ||
| 208 | while (retries-- && ((ireason & CD) == 0 || (ireason & IO))) { | 403 | while (retries-- && ((ireason & ATAPI_COD) == 0 || |
| 404 | (ireason & ATAPI_IO))) { | ||
| 209 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | 405 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " |
| 210 | "a packet command, retrying\n", drive->name); | 406 | "a packet command, retrying\n", drive->name); |
| 211 | udelay(100); | 407 | udelay(100); |
| @@ -214,8 +410,8 @@ static u8 ide_wait_ireason(ide_drive_t *drive, u8 ireason) | |||
| 214 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " | 410 | printk(KERN_ERR "%s: (IO,CoD != (0,1) while issuing " |
| 215 | "a packet command, ignoring\n", | 411 | "a packet command, ignoring\n", |
| 216 | drive->name); | 412 | drive->name); |
| 217 | ireason |= CD; | 413 | ireason |= ATAPI_COD; |
| 218 | ireason &= ~IO; | 414 | ireason &= ~ATAPI_IO; |
| 219 | } | 415 | } |
| 220 | } | 416 | } |
| 221 | 417 | ||
| @@ -231,7 +427,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 231 | ide_startstop_t startstop; | 427 | ide_startstop_t startstop; |
| 232 | u8 ireason; | 428 | u8 ireason; |
| 233 | 429 | ||
| 234 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, BUSY_STAT, WAIT_READY)) { | 430 | if (ide_wait_stat(&startstop, drive, ATA_DRQ, ATA_BUSY, WAIT_READY)) { |
| 235 | printk(KERN_ERR "%s: Strange, packet command initiated yet " | 431 | printk(KERN_ERR "%s: Strange, packet command initiated yet " |
| 236 | "DRQ isn't asserted\n", drive->name); | 432 | "DRQ isn't asserted\n", drive->name); |
| 237 | return startstop; | 433 | return startstop; |
| @@ -241,7 +437,7 @@ ide_startstop_t ide_transfer_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 241 | if (drive->media == ide_tape && !drive->scsi) | 437 | if (drive->media == ide_tape && !drive->scsi) |
| 242 | ireason = ide_wait_ireason(drive, ireason); | 438 | ireason = ide_wait_ireason(drive, ireason); |
| 243 | 439 | ||
| 244 | if ((ireason & CD) == 0 || (ireason & IO)) { | 440 | if ((ireason & ATAPI_COD) == 0 || (ireason & ATAPI_IO)) { |
| 245 | printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " | 441 | printk(KERN_ERR "%s: (IO,CoD) != (0,1) while issuing " |
| 246 | "a packet command\n", drive->name); | 442 | "a packet command\n", drive->name); |
| 247 | return ide_do_reset(drive); | 443 | return ide_do_reset(drive); |
| @@ -303,7 +499,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 303 | 499 | ||
| 304 | /* Issue the packet command */ | 500 | /* Issue the packet command */ |
| 305 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { | 501 | if (drive->atapi_flags & IDE_AFLAG_DRQ_INTERRUPT) { |
| 306 | ide_execute_command(drive, WIN_PACKETCMD, handler, | 502 | ide_execute_command(drive, ATA_CMD_PACKET, handler, |
| 307 | timeout, NULL); | 503 | timeout, NULL); |
| 308 | return ide_started; | 504 | return ide_started; |
| 309 | } else { | 505 | } else { |
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 03c2cb6a58bc..465a92ca0179 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
| @@ -436,7 +436,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
| 436 | ide_dump_status_no_sense(drive, "media error (blank)", | 436 | ide_dump_status_no_sense(drive, "media error (blank)", |
| 437 | stat); | 437 | stat); |
| 438 | do_end_request = 1; | 438 | do_end_request = 1; |
| 439 | } else if ((err & ~ABRT_ERR) != 0) { | 439 | } else if ((err & ~ATA_ABORTED) != 0) { |
| 440 | /* go to the default handler for other errors */ | 440 | /* go to the default handler for other errors */ |
| 441 | ide_error(drive, "cdrom_decode_status", stat); | 441 | ide_error(drive, "cdrom_decode_status", stat); |
| 442 | return 1; | 442 | return 1; |
| @@ -457,7 +457,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
| 457 | * If we got a CHECK_CONDITION status, queue | 457 | * If we got a CHECK_CONDITION status, queue |
| 458 | * a request sense command. | 458 | * a request sense command. |
| 459 | */ | 459 | */ |
| 460 | if (stat & ERR_STAT) | 460 | if (stat & ATA_ERR) |
| 461 | cdrom_queue_request_sense(drive, NULL, NULL); | 461 | cdrom_queue_request_sense(drive, NULL, NULL); |
| 462 | } else { | 462 | } else { |
| 463 | blk_dump_rq_flags(rq, "ide-cd: bad rq"); | 463 | blk_dump_rq_flags(rq, "ide-cd: bad rq"); |
| @@ -468,7 +468,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
| 468 | return 1; | 468 | return 1; |
| 469 | 469 | ||
| 470 | end_request: | 470 | end_request: |
| 471 | if (stat & ERR_STAT) { | 471 | if (stat & ATA_ERR) { |
| 472 | unsigned long flags; | 472 | unsigned long flags; |
| 473 | 473 | ||
| 474 | spin_lock_irqsave(&ide_lock, flags); | 474 | spin_lock_irqsave(&ide_lock, flags); |
| @@ -541,7 +541,7 @@ static ide_startstop_t cdrom_start_packet_command(ide_drive_t *drive, | |||
| 541 | drive->waiting_for_dma = 0; | 541 | drive->waiting_for_dma = 0; |
| 542 | 542 | ||
| 543 | /* packet command */ | 543 | /* packet command */ |
| 544 | ide_execute_command(drive, WIN_PACKETCMD, handler, | 544 | ide_execute_command(drive, ATA_CMD_PACKET, handler, |
| 545 | ATAPI_WAIT_PC, cdrom_timer_expiry); | 545 | ATAPI_WAIT_PC, cdrom_timer_expiry); |
| 546 | return ide_started; | 546 | return ide_started; |
| 547 | } else { | 547 | } else { |
| @@ -574,7 +574,7 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | |||
| 574 | */ | 574 | */ |
| 575 | 575 | ||
| 576 | /* check for errors */ | 576 | /* check for errors */ |
| 577 | if (cdrom_decode_status(drive, DRQ_STAT, NULL)) | 577 | if (cdrom_decode_status(drive, ATA_DRQ, NULL)) |
| 578 | return ide_stopped; | 578 | return ide_stopped; |
| 579 | 579 | ||
| 580 | /* ok, next interrupt will be DMA interrupt */ | 580 | /* ok, next interrupt will be DMA interrupt */ |
| @@ -582,8 +582,8 @@ static ide_startstop_t cdrom_transfer_packet_command(ide_drive_t *drive, | |||
| 582 | drive->waiting_for_dma = 1; | 582 | drive->waiting_for_dma = 1; |
| 583 | } else { | 583 | } else { |
| 584 | /* otherwise, we must wait for DRQ to get set */ | 584 | /* otherwise, we must wait for DRQ to get set */ |
| 585 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, | 585 | if (ide_wait_stat(&startstop, drive, ATA_DRQ, |
| 586 | BUSY_STAT, WAIT_READY)) | 586 | ATA_BUSY, WAIT_READY)) |
| 587 | return startstop; | 587 | return startstop; |
| 588 | } | 588 | } |
| 589 | 589 | ||
| @@ -938,7 +938,7 @@ static ide_startstop_t cdrom_newpc_intr(ide_drive_t *drive) | |||
| 938 | thislen = len; | 938 | thislen = len; |
| 939 | 939 | ||
| 940 | /* If DRQ is clear, the command has completed. */ | 940 | /* If DRQ is clear, the command has completed. */ |
| 941 | if ((stat & DRQ_STAT) == 0) { | 941 | if ((stat & ATA_DRQ) == 0) { |
| 942 | if (blk_fs_request(rq)) { | 942 | if (blk_fs_request(rq)) { |
| 943 | /* | 943 | /* |
| 944 | * If we're not done reading/writing, complain. | 944 | * If we're not done reading/writing, complain. |
| @@ -1164,13 +1164,12 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
| 1164 | if (rq->bio || ((rq->cmd_type == REQ_TYPE_ATA_PC) && rq->data_len)) { | 1164 | if (rq->bio || ((rq->cmd_type == REQ_TYPE_ATA_PC) && rq->data_len)) { |
| 1165 | struct request_queue *q = drive->queue; | 1165 | struct request_queue *q = drive->queue; |
| 1166 | unsigned int alignment; | 1166 | unsigned int alignment; |
| 1167 | unsigned long addr; | 1167 | char *buf; |
| 1168 | unsigned long stack_mask = ~(THREAD_SIZE - 1); | ||
| 1169 | 1168 | ||
| 1170 | if (rq->bio) | 1169 | if (rq->bio) |
| 1171 | addr = (unsigned long)bio_data(rq->bio); | 1170 | buf = bio_data(rq->bio); |
| 1172 | else | 1171 | else |
| 1173 | addr = (unsigned long)rq->data; | 1172 | buf = rq->data; |
| 1174 | 1173 | ||
| 1175 | info->dma = drive->using_dma; | 1174 | info->dma = drive->using_dma; |
| 1176 | 1175 | ||
| @@ -1181,11 +1180,8 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
| 1181 | * separate masks. | 1180 | * separate masks. |
| 1182 | */ | 1181 | */ |
| 1183 | alignment = queue_dma_alignment(q) | q->dma_pad_mask; | 1182 | alignment = queue_dma_alignment(q) | q->dma_pad_mask; |
| 1184 | if (addr & alignment || rq->data_len & alignment) | 1183 | if ((unsigned long)buf & alignment || rq->data_len & alignment |
| 1185 | info->dma = 0; | 1184 | || object_is_on_stack(buf)) |
| 1186 | |||
| 1187 | if (!((addr & stack_mask) ^ | ||
| 1188 | ((unsigned long)current->stack & stack_mask))) | ||
| 1189 | info->dma = 0; | 1185 | info->dma = 0; |
| 1190 | } | 1186 | } |
| 1191 | } | 1187 | } |
| @@ -1206,7 +1202,7 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, | |||
| 1206 | unsigned long elapsed = jiffies - info->start_seek; | 1202 | unsigned long elapsed = jiffies - info->start_seek; |
| 1207 | int stat = hwif->tp_ops->read_status(hwif); | 1203 | int stat = hwif->tp_ops->read_status(hwif); |
| 1208 | 1204 | ||
| 1209 | if ((stat & SEEK_STAT) != SEEK_STAT) { | 1205 | if ((stat & ATA_DSC) != ATA_DSC) { |
| 1210 | if (elapsed < IDECD_SEEK_TIMEOUT) { | 1206 | if (elapsed < IDECD_SEEK_TIMEOUT) { |
| 1211 | ide_stall_queue(drive, | 1207 | ide_stall_queue(drive, |
| 1212 | IDECD_SEEK_TIMER); | 1208 | IDECD_SEEK_TIMER); |
| @@ -1813,13 +1809,12 @@ static ide_proc_entry_t idecd_proc[] = { | |||
| 1813 | { NULL, 0, NULL, NULL } | 1809 | { NULL, 0, NULL, NULL } |
| 1814 | }; | 1810 | }; |
| 1815 | 1811 | ||
| 1816 | static void ide_cdrom_add_settings(ide_drive_t *drive) | 1812 | ide_devset_rw_field(dsc_overlap, dsc_overlap); |
| 1817 | { | 1813 | |
| 1818 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, | 1814 | static const struct ide_proc_devset idecd_settings[] = { |
| 1819 | &drive->dsc_overlap, NULL); | 1815 | IDE_PROC_DEVSET(dsc_overlap, 0, 1), |
| 1820 | } | 1816 | { 0 }, |
| 1821 | #else | 1817 | }; |
| 1822 | static inline void ide_cdrom_add_settings(ide_drive_t *drive) { ; } | ||
| 1823 | #endif | 1818 | #endif |
| 1824 | 1819 | ||
| 1825 | static const struct cd_list_entry ide_cd_quirks_list[] = { | 1820 | static const struct cd_list_entry ide_cd_quirks_list[] = { |
| @@ -1866,14 +1861,14 @@ static const struct cd_list_entry ide_cd_quirks_list[] = { | |||
| 1866 | { NULL, NULL, 0 } | 1861 | { NULL, NULL, 0 } |
| 1867 | }; | 1862 | }; |
| 1868 | 1863 | ||
| 1869 | static unsigned int ide_cd_flags(struct hd_driveid *id) | 1864 | static unsigned int ide_cd_flags(u16 *id) |
| 1870 | { | 1865 | { |
| 1871 | const struct cd_list_entry *cle = ide_cd_quirks_list; | 1866 | const struct cd_list_entry *cle = ide_cd_quirks_list; |
| 1872 | 1867 | ||
| 1873 | while (cle->id_model) { | 1868 | while (cle->id_model) { |
| 1874 | if (strcmp(cle->id_model, id->model) == 0 && | 1869 | if (strcmp(cle->id_model, (char *)&id[ATA_ID_PROD]) == 0 && |
| 1875 | (cle->id_firmware == NULL || | 1870 | (cle->id_firmware == NULL || |
| 1876 | strstr(id->fw_rev, cle->id_firmware))) | 1871 | strstr((char *)&id[ATA_ID_FW_REV], cle->id_firmware))) |
| 1877 | return cle->cd_flags; | 1872 | return cle->cd_flags; |
| 1878 | cle++; | 1873 | cle++; |
| 1879 | } | 1874 | } |
| @@ -1885,7 +1880,8 @@ static int ide_cdrom_setup(ide_drive_t *drive) | |||
| 1885 | { | 1880 | { |
| 1886 | struct cdrom_info *cd = drive->driver_data; | 1881 | struct cdrom_info *cd = drive->driver_data; |
| 1887 | struct cdrom_device_info *cdi = &cd->devinfo; | 1882 | struct cdrom_device_info *cdi = &cd->devinfo; |
| 1888 | struct hd_driveid *id = drive->id; | 1883 | u16 *id = drive->id; |
| 1884 | char *fw_rev = (char *)&id[ATA_ID_FW_REV]; | ||
| 1889 | int nslots; | 1885 | int nslots; |
| 1890 | 1886 | ||
| 1891 | blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); | 1887 | blk_queue_prep_rq(drive->queue, ide_cdrom_prep_fn); |
| @@ -1900,15 +1896,15 @@ static int ide_cdrom_setup(ide_drive_t *drive) | |||
| 1900 | drive->atapi_flags = IDE_AFLAG_MEDIA_CHANGED | IDE_AFLAG_NO_EJECT | | 1896 | drive->atapi_flags = IDE_AFLAG_MEDIA_CHANGED | IDE_AFLAG_NO_EJECT | |
| 1901 | ide_cd_flags(id); | 1897 | ide_cd_flags(id); |
| 1902 | 1898 | ||
| 1903 | if ((id->config & 0x0060) == 0x20) | 1899 | if ((id[ATA_ID_CONFIG] & 0x0060) == 0x20) |
| 1904 | drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; | 1900 | drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; |
| 1905 | 1901 | ||
| 1906 | if ((drive->atapi_flags & IDE_AFLAG_VERTOS_300_SSD) && | 1902 | if ((drive->atapi_flags & IDE_AFLAG_VERTOS_300_SSD) && |
| 1907 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') | 1903 | fw_rev[4] == '1' && fw_rev[6] <= '2') |
| 1908 | drive->atapi_flags |= (IDE_AFLAG_TOCTRACKS_AS_BCD | | 1904 | drive->atapi_flags |= (IDE_AFLAG_TOCTRACKS_AS_BCD | |
| 1909 | IDE_AFLAG_TOCADDR_AS_BCD); | 1905 | IDE_AFLAG_TOCADDR_AS_BCD); |
| 1910 | else if ((drive->atapi_flags & IDE_AFLAG_VERTOS_600_ESD) && | 1906 | else if ((drive->atapi_flags & IDE_AFLAG_VERTOS_600_ESD) && |
| 1911 | id->fw_rev[4] == '1' && id->fw_rev[6] <= '2') | 1907 | fw_rev[4] == '1' && fw_rev[6] <= '2') |
| 1912 | drive->atapi_flags |= IDE_AFLAG_TOCTRACKS_AS_BCD; | 1908 | drive->atapi_flags |= IDE_AFLAG_TOCTRACKS_AS_BCD; |
| 1913 | else if (drive->atapi_flags & IDE_AFLAG_SANYO_3CD) | 1909 | else if (drive->atapi_flags & IDE_AFLAG_SANYO_3CD) |
| 1914 | /* 3 => use CD in slot 0 */ | 1910 | /* 3 => use CD in slot 0 */ |
| @@ -1927,7 +1923,8 @@ static int ide_cdrom_setup(ide_drive_t *drive) | |||
| 1927 | cd->devinfo.handle = NULL; | 1923 | cd->devinfo.handle = NULL; |
| 1928 | return 1; | 1924 | return 1; |
| 1929 | } | 1925 | } |
| 1930 | ide_cdrom_add_settings(drive); | 1926 | |
| 1927 | ide_proc_register_driver(drive, cd->driver); | ||
| 1931 | return 0; | 1928 | return 0; |
| 1932 | } | 1929 | } |
| 1933 | 1930 | ||
| @@ -1972,12 +1969,12 @@ static ide_driver_t ide_cdrom_driver = { | |||
| 1972 | .remove = ide_cd_remove, | 1969 | .remove = ide_cd_remove, |
| 1973 | .version = IDECD_VERSION, | 1970 | .version = IDECD_VERSION, |
| 1974 | .media = ide_cdrom, | 1971 | .media = ide_cdrom, |
| 1975 | .supports_dsc_overlap = 1, | ||
| 1976 | .do_request = ide_cd_do_request, | 1972 | .do_request = ide_cd_do_request, |
| 1977 | .end_request = ide_end_request, | 1973 | .end_request = ide_end_request, |
| 1978 | .error = __ide_error, | 1974 | .error = __ide_error, |
| 1979 | #ifdef CONFIG_IDE_PROC_FS | 1975 | #ifdef CONFIG_IDE_PROC_FS |
| 1980 | .proc = idecd_proc, | 1976 | .proc = idecd_proc, |
| 1977 | .settings = idecd_settings, | ||
| 1981 | #endif | 1978 | #endif |
| 1982 | }; | 1979 | }; |
| 1983 | 1980 | ||
| @@ -2112,10 +2109,10 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
| 2112 | 2109 | ||
| 2113 | if (!strstr("ide-cdrom", drive->driver_req)) | 2110 | if (!strstr("ide-cdrom", drive->driver_req)) |
| 2114 | goto failed; | 2111 | goto failed; |
| 2115 | if (!drive->present) | 2112 | |
| 2116 | goto failed; | ||
| 2117 | if (drive->media != ide_cdrom && drive->media != ide_optical) | 2113 | if (drive->media != ide_cdrom && drive->media != ide_optical) |
| 2118 | goto failed; | 2114 | goto failed; |
| 2115 | |||
| 2119 | /* skip drives that we were told to ignore */ | 2116 | /* skip drives that we were told to ignore */ |
| 2120 | if (ignore != NULL) { | 2117 | if (ignore != NULL) { |
| 2121 | if (strstr(ignore, drive->name)) { | 2118 | if (strstr(ignore, drive->name)) { |
| @@ -2137,8 +2134,6 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
| 2137 | 2134 | ||
| 2138 | ide_init_disk(g, drive); | 2135 | ide_init_disk(g, drive); |
| 2139 | 2136 | ||
| 2140 | ide_proc_register_driver(drive, &ide_cdrom_driver); | ||
| 2141 | |||
| 2142 | kref_init(&info->kref); | 2137 | kref_init(&info->kref); |
| 2143 | 2138 | ||
| 2144 | info->drive = drive; | 2139 | info->drive = drive; |
| @@ -2153,7 +2148,6 @@ static int ide_cd_probe(ide_drive_t *drive) | |||
| 2153 | g->driverfs_dev = &drive->gendev; | 2148 | g->driverfs_dev = &drive->gendev; |
| 2154 | g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE; | 2149 | g->flags = GENHD_FL_CD | GENHD_FL_REMOVABLE; |
| 2155 | if (ide_cdrom_setup(drive)) { | 2150 | if (ide_cdrom_setup(drive)) { |
| 2156 | ide_proc_unregister_driver(drive, &ide_cdrom_driver); | ||
| 2157 | ide_cd_release(&info->kref); | 2151 | ide_cd_release(&info->kref); |
| 2158 | goto failed; | 2152 | goto failed; |
| 2159 | } | 2153 | } |
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 33ea8c048717..01846f244b40 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
| @@ -30,10 +30,8 @@ | |||
| 30 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
| 31 | #include <linux/mutex.h> | 31 | #include <linux/mutex.h> |
| 32 | #include <linux/leds.h> | 32 | #include <linux/leds.h> |
| 33 | |||
| 34 | #define _IDE_DISK | ||
| 35 | |||
| 36 | #include <linux/ide.h> | 33 | #include <linux/ide.h> |
| 34 | #include <linux/hdreg.h> | ||
| 37 | 35 | ||
| 38 | #include <asm/byteorder.h> | 36 | #include <asm/byteorder.h> |
| 39 | #include <asm/irq.h> | 37 | #include <asm/irq.h> |
| @@ -90,68 +88,19 @@ static void ide_disk_put(struct ide_disk_obj *idkp) | |||
| 90 | mutex_unlock(&idedisk_ref_mutex); | 88 | mutex_unlock(&idedisk_ref_mutex); |
| 91 | } | 89 | } |
| 92 | 90 | ||
| 93 | /* | ||
| 94 | * lba_capacity_is_ok() performs a sanity check on the claimed "lba_capacity" | ||
| 95 | * value for this drive (from its reported identification information). | ||
| 96 | * | ||
| 97 | * Returns: 1 if lba_capacity looks sensible | ||
| 98 | * 0 otherwise | ||
| 99 | * | ||
| 100 | * It is called only once for each drive. | ||
| 101 | */ | ||
| 102 | static int lba_capacity_is_ok(struct hd_driveid *id) | ||
| 103 | { | ||
| 104 | unsigned long lba_sects, chs_sects, head, tail; | ||
| 105 | |||
| 106 | /* No non-LBA info .. so valid! */ | ||
| 107 | if (id->cyls == 0) | ||
| 108 | return 1; | ||
| 109 | |||
| 110 | /* | ||
| 111 | * The ATA spec tells large drives to return | ||
| 112 | * C/H/S = 16383/16/63 independent of their size. | ||
| 113 | * Some drives can be jumpered to use 15 heads instead of 16. | ||
| 114 | * Some drives can be jumpered to use 4092 cyls instead of 16383. | ||
| 115 | */ | ||
| 116 | if ((id->cyls == 16383 | ||
| 117 | || (id->cyls == 4092 && id->cur_cyls == 16383)) && | ||
| 118 | id->sectors == 63 && | ||
| 119 | (id->heads == 15 || id->heads == 16) && | ||
| 120 | (id->lba_capacity >= 16383*63*id->heads)) | ||
| 121 | return 1; | ||
| 122 | |||
| 123 | lba_sects = id->lba_capacity; | ||
| 124 | chs_sects = id->cyls * id->heads * id->sectors; | ||
| 125 | |||
| 126 | /* perform a rough sanity check on lba_sects: within 10% is OK */ | ||
| 127 | if ((lba_sects - chs_sects) < chs_sects/10) | ||
| 128 | return 1; | ||
| 129 | |||
| 130 | /* some drives have the word order reversed */ | ||
| 131 | head = ((lba_sects >> 16) & 0xffff); | ||
| 132 | tail = (lba_sects & 0xffff); | ||
| 133 | lba_sects = (head | (tail << 16)); | ||
| 134 | if ((lba_sects - chs_sects) < chs_sects/10) { | ||
| 135 | id->lba_capacity = lba_sects; | ||
| 136 | return 1; /* lba_capacity is (now) good */ | ||
| 137 | } | ||
| 138 | |||
| 139 | return 0; /* lba_capacity value may be bad */ | ||
| 140 | } | ||
| 141 | |||
| 142 | static const u8 ide_rw_cmds[] = { | 91 | static const u8 ide_rw_cmds[] = { |
| 143 | WIN_MULTREAD, | 92 | ATA_CMD_READ_MULTI, |
| 144 | WIN_MULTWRITE, | 93 | ATA_CMD_WRITE_MULTI, |
| 145 | WIN_MULTREAD_EXT, | 94 | ATA_CMD_READ_MULTI_EXT, |
| 146 | WIN_MULTWRITE_EXT, | 95 | ATA_CMD_WRITE_MULTI_EXT, |
| 147 | WIN_READ, | 96 | ATA_CMD_PIO_READ, |
| 148 | WIN_WRITE, | 97 | ATA_CMD_PIO_WRITE, |
| 149 | WIN_READ_EXT, | 98 | ATA_CMD_PIO_READ_EXT, |
| 150 | WIN_WRITE_EXT, | 99 | ATA_CMD_PIO_WRITE_EXT, |
| 151 | WIN_READDMA, | 100 | ATA_CMD_READ, |
| 152 | WIN_WRITEDMA, | 101 | ATA_CMD_WRITE, |
| 153 | WIN_READDMA_EXT, | 102 | ATA_CMD_READ_EXT, |
| 154 | WIN_WRITEDMA_EXT, | 103 | ATA_CMD_WRITE_EXT, |
| 155 | }; | 104 | }; |
| 156 | 105 | ||
| 157 | static const u8 ide_data_phases[] = { | 106 | static const u8 ide_data_phases[] = { |
| @@ -322,9 +271,9 @@ static u64 idedisk_read_native_max_address(ide_drive_t *drive, int lba48) | |||
| 322 | /* Create IDE/ATA command request structure */ | 271 | /* Create IDE/ATA command request structure */ |
| 323 | memset(&args, 0, sizeof(ide_task_t)); | 272 | memset(&args, 0, sizeof(ide_task_t)); |
| 324 | if (lba48) | 273 | if (lba48) |
| 325 | tf->command = WIN_READ_NATIVE_MAX_EXT; | 274 | tf->command = ATA_CMD_READ_NATIVE_MAX_EXT; |
| 326 | else | 275 | else |
| 327 | tf->command = WIN_READ_NATIVE_MAX; | 276 | tf->command = ATA_CMD_READ_NATIVE_MAX; |
| 328 | tf->device = ATA_LBA; | 277 | tf->device = ATA_LBA; |
| 329 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | 278 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
| 330 | if (lba48) | 279 | if (lba48) |
| @@ -359,10 +308,10 @@ static u64 idedisk_set_max_address(ide_drive_t *drive, u64 addr_req, int lba48) | |||
| 359 | tf->hob_lbal = (addr_req >>= 8) & 0xff; | 308 | tf->hob_lbal = (addr_req >>= 8) & 0xff; |
| 360 | tf->hob_lbam = (addr_req >>= 8) & 0xff; | 309 | tf->hob_lbam = (addr_req >>= 8) & 0xff; |
| 361 | tf->hob_lbah = (addr_req >>= 8) & 0xff; | 310 | tf->hob_lbah = (addr_req >>= 8) & 0xff; |
| 362 | tf->command = WIN_SET_MAX_EXT; | 311 | tf->command = ATA_CMD_SET_MAX_EXT; |
| 363 | } else { | 312 | } else { |
| 364 | tf->device = (addr_req >>= 8) & 0x0f; | 313 | tf->device = (addr_req >>= 8) & 0x0f; |
| 365 | tf->command = WIN_SET_MAX; | 314 | tf->command = ATA_CMD_SET_MAX; |
| 366 | } | 315 | } |
| 367 | tf->device |= ATA_LBA; | 316 | tf->device |= ATA_LBA; |
| 368 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | 317 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
| @@ -385,25 +334,6 @@ static unsigned long long sectors_to_MB(unsigned long long n) | |||
| 385 | } | 334 | } |
| 386 | 335 | ||
| 387 | /* | 336 | /* |
| 388 | * Bits 10 of command_set_1 and cfs_enable_1 must be equal, | ||
| 389 | * so on non-buggy drives we need test only one. | ||
| 390 | * However, we should also check whether these fields are valid. | ||
| 391 | */ | ||
| 392 | static inline int idedisk_supports_hpa(const struct hd_driveid *id) | ||
| 393 | { | ||
| 394 | return (id->command_set_1 & 0x0400) && (id->cfs_enable_1 & 0x0400); | ||
| 395 | } | ||
| 396 | |||
| 397 | /* | ||
| 398 | * The same here. | ||
| 399 | */ | ||
| 400 | static inline int idedisk_supports_lba48(const struct hd_driveid *id) | ||
| 401 | { | ||
| 402 | return (id->command_set_2 & 0x0400) && (id->cfs_enable_2 & 0x0400) | ||
| 403 | && id->lba_capacity_2; | ||
| 404 | } | ||
| 405 | |||
| 406 | /* | ||
| 407 | * Some disks report total number of sectors instead of | 337 | * Some disks report total number of sectors instead of |
| 408 | * maximum sector address. We list them here. | 338 | * maximum sector address. We list them here. |
| 409 | */ | 339 | */ |
| @@ -417,7 +347,7 @@ static const struct drive_list_entry hpa_list[] = { | |||
| 417 | static void idedisk_check_hpa(ide_drive_t *drive) | 347 | static void idedisk_check_hpa(ide_drive_t *drive) |
| 418 | { | 348 | { |
| 419 | unsigned long long capacity, set_max; | 349 | unsigned long long capacity, set_max; |
| 420 | int lba48 = idedisk_supports_lba48(drive->id); | 350 | int lba48 = ata_id_lba48_enabled(drive->id); |
| 421 | 351 | ||
| 422 | capacity = drive->capacity64; | 352 | capacity = drive->capacity64; |
| 423 | 353 | ||
| @@ -453,23 +383,23 @@ static void idedisk_check_hpa(ide_drive_t *drive) | |||
| 453 | 383 | ||
| 454 | static void init_idedisk_capacity(ide_drive_t *drive) | 384 | static void init_idedisk_capacity(ide_drive_t *drive) |
| 455 | { | 385 | { |
| 456 | struct hd_driveid *id = drive->id; | 386 | u16 *id = drive->id; |
| 457 | /* | 387 | /* |
| 458 | * If this drive supports the Host Protected Area feature set, | 388 | * If this drive supports the Host Protected Area feature set, |
| 459 | * then we may need to change our opinion about the drive's capacity. | 389 | * then we may need to change our opinion about the drive's capacity. |
| 460 | */ | 390 | */ |
| 461 | int hpa = idedisk_supports_hpa(id); | 391 | int hpa = ata_id_hpa_enabled(id); |
| 462 | 392 | ||
| 463 | if (idedisk_supports_lba48(id)) { | 393 | if (ata_id_lba48_enabled(id)) { |
| 464 | /* drive speaks 48-bit LBA */ | 394 | /* drive speaks 48-bit LBA */ |
| 465 | drive->select.b.lba = 1; | 395 | drive->select.b.lba = 1; |
| 466 | drive->capacity64 = id->lba_capacity_2; | 396 | drive->capacity64 = ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); |
| 467 | if (hpa) | 397 | if (hpa) |
| 468 | idedisk_check_hpa(drive); | 398 | idedisk_check_hpa(drive); |
| 469 | } else if ((id->capability & 2) && lba_capacity_is_ok(id)) { | 399 | } else if (ata_id_has_lba(id) && ata_id_is_lba_capacity_ok(id)) { |
| 470 | /* drive speaks 28-bit LBA */ | 400 | /* drive speaks 28-bit LBA */ |
| 471 | drive->select.b.lba = 1; | 401 | drive->select.b.lba = 1; |
| 472 | drive->capacity64 = id->lba_capacity; | 402 | drive->capacity64 = ata_id_u32(id, ATA_ID_LBA_CAPACITY); |
| 473 | if (hpa) | 403 | if (hpa) |
| 474 | idedisk_check_hpa(drive); | 404 | idedisk_check_hpa(drive); |
| 475 | } else { | 405 | } else { |
| @@ -480,7 +410,7 @@ static void init_idedisk_capacity(ide_drive_t *drive) | |||
| 480 | 410 | ||
| 481 | static sector_t idedisk_capacity(ide_drive_t *drive) | 411 | static sector_t idedisk_capacity(ide_drive_t *drive) |
| 482 | { | 412 | { |
| 483 | return drive->capacity64 - drive->sect0; | 413 | return drive->capacity64; |
| 484 | } | 414 | } |
| 485 | 415 | ||
| 486 | #ifdef CONFIG_IDE_PROC_FS | 416 | #ifdef CONFIG_IDE_PROC_FS |
| @@ -490,10 +420,10 @@ static int smart_enable(ide_drive_t *drive) | |||
| 490 | struct ide_taskfile *tf = &args.tf; | 420 | struct ide_taskfile *tf = &args.tf; |
| 491 | 421 | ||
| 492 | memset(&args, 0, sizeof(ide_task_t)); | 422 | memset(&args, 0, sizeof(ide_task_t)); |
| 493 | tf->feature = SMART_ENABLE; | 423 | tf->feature = ATA_SMART_ENABLE; |
| 494 | tf->lbam = SMART_LCYL_PASS; | 424 | tf->lbam = ATA_SMART_LBAM_PASS; |
| 495 | tf->lbah = SMART_HCYL_PASS; | 425 | tf->lbah = ATA_SMART_LBAH_PASS; |
| 496 | tf->command = WIN_SMART; | 426 | tf->command = ATA_CMD_SMART; |
| 497 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | 427 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
| 498 | return ide_no_data_taskfile(drive, &args); | 428 | return ide_no_data_taskfile(drive, &args); |
| 499 | } | 429 | } |
| @@ -506,9 +436,9 @@ static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) | |||
| 506 | memset(&args, 0, sizeof(ide_task_t)); | 436 | memset(&args, 0, sizeof(ide_task_t)); |
| 507 | tf->feature = sub_cmd; | 437 | tf->feature = sub_cmd; |
| 508 | tf->nsect = 0x01; | 438 | tf->nsect = 0x01; |
| 509 | tf->lbam = SMART_LCYL_PASS; | 439 | tf->lbam = ATA_SMART_LBAM_PASS; |
| 510 | tf->lbah = SMART_HCYL_PASS; | 440 | tf->lbah = ATA_SMART_LBAH_PASS; |
| 511 | tf->command = WIN_SMART; | 441 | tf->command = ATA_CMD_SMART; |
| 512 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | 442 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
| 513 | args.data_phase = TASKFILE_IN; | 443 | args.data_phase = TASKFILE_IN; |
| 514 | (void) smart_enable(drive); | 444 | (void) smart_enable(drive); |
| @@ -523,7 +453,7 @@ static int proc_idedisk_read_cache | |||
| 523 | int len; | 453 | int len; |
| 524 | 454 | ||
| 525 | if (drive->id_read) | 455 | if (drive->id_read) |
| 526 | len = sprintf(out, "%i\n", drive->id->buf_size / 2); | 456 | len = sprintf(out, "%i\n", drive->id[ATA_ID_BUF_SIZE] / 2); |
| 527 | else | 457 | else |
| 528 | len = sprintf(out, "(none)\n"); | 458 | len = sprintf(out, "(none)\n"); |
| 529 | 459 | ||
| @@ -549,13 +479,14 @@ static int proc_idedisk_read_smart(char *page, char **start, off_t off, | |||
| 549 | 479 | ||
| 550 | if (get_smart_data(drive, page, sub_cmd) == 0) { | 480 | if (get_smart_data(drive, page, sub_cmd) == 0) { |
| 551 | unsigned short *val = (unsigned short *) page; | 481 | unsigned short *val = (unsigned short *) page; |
| 552 | char *out = ((char *)val) + (SECTOR_WORDS * 4); | 482 | char *out = (char *)val + SECTOR_SIZE; |
| 483 | |||
| 553 | page = out; | 484 | page = out; |
| 554 | do { | 485 | do { |
| 555 | out += sprintf(out, "%04x%c", le16_to_cpu(*val), | 486 | out += sprintf(out, "%04x%c", le16_to_cpu(*val), |
| 556 | (++i & 7) ? ' ' : '\n'); | 487 | (++i & 7) ? ' ' : '\n'); |
| 557 | val += 1; | 488 | val += 1; |
| 558 | } while (i < (SECTOR_WORDS * 2)); | 489 | } while (i < SECTOR_SIZE / 2); |
| 559 | len = out - page; | 490 | len = out - page; |
| 560 | } | 491 | } |
| 561 | 492 | ||
| @@ -566,14 +497,14 @@ static int proc_idedisk_read_sv | |||
| 566 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 497 | (char *page, char **start, off_t off, int count, int *eof, void *data) |
| 567 | { | 498 | { |
| 568 | return proc_idedisk_read_smart(page, start, off, count, eof, data, | 499 | return proc_idedisk_read_smart(page, start, off, count, eof, data, |
| 569 | SMART_READ_VALUES); | 500 | ATA_SMART_READ_VALUES); |
| 570 | } | 501 | } |
| 571 | 502 | ||
| 572 | static int proc_idedisk_read_st | 503 | static int proc_idedisk_read_st |
| 573 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 504 | (char *page, char **start, off_t off, int count, int *eof, void *data) |
| 574 | { | 505 | { |
| 575 | return proc_idedisk_read_smart(page, start, off, count, eof, data, | 506 | return proc_idedisk_read_smart(page, start, off, count, eof, data, |
| 576 | SMART_READ_THRESHOLDS); | 507 | ATA_SMART_READ_THRESHOLDS); |
| 577 | } | 508 | } |
| 578 | 509 | ||
| 579 | static ide_proc_entry_t idedisk_proc[] = { | 510 | static ide_proc_entry_t idedisk_proc[] = { |
| @@ -595,11 +526,11 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) | |||
| 595 | BUG_ON(task == NULL); | 526 | BUG_ON(task == NULL); |
| 596 | 527 | ||
| 597 | memset(task, 0, sizeof(*task)); | 528 | memset(task, 0, sizeof(*task)); |
| 598 | if (ide_id_has_flush_cache_ext(drive->id) && | 529 | if (ata_id_flush_ext_enabled(drive->id) && |
| 599 | (drive->capacity64 >= (1UL << 28))) | 530 | (drive->capacity64 >= (1UL << 28))) |
| 600 | task->tf.command = WIN_FLUSH_CACHE_EXT; | 531 | task->tf.command = ATA_CMD_FLUSH_EXT; |
| 601 | else | 532 | else |
| 602 | task->tf.command = WIN_FLUSH_CACHE; | 533 | task->tf.command = ATA_CMD_FLUSH; |
| 603 | task->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE | | 534 | task->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE | |
| 604 | IDE_TFLAG_DYN; | 535 | IDE_TFLAG_DYN; |
| 605 | task->data_phase = TASKFILE_NO_DATA; | 536 | task->data_phase = TASKFILE_NO_DATA; |
| @@ -609,6 +540,8 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) | |||
| 609 | rq->special = task; | 540 | rq->special = task; |
| 610 | } | 541 | } |
| 611 | 542 | ||
| 543 | ide_devset_get(multcount, mult_count); | ||
| 544 | |||
| 612 | /* | 545 | /* |
| 613 | * This is tightly woven into the driver->do_special can not touch. | 546 | * This is tightly woven into the driver->do_special can not touch. |
| 614 | * DON'T do it again until a total personality rewrite is committed. | 547 | * DON'T do it again until a total personality rewrite is committed. |
| @@ -618,7 +551,7 @@ static int set_multcount(ide_drive_t *drive, int arg) | |||
| 618 | struct request *rq; | 551 | struct request *rq; |
| 619 | int error; | 552 | int error; |
| 620 | 553 | ||
| 621 | if (arg < 0 || arg > drive->id->max_multsect) | 554 | if (arg < 0 || arg > (drive->id[ATA_ID_MAX_MULTSECT] & 0xff)) |
| 622 | return -EINVAL; | 555 | return -EINVAL; |
| 623 | 556 | ||
| 624 | if (drive->special.b.set_multmode) | 557 | if (drive->special.b.set_multmode) |
| @@ -635,22 +568,21 @@ static int set_multcount(ide_drive_t *drive, int arg) | |||
| 635 | return (drive->mult_count == arg) ? 0 : -EIO; | 568 | return (drive->mult_count == arg) ? 0 : -EIO; |
| 636 | } | 569 | } |
| 637 | 570 | ||
| 571 | ide_devset_get(nowerr, nowerr); | ||
| 572 | |||
| 638 | static int set_nowerr(ide_drive_t *drive, int arg) | 573 | static int set_nowerr(ide_drive_t *drive, int arg) |
| 639 | { | 574 | { |
| 640 | if (arg < 0 || arg > 1) | 575 | if (arg < 0 || arg > 1) |
| 641 | return -EINVAL; | 576 | return -EINVAL; |
| 642 | 577 | ||
| 643 | if (ide_spin_wait_hwgroup(drive)) | ||
| 644 | return -EBUSY; | ||
| 645 | drive->nowerr = arg; | 578 | drive->nowerr = arg; |
| 646 | drive->bad_wstat = arg ? BAD_R_STAT : BAD_W_STAT; | 579 | drive->bad_wstat = arg ? BAD_R_STAT : BAD_W_STAT; |
| 647 | spin_unlock_irq(&ide_lock); | ||
| 648 | return 0; | 580 | return 0; |
| 649 | } | 581 | } |
| 650 | 582 | ||
| 651 | static void update_ordered(ide_drive_t *drive) | 583 | static void update_ordered(ide_drive_t *drive) |
| 652 | { | 584 | { |
| 653 | struct hd_driveid *id = drive->id; | 585 | u16 *id = drive->id; |
| 654 | unsigned ordered = QUEUE_ORDERED_NONE; | 586 | unsigned ordered = QUEUE_ORDERED_NONE; |
| 655 | prepare_flush_fn *prep_fn = NULL; | 587 | prepare_flush_fn *prep_fn = NULL; |
| 656 | 588 | ||
| @@ -666,9 +598,9 @@ static void update_ordered(ide_drive_t *drive) | |||
| 666 | * not available so we don't need to recheck that. | 598 | * not available so we don't need to recheck that. |
| 667 | */ | 599 | */ |
| 668 | capacity = idedisk_capacity(drive); | 600 | capacity = idedisk_capacity(drive); |
| 669 | barrier = ide_id_has_flush_cache(id) && !drive->noflush && | 601 | barrier = ata_id_flush_enabled(id) && !drive->noflush && |
| 670 | (drive->addressing == 0 || capacity <= (1ULL << 28) || | 602 | (drive->addressing == 0 || capacity <= (1ULL << 28) || |
| 671 | ide_id_has_flush_cache_ext(id)); | 603 | ata_id_flush_ext_enabled(id)); |
| 672 | 604 | ||
| 673 | printk(KERN_INFO "%s: cache flushes %ssupported\n", | 605 | printk(KERN_INFO "%s: cache flushes %ssupported\n", |
| 674 | drive->name, barrier ? "" : "not "); | 606 | drive->name, barrier ? "" : "not "); |
| @@ -683,7 +615,9 @@ static void update_ordered(ide_drive_t *drive) | |||
| 683 | blk_queue_ordered(drive->queue, ordered, prep_fn); | 615 | blk_queue_ordered(drive->queue, ordered, prep_fn); |
| 684 | } | 616 | } |
| 685 | 617 | ||
| 686 | static int write_cache(ide_drive_t *drive, int arg) | 618 | ide_devset_get(wcache, wcache); |
| 619 | |||
| 620 | static int set_wcache(ide_drive_t *drive, int arg) | ||
| 687 | { | 621 | { |
| 688 | ide_task_t args; | 622 | ide_task_t args; |
| 689 | int err = 1; | 623 | int err = 1; |
| @@ -691,11 +625,11 @@ static int write_cache(ide_drive_t *drive, int arg) | |||
| 691 | if (arg < 0 || arg > 1) | 625 | if (arg < 0 || arg > 1) |
| 692 | return -EINVAL; | 626 | return -EINVAL; |
| 693 | 627 | ||
| 694 | if (ide_id_has_flush_cache(drive->id)) { | 628 | if (ata_id_flush_enabled(drive->id)) { |
| 695 | memset(&args, 0, sizeof(ide_task_t)); | 629 | memset(&args, 0, sizeof(ide_task_t)); |
| 696 | args.tf.feature = arg ? | 630 | args.tf.feature = arg ? |
| 697 | SETFEATURES_EN_WCACHE : SETFEATURES_DIS_WCACHE; | 631 | SETFEATURES_WC_ON : SETFEATURES_WC_OFF; |
| 698 | args.tf.command = WIN_SETFEATURES; | 632 | args.tf.command = ATA_CMD_SET_FEATURES; |
| 699 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | 633 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
| 700 | err = ide_no_data_taskfile(drive, &args); | 634 | err = ide_no_data_taskfile(drive, &args); |
| 701 | if (err == 0) | 635 | if (err == 0) |
| @@ -712,14 +646,16 @@ static int do_idedisk_flushcache(ide_drive_t *drive) | |||
| 712 | ide_task_t args; | 646 | ide_task_t args; |
| 713 | 647 | ||
| 714 | memset(&args, 0, sizeof(ide_task_t)); | 648 | memset(&args, 0, sizeof(ide_task_t)); |
| 715 | if (ide_id_has_flush_cache_ext(drive->id)) | 649 | if (ata_id_flush_ext_enabled(drive->id)) |
| 716 | args.tf.command = WIN_FLUSH_CACHE_EXT; | 650 | args.tf.command = ATA_CMD_FLUSH_EXT; |
| 717 | else | 651 | else |
| 718 | args.tf.command = WIN_FLUSH_CACHE; | 652 | args.tf.command = ATA_CMD_FLUSH; |
| 719 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | 653 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
| 720 | return ide_no_data_taskfile(drive, &args); | 654 | return ide_no_data_taskfile(drive, &args); |
| 721 | } | 655 | } |
| 722 | 656 | ||
| 657 | ide_devset_get(acoustic, acoustic); | ||
| 658 | |||
| 723 | static int set_acoustic(ide_drive_t *drive, int arg) | 659 | static int set_acoustic(ide_drive_t *drive, int arg) |
| 724 | { | 660 | { |
| 725 | ide_task_t args; | 661 | ide_task_t args; |
| @@ -728,22 +664,24 @@ static int set_acoustic(ide_drive_t *drive, int arg) | |||
| 728 | return -EINVAL; | 664 | return -EINVAL; |
| 729 | 665 | ||
| 730 | memset(&args, 0, sizeof(ide_task_t)); | 666 | memset(&args, 0, sizeof(ide_task_t)); |
| 731 | args.tf.feature = arg ? SETFEATURES_EN_AAM : SETFEATURES_DIS_AAM; | 667 | args.tf.feature = arg ? SETFEATURES_AAM_ON : SETFEATURES_AAM_OFF; |
| 732 | args.tf.nsect = arg; | 668 | args.tf.nsect = arg; |
| 733 | args.tf.command = WIN_SETFEATURES; | 669 | args.tf.command = ATA_CMD_SET_FEATURES; |
| 734 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | 670 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
| 735 | ide_no_data_taskfile(drive, &args); | 671 | ide_no_data_taskfile(drive, &args); |
| 736 | drive->acoustic = arg; | 672 | drive->acoustic = arg; |
| 737 | return 0; | 673 | return 0; |
| 738 | } | 674 | } |
| 739 | 675 | ||
| 676 | ide_devset_get(addressing, addressing); | ||
| 677 | |||
| 740 | /* | 678 | /* |
| 741 | * drive->addressing: | 679 | * drive->addressing: |
| 742 | * 0: 28-bit | 680 | * 0: 28-bit |
| 743 | * 1: 48-bit | 681 | * 1: 48-bit |
| 744 | * 2: 48-bit capable doing 28-bit | 682 | * 2: 48-bit capable doing 28-bit |
| 745 | */ | 683 | */ |
| 746 | static int set_lba_addressing(ide_drive_t *drive, int arg) | 684 | static int set_addressing(ide_drive_t *drive, int arg) |
| 747 | { | 685 | { |
| 748 | if (arg < 0 || arg > 2) | 686 | if (arg < 0 || arg > 2) |
| 749 | return -EINVAL; | 687 | return -EINVAL; |
| @@ -753,52 +691,54 @@ static int set_lba_addressing(ide_drive_t *drive, int arg) | |||
| 753 | if (drive->hwif->host_flags & IDE_HFLAG_NO_LBA48) | 691 | if (drive->hwif->host_flags & IDE_HFLAG_NO_LBA48) |
| 754 | return 0; | 692 | return 0; |
| 755 | 693 | ||
| 756 | if (!idedisk_supports_lba48(drive->id)) | 694 | if (ata_id_lba48_enabled(drive->id) == 0) |
| 757 | return -EIO; | 695 | return -EIO; |
| 696 | |||
| 758 | drive->addressing = arg; | 697 | drive->addressing = arg; |
| 698 | |||
| 759 | return 0; | 699 | return 0; |
| 760 | } | 700 | } |
| 761 | 701 | ||
| 702 | ide_devset_rw(acoustic, acoustic); | ||
| 703 | ide_devset_rw(address, addressing); | ||
| 704 | ide_devset_rw(multcount, multcount); | ||
| 705 | ide_devset_rw(wcache, wcache); | ||
| 706 | |||
| 707 | ide_devset_rw_sync(nowerr, nowerr); | ||
| 708 | |||
| 762 | #ifdef CONFIG_IDE_PROC_FS | 709 | #ifdef CONFIG_IDE_PROC_FS |
| 763 | static void idedisk_add_settings(ide_drive_t *drive) | 710 | ide_devset_rw_field(bios_cyl, bios_cyl); |
| 764 | { | 711 | ide_devset_rw_field(bios_head, bios_head); |
| 765 | struct hd_driveid *id = drive->id; | 712 | ide_devset_rw_field(bios_sect, bios_sect); |
| 766 | 713 | ide_devset_rw_field(failures, failures); | |
| 767 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, | 714 | ide_devset_rw_field(lun, lun); |
| 768 | &drive->bios_cyl, NULL); | 715 | ide_devset_rw_field(max_failures, max_failures); |
| 769 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, | 716 | |
| 770 | &drive->bios_head, NULL); | 717 | static const struct ide_proc_devset idedisk_settings[] = { |
| 771 | ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, | 718 | IDE_PROC_DEVSET(acoustic, 0, 254), |
| 772 | &drive->bios_sect, NULL); | 719 | IDE_PROC_DEVSET(address, 0, 2), |
| 773 | ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1, | 720 | IDE_PROC_DEVSET(bios_cyl, 0, 65535), |
| 774 | &drive->addressing, set_lba_addressing); | 721 | IDE_PROC_DEVSET(bios_head, 0, 255), |
| 775 | ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0, | 722 | IDE_PROC_DEVSET(bios_sect, 0, 63), |
| 776 | id->max_multsect, 1, 1, &drive->mult_count, | 723 | IDE_PROC_DEVSET(failures, 0, 65535), |
| 777 | set_multcount); | 724 | IDE_PROC_DEVSET(lun, 0, 7), |
| 778 | ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, | 725 | IDE_PROC_DEVSET(max_failures, 0, 65535), |
| 779 | &drive->nowerr, set_nowerr); | 726 | IDE_PROC_DEVSET(multcount, 0, 16), |
| 780 | ide_add_setting(drive, "lun", SETTING_RW, TYPE_INT, 0, 7, 1, 1, | 727 | IDE_PROC_DEVSET(nowerr, 0, 1), |
| 781 | &drive->lun, NULL); | 728 | IDE_PROC_DEVSET(wcache, 0, 1), |
| 782 | ide_add_setting(drive, "wcache", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, | 729 | { 0 }, |
| 783 | &drive->wcache, write_cache); | 730 | }; |
| 784 | ide_add_setting(drive, "acoustic", SETTING_RW, TYPE_BYTE, 0, 254, 1, 1, | ||
| 785 | &drive->acoustic, set_acoustic); | ||
| 786 | ide_add_setting(drive, "failures", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, | ||
| 787 | &drive->failures, NULL); | ||
| 788 | ide_add_setting(drive, "max_failures", SETTING_RW, TYPE_INT, 0, 65535, | ||
| 789 | 1, 1, &drive->max_failures, NULL); | ||
| 790 | } | ||
| 791 | #else | ||
| 792 | static inline void idedisk_add_settings(ide_drive_t *drive) { ; } | ||
| 793 | #endif | 731 | #endif |
| 794 | 732 | ||
| 795 | static void idedisk_setup(ide_drive_t *drive) | 733 | static void idedisk_setup(ide_drive_t *drive) |
| 796 | { | 734 | { |
| 735 | struct ide_disk_obj *idkp = drive->driver_data; | ||
| 797 | ide_hwif_t *hwif = drive->hwif; | 736 | ide_hwif_t *hwif = drive->hwif; |
| 798 | struct hd_driveid *id = drive->id; | 737 | u16 *id = drive->id; |
| 738 | char *m = (char *)&id[ATA_ID_PROD]; | ||
| 799 | unsigned long long capacity; | 739 | unsigned long long capacity; |
| 800 | 740 | ||
| 801 | idedisk_add_settings(drive); | 741 | ide_proc_register_driver(drive, idkp->driver); |
| 802 | 742 | ||
| 803 | if (drive->id_read == 0) | 743 | if (drive->id_read == 0) |
| 804 | return; | 744 | return; |
| @@ -807,11 +747,11 @@ static void idedisk_setup(ide_drive_t *drive) | |||
| 807 | /* | 747 | /* |
| 808 | * Removable disks (eg. SYQUEST); ignore 'WD' drives | 748 | * Removable disks (eg. SYQUEST); ignore 'WD' drives |
| 809 | */ | 749 | */ |
| 810 | if (id->model[0] != 'W' || id->model[1] != 'D') | 750 | if (m[0] != 'W' || m[1] != 'D') |
| 811 | drive->doorlocking = 1; | 751 | drive->doorlocking = 1; |
| 812 | } | 752 | } |
| 813 | 753 | ||
| 814 | (void)set_lba_addressing(drive, 1); | 754 | (void)set_addressing(drive, 1); |
| 815 | 755 | ||
| 816 | if (drive->addressing == 1) { | 756 | if (drive->addressing == 1) { |
| 817 | int max_s = 2048; | 757 | int max_s = 2048; |
| @@ -853,8 +793,7 @@ static void idedisk_setup(ide_drive_t *drive) | |||
| 853 | capacity = idedisk_capacity(drive); | 793 | capacity = idedisk_capacity(drive); |
| 854 | 794 | ||
| 855 | if (!drive->forced_geom) { | 795 | if (!drive->forced_geom) { |
| 856 | 796 | if (ata_id_lba48_enabled(drive->id)) { | |
| 857 | if (idedisk_supports_lba48(drive->id)) { | ||
| 858 | /* compatibility */ | 797 | /* compatibility */ |
| 859 | drive->bios_sect = 63; | 798 | drive->bios_sect = 63; |
| 860 | drive->bios_head = 255; | 799 | drive->bios_head = 255; |
| @@ -880,22 +819,22 @@ static void idedisk_setup(ide_drive_t *drive) | |||
| 880 | drive->name, capacity, sectors_to_MB(capacity)); | 819 | drive->name, capacity, sectors_to_MB(capacity)); |
| 881 | 820 | ||
| 882 | /* Only print cache size when it was specified */ | 821 | /* Only print cache size when it was specified */ |
| 883 | if (id->buf_size) | 822 | if (id[ATA_ID_BUF_SIZE]) |
| 884 | printk(KERN_CONT " w/%dKiB Cache", id->buf_size / 2); | 823 | printk(KERN_CONT " w/%dKiB Cache", id[ATA_ID_BUF_SIZE] / 2); |
| 885 | 824 | ||
| 886 | printk(KERN_CONT ", CHS=%d/%d/%d\n", | 825 | printk(KERN_CONT ", CHS=%d/%d/%d\n", |
| 887 | drive->bios_cyl, drive->bios_head, drive->bios_sect); | 826 | drive->bios_cyl, drive->bios_head, drive->bios_sect); |
| 888 | 827 | ||
| 889 | /* write cache enabled? */ | 828 | /* write cache enabled? */ |
| 890 | if ((id->csfo & 1) || (id->cfs_enable_1 & (1 << 5))) | 829 | if ((id[ATA_ID_CSFO] & 1) || ata_id_wcache_enabled(id)) |
| 891 | drive->wcache = 1; | 830 | drive->wcache = 1; |
| 892 | 831 | ||
| 893 | write_cache(drive, 1); | 832 | set_wcache(drive, 1); |
| 894 | } | 833 | } |
| 895 | 834 | ||
| 896 | static void ide_cacheflush_p(ide_drive_t *drive) | 835 | static void ide_cacheflush_p(ide_drive_t *drive) |
| 897 | { | 836 | { |
| 898 | if (!drive->wcache || !ide_id_has_flush_cache(drive->id)) | 837 | if (!drive->wcache || ata_id_flush_enabled(drive->id) == 0) |
| 899 | return; | 838 | return; |
| 900 | 839 | ||
| 901 | if (do_idedisk_flushcache(drive)) | 840 | if (do_idedisk_flushcache(drive)) |
| @@ -937,7 +876,7 @@ static int ide_disk_probe(ide_drive_t *drive); | |||
| 937 | */ | 876 | */ |
| 938 | static void ide_disk_resume(ide_drive_t *drive) | 877 | static void ide_disk_resume(ide_drive_t *drive) |
| 939 | { | 878 | { |
| 940 | if (idedisk_supports_hpa(drive->id)) | 879 | if (ata_id_hpa_enabled(drive->id)) |
| 941 | init_idedisk_capacity(drive); | 880 | init_idedisk_capacity(drive); |
| 942 | } | 881 | } |
| 943 | 882 | ||
| @@ -980,12 +919,12 @@ static ide_driver_t idedisk_driver = { | |||
| 980 | .shutdown = ide_device_shutdown, | 919 | .shutdown = ide_device_shutdown, |
| 981 | .version = IDEDISK_VERSION, | 920 | .version = IDEDISK_VERSION, |
| 982 | .media = ide_disk, | 921 | .media = ide_disk, |
| 983 | .supports_dsc_overlap = 0, | ||
| 984 | .do_request = ide_do_rw_disk, | 922 | .do_request = ide_do_rw_disk, |
| 985 | .end_request = ide_end_request, | 923 | .end_request = ide_end_request, |
| 986 | .error = __ide_error, | 924 | .error = __ide_error, |
| 987 | #ifdef CONFIG_IDE_PROC_FS | 925 | #ifdef CONFIG_IDE_PROC_FS |
| 988 | .proc = idedisk_proc, | 926 | .proc = idedisk_proc, |
| 927 | .settings = idedisk_settings, | ||
| 989 | #endif | 928 | #endif |
| 990 | }; | 929 | }; |
| 991 | 930 | ||
| @@ -994,7 +933,7 @@ static int idedisk_set_doorlock(ide_drive_t *drive, int on) | |||
| 994 | ide_task_t task; | 933 | ide_task_t task; |
| 995 | 934 | ||
| 996 | memset(&task, 0, sizeof(task)); | 935 | memset(&task, 0, sizeof(task)); |
| 997 | task.tf.command = on ? WIN_DOORLOCK : WIN_DOORUNLOCK; | 936 | task.tf.command = on ? ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK; |
| 998 | task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | 937 | task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
| 999 | 938 | ||
| 1000 | return ide_no_data_taskfile(drive, &task); | 939 | return ide_no_data_taskfile(drive, &task); |
| @@ -1059,52 +998,28 @@ static int idedisk_getgeo(struct block_device *bdev, struct hd_geometry *geo) | |||
| 1059 | return 0; | 998 | return 0; |
| 1060 | } | 999 | } |
| 1061 | 1000 | ||
| 1001 | static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = { | ||
| 1002 | { HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address }, | ||
| 1003 | { HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount }, | ||
| 1004 | { HDIO_GET_NOWERR, HDIO_SET_NOWERR, &ide_devset_nowerr }, | ||
| 1005 | { HDIO_GET_WCACHE, HDIO_SET_WCACHE, &ide_devset_wcache }, | ||
| 1006 | { HDIO_GET_ACOUSTIC, HDIO_SET_ACOUSTIC, &ide_devset_acoustic }, | ||
| 1007 | { 0 } | ||
| 1008 | }; | ||
| 1009 | |||
| 1062 | static int idedisk_ioctl(struct inode *inode, struct file *file, | 1010 | static int idedisk_ioctl(struct inode *inode, struct file *file, |
| 1063 | unsigned int cmd, unsigned long arg) | 1011 | unsigned int cmd, unsigned long arg) |
| 1064 | { | 1012 | { |
| 1065 | unsigned long flags; | ||
| 1066 | struct block_device *bdev = inode->i_bdev; | 1013 | struct block_device *bdev = inode->i_bdev; |
| 1067 | struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk); | 1014 | struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk); |
| 1068 | ide_drive_t *drive = idkp->drive; | 1015 | ide_drive_t *drive = idkp->drive; |
| 1069 | int err, (*setfunc)(ide_drive_t *, int); | 1016 | int err; |
| 1070 | u8 *val; | ||
| 1071 | |||
| 1072 | switch (cmd) { | ||
| 1073 | case HDIO_GET_ADDRESS: val = &drive->addressing; goto read_val; | ||
| 1074 | case HDIO_GET_MULTCOUNT: val = &drive->mult_count; goto read_val; | ||
| 1075 | case HDIO_GET_NOWERR: val = &drive->nowerr; goto read_val; | ||
| 1076 | case HDIO_GET_WCACHE: val = &drive->wcache; goto read_val; | ||
| 1077 | case HDIO_GET_ACOUSTIC: val = &drive->acoustic; goto read_val; | ||
| 1078 | case HDIO_SET_ADDRESS: setfunc = set_lba_addressing; goto set_val; | ||
| 1079 | case HDIO_SET_MULTCOUNT: setfunc = set_multcount; goto set_val; | ||
| 1080 | case HDIO_SET_NOWERR: setfunc = set_nowerr; goto set_val; | ||
| 1081 | case HDIO_SET_WCACHE: setfunc = write_cache; goto set_val; | ||
| 1082 | case HDIO_SET_ACOUSTIC: setfunc = set_acoustic; goto set_val; | ||
| 1083 | } | ||
| 1084 | 1017 | ||
| 1085 | return generic_ide_ioctl(drive, file, bdev, cmd, arg); | 1018 | err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); |
| 1019 | if (err != -EOPNOTSUPP) | ||
| 1020 | return err; | ||
| 1086 | 1021 | ||
| 1087 | read_val: | 1022 | return generic_ide_ioctl(drive, file, bdev, cmd, arg); |
| 1088 | mutex_lock(&ide_setting_mtx); | ||
| 1089 | spin_lock_irqsave(&ide_lock, flags); | ||
| 1090 | err = *val; | ||
| 1091 | spin_unlock_irqrestore(&ide_lock, flags); | ||
| 1092 | mutex_unlock(&ide_setting_mtx); | ||
| 1093 | return err >= 0 ? put_user(err, (long __user *)arg) : err; | ||
| 1094 | |||
| 1095 | set_val: | ||
| 1096 | if (bdev != bdev->bd_contains) | ||
| 1097 | err = -EINVAL; | ||
| 1098 | else { | ||
| 1099 | if (!capable(CAP_SYS_ADMIN)) | ||
| 1100 | err = -EACCES; | ||
| 1101 | else { | ||
| 1102 | mutex_lock(&ide_setting_mtx); | ||
| 1103 | err = setfunc(drive, arg); | ||
| 1104 | mutex_unlock(&ide_setting_mtx); | ||
| 1105 | } | ||
| 1106 | } | ||
| 1107 | return err; | ||
| 1108 | } | 1023 | } |
| 1109 | 1024 | ||
| 1110 | static int idedisk_media_changed(struct gendisk *disk) | 1025 | static int idedisk_media_changed(struct gendisk *disk) |
| @@ -1148,8 +1063,7 @@ static int ide_disk_probe(ide_drive_t *drive) | |||
| 1148 | /* strstr("foo", "") is non-NULL */ | 1063 | /* strstr("foo", "") is non-NULL */ |
| 1149 | if (!strstr("ide-disk", drive->driver_req)) | 1064 | if (!strstr("ide-disk", drive->driver_req)) |
| 1150 | goto failed; | 1065 | goto failed; |
| 1151 | if (!drive->present) | 1066 | |
| 1152 | goto failed; | ||
| 1153 | if (drive->media != ide_disk) | 1067 | if (drive->media != ide_disk) |
| 1154 | goto failed; | 1068 | goto failed; |
| 1155 | 1069 | ||
| @@ -1163,8 +1077,6 @@ static int ide_disk_probe(ide_drive_t *drive) | |||
| 1163 | 1077 | ||
| 1164 | ide_init_disk(g, drive); | 1078 | ide_init_disk(g, drive); |
| 1165 | 1079 | ||
| 1166 | ide_proc_register_driver(drive, &idedisk_driver); | ||
| 1167 | |||
| 1168 | kref_init(&idkp->kref); | 1080 | kref_init(&idkp->kref); |
| 1169 | 1081 | ||
| 1170 | idkp->drive = drive; | 1082 | idkp->drive = drive; |
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c index 3fa07c0aeaa4..ef2f1504c0d5 100644 --- a/drivers/ide/ide-dma.c +++ b/drivers/ide/ide-dma.c | |||
| @@ -106,7 +106,7 @@ ide_startstop_t ide_dma_intr (ide_drive_t *drive) | |||
| 106 | dma_stat = hwif->dma_ops->dma_end(drive); | 106 | dma_stat = hwif->dma_ops->dma_end(drive); |
| 107 | stat = hwif->tp_ops->read_status(hwif); | 107 | stat = hwif->tp_ops->read_status(hwif); |
| 108 | 108 | ||
| 109 | if (OK_STAT(stat,DRIVE_READY,drive->bad_wstat|DRQ_STAT)) { | 109 | if (OK_STAT(stat, DRIVE_READY, drive->bad_wstat | ATA_DRQ)) { |
| 110 | if (!dma_stat) { | 110 | if (!dma_stat) { |
| 111 | struct request *rq = HWGROUP(drive)->rq; | 111 | struct request *rq = HWGROUP(drive)->rq; |
| 112 | 112 | ||
| @@ -288,7 +288,7 @@ EXPORT_SYMBOL_GPL(ide_destroy_dmatable); | |||
| 288 | static int config_drive_for_dma (ide_drive_t *drive) | 288 | static int config_drive_for_dma (ide_drive_t *drive) |
| 289 | { | 289 | { |
| 290 | ide_hwif_t *hwif = drive->hwif; | 290 | ide_hwif_t *hwif = drive->hwif; |
| 291 | struct hd_driveid *id = drive->id; | 291 | u16 *id = drive->id; |
| 292 | 292 | ||
| 293 | if (drive->media != ide_disk) { | 293 | if (drive->media != ide_disk) { |
| 294 | if (hwif->host_flags & IDE_HFLAG_NO_ATAPI_DMA) | 294 | if (hwif->host_flags & IDE_HFLAG_NO_ATAPI_DMA) |
| @@ -299,16 +299,17 @@ static int config_drive_for_dma (ide_drive_t *drive) | |||
| 299 | * Enable DMA on any drive that has | 299 | * Enable DMA on any drive that has |
| 300 | * UltraDMA (mode 0/1/2/3/4/5/6) enabled | 300 | * UltraDMA (mode 0/1/2/3/4/5/6) enabled |
| 301 | */ | 301 | */ |
| 302 | if ((id->field_valid & 4) && ((id->dma_ultra >> 8) & 0x7f)) | 302 | if ((id[ATA_ID_FIELD_VALID] & 4) && |
| 303 | ((id[ATA_ID_UDMA_MODES] >> 8) & 0x7f)) | ||
| 303 | return 1; | 304 | return 1; |
| 304 | 305 | ||
| 305 | /* | 306 | /* |
| 306 | * Enable DMA on any drive that has mode2 DMA | 307 | * Enable DMA on any drive that has mode2 DMA |
| 307 | * (multi or single) enabled | 308 | * (multi or single) enabled |
| 308 | */ | 309 | */ |
| 309 | if (id->field_valid & 2) /* regular DMA */ | 310 | if (id[ATA_ID_FIELD_VALID] & 2) /* regular DMA */ |
| 310 | if ((id->dma_mword & 0x404) == 0x404 || | 311 | if ((id[ATA_ID_MWDMA_MODES] & 0x404) == 0x404 || |
| 311 | (id->dma_1word & 0x404) == 0x404) | 312 | (id[ATA_ID_SWDMA_MODES] & 0x404) == 0x404) |
| 312 | return 1; | 313 | return 1; |
| 313 | 314 | ||
| 314 | /* Consult the list of known "good" drives */ | 315 | /* Consult the list of known "good" drives */ |
| @@ -591,12 +592,12 @@ static inline int config_drive_for_dma(ide_drive_t *drive) { return 0; } | |||
| 591 | 592 | ||
| 592 | int __ide_dma_bad_drive (ide_drive_t *drive) | 593 | int __ide_dma_bad_drive (ide_drive_t *drive) |
| 593 | { | 594 | { |
| 594 | struct hd_driveid *id = drive->id; | 595 | u16 *id = drive->id; |
| 595 | 596 | ||
| 596 | int blacklist = ide_in_drive_list(id, drive_blacklist); | 597 | int blacklist = ide_in_drive_list(id, drive_blacklist); |
| 597 | if (blacklist) { | 598 | if (blacklist) { |
| 598 | printk(KERN_WARNING "%s: Disabling (U)DMA for %s (blacklisted)\n", | 599 | printk(KERN_WARNING "%s: Disabling (U)DMA for %s (blacklisted)\n", |
| 599 | drive->name, id->model); | 600 | drive->name, (char *)&id[ATA_ID_PROD]); |
| 600 | return blacklist; | 601 | return blacklist; |
| 601 | } | 602 | } |
| 602 | return 0; | 603 | return 0; |
| @@ -612,21 +613,21 @@ static const u8 xfer_mode_bases[] = { | |||
| 612 | 613 | ||
| 613 | static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) | 614 | static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) |
| 614 | { | 615 | { |
| 615 | struct hd_driveid *id = drive->id; | 616 | u16 *id = drive->id; |
| 616 | ide_hwif_t *hwif = drive->hwif; | 617 | ide_hwif_t *hwif = drive->hwif; |
| 617 | const struct ide_port_ops *port_ops = hwif->port_ops; | 618 | const struct ide_port_ops *port_ops = hwif->port_ops; |
| 618 | unsigned int mask = 0; | 619 | unsigned int mask = 0; |
| 619 | 620 | ||
| 620 | switch(base) { | 621 | switch(base) { |
| 621 | case XFER_UDMA_0: | 622 | case XFER_UDMA_0: |
| 622 | if ((id->field_valid & 4) == 0) | 623 | if ((id[ATA_ID_FIELD_VALID] & 4) == 0) |
| 623 | break; | 624 | break; |
| 624 | 625 | ||
| 625 | if (port_ops && port_ops->udma_filter) | 626 | if (port_ops && port_ops->udma_filter) |
| 626 | mask = port_ops->udma_filter(drive); | 627 | mask = port_ops->udma_filter(drive); |
| 627 | else | 628 | else |
| 628 | mask = hwif->ultra_mask; | 629 | mask = hwif->ultra_mask; |
| 629 | mask &= id->dma_ultra; | 630 | mask &= id[ATA_ID_UDMA_MODES]; |
| 630 | 631 | ||
| 631 | /* | 632 | /* |
| 632 | * avoid false cable warning from eighty_ninty_three() | 633 | * avoid false cable warning from eighty_ninty_three() |
| @@ -637,19 +638,19 @@ static unsigned int ide_get_mode_mask(ide_drive_t *drive, u8 base, u8 req_mode) | |||
| 637 | } | 638 | } |
| 638 | break; | 639 | break; |
| 639 | case XFER_MW_DMA_0: | 640 | case XFER_MW_DMA_0: |
| 640 | if ((id->field_valid & 2) == 0) | 641 | if ((id[ATA_ID_FIELD_VALID] & 2) == 0) |
| 641 | break; | 642 | break; |
| 642 | if (port_ops && port_ops->mdma_filter) | 643 | if (port_ops && port_ops->mdma_filter) |
| 643 | mask = port_ops->mdma_filter(drive); | 644 | mask = port_ops->mdma_filter(drive); |
| 644 | else | 645 | else |
| 645 | mask = hwif->mwdma_mask; | 646 | mask = hwif->mwdma_mask; |
| 646 | mask &= id->dma_mword; | 647 | mask &= id[ATA_ID_MWDMA_MODES]; |
| 647 | break; | 648 | break; |
| 648 | case XFER_SW_DMA_0: | 649 | case XFER_SW_DMA_0: |
| 649 | if (id->field_valid & 2) { | 650 | if (id[ATA_ID_FIELD_VALID] & 2) { |
| 650 | mask = id->dma_1word & hwif->swdma_mask; | 651 | mask = id[ATA_ID_SWDMA_MODES] & hwif->swdma_mask; |
| 651 | } else if (id->tDMA) { | 652 | } else if (id[ATA_ID_OLD_DMA_MODES] >> 8) { |
| 652 | u8 mode = id->tDMA; | 653 | u8 mode = id[ATA_ID_OLD_DMA_MODES] >> 8; |
| 653 | 654 | ||
| 654 | /* | 655 | /* |
| 655 | * if the mode is valid convert it to the mask | 656 | * if the mode is valid convert it to the mask |
| @@ -706,7 +707,8 @@ u8 ide_find_dma_mode(ide_drive_t *drive, u8 req_mode) | |||
| 706 | /* | 707 | /* |
| 707 | * is this correct? | 708 | * is this correct? |
| 708 | */ | 709 | */ |
| 709 | if (ide_dma_good_drive(drive) && drive->id->eide_dma_time < 150) | 710 | if (ide_dma_good_drive(drive) && |
| 711 | drive->id[ATA_ID_EIDE_DMA_TIME] < 150) | ||
| 710 | mode = XFER_MW_DMA_1; | 712 | mode = XFER_MW_DMA_1; |
| 711 | } | 713 | } |
| 712 | 714 | ||
| @@ -725,7 +727,7 @@ static int ide_tune_dma(ide_drive_t *drive) | |||
| 725 | ide_hwif_t *hwif = drive->hwif; | 727 | ide_hwif_t *hwif = drive->hwif; |
| 726 | u8 speed; | 728 | u8 speed; |
| 727 | 729 | ||
| 728 | if (drive->nodma || (drive->id->capability & 1) == 0) | 730 | if (drive->nodma || ata_id_has_dma(drive->id) == 0) |
| 729 | return 0; | 731 | return 0; |
| 730 | 732 | ||
| 731 | /* consult the list of known "bad" drives */ | 733 | /* consult the list of known "bad" drives */ |
| @@ -767,13 +769,15 @@ static int ide_dma_check(ide_drive_t *drive) | |||
| 767 | 769 | ||
| 768 | int ide_id_dma_bug(ide_drive_t *drive) | 770 | int ide_id_dma_bug(ide_drive_t *drive) |
| 769 | { | 771 | { |
| 770 | struct hd_driveid *id = drive->id; | 772 | u16 *id = drive->id; |
| 771 | 773 | ||
| 772 | if (id->field_valid & 4) { | 774 | if (id[ATA_ID_FIELD_VALID] & 4) { |
| 773 | if ((id->dma_ultra >> 8) && (id->dma_mword >> 8)) | 775 | if ((id[ATA_ID_UDMA_MODES] >> 8) && |
| 776 | (id[ATA_ID_MWDMA_MODES] >> 8)) | ||
| 774 | goto err_out; | 777 | goto err_out; |
| 775 | } else if (id->field_valid & 2) { | 778 | } else if (id[ATA_ID_FIELD_VALID] & 2) { |
| 776 | if ((id->dma_mword >> 8) && (id->dma_1word >> 8)) | 779 | if ((id[ATA_ID_MWDMA_MODES] >> 8) && |
| 780 | (id[ATA_ID_SWDMA_MODES] >> 8)) | ||
| 777 | goto err_out; | 781 | goto err_out; |
| 778 | } | 782 | } |
| 779 | return 0; | 783 | return 0; |
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c index e9034c0125f3..d36f155470a4 100644 --- a/drivers/ide/ide-floppy.c +++ b/drivers/ide/ide-floppy.c | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | * Documentation/ide/ChangeLog.ide-floppy.1996-2002 | 15 | * Documentation/ide/ChangeLog.ide-floppy.1996-2002 |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #define DRV_NAME "ide-floppy" | ||
| 19 | |||
| 18 | #define IDEFLOPPY_VERSION "1.00" | 20 | #define IDEFLOPPY_VERSION "1.00" |
| 19 | 21 | ||
| 20 | #include <linux/module.h> | 22 | #include <linux/module.h> |
| @@ -31,8 +33,10 @@ | |||
| 31 | #include <linux/slab.h> | 33 | #include <linux/slab.h> |
| 32 | #include <linux/cdrom.h> | 34 | #include <linux/cdrom.h> |
| 33 | #include <linux/ide.h> | 35 | #include <linux/ide.h> |
| 36 | #include <linux/hdreg.h> | ||
| 34 | #include <linux/bitops.h> | 37 | #include <linux/bitops.h> |
| 35 | #include <linux/mutex.h> | 38 | #include <linux/mutex.h> |
| 39 | #include <linux/scatterlist.h> | ||
| 36 | 40 | ||
| 37 | #include <scsi/scsi_ioctl.h> | 41 | #include <scsi/scsi_ioctl.h> |
| 38 | 42 | ||
| @@ -42,6 +46,8 @@ | |||
| 42 | #include <linux/io.h> | 46 | #include <linux/io.h> |
| 43 | #include <asm/unaligned.h> | 47 | #include <asm/unaligned.h> |
| 44 | 48 | ||
| 49 | #include "ide-floppy.h" | ||
| 50 | |||
| 45 | /* define to see debug info */ | 51 | /* define to see debug info */ |
| 46 | #define IDEFLOPPY_DEBUG_LOG 0 | 52 | #define IDEFLOPPY_DEBUG_LOG 0 |
| 47 | 53 | ||
| @@ -55,102 +61,23 @@ | |||
| 55 | #define debug_log(fmt, args...) do {} while (0) | 61 | #define debug_log(fmt, args...) do {} while (0) |
| 56 | #endif | 62 | #endif |
| 57 | 63 | ||
| 58 | |||
| 59 | /* Some drives require a longer irq timeout. */ | ||
| 60 | #define IDEFLOPPY_WAIT_CMD (5 * WAIT_CMD) | ||
| 61 | |||
| 62 | /* | 64 | /* |
| 63 | * After each failed packet command we issue a request sense command and retry | 65 | * After each failed packet command we issue a request sense command and retry |
| 64 | * the packet command IDEFLOPPY_MAX_PC_RETRIES times. | 66 | * the packet command IDEFLOPPY_MAX_PC_RETRIES times. |
| 65 | */ | 67 | */ |
| 66 | #define IDEFLOPPY_MAX_PC_RETRIES 3 | 68 | #define IDEFLOPPY_MAX_PC_RETRIES 3 |
| 67 | 69 | ||
| 68 | /* | ||
| 69 | * With each packet command, we allocate a buffer of IDEFLOPPY_PC_BUFFER_SIZE | ||
| 70 | * bytes. | ||
| 71 | */ | ||
| 72 | #define IDEFLOPPY_PC_BUFFER_SIZE 256 | ||
| 73 | |||
| 74 | /* | ||
| 75 | * In various places in the driver, we need to allocate storage for packet | ||
| 76 | * commands and requests, which will remain valid while we leave the driver to | ||
| 77 | * wait for an interrupt or a timeout event. | ||
| 78 | */ | ||
| 79 | #define IDEFLOPPY_PC_STACK (10 + IDEFLOPPY_MAX_PC_RETRIES) | ||
| 80 | |||
| 81 | /* format capacities descriptor codes */ | 70 | /* format capacities descriptor codes */ |
| 82 | #define CAPACITY_INVALID 0x00 | 71 | #define CAPACITY_INVALID 0x00 |
| 83 | #define CAPACITY_UNFORMATTED 0x01 | 72 | #define CAPACITY_UNFORMATTED 0x01 |
| 84 | #define CAPACITY_CURRENT 0x02 | 73 | #define CAPACITY_CURRENT 0x02 |
| 85 | #define CAPACITY_NO_CARTRIDGE 0x03 | 74 | #define CAPACITY_NO_CARTRIDGE 0x03 |
| 86 | 75 | ||
| 87 | /* | ||
| 88 | * Most of our global data which we need to save even as we leave the driver | ||
| 89 | * due to an interrupt or a timer event is stored in a variable of type | ||
| 90 | * idefloppy_floppy_t, defined below. | ||
| 91 | */ | ||
| 92 | typedef struct ide_floppy_obj { | ||
| 93 | ide_drive_t *drive; | ||
| 94 | ide_driver_t *driver; | ||
| 95 | struct gendisk *disk; | ||
| 96 | struct kref kref; | ||
| 97 | unsigned int openers; /* protected by BKL for now */ | ||
| 98 | |||
| 99 | /* Current packet command */ | ||
| 100 | struct ide_atapi_pc *pc; | ||
| 101 | /* Last failed packet command */ | ||
| 102 | struct ide_atapi_pc *failed_pc; | ||
| 103 | /* Packet command stack */ | ||
| 104 | struct ide_atapi_pc pc_stack[IDEFLOPPY_PC_STACK]; | ||
| 105 | /* Next free packet command storage space */ | ||
| 106 | int pc_stack_index; | ||
| 107 | struct request rq_stack[IDEFLOPPY_PC_STACK]; | ||
| 108 | /* We implement a circular array */ | ||
| 109 | int rq_stack_index; | ||
| 110 | |||
| 111 | /* Last error information */ | ||
| 112 | u8 sense_key, asc, ascq; | ||
| 113 | /* delay this long before sending packet command */ | ||
| 114 | u8 ticks; | ||
| 115 | int progress_indication; | ||
| 116 | |||
| 117 | /* Device information */ | ||
| 118 | /* Current format */ | ||
| 119 | int blocks, block_size, bs_factor; | ||
| 120 | /* Last format capacity descriptor */ | ||
| 121 | u8 cap_desc[8]; | ||
| 122 | /* Copy of the flexible disk page */ | ||
| 123 | u8 flexible_disk_page[32]; | ||
| 124 | /* Write protect */ | ||
| 125 | int wp; | ||
| 126 | /* Supports format progress report */ | ||
| 127 | int srfp; | ||
| 128 | } idefloppy_floppy_t; | ||
| 129 | |||
| 130 | #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ | 76 | #define IDEFLOPPY_TICKS_DELAY HZ/20 /* default delay for ZIP 100 (50ms) */ |
| 131 | 77 | ||
| 132 | /* Defines for the MODE SENSE command */ | ||
| 133 | #define MODE_SENSE_CURRENT 0x00 | ||
| 134 | #define MODE_SENSE_CHANGEABLE 0x01 | ||
| 135 | #define MODE_SENSE_DEFAULT 0x02 | ||
| 136 | #define MODE_SENSE_SAVED 0x03 | ||
| 137 | |||
| 138 | /* IOCTLs used in low-level formatting. */ | ||
| 139 | #define IDEFLOPPY_IOCTL_FORMAT_SUPPORTED 0x4600 | ||
| 140 | #define IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY 0x4601 | ||
| 141 | #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602 | ||
| 142 | #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 | ||
| 143 | |||
| 144 | /* Error code returned in rq->errors to the higher part of the driver. */ | 78 | /* Error code returned in rq->errors to the higher part of the driver. */ |
| 145 | #define IDEFLOPPY_ERROR_GENERAL 101 | 79 | #define IDEFLOPPY_ERROR_GENERAL 101 |
| 146 | 80 | ||
| 147 | /* | ||
| 148 | * Pages of the SELECT SENSE / MODE SENSE packet commands. | ||
| 149 | * See SFF-8070i spec. | ||
| 150 | */ | ||
| 151 | #define IDEFLOPPY_CAPABILITIES_PAGE 0x1b | ||
| 152 | #define IDEFLOPPY_FLEXIBLE_DISK_PAGE 0x05 | ||
| 153 | |||
| 154 | static DEFINE_MUTEX(idefloppy_ref_mutex); | 81 | static DEFINE_MUTEX(idefloppy_ref_mutex); |
| 155 | 82 | ||
| 156 | #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) | 83 | #define to_ide_floppy(obj) container_of(obj, struct ide_floppy_obj, kref) |
| @@ -219,44 +146,6 @@ static int idefloppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) | |||
| 219 | return 0; | 146 | return 0; |
| 220 | } | 147 | } |
| 221 | 148 | ||
| 222 | static void ide_floppy_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
| 223 | unsigned int bcount, int direction) | ||
| 224 | { | ||
| 225 | ide_hwif_t *hwif = drive->hwif; | ||
| 226 | struct request *rq = pc->rq; | ||
| 227 | struct req_iterator iter; | ||
| 228 | struct bio_vec *bvec; | ||
| 229 | unsigned long flags; | ||
| 230 | int count, done = 0; | ||
| 231 | char *data; | ||
| 232 | |||
| 233 | rq_for_each_segment(bvec, rq, iter) { | ||
| 234 | if (!bcount) | ||
| 235 | break; | ||
| 236 | |||
| 237 | count = min(bvec->bv_len, bcount); | ||
| 238 | |||
| 239 | data = bvec_kmap_irq(bvec, &flags); | ||
| 240 | if (direction) | ||
| 241 | hwif->tp_ops->output_data(drive, NULL, data, count); | ||
| 242 | else | ||
| 243 | hwif->tp_ops->input_data(drive, NULL, data, count); | ||
| 244 | bvec_kunmap_irq(data, &flags); | ||
| 245 | |||
| 246 | bcount -= count; | ||
| 247 | pc->b_count += count; | ||
| 248 | done += count; | ||
| 249 | } | ||
| 250 | |||
| 251 | idefloppy_end_request(drive, 1, done >> 9); | ||
| 252 | |||
| 253 | if (bcount) { | ||
| 254 | printk(KERN_ERR "%s: leftover data in %s, bcount == %d\n", | ||
| 255 | drive->name, __func__, bcount); | ||
| 256 | ide_pad_transfer(drive, direction, bcount); | ||
| 257 | } | ||
| 258 | } | ||
| 259 | |||
| 260 | static void idefloppy_update_buffers(ide_drive_t *drive, | 149 | static void idefloppy_update_buffers(ide_drive_t *drive, |
| 261 | struct ide_atapi_pc *pc) | 150 | struct ide_atapi_pc *pc) |
| 262 | { | 151 | { |
| @@ -267,43 +156,6 @@ static void idefloppy_update_buffers(ide_drive_t *drive, | |||
| 267 | idefloppy_end_request(drive, 1, 0); | 156 | idefloppy_end_request(drive, 1, 0); |
| 268 | } | 157 | } |
| 269 | 158 | ||
| 270 | /* | ||
| 271 | * Generate a new packet command request in front of the request queue, before | ||
| 272 | * the current request so that it will be processed immediately, on the next | ||
| 273 | * pass through the driver. | ||
| 274 | */ | ||
| 275 | static void idefloppy_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
| 276 | struct request *rq) | ||
| 277 | { | ||
| 278 | struct ide_floppy_obj *floppy = drive->driver_data; | ||
| 279 | |||
| 280 | blk_rq_init(NULL, rq); | ||
| 281 | rq->buffer = (char *) pc; | ||
| 282 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
| 283 | rq->cmd_flags |= REQ_PREEMPT; | ||
| 284 | rq->rq_disk = floppy->disk; | ||
| 285 | memcpy(rq->cmd, pc->c, 12); | ||
| 286 | ide_do_drive_cmd(drive, rq); | ||
| 287 | } | ||
| 288 | |||
| 289 | static struct ide_atapi_pc *idefloppy_next_pc_storage(ide_drive_t *drive) | ||
| 290 | { | ||
| 291 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
| 292 | |||
| 293 | if (floppy->pc_stack_index == IDEFLOPPY_PC_STACK) | ||
| 294 | floppy->pc_stack_index = 0; | ||
| 295 | return (&floppy->pc_stack[floppy->pc_stack_index++]); | ||
| 296 | } | ||
| 297 | |||
| 298 | static struct request *idefloppy_next_rq_storage(ide_drive_t *drive) | ||
| 299 | { | ||
| 300 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
| 301 | |||
| 302 | if (floppy->rq_stack_index == IDEFLOPPY_PC_STACK) | ||
| 303 | floppy->rq_stack_index = 0; | ||
| 304 | return (&floppy->rq_stack[floppy->rq_stack_index++]); | ||
| 305 | } | ||
| 306 | |||
| 307 | static void ide_floppy_callback(ide_drive_t *drive) | 159 | static void ide_floppy_callback(ide_drive_t *drive) |
| 308 | { | 160 | { |
| 309 | idefloppy_floppy_t *floppy = drive->driver_data; | 161 | idefloppy_floppy_t *floppy = drive->driver_data; |
| @@ -341,16 +193,9 @@ static void ide_floppy_callback(ide_drive_t *drive) | |||
| 341 | idefloppy_end_request(drive, uptodate, 0); | 193 | idefloppy_end_request(drive, uptodate, 0); |
| 342 | } | 194 | } |
| 343 | 195 | ||
| 344 | static void idefloppy_init_pc(struct ide_atapi_pc *pc) | 196 | void ide_floppy_create_request_sense_cmd(struct ide_atapi_pc *pc) |
| 345 | { | ||
| 346 | memset(pc, 0, sizeof(*pc)); | ||
| 347 | pc->buf = pc->pc_buf; | ||
| 348 | pc->buf_size = IDEFLOPPY_PC_BUFFER_SIZE; | ||
| 349 | } | ||
| 350 | |||
| 351 | static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) | ||
| 352 | { | 197 | { |
| 353 | idefloppy_init_pc(pc); | 198 | ide_init_pc(pc); |
| 354 | pc->c[0] = GPCMD_REQUEST_SENSE; | 199 | pc->c[0] = GPCMD_REQUEST_SENSE; |
| 355 | pc->c[4] = 255; | 200 | pc->c[4] = 255; |
| 356 | pc->req_xfer = 18; | 201 | pc->req_xfer = 18; |
| @@ -362,14 +207,13 @@ static void idefloppy_create_request_sense_cmd(struct ide_atapi_pc *pc) | |||
| 362 | */ | 207 | */ |
| 363 | static void idefloppy_retry_pc(ide_drive_t *drive) | 208 | static void idefloppy_retry_pc(ide_drive_t *drive) |
| 364 | { | 209 | { |
| 365 | struct ide_atapi_pc *pc; | 210 | struct ide_floppy_obj *floppy = drive->driver_data; |
| 366 | struct request *rq; | 211 | struct request *rq = &floppy->request_sense_rq; |
| 212 | struct ide_atapi_pc *pc = &floppy->request_sense_pc; | ||
| 367 | 213 | ||
| 368 | (void)ide_read_error(drive); | 214 | (void)ide_read_error(drive); |
| 369 | pc = idefloppy_next_pc_storage(drive); | 215 | ide_floppy_create_request_sense_cmd(pc); |
| 370 | rq = idefloppy_next_rq_storage(drive); | 216 | ide_queue_pc_head(drive, floppy->disk, pc, rq); |
| 371 | idefloppy_create_request_sense_cmd(pc); | ||
| 372 | idefloppy_queue_pc_head(drive, pc, rq); | ||
| 373 | } | 217 | } |
| 374 | 218 | ||
| 375 | /* The usual interrupt handler called during a packet command. */ | 219 | /* The usual interrupt handler called during a packet command. */ |
| @@ -378,8 +222,8 @@ static ide_startstop_t idefloppy_pc_intr(ide_drive_t *drive) | |||
| 378 | idefloppy_floppy_t *floppy = drive->driver_data; | 222 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 379 | 223 | ||
| 380 | return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr, | 224 | return ide_pc_intr(drive, floppy->pc, idefloppy_pc_intr, |
| 381 | IDEFLOPPY_WAIT_CMD, NULL, idefloppy_update_buffers, | 225 | WAIT_FLOPPY_CMD, NULL, idefloppy_update_buffers, |
| 382 | idefloppy_retry_pc, NULL, ide_floppy_io_buffers); | 226 | idefloppy_retry_pc, NULL, ide_io_buffers); |
| 383 | } | 227 | } |
| 384 | 228 | ||
| 385 | /* | 229 | /* |
| @@ -396,10 +240,9 @@ static int idefloppy_transfer_pc(ide_drive_t *drive) | |||
| 396 | drive->hwif->tp_ops->output_data(drive, NULL, floppy->pc->c, 12); | 240 | drive->hwif->tp_ops->output_data(drive, NULL, floppy->pc->c, 12); |
| 397 | 241 | ||
| 398 | /* Timeout for the packet command */ | 242 | /* Timeout for the packet command */ |
| 399 | return IDEFLOPPY_WAIT_CMD; | 243 | return WAIT_FLOPPY_CMD; |
| 400 | } | 244 | } |
| 401 | 245 | ||
| 402 | |||
| 403 | /* | 246 | /* |
| 404 | * Called as an interrupt (or directly). When the device says it's ready for a | 247 | * Called as an interrupt (or directly). When the device says it's ready for a |
| 405 | * packet, we schedule the packet transfer to occur about 2-3 ticks later in | 248 | * packet, we schedule the packet transfer to occur about 2-3 ticks later in |
| @@ -424,7 +267,7 @@ static ide_startstop_t idefloppy_start_pc_transfer(ide_drive_t *drive) | |||
| 424 | timeout = floppy->ticks; | 267 | timeout = floppy->ticks; |
| 425 | expiry = &idefloppy_transfer_pc; | 268 | expiry = &idefloppy_transfer_pc; |
| 426 | } else { | 269 | } else { |
| 427 | timeout = IDEFLOPPY_WAIT_CMD; | 270 | timeout = WAIT_FLOPPY_CMD; |
| 428 | expiry = NULL; | 271 | expiry = NULL; |
| 429 | } | 272 | } |
| 430 | 273 | ||
| @@ -474,58 +317,27 @@ static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, | |||
| 474 | pc->retries++; | 317 | pc->retries++; |
| 475 | 318 | ||
| 476 | return ide_issue_pc(drive, pc, idefloppy_start_pc_transfer, | 319 | return ide_issue_pc(drive, pc, idefloppy_start_pc_transfer, |
| 477 | IDEFLOPPY_WAIT_CMD, NULL); | 320 | WAIT_FLOPPY_CMD, NULL); |
| 478 | } | ||
| 479 | |||
| 480 | static void idefloppy_create_prevent_cmd(struct ide_atapi_pc *pc, int prevent) | ||
| 481 | { | ||
| 482 | debug_log("creating prevent removal command, prevent = %d\n", prevent); | ||
| 483 | |||
| 484 | idefloppy_init_pc(pc); | ||
| 485 | pc->c[0] = GPCMD_PREVENT_ALLOW_MEDIUM_REMOVAL; | ||
| 486 | pc->c[4] = prevent; | ||
| 487 | } | 321 | } |
| 488 | 322 | ||
| 489 | static void idefloppy_create_read_capacity_cmd(struct ide_atapi_pc *pc) | 323 | void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *pc) |
| 490 | { | 324 | { |
| 491 | idefloppy_init_pc(pc); | 325 | ide_init_pc(pc); |
| 492 | pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES; | 326 | pc->c[0] = GPCMD_READ_FORMAT_CAPACITIES; |
| 493 | pc->c[7] = 255; | 327 | pc->c[7] = 255; |
| 494 | pc->c[8] = 255; | 328 | pc->c[8] = 255; |
| 495 | pc->req_xfer = 255; | 329 | pc->req_xfer = 255; |
| 496 | } | 330 | } |
| 497 | 331 | ||
| 498 | static void idefloppy_create_format_unit_cmd(struct ide_atapi_pc *pc, int b, | ||
| 499 | int l, int flags) | ||
| 500 | { | ||
| 501 | idefloppy_init_pc(pc); | ||
| 502 | pc->c[0] = GPCMD_FORMAT_UNIT; | ||
| 503 | pc->c[1] = 0x17; | ||
| 504 | |||
| 505 | memset(pc->buf, 0, 12); | ||
| 506 | pc->buf[1] = 0xA2; | ||
| 507 | /* Default format list header, u8 1: FOV/DCRT/IMM bits set */ | ||
| 508 | |||
| 509 | if (flags & 1) /* Verify bit on... */ | ||
| 510 | pc->buf[1] ^= 0x20; /* ... turn off DCRT bit */ | ||
| 511 | pc->buf[3] = 8; | ||
| 512 | |||
| 513 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buf[4])); | ||
| 514 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buf[8])); | ||
| 515 | pc->buf_size = 12; | ||
| 516 | pc->flags |= PC_FLAG_WRITING; | ||
| 517 | } | ||
| 518 | |||
| 519 | /* A mode sense command is used to "sense" floppy parameters. */ | 332 | /* A mode sense command is used to "sense" floppy parameters. */ |
| 520 | static void idefloppy_create_mode_sense_cmd(struct ide_atapi_pc *pc, | 333 | void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) |
| 521 | u8 page_code, u8 type) | ||
| 522 | { | 334 | { |
| 523 | u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ | 335 | u16 length = 8; /* sizeof(Mode Parameter Header) = 8 Bytes */ |
| 524 | 336 | ||
| 525 | idefloppy_init_pc(pc); | 337 | ide_init_pc(pc); |
| 526 | pc->c[0] = GPCMD_MODE_SENSE_10; | 338 | pc->c[0] = GPCMD_MODE_SENSE_10; |
| 527 | pc->c[1] = 0; | 339 | pc->c[1] = 0; |
| 528 | pc->c[2] = page_code + (type << 6); | 340 | pc->c[2] = page_code; |
| 529 | 341 | ||
| 530 | switch (page_code) { | 342 | switch (page_code) { |
| 531 | case IDEFLOPPY_CAPABILITIES_PAGE: | 343 | case IDEFLOPPY_CAPABILITIES_PAGE: |
| @@ -542,13 +354,6 @@ static void idefloppy_create_mode_sense_cmd(struct ide_atapi_pc *pc, | |||
| 542 | pc->req_xfer = length; | 354 | pc->req_xfer = length; |
| 543 | } | 355 | } |
| 544 | 356 | ||
| 545 | static void idefloppy_create_start_stop_cmd(struct ide_atapi_pc *pc, int start) | ||
| 546 | { | ||
| 547 | idefloppy_init_pc(pc); | ||
| 548 | pc->c[0] = GPCMD_START_STOP_UNIT; | ||
| 549 | pc->c[4] = start; | ||
| 550 | } | ||
| 551 | |||
| 552 | static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | 357 | static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, |
| 553 | struct ide_atapi_pc *pc, struct request *rq, | 358 | struct ide_atapi_pc *pc, struct request *rq, |
| 554 | unsigned long sector) | 359 | unsigned long sector) |
| @@ -560,7 +365,7 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | |||
| 560 | debug_log("create_rw10_cmd: block == %d, blocks == %d\n", | 365 | debug_log("create_rw10_cmd: block == %d, blocks == %d\n", |
| 561 | block, blocks); | 366 | block, blocks); |
| 562 | 367 | ||
| 563 | idefloppy_init_pc(pc); | 368 | ide_init_pc(pc); |
| 564 | pc->c[0] = cmd == READ ? GPCMD_READ_10 : GPCMD_WRITE_10; | 369 | pc->c[0] = cmd == READ ? GPCMD_READ_10 : GPCMD_WRITE_10; |
| 565 | put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); | 370 | put_unaligned(cpu_to_be16(blocks), (unsigned short *)&pc->c[7]); |
| 566 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); | 371 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[2]); |
| @@ -568,7 +373,7 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | |||
| 568 | memcpy(rq->cmd, pc->c, 12); | 373 | memcpy(rq->cmd, pc->c, 12); |
| 569 | 374 | ||
| 570 | pc->rq = rq; | 375 | pc->rq = rq; |
| 571 | pc->b_count = cmd == READ ? 0 : rq->bio->bi_size; | 376 | pc->b_count = 0; |
| 572 | if (rq->cmd_flags & REQ_RW) | 377 | if (rq->cmd_flags & REQ_RW) |
| 573 | pc->flags |= PC_FLAG_WRITING; | 378 | pc->flags |= PC_FLAG_WRITING; |
| 574 | pc->buf = NULL; | 379 | pc->buf = NULL; |
| @@ -579,10 +384,10 @@ static void idefloppy_create_rw_cmd(idefloppy_floppy_t *floppy, | |||
| 579 | static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, | 384 | static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, |
| 580 | struct ide_atapi_pc *pc, struct request *rq) | 385 | struct ide_atapi_pc *pc, struct request *rq) |
| 581 | { | 386 | { |
| 582 | idefloppy_init_pc(pc); | 387 | ide_init_pc(pc); |
| 583 | memcpy(pc->c, rq->cmd, sizeof(pc->c)); | 388 | memcpy(pc->c, rq->cmd, sizeof(pc->c)); |
| 584 | pc->rq = rq; | 389 | pc->rq = rq; |
| 585 | pc->b_count = rq->data_len; | 390 | pc->b_count = 0; |
| 586 | if (rq->data_len && rq_data_dir(rq) == WRITE) | 391 | if (rq->data_len && rq_data_dir(rq) == WRITE) |
| 587 | pc->flags |= PC_FLAG_WRITING; | 392 | pc->flags |= PC_FLAG_WRITING; |
| 588 | pc->buf = rq->data; | 393 | pc->buf = rq->data; |
| @@ -599,15 +404,17 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | |||
| 599 | struct request *rq, sector_t block_s) | 404 | struct request *rq, sector_t block_s) |
| 600 | { | 405 | { |
| 601 | idefloppy_floppy_t *floppy = drive->driver_data; | 406 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 407 | ide_hwif_t *hwif = drive->hwif; | ||
| 602 | struct ide_atapi_pc *pc; | 408 | struct ide_atapi_pc *pc; |
| 603 | unsigned long block = (unsigned long)block_s; | 409 | unsigned long block = (unsigned long)block_s; |
| 604 | 410 | ||
| 605 | debug_log("dev: %s, cmd_type: %x, errors: %d\n", | 411 | debug_log("%s: dev: %s, cmd: 0x%x, cmd_type: %x, errors: %d\n", |
| 606 | rq->rq_disk ? rq->rq_disk->disk_name : "?", | 412 | __func__, rq->rq_disk ? rq->rq_disk->disk_name : "?", |
| 607 | rq->cmd_type, rq->errors); | 413 | rq->cmd[0], rq->cmd_type, rq->errors); |
| 608 | debug_log("sector: %ld, nr_sectors: %ld, " | 414 | |
| 609 | "current_nr_sectors: %d\n", (long)rq->sector, | 415 | debug_log("%s: sector: %ld, nr_sectors: %ld, current_nr_sectors: %d\n", |
| 610 | rq->nr_sectors, rq->current_nr_sectors); | 416 | __func__, (long)rq->sector, rq->nr_sectors, |
| 417 | rq->current_nr_sectors); | ||
| 611 | 418 | ||
| 612 | if (rq->errors >= ERROR_MAX) { | 419 | if (rq->errors >= ERROR_MAX) { |
| 613 | if (floppy->failed_pc) | 420 | if (floppy->failed_pc) |
| @@ -626,12 +433,12 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | |||
| 626 | idefloppy_end_request(drive, 0, 0); | 433 | idefloppy_end_request(drive, 0, 0); |
| 627 | return ide_stopped; | 434 | return ide_stopped; |
| 628 | } | 435 | } |
| 629 | pc = idefloppy_next_pc_storage(drive); | 436 | pc = &floppy->queued_pc; |
| 630 | idefloppy_create_rw_cmd(floppy, pc, rq, block); | 437 | idefloppy_create_rw_cmd(floppy, pc, rq, block); |
| 631 | } else if (blk_special_request(rq)) { | 438 | } else if (blk_special_request(rq)) { |
| 632 | pc = (struct ide_atapi_pc *) rq->buffer; | 439 | pc = (struct ide_atapi_pc *) rq->buffer; |
| 633 | } else if (blk_pc_request(rq)) { | 440 | } else if (blk_pc_request(rq)) { |
| 634 | pc = idefloppy_next_pc_storage(drive); | 441 | pc = &floppy->queued_pc; |
| 635 | idefloppy_blockpc_cmd(floppy, pc, rq); | 442 | idefloppy_blockpc_cmd(floppy, pc, rq); |
| 636 | } else { | 443 | } else { |
| 637 | blk_dump_rq_flags(rq, | 444 | blk_dump_rq_flags(rq, |
| @@ -640,29 +447,15 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, | |||
| 640 | return ide_stopped; | 447 | return ide_stopped; |
| 641 | } | 448 | } |
| 642 | 449 | ||
| 643 | pc->rq = rq; | 450 | ide_init_sg_cmd(drive, rq); |
| 451 | ide_map_sg(drive, rq); | ||
| 644 | 452 | ||
| 645 | return idefloppy_issue_pc(drive, pc); | 453 | pc->sg = hwif->sg_table; |
| 646 | } | 454 | pc->sg_cnt = hwif->sg_nents; |
| 647 | 455 | ||
| 648 | /* | 456 | pc->rq = rq; |
| 649 | * Add a special packet command request to the tail of the request queue, | ||
| 650 | * and wait for it to be serviced. | ||
| 651 | */ | ||
| 652 | static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | ||
| 653 | { | ||
| 654 | struct ide_floppy_obj *floppy = drive->driver_data; | ||
| 655 | struct request *rq; | ||
| 656 | int error; | ||
| 657 | |||
| 658 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | ||
| 659 | rq->buffer = (char *) pc; | ||
| 660 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
| 661 | memcpy(rq->cmd, pc->c, 12); | ||
| 662 | error = blk_execute_rq(drive->queue, floppy->disk, rq, 0); | ||
| 663 | blk_put_request(rq); | ||
| 664 | 457 | ||
| 665 | return error; | 458 | return idefloppy_issue_pc(drive, pc); |
| 666 | } | 459 | } |
| 667 | 460 | ||
| 668 | /* | 461 | /* |
| @@ -672,22 +465,28 @@ static int idefloppy_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | |||
| 672 | static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) | 465 | static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) |
| 673 | { | 466 | { |
| 674 | idefloppy_floppy_t *floppy = drive->driver_data; | 467 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 468 | struct gendisk *disk = floppy->disk; | ||
| 675 | struct ide_atapi_pc pc; | 469 | struct ide_atapi_pc pc; |
| 676 | u8 *page; | 470 | u8 *page; |
| 677 | int capacity, lba_capacity; | 471 | int capacity, lba_capacity; |
| 678 | u16 transfer_rate, sector_size, cyls, rpm; | 472 | u16 transfer_rate, sector_size, cyls, rpm; |
| 679 | u8 heads, sectors; | 473 | u8 heads, sectors; |
| 680 | 474 | ||
| 681 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE, | 475 | ide_floppy_create_mode_sense_cmd(&pc, IDEFLOPPY_FLEXIBLE_DISK_PAGE); |
| 682 | MODE_SENSE_CURRENT); | ||
| 683 | 476 | ||
| 684 | if (idefloppy_queue_pc_tail(drive, &pc)) { | 477 | if (ide_queue_pc_tail(drive, disk, &pc)) { |
| 685 | printk(KERN_ERR "ide-floppy: Can't get flexible disk page" | 478 | printk(KERN_ERR "ide-floppy: Can't get flexible disk page" |
| 686 | " parameters\n"); | 479 | " parameters\n"); |
| 687 | return 1; | 480 | return 1; |
| 688 | } | 481 | } |
| 689 | floppy->wp = !!(pc.buf[3] & 0x80); | 482 | |
| 690 | set_disk_ro(floppy->disk, floppy->wp); | 483 | if (pc.buf[3] & 0x80) |
| 484 | drive->atapi_flags |= IDE_AFLAG_WP; | ||
| 485 | else | ||
| 486 | drive->atapi_flags &= ~IDE_AFLAG_WP; | ||
| 487 | |||
| 488 | set_disk_ro(disk, !!(drive->atapi_flags & IDE_AFLAG_WP)); | ||
| 489 | |||
| 691 | page = &pc.buf[8]; | 490 | page = &pc.buf[8]; |
| 692 | 491 | ||
| 693 | transfer_rate = be16_to_cpup((__be16 *)&pc.buf[8 + 2]); | 492 | transfer_rate = be16_to_cpup((__be16 *)&pc.buf[8 + 2]); |
| @@ -721,23 +520,6 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) | |||
| 721 | return 0; | 520 | return 0; |
| 722 | } | 521 | } |
| 723 | 522 | ||
| 724 | static int idefloppy_get_sfrp_bit(ide_drive_t *drive) | ||
| 725 | { | ||
| 726 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
| 727 | struct ide_atapi_pc pc; | ||
| 728 | |||
| 729 | floppy->srfp = 0; | ||
| 730 | idefloppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE, | ||
| 731 | MODE_SENSE_CURRENT); | ||
| 732 | |||
| 733 | pc.flags |= PC_FLAG_SUPPRESS_ERROR; | ||
| 734 | if (idefloppy_queue_pc_tail(drive, &pc)) | ||
| 735 | return 1; | ||
| 736 | |||
| 737 | floppy->srfp = pc.buf[8 + 2] & 0x40; | ||
| 738 | return (0); | ||
| 739 | } | ||
| 740 | |||
| 741 | /* | 523 | /* |
| 742 | * Determine if a media is present in the floppy drive, and if so, its LBA | 524 | * Determine if a media is present in the floppy drive, and if so, its LBA |
| 743 | * capacity. | 525 | * capacity. |
| @@ -745,6 +527,7 @@ static int idefloppy_get_sfrp_bit(ide_drive_t *drive) | |||
| 745 | static int ide_floppy_get_capacity(ide_drive_t *drive) | 527 | static int ide_floppy_get_capacity(ide_drive_t *drive) |
| 746 | { | 528 | { |
| 747 | idefloppy_floppy_t *floppy = drive->driver_data; | 529 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 530 | struct gendisk *disk = floppy->disk; | ||
| 748 | struct ide_atapi_pc pc; | 531 | struct ide_atapi_pc pc; |
| 749 | u8 *cap_desc; | 532 | u8 *cap_desc; |
| 750 | u8 header_len, desc_cnt; | 533 | u8 header_len, desc_cnt; |
| @@ -756,8 +539,8 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
| 756 | floppy->bs_factor = 1; | 539 | floppy->bs_factor = 1; |
| 757 | set_capacity(floppy->disk, 0); | 540 | set_capacity(floppy->disk, 0); |
| 758 | 541 | ||
| 759 | idefloppy_create_read_capacity_cmd(&pc); | 542 | ide_floppy_create_read_capacity_cmd(&pc); |
| 760 | if (idefloppy_queue_pc_tail(drive, &pc)) { | 543 | if (ide_queue_pc_tail(drive, disk, &pc)) { |
| 761 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); | 544 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); |
| 762 | return 1; | 545 | return 1; |
| 763 | } | 546 | } |
| @@ -832,202 +615,55 @@ static int ide_floppy_get_capacity(ide_drive_t *drive) | |||
| 832 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) | 615 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) |
| 833 | (void) ide_floppy_get_flexible_disk_page(drive); | 616 | (void) ide_floppy_get_flexible_disk_page(drive); |
| 834 | 617 | ||
| 835 | set_capacity(floppy->disk, floppy->blocks * floppy->bs_factor); | 618 | set_capacity(disk, floppy->blocks * floppy->bs_factor); |
| 619 | |||
| 836 | return rc; | 620 | return rc; |
| 837 | } | 621 | } |
| 838 | 622 | ||
| 839 | /* | 623 | static sector_t idefloppy_capacity(ide_drive_t *drive) |
| 840 | * Obtain the list of formattable capacities. | ||
| 841 | * Very similar to ide_floppy_get_capacity, except that we push the capacity | ||
| 842 | * descriptors to userland, instead of our own structures. | ||
| 843 | * | ||
| 844 | * Userland gives us the following structure: | ||
| 845 | * | ||
| 846 | * struct idefloppy_format_capacities { | ||
| 847 | * int nformats; | ||
| 848 | * struct { | ||
| 849 | * int nblocks; | ||
| 850 | * int blocksize; | ||
| 851 | * } formats[]; | ||
| 852 | * }; | ||
| 853 | * | ||
| 854 | * userland initializes nformats to the number of allocated formats[] records. | ||
| 855 | * On exit we set nformats to the number of records we've actually initialized. | ||
| 856 | */ | ||
| 857 | |||
| 858 | static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | ||
| 859 | { | 624 | { |
| 860 | struct ide_atapi_pc pc; | 625 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 861 | u8 header_len, desc_cnt; | 626 | unsigned long capacity = floppy->blocks * floppy->bs_factor; |
| 862 | int i, blocks, length, u_array_size, u_index; | ||
| 863 | int __user *argp; | ||
| 864 | |||
| 865 | if (get_user(u_array_size, arg)) | ||
| 866 | return (-EFAULT); | ||
| 867 | |||
| 868 | if (u_array_size <= 0) | ||
| 869 | return (-EINVAL); | ||
| 870 | |||
| 871 | idefloppy_create_read_capacity_cmd(&pc); | ||
| 872 | if (idefloppy_queue_pc_tail(drive, &pc)) { | ||
| 873 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); | ||
| 874 | return (-EIO); | ||
| 875 | } | ||
| 876 | header_len = pc.buf[3]; | ||
| 877 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ | ||
| 878 | |||
| 879 | u_index = 0; | ||
| 880 | argp = arg + 1; | ||
| 881 | |||
| 882 | /* | ||
| 883 | * We always skip the first capacity descriptor. That's the current | ||
| 884 | * capacity. We are interested in the remaining descriptors, the | ||
| 885 | * formattable capacities. | ||
| 886 | */ | ||
| 887 | for (i = 1; i < desc_cnt; i++) { | ||
| 888 | unsigned int desc_start = 4 + i*8; | ||
| 889 | |||
| 890 | if (u_index >= u_array_size) | ||
| 891 | break; /* User-supplied buffer too small */ | ||
| 892 | |||
| 893 | blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]); | ||
| 894 | length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]); | ||
| 895 | |||
| 896 | if (put_user(blocks, argp)) | ||
| 897 | return(-EFAULT); | ||
| 898 | ++argp; | ||
| 899 | |||
| 900 | if (put_user(length, argp)) | ||
| 901 | return (-EFAULT); | ||
| 902 | ++argp; | ||
| 903 | |||
| 904 | ++u_index; | ||
| 905 | } | ||
| 906 | 627 | ||
| 907 | if (put_user(u_index, arg)) | 628 | return capacity; |
| 908 | return (-EFAULT); | ||
| 909 | return (0); | ||
| 910 | } | 629 | } |
| 911 | 630 | ||
| 912 | /* | 631 | #ifdef CONFIG_IDE_PROC_FS |
| 913 | * Get ATAPI_FORMAT_UNIT progress indication. | 632 | ide_devset_rw_field(bios_cyl, bios_cyl); |
| 914 | * | 633 | ide_devset_rw_field(bios_head, bios_head); |
| 915 | * Userland gives a pointer to an int. The int is set to a progress | 634 | ide_devset_rw_field(bios_sect, bios_sect); |
| 916 | * indicator 0-65536, with 65536=100%. | ||
| 917 | * | ||
| 918 | * If the drive does not support format progress indication, we just check | ||
| 919 | * the dsc bit, and return either 0 or 65536. | ||
| 920 | */ | ||
| 921 | 635 | ||
| 922 | static int idefloppy_get_format_progress(ide_drive_t *drive, int __user *arg) | 636 | static int get_ticks(ide_drive_t *drive) |
| 923 | { | 637 | { |
| 924 | idefloppy_floppy_t *floppy = drive->driver_data; | 638 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 925 | struct ide_atapi_pc pc; | 639 | return floppy->ticks; |
| 926 | int progress_indication = 0x10000; | ||
| 927 | |||
| 928 | if (floppy->srfp) { | ||
| 929 | idefloppy_create_request_sense_cmd(&pc); | ||
| 930 | if (idefloppy_queue_pc_tail(drive, &pc)) | ||
| 931 | return (-EIO); | ||
| 932 | |||
| 933 | if (floppy->sense_key == 2 && | ||
| 934 | floppy->asc == 4 && | ||
| 935 | floppy->ascq == 4) | ||
| 936 | progress_indication = floppy->progress_indication; | ||
| 937 | |||
| 938 | /* Else assume format_unit has finished, and we're at 0x10000 */ | ||
| 939 | } else { | ||
| 940 | ide_hwif_t *hwif = drive->hwif; | ||
| 941 | unsigned long flags; | ||
| 942 | u8 stat; | ||
| 943 | |||
| 944 | local_irq_save(flags); | ||
| 945 | stat = hwif->tp_ops->read_status(hwif); | ||
| 946 | local_irq_restore(flags); | ||
| 947 | |||
| 948 | progress_indication = ((stat & SEEK_STAT) == 0) ? 0 : 0x10000; | ||
| 949 | } | ||
| 950 | if (put_user(progress_indication, arg)) | ||
| 951 | return (-EFAULT); | ||
| 952 | |||
| 953 | return (0); | ||
| 954 | } | 640 | } |
| 955 | 641 | ||
| 956 | static sector_t idefloppy_capacity(ide_drive_t *drive) | 642 | static int set_ticks(ide_drive_t *drive, int arg) |
| 957 | { | 643 | { |
| 958 | idefloppy_floppy_t *floppy = drive->driver_data; | 644 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 959 | unsigned long capacity = floppy->blocks * floppy->bs_factor; | 645 | floppy->ticks = arg; |
| 960 | |||
| 961 | return capacity; | ||
| 962 | } | ||
| 963 | |||
| 964 | /* | ||
| 965 | * Check whether we can support a drive, based on the ATAPI IDENTIFY command | ||
| 966 | * results. | ||
| 967 | */ | ||
| 968 | static int idefloppy_identify_device(ide_drive_t *drive, struct hd_driveid *id) | ||
| 969 | { | ||
| 970 | u8 gcw[2]; | ||
| 971 | u8 device_type, protocol, removable, drq_type, packet_size; | ||
| 972 | |||
| 973 | *((u16 *) &gcw) = id->config; | ||
| 974 | |||
| 975 | device_type = gcw[1] & 0x1F; | ||
| 976 | removable = (gcw[0] & 0x80) >> 7; | ||
| 977 | protocol = (gcw[1] & 0xC0) >> 6; | ||
| 978 | drq_type = (gcw[0] & 0x60) >> 5; | ||
| 979 | packet_size = gcw[0] & 0x03; | ||
| 980 | |||
| 981 | #ifdef CONFIG_PPC | ||
| 982 | /* kludge for Apple PowerBook internal zip */ | ||
| 983 | if (device_type == 5 && | ||
| 984 | !strstr(id->model, "CD-ROM") && strstr(id->model, "ZIP")) | ||
| 985 | device_type = 0; | ||
| 986 | #endif | ||
| 987 | |||
| 988 | if (protocol != 2) | ||
| 989 | printk(KERN_ERR "ide-floppy: Protocol (0x%02x) is not ATAPI\n", | ||
| 990 | protocol); | ||
| 991 | else if (device_type != 0) | ||
| 992 | printk(KERN_ERR "ide-floppy: Device type (0x%02x) is not set " | ||
| 993 | "to floppy\n", device_type); | ||
| 994 | else if (!removable) | ||
| 995 | printk(KERN_ERR "ide-floppy: The removable flag is not set\n"); | ||
| 996 | else if (drq_type == 3) | ||
| 997 | printk(KERN_ERR "ide-floppy: Sorry, DRQ type (0x%02x) not " | ||
| 998 | "supported\n", drq_type); | ||
| 999 | else if (packet_size != 0) | ||
| 1000 | printk(KERN_ERR "ide-floppy: Packet size (0x%02x) is not 12 " | ||
| 1001 | "bytes\n", packet_size); | ||
| 1002 | else | ||
| 1003 | return 1; | ||
| 1004 | return 0; | 646 | return 0; |
| 1005 | } | 647 | } |
| 1006 | 648 | ||
| 1007 | #ifdef CONFIG_IDE_PROC_FS | 649 | IDE_DEVSET(ticks, DS_SYNC, get_ticks, set_ticks); |
| 1008 | static void idefloppy_add_settings(ide_drive_t *drive) | ||
| 1009 | { | ||
| 1010 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
| 1011 | 650 | ||
| 1012 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1, | 651 | static const struct ide_proc_devset idefloppy_settings[] = { |
| 1013 | &drive->bios_cyl, NULL); | 652 | IDE_PROC_DEVSET(bios_cyl, 0, 1023), |
| 1014 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, | 653 | IDE_PROC_DEVSET(bios_head, 0, 255), |
| 1015 | &drive->bios_head, NULL); | 654 | IDE_PROC_DEVSET(bios_sect, 0, 63), |
| 1016 | ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, | 655 | IDE_PROC_DEVSET(ticks, 0, 255), |
| 1017 | &drive->bios_sect, NULL); | 656 | { 0 }, |
| 1018 | ide_add_setting(drive, "ticks", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, | 657 | }; |
| 1019 | &floppy->ticks, NULL); | ||
| 1020 | } | ||
| 1021 | #else | ||
| 1022 | static inline void idefloppy_add_settings(ide_drive_t *drive) { ; } | ||
| 1023 | #endif | 658 | #endif |
| 1024 | 659 | ||
| 1025 | static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) | 660 | static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) |
| 1026 | { | 661 | { |
| 662 | u16 *id = drive->id; | ||
| 1027 | u8 gcw[2]; | 663 | u8 gcw[2]; |
| 1028 | 664 | ||
| 1029 | *((u16 *) &gcw) = drive->id->config; | 665 | *((u16 *)&gcw) = id[ATA_ID_CONFIG]; |
| 1030 | floppy->pc = floppy->pc_stack; | 666 | |
| 1031 | drive->pc_callback = ide_floppy_callback; | 667 | drive->pc_callback = ide_floppy_callback; |
| 1032 | 668 | ||
| 1033 | if (((gcw[0] & 0x60) >> 5) == 1) | 669 | if (((gcw[0] & 0x60) >> 5) == 1) |
| @@ -1041,7 +677,7 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) | |||
| 1041 | * it. It should be fixed as of version 1.9, but to be on the safe side | 677 | * it. It should be fixed as of version 1.9, but to be on the safe side |
| 1042 | * we'll leave the limitation below for the 2.2.x tree. | 678 | * we'll leave the limitation below for the 2.2.x tree. |
| 1043 | */ | 679 | */ |
| 1044 | if (!strncmp(drive->id->model, "IOMEGA ZIP 100 ATAPI", 20)) { | 680 | if (!strncmp((char *)&id[ATA_ID_PROD], "IOMEGA ZIP 100 ATAPI", 20)) { |
| 1045 | drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE; | 681 | drive->atapi_flags |= IDE_AFLAG_ZIP_DRIVE; |
| 1046 | /* This value will be visible in the /proc/ide/hdx/settings */ | 682 | /* This value will be visible in the /proc/ide/hdx/settings */ |
| 1047 | floppy->ticks = IDEFLOPPY_TICKS_DELAY; | 683 | floppy->ticks = IDEFLOPPY_TICKS_DELAY; |
| @@ -1052,13 +688,16 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy) | |||
| 1052 | * Guess what? The IOMEGA Clik! drive also needs the above fix. It makes | 688 | * Guess what? The IOMEGA Clik! drive also needs the above fix. It makes |
| 1053 | * nasty clicking noises without it, so please don't remove this. | 689 | * nasty clicking noises without it, so please don't remove this. |
| 1054 | */ | 690 | */ |
| 1055 | if (strncmp(drive->id->model, "IOMEGA Clik!", 11) == 0) { | 691 | if (strncmp((char *)&id[ATA_ID_PROD], "IOMEGA Clik!", 11) == 0) { |
| 1056 | blk_queue_max_sectors(drive->queue, 64); | 692 | blk_queue_max_sectors(drive->queue, 64); |
| 1057 | drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE; | 693 | drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE; |
| 694 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | ||
| 695 | drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; | ||
| 1058 | } | 696 | } |
| 1059 | 697 | ||
| 1060 | (void) ide_floppy_get_capacity(drive); | 698 | (void) ide_floppy_get_capacity(drive); |
| 1061 | idefloppy_add_settings(drive); | 699 | |
| 700 | ide_proc_register_driver(drive, floppy->driver); | ||
| 1062 | } | 701 | } |
| 1063 | 702 | ||
| 1064 | static void ide_floppy_remove(ide_drive_t *drive) | 703 | static void ide_floppy_remove(ide_drive_t *drive) |
| @@ -1115,12 +754,12 @@ static ide_driver_t idefloppy_driver = { | |||
| 1115 | .remove = ide_floppy_remove, | 754 | .remove = ide_floppy_remove, |
| 1116 | .version = IDEFLOPPY_VERSION, | 755 | .version = IDEFLOPPY_VERSION, |
| 1117 | .media = ide_floppy, | 756 | .media = ide_floppy, |
| 1118 | .supports_dsc_overlap = 0, | ||
| 1119 | .do_request = idefloppy_do_request, | 757 | .do_request = idefloppy_do_request, |
| 1120 | .end_request = idefloppy_end_request, | 758 | .end_request = idefloppy_end_request, |
| 1121 | .error = __ide_error, | 759 | .error = __ide_error, |
| 1122 | #ifdef CONFIG_IDE_PROC_FS | 760 | #ifdef CONFIG_IDE_PROC_FS |
| 1123 | .proc = idefloppy_proc, | 761 | .proc = idefloppy_proc, |
| 762 | .settings = idefloppy_settings, | ||
| 1124 | #endif | 763 | #endif |
| 1125 | }; | 764 | }; |
| 1126 | 765 | ||
| @@ -1129,7 +768,6 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
| 1129 | struct gendisk *disk = inode->i_bdev->bd_disk; | 768 | struct gendisk *disk = inode->i_bdev->bd_disk; |
| 1130 | struct ide_floppy_obj *floppy; | 769 | struct ide_floppy_obj *floppy; |
| 1131 | ide_drive_t *drive; | 770 | ide_drive_t *drive; |
| 1132 | struct ide_atapi_pc pc; | ||
| 1133 | int ret = 0; | 771 | int ret = 0; |
| 1134 | 772 | ||
| 1135 | debug_log("Reached %s\n", __func__); | 773 | debug_log("Reached %s\n", __func__); |
| @@ -1146,13 +784,8 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
| 1146 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | 784 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; |
| 1147 | /* Just in case */ | 785 | /* Just in case */ |
| 1148 | 786 | ||
| 1149 | idefloppy_init_pc(&pc); | 787 | if (ide_do_test_unit_ready(drive, disk)) |
| 1150 | pc.c[0] = GPCMD_TEST_UNIT_READY; | 788 | ide_do_start_stop(drive, disk, 1); |
| 1151 | |||
| 1152 | if (idefloppy_queue_pc_tail(drive, &pc)) { | ||
| 1153 | idefloppy_create_start_stop_cmd(&pc, 1); | ||
| 1154 | (void) idefloppy_queue_pc_tail(drive, &pc); | ||
| 1155 | } | ||
| 1156 | 789 | ||
| 1157 | if (ide_floppy_get_capacity(drive) | 790 | if (ide_floppy_get_capacity(drive) |
| 1158 | && (filp->f_flags & O_NDELAY) == 0 | 791 | && (filp->f_flags & O_NDELAY) == 0 |
| @@ -1166,16 +799,13 @@ static int idefloppy_open(struct inode *inode, struct file *filp) | |||
| 1166 | goto out_put_floppy; | 799 | goto out_put_floppy; |
| 1167 | } | 800 | } |
| 1168 | 801 | ||
| 1169 | if (floppy->wp && (filp->f_mode & 2)) { | 802 | if ((drive->atapi_flags & IDE_AFLAG_WP) && (filp->f_mode & 2)) { |
| 1170 | ret = -EROFS; | 803 | ret = -EROFS; |
| 1171 | goto out_put_floppy; | 804 | goto out_put_floppy; |
| 1172 | } | 805 | } |
| 806 | |||
| 1173 | drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED; | 807 | drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED; |
| 1174 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 808 | ide_set_media_lock(drive, disk, 1); |
| 1175 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { | ||
| 1176 | idefloppy_create_prevent_cmd(&pc, 1); | ||
| 1177 | (void) idefloppy_queue_pc_tail(drive, &pc); | ||
| 1178 | } | ||
| 1179 | check_disk_change(inode->i_bdev); | 809 | check_disk_change(inode->i_bdev); |
| 1180 | } else if (drive->atapi_flags & IDE_AFLAG_FORMAT_IN_PROGRESS) { | 810 | } else if (drive->atapi_flags & IDE_AFLAG_FORMAT_IN_PROGRESS) { |
| 1181 | ret = -EBUSY; | 811 | ret = -EBUSY; |
| @@ -1194,17 +824,11 @@ static int idefloppy_release(struct inode *inode, struct file *filp) | |||
| 1194 | struct gendisk *disk = inode->i_bdev->bd_disk; | 824 | struct gendisk *disk = inode->i_bdev->bd_disk; |
| 1195 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); | 825 | struct ide_floppy_obj *floppy = ide_floppy_g(disk); |
| 1196 | ide_drive_t *drive = floppy->drive; | 826 | ide_drive_t *drive = floppy->drive; |
| 1197 | struct ide_atapi_pc pc; | ||
| 1198 | 827 | ||
| 1199 | debug_log("Reached %s\n", __func__); | 828 | debug_log("Reached %s\n", __func__); |
| 1200 | 829 | ||
| 1201 | if (floppy->openers == 1) { | 830 | if (floppy->openers == 1) { |
| 1202 | /* IOMEGA Clik! drives do not support lock/unlock commands */ | 831 | ide_set_media_lock(drive, disk, 0); |
| 1203 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { | ||
| 1204 | idefloppy_create_prevent_cmd(&pc, 0); | ||
| 1205 | (void) idefloppy_queue_pc_tail(drive, &pc); | ||
| 1206 | } | ||
| 1207 | |||
| 1208 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | 832 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; |
| 1209 | } | 833 | } |
| 1210 | 834 | ||
| @@ -1230,80 +854,20 @@ static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 1230 | unsigned long arg, unsigned int cmd) | 854 | unsigned long arg, unsigned int cmd) |
| 1231 | { | 855 | { |
| 1232 | idefloppy_floppy_t *floppy = drive->driver_data; | 856 | idefloppy_floppy_t *floppy = drive->driver_data; |
| 857 | struct gendisk *disk = floppy->disk; | ||
| 858 | int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0; | ||
| 1233 | 859 | ||
| 1234 | if (floppy->openers > 1) | 860 | if (floppy->openers > 1) |
| 1235 | return -EBUSY; | 861 | return -EBUSY; |
| 1236 | 862 | ||
| 1237 | /* The IOMEGA Clik! Drive doesn't support this command - | 863 | ide_set_media_lock(drive, disk, prevent); |
| 1238 | * no room for an eject mechanism */ | ||
| 1239 | if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) { | ||
| 1240 | int prevent = arg ? 1 : 0; | ||
| 1241 | |||
| 1242 | if (cmd == CDROMEJECT) | ||
| 1243 | prevent = 0; | ||
| 1244 | 864 | ||
| 1245 | idefloppy_create_prevent_cmd(pc, prevent); | 865 | if (cmd == CDROMEJECT) |
| 1246 | (void) idefloppy_queue_pc_tail(floppy->drive, pc); | 866 | ide_do_start_stop(drive, disk, 2); |
| 1247 | } | ||
| 1248 | |||
| 1249 | if (cmd == CDROMEJECT) { | ||
| 1250 | idefloppy_create_start_stop_cmd(pc, 2); | ||
| 1251 | (void) idefloppy_queue_pc_tail(floppy->drive, pc); | ||
| 1252 | } | ||
| 1253 | 867 | ||
| 1254 | return 0; | 868 | return 0; |
| 1255 | } | 869 | } |
| 1256 | 870 | ||
| 1257 | static int ide_floppy_format_unit(idefloppy_floppy_t *floppy, | ||
| 1258 | int __user *arg) | ||
| 1259 | { | ||
| 1260 | struct ide_atapi_pc pc; | ||
| 1261 | ide_drive_t *drive = floppy->drive; | ||
| 1262 | int blocks, length, flags, err = 0; | ||
| 1263 | |||
| 1264 | if (floppy->openers > 1) { | ||
| 1265 | /* Don't format if someone is using the disk */ | ||
| 1266 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | ||
| 1267 | return -EBUSY; | ||
| 1268 | } | ||
| 1269 | |||
| 1270 | drive->atapi_flags |= IDE_AFLAG_FORMAT_IN_PROGRESS; | ||
| 1271 | |||
| 1272 | /* | ||
| 1273 | * Send ATAPI_FORMAT_UNIT to the drive. | ||
| 1274 | * | ||
| 1275 | * Userland gives us the following structure: | ||
| 1276 | * | ||
| 1277 | * struct idefloppy_format_command { | ||
| 1278 | * int nblocks; | ||
| 1279 | * int blocksize; | ||
| 1280 | * int flags; | ||
| 1281 | * } ; | ||
| 1282 | * | ||
| 1283 | * flags is a bitmask, currently, the only defined flag is: | ||
| 1284 | * | ||
| 1285 | * 0x01 - verify media after format. | ||
| 1286 | */ | ||
| 1287 | if (get_user(blocks, arg) || | ||
| 1288 | get_user(length, arg+1) || | ||
| 1289 | get_user(flags, arg+2)) { | ||
| 1290 | err = -EFAULT; | ||
| 1291 | goto out; | ||
| 1292 | } | ||
| 1293 | |||
| 1294 | (void) idefloppy_get_sfrp_bit(drive); | ||
| 1295 | idefloppy_create_format_unit_cmd(&pc, blocks, length, flags); | ||
| 1296 | |||
| 1297 | if (idefloppy_queue_pc_tail(drive, &pc)) | ||
| 1298 | err = -EIO; | ||
| 1299 | |||
| 1300 | out: | ||
| 1301 | if (err) | ||
| 1302 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | ||
| 1303 | return err; | ||
| 1304 | } | ||
| 1305 | |||
| 1306 | |||
| 1307 | static int idefloppy_ioctl(struct inode *inode, struct file *file, | 871 | static int idefloppy_ioctl(struct inode *inode, struct file *file, |
| 1308 | unsigned int cmd, unsigned long arg) | 872 | unsigned int cmd, unsigned long arg) |
| 1309 | { | 873 | { |
| @@ -1314,23 +878,12 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file, | |||
| 1314 | void __user *argp = (void __user *)arg; | 878 | void __user *argp = (void __user *)arg; |
| 1315 | int err; | 879 | int err; |
| 1316 | 880 | ||
| 1317 | switch (cmd) { | 881 | if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) |
| 1318 | case CDROMEJECT: | ||
| 1319 | /* fall through */ | ||
| 1320 | case CDROM_LOCKDOOR: | ||
| 1321 | return ide_floppy_lockdoor(drive, &pc, arg, cmd); | 882 | return ide_floppy_lockdoor(drive, &pc, arg, cmd); |
| 1322 | case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: | 883 | |
| 1323 | return 0; | 884 | err = ide_floppy_format_ioctl(drive, file, cmd, argp); |
| 1324 | case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: | 885 | if (err != -ENOTTY) |
| 1325 | return ide_floppy_get_format_capacities(drive, argp); | 886 | return err; |
| 1326 | case IDEFLOPPY_IOCTL_FORMAT_START: | ||
| 1327 | if (!(file->f_mode & 2)) | ||
| 1328 | return -EPERM; | ||
| 1329 | |||
| 1330 | return ide_floppy_format_unit(floppy, (int __user *)arg); | ||
| 1331 | case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS: | ||
| 1332 | return idefloppy_get_format_progress(drive, argp); | ||
| 1333 | } | ||
| 1334 | 887 | ||
| 1335 | /* | 888 | /* |
| 1336 | * skip SCSI_IOCTL_SEND_COMMAND (deprecated) | 889 | * skip SCSI_IOCTL_SEND_COMMAND (deprecated) |
| @@ -1339,8 +892,6 @@ static int idefloppy_ioctl(struct inode *inode, struct file *file, | |||
| 1339 | if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND) | 892 | if (cmd != CDROM_SEND_PACKET && cmd != SCSI_IOCTL_SEND_COMMAND) |
| 1340 | err = scsi_cmd_ioctl(file, bdev->bd_disk->queue, | 893 | err = scsi_cmd_ioctl(file, bdev->bd_disk->queue, |
| 1341 | bdev->bd_disk, cmd, argp); | 894 | bdev->bd_disk, cmd, argp); |
| 1342 | else | ||
| 1343 | err = -ENOTTY; | ||
| 1344 | 895 | ||
| 1345 | if (err == -ENOTTY) | 896 | if (err == -ENOTTY) |
| 1346 | err = generic_ide_ioctl(drive, file, bdev, cmd, arg); | 897 | err = generic_ide_ioctl(drive, file, bdev, cmd, arg); |
| @@ -1388,11 +939,11 @@ static int ide_floppy_probe(ide_drive_t *drive) | |||
| 1388 | 939 | ||
| 1389 | if (!strstr("ide-floppy", drive->driver_req)) | 940 | if (!strstr("ide-floppy", drive->driver_req)) |
| 1390 | goto failed; | 941 | goto failed; |
| 1391 | if (!drive->present) | 942 | |
| 1392 | goto failed; | ||
| 1393 | if (drive->media != ide_floppy) | 943 | if (drive->media != ide_floppy) |
| 1394 | goto failed; | 944 | goto failed; |
| 1395 | if (!idefloppy_identify_device(drive, drive->id)) { | 945 | |
| 946 | if (!ide_check_atapi_device(drive, DRV_NAME)) { | ||
| 1396 | printk(KERN_ERR "ide-floppy: %s: not supported by this version" | 947 | printk(KERN_ERR "ide-floppy: %s: not supported by this version" |
| 1397 | " of ide-floppy\n", drive->name); | 948 | " of ide-floppy\n", drive->name); |
| 1398 | goto failed; | 949 | goto failed; |
| @@ -1410,8 +961,6 @@ static int ide_floppy_probe(ide_drive_t *drive) | |||
| 1410 | 961 | ||
| 1411 | ide_init_disk(g, drive); | 962 | ide_init_disk(g, drive); |
| 1412 | 963 | ||
| 1413 | ide_proc_register_driver(drive, &idefloppy_driver); | ||
| 1414 | |||
| 1415 | kref_init(&floppy->kref); | 964 | kref_init(&floppy->kref); |
| 1416 | 965 | ||
| 1417 | floppy->drive = drive; | 966 | floppy->drive = drive; |
| @@ -1450,6 +999,7 @@ static int __init idefloppy_init(void) | |||
| 1450 | } | 999 | } |
| 1451 | 1000 | ||
| 1452 | MODULE_ALIAS("ide:*m-floppy*"); | 1001 | MODULE_ALIAS("ide:*m-floppy*"); |
| 1002 | MODULE_ALIAS("ide-floppy"); | ||
| 1453 | module_init(idefloppy_init); | 1003 | module_init(idefloppy_init); |
| 1454 | module_exit(idefloppy_exit); | 1004 | module_exit(idefloppy_exit); |
| 1455 | MODULE_LICENSE("GPL"); | 1005 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/ide/ide-floppy.h b/drivers/ide/ide-floppy.h new file mode 100644 index 000000000000..ecadc2bc322d --- /dev/null +++ b/drivers/ide/ide-floppy.h | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | #ifndef __IDE_FLOPPY_H | ||
| 2 | #define __IDE_FLOPPY_H | ||
| 3 | |||
| 4 | /* | ||
| 5 | * Most of our global data which we need to save even as we leave the driver | ||
| 6 | * due to an interrupt or a timer event is stored in a variable of type | ||
| 7 | * idefloppy_floppy_t, defined below. | ||
| 8 | */ | ||
| 9 | typedef struct ide_floppy_obj { | ||
| 10 | ide_drive_t *drive; | ||
| 11 | ide_driver_t *driver; | ||
| 12 | struct gendisk *disk; | ||
| 13 | struct kref kref; | ||
| 14 | unsigned int openers; /* protected by BKL for now */ | ||
| 15 | |||
| 16 | /* Current packet command */ | ||
| 17 | struct ide_atapi_pc *pc; | ||
| 18 | /* Last failed packet command */ | ||
| 19 | struct ide_atapi_pc *failed_pc; | ||
| 20 | /* used for blk_{fs,pc}_request() requests */ | ||
| 21 | struct ide_atapi_pc queued_pc; | ||
| 22 | |||
| 23 | struct ide_atapi_pc request_sense_pc; | ||
| 24 | struct request request_sense_rq; | ||
| 25 | |||
| 26 | /* Last error information */ | ||
| 27 | u8 sense_key, asc, ascq; | ||
| 28 | /* delay this long before sending packet command */ | ||
| 29 | u8 ticks; | ||
| 30 | int progress_indication; | ||
| 31 | |||
| 32 | /* Device information */ | ||
| 33 | /* Current format */ | ||
| 34 | int blocks, block_size, bs_factor; | ||
| 35 | /* Last format capacity descriptor */ | ||
| 36 | u8 cap_desc[8]; | ||
| 37 | /* Copy of the flexible disk page */ | ||
| 38 | u8 flexible_disk_page[32]; | ||
| 39 | } idefloppy_floppy_t; | ||
| 40 | |||
| 41 | /* | ||
| 42 | * Pages of the SELECT SENSE / MODE SENSE packet commands. | ||
| 43 | * See SFF-8070i spec. | ||
| 44 | */ | ||
| 45 | #define IDEFLOPPY_CAPABILITIES_PAGE 0x1b | ||
| 46 | #define IDEFLOPPY_FLEXIBLE_DISK_PAGE 0x05 | ||
| 47 | |||
| 48 | /* IOCTLs used in low-level formatting. */ | ||
| 49 | #define IDEFLOPPY_IOCTL_FORMAT_SUPPORTED 0x4600 | ||
| 50 | #define IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY 0x4601 | ||
| 51 | #define IDEFLOPPY_IOCTL_FORMAT_START 0x4602 | ||
| 52 | #define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 | ||
| 53 | |||
| 54 | /* ide-floppy.c */ | ||
| 55 | void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8); | ||
| 56 | void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *); | ||
| 57 | void ide_floppy_create_request_sense_cmd(struct ide_atapi_pc *); | ||
| 58 | |||
| 59 | /* ide-floppy_ioctl.c */ | ||
| 60 | int ide_floppy_format_ioctl(ide_drive_t *, struct file *, unsigned int, | ||
| 61 | void __user *); | ||
| 62 | |||
| 63 | #endif /*__IDE_FLOPPY_H */ | ||
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c new file mode 100644 index 000000000000..5ffc4512d14b --- /dev/null +++ b/drivers/ide/ide-floppy_ioctl.c | |||
| @@ -0,0 +1,243 @@ | |||
| 1 | /* | ||
| 2 | * ide-floppy IOCTLs handling. | ||
| 3 | */ | ||
| 4 | |||
| 5 | #include <linux/kernel.h> | ||
| 6 | #include <linux/ide.h> | ||
| 7 | #include <linux/cdrom.h> | ||
| 8 | |||
| 9 | #include <asm/unaligned.h> | ||
| 10 | |||
| 11 | #include <scsi/scsi_ioctl.h> | ||
| 12 | |||
| 13 | #include "ide-floppy.h" | ||
| 14 | |||
| 15 | /* | ||
| 16 | * Obtain the list of formattable capacities. | ||
| 17 | * Very similar to ide_floppy_get_capacity, except that we push the capacity | ||
| 18 | * descriptors to userland, instead of our own structures. | ||
| 19 | * | ||
| 20 | * Userland gives us the following structure: | ||
| 21 | * | ||
| 22 | * struct idefloppy_format_capacities { | ||
| 23 | * int nformats; | ||
| 24 | * struct { | ||
| 25 | * int nblocks; | ||
| 26 | * int blocksize; | ||
| 27 | * } formats[]; | ||
| 28 | * }; | ||
| 29 | * | ||
| 30 | * userland initializes nformats to the number of allocated formats[] records. | ||
| 31 | * On exit we set nformats to the number of records we've actually initialized. | ||
| 32 | */ | ||
| 33 | |||
| 34 | static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) | ||
| 35 | { | ||
| 36 | struct ide_floppy_obj *floppy = drive->driver_data; | ||
| 37 | struct ide_atapi_pc pc; | ||
| 38 | u8 header_len, desc_cnt; | ||
| 39 | int i, blocks, length, u_array_size, u_index; | ||
| 40 | int __user *argp; | ||
| 41 | |||
| 42 | if (get_user(u_array_size, arg)) | ||
| 43 | return -EFAULT; | ||
| 44 | |||
| 45 | if (u_array_size <= 0) | ||
| 46 | return -EINVAL; | ||
| 47 | |||
| 48 | ide_floppy_create_read_capacity_cmd(&pc); | ||
| 49 | if (ide_queue_pc_tail(drive, floppy->disk, &pc)) { | ||
| 50 | printk(KERN_ERR "ide-floppy: Can't get floppy parameters\n"); | ||
| 51 | return -EIO; | ||
| 52 | } | ||
| 53 | |||
| 54 | header_len = pc.buf[3]; | ||
| 55 | desc_cnt = header_len / 8; /* capacity descriptor of 8 bytes */ | ||
| 56 | |||
| 57 | u_index = 0; | ||
| 58 | argp = arg + 1; | ||
| 59 | |||
| 60 | /* | ||
| 61 | * We always skip the first capacity descriptor. That's the current | ||
| 62 | * capacity. We are interested in the remaining descriptors, the | ||
| 63 | * formattable capacities. | ||
| 64 | */ | ||
| 65 | for (i = 1; i < desc_cnt; i++) { | ||
| 66 | unsigned int desc_start = 4 + i*8; | ||
| 67 | |||
| 68 | if (u_index >= u_array_size) | ||
| 69 | break; /* User-supplied buffer too small */ | ||
| 70 | |||
| 71 | blocks = be32_to_cpup((__be32 *)&pc.buf[desc_start]); | ||
| 72 | length = be16_to_cpup((__be16 *)&pc.buf[desc_start + 6]); | ||
| 73 | |||
| 74 | if (put_user(blocks, argp)) | ||
| 75 | return -EFAULT; | ||
| 76 | |||
| 77 | ++argp; | ||
| 78 | |||
| 79 | if (put_user(length, argp)) | ||
| 80 | return -EFAULT; | ||
| 81 | |||
| 82 | ++argp; | ||
| 83 | |||
| 84 | ++u_index; | ||
| 85 | } | ||
| 86 | |||
| 87 | if (put_user(u_index, arg)) | ||
| 88 | return -EFAULT; | ||
| 89 | |||
| 90 | return 0; | ||
| 91 | } | ||
| 92 | |||
| 93 | static void ide_floppy_create_format_unit_cmd(struct ide_atapi_pc *pc, int b, | ||
| 94 | int l, int flags) | ||
| 95 | { | ||
| 96 | ide_init_pc(pc); | ||
| 97 | pc->c[0] = GPCMD_FORMAT_UNIT; | ||
| 98 | pc->c[1] = 0x17; | ||
| 99 | |||
| 100 | memset(pc->buf, 0, 12); | ||
| 101 | pc->buf[1] = 0xA2; | ||
| 102 | /* Default format list header, u8 1: FOV/DCRT/IMM bits set */ | ||
| 103 | |||
| 104 | if (flags & 1) /* Verify bit on... */ | ||
| 105 | pc->buf[1] ^= 0x20; /* ... turn off DCRT bit */ | ||
| 106 | pc->buf[3] = 8; | ||
| 107 | |||
| 108 | put_unaligned(cpu_to_be32(b), (unsigned int *)(&pc->buf[4])); | ||
| 109 | put_unaligned(cpu_to_be32(l), (unsigned int *)(&pc->buf[8])); | ||
| 110 | pc->buf_size = 12; | ||
| 111 | pc->flags |= PC_FLAG_WRITING; | ||
| 112 | } | ||
| 113 | |||
| 114 | static int ide_floppy_get_sfrp_bit(ide_drive_t *drive) | ||
| 115 | { | ||
| 116 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
| 117 | struct ide_atapi_pc pc; | ||
| 118 | |||
| 119 | drive->atapi_flags &= ~IDE_AFLAG_SRFP; | ||
| 120 | |||
| 121 | ide_floppy_create_mode_sense_cmd(&pc, IDEFLOPPY_CAPABILITIES_PAGE); | ||
| 122 | pc.flags |= PC_FLAG_SUPPRESS_ERROR; | ||
| 123 | |||
| 124 | if (ide_queue_pc_tail(drive, floppy->disk, &pc)) | ||
| 125 | return 1; | ||
| 126 | |||
| 127 | if (pc.buf[8 + 2] & 0x40) | ||
| 128 | drive->atapi_flags |= IDE_AFLAG_SRFP; | ||
| 129 | |||
| 130 | return 0; | ||
| 131 | } | ||
| 132 | |||
| 133 | static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg) | ||
| 134 | { | ||
| 135 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
| 136 | struct ide_atapi_pc pc; | ||
| 137 | int blocks, length, flags, err = 0; | ||
| 138 | |||
| 139 | if (floppy->openers > 1) { | ||
| 140 | /* Don't format if someone is using the disk */ | ||
| 141 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | ||
| 142 | return -EBUSY; | ||
| 143 | } | ||
| 144 | |||
| 145 | drive->atapi_flags |= IDE_AFLAG_FORMAT_IN_PROGRESS; | ||
| 146 | |||
| 147 | /* | ||
| 148 | * Send ATAPI_FORMAT_UNIT to the drive. | ||
| 149 | * | ||
| 150 | * Userland gives us the following structure: | ||
| 151 | * | ||
| 152 | * struct idefloppy_format_command { | ||
| 153 | * int nblocks; | ||
| 154 | * int blocksize; | ||
| 155 | * int flags; | ||
| 156 | * } ; | ||
| 157 | * | ||
| 158 | * flags is a bitmask, currently, the only defined flag is: | ||
| 159 | * | ||
| 160 | * 0x01 - verify media after format. | ||
| 161 | */ | ||
| 162 | if (get_user(blocks, arg) || | ||
| 163 | get_user(length, arg+1) || | ||
| 164 | get_user(flags, arg+2)) { | ||
| 165 | err = -EFAULT; | ||
| 166 | goto out; | ||
| 167 | } | ||
| 168 | |||
| 169 | (void)ide_floppy_get_sfrp_bit(drive); | ||
| 170 | ide_floppy_create_format_unit_cmd(&pc, blocks, length, flags); | ||
| 171 | |||
| 172 | if (ide_queue_pc_tail(drive, floppy->disk, &pc)) | ||
| 173 | err = -EIO; | ||
| 174 | |||
| 175 | out: | ||
| 176 | if (err) | ||
| 177 | drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; | ||
| 178 | return err; | ||
| 179 | } | ||
| 180 | |||
| 181 | /* | ||
| 182 | * Get ATAPI_FORMAT_UNIT progress indication. | ||
| 183 | * | ||
| 184 | * Userland gives a pointer to an int. The int is set to a progress | ||
| 185 | * indicator 0-65536, with 65536=100%. | ||
| 186 | * | ||
| 187 | * If the drive does not support format progress indication, we just check | ||
| 188 | * the dsc bit, and return either 0 or 65536. | ||
| 189 | */ | ||
| 190 | |||
| 191 | static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg) | ||
| 192 | { | ||
| 193 | idefloppy_floppy_t *floppy = drive->driver_data; | ||
| 194 | struct ide_atapi_pc pc; | ||
| 195 | int progress_indication = 0x10000; | ||
| 196 | |||
| 197 | if (drive->atapi_flags & IDE_AFLAG_SRFP) { | ||
| 198 | ide_floppy_create_request_sense_cmd(&pc); | ||
| 199 | if (ide_queue_pc_tail(drive, floppy->disk, &pc)) | ||
| 200 | return -EIO; | ||
| 201 | |||
| 202 | if (floppy->sense_key == 2 && | ||
| 203 | floppy->asc == 4 && | ||
| 204 | floppy->ascq == 4) | ||
| 205 | progress_indication = floppy->progress_indication; | ||
| 206 | |||
| 207 | /* Else assume format_unit has finished, and we're at 0x10000 */ | ||
| 208 | } else { | ||
| 209 | ide_hwif_t *hwif = drive->hwif; | ||
| 210 | unsigned long flags; | ||
| 211 | u8 stat; | ||
| 212 | |||
| 213 | local_irq_save(flags); | ||
| 214 | stat = hwif->tp_ops->read_status(hwif); | ||
| 215 | local_irq_restore(flags); | ||
| 216 | |||
| 217 | progress_indication = ((stat & ATA_DSC) == 0) ? 0 : 0x10000; | ||
| 218 | } | ||
| 219 | |||
| 220 | if (put_user(progress_indication, arg)) | ||
| 221 | return -EFAULT; | ||
| 222 | |||
| 223 | return 0; | ||
| 224 | } | ||
| 225 | |||
| 226 | int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file, | ||
| 227 | unsigned int cmd, void __user *argp) | ||
| 228 | { | ||
| 229 | switch (cmd) { | ||
| 230 | case IDEFLOPPY_IOCTL_FORMAT_SUPPORTED: | ||
| 231 | return 0; | ||
| 232 | case IDEFLOPPY_IOCTL_FORMAT_GET_CAPACITY: | ||
| 233 | return ide_floppy_get_format_capacities(drive, argp); | ||
| 234 | case IDEFLOPPY_IOCTL_FORMAT_START: | ||
| 235 | if (!(file->f_mode & 2)) | ||
| 236 | return -EPERM; | ||
| 237 | return ide_floppy_format_unit(drive, (int __user *)argp); | ||
| 238 | case IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS: | ||
| 239 | return ide_floppy_get_format_progress(drive, argp); | ||
| 240 | default: | ||
| 241 | return -ENOTTY; | ||
| 242 | } | ||
| 243 | } | ||
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c index 8fe8b5b9cf7d..0a3cb0c33ae5 100644 --- a/drivers/ide/ide-generic.c +++ b/drivers/ide/ide-generic.c | |||
| @@ -19,6 +19,7 @@ | |||
| 19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
| 20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
| 21 | #include <linux/ide.h> | 21 | #include <linux/ide.h> |
| 22 | #include <linux/pci_ids.h> | ||
| 22 | 23 | ||
| 23 | /* FIXME: convert m32r to use ide_platform host driver */ | 24 | /* FIXME: convert m32r to use ide_platform host driver */ |
| 24 | #ifdef CONFIG_M32R | 25 | #ifdef CONFIG_M32R |
| @@ -27,7 +28,7 @@ | |||
| 27 | 28 | ||
| 28 | #define DRV_NAME "ide_generic" | 29 | #define DRV_NAME "ide_generic" |
| 29 | 30 | ||
| 30 | static int probe_mask = 0x03; | 31 | static int probe_mask; |
| 31 | module_param(probe_mask, int, 0); | 32 | module_param(probe_mask, int, 0); |
| 32 | MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports"); | 33 | MODULE_PARM_DESC(probe_mask, "probe mask for legacy ISA IDE ports"); |
| 33 | 34 | ||
| @@ -100,19 +101,65 @@ static const u16 legacy_bases[] = { 0x1f0, 0x170, 0x1e8, 0x168, 0x1e0, 0x160 }; | |||
| 100 | static const int legacy_irqs[] = { 14, 15, 11, 10, 8, 12 }; | 101 | static const int legacy_irqs[] = { 14, 15, 11, 10, 8, 12 }; |
| 101 | #endif | 102 | #endif |
| 102 | 103 | ||
| 104 | static void ide_generic_check_pci_legacy_iobases(int *primary, int *secondary) | ||
| 105 | { | ||
| 106 | struct pci_dev *p = NULL; | ||
| 107 | u16 val; | ||
| 108 | |||
| 109 | for_each_pci_dev(p) { | ||
| 110 | |||
| 111 | if (pci_resource_start(p, 0) == 0x1f0) | ||
| 112 | *primary = 1; | ||
| 113 | if (pci_resource_start(p, 2) == 0x170) | ||
| 114 | *secondary = 1; | ||
| 115 | |||
| 116 | /* Cyrix CS55{1,2}0 pre SFF MWDMA ATA on the bridge */ | ||
| 117 | if (p->vendor == PCI_VENDOR_ID_CYRIX && | ||
| 118 | (p->device == PCI_DEVICE_ID_CYRIX_5510 || | ||
| 119 | p->device == PCI_DEVICE_ID_CYRIX_5520)) | ||
| 120 | *primary = *secondary = 1; | ||
| 121 | |||
| 122 | /* Intel MPIIX - PIO ATA on non PCI side of bridge */ | ||
| 123 | if (p->vendor == PCI_VENDOR_ID_INTEL && | ||
| 124 | p->device == PCI_DEVICE_ID_INTEL_82371MX) { | ||
| 125 | |||
| 126 | pci_read_config_word(p, 0x6C, &val); | ||
| 127 | if (val & 0x8000) { | ||
| 128 | /* ATA port enabled */ | ||
| 129 | if (val & 0x4000) | ||
| 130 | *secondary = 1; | ||
| 131 | else | ||
| 132 | *primary = 1; | ||
| 133 | } | ||
| 134 | } | ||
| 135 | } | ||
| 136 | } | ||
| 137 | |||
| 103 | static int __init ide_generic_init(void) | 138 | static int __init ide_generic_init(void) |
| 104 | { | 139 | { |
| 105 | hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS]; | 140 | hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS]; |
| 106 | struct ide_host *host; | 141 | struct ide_host *host; |
| 107 | unsigned long io_addr; | 142 | unsigned long io_addr; |
| 108 | int i, rc; | 143 | int i, rc, primary = 0, secondary = 0; |
| 109 | 144 | ||
| 110 | #ifdef CONFIG_MIPS | 145 | #ifdef CONFIG_MIPS |
| 111 | if (!ide_probe_legacy()) | 146 | if (!ide_probe_legacy()) |
| 112 | return -ENODEV; | 147 | return -ENODEV; |
| 113 | #endif | 148 | #endif |
| 114 | printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module " | 149 | ide_generic_check_pci_legacy_iobases(&primary, &secondary); |
| 115 | "parameter for probing all legacy ISA IDE ports\n"); | 150 | |
| 151 | if (!probe_mask) { | ||
| 152 | printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" " | ||
| 153 | "module parameter for probing all legacy ISA IDE ports\n"); | ||
| 154 | |||
| 155 | if (primary == 0) | ||
| 156 | probe_mask |= 0x1; | ||
| 157 | |||
| 158 | if (secondary == 0) | ||
| 159 | probe_mask |= 0x2; | ||
| 160 | } else | ||
| 161 | printk(KERN_INFO DRV_NAME ": enforcing probing of I/O ports " | ||
| 162 | "upon user request\n"); | ||
| 116 | 163 | ||
| 117 | memset(hws, 0, sizeof(hw_regs_t *) * MAX_HWIFS); | 164 | memset(hws, 0, sizeof(hw_regs_t *) * MAX_HWIFS); |
| 118 | 165 | ||
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index a896a283f27f..1c51949833be 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | #include <linux/pci.h> | 40 | #include <linux/pci.h> |
| 41 | #include <linux/delay.h> | 41 | #include <linux/delay.h> |
| 42 | #include <linux/ide.h> | 42 | #include <linux/ide.h> |
| 43 | #include <linux/hdreg.h> | ||
| 43 | #include <linux/completion.h> | 44 | #include <linux/completion.h> |
| 44 | #include <linux/reboot.h> | 45 | #include <linux/reboot.h> |
| 45 | #include <linux/cdrom.h> | 46 | #include <linux/cdrom.h> |
| @@ -183,18 +184,18 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * | |||
| 183 | if (drive->media != ide_disk) | 184 | if (drive->media != ide_disk) |
| 184 | break; | 185 | break; |
| 185 | /* Not supported? Switch to next step now. */ | 186 | /* Not supported? Switch to next step now. */ |
| 186 | if (!drive->wcache || !ide_id_has_flush_cache(drive->id)) { | 187 | if (!drive->wcache || ata_id_flush_enabled(drive->id) == 0) { |
| 187 | ide_complete_power_step(drive, rq, 0, 0); | 188 | ide_complete_power_step(drive, rq, 0, 0); |
| 188 | return ide_stopped; | 189 | return ide_stopped; |
| 189 | } | 190 | } |
| 190 | if (ide_id_has_flush_cache_ext(drive->id)) | 191 | if (ata_id_flush_ext_enabled(drive->id)) |
| 191 | args->tf.command = WIN_FLUSH_CACHE_EXT; | 192 | args->tf.command = ATA_CMD_FLUSH_EXT; |
| 192 | else | 193 | else |
| 193 | args->tf.command = WIN_FLUSH_CACHE; | 194 | args->tf.command = ATA_CMD_FLUSH; |
| 194 | goto out_do_tf; | 195 | goto out_do_tf; |
| 195 | 196 | ||
| 196 | case idedisk_pm_standby: /* Suspend step 2 (standby) */ | 197 | case idedisk_pm_standby: /* Suspend step 2 (standby) */ |
| 197 | args->tf.command = WIN_STANDBYNOW1; | 198 | args->tf.command = ATA_CMD_STANDBYNOW1; |
| 198 | goto out_do_tf; | 199 | goto out_do_tf; |
| 199 | 200 | ||
| 200 | case idedisk_pm_restore_pio: /* Resume step 1 (restore PIO) */ | 201 | case idedisk_pm_restore_pio: /* Resume step 1 (restore PIO) */ |
| @@ -209,7 +210,7 @@ static ide_startstop_t ide_start_power_step(ide_drive_t *drive, struct request * | |||
| 209 | return ide_stopped; | 210 | return ide_stopped; |
| 210 | 211 | ||
| 211 | case idedisk_pm_idle: /* Resume step 2 (idle) */ | 212 | case idedisk_pm_idle: /* Resume step 2 (idle) */ |
| 212 | args->tf.command = WIN_IDLEIMMEDIATE; | 213 | args->tf.command = ATA_CMD_IDLEIMMEDIATE; |
| 213 | goto out_do_tf; | 214 | goto out_do_tf; |
| 214 | 215 | ||
| 215 | case ide_pm_restore_dma: /* Resume step 3 (restore DMA) */ | 216 | case ide_pm_restore_dma: /* Resume step 3 (restore DMA) */ |
| @@ -322,7 +323,7 @@ void ide_end_drive_cmd (ide_drive_t *drive, u8 stat, u8 err) | |||
| 322 | ide_task_t *task = (ide_task_t *)rq->special; | 323 | ide_task_t *task = (ide_task_t *)rq->special; |
| 323 | 324 | ||
| 324 | if (rq->errors == 0) | 325 | if (rq->errors == 0) |
| 325 | rq->errors = !OK_STAT(stat, READY_STAT, BAD_STAT); | 326 | rq->errors = !OK_STAT(stat, ATA_DRDY, BAD_STAT); |
| 326 | 327 | ||
| 327 | if (task) { | 328 | if (task) { |
| 328 | struct ide_taskfile *tf = &task->tf; | 329 | struct ide_taskfile *tf = &task->tf; |
| @@ -373,29 +374,29 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 | |||
| 373 | { | 374 | { |
| 374 | ide_hwif_t *hwif = drive->hwif; | 375 | ide_hwif_t *hwif = drive->hwif; |
| 375 | 376 | ||
| 376 | if (stat & BUSY_STAT || ((stat & WRERR_STAT) && !drive->nowerr)) { | 377 | if ((stat & ATA_BUSY) || ((stat & ATA_DF) && !drive->nowerr)) { |
| 377 | /* other bits are useless when BUSY */ | 378 | /* other bits are useless when BUSY */ |
| 378 | rq->errors |= ERROR_RESET; | 379 | rq->errors |= ERROR_RESET; |
| 379 | } else if (stat & ERR_STAT) { | 380 | } else if (stat & ATA_ERR) { |
| 380 | /* err has different meaning on cdrom and tape */ | 381 | /* err has different meaning on cdrom and tape */ |
| 381 | if (err == ABRT_ERR) { | 382 | if (err == ATA_ABORTED) { |
| 382 | if (drive->select.b.lba && | 383 | if (drive->select.b.lba && |
| 383 | /* some newer drives don't support WIN_SPECIFY */ | 384 | /* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */ |
| 384 | hwif->tp_ops->read_status(hwif) == WIN_SPECIFY) | 385 | hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS) |
| 385 | return ide_stopped; | 386 | return ide_stopped; |
| 386 | } else if ((err & BAD_CRC) == BAD_CRC) { | 387 | } else if ((err & BAD_CRC) == BAD_CRC) { |
| 387 | /* UDMA crc error, just retry the operation */ | 388 | /* UDMA crc error, just retry the operation */ |
| 388 | drive->crc_count++; | 389 | drive->crc_count++; |
| 389 | } else if (err & (BBD_ERR | ECC_ERR)) { | 390 | } else if (err & (ATA_BBK | ATA_UNC)) { |
| 390 | /* retries won't help these */ | 391 | /* retries won't help these */ |
| 391 | rq->errors = ERROR_MAX; | 392 | rq->errors = ERROR_MAX; |
| 392 | } else if (err & TRK0_ERR) { | 393 | } else if (err & ATA_TRK0NF) { |
| 393 | /* help it find track zero */ | 394 | /* help it find track zero */ |
| 394 | rq->errors |= ERROR_RECAL; | 395 | rq->errors |= ERROR_RECAL; |
| 395 | } | 396 | } |
| 396 | } | 397 | } |
| 397 | 398 | ||
| 398 | if ((stat & DRQ_STAT) && rq_data_dir(rq) == READ && | 399 | if ((stat & ATA_DRQ) && rq_data_dir(rq) == READ && |
| 399 | (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) { | 400 | (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) { |
| 400 | int nsect = drive->mult_count ? drive->mult_count : 1; | 401 | int nsect = drive->mult_count ? drive->mult_count : 1; |
| 401 | 402 | ||
| @@ -407,7 +408,7 @@ static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq, u8 | |||
| 407 | return ide_stopped; | 408 | return ide_stopped; |
| 408 | } | 409 | } |
| 409 | 410 | ||
| 410 | if (hwif->tp_ops->read_status(hwif) & (BUSY_STAT | DRQ_STAT)) | 411 | if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ)) |
| 411 | rq->errors |= ERROR_RESET; | 412 | rq->errors |= ERROR_RESET; |
| 412 | 413 | ||
| 413 | if ((rq->errors & ERROR_RESET) == ERROR_RESET) { | 414 | if ((rq->errors & ERROR_RESET) == ERROR_RESET) { |
| @@ -427,16 +428,16 @@ static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq, u | |||
| 427 | { | 428 | { |
| 428 | ide_hwif_t *hwif = drive->hwif; | 429 | ide_hwif_t *hwif = drive->hwif; |
| 429 | 430 | ||
| 430 | if (stat & BUSY_STAT || ((stat & WRERR_STAT) && !drive->nowerr)) { | 431 | if ((stat & ATA_BUSY) || ((stat & ATA_DF) && !drive->nowerr)) { |
| 431 | /* other bits are useless when BUSY */ | 432 | /* other bits are useless when BUSY */ |
| 432 | rq->errors |= ERROR_RESET; | 433 | rq->errors |= ERROR_RESET; |
| 433 | } else { | 434 | } else { |
| 434 | /* add decoding error stuff */ | 435 | /* add decoding error stuff */ |
| 435 | } | 436 | } |
| 436 | 437 | ||
| 437 | if (hwif->tp_ops->read_status(hwif) & (BUSY_STAT | DRQ_STAT)) | 438 | if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ)) |
| 438 | /* force an abort */ | 439 | /* force an abort */ |
| 439 | hwif->tp_ops->exec_command(hwif, WIN_IDLEIMMEDIATE); | 440 | hwif->tp_ops->exec_command(hwif, ATA_CMD_IDLEIMMEDIATE); |
| 440 | 441 | ||
| 441 | if (rq->errors >= ERROR_MAX) { | 442 | if (rq->errors >= ERROR_MAX) { |
| 442 | ide_kill_rq(drive, rq); | 443 | ide_kill_rq(drive, rq); |
| @@ -509,19 +510,19 @@ static void ide_tf_set_specify_cmd(ide_drive_t *drive, struct ide_taskfile *tf) | |||
| 509 | tf->lbam = drive->cyl; | 510 | tf->lbam = drive->cyl; |
| 510 | tf->lbah = drive->cyl >> 8; | 511 | tf->lbah = drive->cyl >> 8; |
| 511 | tf->device = ((drive->head - 1) | drive->select.all) & ~ATA_LBA; | 512 | tf->device = ((drive->head - 1) | drive->select.all) & ~ATA_LBA; |
| 512 | tf->command = WIN_SPECIFY; | 513 | tf->command = ATA_CMD_INIT_DEV_PARAMS; |
| 513 | } | 514 | } |
| 514 | 515 | ||
| 515 | static void ide_tf_set_restore_cmd(ide_drive_t *drive, struct ide_taskfile *tf) | 516 | static void ide_tf_set_restore_cmd(ide_drive_t *drive, struct ide_taskfile *tf) |
| 516 | { | 517 | { |
| 517 | tf->nsect = drive->sect; | 518 | tf->nsect = drive->sect; |
| 518 | tf->command = WIN_RESTORE; | 519 | tf->command = ATA_CMD_RESTORE; |
| 519 | } | 520 | } |
| 520 | 521 | ||
| 521 | static void ide_tf_set_setmult_cmd(ide_drive_t *drive, struct ide_taskfile *tf) | 522 | static void ide_tf_set_setmult_cmd(ide_drive_t *drive, struct ide_taskfile *tf) |
| 522 | { | 523 | { |
| 523 | tf->nsect = drive->mult_req; | 524 | tf->nsect = drive->mult_req; |
| 524 | tf->command = WIN_SETMULT; | 525 | tf->command = ATA_CMD_SET_MULTI; |
| 525 | } | 526 | } |
| 526 | 527 | ||
| 527 | static ide_startstop_t ide_disk_special(ide_drive_t *drive) | 528 | static ide_startstop_t ide_disk_special(ide_drive_t *drive) |
| @@ -540,8 +541,6 @@ static ide_startstop_t ide_disk_special(ide_drive_t *drive) | |||
| 540 | ide_tf_set_restore_cmd(drive, &args.tf); | 541 | ide_tf_set_restore_cmd(drive, &args.tf); |
| 541 | } else if (s->b.set_multmode) { | 542 | } else if (s->b.set_multmode) { |
| 542 | s->b.set_multmode = 0; | 543 | s->b.set_multmode = 0; |
| 543 | if (drive->mult_req > drive->id->max_multsect) | ||
| 544 | drive->mult_req = drive->id->max_multsect; | ||
| 545 | ide_tf_set_setmult_cmd(drive, &args.tf); | 544 | ide_tf_set_setmult_cmd(drive, &args.tf); |
| 546 | } else if (s->all) { | 545 | } else if (s->all) { |
| 547 | int special = s->all; | 546 | int special = s->all; |
| @@ -586,9 +585,10 @@ static int set_pio_mode_abuse(ide_hwif_t *hwif, u8 req_pio) | |||
| 586 | * do_special - issue some special commands | 585 | * do_special - issue some special commands |
| 587 | * @drive: drive the command is for | 586 | * @drive: drive the command is for |
| 588 | * | 587 | * |
| 589 | * do_special() is used to issue WIN_SPECIFY, WIN_RESTORE, and WIN_SETMULT | 588 | * do_special() is used to issue ATA_CMD_INIT_DEV_PARAMS, |
| 590 | * commands to a drive. It used to do much more, but has been scaled | 589 | * ATA_CMD_RESTORE and ATA_CMD_SET_MULTI commands to a drive. |
| 591 | * back. | 590 | * |
| 591 | * It used to do much more, but has been scaled back. | ||
| 592 | */ | 592 | */ |
| 593 | 593 | ||
| 594 | static ide_startstop_t do_special (ide_drive_t *drive) | 594 | static ide_startstop_t do_special (ide_drive_t *drive) |
| @@ -716,9 +716,49 @@ static ide_startstop_t execute_drive_cmd (ide_drive_t *drive, | |||
| 716 | return ide_stopped; | 716 | return ide_stopped; |
| 717 | } | 717 | } |
| 718 | 718 | ||
| 719 | int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting, | ||
| 720 | int arg) | ||
| 721 | { | ||
| 722 | struct request_queue *q = drive->queue; | ||
| 723 | struct request *rq; | ||
| 724 | int ret = 0; | ||
| 725 | |||
| 726 | if (!(setting->flags & DS_SYNC)) | ||
| 727 | return setting->set(drive, arg); | ||
| 728 | |||
| 729 | rq = blk_get_request(q, READ, GFP_KERNEL); | ||
| 730 | if (!rq) | ||
| 731 | return -ENOMEM; | ||
| 732 | |||
| 733 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
| 734 | rq->cmd_len = 5; | ||
| 735 | rq->cmd[0] = REQ_DEVSET_EXEC; | ||
| 736 | *(int *)&rq->cmd[1] = arg; | ||
| 737 | rq->special = setting->set; | ||
| 738 | |||
| 739 | if (blk_execute_rq(q, NULL, rq, 0)) | ||
| 740 | ret = rq->errors; | ||
| 741 | blk_put_request(rq); | ||
| 742 | |||
| 743 | return ret; | ||
| 744 | } | ||
| 745 | EXPORT_SYMBOL_GPL(ide_devset_execute); | ||
| 746 | |||
| 719 | static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq) | 747 | static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq) |
| 720 | { | 748 | { |
| 721 | switch (rq->cmd[0]) { | 749 | switch (rq->cmd[0]) { |
| 750 | case REQ_DEVSET_EXEC: | ||
| 751 | { | ||
| 752 | int err, (*setfunc)(ide_drive_t *, int) = rq->special; | ||
| 753 | |||
| 754 | err = setfunc(drive, *(int *)&rq->cmd[1]); | ||
| 755 | if (err) | ||
| 756 | rq->errors = err; | ||
| 757 | else | ||
| 758 | err = 1; | ||
| 759 | ide_end_request(drive, err, 0); | ||
| 760 | return ide_stopped; | ||
| 761 | } | ||
| 722 | case REQ_DRIVE_RESET: | 762 | case REQ_DRIVE_RESET: |
| 723 | return ide_do_reset(drive); | 763 | return ide_do_reset(drive); |
| 724 | default: | 764 | default: |
| @@ -766,9 +806,7 @@ static void ide_check_pm_state(ide_drive_t *drive, struct request *rq) | |||
| 766 | * start_request - start of I/O and command issuing for IDE | 806 | * start_request - start of I/O and command issuing for IDE |
| 767 | * | 807 | * |
| 768 | * start_request() initiates handling of a new I/O request. It | 808 | * start_request() initiates handling of a new I/O request. It |
| 769 | * accepts commands and I/O (read/write) requests. It also does | 809 | * accepts commands and I/O (read/write) requests. |
| 770 | * the final remapping for weird stuff like EZDrive. Once | ||
| 771 | * device mapper can work sector level the EZDrive stuff can go away | ||
| 772 | * | 810 | * |
| 773 | * FIXME: this function needs a rename | 811 | * FIXME: this function needs a rename |
| 774 | */ | 812 | */ |
| @@ -776,7 +814,6 @@ static void ide_check_pm_state(ide_drive_t *drive, struct request *rq) | |||
| 776 | static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) | 814 | static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) |
| 777 | { | 815 | { |
| 778 | ide_startstop_t startstop; | 816 | ide_startstop_t startstop; |
| 779 | sector_t block; | ||
| 780 | 817 | ||
| 781 | BUG_ON(!blk_rq_started(rq)); | 818 | BUG_ON(!blk_rq_started(rq)); |
| 782 | 819 | ||
| @@ -791,21 +828,12 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) | |||
| 791 | goto kill_rq; | 828 | goto kill_rq; |
| 792 | } | 829 | } |
| 793 | 830 | ||
| 794 | block = rq->sector; | ||
| 795 | if (blk_fs_request(rq) && | ||
| 796 | (drive->media == ide_disk || drive->media == ide_floppy)) { | ||
| 797 | block += drive->sect0; | ||
| 798 | } | ||
| 799 | /* Yecch - this will shift the entire interval, | ||
| 800 | possibly killing some innocent following sector */ | ||
| 801 | if (block == 0 && drive->remap_0_to_1 == 1) | ||
| 802 | block = 1; /* redirect MBR access to EZ-Drive partn table */ | ||
| 803 | |||
| 804 | if (blk_pm_request(rq)) | 831 | if (blk_pm_request(rq)) |
| 805 | ide_check_pm_state(drive, rq); | 832 | ide_check_pm_state(drive, rq); |
| 806 | 833 | ||
| 807 | SELECT_DRIVE(drive); | 834 | SELECT_DRIVE(drive); |
| 808 | if (ide_wait_stat(&startstop, drive, drive->ready_stat, BUSY_STAT|DRQ_STAT, WAIT_READY)) { | 835 | if (ide_wait_stat(&startstop, drive, drive->ready_stat, |
| 836 | ATA_BUSY | ATA_DRQ, WAIT_READY)) { | ||
| 809 | printk(KERN_ERR "%s: drive not ready for command\n", drive->name); | 837 | printk(KERN_ERR "%s: drive not ready for command\n", drive->name); |
| 810 | return startstop; | 838 | return startstop; |
| 811 | } | 839 | } |
| @@ -844,7 +872,8 @@ static ide_startstop_t start_request (ide_drive_t *drive, struct request *rq) | |||
| 844 | return ide_special_rq(drive, rq); | 872 | return ide_special_rq(drive, rq); |
| 845 | 873 | ||
| 846 | drv = *(ide_driver_t **)rq->rq_disk->private_data; | 874 | drv = *(ide_driver_t **)rq->rq_disk->private_data; |
| 847 | return drv->do_request(drive, rq, block); | 875 | |
| 876 | return drv->do_request(drive, rq, rq->sector); | ||
| 848 | } | 877 | } |
| 849 | return do_special(drive); | 878 | return do_special(drive); |
| 850 | kill_rq: | 879 | kill_rq: |
| @@ -1325,7 +1354,7 @@ static void unexpected_intr (int irq, ide_hwgroup_t *hwgroup) | |||
| 1325 | if (hwif->irq == irq) { | 1354 | if (hwif->irq == irq) { |
| 1326 | stat = hwif->tp_ops->read_status(hwif); | 1355 | stat = hwif->tp_ops->read_status(hwif); |
| 1327 | 1356 | ||
| 1328 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) { | 1357 | if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) { |
| 1329 | /* Try to not flood the console with msgs */ | 1358 | /* Try to not flood the console with msgs */ |
| 1330 | static unsigned long last_msgtime, count; | 1359 | static unsigned long last_msgtime, count; |
| 1331 | ++count; | 1360 | ++count; |
diff --git a/drivers/ide/ide-ioctls.c b/drivers/ide/ide-ioctls.c new file mode 100644 index 000000000000..cf01564901af --- /dev/null +++ b/drivers/ide/ide-ioctls.c | |||
| @@ -0,0 +1,290 @@ | |||
| 1 | /* | ||
| 2 | * IDE ioctls handling. | ||
| 3 | */ | ||
| 4 | |||
| 5 | #include <linux/hdreg.h> | ||
| 6 | #include <linux/ide.h> | ||
| 7 | |||
| 8 | static const struct ide_ioctl_devset ide_ioctl_settings[] = { | ||
| 9 | { HDIO_GET_32BIT, HDIO_SET_32BIT, &ide_devset_io_32bit }, | ||
| 10 | { HDIO_GET_KEEPSETTINGS, HDIO_SET_KEEPSETTINGS, &ide_devset_keepsettings }, | ||
| 11 | { HDIO_GET_UNMASKINTR, HDIO_SET_UNMASKINTR, &ide_devset_unmaskirq }, | ||
| 12 | { HDIO_GET_DMA, HDIO_SET_DMA, &ide_devset_using_dma }, | ||
| 13 | { -1, HDIO_SET_PIO_MODE, &ide_devset_pio_mode }, | ||
| 14 | { 0 } | ||
| 15 | }; | ||
| 16 | |||
| 17 | int ide_setting_ioctl(ide_drive_t *drive, struct block_device *bdev, | ||
| 18 | unsigned int cmd, unsigned long arg, | ||
| 19 | const struct ide_ioctl_devset *s) | ||
| 20 | { | ||
| 21 | const struct ide_devset *ds; | ||
| 22 | unsigned long flags; | ||
| 23 | int err = -EOPNOTSUPP; | ||
| 24 | |||
| 25 | for (; (ds = s->setting); s++) { | ||
| 26 | if (ds->get && s->get_ioctl == cmd) | ||
| 27 | goto read_val; | ||
| 28 | else if (ds->set && s->set_ioctl == cmd) | ||
| 29 | goto set_val; | ||
| 30 | } | ||
| 31 | |||
| 32 | return err; | ||
| 33 | |||
| 34 | read_val: | ||
| 35 | mutex_lock(&ide_setting_mtx); | ||
| 36 | spin_lock_irqsave(&ide_lock, flags); | ||
| 37 | err = ds->get(drive); | ||
| 38 | spin_unlock_irqrestore(&ide_lock, flags); | ||
| 39 | mutex_unlock(&ide_setting_mtx); | ||
| 40 | return err >= 0 ? put_user(err, (long __user *)arg) : err; | ||
| 41 | |||
| 42 | set_val: | ||
| 43 | if (bdev != bdev->bd_contains) | ||
| 44 | err = -EINVAL; | ||
| 45 | else { | ||
| 46 | if (!capable(CAP_SYS_ADMIN)) | ||
| 47 | err = -EACCES; | ||
| 48 | else { | ||
| 49 | mutex_lock(&ide_setting_mtx); | ||
| 50 | err = ide_devset_execute(drive, ds, arg); | ||
| 51 | mutex_unlock(&ide_setting_mtx); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | return err; | ||
| 55 | } | ||
| 56 | EXPORT_SYMBOL_GPL(ide_setting_ioctl); | ||
| 57 | |||
| 58 | static int ide_get_identity_ioctl(ide_drive_t *drive, unsigned int cmd, | ||
| 59 | unsigned long arg) | ||
| 60 | { | ||
| 61 | u16 *id = NULL; | ||
| 62 | int size = (cmd == HDIO_GET_IDENTITY) ? (ATA_ID_WORDS * 2) : 142; | ||
| 63 | int rc = 0; | ||
| 64 | |||
| 65 | if (drive->id_read == 0) { | ||
| 66 | rc = -ENOMSG; | ||
| 67 | goto out; | ||
| 68 | } | ||
| 69 | |||
| 70 | id = kmalloc(size, GFP_KERNEL); | ||
| 71 | if (id == NULL) { | ||
| 72 | rc = -ENOMEM; | ||
| 73 | goto out; | ||
| 74 | } | ||
| 75 | |||
| 76 | memcpy(id, drive->id, size); | ||
| 77 | ata_id_to_hd_driveid(id); | ||
| 78 | |||
| 79 | if (copy_to_user((void __user *)arg, id, size)) | ||
| 80 | rc = -EFAULT; | ||
| 81 | |||
| 82 | kfree(id); | ||
| 83 | out: | ||
| 84 | return rc; | ||
| 85 | } | ||
| 86 | |||
| 87 | static int ide_get_nice_ioctl(ide_drive_t *drive, unsigned long arg) | ||
| 88 | { | ||
| 89 | return put_user((drive->dsc_overlap << IDE_NICE_DSC_OVERLAP) | | ||
| 90 | (drive->nice1 << IDE_NICE_1), (long __user *)arg); | ||
| 91 | } | ||
| 92 | |||
| 93 | static int ide_set_nice_ioctl(ide_drive_t *drive, unsigned long arg) | ||
| 94 | { | ||
| 95 | if (arg != (arg & ((1 << IDE_NICE_DSC_OVERLAP) | (1 << IDE_NICE_1)))) | ||
| 96 | return -EPERM; | ||
| 97 | |||
| 98 | if (((arg >> IDE_NICE_DSC_OVERLAP) & 1) && | ||
| 99 | (drive->media == ide_disk || drive->media == ide_floppy || | ||
| 100 | drive->scsi)) | ||
| 101 | return -EPERM; | ||
| 102 | |||
| 103 | drive->dsc_overlap = (arg >> IDE_NICE_DSC_OVERLAP) & 1; | ||
| 104 | drive->nice1 = (arg >> IDE_NICE_1) & 1; | ||
| 105 | |||
| 106 | return 0; | ||
| 107 | } | ||
| 108 | |||
| 109 | static int ide_cmd_ioctl(ide_drive_t *drive, unsigned cmd, unsigned long arg) | ||
| 110 | { | ||
| 111 | u8 *buf = NULL; | ||
| 112 | int bufsize = 0, err = 0; | ||
| 113 | u8 args[4], xfer_rate = 0; | ||
| 114 | ide_task_t tfargs; | ||
| 115 | struct ide_taskfile *tf = &tfargs.tf; | ||
| 116 | u16 *id = drive->id; | ||
| 117 | |||
| 118 | if (NULL == (void *) arg) { | ||
| 119 | struct request *rq; | ||
| 120 | |||
| 121 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | ||
| 122 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; | ||
| 123 | err = blk_execute_rq(drive->queue, NULL, rq, 0); | ||
| 124 | blk_put_request(rq); | ||
| 125 | |||
| 126 | return err; | ||
| 127 | } | ||
| 128 | |||
| 129 | if (copy_from_user(args, (void __user *)arg, 4)) | ||
| 130 | return -EFAULT; | ||
| 131 | |||
| 132 | memset(&tfargs, 0, sizeof(ide_task_t)); | ||
| 133 | tf->feature = args[2]; | ||
| 134 | if (args[0] == ATA_CMD_SMART) { | ||
| 135 | tf->nsect = args[3]; | ||
| 136 | tf->lbal = args[1]; | ||
| 137 | tf->lbam = 0x4f; | ||
| 138 | tf->lbah = 0xc2; | ||
| 139 | tfargs.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_IN_NSECT; | ||
| 140 | } else { | ||
| 141 | tf->nsect = args[1]; | ||
| 142 | tfargs.tf_flags = IDE_TFLAG_OUT_FEATURE | | ||
| 143 | IDE_TFLAG_OUT_NSECT | IDE_TFLAG_IN_NSECT; | ||
| 144 | } | ||
| 145 | tf->command = args[0]; | ||
| 146 | tfargs.data_phase = args[3] ? TASKFILE_IN : TASKFILE_NO_DATA; | ||
| 147 | |||
| 148 | if (args[3]) { | ||
| 149 | tfargs.tf_flags |= IDE_TFLAG_IO_16BIT; | ||
| 150 | bufsize = SECTOR_SIZE * args[3]; | ||
| 151 | buf = kzalloc(bufsize, GFP_KERNEL); | ||
| 152 | if (buf == NULL) | ||
| 153 | return -ENOMEM; | ||
| 154 | } | ||
| 155 | |||
| 156 | if (tf->command == ATA_CMD_SET_FEATURES && | ||
| 157 | tf->feature == SETFEATURES_XFER && | ||
| 158 | tf->nsect >= XFER_SW_DMA_0 && | ||
| 159 | (id[ATA_ID_UDMA_MODES] || | ||
| 160 | id[ATA_ID_MWDMA_MODES] || | ||
| 161 | id[ATA_ID_SWDMA_MODES])) { | ||
| 162 | xfer_rate = args[1]; | ||
| 163 | if (tf->nsect > XFER_UDMA_2 && !eighty_ninty_three(drive)) { | ||
| 164 | printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot " | ||
| 165 | "be set\n", drive->name); | ||
| 166 | goto abort; | ||
| 167 | } | ||
| 168 | } | ||
| 169 | |||
| 170 | err = ide_raw_taskfile(drive, &tfargs, buf, args[3]); | ||
| 171 | |||
| 172 | args[0] = tf->status; | ||
| 173 | args[1] = tf->error; | ||
| 174 | args[2] = tf->nsect; | ||
| 175 | |||
| 176 | if (!err && xfer_rate) { | ||
| 177 | /* active-retuning-calls future */ | ||
| 178 | ide_set_xfer_rate(drive, xfer_rate); | ||
| 179 | ide_driveid_update(drive); | ||
| 180 | } | ||
| 181 | abort: | ||
| 182 | if (copy_to_user((void __user *)arg, &args, 4)) | ||
| 183 | err = -EFAULT; | ||
| 184 | if (buf) { | ||
| 185 | if (copy_to_user((void __user *)(arg + 4), buf, bufsize)) | ||
| 186 | err = -EFAULT; | ||
| 187 | kfree(buf); | ||
| 188 | } | ||
| 189 | return err; | ||
| 190 | } | ||
| 191 | |||
| 192 | static int ide_task_ioctl(ide_drive_t *drive, unsigned cmd, unsigned long arg) | ||
| 193 | { | ||
| 194 | void __user *p = (void __user *)arg; | ||
| 195 | int err = 0; | ||
| 196 | u8 args[7]; | ||
| 197 | ide_task_t task; | ||
| 198 | |||
| 199 | if (copy_from_user(args, p, 7)) | ||
| 200 | return -EFAULT; | ||
| 201 | |||
| 202 | memset(&task, 0, sizeof(task)); | ||
| 203 | memcpy(&task.tf_array[7], &args[1], 6); | ||
| 204 | task.tf.command = args[0]; | ||
| 205 | task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
| 206 | |||
| 207 | err = ide_no_data_taskfile(drive, &task); | ||
| 208 | |||
| 209 | args[0] = task.tf.command; | ||
| 210 | memcpy(&args[1], &task.tf_array[7], 6); | ||
| 211 | |||
| 212 | if (copy_to_user(p, args, 7)) | ||
| 213 | err = -EFAULT; | ||
| 214 | |||
| 215 | return err; | ||
| 216 | } | ||
| 217 | |||
| 218 | static int generic_drive_reset(ide_drive_t *drive) | ||
| 219 | { | ||
| 220 | struct request *rq; | ||
| 221 | int ret = 0; | ||
| 222 | |||
| 223 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | ||
| 224 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
| 225 | rq->cmd_len = 1; | ||
| 226 | rq->cmd[0] = REQ_DRIVE_RESET; | ||
| 227 | rq->cmd_flags |= REQ_SOFTBARRIER; | ||
| 228 | if (blk_execute_rq(drive->queue, NULL, rq, 1)) | ||
| 229 | ret = rq->errors; | ||
| 230 | blk_put_request(rq); | ||
| 231 | return ret; | ||
| 232 | } | ||
| 233 | |||
| 234 | int generic_ide_ioctl(ide_drive_t *drive, struct file *file, | ||
| 235 | struct block_device *bdev, | ||
| 236 | unsigned int cmd, unsigned long arg) | ||
| 237 | { | ||
| 238 | int err; | ||
| 239 | |||
| 240 | err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_ioctl_settings); | ||
| 241 | if (err != -EOPNOTSUPP) | ||
| 242 | return err; | ||
| 243 | |||
| 244 | switch (cmd) { | ||
| 245 | case HDIO_OBSOLETE_IDENTITY: | ||
| 246 | case HDIO_GET_IDENTITY: | ||
| 247 | if (bdev != bdev->bd_contains) | ||
| 248 | return -EINVAL; | ||
| 249 | return ide_get_identity_ioctl(drive, cmd, arg); | ||
| 250 | case HDIO_GET_NICE: | ||
| 251 | return ide_get_nice_ioctl(drive, arg); | ||
| 252 | case HDIO_SET_NICE: | ||
| 253 | if (!capable(CAP_SYS_ADMIN)) | ||
| 254 | return -EACCES; | ||
| 255 | return ide_set_nice_ioctl(drive, arg); | ||
| 256 | #ifdef CONFIG_IDE_TASK_IOCTL | ||
| 257 | case HDIO_DRIVE_TASKFILE: | ||
| 258 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | ||
| 259 | return -EACCES; | ||
| 260 | if (drive->media == ide_disk) | ||
| 261 | return ide_taskfile_ioctl(drive, cmd, arg); | ||
| 262 | return -ENOMSG; | ||
| 263 | #endif | ||
| 264 | case HDIO_DRIVE_CMD: | ||
| 265 | if (!capable(CAP_SYS_RAWIO)) | ||
| 266 | return -EACCES; | ||
| 267 | return ide_cmd_ioctl(drive, cmd, arg); | ||
| 268 | case HDIO_DRIVE_TASK: | ||
| 269 | if (!capable(CAP_SYS_RAWIO)) | ||
| 270 | return -EACCES; | ||
| 271 | return ide_task_ioctl(drive, cmd, arg); | ||
| 272 | case HDIO_DRIVE_RESET: | ||
| 273 | if (!capable(CAP_SYS_ADMIN)) | ||
| 274 | return -EACCES; | ||
| 275 | return generic_drive_reset(drive); | ||
| 276 | case HDIO_GET_BUSSTATE: | ||
| 277 | if (!capable(CAP_SYS_ADMIN)) | ||
| 278 | return -EACCES; | ||
| 279 | if (put_user(BUSSTATE_ON, (long __user *)arg)) | ||
| 280 | return -EFAULT; | ||
| 281 | return 0; | ||
| 282 | case HDIO_SET_BUSSTATE: | ||
| 283 | if (!capable(CAP_SYS_ADMIN)) | ||
| 284 | return -EACCES; | ||
| 285 | return -EOPNOTSUPP; | ||
| 286 | default: | ||
| 287 | return -EINVAL; | ||
| 288 | } | ||
| 289 | } | ||
| 290 | EXPORT_SYMBOL(generic_ide_ioctl); | ||
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index 2cbadffe922e..0a2fd3b37ac4 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
| @@ -18,7 +18,6 @@ | |||
| 18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
| 19 | #include <linux/pci.h> | 19 | #include <linux/pci.h> |
| 20 | #include <linux/delay.h> | 20 | #include <linux/delay.h> |
| 21 | #include <linux/hdreg.h> | ||
| 22 | #include <linux/ide.h> | 21 | #include <linux/ide.h> |
| 23 | #include <linux/bitops.h> | 22 | #include <linux/bitops.h> |
| 24 | #include <linux/nmi.h> | 23 | #include <linux/nmi.h> |
| @@ -400,97 +399,14 @@ const struct ide_tp_ops default_tp_ops = { | |||
| 400 | .output_data = ide_output_data, | 399 | .output_data = ide_output_data, |
| 401 | }; | 400 | }; |
| 402 | 401 | ||
| 403 | void ide_fix_driveid (struct hd_driveid *id) | 402 | void ide_fix_driveid(u16 *id) |
| 404 | { | 403 | { |
| 405 | #ifndef __LITTLE_ENDIAN | 404 | #ifndef __LITTLE_ENDIAN |
| 406 | # ifdef __BIG_ENDIAN | 405 | # ifdef __BIG_ENDIAN |
| 407 | int i; | 406 | int i; |
| 408 | u16 *stringcast; | 407 | |
| 409 | 408 | for (i = 0; i < 256; i++) | |
| 410 | id->config = __le16_to_cpu(id->config); | 409 | id[i] = __le16_to_cpu(id[i]); |
| 411 | id->cyls = __le16_to_cpu(id->cyls); | ||
| 412 | id->reserved2 = __le16_to_cpu(id->reserved2); | ||
| 413 | id->heads = __le16_to_cpu(id->heads); | ||
| 414 | id->track_bytes = __le16_to_cpu(id->track_bytes); | ||
| 415 | id->sector_bytes = __le16_to_cpu(id->sector_bytes); | ||
| 416 | id->sectors = __le16_to_cpu(id->sectors); | ||
| 417 | id->vendor0 = __le16_to_cpu(id->vendor0); | ||
| 418 | id->vendor1 = __le16_to_cpu(id->vendor1); | ||
| 419 | id->vendor2 = __le16_to_cpu(id->vendor2); | ||
| 420 | stringcast = (u16 *)&id->serial_no[0]; | ||
| 421 | for (i = 0; i < (20/2); i++) | ||
| 422 | stringcast[i] = __le16_to_cpu(stringcast[i]); | ||
| 423 | id->buf_type = __le16_to_cpu(id->buf_type); | ||
| 424 | id->buf_size = __le16_to_cpu(id->buf_size); | ||
| 425 | id->ecc_bytes = __le16_to_cpu(id->ecc_bytes); | ||
| 426 | stringcast = (u16 *)&id->fw_rev[0]; | ||
| 427 | for (i = 0; i < (8/2); i++) | ||
| 428 | stringcast[i] = __le16_to_cpu(stringcast[i]); | ||
| 429 | stringcast = (u16 *)&id->model[0]; | ||
| 430 | for (i = 0; i < (40/2); i++) | ||
| 431 | stringcast[i] = __le16_to_cpu(stringcast[i]); | ||
| 432 | id->dword_io = __le16_to_cpu(id->dword_io); | ||
| 433 | id->reserved50 = __le16_to_cpu(id->reserved50); | ||
| 434 | id->field_valid = __le16_to_cpu(id->field_valid); | ||
| 435 | id->cur_cyls = __le16_to_cpu(id->cur_cyls); | ||
| 436 | id->cur_heads = __le16_to_cpu(id->cur_heads); | ||
| 437 | id->cur_sectors = __le16_to_cpu(id->cur_sectors); | ||
| 438 | id->cur_capacity0 = __le16_to_cpu(id->cur_capacity0); | ||
| 439 | id->cur_capacity1 = __le16_to_cpu(id->cur_capacity1); | ||
| 440 | id->lba_capacity = __le32_to_cpu(id->lba_capacity); | ||
| 441 | id->dma_1word = __le16_to_cpu(id->dma_1word); | ||
| 442 | id->dma_mword = __le16_to_cpu(id->dma_mword); | ||
| 443 | id->eide_pio_modes = __le16_to_cpu(id->eide_pio_modes); | ||
| 444 | id->eide_dma_min = __le16_to_cpu(id->eide_dma_min); | ||
| 445 | id->eide_dma_time = __le16_to_cpu(id->eide_dma_time); | ||
| 446 | id->eide_pio = __le16_to_cpu(id->eide_pio); | ||
| 447 | id->eide_pio_iordy = __le16_to_cpu(id->eide_pio_iordy); | ||
| 448 | for (i = 0; i < 2; ++i) | ||
| 449 | id->words69_70[i] = __le16_to_cpu(id->words69_70[i]); | ||
| 450 | for (i = 0; i < 4; ++i) | ||
| 451 | id->words71_74[i] = __le16_to_cpu(id->words71_74[i]); | ||
| 452 | id->queue_depth = __le16_to_cpu(id->queue_depth); | ||
| 453 | for (i = 0; i < 4; ++i) | ||
| 454 | id->words76_79[i] = __le16_to_cpu(id->words76_79[i]); | ||
| 455 | id->major_rev_num = __le16_to_cpu(id->major_rev_num); | ||
| 456 | id->minor_rev_num = __le16_to_cpu(id->minor_rev_num); | ||
| 457 | id->command_set_1 = __le16_to_cpu(id->command_set_1); | ||
| 458 | id->command_set_2 = __le16_to_cpu(id->command_set_2); | ||
| 459 | id->cfsse = __le16_to_cpu(id->cfsse); | ||
| 460 | id->cfs_enable_1 = __le16_to_cpu(id->cfs_enable_1); | ||
| 461 | id->cfs_enable_2 = __le16_to_cpu(id->cfs_enable_2); | ||
| 462 | id->csf_default = __le16_to_cpu(id->csf_default); | ||
| 463 | id->dma_ultra = __le16_to_cpu(id->dma_ultra); | ||
| 464 | id->trseuc = __le16_to_cpu(id->trseuc); | ||
| 465 | id->trsEuc = __le16_to_cpu(id->trsEuc); | ||
| 466 | id->CurAPMvalues = __le16_to_cpu(id->CurAPMvalues); | ||
| 467 | id->mprc = __le16_to_cpu(id->mprc); | ||
| 468 | id->hw_config = __le16_to_cpu(id->hw_config); | ||
| 469 | id->acoustic = __le16_to_cpu(id->acoustic); | ||
| 470 | id->msrqs = __le16_to_cpu(id->msrqs); | ||
| 471 | id->sxfert = __le16_to_cpu(id->sxfert); | ||
| 472 | id->sal = __le16_to_cpu(id->sal); | ||
| 473 | id->spg = __le32_to_cpu(id->spg); | ||
| 474 | id->lba_capacity_2 = __le64_to_cpu(id->lba_capacity_2); | ||
| 475 | for (i = 0; i < 22; i++) | ||
| 476 | id->words104_125[i] = __le16_to_cpu(id->words104_125[i]); | ||
| 477 | id->last_lun = __le16_to_cpu(id->last_lun); | ||
| 478 | id->word127 = __le16_to_cpu(id->word127); | ||
| 479 | id->dlf = __le16_to_cpu(id->dlf); | ||
| 480 | id->csfo = __le16_to_cpu(id->csfo); | ||
| 481 | for (i = 0; i < 26; i++) | ||
| 482 | id->words130_155[i] = __le16_to_cpu(id->words130_155[i]); | ||
| 483 | id->word156 = __le16_to_cpu(id->word156); | ||
| 484 | for (i = 0; i < 3; i++) | ||
| 485 | id->words157_159[i] = __le16_to_cpu(id->words157_159[i]); | ||
| 486 | id->cfa_power = __le16_to_cpu(id->cfa_power); | ||
| 487 | for (i = 0; i < 15; i++) | ||
| 488 | id->words161_175[i] = __le16_to_cpu(id->words161_175[i]); | ||
| 489 | for (i = 0; i < 30; i++) | ||
| 490 | id->words176_205[i] = __le16_to_cpu(id->words176_205[i]); | ||
| 491 | for (i = 0; i < 49; i++) | ||
| 492 | id->words206_254[i] = __le16_to_cpu(id->words206_254[i]); | ||
| 493 | id->integrity_word = __le16_to_cpu(id->integrity_word); | ||
| 494 | # else | 410 | # else |
| 495 | # error "Please fix <asm/byteorder.h>" | 411 | # error "Please fix <asm/byteorder.h>" |
| 496 | # endif | 412 | # endif |
| @@ -501,19 +417,21 @@ void ide_fix_driveid (struct hd_driveid *id) | |||
| 501 | * ide_fixstring() cleans up and (optionally) byte-swaps a text string, | 417 | * ide_fixstring() cleans up and (optionally) byte-swaps a text string, |
| 502 | * removing leading/trailing blanks and compressing internal blanks. | 418 | * removing leading/trailing blanks and compressing internal blanks. |
| 503 | * It is primarily used to tidy up the model name/number fields as | 419 | * It is primarily used to tidy up the model name/number fields as |
| 504 | * returned by the WIN_[P]IDENTIFY commands. | 420 | * returned by the ATA_CMD_ID_ATA[PI] commands. |
| 505 | */ | 421 | */ |
| 506 | 422 | ||
| 507 | void ide_fixstring (u8 *s, const int bytecount, const int byteswap) | 423 | void ide_fixstring (u8 *s, const int bytecount, const int byteswap) |
| 508 | { | 424 | { |
| 509 | u8 *p = s, *end = &s[bytecount & ~1]; /* bytecount must be even */ | 425 | u8 *p, *end = &s[bytecount & ~1]; /* bytecount must be even */ |
| 510 | 426 | ||
| 511 | if (byteswap) { | 427 | if (byteswap) { |
| 512 | /* convert from big-endian to host byte order */ | 428 | /* convert from big-endian to host byte order */ |
| 513 | for (p = end ; p != s;) | 429 | for (p = s ; p != end ; p += 2) |
| 514 | be16_to_cpus((u16 *)(p -= 2)); | 430 | be16_to_cpus((u16 *) p); |
| 515 | } | 431 | } |
| 432 | |||
| 516 | /* strip leading blanks */ | 433 | /* strip leading blanks */ |
| 434 | p = s; | ||
| 517 | while (s != end && *s == ' ') | 435 | while (s != end && *s == ' ') |
| 518 | ++s; | 436 | ++s; |
| 519 | /* compress internal blanks and strip trailing blanks */ | 437 | /* compress internal blanks and strip trailing blanks */ |
| @@ -556,7 +474,7 @@ int drive_is_ready (ide_drive_t *drive) | |||
| 556 | /* Note: this may clear a pending IRQ!! */ | 474 | /* Note: this may clear a pending IRQ!! */ |
| 557 | stat = hwif->tp_ops->read_status(hwif); | 475 | stat = hwif->tp_ops->read_status(hwif); |
| 558 | 476 | ||
| 559 | if (stat & BUSY_STAT) | 477 | if (stat & ATA_BUSY) |
| 560 | /* drive busy: definitely not interrupting */ | 478 | /* drive busy: definitely not interrupting */ |
| 561 | return 0; | 479 | return 0; |
| 562 | 480 | ||
| @@ -588,10 +506,10 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti | |||
| 588 | udelay(1); /* spec allows drive 400ns to assert "BUSY" */ | 506 | udelay(1); /* spec allows drive 400ns to assert "BUSY" */ |
| 589 | stat = tp_ops->read_status(hwif); | 507 | stat = tp_ops->read_status(hwif); |
| 590 | 508 | ||
| 591 | if (stat & BUSY_STAT) { | 509 | if (stat & ATA_BUSY) { |
| 592 | local_irq_set(flags); | 510 | local_irq_set(flags); |
| 593 | timeout += jiffies; | 511 | timeout += jiffies; |
| 594 | while ((stat = tp_ops->read_status(hwif)) & BUSY_STAT) { | 512 | while ((stat = tp_ops->read_status(hwif)) & ATA_BUSY) { |
| 595 | if (time_after(jiffies, timeout)) { | 513 | if (time_after(jiffies, timeout)) { |
| 596 | /* | 514 | /* |
| 597 | * One last read after the timeout in case | 515 | * One last read after the timeout in case |
| @@ -599,7 +517,7 @@ static int __ide_wait_stat(ide_drive_t *drive, u8 good, u8 bad, unsigned long ti | |||
| 599 | * progress during the timeout.. | 517 | * progress during the timeout.. |
| 600 | */ | 518 | */ |
| 601 | stat = tp_ops->read_status(hwif); | 519 | stat = tp_ops->read_status(hwif); |
| 602 | if (!(stat & BUSY_STAT)) | 520 | if ((stat & ATA_BUSY) == 0) |
| 603 | break; | 521 | break; |
| 604 | 522 | ||
| 605 | local_irq_restore(flags); | 523 | local_irq_restore(flags); |
| @@ -660,18 +578,18 @@ EXPORT_SYMBOL(ide_wait_stat); | |||
| 660 | /** | 578 | /** |
| 661 | * ide_in_drive_list - look for drive in black/white list | 579 | * ide_in_drive_list - look for drive in black/white list |
| 662 | * @id: drive identifier | 580 | * @id: drive identifier |
| 663 | * @drive_table: list to inspect | 581 | * @table: list to inspect |
| 664 | * | 582 | * |
| 665 | * Look for a drive in the blacklist and the whitelist tables | 583 | * Look for a drive in the blacklist and the whitelist tables |
| 666 | * Returns 1 if the drive is found in the table. | 584 | * Returns 1 if the drive is found in the table. |
| 667 | */ | 585 | */ |
| 668 | 586 | ||
| 669 | int ide_in_drive_list(struct hd_driveid *id, const struct drive_list_entry *drive_table) | 587 | int ide_in_drive_list(u16 *id, const struct drive_list_entry *table) |
| 670 | { | 588 | { |
| 671 | for ( ; drive_table->id_model; drive_table++) | 589 | for ( ; table->id_model; table++) |
| 672 | if ((!strcmp(drive_table->id_model, id->model)) && | 590 | if ((!strcmp(table->id_model, (char *)&id[ATA_ID_PROD])) && |
| 673 | (!drive_table->id_firmware || | 591 | (!table->id_firmware || |
| 674 | strstr(id->fw_rev, drive_table->id_firmware))) | 592 | strstr((char *)&id[ATA_ID_FW_REV], table->id_firmware))) |
| 675 | return 1; | 593 | return 1; |
| 676 | return 0; | 594 | return 0; |
| 677 | } | 595 | } |
| @@ -702,7 +620,7 @@ static const struct drive_list_entry ivb_list[] = { | |||
| 702 | u8 eighty_ninty_three (ide_drive_t *drive) | 620 | u8 eighty_ninty_three (ide_drive_t *drive) |
| 703 | { | 621 | { |
| 704 | ide_hwif_t *hwif = drive->hwif; | 622 | ide_hwif_t *hwif = drive->hwif; |
| 705 | struct hd_driveid *id = drive->id; | 623 | u16 *id = drive->id; |
| 706 | int ivb = ide_in_drive_list(id, ivb_list); | 624 | int ivb = ide_in_drive_list(id, ivb_list); |
| 707 | 625 | ||
| 708 | if (hwif->cbl == ATA_CBL_PATA40_SHORT) | 626 | if (hwif->cbl == ATA_CBL_PATA40_SHORT) |
| @@ -712,7 +630,7 @@ u8 eighty_ninty_three (ide_drive_t *drive) | |||
| 712 | printk(KERN_DEBUG "%s: skipping word 93 validity check\n", | 630 | printk(KERN_DEBUG "%s: skipping word 93 validity check\n", |
| 713 | drive->name); | 631 | drive->name); |
| 714 | 632 | ||
| 715 | if (ide_dev_is_sata(id) && !ivb) | 633 | if (ata_id_is_sata(id) && !ivb) |
| 716 | return 1; | 634 | return 1; |
| 717 | 635 | ||
| 718 | if (hwif->cbl != ATA_CBL_PATA80 && !ivb) | 636 | if (hwif->cbl != ATA_CBL_PATA80 && !ivb) |
| @@ -724,7 +642,8 @@ u8 eighty_ninty_three (ide_drive_t *drive) | |||
| 724 | * - force bit13 (80c cable present) check also for !ivb devices | 642 | * - force bit13 (80c cable present) check also for !ivb devices |
| 725 | * (unless the slave device is pre-ATA3) | 643 | * (unless the slave device is pre-ATA3) |
| 726 | */ | 644 | */ |
| 727 | if ((id->hw_config & 0x4000) || (ivb && (id->hw_config & 0x2000))) | 645 | if ((id[ATA_ID_HW_CONFIG] & 0x4000) || |
| 646 | (ivb && (id[ATA_ID_HW_CONFIG] & 0x2000))) | ||
| 728 | return 1; | 647 | return 1; |
| 729 | 648 | ||
| 730 | no_80w: | 649 | no_80w: |
| @@ -745,8 +664,8 @@ int ide_driveid_update(ide_drive_t *drive) | |||
| 745 | { | 664 | { |
| 746 | ide_hwif_t *hwif = drive->hwif; | 665 | ide_hwif_t *hwif = drive->hwif; |
| 747 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 666 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
| 748 | struct hd_driveid *id; | 667 | u16 *id; |
| 749 | unsigned long timeout, flags; | 668 | unsigned long flags; |
| 750 | u8 stat; | 669 | u8 stat; |
| 751 | 670 | ||
| 752 | /* | 671 | /* |
| @@ -757,29 +676,24 @@ int ide_driveid_update(ide_drive_t *drive) | |||
| 757 | SELECT_MASK(drive, 1); | 676 | SELECT_MASK(drive, 1); |
| 758 | tp_ops->set_irq(hwif, 0); | 677 | tp_ops->set_irq(hwif, 0); |
| 759 | msleep(50); | 678 | msleep(50); |
| 760 | tp_ops->exec_command(hwif, WIN_IDENTIFY); | 679 | tp_ops->exec_command(hwif, ATA_CMD_ID_ATA); |
| 761 | timeout = jiffies + WAIT_WORSTCASE; | ||
| 762 | do { | ||
| 763 | if (time_after(jiffies, timeout)) { | ||
| 764 | SELECT_MASK(drive, 0); | ||
| 765 | return 0; /* drive timed-out */ | ||
| 766 | } | ||
| 767 | 680 | ||
| 768 | msleep(50); /* give drive a breather */ | 681 | if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 1)) { |
| 769 | stat = tp_ops->read_altstatus(hwif); | 682 | SELECT_MASK(drive, 0); |
| 770 | } while (stat & BUSY_STAT); | 683 | return 0; |
| 684 | } | ||
| 771 | 685 | ||
| 772 | msleep(50); /* wait for IRQ and DRQ_STAT */ | 686 | msleep(50); /* wait for IRQ and ATA_DRQ */ |
| 773 | stat = tp_ops->read_status(hwif); | 687 | stat = tp_ops->read_status(hwif); |
| 774 | 688 | ||
| 775 | if (!OK_STAT(stat, DRQ_STAT, BAD_R_STAT)) { | 689 | if (!OK_STAT(stat, ATA_DRQ, BAD_R_STAT)) { |
| 776 | SELECT_MASK(drive, 0); | 690 | SELECT_MASK(drive, 0); |
| 777 | printk("%s: CHECK for good STATUS\n", drive->name); | 691 | printk("%s: CHECK for good STATUS\n", drive->name); |
| 778 | return 0; | 692 | return 0; |
| 779 | } | 693 | } |
| 780 | local_irq_save(flags); | 694 | local_irq_save(flags); |
| 781 | SELECT_MASK(drive, 0); | 695 | SELECT_MASK(drive, 0); |
| 782 | id = kmalloc(SECTOR_WORDS*4, GFP_ATOMIC); | 696 | id = kmalloc(SECTOR_SIZE, GFP_ATOMIC); |
| 783 | if (!id) { | 697 | if (!id) { |
| 784 | local_irq_restore(flags); | 698 | local_irq_restore(flags); |
| 785 | return 0; | 699 | return 0; |
| @@ -789,16 +703,16 @@ int ide_driveid_update(ide_drive_t *drive) | |||
| 789 | local_irq_enable(); | 703 | local_irq_enable(); |
| 790 | local_irq_restore(flags); | 704 | local_irq_restore(flags); |
| 791 | ide_fix_driveid(id); | 705 | ide_fix_driveid(id); |
| 792 | if (id) { | 706 | |
| 793 | drive->id->dma_ultra = id->dma_ultra; | 707 | drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES]; |
| 794 | drive->id->dma_mword = id->dma_mword; | 708 | drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES]; |
| 795 | drive->id->dma_1word = id->dma_1word; | 709 | drive->id[ATA_ID_SWDMA_MODES] = id[ATA_ID_SWDMA_MODES]; |
| 796 | /* anything more ? */ | 710 | /* anything more ? */ |
| 797 | kfree(id); | 711 | |
| 798 | 712 | kfree(id); | |
| 799 | if (drive->using_dma && ide_id_dma_bug(drive)) | 713 | |
| 800 | ide_dma_off(drive); | 714 | if (drive->using_dma && ide_id_dma_bug(drive)) |
| 801 | } | 715 | ide_dma_off(drive); |
| 802 | 716 | ||
| 803 | return 1; | 717 | return 1; |
| 804 | } | 718 | } |
| @@ -807,6 +721,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
| 807 | { | 721 | { |
| 808 | ide_hwif_t *hwif = drive->hwif; | 722 | ide_hwif_t *hwif = drive->hwif; |
| 809 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 723 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
| 724 | u16 *id = drive->id, i; | ||
| 810 | int error = 0; | 725 | int error = 0; |
| 811 | u8 stat; | 726 | u8 stat; |
| 812 | ide_task_t task; | 727 | ide_task_t task; |
| @@ -817,7 +732,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
| 817 | #endif | 732 | #endif |
| 818 | 733 | ||
| 819 | /* Skip setting PIO flow-control modes on pre-EIDE drives */ | 734 | /* Skip setting PIO flow-control modes on pre-EIDE drives */ |
| 820 | if ((speed & 0xf8) == XFER_PIO_0 && !(drive->id->capability & 0x08)) | 735 | if ((speed & 0xf8) == XFER_PIO_0 && ata_id_has_iordy(drive->id) == 0) |
| 821 | goto skip; | 736 | goto skip; |
| 822 | 737 | ||
| 823 | /* | 738 | /* |
| @@ -851,13 +766,13 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
| 851 | 766 | ||
| 852 | tp_ops->tf_load(drive, &task); | 767 | tp_ops->tf_load(drive, &task); |
| 853 | 768 | ||
| 854 | tp_ops->exec_command(hwif, WIN_SETFEATURES); | 769 | tp_ops->exec_command(hwif, ATA_CMD_SET_FEATURES); |
| 855 | 770 | ||
| 856 | if (drive->quirk_list == 2) | 771 | if (drive->quirk_list == 2) |
| 857 | tp_ops->set_irq(hwif, 1); | 772 | tp_ops->set_irq(hwif, 1); |
| 858 | 773 | ||
| 859 | error = __ide_wait_stat(drive, drive->ready_stat, | 774 | error = __ide_wait_stat(drive, drive->ready_stat, |
| 860 | BUSY_STAT|DRQ_STAT|ERR_STAT, | 775 | ATA_BUSY | ATA_DRQ | ATA_ERR, |
| 861 | WAIT_CMD, &stat); | 776 | WAIT_CMD, &stat); |
| 862 | 777 | ||
| 863 | SELECT_MASK(drive, 0); | 778 | SELECT_MASK(drive, 0); |
| @@ -869,9 +784,9 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
| 869 | return error; | 784 | return error; |
| 870 | } | 785 | } |
| 871 | 786 | ||
| 872 | drive->id->dma_ultra &= ~0xFF00; | 787 | id[ATA_ID_UDMA_MODES] &= ~0xFF00; |
| 873 | drive->id->dma_mword &= ~0x0F00; | 788 | id[ATA_ID_MWDMA_MODES] &= ~0x0F00; |
| 874 | drive->id->dma_1word &= ~0x0F00; | 789 | id[ATA_ID_SWDMA_MODES] &= ~0x0F00; |
| 875 | 790 | ||
| 876 | skip: | 791 | skip: |
| 877 | #ifdef CONFIG_BLK_DEV_IDEDMA | 792 | #ifdef CONFIG_BLK_DEV_IDEDMA |
| @@ -881,23 +796,17 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed) | |||
| 881 | ide_dma_off_quietly(drive); | 796 | ide_dma_off_quietly(drive); |
| 882 | #endif | 797 | #endif |
| 883 | 798 | ||
| 884 | switch(speed) { | 799 | if (speed >= XFER_UDMA_0) { |
| 885 | case XFER_UDMA_7: drive->id->dma_ultra |= 0x8080; break; | 800 | i = 1 << (speed - XFER_UDMA_0); |
| 886 | case XFER_UDMA_6: drive->id->dma_ultra |= 0x4040; break; | 801 | id[ATA_ID_UDMA_MODES] |= (i << 8 | i); |
| 887 | case XFER_UDMA_5: drive->id->dma_ultra |= 0x2020; break; | 802 | } else if (speed >= XFER_MW_DMA_0) { |
| 888 | case XFER_UDMA_4: drive->id->dma_ultra |= 0x1010; break; | 803 | i = 1 << (speed - XFER_MW_DMA_0); |
| 889 | case XFER_UDMA_3: drive->id->dma_ultra |= 0x0808; break; | 804 | id[ATA_ID_MWDMA_MODES] |= (i << 8 | i); |
| 890 | case XFER_UDMA_2: drive->id->dma_ultra |= 0x0404; break; | 805 | } else if (speed >= XFER_SW_DMA_0) { |
| 891 | case XFER_UDMA_1: drive->id->dma_ultra |= 0x0202; break; | 806 | i = 1 << (speed - XFER_SW_DMA_0); |
| 892 | case XFER_UDMA_0: drive->id->dma_ultra |= 0x0101; break; | 807 | id[ATA_ID_SWDMA_MODES] |= (i << 8 | i); |
| 893 | case XFER_MW_DMA_2: drive->id->dma_mword |= 0x0404; break; | ||
| 894 | case XFER_MW_DMA_1: drive->id->dma_mword |= 0x0202; break; | ||
| 895 | case XFER_MW_DMA_0: drive->id->dma_mword |= 0x0101; break; | ||
| 896 | case XFER_SW_DMA_2: drive->id->dma_1word |= 0x0404; break; | ||
| 897 | case XFER_SW_DMA_1: drive->id->dma_1word |= 0x0202; break; | ||
| 898 | case XFER_SW_DMA_0: drive->id->dma_1word |= 0x0101; break; | ||
| 899 | default: break; | ||
| 900 | } | 808 | } |
| 809 | |||
| 901 | if (!drive->init_speed) | 810 | if (!drive->init_speed) |
| 902 | drive->init_speed = speed; | 811 | drive->init_speed = speed; |
| 903 | drive->current_speed = speed; | 812 | drive->current_speed = speed; |
| @@ -977,7 +886,7 @@ void ide_execute_pkt_cmd(ide_drive_t *drive) | |||
| 977 | unsigned long flags; | 886 | unsigned long flags; |
| 978 | 887 | ||
| 979 | spin_lock_irqsave(&ide_lock, flags); | 888 | spin_lock_irqsave(&ide_lock, flags); |
| 980 | hwif->tp_ops->exec_command(hwif, WIN_PACKETCMD); | 889 | hwif->tp_ops->exec_command(hwif, ATA_CMD_PACKET); |
| 981 | ndelay(400); | 890 | ndelay(400); |
| 982 | spin_unlock_irqrestore(&ide_lock, flags); | 891 | spin_unlock_irqrestore(&ide_lock, flags); |
| 983 | } | 892 | } |
| @@ -1010,7 +919,7 @@ static ide_startstop_t atapi_reset_pollfunc (ide_drive_t *drive) | |||
| 1010 | udelay (10); | 919 | udelay (10); |
| 1011 | stat = hwif->tp_ops->read_status(hwif); | 920 | stat = hwif->tp_ops->read_status(hwif); |
| 1012 | 921 | ||
| 1013 | if (OK_STAT(stat, 0, BUSY_STAT)) | 922 | if (OK_STAT(stat, 0, ATA_BUSY)) |
| 1014 | printk("%s: ATAPI reset complete\n", drive->name); | 923 | printk("%s: ATAPI reset complete\n", drive->name); |
| 1015 | else { | 924 | else { |
| 1016 | if (time_before(jiffies, hwgroup->poll_timeout)) { | 925 | if (time_before(jiffies, hwgroup->poll_timeout)) { |
| @@ -1056,7 +965,7 @@ static ide_startstop_t reset_pollfunc (ide_drive_t *drive) | |||
| 1056 | 965 | ||
| 1057 | tmp = hwif->tp_ops->read_status(hwif); | 966 | tmp = hwif->tp_ops->read_status(hwif); |
| 1058 | 967 | ||
| 1059 | if (!OK_STAT(tmp, 0, BUSY_STAT)) { | 968 | if (!OK_STAT(tmp, 0, ATA_BUSY)) { |
| 1060 | if (time_before(jiffies, hwgroup->poll_timeout)) { | 969 | if (time_before(jiffies, hwgroup->poll_timeout)) { |
| 1061 | ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); | 970 | ide_set_handler(drive, &reset_pollfunc, HZ/20, NULL); |
| 1062 | /* continue polling */ | 971 | /* continue polling */ |
| @@ -1102,7 +1011,7 @@ out: | |||
| 1102 | 1011 | ||
| 1103 | static void ide_disk_pre_reset(ide_drive_t *drive) | 1012 | static void ide_disk_pre_reset(ide_drive_t *drive) |
| 1104 | { | 1013 | { |
| 1105 | int legacy = (drive->id->cfs_enable_2 & 0x0400) ? 0 : 1; | 1014 | int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1; |
| 1106 | 1015 | ||
| 1107 | drive->special.all = 0; | 1016 | drive->special.all = 0; |
| 1108 | drive->special.b.set_geometry = legacy; | 1017 | drive->special.b.set_geometry = legacy; |
| @@ -1187,7 +1096,7 @@ static ide_startstop_t do_reset1 (ide_drive_t *drive, int do_not_try_atapi) | |||
| 1187 | pre_reset(drive); | 1096 | pre_reset(drive); |
| 1188 | SELECT_DRIVE(drive); | 1097 | SELECT_DRIVE(drive); |
| 1189 | udelay (20); | 1098 | udelay (20); |
| 1190 | tp_ops->exec_command(hwif, WIN_SRST); | 1099 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); |
| 1191 | ndelay(400); | 1100 | ndelay(400); |
| 1192 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; | 1101 | hwgroup->poll_timeout = jiffies + WAIT_WORSTCASE; |
| 1193 | hwgroup->polling = 1; | 1102 | hwgroup->polling = 1; |
| @@ -1270,7 +1179,7 @@ int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout) | |||
| 1270 | */ | 1179 | */ |
| 1271 | mdelay(1); | 1180 | mdelay(1); |
| 1272 | stat = hwif->tp_ops->read_status(hwif); | 1181 | stat = hwif->tp_ops->read_status(hwif); |
| 1273 | if ((stat & BUSY_STAT) == 0) | 1182 | if ((stat & ATA_BUSY) == 0) |
| 1274 | return 0; | 1183 | return 0; |
| 1275 | /* | 1184 | /* |
| 1276 | * Assume a value of 0xff means nothing is connected to | 1185 | * Assume a value of 0xff means nothing is connected to |
diff --git a/drivers/ide/ide-lib.c b/drivers/ide/ide-lib.c index 97fefabea8b8..ed426dd0fdd8 100644 --- a/drivers/ide/ide-lib.c +++ b/drivers/ide/ide-lib.c | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | #include <linux/string.h> | 2 | #include <linux/string.h> |
| 3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
| 4 | #include <linux/interrupt.h> | 4 | #include <linux/interrupt.h> |
| 5 | #include <linux/hdreg.h> | ||
| 6 | #include <linux/ide.h> | 5 | #include <linux/ide.h> |
| 7 | #include <linux/bitops.h> | 6 | #include <linux/bitops.h> |
| 8 | 7 | ||
| @@ -90,29 +89,31 @@ static u8 ide_rate_filter(ide_drive_t *drive, u8 speed) | |||
| 90 | 89 | ||
| 91 | u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode) | 90 | u8 ide_get_best_pio_mode (ide_drive_t *drive, u8 mode_wanted, u8 max_mode) |
| 92 | { | 91 | { |
| 93 | int pio_mode; | 92 | u16 *id = drive->id; |
| 94 | struct hd_driveid* id = drive->id; | 93 | int pio_mode = -1, overridden = 0; |
| 95 | int overridden = 0; | ||
| 96 | 94 | ||
| 97 | if (mode_wanted != 255) | 95 | if (mode_wanted != 255) |
| 98 | return min_t(u8, mode_wanted, max_mode); | 96 | return min_t(u8, mode_wanted, max_mode); |
| 99 | 97 | ||
| 100 | if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0 && | 98 | if ((drive->hwif->host_flags & IDE_HFLAG_PIO_NO_BLACKLIST) == 0) |
| 101 | (pio_mode = ide_scan_pio_blacklist(id->model)) != -1) { | 99 | pio_mode = ide_scan_pio_blacklist((char *)&id[ATA_ID_PROD]); |
| 100 | |||
| 101 | if (pio_mode != -1) { | ||
| 102 | printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name); | 102 | printk(KERN_INFO "%s: is on PIO blacklist\n", drive->name); |
| 103 | } else { | 103 | } else { |
| 104 | pio_mode = id->tPIO; | 104 | pio_mode = id[ATA_ID_OLD_PIO_MODES] >> 8; |
| 105 | if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */ | 105 | if (pio_mode > 2) { /* 2 is maximum allowed tPIO value */ |
| 106 | pio_mode = 2; | 106 | pio_mode = 2; |
| 107 | overridden = 1; | 107 | overridden = 1; |
| 108 | } | 108 | } |
| 109 | if (id->field_valid & 2) { /* drive implements ATA2? */ | 109 | |
| 110 | if (id->capability & 8) { /* IORDY supported? */ | 110 | if (id[ATA_ID_FIELD_VALID] & 2) { /* ATA2? */ |
| 111 | if (id->eide_pio_modes & 7) { | 111 | if (ata_id_has_iordy(id)) { |
| 112 | if (id[ATA_ID_PIO_MODES] & 7) { | ||
| 112 | overridden = 0; | 113 | overridden = 0; |
| 113 | if (id->eide_pio_modes & 4) | 114 | if (id[ATA_ID_PIO_MODES] & 4) |
| 114 | pio_mode = 5; | 115 | pio_mode = 5; |
| 115 | else if (id->eide_pio_modes & 2) | 116 | else if (id[ATA_ID_PIO_MODES] & 2) |
| 116 | pio_mode = 4; | 117 | pio_mode = 4; |
| 117 | else | 118 | else |
| 118 | pio_mode = 3; | 119 | pio_mode = 3; |
| @@ -338,16 +339,16 @@ static void ide_dump_sector(ide_drive_t *drive) | |||
| 338 | static void ide_dump_ata_error(ide_drive_t *drive, u8 err) | 339 | static void ide_dump_ata_error(ide_drive_t *drive, u8 err) |
| 339 | { | 340 | { |
| 340 | printk("{ "); | 341 | printk("{ "); |
| 341 | if (err & ABRT_ERR) printk("DriveStatusError "); | 342 | if (err & ATA_ABORTED) printk("DriveStatusError "); |
| 342 | if (err & ICRC_ERR) | 343 | if (err & ATA_ICRC) |
| 343 | printk((err & ABRT_ERR) ? "BadCRC " : "BadSector "); | 344 | printk((err & ATA_ABORTED) ? "BadCRC " : "BadSector "); |
| 344 | if (err & ECC_ERR) printk("UncorrectableError "); | 345 | if (err & ATA_UNC) printk("UncorrectableError "); |
| 345 | if (err & ID_ERR) printk("SectorIdNotFound "); | 346 | if (err & ATA_IDNF) printk("SectorIdNotFound "); |
| 346 | if (err & TRK0_ERR) printk("TrackZeroNotFound "); | 347 | if (err & ATA_TRK0NF) printk("TrackZeroNotFound "); |
| 347 | if (err & MARK_ERR) printk("AddrMarkNotFound "); | 348 | if (err & ATA_AMNF) printk("AddrMarkNotFound "); |
| 348 | printk("}"); | 349 | printk("}"); |
| 349 | if ((err & (BBD_ERR | ABRT_ERR)) == BBD_ERR || | 350 | if ((err & (ATA_BBK | ATA_ABORTED)) == ATA_BBK || |
| 350 | (err & (ECC_ERR|ID_ERR|MARK_ERR))) { | 351 | (err & (ATA_UNC | ATA_IDNF | ATA_AMNF))) { |
| 351 | ide_dump_sector(drive); | 352 | ide_dump_sector(drive); |
| 352 | if (HWGROUP(drive) && HWGROUP(drive)->rq) | 353 | if (HWGROUP(drive) && HWGROUP(drive)->rq) |
| 353 | printk(", sector=%llu", | 354 | printk(", sector=%llu", |
| @@ -359,12 +360,12 @@ static void ide_dump_ata_error(ide_drive_t *drive, u8 err) | |||
| 359 | static void ide_dump_atapi_error(ide_drive_t *drive, u8 err) | 360 | static void ide_dump_atapi_error(ide_drive_t *drive, u8 err) |
| 360 | { | 361 | { |
| 361 | printk("{ "); | 362 | printk("{ "); |
| 362 | if (err & ILI_ERR) printk("IllegalLengthIndication "); | 363 | if (err & ATAPI_ILI) printk("IllegalLengthIndication "); |
| 363 | if (err & EOM_ERR) printk("EndOfMedia "); | 364 | if (err & ATAPI_EOM) printk("EndOfMedia "); |
| 364 | if (err & ABRT_ERR) printk("AbortedCommand "); | 365 | if (err & ATA_ABORTED) printk("AbortedCommand "); |
| 365 | if (err & MCR_ERR) printk("MediaChangeRequested "); | 366 | if (err & ATA_MCR) printk("MediaChangeRequested "); |
| 366 | if (err & LFS_ERR) printk("LastFailedSense=0x%02x ", | 367 | if (err & ATAPI_LFS) printk("LastFailedSense=0x%02x ", |
| 367 | (err & LFS_ERR) >> 4); | 368 | (err & ATAPI_LFS) >> 4); |
| 368 | printk("}\n"); | 369 | printk("}\n"); |
| 369 | } | 370 | } |
| 370 | 371 | ||
| @@ -386,19 +387,19 @@ u8 ide_dump_status(ide_drive_t *drive, const char *msg, u8 stat) | |||
| 386 | 387 | ||
| 387 | local_irq_save(flags); | 388 | local_irq_save(flags); |
| 388 | printk("%s: %s: status=0x%02x { ", drive->name, msg, stat); | 389 | printk("%s: %s: status=0x%02x { ", drive->name, msg, stat); |
| 389 | if (stat & BUSY_STAT) | 390 | if (stat & ATA_BUSY) |
| 390 | printk("Busy "); | 391 | printk("Busy "); |
| 391 | else { | 392 | else { |
| 392 | if (stat & READY_STAT) printk("DriveReady "); | 393 | if (stat & ATA_DRDY) printk("DriveReady "); |
| 393 | if (stat & WRERR_STAT) printk("DeviceFault "); | 394 | if (stat & ATA_DF) printk("DeviceFault "); |
| 394 | if (stat & SEEK_STAT) printk("SeekComplete "); | 395 | if (stat & ATA_DSC) printk("SeekComplete "); |
| 395 | if (stat & DRQ_STAT) printk("DataRequest "); | 396 | if (stat & ATA_DRQ) printk("DataRequest "); |
| 396 | if (stat & ECC_STAT) printk("CorrectedError "); | 397 | if (stat & ATA_CORR) printk("CorrectedError "); |
| 397 | if (stat & INDEX_STAT) printk("Index "); | 398 | if (stat & ATA_IDX) printk("Index "); |
| 398 | if (stat & ERR_STAT) printk("Error "); | 399 | if (stat & ATA_ERR) printk("Error "); |
| 399 | } | 400 | } |
| 400 | printk("}\n"); | 401 | printk("}\n"); |
| 401 | if ((stat & (BUSY_STAT|ERR_STAT)) == ERR_STAT) { | 402 | if ((stat & (ATA_BUSY | ATA_ERR)) == ATA_ERR) { |
| 402 | err = ide_read_error(drive); | 403 | err = ide_read_error(drive); |
| 403 | printk("%s: %s: error=0x%02x ", drive->name, msg, err); | 404 | printk("%s: %s: error=0x%02x ", drive->name, msg, err); |
| 404 | if (drive->media == ide_disk) | 405 | if (drive->media == ide_disk) |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 70aa86c8807e..06575a12b635 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
| @@ -50,59 +50,54 @@ | |||
| 50 | 50 | ||
| 51 | static void generic_id(ide_drive_t *drive) | 51 | static void generic_id(ide_drive_t *drive) |
| 52 | { | 52 | { |
| 53 | drive->id->cyls = drive->cyl; | 53 | u16 *id = drive->id; |
| 54 | drive->id->heads = drive->head; | 54 | |
| 55 | drive->id->sectors = drive->sect; | 55 | id[ATA_ID_CUR_CYLS] = id[ATA_ID_CYLS] = drive->cyl; |
| 56 | drive->id->cur_cyls = drive->cyl; | 56 | id[ATA_ID_CUR_HEADS] = id[ATA_ID_HEADS] = drive->head; |
| 57 | drive->id->cur_heads = drive->head; | 57 | id[ATA_ID_CUR_SECTORS] = id[ATA_ID_SECTORS] = drive->sect; |
| 58 | drive->id->cur_sectors = drive->sect; | ||
| 59 | } | 58 | } |
| 60 | 59 | ||
| 61 | static void ide_disk_init_chs(ide_drive_t *drive) | 60 | static void ide_disk_init_chs(ide_drive_t *drive) |
| 62 | { | 61 | { |
| 63 | struct hd_driveid *id = drive->id; | 62 | u16 *id = drive->id; |
| 64 | 63 | ||
| 65 | /* Extract geometry if we did not already have one for the drive */ | 64 | /* Extract geometry if we did not already have one for the drive */ |
| 66 | if (!drive->cyl || !drive->head || !drive->sect) { | 65 | if (!drive->cyl || !drive->head || !drive->sect) { |
| 67 | drive->cyl = drive->bios_cyl = id->cyls; | 66 | drive->cyl = drive->bios_cyl = id[ATA_ID_CYLS]; |
| 68 | drive->head = drive->bios_head = id->heads; | 67 | drive->head = drive->bios_head = id[ATA_ID_HEADS]; |
| 69 | drive->sect = drive->bios_sect = id->sectors; | 68 | drive->sect = drive->bios_sect = id[ATA_ID_SECTORS]; |
| 70 | } | 69 | } |
| 71 | 70 | ||
| 72 | /* Handle logical geometry translation by the drive */ | 71 | /* Handle logical geometry translation by the drive */ |
| 73 | if ((id->field_valid & 1) && id->cur_cyls && | 72 | if (ata_id_current_chs_valid(id)) { |
| 74 | id->cur_heads && (id->cur_heads <= 16) && id->cur_sectors) { | 73 | drive->cyl = id[ATA_ID_CUR_CYLS]; |
| 75 | drive->cyl = id->cur_cyls; | 74 | drive->head = id[ATA_ID_CUR_HEADS]; |
| 76 | drive->head = id->cur_heads; | 75 | drive->sect = id[ATA_ID_CUR_SECTORS]; |
| 77 | drive->sect = id->cur_sectors; | ||
| 78 | } | 76 | } |
| 79 | 77 | ||
| 80 | /* Use physical geometry if what we have still makes no sense */ | 78 | /* Use physical geometry if what we have still makes no sense */ |
| 81 | if (drive->head > 16 && id->heads && id->heads <= 16) { | 79 | if (drive->head > 16 && id[ATA_ID_HEADS] && id[ATA_ID_HEADS] <= 16) { |
| 82 | drive->cyl = id->cyls; | 80 | drive->cyl = id[ATA_ID_CYLS]; |
| 83 | drive->head = id->heads; | 81 | drive->head = id[ATA_ID_HEADS]; |
| 84 | drive->sect = id->sectors; | 82 | drive->sect = id[ATA_ID_SECTORS]; |
| 85 | } | 83 | } |
| 86 | } | 84 | } |
| 87 | 85 | ||
| 88 | static void ide_disk_init_mult_count(ide_drive_t *drive) | 86 | static void ide_disk_init_mult_count(ide_drive_t *drive) |
| 89 | { | 87 | { |
| 90 | struct hd_driveid *id = drive->id; | 88 | u16 *id = drive->id; |
| 91 | 89 | u8 max_multsect = id[ATA_ID_MAX_MULTSECT] & 0xff; | |
| 92 | drive->mult_count = 0; | 90 | |
| 93 | if (id->max_multsect) { | 91 | if (max_multsect) { |
| 94 | #ifdef CONFIG_IDEDISK_MULTI_MODE | 92 | if ((max_multsect / 2) > 1) |
| 95 | id->multsect = ((id->max_multsect/2) > 1) ? id->max_multsect : 0; | 93 | id[ATA_ID_MULTSECT] = max_multsect | 0x100; |
| 96 | id->multsect_valid = id->multsect ? 1 : 0; | 94 | else |
| 97 | drive->mult_req = id->multsect_valid ? id->max_multsect : 0; | 95 | id[ATA_ID_MULTSECT] &= ~0x1ff; |
| 98 | drive->special.b.set_multmode = drive->mult_req ? 1 : 0; | 96 | |
| 99 | #else /* original, pre IDE-NFG, per request of AC */ | 97 | drive->mult_req = id[ATA_ID_MULTSECT] & 0xff; |
| 100 | drive->mult_req = 0; | 98 | |
| 101 | if (drive->mult_req > id->max_multsect) | 99 | if (drive->mult_req) |
| 102 | drive->mult_req = id->max_multsect; | ||
| 103 | if (drive->mult_req || ((id->multsect_valid & 1) && id->multsect)) | ||
| 104 | drive->special.b.set_multmode = 1; | 100 | drive->special.b.set_multmode = 1; |
| 105 | #endif | ||
| 106 | } | 101 | } |
| 107 | } | 102 | } |
| 108 | 103 | ||
| @@ -119,10 +114,10 @@ static void ide_disk_init_mult_count(ide_drive_t *drive) | |||
| 119 | static inline void do_identify (ide_drive_t *drive, u8 cmd) | 114 | static inline void do_identify (ide_drive_t *drive, u8 cmd) |
| 120 | { | 115 | { |
| 121 | ide_hwif_t *hwif = HWIF(drive); | 116 | ide_hwif_t *hwif = HWIF(drive); |
| 122 | int bswap = 1; | 117 | u16 *id = drive->id; |
| 123 | struct hd_driveid *id; | 118 | char *m = (char *)&id[ATA_ID_PROD]; |
| 119 | int bswap = 1, is_cfa; | ||
| 124 | 120 | ||
| 125 | id = drive->id; | ||
| 126 | /* read 512 bytes of id info */ | 121 | /* read 512 bytes of id info */ |
| 127 | hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); | 122 | hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); |
| 128 | 123 | ||
| @@ -135,27 +130,28 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
| 135 | ide_fix_driveid(id); | 130 | ide_fix_driveid(id); |
| 136 | 131 | ||
| 137 | /* | 132 | /* |
| 138 | * WIN_IDENTIFY returns little-endian info, | 133 | * ATA_CMD_ID_ATA returns little-endian info, |
| 139 | * WIN_PIDENTIFY *usually* returns little-endian info. | 134 | * ATA_CMD_ID_ATAPI *usually* returns little-endian info. |
| 140 | */ | 135 | */ |
| 141 | if (cmd == WIN_PIDENTIFY) { | 136 | if (cmd == ATA_CMD_ID_ATAPI) { |
| 142 | if ((id->model[0] == 'N' && id->model[1] == 'E') /* NEC */ | 137 | if ((m[0] == 'N' && m[1] == 'E') || /* NEC */ |
| 143 | || (id->model[0] == 'F' && id->model[1] == 'X') /* Mitsumi */ | 138 | (m[0] == 'F' && m[1] == 'X') || /* Mitsumi */ |
| 144 | || (id->model[0] == 'P' && id->model[1] == 'i'))/* Pioneer */ | 139 | (m[0] == 'P' && m[1] == 'i')) /* Pioneer */ |
| 145 | /* Vertos drives may still be weird */ | 140 | /* Vertos drives may still be weird */ |
| 146 | bswap ^= 1; | 141 | bswap ^= 1; |
| 147 | } | 142 | } |
| 148 | ide_fixstring(id->model, sizeof(id->model), bswap); | 143 | |
| 149 | ide_fixstring(id->fw_rev, sizeof(id->fw_rev), bswap); | 144 | ide_fixstring(m, ATA_ID_PROD_LEN, bswap); |
| 150 | ide_fixstring(id->serial_no, sizeof(id->serial_no), bswap); | 145 | ide_fixstring((char *)&id[ATA_ID_FW_REV], ATA_ID_FW_REV_LEN, bswap); |
| 146 | ide_fixstring((char *)&id[ATA_ID_SERNO], ATA_ID_SERNO_LEN, bswap); | ||
| 151 | 147 | ||
| 152 | /* we depend on this a lot! */ | 148 | /* we depend on this a lot! */ |
| 153 | id->model[sizeof(id->model)-1] = '\0'; | 149 | m[ATA_ID_PROD_LEN - 1] = '\0'; |
| 154 | 150 | ||
| 155 | if (strstr(id->model, "E X A B Y T E N E S T")) | 151 | if (strstr(m, "E X A B Y T E N E S T")) |
| 156 | goto err_misc; | 152 | goto err_misc; |
| 157 | 153 | ||
| 158 | printk(KERN_INFO "%s: %s, ", drive->name, id->model); | 154 | printk(KERN_INFO "%s: %s, ", drive->name, m); |
| 159 | 155 | ||
| 160 | drive->present = 1; | 156 | drive->present = 1; |
| 161 | drive->dead = 0; | 157 | drive->dead = 0; |
| @@ -163,16 +159,16 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
| 163 | /* | 159 | /* |
| 164 | * Check for an ATAPI device | 160 | * Check for an ATAPI device |
| 165 | */ | 161 | */ |
| 166 | if (cmd == WIN_PIDENTIFY) { | 162 | if (cmd == ATA_CMD_ID_ATAPI) { |
| 167 | u8 type = (id->config >> 8) & 0x1f; | 163 | u8 type = (id[ATA_ID_CONFIG] >> 8) & 0x1f; |
| 168 | 164 | ||
| 169 | printk(KERN_CONT "ATAPI "); | 165 | printk(KERN_CONT "ATAPI "); |
| 170 | switch (type) { | 166 | switch (type) { |
| 171 | case ide_floppy: | 167 | case ide_floppy: |
| 172 | if (!strstr(id->model, "CD-ROM")) { | 168 | if (!strstr(m, "CD-ROM")) { |
| 173 | if (!strstr(id->model, "oppy") && | 169 | if (!strstr(m, "oppy") && |
| 174 | !strstr(id->model, "poyp") && | 170 | !strstr(m, "poyp") && |
| 175 | !strstr(id->model, "ZIP")) | 171 | !strstr(m, "ZIP")) |
| 176 | printk(KERN_CONT "cdrom or floppy?, assuming "); | 172 | printk(KERN_CONT "cdrom or floppy?, assuming "); |
| 177 | if (drive->media != ide_cdrom) { | 173 | if (drive->media != ide_cdrom) { |
| 178 | printk(KERN_CONT "FLOPPY"); | 174 | printk(KERN_CONT "FLOPPY"); |
| @@ -186,8 +182,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
| 186 | drive->removable = 1; | 182 | drive->removable = 1; |
| 187 | #ifdef CONFIG_PPC | 183 | #ifdef CONFIG_PPC |
| 188 | /* kludge for Apple PowerBook internal zip */ | 184 | /* kludge for Apple PowerBook internal zip */ |
| 189 | if (!strstr(id->model, "CD-ROM") && | 185 | if (!strstr(m, "CD-ROM") && strstr(m, "ZIP")) { |
| 190 | strstr(id->model, "ZIP")) { | ||
| 191 | printk(KERN_CONT "FLOPPY"); | 186 | printk(KERN_CONT "FLOPPY"); |
| 192 | type = ide_floppy; | 187 | type = ide_floppy; |
| 193 | break; | 188 | break; |
| @@ -217,18 +212,15 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd) | |||
| 217 | * Not an ATAPI device: looks like a "regular" hard disk | 212 | * Not an ATAPI device: looks like a "regular" hard disk |
| 218 | */ | 213 | */ |
| 219 | 214 | ||
| 220 | /* | 215 | is_cfa = ata_id_is_cfa(id); |
| 221 | * 0x848a = CompactFlash device | ||
| 222 | * These are *not* removable in Linux definition of the term | ||
| 223 | */ | ||
| 224 | 216 | ||
| 225 | if ((id->config != 0x848a) && (id->config & (1<<7))) | 217 | /* CF devices are *not* removable in Linux definition of the term */ |
| 218 | if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7))) | ||
| 226 | drive->removable = 1; | 219 | drive->removable = 1; |
| 227 | 220 | ||
| 228 | drive->media = ide_disk; | 221 | drive->media = ide_disk; |
| 229 | 222 | ||
| 230 | printk(KERN_CONT "%s DISK drive\n", | 223 | printk(KERN_CONT "%s DISK drive\n", is_cfa ? "CFA" : "ATA"); |
| 231 | (id->config == 0x848a) ? "CFA" : "ATA"); | ||
| 232 | 224 | ||
| 233 | return; | 225 | return; |
| 234 | 226 | ||
| @@ -268,7 +260,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
| 268 | if (io_ports->ctl_addr) { | 260 | if (io_ports->ctl_addr) { |
| 269 | a = tp_ops->read_altstatus(hwif); | 261 | a = tp_ops->read_altstatus(hwif); |
| 270 | s = tp_ops->read_status(hwif); | 262 | s = tp_ops->read_status(hwif); |
| 271 | if ((a ^ s) & ~INDEX_STAT) | 263 | if ((a ^ s) & ~ATA_IDX) |
| 272 | /* ancient Seagate drives, broken interfaces */ | 264 | /* ancient Seagate drives, broken interfaces */ |
| 273 | printk(KERN_INFO "%s: probing with STATUS(0x%02x) " | 265 | printk(KERN_INFO "%s: probing with STATUS(0x%02x) " |
| 274 | "instead of ALTSTATUS(0x%02x)\n", | 266 | "instead of ALTSTATUS(0x%02x)\n", |
| @@ -281,7 +273,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
| 281 | /* set features register for atapi | 273 | /* set features register for atapi |
| 282 | * identify command to be sure of reply | 274 | * identify command to be sure of reply |
| 283 | */ | 275 | */ |
| 284 | if (cmd == WIN_PIDENTIFY) { | 276 | if (cmd == ATA_CMD_ID_ATAPI) { |
| 285 | ide_task_t task; | 277 | ide_task_t task; |
| 286 | 278 | ||
| 287 | memset(&task, 0, sizeof(task)); | 279 | memset(&task, 0, sizeof(task)); |
| @@ -294,24 +286,16 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd) | |||
| 294 | /* ask drive for ID */ | 286 | /* ask drive for ID */ |
| 295 | tp_ops->exec_command(hwif, cmd); | 287 | tp_ops->exec_command(hwif, cmd); |
| 296 | 288 | ||
| 297 | timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; | 289 | timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; |
| 298 | timeout += jiffies; | ||
| 299 | do { | ||
| 300 | if (time_after(jiffies, timeout)) { | ||
| 301 | /* drive timed-out */ | ||
| 302 | return 1; | ||
| 303 | } | ||
| 304 | /* give drive a breather */ | ||
| 305 | msleep(50); | ||
| 306 | s = use_altstatus ? tp_ops->read_altstatus(hwif) | ||
| 307 | : tp_ops->read_status(hwif); | ||
| 308 | } while (s & BUSY_STAT); | ||
| 309 | 290 | ||
| 310 | /* wait for IRQ and DRQ_STAT */ | 291 | if (ide_busy_sleep(hwif, timeout, use_altstatus)) |
| 292 | return 1; | ||
| 293 | |||
| 294 | /* wait for IRQ and ATA_DRQ */ | ||
| 311 | msleep(50); | 295 | msleep(50); |
| 312 | s = tp_ops->read_status(hwif); | 296 | s = tp_ops->read_status(hwif); |
| 313 | 297 | ||
| 314 | if (OK_STAT(s, DRQ_STAT, BAD_R_STAT)) { | 298 | if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) { |
| 315 | unsigned long flags; | 299 | unsigned long flags; |
| 316 | 300 | ||
| 317 | /* local CPU only; some systems need this */ | 301 | /* local CPU only; some systems need this */ |
| @@ -387,19 +371,21 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd) | |||
| 387 | return retval; | 371 | return retval; |
| 388 | } | 372 | } |
| 389 | 373 | ||
| 390 | static int ide_busy_sleep(ide_hwif_t *hwif) | 374 | int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus) |
| 391 | { | 375 | { |
| 392 | unsigned long timeout = jiffies + WAIT_WORSTCASE; | ||
| 393 | u8 stat; | 376 | u8 stat; |
| 394 | 377 | ||
| 378 | timeout += jiffies; | ||
| 379 | |||
| 395 | do { | 380 | do { |
| 396 | msleep(50); | 381 | msleep(50); /* give drive a breather */ |
| 397 | stat = hwif->tp_ops->read_status(hwif); | 382 | stat = altstatus ? hwif->tp_ops->read_altstatus(hwif) |
| 398 | if ((stat & BUSY_STAT) == 0) | 383 | : hwif->tp_ops->read_status(hwif); |
| 384 | if ((stat & ATA_BUSY) == 0) | ||
| 399 | return 0; | 385 | return 0; |
| 400 | } while (time_before(jiffies, timeout)); | 386 | } while (time_before(jiffies, timeout)); |
| 401 | 387 | ||
| 402 | return 1; | 388 | return 1; /* drive timed-out */ |
| 403 | } | 389 | } |
| 404 | 390 | ||
| 405 | static u8 ide_read_device(ide_drive_t *drive) | 391 | static u8 ide_read_device(ide_drive_t *drive) |
| @@ -444,13 +430,13 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
| 444 | 430 | ||
| 445 | if (drive->present) { | 431 | if (drive->present) { |
| 446 | /* avoid waiting for inappropriate probes */ | 432 | /* avoid waiting for inappropriate probes */ |
| 447 | if ((drive->media != ide_disk) && (cmd == WIN_IDENTIFY)) | 433 | if (drive->media != ide_disk && cmd == ATA_CMD_ID_ATA) |
| 448 | return 4; | 434 | return 4; |
| 449 | } | 435 | } |
| 450 | #ifdef DEBUG | 436 | #ifdef DEBUG |
| 451 | printk(KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n", | 437 | printk(KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n", |
| 452 | drive->name, drive->present, drive->media, | 438 | drive->name, drive->present, drive->media, |
| 453 | (cmd == WIN_IDENTIFY) ? "ATA" : "ATAPI"); | 439 | (cmd == ATA_CMD_ID_ATA) ? "ATA" : "ATAPI"); |
| 454 | #endif | 440 | #endif |
| 455 | 441 | ||
| 456 | /* needed for some systems | 442 | /* needed for some systems |
| @@ -464,7 +450,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
| 464 | if (drive->select.b.unit != 0) { | 450 | if (drive->select.b.unit != 0) { |
| 465 | /* exit with drive0 selected */ | 451 | /* exit with drive0 selected */ |
| 466 | SELECT_DRIVE(&hwif->drives[0]); | 452 | SELECT_DRIVE(&hwif->drives[0]); |
| 467 | /* allow BUSY_STAT to assert & clear */ | 453 | /* allow ATA_BUSY to assert & clear */ |
| 468 | msleep(50); | 454 | msleep(50); |
| 469 | } | 455 | } |
| 470 | /* no i/f present: mmm.. this should be a 4 -ml */ | 456 | /* no i/f present: mmm.. this should be a 4 -ml */ |
| @@ -473,8 +459,8 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
| 473 | 459 | ||
| 474 | stat = tp_ops->read_status(hwif); | 460 | stat = tp_ops->read_status(hwif); |
| 475 | 461 | ||
| 476 | if (OK_STAT(stat, READY_STAT, BUSY_STAT) || | 462 | if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || |
| 477 | drive->present || cmd == WIN_PIDENTIFY) { | 463 | drive->present || cmd == ATA_CMD_ID_ATAPI) { |
| 478 | /* send cmd and wait */ | 464 | /* send cmd and wait */ |
| 479 | if ((rc = try_to_identify(drive, cmd))) { | 465 | if ((rc = try_to_identify(drive, cmd))) { |
| 480 | /* failed: try again */ | 466 | /* failed: try again */ |
| @@ -483,17 +469,17 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
| 483 | 469 | ||
| 484 | stat = tp_ops->read_status(hwif); | 470 | stat = tp_ops->read_status(hwif); |
| 485 | 471 | ||
| 486 | if (stat == (BUSY_STAT | READY_STAT)) | 472 | if (stat == (ATA_BUSY | ATA_DRDY)) |
| 487 | return 4; | 473 | return 4; |
| 488 | 474 | ||
| 489 | if (rc == 1 && cmd == WIN_PIDENTIFY) { | 475 | if (rc == 1 && cmd == ATA_CMD_ID_ATAPI) { |
| 490 | printk(KERN_ERR "%s: no response (status = 0x%02x), " | 476 | printk(KERN_ERR "%s: no response (status = 0x%02x), " |
| 491 | "resetting drive\n", drive->name, stat); | 477 | "resetting drive\n", drive->name, stat); |
| 492 | msleep(50); | 478 | msleep(50); |
| 493 | SELECT_DRIVE(drive); | 479 | SELECT_DRIVE(drive); |
| 494 | msleep(50); | 480 | msleep(50); |
| 495 | tp_ops->exec_command(hwif, WIN_SRST); | 481 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); |
| 496 | (void)ide_busy_sleep(hwif); | 482 | (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0); |
| 497 | rc = try_to_identify(drive, cmd); | 483 | rc = try_to_identify(drive, cmd); |
| 498 | } | 484 | } |
| 499 | 485 | ||
| @@ -526,13 +512,14 @@ static void enable_nest (ide_drive_t *drive) | |||
| 526 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 512 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
| 527 | u8 stat; | 513 | u8 stat; |
| 528 | 514 | ||
| 529 | printk(KERN_INFO "%s: enabling %s -- ", hwif->name, drive->id->model); | 515 | printk(KERN_INFO "%s: enabling %s -- ", |
| 516 | hwif->name, (char *)&drive->id[ATA_ID_PROD]); | ||
| 530 | 517 | ||
| 531 | SELECT_DRIVE(drive); | 518 | SELECT_DRIVE(drive); |
| 532 | msleep(50); | 519 | msleep(50); |
| 533 | tp_ops->exec_command(hwif, EXABYTE_ENABLE_NEST); | 520 | tp_ops->exec_command(hwif, ATA_EXABYTE_ENABLE_NEST); |
| 534 | 521 | ||
| 535 | if (ide_busy_sleep(hwif)) { | 522 | if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 0)) { |
| 536 | printk(KERN_CONT "failed (timeout)\n"); | 523 | printk(KERN_CONT "failed (timeout)\n"); |
| 537 | return; | 524 | return; |
| 538 | } | 525 | } |
| @@ -545,12 +532,6 @@ static void enable_nest (ide_drive_t *drive) | |||
| 545 | printk(KERN_CONT "failed (status = 0x%02x)\n", stat); | 532 | printk(KERN_CONT "failed (status = 0x%02x)\n", stat); |
| 546 | else | 533 | else |
| 547 | printk(KERN_CONT "success\n"); | 534 | printk(KERN_CONT "success\n"); |
| 548 | |||
| 549 | /* if !(success||timed-out) */ | ||
| 550 | if (do_probe(drive, WIN_IDENTIFY) >= 2) { | ||
| 551 | /* look for ATAPI device */ | ||
| 552 | (void) do_probe(drive, WIN_PIDENTIFY); | ||
| 553 | } | ||
| 554 | } | 535 | } |
| 555 | 536 | ||
| 556 | /** | 537 | /** |
| @@ -567,6 +548,8 @@ static void enable_nest (ide_drive_t *drive) | |||
| 567 | 548 | ||
| 568 | static inline u8 probe_for_drive (ide_drive_t *drive) | 549 | static inline u8 probe_for_drive (ide_drive_t *drive) |
| 569 | { | 550 | { |
| 551 | char *m; | ||
| 552 | |||
| 570 | /* | 553 | /* |
| 571 | * In order to keep things simple we have an id | 554 | * In order to keep things simple we have an id |
| 572 | * block for all drives at all times. If the device | 555 | * block for all drives at all times. If the device |
| @@ -576,29 +559,34 @@ static inline u8 probe_for_drive (ide_drive_t *drive) | |||
| 576 | * Also note that 0 everywhere means "can't do X" | 559 | * Also note that 0 everywhere means "can't do X" |
| 577 | */ | 560 | */ |
| 578 | 561 | ||
| 579 | drive->id = kzalloc(SECTOR_WORDS *4, GFP_KERNEL); | 562 | drive->id = kzalloc(SECTOR_SIZE, GFP_KERNEL); |
| 580 | drive->id_read = 0; | 563 | drive->id_read = 0; |
| 581 | if(drive->id == NULL) | 564 | if(drive->id == NULL) |
| 582 | { | 565 | { |
| 583 | printk(KERN_ERR "ide: out of memory for id data.\n"); | 566 | printk(KERN_ERR "ide: out of memory for id data.\n"); |
| 584 | return 0; | 567 | return 0; |
| 585 | } | 568 | } |
| 586 | strcpy(drive->id->model, "UNKNOWN"); | 569 | |
| 587 | 570 | m = (char *)&drive->id[ATA_ID_PROD]; | |
| 571 | strcpy(m, "UNKNOWN"); | ||
| 572 | |||
| 588 | /* skip probing? */ | 573 | /* skip probing? */ |
| 589 | if (!drive->noprobe) | 574 | if (!drive->noprobe) { |
| 590 | { | 575 | retry: |
| 591 | /* if !(success||timed-out) */ | 576 | /* if !(success||timed-out) */ |
| 592 | if (do_probe(drive, WIN_IDENTIFY) >= 2) { | 577 | if (do_probe(drive, ATA_CMD_ID_ATA) >= 2) |
| 593 | /* look for ATAPI device */ | 578 | /* look for ATAPI device */ |
| 594 | (void) do_probe(drive, WIN_PIDENTIFY); | 579 | (void)do_probe(drive, ATA_CMD_ID_ATAPI); |
| 595 | } | 580 | |
| 596 | if (!drive->present) | 581 | if (!drive->present) |
| 597 | /* drive not found */ | 582 | /* drive not found */ |
| 598 | return 0; | 583 | return 0; |
| 599 | if (strstr(drive->id->model, "E X A B Y T E N E S T")) | 584 | |
| 585 | if (strstr(m, "E X A B Y T E N E S T")) { | ||
| 600 | enable_nest(drive); | 586 | enable_nest(drive); |
| 601 | 587 | goto retry; | |
| 588 | } | ||
| 589 | |||
| 602 | /* identification failed? */ | 590 | /* identification failed? */ |
| 603 | if (!drive->id_read) { | 591 | if (!drive->id_read) { |
| 604 | if (drive->media == ide_disk) { | 592 | if (drive->media == ide_disk) { |
| @@ -740,36 +728,38 @@ out: | |||
| 740 | 728 | ||
| 741 | /** | 729 | /** |
| 742 | * ide_undecoded_slave - look for bad CF adapters | 730 | * ide_undecoded_slave - look for bad CF adapters |
| 743 | * @drive1: drive | 731 | * @dev1: slave device |
| 744 | * | 732 | * |
| 745 | * Analyse the drives on the interface and attempt to decide if we | 733 | * Analyse the drives on the interface and attempt to decide if we |
| 746 | * have the same drive viewed twice. This occurs with crap CF adapters | 734 | * have the same drive viewed twice. This occurs with crap CF adapters |
| 747 | * and PCMCIA sometimes. | 735 | * and PCMCIA sometimes. |
| 748 | */ | 736 | */ |
| 749 | 737 | ||
| 750 | void ide_undecoded_slave(ide_drive_t *drive1) | 738 | void ide_undecoded_slave(ide_drive_t *dev1) |
| 751 | { | 739 | { |
| 752 | ide_drive_t *drive0 = &drive1->hwif->drives[0]; | 740 | ide_drive_t *dev0 = &dev1->hwif->drives[0]; |
| 753 | 741 | ||
| 754 | if ((drive1->dn & 1) == 0 || drive0->present == 0) | 742 | if ((dev1->dn & 1) == 0 || dev0->present == 0) |
| 755 | return; | 743 | return; |
| 756 | 744 | ||
| 757 | /* If the models don't match they are not the same product */ | 745 | /* If the models don't match they are not the same product */ |
| 758 | if (strcmp(drive0->id->model, drive1->id->model)) | 746 | if (strcmp((char *)&dev0->id[ATA_ID_PROD], |
| 747 | (char *)&dev1->id[ATA_ID_PROD])) | ||
| 759 | return; | 748 | return; |
| 760 | 749 | ||
| 761 | /* Serial numbers do not match */ | 750 | /* Serial numbers do not match */ |
| 762 | if (strncmp(drive0->id->serial_no, drive1->id->serial_no, 20)) | 751 | if (strncmp((char *)&dev0->id[ATA_ID_SERNO], |
| 752 | (char *)&dev1->id[ATA_ID_SERNO], ATA_ID_SERNO_LEN)) | ||
| 763 | return; | 753 | return; |
| 764 | 754 | ||
| 765 | /* No serial number, thankfully very rare for CF */ | 755 | /* No serial number, thankfully very rare for CF */ |
| 766 | if (drive0->id->serial_no[0] == 0) | 756 | if (*(char *)&dev0->id[ATA_ID_SERNO] == 0) |
| 767 | return; | 757 | return; |
| 768 | 758 | ||
| 769 | /* Appears to be an IDE flash adapter with decode bugs */ | 759 | /* Appears to be an IDE flash adapter with decode bugs */ |
| 770 | printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n"); | 760 | printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n"); |
| 771 | 761 | ||
| 772 | drive1->present = 0; | 762 | dev1->present = 0; |
| 773 | } | 763 | } |
| 774 | 764 | ||
| 775 | EXPORT_SYMBOL_GPL(ide_undecoded_slave); | 765 | EXPORT_SYMBOL_GPL(ide_undecoded_slave); |
| @@ -853,7 +843,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif) | |||
| 853 | if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) | 843 | if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) |
| 854 | drive->no_io_32bit = 1; | 844 | drive->no_io_32bit = 1; |
| 855 | else | 845 | else |
| 856 | drive->no_io_32bit = drive->id->dword_io ? 1 : 0; | 846 | drive->no_io_32bit = drive->id[ATA_ID_DWORD_IO] ? 1 : 0; |
| 857 | } | 847 | } |
| 858 | } | 848 | } |
| 859 | 849 | ||
| @@ -1037,11 +1027,6 @@ static int init_irq (ide_hwif_t *hwif) | |||
| 1037 | ide_hwgroup_t *hwgroup; | 1027 | ide_hwgroup_t *hwgroup; |
| 1038 | ide_hwif_t *match = NULL; | 1028 | ide_hwif_t *match = NULL; |
| 1039 | 1029 | ||
| 1040 | |||
| 1041 | BUG_ON(in_interrupt()); | ||
| 1042 | BUG_ON(irqs_disabled()); | ||
| 1043 | BUG_ON(hwif == NULL); | ||
| 1044 | |||
| 1045 | mutex_lock(&ide_cfg_mtx); | 1030 | mutex_lock(&ide_cfg_mtx); |
| 1046 | hwif->hwgroup = NULL; | 1031 | hwif->hwgroup = NULL; |
| 1047 | #if MAX_HWIFS > 1 | 1032 | #if MAX_HWIFS > 1 |
| @@ -1116,7 +1101,8 @@ static int init_irq (ide_hwif_t *hwif) | |||
| 1116 | sa = IRQF_SHARED; | 1101 | sa = IRQF_SHARED; |
| 1117 | #endif /* __mc68000__ */ | 1102 | #endif /* __mc68000__ */ |
| 1118 | 1103 | ||
| 1119 | if (IDE_CHIPSET_IS_PCI(hwif->chipset)) | 1104 | if (hwif->chipset == ide_pci || hwif->chipset == ide_cmd646 || |
| 1105 | hwif->chipset == ide_ali14xx) | ||
| 1120 | sa = IRQF_SHARED; | 1106 | sa = IRQF_SHARED; |
| 1121 | 1107 | ||
| 1122 | if (io_ports->ctl_addr) | 1108 | if (io_ports->ctl_addr) |
| @@ -1344,8 +1330,6 @@ static void hwif_register_devices(ide_hwif_t *hwif) | |||
| 1344 | if (!drive->present) | 1330 | if (!drive->present) |
| 1345 | continue; | 1331 | continue; |
| 1346 | 1332 | ||
| 1347 | ide_add_generic_settings(drive); | ||
| 1348 | |||
| 1349 | snprintf(dev->bus_id, BUS_ID_SIZE, "%u.%u", hwif->index, i); | 1333 | snprintf(dev->bus_id, BUS_ID_SIZE, "%u.%u", hwif->index, i); |
| 1350 | dev->parent = &hwif->gendev; | 1334 | dev->parent = &hwif->gendev; |
| 1351 | dev->bus = &ide_bus_type; | 1335 | dev->bus = &ide_bus_type; |
| @@ -1602,8 +1586,10 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *d, | |||
| 1602 | if (hws[0]) | 1586 | if (hws[0]) |
| 1603 | host->dev[0] = hws[0]->dev; | 1587 | host->dev[0] = hws[0]->dev; |
| 1604 | 1588 | ||
| 1605 | if (d) | 1589 | if (d) { |
| 1590 | host->init_chipset = d->init_chipset; | ||
| 1606 | host->host_flags = d->host_flags; | 1591 | host->host_flags = d->host_flags; |
| 1592 | } | ||
| 1607 | 1593 | ||
| 1608 | return host; | 1594 | return host; |
| 1609 | } | 1595 | } |
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c index f66c9c3f6fc6..e7030a491463 100644 --- a/drivers/ide/ide-proc.c +++ b/drivers/ide/ide-proc.c | |||
| @@ -12,14 +12,6 @@ | |||
| 12 | * "settings" files. e.g. "cat /proc/ide0/hda/settings" | 12 | * "settings" files. e.g. "cat /proc/ide0/hda/settings" |
| 13 | * To write a new value "val" into a specific setting "name", use: | 13 | * To write a new value "val" into a specific setting "name", use: |
| 14 | * echo "name:val" >/proc/ide/ide0/hda/settings | 14 | * echo "name:val" >/proc/ide/ide0/hda/settings |
| 15 | * | ||
| 16 | * Also useful, "cat /proc/ide0/hda/[identify, smart_values, | ||
| 17 | * smart_thresholds, capabilities]" will issue an IDENTIFY / | ||
| 18 | * PACKET_IDENTIFY / SMART_READ_VALUES / SMART_READ_THRESHOLDS / | ||
| 19 | * SENSE CAPABILITIES command to /dev/hda, and then dump out the | ||
| 20 | * returned data as 256 16-bit words. The "hdparm" utility will | ||
| 21 | * be updated someday soon to use this mechanism. | ||
| 22 | * | ||
| 23 | */ | 15 | */ |
| 24 | 16 | ||
| 25 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| @@ -31,7 +23,6 @@ | |||
| 31 | #include <linux/mm.h> | 23 | #include <linux/mm.h> |
| 32 | #include <linux/pci.h> | 24 | #include <linux/pci.h> |
| 33 | #include <linux/ctype.h> | 25 | #include <linux/ctype.h> |
| 34 | #include <linux/hdreg.h> | ||
| 35 | #include <linux/ide.h> | 26 | #include <linux/ide.h> |
| 36 | #include <linux/seq_file.h> | 27 | #include <linux/seq_file.h> |
| 37 | 28 | ||
| @@ -109,13 +100,14 @@ static int proc_ide_read_identify | |||
| 109 | 100 | ||
| 110 | err = taskfile_lib_get_identify(drive, page); | 101 | err = taskfile_lib_get_identify(drive, page); |
| 111 | if (!err) { | 102 | if (!err) { |
| 112 | char *out = ((char *)page) + (SECTOR_WORDS * 4); | 103 | char *out = (char *)page + SECTOR_SIZE; |
| 104 | |||
| 113 | page = out; | 105 | page = out; |
| 114 | do { | 106 | do { |
| 115 | out += sprintf(out, "%04x%c", | 107 | out += sprintf(out, "%04x%c", |
| 116 | le16_to_cpup(val), (++i & 7) ? ' ' : '\n'); | 108 | le16_to_cpup(val), (++i & 7) ? ' ' : '\n'); |
| 117 | val += 1; | 109 | val += 1; |
| 118 | } while (i < (SECTOR_WORDS * 2)); | 110 | } while (i < SECTOR_SIZE / 2); |
| 119 | len = out - page; | 111 | len = out - page; |
| 120 | } | 112 | } |
| 121 | } | 113 | } |
| @@ -123,140 +115,25 @@ static int proc_ide_read_identify | |||
| 123 | } | 115 | } |
| 124 | 116 | ||
| 125 | /** | 117 | /** |
| 126 | * __ide_add_setting - add an ide setting option | 118 | * ide_find_setting - find a specific setting |
| 127 | * @drive: drive to use | 119 | * @st: setting table pointer |
| 128 | * @name: setting name | ||
| 129 | * @rw: true if the function is read write | ||
| 130 | * @data_type: type of data | ||
| 131 | * @min: range minimum | ||
| 132 | * @max: range maximum | ||
| 133 | * @mul_factor: multiplication scale | ||
| 134 | * @div_factor: divison scale | ||
| 135 | * @data: private data field | ||
| 136 | * @set: setting | ||
| 137 | * @auto_remove: setting auto removal flag | ||
| 138 | * | ||
| 139 | * Removes the setting named from the device if it is present. | ||
| 140 | * The function takes the settings_lock to protect against | ||
| 141 | * parallel changes. This function must not be called from IRQ | ||
| 142 | * context. Returns 0 on success or -1 on failure. | ||
| 143 | * | ||
| 144 | * BUGS: This code is seriously over-engineered. There is also | ||
| 145 | * magic about how the driver specific features are setup. If | ||
| 146 | * a driver is attached we assume the driver settings are auto | ||
| 147 | * remove. | ||
| 148 | */ | ||
| 149 | |||
| 150 | static int __ide_add_setting(ide_drive_t *drive, const char *name, int rw, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set, int auto_remove) | ||
| 151 | { | ||
| 152 | ide_settings_t **p = (ide_settings_t **) &drive->settings, *setting = NULL; | ||
| 153 | |||
| 154 | mutex_lock(&ide_setting_mtx); | ||
| 155 | while ((*p) && strcmp((*p)->name, name) < 0) | ||
| 156 | p = &((*p)->next); | ||
| 157 | if ((setting = kzalloc(sizeof(*setting), GFP_KERNEL)) == NULL) | ||
| 158 | goto abort; | ||
| 159 | if ((setting->name = kmalloc(strlen(name) + 1, GFP_KERNEL)) == NULL) | ||
| 160 | goto abort; | ||
| 161 | strcpy(setting->name, name); | ||
| 162 | setting->rw = rw; | ||
| 163 | setting->data_type = data_type; | ||
| 164 | setting->min = min; | ||
| 165 | setting->max = max; | ||
| 166 | setting->mul_factor = mul_factor; | ||
| 167 | setting->div_factor = div_factor; | ||
| 168 | setting->data = data; | ||
| 169 | setting->set = set; | ||
| 170 | |||
| 171 | setting->next = *p; | ||
| 172 | if (auto_remove) | ||
| 173 | setting->auto_remove = 1; | ||
| 174 | *p = setting; | ||
| 175 | mutex_unlock(&ide_setting_mtx); | ||
| 176 | return 0; | ||
| 177 | abort: | ||
| 178 | mutex_unlock(&ide_setting_mtx); | ||
| 179 | kfree(setting); | ||
| 180 | return -1; | ||
| 181 | } | ||
| 182 | |||
| 183 | int ide_add_setting(ide_drive_t *drive, const char *name, int rw, int data_type, int min, int max, int mul_factor, int div_factor, void *data, ide_procset_t *set) | ||
| 184 | { | ||
| 185 | return __ide_add_setting(drive, name, rw, data_type, min, max, mul_factor, div_factor, data, set, 1); | ||
| 186 | } | ||
| 187 | |||
| 188 | EXPORT_SYMBOL(ide_add_setting); | ||
| 189 | |||
| 190 | /** | ||
| 191 | * __ide_remove_setting - remove an ide setting option | ||
| 192 | * @drive: drive to use | ||
| 193 | * @name: setting name | ||
| 194 | * | ||
| 195 | * Removes the setting named from the device if it is present. | ||
| 196 | * The caller must hold the setting semaphore. | ||
| 197 | */ | ||
| 198 | |||
| 199 | static void __ide_remove_setting(ide_drive_t *drive, char *name) | ||
| 200 | { | ||
| 201 | ide_settings_t **p, *setting; | ||
| 202 | |||
| 203 | p = (ide_settings_t **) &drive->settings; | ||
| 204 | |||
| 205 | while ((*p) && strcmp((*p)->name, name)) | ||
| 206 | p = &((*p)->next); | ||
| 207 | setting = (*p); | ||
| 208 | if (setting == NULL) | ||
| 209 | return; | ||
| 210 | |||
| 211 | (*p) = setting->next; | ||
| 212 | |||
| 213 | kfree(setting->name); | ||
| 214 | kfree(setting); | ||
| 215 | } | ||
| 216 | |||
| 217 | /** | ||
| 218 | * auto_remove_settings - remove driver specific settings | ||
| 219 | * @drive: drive | ||
| 220 | * | ||
| 221 | * Automatically remove all the driver specific settings for this | ||
| 222 | * drive. This function may not be called from IRQ context. The | ||
| 223 | * caller must hold ide_setting_mtx. | ||
| 224 | */ | ||
| 225 | |||
| 226 | static void auto_remove_settings(ide_drive_t *drive) | ||
| 227 | { | ||
| 228 | ide_settings_t *setting; | ||
| 229 | repeat: | ||
| 230 | setting = drive->settings; | ||
| 231 | while (setting) { | ||
| 232 | if (setting->auto_remove) { | ||
| 233 | __ide_remove_setting(drive, setting->name); | ||
| 234 | goto repeat; | ||
| 235 | } | ||
| 236 | setting = setting->next; | ||
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 240 | /** | ||
| 241 | * ide_find_setting_by_name - find a drive specific setting | ||
| 242 | * @drive: drive to scan | ||
| 243 | * @name: setting name | 120 | * @name: setting name |
| 244 | * | 121 | * |
| 245 | * Scan's the device setting table for a matching entry and returns | 122 | * Scan's the setting table for a matching entry and returns |
| 246 | * this or NULL if no entry is found. The caller must hold the | 123 | * this or NULL if no entry is found. The caller must hold the |
| 247 | * setting semaphore | 124 | * setting semaphore |
| 248 | */ | 125 | */ |
| 249 | 126 | ||
| 250 | static ide_settings_t *ide_find_setting_by_name(ide_drive_t *drive, char *name) | 127 | static |
| 128 | const struct ide_proc_devset *ide_find_setting(const struct ide_proc_devset *st, | ||
| 129 | char *name) | ||
| 251 | { | 130 | { |
| 252 | ide_settings_t *setting = drive->settings; | 131 | while (st->name) { |
| 253 | 132 | if (strcmp(st->name, name) == 0) | |
| 254 | while (setting) { | ||
| 255 | if (strcmp(setting->name, name) == 0) | ||
| 256 | break; | 133 | break; |
| 257 | setting = setting->next; | 134 | st++; |
| 258 | } | 135 | } |
| 259 | return setting; | 136 | return st->name ? st : NULL; |
| 260 | } | 137 | } |
| 261 | 138 | ||
| 262 | /** | 139 | /** |
| @@ -272,26 +149,20 @@ static ide_settings_t *ide_find_setting_by_name(ide_drive_t *drive, char *name) | |||
| 272 | * be told apart | 149 | * be told apart |
| 273 | */ | 150 | */ |
| 274 | 151 | ||
| 275 | static int ide_read_setting(ide_drive_t *drive, ide_settings_t *setting) | 152 | static int ide_read_setting(ide_drive_t *drive, |
| 153 | const struct ide_proc_devset *setting) | ||
| 276 | { | 154 | { |
| 277 | int val = -EINVAL; | 155 | const struct ide_devset *ds = setting->setting; |
| 278 | unsigned long flags; | 156 | int val = -EINVAL; |
| 157 | |||
| 158 | if (ds->get) { | ||
| 159 | unsigned long flags; | ||
| 279 | 160 | ||
| 280 | if ((setting->rw & SETTING_READ)) { | ||
| 281 | spin_lock_irqsave(&ide_lock, flags); | 161 | spin_lock_irqsave(&ide_lock, flags); |
| 282 | switch (setting->data_type) { | 162 | val = ds->get(drive); |
| 283 | case TYPE_BYTE: | ||
| 284 | val = *((u8 *) setting->data); | ||
| 285 | break; | ||
| 286 | case TYPE_SHORT: | ||
| 287 | val = *((u16 *) setting->data); | ||
| 288 | break; | ||
| 289 | case TYPE_INT: | ||
| 290 | val = *((u32 *) setting->data); | ||
| 291 | break; | ||
| 292 | } | ||
| 293 | spin_unlock_irqrestore(&ide_lock, flags); | 163 | spin_unlock_irqrestore(&ide_lock, flags); |
| 294 | } | 164 | } |
| 165 | |||
| 295 | return val; | 166 | return val; |
| 296 | } | 167 | } |
| 297 | 168 | ||
| @@ -313,33 +184,23 @@ static int ide_read_setting(ide_drive_t *drive, ide_settings_t *setting) | |||
| 313 | * The current scheme of polling is kludgy, though safe enough. | 184 | * The current scheme of polling is kludgy, though safe enough. |
| 314 | */ | 185 | */ |
| 315 | 186 | ||
| 316 | static int ide_write_setting(ide_drive_t *drive, ide_settings_t *setting, int val) | 187 | static int ide_write_setting(ide_drive_t *drive, |
| 188 | const struct ide_proc_devset *setting, int val) | ||
| 317 | { | 189 | { |
| 190 | const struct ide_devset *ds = setting->setting; | ||
| 191 | |||
| 318 | if (!capable(CAP_SYS_ADMIN)) | 192 | if (!capable(CAP_SYS_ADMIN)) |
| 319 | return -EACCES; | 193 | return -EACCES; |
| 320 | if (setting->set) | 194 | if (!ds->set) |
| 321 | return setting->set(drive, val); | ||
| 322 | if (!(setting->rw & SETTING_WRITE)) | ||
| 323 | return -EPERM; | 195 | return -EPERM; |
| 324 | if (val < setting->min || val > setting->max) | 196 | if ((ds->flags & DS_SYNC) |
| 197 | && (val < setting->min || val > setting->max)) | ||
| 325 | return -EINVAL; | 198 | return -EINVAL; |
| 326 | if (ide_spin_wait_hwgroup(drive)) | 199 | return ide_devset_execute(drive, ds, val); |
| 327 | return -EBUSY; | ||
| 328 | switch (setting->data_type) { | ||
| 329 | case TYPE_BYTE: | ||
| 330 | *((u8 *) setting->data) = val; | ||
| 331 | break; | ||
| 332 | case TYPE_SHORT: | ||
| 333 | *((u16 *) setting->data) = val; | ||
| 334 | break; | ||
| 335 | case TYPE_INT: | ||
| 336 | *((u32 *) setting->data) = val; | ||
| 337 | break; | ||
| 338 | } | ||
| 339 | spin_unlock_irq(&ide_lock); | ||
| 340 | return 0; | ||
| 341 | } | 200 | } |
| 342 | 201 | ||
| 202 | ide_devset_get(xfer_rate, current_speed); | ||
| 203 | |||
| 343 | static int set_xfer_rate (ide_drive_t *drive, int arg) | 204 | static int set_xfer_rate (ide_drive_t *drive, int arg) |
| 344 | { | 205 | { |
| 345 | ide_task_t task; | 206 | ide_task_t task; |
| @@ -349,7 +210,7 @@ static int set_xfer_rate (ide_drive_t *drive, int arg) | |||
| 349 | return -EINVAL; | 210 | return -EINVAL; |
| 350 | 211 | ||
| 351 | memset(&task, 0, sizeof(task)); | 212 | memset(&task, 0, sizeof(task)); |
| 352 | task.tf.command = WIN_SETFEATURES; | 213 | task.tf.command = ATA_CMD_SET_FEATURES; |
| 353 | task.tf.feature = SETFEATURES_XFER; | 214 | task.tf.feature = SETFEATURES_XFER; |
| 354 | task.tf.nsect = (u8)arg; | 215 | task.tf.nsect = (u8)arg; |
| 355 | task.tf_flags = IDE_TFLAG_OUT_FEATURE | IDE_TFLAG_OUT_NSECT | | 216 | task.tf_flags = IDE_TFLAG_OUT_FEATURE | IDE_TFLAG_OUT_NSECT | |
| @@ -364,29 +225,23 @@ static int set_xfer_rate (ide_drive_t *drive, int arg) | |||
| 364 | return err; | 225 | return err; |
| 365 | } | 226 | } |
| 366 | 227 | ||
| 367 | /** | 228 | ide_devset_rw(current_speed, xfer_rate); |
| 368 | * ide_add_generic_settings - generic ide settings | 229 | ide_devset_rw_field(init_speed, init_speed); |
| 369 | * @drive: drive being configured | 230 | ide_devset_rw_field(nice1, nice1); |
| 370 | * | 231 | ide_devset_rw_field(number, dn); |
| 371 | * Add the generic parts of the system settings to the /proc files. | 232 | |
| 372 | * The caller must not be holding the ide_setting_mtx. | 233 | static const struct ide_proc_devset ide_generic_settings[] = { |
| 373 | */ | 234 | IDE_PROC_DEVSET(current_speed, 0, 70), |
| 374 | 235 | IDE_PROC_DEVSET(init_speed, 0, 70), | |
| 375 | void ide_add_generic_settings (ide_drive_t *drive) | 236 | IDE_PROC_DEVSET(io_32bit, 0, 1 + (SUPPORT_VLB_SYNC << 1)), |
| 376 | { | 237 | IDE_PROC_DEVSET(keepsettings, 0, 1), |
| 377 | /* | 238 | IDE_PROC_DEVSET(nice1, 0, 1), |
| 378 | * drive setting name read/write access data type min max mul_factor div_factor data pointer set function | 239 | IDE_PROC_DEVSET(number, 0, 3), |
| 379 | */ | 240 | IDE_PROC_DEVSET(pio_mode, 0, 255), |
| 380 | __ide_add_setting(drive, "io_32bit", drive->no_io_32bit ? SETTING_READ : SETTING_RW, TYPE_BYTE, 0, 1 + (SUPPORT_VLB_SYNC << 1), 1, 1, &drive->io_32bit, set_io_32bit, 0); | 241 | IDE_PROC_DEVSET(unmaskirq, 0, 1), |
| 381 | __ide_add_setting(drive, "keepsettings", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->keep_settings, NULL, 0); | 242 | IDE_PROC_DEVSET(using_dma, 0, 1), |
| 382 | __ide_add_setting(drive, "nice1", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->nice1, NULL, 0); | 243 | { 0 }, |
| 383 | __ide_add_setting(drive, "pio_mode", SETTING_WRITE, TYPE_BYTE, 0, 255, 1, 1, NULL, set_pio_mode, 0); | 244 | }; |
| 384 | __ide_add_setting(drive, "unmaskirq", drive->no_unmask ? SETTING_READ : SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->unmask, NULL, 0); | ||
| 385 | __ide_add_setting(drive, "using_dma", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, &drive->using_dma, set_using_dma, 0); | ||
| 386 | __ide_add_setting(drive, "init_speed", SETTING_RW, TYPE_BYTE, 0, 70, 1, 1, &drive->init_speed, NULL, 0); | ||
| 387 | __ide_add_setting(drive, "current_speed", SETTING_RW, TYPE_BYTE, 0, 70, 1, 1, &drive->current_speed, set_xfer_rate, 0); | ||
| 388 | __ide_add_setting(drive, "number", SETTING_RW, TYPE_BYTE, 0, 3, 1, 1, &drive->dn, NULL, 0); | ||
| 389 | } | ||
| 390 | 245 | ||
| 391 | static void proc_ide_settings_warn(void) | 246 | static void proc_ide_settings_warn(void) |
| 392 | { | 247 | { |
| @@ -403,19 +258,32 @@ static void proc_ide_settings_warn(void) | |||
| 403 | static int proc_ide_read_settings | 258 | static int proc_ide_read_settings |
| 404 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 259 | (char *page, char **start, off_t off, int count, int *eof, void *data) |
| 405 | { | 260 | { |
| 261 | const struct ide_proc_devset *setting, *g, *d; | ||
| 262 | const struct ide_devset *ds; | ||
| 406 | ide_drive_t *drive = (ide_drive_t *) data; | 263 | ide_drive_t *drive = (ide_drive_t *) data; |
| 407 | ide_settings_t *setting = (ide_settings_t *) drive->settings; | ||
| 408 | char *out = page; | 264 | char *out = page; |
| 409 | int len, rc, mul_factor, div_factor; | 265 | int len, rc, mul_factor, div_factor; |
| 410 | 266 | ||
| 411 | proc_ide_settings_warn(); | 267 | proc_ide_settings_warn(); |
| 412 | 268 | ||
| 413 | mutex_lock(&ide_setting_mtx); | 269 | mutex_lock(&ide_setting_mtx); |
| 270 | g = ide_generic_settings; | ||
| 271 | d = drive->settings; | ||
| 414 | out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); | 272 | out += sprintf(out, "name\t\t\tvalue\t\tmin\t\tmax\t\tmode\n"); |
| 415 | out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n"); | 273 | out += sprintf(out, "----\t\t\t-----\t\t---\t\t---\t\t----\n"); |
| 416 | while (setting) { | 274 | while (g->name || (d && d->name)) { |
| 417 | mul_factor = setting->mul_factor; | 275 | /* read settings in the alphabetical order */ |
| 418 | div_factor = setting->div_factor; | 276 | if (g->name && d && d->name) { |
| 277 | if (strcmp(d->name, g->name) < 0) | ||
| 278 | setting = d++; | ||
| 279 | else | ||
| 280 | setting = g++; | ||
| 281 | } else if (d && d->name) { | ||
| 282 | setting = d++; | ||
| 283 | } else | ||
| 284 | setting = g++; | ||
| 285 | mul_factor = setting->mulf ? setting->mulf(drive) : 1; | ||
| 286 | div_factor = setting->divf ? setting->divf(drive) : 1; | ||
| 419 | out += sprintf(out, "%-24s", setting->name); | 287 | out += sprintf(out, "%-24s", setting->name); |
| 420 | rc = ide_read_setting(drive, setting); | 288 | rc = ide_read_setting(drive, setting); |
| 421 | if (rc >= 0) | 289 | if (rc >= 0) |
| @@ -423,12 +291,12 @@ static int proc_ide_read_settings | |||
| 423 | else | 291 | else |
| 424 | out += sprintf(out, "%-16s", "write-only"); | 292 | out += sprintf(out, "%-16s", "write-only"); |
| 425 | out += sprintf(out, "%-16d%-16d", (setting->min * mul_factor + div_factor - 1) / div_factor, setting->max * mul_factor / div_factor); | 293 | out += sprintf(out, "%-16d%-16d", (setting->min * mul_factor + div_factor - 1) / div_factor, setting->max * mul_factor / div_factor); |
| 426 | if (setting->rw & SETTING_READ) | 294 | ds = setting->setting; |
| 295 | if (ds->get) | ||
| 427 | out += sprintf(out, "r"); | 296 | out += sprintf(out, "r"); |
| 428 | if (setting->rw & SETTING_WRITE) | 297 | if (ds->set) |
| 429 | out += sprintf(out, "w"); | 298 | out += sprintf(out, "w"); |
| 430 | out += sprintf(out, "\n"); | 299 | out += sprintf(out, "\n"); |
| 431 | setting = setting->next; | ||
| 432 | } | 300 | } |
| 433 | len = out - page; | 301 | len = out - page; |
| 434 | mutex_unlock(&ide_setting_mtx); | 302 | mutex_unlock(&ide_setting_mtx); |
| @@ -442,9 +310,10 @@ static int proc_ide_write_settings(struct file *file, const char __user *buffer, | |||
| 442 | { | 310 | { |
| 443 | ide_drive_t *drive = (ide_drive_t *) data; | 311 | ide_drive_t *drive = (ide_drive_t *) data; |
| 444 | char name[MAX_LEN + 1]; | 312 | char name[MAX_LEN + 1]; |
| 445 | int for_real = 0; | 313 | int for_real = 0, mul_factor, div_factor; |
| 446 | unsigned long n; | 314 | unsigned long n; |
| 447 | ide_settings_t *setting; | 315 | |
| 316 | const struct ide_proc_devset *setting; | ||
| 448 | char *buf, *s; | 317 | char *buf, *s; |
| 449 | 318 | ||
| 450 | if (!capable(CAP_SYS_ADMIN)) | 319 | if (!capable(CAP_SYS_ADMIN)) |
| @@ -512,13 +381,21 @@ static int proc_ide_write_settings(struct file *file, const char __user *buffer, | |||
| 512 | } | 381 | } |
| 513 | 382 | ||
| 514 | mutex_lock(&ide_setting_mtx); | 383 | mutex_lock(&ide_setting_mtx); |
| 515 | setting = ide_find_setting_by_name(drive, name); | 384 | /* generic settings first, then driver specific ones */ |
| 385 | setting = ide_find_setting(ide_generic_settings, name); | ||
| 516 | if (!setting) { | 386 | if (!setting) { |
| 517 | mutex_unlock(&ide_setting_mtx); | 387 | if (drive->settings) |
| 518 | goto parse_error; | 388 | setting = ide_find_setting(drive->settings, name); |
| 389 | if (!setting) { | ||
| 390 | mutex_unlock(&ide_setting_mtx); | ||
| 391 | goto parse_error; | ||
| 392 | } | ||
| 393 | } | ||
| 394 | if (for_real) { | ||
| 395 | mul_factor = setting->mulf ? setting->mulf(drive) : 1; | ||
| 396 | div_factor = setting->divf ? setting->divf(drive) : 1; | ||
| 397 | ide_write_setting(drive, setting, val * div_factor / mul_factor); | ||
| 519 | } | 398 | } |
| 520 | if (for_real) | ||
| 521 | ide_write_setting(drive, setting, val * setting->div_factor / setting->mul_factor); | ||
| 522 | mutex_unlock(&ide_setting_mtx); | 399 | mutex_unlock(&ide_setting_mtx); |
| 523 | } | 400 | } |
| 524 | } while (!for_real++); | 401 | } while (!for_real++); |
| @@ -561,11 +438,10 @@ static int proc_ide_read_dmodel | |||
| 561 | (char *page, char **start, off_t off, int count, int *eof, void *data) | 438 | (char *page, char **start, off_t off, int count, int *eof, void *data) |
| 562 | { | 439 | { |
| 563 | ide_drive_t *drive = (ide_drive_t *) data; | 440 | ide_drive_t *drive = (ide_drive_t *) data; |
| 564 | struct hd_driveid *id = drive->id; | 441 | char *m = (char *)&drive->id[ATA_ID_PROD]; |
| 565 | int len; | 442 | int len; |
| 566 | 443 | ||
| 567 | len = sprintf(page, "%.40s\n", | 444 | len = sprintf(page, "%.40s\n", m[0] ? m : "(none)"); |
| 568 | (id && id->model[0]) ? (char *)id->model : "(none)"); | ||
| 569 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); | 445 | PROC_IDE_READ_RETURN(page, start, off, count, eof, len); |
| 570 | } | 446 | } |
| 571 | 447 | ||
| @@ -690,6 +566,10 @@ static void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t | |||
| 690 | 566 | ||
| 691 | void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) | 567 | void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) |
| 692 | { | 568 | { |
| 569 | mutex_lock(&ide_setting_mtx); | ||
| 570 | drive->settings = driver->settings; | ||
| 571 | mutex_unlock(&ide_setting_mtx); | ||
| 572 | |||
| 693 | ide_add_proc_entries(drive->proc, driver->proc, drive); | 573 | ide_add_proc_entries(drive->proc, driver->proc, drive); |
| 694 | } | 574 | } |
| 695 | 575 | ||
| @@ -726,7 +606,7 @@ void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) | |||
| 726 | * OTOH both ide_{read,write}_setting are only ever used under | 606 | * OTOH both ide_{read,write}_setting are only ever used under |
| 727 | * ide_setting_mtx. | 607 | * ide_setting_mtx. |
| 728 | */ | 608 | */ |
| 729 | auto_remove_settings(drive); | 609 | drive->settings = NULL; |
| 730 | spin_unlock_irqrestore(&ide_lock, flags); | 610 | spin_unlock_irqrestore(&ide_lock, flags); |
| 731 | mutex_unlock(&ide_setting_mtx); | 611 | mutex_unlock(&ide_setting_mtx); |
| 732 | } | 612 | } |
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 3833189144ed..f8c84df4a0bc 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | * Documentation/ide/ChangeLog.ide-tape.1995-2002 | 15 | * Documentation/ide/ChangeLog.ide-tape.1995-2002 |
| 16 | */ | 16 | */ |
| 17 | 17 | ||
| 18 | #define DRV_NAME "ide-tape" | ||
| 19 | |||
| 18 | #define IDETAPE_VERSION "1.20" | 20 | #define IDETAPE_VERSION "1.20" |
| 19 | 21 | ||
| 20 | #include <linux/module.h> | 22 | #include <linux/module.h> |
| @@ -54,8 +56,6 @@ enum { | |||
| 54 | DBG_CHRDEV = (1 << 2), | 56 | DBG_CHRDEV = (1 << 2), |
| 55 | /* all remaining procedures */ | 57 | /* all remaining procedures */ |
| 56 | DBG_PROCS = (1 << 3), | 58 | DBG_PROCS = (1 << 3), |
| 57 | /* buffer alloc info (pc_stack & rq_stack) */ | ||
| 58 | DBG_PCRQ_STACK = (1 << 4), | ||
| 59 | }; | 59 | }; |
| 60 | 60 | ||
| 61 | /* define to see debug info */ | 61 | /* define to see debug info */ |
| @@ -81,26 +81,6 @@ enum { | |||
| 81 | #define IDETAPE_MAX_PC_RETRIES 3 | 81 | #define IDETAPE_MAX_PC_RETRIES 3 |
| 82 | 82 | ||
| 83 | /* | 83 | /* |
| 84 | * With each packet command, we allocate a buffer of IDETAPE_PC_BUFFER_SIZE | ||
| 85 | * bytes. This is used for several packet commands (Not for READ/WRITE commands) | ||
| 86 | */ | ||
| 87 | #define IDETAPE_PC_BUFFER_SIZE 256 | ||
| 88 | |||
| 89 | /* | ||
| 90 | * In various places in the driver, we need to allocate storage | ||
| 91 | * for packet commands and requests, which will remain valid while | ||
| 92 | * we leave the driver to wait for an interrupt or a timeout event. | ||
| 93 | */ | ||
| 94 | #define IDETAPE_PC_STACK (10 + IDETAPE_MAX_PC_RETRIES) | ||
| 95 | |||
| 96 | /* | ||
| 97 | * Some drives (for example, Seagate STT3401A Travan) require a very long | ||
| 98 | * timeout, because they don't return an interrupt or clear their busy bit | ||
| 99 | * until after the command completes (even retension commands). | ||
| 100 | */ | ||
| 101 | #define IDETAPE_WAIT_CMD (900*HZ) | ||
| 102 | |||
| 103 | /* | ||
| 104 | * The following parameter is used to select the point in the internal tape fifo | 84 | * The following parameter is used to select the point in the internal tape fifo |
| 105 | * in which we will start to refill the buffer. Decreasing the following | 85 | * in which we will start to refill the buffer. Decreasing the following |
| 106 | * parameter will improve the system's latency and interactive response, while | 86 | * parameter will improve the system's latency and interactive response, while |
| @@ -172,20 +152,6 @@ struct idetape_bh { | |||
| 172 | #define IDETAPE_LU_RETENSION_MASK 2 | 152 | #define IDETAPE_LU_RETENSION_MASK 2 |
| 173 | #define IDETAPE_LU_EOT_MASK 4 | 153 | #define IDETAPE_LU_EOT_MASK 4 |
| 174 | 154 | ||
| 175 | /* | ||
| 176 | * Special requests for our block device strategy routine. | ||
| 177 | * | ||
| 178 | * In order to service a character device command, we add special requests to | ||
| 179 | * the tail of our block device request queue and wait for their completion. | ||
| 180 | */ | ||
| 181 | |||
| 182 | enum { | ||
| 183 | REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */ | ||
| 184 | REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */ | ||
| 185 | REQ_IDETAPE_READ = (1 << 2), | ||
| 186 | REQ_IDETAPE_WRITE = (1 << 3), | ||
| 187 | }; | ||
| 188 | |||
| 189 | /* Error codes returned in rq->errors to the higher part of the driver. */ | 155 | /* Error codes returned in rq->errors to the higher part of the driver. */ |
| 190 | #define IDETAPE_ERROR_GENERAL 101 | 156 | #define IDETAPE_ERROR_GENERAL 101 |
| 191 | #define IDETAPE_ERROR_FILEMARK 102 | 157 | #define IDETAPE_ERROR_FILEMARK 102 |
| @@ -206,13 +172,6 @@ typedef struct ide_tape_obj { | |||
| 206 | struct kref kref; | 172 | struct kref kref; |
| 207 | 173 | ||
| 208 | /* | 174 | /* |
| 209 | * Since a typical character device operation requires more | ||
| 210 | * than one packet command, we provide here enough memory | ||
| 211 | * for the maximum of interconnected packet commands. | ||
| 212 | * The packet commands are stored in the circular array pc_stack. | ||
| 213 | * pc_stack_index points to the last used entry, and warps around | ||
| 214 | * to the start when we get to the last array entry. | ||
| 215 | * | ||
| 216 | * pc points to the current processed packet command. | 175 | * pc points to the current processed packet command. |
| 217 | * | 176 | * |
| 218 | * failed_pc points to the last failed packet command, or contains | 177 | * failed_pc points to the last failed packet command, or contains |
| @@ -224,13 +183,11 @@ typedef struct ide_tape_obj { | |||
| 224 | struct ide_atapi_pc *pc; | 183 | struct ide_atapi_pc *pc; |
| 225 | /* Last failed packet command */ | 184 | /* Last failed packet command */ |
| 226 | struct ide_atapi_pc *failed_pc; | 185 | struct ide_atapi_pc *failed_pc; |
| 227 | /* Packet command stack */ | 186 | /* used by REQ_IDETAPE_{READ,WRITE} requests */ |
| 228 | struct ide_atapi_pc pc_stack[IDETAPE_PC_STACK]; | 187 | struct ide_atapi_pc queued_pc; |
| 229 | /* Next free packet command storage space */ | 188 | |
| 230 | int pc_stack_index; | 189 | struct ide_atapi_pc request_sense_pc; |
| 231 | struct request rq_stack[IDETAPE_PC_STACK]; | 190 | struct request request_sense_rq; |
| 232 | /* We implement a circular array */ | ||
| 233 | int rq_stack_index; | ||
| 234 | 191 | ||
| 235 | /* | 192 | /* |
| 236 | * DSC polling variables. | 193 | * DSC polling variables. |
| @@ -451,47 +408,6 @@ static void idetape_update_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc) | |||
| 451 | } | 408 | } |
| 452 | 409 | ||
| 453 | /* | 410 | /* |
| 454 | * idetape_next_pc_storage returns a pointer to a place in which we can | ||
| 455 | * safely store a packet command, even though we intend to leave the | ||
| 456 | * driver. A storage space for a maximum of IDETAPE_PC_STACK packet | ||
| 457 | * commands is allocated at initialization time. | ||
| 458 | */ | ||
| 459 | static struct ide_atapi_pc *idetape_next_pc_storage(ide_drive_t *drive) | ||
| 460 | { | ||
| 461 | idetape_tape_t *tape = drive->driver_data; | ||
| 462 | |||
| 463 | debug_log(DBG_PCRQ_STACK, "pc_stack_index=%d\n", tape->pc_stack_index); | ||
| 464 | |||
| 465 | if (tape->pc_stack_index == IDETAPE_PC_STACK) | ||
| 466 | tape->pc_stack_index = 0; | ||
| 467 | return (&tape->pc_stack[tape->pc_stack_index++]); | ||
| 468 | } | ||
| 469 | |||
| 470 | /* | ||
| 471 | * idetape_next_rq_storage is used along with idetape_next_pc_storage. | ||
| 472 | * Since we queue packet commands in the request queue, we need to | ||
| 473 | * allocate a request, along with the allocation of a packet command. | ||
| 474 | */ | ||
| 475 | |||
| 476 | /************************************************************** | ||
| 477 | * * | ||
| 478 | * This should get fixed to use kmalloc(.., GFP_ATOMIC) * | ||
| 479 | * followed later on by kfree(). -ml * | ||
| 480 | * * | ||
| 481 | **************************************************************/ | ||
| 482 | |||
| 483 | static struct request *idetape_next_rq_storage(ide_drive_t *drive) | ||
| 484 | { | ||
| 485 | idetape_tape_t *tape = drive->driver_data; | ||
| 486 | |||
| 487 | debug_log(DBG_PCRQ_STACK, "rq_stack_index=%d\n", tape->rq_stack_index); | ||
| 488 | |||
| 489 | if (tape->rq_stack_index == IDETAPE_PC_STACK) | ||
| 490 | tape->rq_stack_index = 0; | ||
| 491 | return (&tape->rq_stack[tape->rq_stack_index++]); | ||
| 492 | } | ||
| 493 | |||
| 494 | /* | ||
| 495 | * called on each failed packet command retry to analyze the request sense. We | 411 | * called on each failed packet command retry to analyze the request sense. We |
| 496 | * currently do not utilize this information. | 412 | * currently do not utilize this information. |
| 497 | */ | 413 | */ |
| @@ -667,61 +583,14 @@ static void ide_tape_callback(ide_drive_t *drive) | |||
| 667 | idetape_end_request(drive, uptodate, 0); | 583 | idetape_end_request(drive, uptodate, 0); |
| 668 | } | 584 | } |
| 669 | 585 | ||
| 670 | static void idetape_init_pc(struct ide_atapi_pc *pc) | ||
| 671 | { | ||
| 672 | memset(pc->c, 0, 12); | ||
| 673 | pc->retries = 0; | ||
| 674 | pc->flags = 0; | ||
| 675 | pc->req_xfer = 0; | ||
| 676 | pc->buf = pc->pc_buf; | ||
| 677 | pc->buf_size = IDETAPE_PC_BUFFER_SIZE; | ||
| 678 | pc->bh = NULL; | ||
| 679 | pc->b_data = NULL; | ||
| 680 | } | ||
| 681 | |||
| 682 | static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) | 586 | static void idetape_create_request_sense_cmd(struct ide_atapi_pc *pc) |
| 683 | { | 587 | { |
| 684 | idetape_init_pc(pc); | 588 | ide_init_pc(pc); |
| 685 | pc->c[0] = REQUEST_SENSE; | 589 | pc->c[0] = REQUEST_SENSE; |
| 686 | pc->c[4] = 20; | 590 | pc->c[4] = 20; |
| 687 | pc->req_xfer = 20; | 591 | pc->req_xfer = 20; |
| 688 | } | 592 | } |
| 689 | 593 | ||
| 690 | static void idetape_init_rq(struct request *rq, u8 cmd) | ||
| 691 | { | ||
| 692 | blk_rq_init(NULL, rq); | ||
| 693 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
| 694 | rq->cmd[13] = cmd; | ||
| 695 | } | ||
| 696 | |||
| 697 | /* | ||
| 698 | * Generate a new packet command request in front of the request queue, before | ||
| 699 | * the current request, so that it will be processed immediately, on the next | ||
| 700 | * pass through the driver. The function below is called from the request | ||
| 701 | * handling part of the driver (the "bottom" part). Safe storage for the request | ||
| 702 | * should be allocated with ide_tape_next_{pc,rq}_storage() prior to that. | ||
| 703 | * | ||
| 704 | * Memory for those requests is pre-allocated at initialization time, and is | ||
| 705 | * limited to IDETAPE_PC_STACK requests. We assume that we have enough space for | ||
| 706 | * the maximum possible number of inter-dependent packet commands. | ||
| 707 | * | ||
| 708 | * The higher level of the driver - The ioctl handler and the character device | ||
| 709 | * handling functions should queue request to the lower level part and wait for | ||
| 710 | * their completion using idetape_queue_pc_tail or idetape_queue_rw_tail. | ||
| 711 | */ | ||
| 712 | static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
| 713 | struct request *rq) | ||
| 714 | { | ||
| 715 | struct ide_tape_obj *tape = drive->driver_data; | ||
| 716 | |||
| 717 | idetape_init_rq(rq, REQ_IDETAPE_PC1); | ||
| 718 | rq->cmd_flags |= REQ_PREEMPT; | ||
| 719 | rq->buffer = (char *) pc; | ||
| 720 | rq->rq_disk = tape->disk; | ||
| 721 | memcpy(rq->cmd, pc->c, 12); | ||
| 722 | ide_do_drive_cmd(drive, rq); | ||
| 723 | } | ||
| 724 | |||
| 725 | /* | 594 | /* |
| 726 | * idetape_retry_pc is called when an error was detected during the | 595 | * idetape_retry_pc is called when an error was detected during the |
| 727 | * last packet command. We queue a request sense packet command in | 596 | * last packet command. We queue a request sense packet command in |
| @@ -729,15 +598,14 @@ static void idetape_queue_pc_head(ide_drive_t *drive, struct ide_atapi_pc *pc, | |||
| 729 | */ | 598 | */ |
| 730 | static void idetape_retry_pc(ide_drive_t *drive) | 599 | static void idetape_retry_pc(ide_drive_t *drive) |
| 731 | { | 600 | { |
| 732 | struct ide_atapi_pc *pc; | 601 | struct ide_tape_obj *tape = drive->driver_data; |
| 733 | struct request *rq; | 602 | struct request *rq = &tape->request_sense_rq; |
| 603 | struct ide_atapi_pc *pc = &tape->request_sense_pc; | ||
| 734 | 604 | ||
| 735 | (void)ide_read_error(drive); | 605 | (void)ide_read_error(drive); |
| 736 | pc = idetape_next_pc_storage(drive); | ||
| 737 | rq = idetape_next_rq_storage(drive); | ||
| 738 | idetape_create_request_sense_cmd(pc); | 606 | idetape_create_request_sense_cmd(pc); |
| 739 | set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); | 607 | set_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags); |
| 740 | idetape_queue_pc_head(drive, pc, rq); | 608 | ide_queue_pc_head(drive, tape->disk, pc, rq); |
| 741 | } | 609 | } |
| 742 | 610 | ||
| 743 | /* | 611 | /* |
| @@ -766,13 +634,15 @@ static void ide_tape_handle_dsc(ide_drive_t *drive) | |||
| 766 | idetape_postpone_request(drive); | 634 | idetape_postpone_request(drive); |
| 767 | } | 635 | } |
| 768 | 636 | ||
| 769 | static void ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | 637 | static int ide_tape_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, |
| 770 | unsigned int bcount, int write) | 638 | unsigned int bcount, int write) |
| 771 | { | 639 | { |
| 772 | if (write) | 640 | if (write) |
| 773 | idetape_output_buffers(drive, pc, bcount); | 641 | idetape_output_buffers(drive, pc, bcount); |
| 774 | else | 642 | else |
| 775 | idetape_input_buffers(drive, pc, bcount); | 643 | idetape_input_buffers(drive, pc, bcount); |
| 644 | |||
| 645 | return bcount; | ||
| 776 | } | 646 | } |
| 777 | 647 | ||
| 778 | /* | 648 | /* |
| @@ -786,7 +656,7 @@ static ide_startstop_t idetape_pc_intr(ide_drive_t *drive) | |||
| 786 | { | 656 | { |
| 787 | idetape_tape_t *tape = drive->driver_data; | 657 | idetape_tape_t *tape = drive->driver_data; |
| 788 | 658 | ||
| 789 | return ide_pc_intr(drive, tape->pc, idetape_pc_intr, IDETAPE_WAIT_CMD, | 659 | return ide_pc_intr(drive, tape->pc, idetape_pc_intr, WAIT_TAPE_CMD, |
| 790 | NULL, idetape_update_buffers, idetape_retry_pc, | 660 | NULL, idetape_update_buffers, idetape_retry_pc, |
| 791 | ide_tape_handle_dsc, ide_tape_io_buffers); | 661 | ide_tape_handle_dsc, ide_tape_io_buffers); |
| 792 | } | 662 | } |
| @@ -832,7 +702,7 @@ static ide_startstop_t idetape_transfer_pc(ide_drive_t *drive) | |||
| 832 | idetape_tape_t *tape = drive->driver_data; | 702 | idetape_tape_t *tape = drive->driver_data; |
| 833 | 703 | ||
| 834 | return ide_transfer_pc(drive, tape->pc, idetape_pc_intr, | 704 | return ide_transfer_pc(drive, tape->pc, idetape_pc_intr, |
| 835 | IDETAPE_WAIT_CMD, NULL); | 705 | WAIT_TAPE_CMD, NULL); |
| 836 | } | 706 | } |
| 837 | 707 | ||
| 838 | static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | 708 | static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, |
| @@ -881,13 +751,13 @@ static ide_startstop_t idetape_issue_pc(ide_drive_t *drive, | |||
| 881 | pc->retries++; | 751 | pc->retries++; |
| 882 | 752 | ||
| 883 | return ide_issue_pc(drive, pc, idetape_transfer_pc, | 753 | return ide_issue_pc(drive, pc, idetape_transfer_pc, |
| 884 | IDETAPE_WAIT_CMD, NULL); | 754 | WAIT_TAPE_CMD, NULL); |
| 885 | } | 755 | } |
| 886 | 756 | ||
| 887 | /* A mode sense command is used to "sense" tape parameters. */ | 757 | /* A mode sense command is used to "sense" tape parameters. */ |
| 888 | static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) | 758 | static void idetape_create_mode_sense_cmd(struct ide_atapi_pc *pc, u8 page_code) |
| 889 | { | 759 | { |
| 890 | idetape_init_pc(pc); | 760 | ide_init_pc(pc); |
| 891 | pc->c[0] = MODE_SENSE; | 761 | pc->c[0] = MODE_SENSE; |
| 892 | if (page_code != IDETAPE_BLOCK_DESCRIPTOR) | 762 | if (page_code != IDETAPE_BLOCK_DESCRIPTOR) |
| 893 | /* DBD = 1 - Don't return block descriptors */ | 763 | /* DBD = 1 - Don't return block descriptors */ |
| @@ -920,8 +790,8 @@ static ide_startstop_t idetape_media_access_finished(ide_drive_t *drive) | |||
| 920 | 790 | ||
| 921 | stat = hwif->tp_ops->read_status(hwif); | 791 | stat = hwif->tp_ops->read_status(hwif); |
| 922 | 792 | ||
| 923 | if (stat & SEEK_STAT) { | 793 | if (stat & ATA_DSC) { |
| 924 | if (stat & ERR_STAT) { | 794 | if (stat & ATA_ERR) { |
| 925 | /* Error detected */ | 795 | /* Error detected */ |
| 926 | if (pc->c[0] != TEST_UNIT_READY) | 796 | if (pc->c[0] != TEST_UNIT_READY) |
| 927 | printk(KERN_ERR "ide-tape: %s: I/O error, ", | 797 | printk(KERN_ERR "ide-tape: %s: I/O error, ", |
| @@ -946,7 +816,7 @@ static void ide_tape_create_rw_cmd(idetape_tape_t *tape, | |||
| 946 | struct idetape_bh *bh = (struct idetape_bh *)rq->special; | 816 | struct idetape_bh *bh = (struct idetape_bh *)rq->special; |
| 947 | unsigned int length = rq->current_nr_sectors; | 817 | unsigned int length = rq->current_nr_sectors; |
| 948 | 818 | ||
| 949 | idetape_init_pc(pc); | 819 | ide_init_pc(pc); |
| 950 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); | 820 | put_unaligned(cpu_to_be32(length), (unsigned int *) &pc->c[1]); |
| 951 | pc->c[1] = 1; | 821 | pc->c[1] = 1; |
| 952 | pc->bh = bh; | 822 | pc->bh = bh; |
| @@ -978,9 +848,10 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
| 978 | struct request *postponed_rq = tape->postponed_rq; | 848 | struct request *postponed_rq = tape->postponed_rq; |
| 979 | u8 stat; | 849 | u8 stat; |
| 980 | 850 | ||
| 981 | debug_log(DBG_SENSE, "sector: %ld, nr_sectors: %ld," | 851 | debug_log(DBG_SENSE, "sector: %llu, nr_sectors: %lu," |
| 982 | " current_nr_sectors: %d\n", | 852 | " current_nr_sectors: %u\n", |
| 983 | rq->sector, rq->nr_sectors, rq->current_nr_sectors); | 853 | (unsigned long long)rq->sector, rq->nr_sectors, |
| 854 | rq->current_nr_sectors); | ||
| 984 | 855 | ||
| 985 | if (!blk_special_request(rq)) { | 856 | if (!blk_special_request(rq)) { |
| 986 | /* We do not support buffer cache originated requests. */ | 857 | /* We do not support buffer cache originated requests. */ |
| @@ -1021,7 +892,7 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
| 1021 | } | 892 | } |
| 1022 | 893 | ||
| 1023 | if (!test_and_clear_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags) && | 894 | if (!test_and_clear_bit(IDE_AFLAG_IGNORE_DSC, &drive->atapi_flags) && |
| 1024 | (stat & SEEK_STAT) == 0) { | 895 | (stat & ATA_DSC) == 0) { |
| 1025 | if (postponed_rq == NULL) { | 896 | if (postponed_rq == NULL) { |
| 1026 | tape->dsc_polling_start = jiffies; | 897 | tape->dsc_polling_start = jiffies; |
| 1027 | tape->dsc_poll_freq = tape->best_dsc_rw_freq; | 898 | tape->dsc_poll_freq = tape->best_dsc_rw_freq; |
| @@ -1043,12 +914,12 @@ static ide_startstop_t idetape_do_request(ide_drive_t *drive, | |||
| 1043 | return ide_stopped; | 914 | return ide_stopped; |
| 1044 | } | 915 | } |
| 1045 | if (rq->cmd[13] & REQ_IDETAPE_READ) { | 916 | if (rq->cmd[13] & REQ_IDETAPE_READ) { |
| 1046 | pc = idetape_next_pc_storage(drive); | 917 | pc = &tape->queued_pc; |
| 1047 | ide_tape_create_rw_cmd(tape, pc, rq, READ_6); | 918 | ide_tape_create_rw_cmd(tape, pc, rq, READ_6); |
| 1048 | goto out; | 919 | goto out; |
| 1049 | } | 920 | } |
| 1050 | if (rq->cmd[13] & REQ_IDETAPE_WRITE) { | 921 | if (rq->cmd[13] & REQ_IDETAPE_WRITE) { |
| 1051 | pc = idetape_next_pc_storage(drive); | 922 | pc = &tape->queued_pc; |
| 1052 | ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6); | 923 | ide_tape_create_rw_cmd(tape, pc, rq, WRITE_6); |
| 1053 | goto out; | 924 | goto out; |
| 1054 | } | 925 | } |
| @@ -1235,77 +1106,30 @@ static void idetape_init_merge_buffer(idetape_tape_t *tape) | |||
| 1235 | static void idetape_create_write_filemark_cmd(ide_drive_t *drive, | 1106 | static void idetape_create_write_filemark_cmd(ide_drive_t *drive, |
| 1236 | struct ide_atapi_pc *pc, int write_filemark) | 1107 | struct ide_atapi_pc *pc, int write_filemark) |
| 1237 | { | 1108 | { |
| 1238 | idetape_init_pc(pc); | 1109 | ide_init_pc(pc); |
| 1239 | pc->c[0] = WRITE_FILEMARKS; | 1110 | pc->c[0] = WRITE_FILEMARKS; |
| 1240 | pc->c[4] = write_filemark; | 1111 | pc->c[4] = write_filemark; |
| 1241 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1112 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
| 1242 | } | 1113 | } |
| 1243 | 1114 | ||
| 1244 | static void idetape_create_test_unit_ready_cmd(struct ide_atapi_pc *pc) | ||
| 1245 | { | ||
| 1246 | idetape_init_pc(pc); | ||
| 1247 | pc->c[0] = TEST_UNIT_READY; | ||
| 1248 | } | ||
| 1249 | |||
| 1250 | /* | ||
| 1251 | * We add a special packet command request to the tail of the request queue, and | ||
| 1252 | * wait for it to be serviced. This is not to be called from within the request | ||
| 1253 | * handling part of the driver! We allocate here data on the stack and it is | ||
| 1254 | * valid until the request is finished. This is not the case for the bottom part | ||
| 1255 | * of the driver, where we are always leaving the functions to wait for an | ||
| 1256 | * interrupt or a timer event. | ||
| 1257 | * | ||
| 1258 | * From the bottom part of the driver, we should allocate safe memory using | ||
| 1259 | * idetape_next_pc_storage() and ide_tape_next_rq_storage(), and add the request | ||
| 1260 | * to the request list without waiting for it to be serviced! In that case, we | ||
| 1261 | * usually use idetape_queue_pc_head(). | ||
| 1262 | */ | ||
| 1263 | static int idetape_queue_pc_tail(ide_drive_t *drive, struct ide_atapi_pc *pc) | ||
| 1264 | { | ||
| 1265 | struct ide_tape_obj *tape = drive->driver_data; | ||
| 1266 | struct request *rq; | ||
| 1267 | int error; | ||
| 1268 | |||
| 1269 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | ||
| 1270 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
| 1271 | rq->cmd[13] = REQ_IDETAPE_PC1; | ||
| 1272 | rq->buffer = (char *)pc; | ||
| 1273 | memcpy(rq->cmd, pc->c, 12); | ||
| 1274 | error = blk_execute_rq(drive->queue, tape->disk, rq, 0); | ||
| 1275 | blk_put_request(rq); | ||
| 1276 | return error; | ||
| 1277 | } | ||
| 1278 | |||
| 1279 | static void idetape_create_load_unload_cmd(ide_drive_t *drive, | ||
| 1280 | struct ide_atapi_pc *pc, int cmd) | ||
| 1281 | { | ||
| 1282 | idetape_init_pc(pc); | ||
| 1283 | pc->c[0] = START_STOP; | ||
| 1284 | pc->c[4] = cmd; | ||
| 1285 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | ||
| 1286 | } | ||
| 1287 | |||
| 1288 | static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | 1115 | static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) |
| 1289 | { | 1116 | { |
| 1290 | idetape_tape_t *tape = drive->driver_data; | 1117 | idetape_tape_t *tape = drive->driver_data; |
| 1291 | struct ide_atapi_pc pc; | 1118 | struct gendisk *disk = tape->disk; |
| 1292 | int load_attempted = 0; | 1119 | int load_attempted = 0; |
| 1293 | 1120 | ||
| 1294 | /* Wait for the tape to become ready */ | 1121 | /* Wait for the tape to become ready */ |
| 1295 | set_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); | 1122 | set_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); |
| 1296 | timeout += jiffies; | 1123 | timeout += jiffies; |
| 1297 | while (time_before(jiffies, timeout)) { | 1124 | while (time_before(jiffies, timeout)) { |
| 1298 | idetape_create_test_unit_ready_cmd(&pc); | 1125 | if (ide_do_test_unit_ready(drive, disk) == 0) |
| 1299 | if (!idetape_queue_pc_tail(drive, &pc)) | ||
| 1300 | return 0; | 1126 | return 0; |
| 1301 | if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) | 1127 | if ((tape->sense_key == 2 && tape->asc == 4 && tape->ascq == 2) |
| 1302 | || (tape->asc == 0x3A)) { | 1128 | || (tape->asc == 0x3A)) { |
| 1303 | /* no media */ | 1129 | /* no media */ |
| 1304 | if (load_attempted) | 1130 | if (load_attempted) |
| 1305 | return -ENOMEDIUM; | 1131 | return -ENOMEDIUM; |
| 1306 | idetape_create_load_unload_cmd(drive, &pc, | 1132 | ide_do_start_stop(drive, disk, IDETAPE_LU_LOAD_MASK); |
| 1307 | IDETAPE_LU_LOAD_MASK); | ||
| 1308 | idetape_queue_pc_tail(drive, &pc); | ||
| 1309 | load_attempted = 1; | 1133 | load_attempted = 1; |
| 1310 | /* not about to be ready */ | 1134 | /* not about to be ready */ |
| 1311 | } else if (!(tape->sense_key == 2 && tape->asc == 4 && | 1135 | } else if (!(tape->sense_key == 2 && tape->asc == 4 && |
| @@ -1318,11 +1142,12 @@ static int idetape_wait_ready(ide_drive_t *drive, unsigned long timeout) | |||
| 1318 | 1142 | ||
| 1319 | static int idetape_flush_tape_buffers(ide_drive_t *drive) | 1143 | static int idetape_flush_tape_buffers(ide_drive_t *drive) |
| 1320 | { | 1144 | { |
| 1145 | struct ide_tape_obj *tape = drive->driver_data; | ||
| 1321 | struct ide_atapi_pc pc; | 1146 | struct ide_atapi_pc pc; |
| 1322 | int rc; | 1147 | int rc; |
| 1323 | 1148 | ||
| 1324 | idetape_create_write_filemark_cmd(drive, &pc, 0); | 1149 | idetape_create_write_filemark_cmd(drive, &pc, 0); |
| 1325 | rc = idetape_queue_pc_tail(drive, &pc); | 1150 | rc = ide_queue_pc_tail(drive, tape->disk, &pc); |
| 1326 | if (rc) | 1151 | if (rc) |
| 1327 | return rc; | 1152 | return rc; |
| 1328 | idetape_wait_ready(drive, 60 * 5 * HZ); | 1153 | idetape_wait_ready(drive, 60 * 5 * HZ); |
| @@ -1331,7 +1156,7 @@ static int idetape_flush_tape_buffers(ide_drive_t *drive) | |||
| 1331 | 1156 | ||
| 1332 | static void idetape_create_read_position_cmd(struct ide_atapi_pc *pc) | 1157 | static void idetape_create_read_position_cmd(struct ide_atapi_pc *pc) |
| 1333 | { | 1158 | { |
| 1334 | idetape_init_pc(pc); | 1159 | ide_init_pc(pc); |
| 1335 | pc->c[0] = READ_POSITION; | 1160 | pc->c[0] = READ_POSITION; |
| 1336 | pc->req_xfer = 20; | 1161 | pc->req_xfer = 20; |
| 1337 | } | 1162 | } |
| @@ -1345,7 +1170,7 @@ static int idetape_read_position(ide_drive_t *drive) | |||
| 1345 | debug_log(DBG_PROCS, "Enter %s\n", __func__); | 1170 | debug_log(DBG_PROCS, "Enter %s\n", __func__); |
| 1346 | 1171 | ||
| 1347 | idetape_create_read_position_cmd(&pc); | 1172 | idetape_create_read_position_cmd(&pc); |
| 1348 | if (idetape_queue_pc_tail(drive, &pc)) | 1173 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) |
| 1349 | return -1; | 1174 | return -1; |
| 1350 | position = tape->first_frame; | 1175 | position = tape->first_frame; |
| 1351 | return position; | 1176 | return position; |
| @@ -1355,7 +1180,7 @@ static void idetape_create_locate_cmd(ide_drive_t *drive, | |||
| 1355 | struct ide_atapi_pc *pc, | 1180 | struct ide_atapi_pc *pc, |
| 1356 | unsigned int block, u8 partition, int skip) | 1181 | unsigned int block, u8 partition, int skip) |
| 1357 | { | 1182 | { |
| 1358 | idetape_init_pc(pc); | 1183 | ide_init_pc(pc); |
| 1359 | pc->c[0] = POSITION_TO_ELEMENT; | 1184 | pc->c[0] = POSITION_TO_ELEMENT; |
| 1360 | pc->c[1] = 2; | 1185 | pc->c[1] = 2; |
| 1361 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); | 1186 | put_unaligned(cpu_to_be32(block), (unsigned int *) &pc->c[3]); |
| @@ -1363,21 +1188,6 @@ static void idetape_create_locate_cmd(ide_drive_t *drive, | |||
| 1363 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1188 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
| 1364 | } | 1189 | } |
| 1365 | 1190 | ||
| 1366 | static int idetape_create_prevent_cmd(ide_drive_t *drive, | ||
| 1367 | struct ide_atapi_pc *pc, int prevent) | ||
| 1368 | { | ||
| 1369 | idetape_tape_t *tape = drive->driver_data; | ||
| 1370 | |||
| 1371 | /* device supports locking according to capabilities page */ | ||
| 1372 | if (!(tape->caps[6] & 0x01)) | ||
| 1373 | return 0; | ||
| 1374 | |||
| 1375 | idetape_init_pc(pc); | ||
| 1376 | pc->c[0] = ALLOW_MEDIUM_REMOVAL; | ||
| 1377 | pc->c[4] = prevent; | ||
| 1378 | return 1; | ||
| 1379 | } | ||
| 1380 | |||
| 1381 | static void __ide_tape_discard_merge_buffer(ide_drive_t *drive) | 1191 | static void __ide_tape_discard_merge_buffer(ide_drive_t *drive) |
| 1382 | { | 1192 | { |
| 1383 | idetape_tape_t *tape = drive->driver_data; | 1193 | idetape_tape_t *tape = drive->driver_data; |
| @@ -1405,6 +1215,7 @@ static int idetape_position_tape(ide_drive_t *drive, unsigned int block, | |||
| 1405 | u8 partition, int skip) | 1215 | u8 partition, int skip) |
| 1406 | { | 1216 | { |
| 1407 | idetape_tape_t *tape = drive->driver_data; | 1217 | idetape_tape_t *tape = drive->driver_data; |
| 1218 | struct gendisk *disk = tape->disk; | ||
| 1408 | int retval; | 1219 | int retval; |
| 1409 | struct ide_atapi_pc pc; | 1220 | struct ide_atapi_pc pc; |
| 1410 | 1221 | ||
| @@ -1412,12 +1223,12 @@ static int idetape_position_tape(ide_drive_t *drive, unsigned int block, | |||
| 1412 | __ide_tape_discard_merge_buffer(drive); | 1223 | __ide_tape_discard_merge_buffer(drive); |
| 1413 | idetape_wait_ready(drive, 60 * 5 * HZ); | 1224 | idetape_wait_ready(drive, 60 * 5 * HZ); |
| 1414 | idetape_create_locate_cmd(drive, &pc, block, partition, skip); | 1225 | idetape_create_locate_cmd(drive, &pc, block, partition, skip); |
| 1415 | retval = idetape_queue_pc_tail(drive, &pc); | 1226 | retval = ide_queue_pc_tail(drive, disk, &pc); |
| 1416 | if (retval) | 1227 | if (retval) |
| 1417 | return (retval); | 1228 | return (retval); |
| 1418 | 1229 | ||
| 1419 | idetape_create_read_position_cmd(&pc); | 1230 | idetape_create_read_position_cmd(&pc); |
| 1420 | return (idetape_queue_pc_tail(drive, &pc)); | 1231 | return ide_queue_pc_tail(drive, disk, &pc); |
| 1421 | } | 1232 | } |
| 1422 | 1233 | ||
| 1423 | static void ide_tape_discard_merge_buffer(ide_drive_t *drive, | 1234 | static void ide_tape_discard_merge_buffer(ide_drive_t *drive, |
| @@ -1477,7 +1288,7 @@ static int idetape_queue_rw_tail(ide_drive_t *drive, int cmd, int blocks, | |||
| 1477 | 1288 | ||
| 1478 | static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) | 1289 | static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) |
| 1479 | { | 1290 | { |
| 1480 | idetape_init_pc(pc); | 1291 | ide_init_pc(pc); |
| 1481 | pc->c[0] = INQUIRY; | 1292 | pc->c[0] = INQUIRY; |
| 1482 | pc->c[4] = 254; | 1293 | pc->c[4] = 254; |
| 1483 | pc->req_xfer = 254; | 1294 | pc->req_xfer = 254; |
| @@ -1486,14 +1297,14 @@ static void idetape_create_inquiry_cmd(struct ide_atapi_pc *pc) | |||
| 1486 | static void idetape_create_rewind_cmd(ide_drive_t *drive, | 1297 | static void idetape_create_rewind_cmd(ide_drive_t *drive, |
| 1487 | struct ide_atapi_pc *pc) | 1298 | struct ide_atapi_pc *pc) |
| 1488 | { | 1299 | { |
| 1489 | idetape_init_pc(pc); | 1300 | ide_init_pc(pc); |
| 1490 | pc->c[0] = REZERO_UNIT; | 1301 | pc->c[0] = REZERO_UNIT; |
| 1491 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1302 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
| 1492 | } | 1303 | } |
| 1493 | 1304 | ||
| 1494 | static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) | 1305 | static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) |
| 1495 | { | 1306 | { |
| 1496 | idetape_init_pc(pc); | 1307 | ide_init_pc(pc); |
| 1497 | pc->c[0] = ERASE; | 1308 | pc->c[0] = ERASE; |
| 1498 | pc->c[1] = 1; | 1309 | pc->c[1] = 1; |
| 1499 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; | 1310 | pc->flags |= PC_FLAG_WAIT_FOR_DSC; |
| @@ -1501,7 +1312,7 @@ static void idetape_create_erase_cmd(struct ide_atapi_pc *pc) | |||
| 1501 | 1312 | ||
| 1502 | static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) | 1313 | static void idetape_create_space_cmd(struct ide_atapi_pc *pc, int count, u8 cmd) |
| 1503 | { | 1314 | { |
| 1504 | idetape_init_pc(pc); | 1315 | ide_init_pc(pc); |
| 1505 | pc->c[0] = SPACE; | 1316 | pc->c[0] = SPACE; |
| 1506 | put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); | 1317 | put_unaligned(cpu_to_be32(count), (unsigned int *) &pc->c[1]); |
| 1507 | pc->c[1] = cmd; | 1318 | pc->c[1] = cmd; |
| @@ -1664,20 +1475,20 @@ static void idetape_pad_zeros(ide_drive_t *drive, int bcount) | |||
| 1664 | */ | 1475 | */ |
| 1665 | static int idetape_rewind_tape(ide_drive_t *drive) | 1476 | static int idetape_rewind_tape(ide_drive_t *drive) |
| 1666 | { | 1477 | { |
| 1478 | struct ide_tape_obj *tape = drive->driver_data; | ||
| 1479 | struct gendisk *disk = tape->disk; | ||
| 1667 | int retval; | 1480 | int retval; |
| 1668 | struct ide_atapi_pc pc; | 1481 | struct ide_atapi_pc pc; |
| 1669 | idetape_tape_t *tape; | ||
| 1670 | tape = drive->driver_data; | ||
| 1671 | 1482 | ||
| 1672 | debug_log(DBG_SENSE, "Enter %s\n", __func__); | 1483 | debug_log(DBG_SENSE, "Enter %s\n", __func__); |
| 1673 | 1484 | ||
| 1674 | idetape_create_rewind_cmd(drive, &pc); | 1485 | idetape_create_rewind_cmd(drive, &pc); |
| 1675 | retval = idetape_queue_pc_tail(drive, &pc); | 1486 | retval = ide_queue_pc_tail(drive, disk, &pc); |
| 1676 | if (retval) | 1487 | if (retval) |
| 1677 | return retval; | 1488 | return retval; |
| 1678 | 1489 | ||
| 1679 | idetape_create_read_position_cmd(&pc); | 1490 | idetape_create_read_position_cmd(&pc); |
| 1680 | retval = idetape_queue_pc_tail(drive, &pc); | 1491 | retval = ide_queue_pc_tail(drive, disk, &pc); |
| 1681 | if (retval) | 1492 | if (retval) |
| 1682 | return retval; | 1493 | return retval; |
| 1683 | return 0; | 1494 | return 0; |
| @@ -1720,6 +1531,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
| 1720 | int mt_count) | 1531 | int mt_count) |
| 1721 | { | 1532 | { |
| 1722 | idetape_tape_t *tape = drive->driver_data; | 1533 | idetape_tape_t *tape = drive->driver_data; |
| 1534 | struct gendisk *disk = tape->disk; | ||
| 1723 | struct ide_atapi_pc pc; | 1535 | struct ide_atapi_pc pc; |
| 1724 | int retval, count = 0; | 1536 | int retval, count = 0; |
| 1725 | int sprev = !!(tape->caps[4] & 0x20); | 1537 | int sprev = !!(tape->caps[4] & 0x20); |
| @@ -1744,7 +1556,7 @@ static int idetape_space_over_filemarks(ide_drive_t *drive, short mt_op, | |||
| 1744 | case MTBSF: | 1556 | case MTBSF: |
| 1745 | idetape_create_space_cmd(&pc, mt_count - count, | 1557 | idetape_create_space_cmd(&pc, mt_count - count, |
| 1746 | IDETAPE_SPACE_OVER_FILEMARK); | 1558 | IDETAPE_SPACE_OVER_FILEMARK); |
| 1747 | return idetape_queue_pc_tail(drive, &pc); | 1559 | return ide_queue_pc_tail(drive, disk, &pc); |
| 1748 | case MTFSFM: | 1560 | case MTFSFM: |
| 1749 | case MTBSFM: | 1561 | case MTBSFM: |
| 1750 | if (!sprev) | 1562 | if (!sprev) |
| @@ -1933,11 +1745,12 @@ static ssize_t idetape_chrdev_write(struct file *file, const char __user *buf, | |||
| 1933 | 1745 | ||
| 1934 | static int idetape_write_filemark(ide_drive_t *drive) | 1746 | static int idetape_write_filemark(ide_drive_t *drive) |
| 1935 | { | 1747 | { |
| 1748 | struct ide_tape_obj *tape = drive->driver_data; | ||
| 1936 | struct ide_atapi_pc pc; | 1749 | struct ide_atapi_pc pc; |
| 1937 | 1750 | ||
| 1938 | /* Write a filemark */ | 1751 | /* Write a filemark */ |
| 1939 | idetape_create_write_filemark_cmd(drive, &pc, 1); | 1752 | idetape_create_write_filemark_cmd(drive, &pc, 1); |
| 1940 | if (idetape_queue_pc_tail(drive, &pc)) { | 1753 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { |
| 1941 | printk(KERN_ERR "ide-tape: Couldn't write a filemark\n"); | 1754 | printk(KERN_ERR "ide-tape: Couldn't write a filemark\n"); |
| 1942 | return -EIO; | 1755 | return -EIO; |
| 1943 | } | 1756 | } |
| @@ -1960,6 +1773,7 @@ static int idetape_write_filemark(ide_drive_t *drive) | |||
| 1960 | static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | 1773 | static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) |
| 1961 | { | 1774 | { |
| 1962 | idetape_tape_t *tape = drive->driver_data; | 1775 | idetape_tape_t *tape = drive->driver_data; |
| 1776 | struct gendisk *disk = tape->disk; | ||
| 1963 | struct ide_atapi_pc pc; | 1777 | struct ide_atapi_pc pc; |
| 1964 | int i, retval; | 1778 | int i, retval; |
| 1965 | 1779 | ||
| @@ -1996,9 +1810,7 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
| 1996 | return 0; | 1810 | return 0; |
| 1997 | case MTLOAD: | 1811 | case MTLOAD: |
| 1998 | ide_tape_discard_merge_buffer(drive, 0); | 1812 | ide_tape_discard_merge_buffer(drive, 0); |
| 1999 | idetape_create_load_unload_cmd(drive, &pc, | 1813 | return ide_do_start_stop(drive, disk, IDETAPE_LU_LOAD_MASK); |
| 2000 | IDETAPE_LU_LOAD_MASK); | ||
| 2001 | return idetape_queue_pc_tail(drive, &pc); | ||
| 2002 | case MTUNLOAD: | 1814 | case MTUNLOAD: |
| 2003 | case MTOFFL: | 1815 | case MTOFFL: |
| 2004 | /* | 1816 | /* |
| @@ -2006,14 +1818,11 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
| 2006 | * attempting to eject. | 1818 | * attempting to eject. |
| 2007 | */ | 1819 | */ |
| 2008 | if (tape->door_locked) { | 1820 | if (tape->door_locked) { |
| 2009 | if (idetape_create_prevent_cmd(drive, &pc, 0)) | 1821 | if (!ide_set_media_lock(drive, disk, 0)) |
| 2010 | if (!idetape_queue_pc_tail(drive, &pc)) | 1822 | tape->door_locked = DOOR_UNLOCKED; |
| 2011 | tape->door_locked = DOOR_UNLOCKED; | ||
| 2012 | } | 1823 | } |
| 2013 | ide_tape_discard_merge_buffer(drive, 0); | 1824 | ide_tape_discard_merge_buffer(drive, 0); |
| 2014 | idetape_create_load_unload_cmd(drive, &pc, | 1825 | retval = ide_do_start_stop(drive, disk, !IDETAPE_LU_LOAD_MASK); |
| 2015 | !IDETAPE_LU_LOAD_MASK); | ||
| 2016 | retval = idetape_queue_pc_tail(drive, &pc); | ||
| 2017 | if (!retval) | 1826 | if (!retval) |
| 2018 | clear_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); | 1827 | clear_bit(IDE_AFLAG_MEDIUM_PRESENT, &drive->atapi_flags); |
| 2019 | return retval; | 1828 | return retval; |
| @@ -2022,16 +1831,15 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
| 2022 | return idetape_flush_tape_buffers(drive); | 1831 | return idetape_flush_tape_buffers(drive); |
| 2023 | case MTRETEN: | 1832 | case MTRETEN: |
| 2024 | ide_tape_discard_merge_buffer(drive, 0); | 1833 | ide_tape_discard_merge_buffer(drive, 0); |
| 2025 | idetape_create_load_unload_cmd(drive, &pc, | 1834 | return ide_do_start_stop(drive, disk, |
| 2026 | IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); | 1835 | IDETAPE_LU_RETENSION_MASK | IDETAPE_LU_LOAD_MASK); |
| 2027 | return idetape_queue_pc_tail(drive, &pc); | ||
| 2028 | case MTEOM: | 1836 | case MTEOM: |
| 2029 | idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); | 1837 | idetape_create_space_cmd(&pc, 0, IDETAPE_SPACE_TO_EOD); |
| 2030 | return idetape_queue_pc_tail(drive, &pc); | 1838 | return ide_queue_pc_tail(drive, disk, &pc); |
| 2031 | case MTERASE: | 1839 | case MTERASE: |
| 2032 | (void)idetape_rewind_tape(drive); | 1840 | (void)idetape_rewind_tape(drive); |
| 2033 | idetape_create_erase_cmd(&pc); | 1841 | idetape_create_erase_cmd(&pc); |
| 2034 | return idetape_queue_pc_tail(drive, &pc); | 1842 | return ide_queue_pc_tail(drive, disk, &pc); |
| 2035 | case MTSETBLK: | 1843 | case MTSETBLK: |
| 2036 | if (mt_count) { | 1844 | if (mt_count) { |
| 2037 | if (mt_count < tape->blk_size || | 1845 | if (mt_count < tape->blk_size || |
| @@ -2052,17 +1860,13 @@ static int idetape_mtioctop(ide_drive_t *drive, short mt_op, int mt_count) | |||
| 2052 | case MTFSR: | 1860 | case MTFSR: |
| 2053 | case MTBSR: | 1861 | case MTBSR: |
| 2054 | case MTLOCK: | 1862 | case MTLOCK: |
| 2055 | if (!idetape_create_prevent_cmd(drive, &pc, 1)) | 1863 | retval = ide_set_media_lock(drive, disk, 1); |
| 2056 | return 0; | ||
| 2057 | retval = idetape_queue_pc_tail(drive, &pc); | ||
| 2058 | if (retval) | 1864 | if (retval) |
| 2059 | return retval; | 1865 | return retval; |
| 2060 | tape->door_locked = DOOR_EXPLICITLY_LOCKED; | 1866 | tape->door_locked = DOOR_EXPLICITLY_LOCKED; |
| 2061 | return 0; | 1867 | return 0; |
| 2062 | case MTUNLOCK: | 1868 | case MTUNLOCK: |
| 2063 | if (!idetape_create_prevent_cmd(drive, &pc, 0)) | 1869 | retval = ide_set_media_lock(drive, disk, 0); |
| 2064 | return 0; | ||
| 2065 | retval = idetape_queue_pc_tail(drive, &pc); | ||
| 2066 | if (retval) | 1870 | if (retval) |
| 2067 | return retval; | 1871 | return retval; |
| 2068 | tape->door_locked = DOOR_UNLOCKED; | 1872 | tape->door_locked = DOOR_UNLOCKED; |
| @@ -2144,7 +1948,7 @@ static void ide_tape_get_bsize_from_bdesc(ide_drive_t *drive) | |||
| 2144 | struct ide_atapi_pc pc; | 1948 | struct ide_atapi_pc pc; |
| 2145 | 1949 | ||
| 2146 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); | 1950 | idetape_create_mode_sense_cmd(&pc, IDETAPE_BLOCK_DESCRIPTOR); |
| 2147 | if (idetape_queue_pc_tail(drive, &pc)) { | 1951 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { |
| 2148 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); | 1952 | printk(KERN_ERR "ide-tape: Can't get block descriptor\n"); |
| 2149 | if (tape->blk_size == 0) { | 1953 | if (tape->blk_size == 0) { |
| 2150 | printk(KERN_WARNING "ide-tape: Cannot deal with zero " | 1954 | printk(KERN_WARNING "ide-tape: Cannot deal with zero " |
| @@ -2164,7 +1968,6 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
| 2164 | unsigned int minor = iminor(inode), i = minor & ~0xc0; | 1968 | unsigned int minor = iminor(inode), i = minor & ~0xc0; |
| 2165 | ide_drive_t *drive; | 1969 | ide_drive_t *drive; |
| 2166 | idetape_tape_t *tape; | 1970 | idetape_tape_t *tape; |
| 2167 | struct ide_atapi_pc pc; | ||
| 2168 | int retval; | 1971 | int retval; |
| 2169 | 1972 | ||
| 2170 | if (i >= MAX_HWIFS * MAX_DRIVES) | 1973 | if (i >= MAX_HWIFS * MAX_DRIVES) |
| @@ -2227,11 +2030,9 @@ static int idetape_chrdev_open(struct inode *inode, struct file *filp) | |||
| 2227 | 2030 | ||
| 2228 | /* Lock the tape drive door so user can't eject. */ | 2031 | /* Lock the tape drive door so user can't eject. */ |
| 2229 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { | 2032 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { |
| 2230 | if (idetape_create_prevent_cmd(drive, &pc, 1)) { | 2033 | if (!ide_set_media_lock(drive, tape->disk, 1)) { |
| 2231 | if (!idetape_queue_pc_tail(drive, &pc)) { | 2034 | if (tape->door_locked != DOOR_EXPLICITLY_LOCKED) |
| 2232 | if (tape->door_locked != DOOR_EXPLICITLY_LOCKED) | 2035 | tape->door_locked = DOOR_LOCKED; |
| 2233 | tape->door_locked = DOOR_LOCKED; | ||
| 2234 | } | ||
| 2235 | } | 2036 | } |
| 2236 | } | 2037 | } |
| 2237 | unlock_kernel(); | 2038 | unlock_kernel(); |
| @@ -2264,7 +2065,6 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
| 2264 | { | 2065 | { |
| 2265 | struct ide_tape_obj *tape = ide_tape_f(filp); | 2066 | struct ide_tape_obj *tape = ide_tape_f(filp); |
| 2266 | ide_drive_t *drive = tape->drive; | 2067 | ide_drive_t *drive = tape->drive; |
| 2267 | struct ide_atapi_pc pc; | ||
| 2268 | unsigned int minor = iminor(inode); | 2068 | unsigned int minor = iminor(inode); |
| 2269 | 2069 | ||
| 2270 | lock_kernel(); | 2070 | lock_kernel(); |
| @@ -2283,10 +2083,8 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
| 2283 | (void) idetape_rewind_tape(drive); | 2083 | (void) idetape_rewind_tape(drive); |
| 2284 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { | 2084 | if (tape->chrdev_dir == IDETAPE_DIR_NONE) { |
| 2285 | if (tape->door_locked == DOOR_LOCKED) { | 2085 | if (tape->door_locked == DOOR_LOCKED) { |
| 2286 | if (idetape_create_prevent_cmd(drive, &pc, 0)) { | 2086 | if (!ide_set_media_lock(drive, tape->disk, 0)) |
| 2287 | if (!idetape_queue_pc_tail(drive, &pc)) | 2087 | tape->door_locked = DOOR_UNLOCKED; |
| 2288 | tape->door_locked = DOOR_UNLOCKED; | ||
| 2289 | } | ||
| 2290 | } | 2088 | } |
| 2291 | } | 2089 | } |
| 2292 | clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); | 2090 | clear_bit(IDE_AFLAG_BUSY, &drive->atapi_flags); |
| @@ -2295,45 +2093,6 @@ static int idetape_chrdev_release(struct inode *inode, struct file *filp) | |||
| 2295 | return 0; | 2093 | return 0; |
| 2296 | } | 2094 | } |
| 2297 | 2095 | ||
| 2298 | /* | ||
| 2299 | * check the contents of the ATAPI IDENTIFY command results. We return: | ||
| 2300 | * | ||
| 2301 | * 1 - If the tape can be supported by us, based on the information we have so | ||
| 2302 | * far. | ||
| 2303 | * | ||
| 2304 | * 0 - If this tape driver is not currently supported by us. | ||
| 2305 | */ | ||
| 2306 | static int idetape_identify_device(ide_drive_t *drive) | ||
| 2307 | { | ||
| 2308 | u8 gcw[2], protocol, device_type, removable, packet_size; | ||
| 2309 | |||
| 2310 | if (drive->id_read == 0) | ||
| 2311 | return 1; | ||
| 2312 | |||
| 2313 | *((unsigned short *) &gcw) = drive->id->config; | ||
| 2314 | |||
| 2315 | protocol = (gcw[1] & 0xC0) >> 6; | ||
| 2316 | device_type = gcw[1] & 0x1F; | ||
| 2317 | removable = !!(gcw[0] & 0x80); | ||
| 2318 | packet_size = gcw[0] & 0x3; | ||
| 2319 | |||
| 2320 | /* Check that we can support this device */ | ||
| 2321 | if (protocol != 2) | ||
| 2322 | printk(KERN_ERR "ide-tape: Protocol (0x%02x) is not ATAPI\n", | ||
| 2323 | protocol); | ||
| 2324 | else if (device_type != 1) | ||
| 2325 | printk(KERN_ERR "ide-tape: Device type (0x%02x) is not set " | ||
| 2326 | "to tape\n", device_type); | ||
| 2327 | else if (!removable) | ||
| 2328 | printk(KERN_ERR "ide-tape: The removable flag is not set\n"); | ||
| 2329 | else if (packet_size != 0) { | ||
| 2330 | printk(KERN_ERR "ide-tape: Packet size (0x%02x) is not 12" | ||
| 2331 | " bytes\n", packet_size); | ||
| 2332 | } else | ||
| 2333 | return 1; | ||
| 2334 | return 0; | ||
| 2335 | } | ||
| 2336 | |||
| 2337 | static void idetape_get_inquiry_results(ide_drive_t *drive) | 2096 | static void idetape_get_inquiry_results(ide_drive_t *drive) |
| 2338 | { | 2097 | { |
| 2339 | idetape_tape_t *tape = drive->driver_data; | 2098 | idetape_tape_t *tape = drive->driver_data; |
| @@ -2341,7 +2100,7 @@ static void idetape_get_inquiry_results(ide_drive_t *drive) | |||
| 2341 | char fw_rev[4], vendor_id[8], product_id[16]; | 2100 | char fw_rev[4], vendor_id[8], product_id[16]; |
| 2342 | 2101 | ||
| 2343 | idetape_create_inquiry_cmd(&pc); | 2102 | idetape_create_inquiry_cmd(&pc); |
| 2344 | if (idetape_queue_pc_tail(drive, &pc)) { | 2103 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { |
| 2345 | printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", | 2104 | printk(KERN_ERR "ide-tape: %s: can't get INQUIRY results\n", |
| 2346 | tape->name); | 2105 | tape->name); |
| 2347 | return; | 2106 | return; |
| @@ -2370,7 +2129,7 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive) | |||
| 2370 | u8 speed, max_speed; | 2129 | u8 speed, max_speed; |
| 2371 | 2130 | ||
| 2372 | idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); | 2131 | idetape_create_mode_sense_cmd(&pc, IDETAPE_CAPABILITIES_PAGE); |
| 2373 | if (idetape_queue_pc_tail(drive, &pc)) { | 2132 | if (ide_queue_pc_tail(drive, tape->disk, &pc)) { |
| 2374 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" | 2133 | printk(KERN_ERR "ide-tape: Can't get tape parameters - assuming" |
| 2375 | " some default values\n"); | 2134 | " some default values\n"); |
| 2376 | tape->blk_size = 512; | 2135 | tape->blk_size = 512; |
| @@ -2402,6 +2161,11 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive) | |||
| 2402 | } | 2161 | } |
| 2403 | 2162 | ||
| 2404 | memcpy(&tape->caps, caps, 20); | 2163 | memcpy(&tape->caps, caps, 20); |
| 2164 | |||
| 2165 | /* device lacks locking support according to capabilities page */ | ||
| 2166 | if ((caps[6] & 1) == 0) | ||
| 2167 | drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; | ||
| 2168 | |||
| 2405 | if (caps[7] & 0x02) | 2169 | if (caps[7] & 0x02) |
| 2406 | tape->blk_size = 512; | 2170 | tape->blk_size = 512; |
| 2407 | else if (caps[7] & 0x04) | 2171 | else if (caps[7] & 0x04) |
| @@ -2409,28 +2173,56 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive) | |||
| 2409 | } | 2173 | } |
| 2410 | 2174 | ||
| 2411 | #ifdef CONFIG_IDE_PROC_FS | 2175 | #ifdef CONFIG_IDE_PROC_FS |
| 2412 | static void idetape_add_settings(ide_drive_t *drive) | 2176 | #define ide_tape_devset_get(name, field) \ |
| 2413 | { | 2177 | static int get_##name(ide_drive_t *drive) \ |
| 2414 | idetape_tape_t *tape = drive->driver_data; | 2178 | { \ |
| 2415 | 2179 | idetape_tape_t *tape = drive->driver_data; \ | |
| 2416 | ide_add_setting(drive, "buffer", SETTING_READ, TYPE_SHORT, 0, 0xffff, | 2180 | return tape->field; \ |
| 2417 | 1, 2, (u16 *)&tape->caps[16], NULL); | 2181 | } |
| 2418 | ide_add_setting(drive, "speed", SETTING_READ, TYPE_SHORT, 0, 0xffff, | 2182 | |
| 2419 | 1, 1, (u16 *)&tape->caps[14], NULL); | 2183 | #define ide_tape_devset_set(name, field) \ |
| 2420 | ide_add_setting(drive, "buffer_size", SETTING_READ, TYPE_INT, 0, 0xffff, | 2184 | static int set_##name(ide_drive_t *drive, int arg) \ |
| 2421 | 1, 1024, &tape->buffer_size, NULL); | 2185 | { \ |
| 2422 | ide_add_setting(drive, "tdsc", SETTING_RW, TYPE_INT, IDETAPE_DSC_RW_MIN, | 2186 | idetape_tape_t *tape = drive->driver_data; \ |
| 2423 | IDETAPE_DSC_RW_MAX, 1000, HZ, &tape->best_dsc_rw_freq, | 2187 | tape->field = arg; \ |
| 2424 | NULL); | 2188 | return 0; \ |
| 2425 | ide_add_setting(drive, "dsc_overlap", SETTING_RW, TYPE_BYTE, 0, 1, 1, | 2189 | } |
| 2426 | 1, &drive->dsc_overlap, NULL); | 2190 | |
| 2427 | ide_add_setting(drive, "avg_speed", SETTING_READ, TYPE_INT, 0, 0xffff, | 2191 | #define ide_tape_devset_rw_field(_name, _field) \ |
| 2428 | 1, 1, &tape->avg_speed, NULL); | 2192 | ide_tape_devset_get(_name, _field) \ |
| 2429 | ide_add_setting(drive, "debug_mask", SETTING_RW, TYPE_INT, 0, 0xffff, 1, | 2193 | ide_tape_devset_set(_name, _field) \ |
| 2430 | 1, &tape->debug_mask, NULL); | 2194 | IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) |
| 2431 | } | 2195 | |
| 2432 | #else | 2196 | #define ide_tape_devset_r_field(_name, _field) \ |
| 2433 | static inline void idetape_add_settings(ide_drive_t *drive) { ; } | 2197 | ide_tape_devset_get(_name, _field) \ |
| 2198 | IDE_DEVSET(_name, 0, get_##_name, NULL) | ||
| 2199 | |||
| 2200 | static int mulf_tdsc(ide_drive_t *drive) { return 1000; } | ||
| 2201 | static int divf_tdsc(ide_drive_t *drive) { return HZ; } | ||
| 2202 | static int divf_buffer(ide_drive_t *drive) { return 2; } | ||
| 2203 | static int divf_buffer_size(ide_drive_t *drive) { return 1024; } | ||
| 2204 | |||
| 2205 | ide_devset_rw_field(dsc_overlap, dsc_overlap); | ||
| 2206 | |||
| 2207 | ide_tape_devset_rw_field(debug_mask, debug_mask); | ||
| 2208 | ide_tape_devset_rw_field(tdsc, best_dsc_rw_freq); | ||
| 2209 | |||
| 2210 | ide_tape_devset_r_field(avg_speed, avg_speed); | ||
| 2211 | ide_tape_devset_r_field(speed, caps[14]); | ||
| 2212 | ide_tape_devset_r_field(buffer, caps[16]); | ||
| 2213 | ide_tape_devset_r_field(buffer_size, buffer_size); | ||
| 2214 | |||
| 2215 | static const struct ide_proc_devset idetape_settings[] = { | ||
| 2216 | __IDE_PROC_DEVSET(avg_speed, 0, 0xffff, NULL, NULL), | ||
| 2217 | __IDE_PROC_DEVSET(buffer, 0, 0xffff, NULL, divf_buffer), | ||
| 2218 | __IDE_PROC_DEVSET(buffer_size, 0, 0xffff, NULL, divf_buffer_size), | ||
| 2219 | __IDE_PROC_DEVSET(debug_mask, 0, 0xffff, NULL, NULL), | ||
| 2220 | __IDE_PROC_DEVSET(dsc_overlap, 0, 1, NULL, NULL), | ||
| 2221 | __IDE_PROC_DEVSET(speed, 0, 0xffff, NULL, NULL), | ||
| 2222 | __IDE_PROC_DEVSET(tdsc, IDETAPE_DSC_RW_MIN, IDETAPE_DSC_RW_MAX, | ||
| 2223 | mulf_tdsc, divf_tdsc), | ||
| 2224 | { 0 }, | ||
| 2225 | }; | ||
| 2434 | #endif | 2226 | #endif |
| 2435 | 2227 | ||
| 2436 | /* | 2228 | /* |
| @@ -2462,15 +2254,15 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
| 2462 | drive->dsc_overlap = 0; | 2254 | drive->dsc_overlap = 0; |
| 2463 | } | 2255 | } |
| 2464 | /* Seagate Travan drives do not support DSC overlap. */ | 2256 | /* Seagate Travan drives do not support DSC overlap. */ |
| 2465 | if (strstr(drive->id->model, "Seagate STT3401")) | 2257 | if (strstr((char *)&drive->id[ATA_ID_PROD], "Seagate STT3401")) |
| 2466 | drive->dsc_overlap = 0; | 2258 | drive->dsc_overlap = 0; |
| 2467 | tape->minor = minor; | 2259 | tape->minor = minor; |
| 2468 | tape->name[0] = 'h'; | 2260 | tape->name[0] = 'h'; |
| 2469 | tape->name[1] = 't'; | 2261 | tape->name[1] = 't'; |
| 2470 | tape->name[2] = '0' + minor; | 2262 | tape->name[2] = '0' + minor; |
| 2471 | tape->chrdev_dir = IDETAPE_DIR_NONE; | 2263 | tape->chrdev_dir = IDETAPE_DIR_NONE; |
| 2472 | tape->pc = tape->pc_stack; | 2264 | |
| 2473 | *((unsigned short *) &gcw) = drive->id->config; | 2265 | *((u16 *)&gcw) = drive->id[ATA_ID_CONFIG]; |
| 2474 | 2266 | ||
| 2475 | /* Command packet DRQ type */ | 2267 | /* Command packet DRQ type */ |
| 2476 | if (((gcw[0] & 0x60) >> 5) == 1) | 2268 | if (((gcw[0] & 0x60) >> 5) == 1) |
| @@ -2512,7 +2304,7 @@ static void idetape_setup(ide_drive_t *drive, idetape_tape_t *tape, int minor) | |||
| 2512 | tape->best_dsc_rw_freq * 1000 / HZ, | 2304 | tape->best_dsc_rw_freq * 1000 / HZ, |
| 2513 | drive->using_dma ? ", DMA":""); | 2305 | drive->using_dma ? ", DMA":""); |
| 2514 | 2306 | ||
| 2515 | idetape_add_settings(drive); | 2307 | ide_proc_register_driver(drive, tape->driver); |
| 2516 | } | 2308 | } |
| 2517 | 2309 | ||
| 2518 | static void ide_tape_remove(ide_drive_t *drive) | 2310 | static void ide_tape_remove(ide_drive_t *drive) |
| @@ -2577,12 +2369,12 @@ static ide_driver_t idetape_driver = { | |||
| 2577 | .remove = ide_tape_remove, | 2369 | .remove = ide_tape_remove, |
| 2578 | .version = IDETAPE_VERSION, | 2370 | .version = IDETAPE_VERSION, |
| 2579 | .media = ide_tape, | 2371 | .media = ide_tape, |
| 2580 | .supports_dsc_overlap = 1, | ||
| 2581 | .do_request = idetape_do_request, | 2372 | .do_request = idetape_do_request, |
| 2582 | .end_request = idetape_end_request, | 2373 | .end_request = idetape_end_request, |
| 2583 | .error = __ide_error, | 2374 | .error = __ide_error, |
| 2584 | #ifdef CONFIG_IDE_PROC_FS | 2375 | #ifdef CONFIG_IDE_PROC_FS |
| 2585 | .proc = idetape_proc, | 2376 | .proc = idetape_proc, |
| 2377 | .settings = idetape_settings, | ||
| 2586 | #endif | 2378 | #endif |
| 2587 | }; | 2379 | }; |
| 2588 | 2380 | ||
| @@ -2645,11 +2437,11 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
| 2645 | 2437 | ||
| 2646 | if (!strstr("ide-tape", drive->driver_req)) | 2438 | if (!strstr("ide-tape", drive->driver_req)) |
| 2647 | goto failed; | 2439 | goto failed; |
| 2648 | if (!drive->present) | 2440 | |
| 2649 | goto failed; | ||
| 2650 | if (drive->media != ide_tape) | 2441 | if (drive->media != ide_tape) |
| 2651 | goto failed; | 2442 | goto failed; |
| 2652 | if (!idetape_identify_device(drive)) { | 2443 | |
| 2444 | if (drive->id_read == 1 && !ide_check_atapi_device(drive, DRV_NAME)) { | ||
| 2653 | printk(KERN_ERR "ide-tape: %s: not supported by this version of" | 2445 | printk(KERN_ERR "ide-tape: %s: not supported by this version of" |
| 2654 | " the driver\n", drive->name); | 2446 | " the driver\n", drive->name); |
| 2655 | goto failed; | 2447 | goto failed; |
| @@ -2667,8 +2459,6 @@ static int ide_tape_probe(ide_drive_t *drive) | |||
| 2667 | 2459 | ||
| 2668 | ide_init_disk(g, drive); | 2460 | ide_init_disk(g, drive); |
| 2669 | 2461 | ||
| 2670 | ide_proc_register_driver(drive, &idetape_driver); | ||
| 2671 | |||
| 2672 | kref_init(&tape->kref); | 2462 | kref_init(&tape->kref); |
| 2673 | 2463 | ||
| 2674 | tape->drive = drive; | 2464 | tape->drive = drive; |
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c index 7fb6f1c86272..487b18b3ebae 100644 --- a/drivers/ide/ide-taskfile.c +++ b/drivers/ide/ide-taskfile.c | |||
| @@ -44,9 +44,9 @@ int taskfile_lib_get_identify (ide_drive_t *drive, u8 *buf) | |||
| 44 | memset(&args, 0, sizeof(ide_task_t)); | 44 | memset(&args, 0, sizeof(ide_task_t)); |
| 45 | args.tf.nsect = 0x01; | 45 | args.tf.nsect = 0x01; |
| 46 | if (drive->media == ide_disk) | 46 | if (drive->media == ide_disk) |
| 47 | args.tf.command = WIN_IDENTIFY; | 47 | args.tf.command = ATA_CMD_ID_ATA; |
| 48 | else | 48 | else |
| 49 | args.tf.command = WIN_PIDENTIFY; | 49 | args.tf.command = ATA_CMD_ID_ATAPI; |
| 50 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | 50 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; |
| 51 | args.data_phase = TASKFILE_IN; | 51 | args.data_phase = TASKFILE_IN; |
| 52 | return ide_raw_taskfile(drive, &args, buf, 1); | 52 | return ide_raw_taskfile(drive, &args, buf, 1); |
| @@ -99,12 +99,17 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
| 99 | case TASKFILE_NO_DATA: | 99 | case TASKFILE_NO_DATA: |
| 100 | if (handler == NULL) | 100 | if (handler == NULL) |
| 101 | handler = task_no_data_intr; | 101 | handler = task_no_data_intr; |
| 102 | /* WIN_{SPECIFY,RESTORE,SETMULT} use custom handlers */ | ||
| 103 | if (task->tf_flags & IDE_TFLAG_CUSTOM_HANDLER) { | 102 | if (task->tf_flags & IDE_TFLAG_CUSTOM_HANDLER) { |
| 104 | switch (tf->command) { | 103 | switch (tf->command) { |
| 105 | case WIN_SPECIFY: handler = set_geometry_intr; break; | 104 | case ATA_CMD_INIT_DEV_PARAMS: |
| 106 | case WIN_RESTORE: handler = recal_intr; break; | 105 | handler = set_geometry_intr; |
| 107 | case WIN_SETMULT: handler = set_multmode_intr; break; | 106 | break; |
| 107 | case ATA_CMD_RESTORE: | ||
| 108 | handler = recal_intr; | ||
| 109 | break; | ||
| 110 | case ATA_CMD_SET_MULTI: | ||
| 111 | handler = set_multmode_intr; | ||
| 112 | break; | ||
| 108 | } | 113 | } |
| 109 | } | 114 | } |
| 110 | ide_execute_command(drive, tf->command, handler, | 115 | ide_execute_command(drive, tf->command, handler, |
| @@ -121,7 +126,7 @@ ide_startstop_t do_rw_taskfile (ide_drive_t *drive, ide_task_t *task) | |||
| 121 | EXPORT_SYMBOL_GPL(do_rw_taskfile); | 126 | EXPORT_SYMBOL_GPL(do_rw_taskfile); |
| 122 | 127 | ||
| 123 | /* | 128 | /* |
| 124 | * set_multmode_intr() is invoked on completion of a WIN_SETMULT cmd. | 129 | * set_multmode_intr() is invoked on completion of a ATA_CMD_SET_MULTI cmd. |
| 125 | */ | 130 | */ |
| 126 | static ide_startstop_t set_multmode_intr(ide_drive_t *drive) | 131 | static ide_startstop_t set_multmode_intr(ide_drive_t *drive) |
| 127 | { | 132 | { |
| @@ -131,7 +136,7 @@ static ide_startstop_t set_multmode_intr(ide_drive_t *drive) | |||
| 131 | local_irq_enable_in_hardirq(); | 136 | local_irq_enable_in_hardirq(); |
| 132 | stat = hwif->tp_ops->read_status(hwif); | 137 | stat = hwif->tp_ops->read_status(hwif); |
| 133 | 138 | ||
| 134 | if (OK_STAT(stat, READY_STAT, BAD_STAT)) | 139 | if (OK_STAT(stat, ATA_DRDY, BAD_STAT)) |
| 135 | drive->mult_count = drive->mult_req; | 140 | drive->mult_count = drive->mult_req; |
| 136 | else { | 141 | else { |
| 137 | drive->mult_req = drive->mult_count = 0; | 142 | drive->mult_req = drive->mult_count = 0; |
| @@ -142,7 +147,7 @@ static ide_startstop_t set_multmode_intr(ide_drive_t *drive) | |||
| 142 | } | 147 | } |
| 143 | 148 | ||
| 144 | /* | 149 | /* |
| 145 | * set_geometry_intr() is invoked on completion of a WIN_SPECIFY cmd. | 150 | * set_geometry_intr() is invoked on completion of a ATA_CMD_INIT_DEV_PARAMS cmd. |
| 146 | */ | 151 | */ |
| 147 | static ide_startstop_t set_geometry_intr(ide_drive_t *drive) | 152 | static ide_startstop_t set_geometry_intr(ide_drive_t *drive) |
| 148 | { | 153 | { |
| @@ -154,15 +159,15 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive) | |||
| 154 | 159 | ||
| 155 | while (1) { | 160 | while (1) { |
| 156 | stat = hwif->tp_ops->read_status(hwif); | 161 | stat = hwif->tp_ops->read_status(hwif); |
| 157 | if ((stat & BUSY_STAT) == 0 || retries-- == 0) | 162 | if ((stat & ATA_BUSY) == 0 || retries-- == 0) |
| 158 | break; | 163 | break; |
| 159 | udelay(10); | 164 | udelay(10); |
| 160 | }; | 165 | }; |
| 161 | 166 | ||
| 162 | if (OK_STAT(stat, READY_STAT, BAD_STAT)) | 167 | if (OK_STAT(stat, ATA_DRDY, BAD_STAT)) |
| 163 | return ide_stopped; | 168 | return ide_stopped; |
| 164 | 169 | ||
| 165 | if (stat & (ERR_STAT|DRQ_STAT)) | 170 | if (stat & (ATA_ERR | ATA_DRQ)) |
| 166 | return ide_error(drive, "set_geometry_intr", stat); | 171 | return ide_error(drive, "set_geometry_intr", stat); |
| 167 | 172 | ||
| 168 | ide_set_handler(drive, &set_geometry_intr, WAIT_WORSTCASE, NULL); | 173 | ide_set_handler(drive, &set_geometry_intr, WAIT_WORSTCASE, NULL); |
| @@ -170,7 +175,7 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive) | |||
| 170 | } | 175 | } |
| 171 | 176 | ||
| 172 | /* | 177 | /* |
| 173 | * recal_intr() is invoked on completion of a WIN_RESTORE (recalibrate) cmd. | 178 | * recal_intr() is invoked on completion of a ATA_CMD_RESTORE (recalibrate) cmd. |
| 174 | */ | 179 | */ |
| 175 | static ide_startstop_t recal_intr(ide_drive_t *drive) | 180 | static ide_startstop_t recal_intr(ide_drive_t *drive) |
| 176 | { | 181 | { |
| @@ -180,7 +185,7 @@ static ide_startstop_t recal_intr(ide_drive_t *drive) | |||
| 180 | local_irq_enable_in_hardirq(); | 185 | local_irq_enable_in_hardirq(); |
| 181 | stat = hwif->tp_ops->read_status(hwif); | 186 | stat = hwif->tp_ops->read_status(hwif); |
| 182 | 187 | ||
| 183 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) | 188 | if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) |
| 184 | return ide_error(drive, "recal_intr", stat); | 189 | return ide_error(drive, "recal_intr", stat); |
| 185 | return ide_stopped; | 190 | return ide_stopped; |
| 186 | } | 191 | } |
| @@ -197,7 +202,7 @@ static ide_startstop_t task_no_data_intr(ide_drive_t *drive) | |||
| 197 | local_irq_enable_in_hardirq(); | 202 | local_irq_enable_in_hardirq(); |
| 198 | stat = hwif->tp_ops->read_status(hwif); | 203 | stat = hwif->tp_ops->read_status(hwif); |
| 199 | 204 | ||
| 200 | if (!OK_STAT(stat, READY_STAT, BAD_STAT)) | 205 | if (!OK_STAT(stat, ATA_DRDY, BAD_STAT)) |
| 201 | return ide_error(drive, "task_no_data_intr", stat); | 206 | return ide_error(drive, "task_no_data_intr", stat); |
| 202 | /* calls ide_end_drive_cmd */ | 207 | /* calls ide_end_drive_cmd */ |
| 203 | 208 | ||
| @@ -220,13 +225,13 @@ static u8 wait_drive_not_busy(ide_drive_t *drive) | |||
| 220 | for (retries = 0; retries < 1000; retries++) { | 225 | for (retries = 0; retries < 1000; retries++) { |
| 221 | stat = hwif->tp_ops->read_status(hwif); | 226 | stat = hwif->tp_ops->read_status(hwif); |
| 222 | 227 | ||
| 223 | if (stat & BUSY_STAT) | 228 | if (stat & ATA_BUSY) |
| 224 | udelay(10); | 229 | udelay(10); |
| 225 | else | 230 | else |
| 226 | break; | 231 | break; |
| 227 | } | 232 | } |
| 228 | 233 | ||
| 229 | if (stat & BUSY_STAT) | 234 | if (stat & ATA_BUSY) |
| 230 | printk(KERN_ERR "%s: drive still BUSY!\n", drive->name); | 235 | printk(KERN_ERR "%s: drive still BUSY!\n", drive->name); |
| 231 | 236 | ||
| 232 | return stat; | 237 | return stat; |
| @@ -385,7 +390,7 @@ void task_end_request(ide_drive_t *drive, struct request *rq, u8 stat) | |||
| 385 | static ide_startstop_t task_in_unexpected(ide_drive_t *drive, struct request *rq, u8 stat) | 390 | static ide_startstop_t task_in_unexpected(ide_drive_t *drive, struct request *rq, u8 stat) |
| 386 | { | 391 | { |
| 387 | /* Command all done? */ | 392 | /* Command all done? */ |
| 388 | if (OK_STAT(stat, READY_STAT, BUSY_STAT)) { | 393 | if (OK_STAT(stat, ATA_DRDY, ATA_BUSY)) { |
| 389 | task_end_request(drive, rq, stat); | 394 | task_end_request(drive, rq, stat); |
| 390 | return ide_stopped; | 395 | return ide_stopped; |
| 391 | } | 396 | } |
| @@ -405,11 +410,11 @@ static ide_startstop_t task_in_intr(ide_drive_t *drive) | |||
| 405 | u8 stat = hwif->tp_ops->read_status(hwif); | 410 | u8 stat = hwif->tp_ops->read_status(hwif); |
| 406 | 411 | ||
| 407 | /* Error? */ | 412 | /* Error? */ |
| 408 | if (stat & ERR_STAT) | 413 | if (stat & ATA_ERR) |
| 409 | return task_error(drive, rq, __func__, stat); | 414 | return task_error(drive, rq, __func__, stat); |
| 410 | 415 | ||
| 411 | /* Didn't want any data? Odd. */ | 416 | /* Didn't want any data? Odd. */ |
| 412 | if (!(stat & DRQ_STAT)) | 417 | if ((stat & ATA_DRQ) == 0) |
| 413 | return task_in_unexpected(drive, rq, stat); | 418 | return task_in_unexpected(drive, rq, stat); |
| 414 | 419 | ||
| 415 | ide_pio_datablock(drive, rq, 0); | 420 | ide_pio_datablock(drive, rq, 0); |
| @@ -442,7 +447,7 @@ static ide_startstop_t task_out_intr (ide_drive_t *drive) | |||
| 442 | return task_error(drive, rq, __func__, stat); | 447 | return task_error(drive, rq, __func__, stat); |
| 443 | 448 | ||
| 444 | /* Deal with unexpected ATA data phase. */ | 449 | /* Deal with unexpected ATA data phase. */ |
| 445 | if (((stat & DRQ_STAT) == 0) ^ !hwif->nleft) | 450 | if (((stat & ATA_DRQ) == 0) ^ !hwif->nleft) |
| 446 | return task_error(drive, rq, __func__, stat); | 451 | return task_error(drive, rq, __func__, stat); |
| 447 | 452 | ||
| 448 | if (!hwif->nleft) { | 453 | if (!hwif->nleft) { |
| @@ -461,7 +466,7 @@ static ide_startstop_t pre_task_out_intr(ide_drive_t *drive, struct request *rq) | |||
| 461 | { | 466 | { |
| 462 | ide_startstop_t startstop; | 467 | ide_startstop_t startstop; |
| 463 | 468 | ||
| 464 | if (ide_wait_stat(&startstop, drive, DRQ_STAT, | 469 | if (ide_wait_stat(&startstop, drive, ATA_DRQ, |
| 465 | drive->bad_wstat, WAIT_DRQ)) { | 470 | drive->bad_wstat, WAIT_DRQ)) { |
| 466 | printk(KERN_ERR "%s: no DRQ after issuing %sWRITE%s\n", | 471 | printk(KERN_ERR "%s: no DRQ after issuing %sWRITE%s\n", |
| 467 | drive->name, | 472 | drive->name, |
| @@ -721,110 +726,3 @@ abort: | |||
| 721 | return err; | 726 | return err; |
| 722 | } | 727 | } |
| 723 | #endif | 728 | #endif |
| 724 | |||
| 725 | int ide_cmd_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | ||
| 726 | { | ||
| 727 | u8 *buf = NULL; | ||
| 728 | int bufsize = 0, err = 0; | ||
| 729 | u8 args[4], xfer_rate = 0; | ||
| 730 | ide_task_t tfargs; | ||
| 731 | struct ide_taskfile *tf = &tfargs.tf; | ||
| 732 | struct hd_driveid *id = drive->id; | ||
| 733 | |||
| 734 | if (NULL == (void *) arg) { | ||
| 735 | struct request *rq; | ||
| 736 | |||
| 737 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | ||
| 738 | rq->cmd_type = REQ_TYPE_ATA_TASKFILE; | ||
| 739 | err = blk_execute_rq(drive->queue, NULL, rq, 0); | ||
| 740 | blk_put_request(rq); | ||
| 741 | |||
| 742 | return err; | ||
| 743 | } | ||
| 744 | |||
| 745 | if (copy_from_user(args, (void __user *)arg, 4)) | ||
| 746 | return -EFAULT; | ||
| 747 | |||
| 748 | memset(&tfargs, 0, sizeof(ide_task_t)); | ||
| 749 | tf->feature = args[2]; | ||
| 750 | if (args[0] == WIN_SMART) { | ||
| 751 | tf->nsect = args[3]; | ||
| 752 | tf->lbal = args[1]; | ||
| 753 | tf->lbam = 0x4f; | ||
| 754 | tf->lbah = 0xc2; | ||
| 755 | tfargs.tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_IN_NSECT; | ||
| 756 | } else { | ||
| 757 | tf->nsect = args[1]; | ||
| 758 | tfargs.tf_flags = IDE_TFLAG_OUT_FEATURE | | ||
| 759 | IDE_TFLAG_OUT_NSECT | IDE_TFLAG_IN_NSECT; | ||
| 760 | } | ||
| 761 | tf->command = args[0]; | ||
| 762 | tfargs.data_phase = args[3] ? TASKFILE_IN : TASKFILE_NO_DATA; | ||
| 763 | |||
| 764 | if (args[3]) { | ||
| 765 | tfargs.tf_flags |= IDE_TFLAG_IO_16BIT; | ||
| 766 | bufsize = SECTOR_WORDS * 4 * args[3]; | ||
| 767 | buf = kzalloc(bufsize, GFP_KERNEL); | ||
| 768 | if (buf == NULL) | ||
| 769 | return -ENOMEM; | ||
| 770 | } | ||
| 771 | |||
| 772 | if (tf->command == WIN_SETFEATURES && | ||
| 773 | tf->feature == SETFEATURES_XFER && | ||
| 774 | tf->nsect >= XFER_SW_DMA_0 && | ||
| 775 | (id->dma_ultra || id->dma_mword || id->dma_1word)) { | ||
| 776 | xfer_rate = args[1]; | ||
| 777 | if (tf->nsect > XFER_UDMA_2 && !eighty_ninty_three(drive)) { | ||
| 778 | printk(KERN_WARNING "%s: UDMA speeds >UDMA33 cannot " | ||
| 779 | "be set\n", drive->name); | ||
| 780 | goto abort; | ||
| 781 | } | ||
| 782 | } | ||
| 783 | |||
| 784 | err = ide_raw_taskfile(drive, &tfargs, buf, args[3]); | ||
| 785 | |||
| 786 | args[0] = tf->status; | ||
| 787 | args[1] = tf->error; | ||
| 788 | args[2] = tf->nsect; | ||
| 789 | |||
| 790 | if (!err && xfer_rate) { | ||
| 791 | /* active-retuning-calls future */ | ||
| 792 | ide_set_xfer_rate(drive, xfer_rate); | ||
| 793 | ide_driveid_update(drive); | ||
| 794 | } | ||
| 795 | abort: | ||
| 796 | if (copy_to_user((void __user *)arg, &args, 4)) | ||
| 797 | err = -EFAULT; | ||
| 798 | if (buf) { | ||
| 799 | if (copy_to_user((void __user *)(arg + 4), buf, bufsize)) | ||
| 800 | err = -EFAULT; | ||
| 801 | kfree(buf); | ||
| 802 | } | ||
| 803 | return err; | ||
| 804 | } | ||
| 805 | |||
| 806 | int ide_task_ioctl (ide_drive_t *drive, unsigned int cmd, unsigned long arg) | ||
| 807 | { | ||
| 808 | void __user *p = (void __user *)arg; | ||
| 809 | int err = 0; | ||
| 810 | u8 args[7]; | ||
| 811 | ide_task_t task; | ||
| 812 | |||
| 813 | if (copy_from_user(args, p, 7)) | ||
| 814 | return -EFAULT; | ||
| 815 | |||
| 816 | memset(&task, 0, sizeof(task)); | ||
| 817 | memcpy(&task.tf_array[7], &args[1], 6); | ||
| 818 | task.tf.command = args[0]; | ||
| 819 | task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
| 820 | |||
| 821 | err = ide_no_data_taskfile(drive, &task); | ||
| 822 | |||
| 823 | args[0] = task.tf.command; | ||
| 824 | memcpy(&args[1], &task.tf_array[7], 6); | ||
| 825 | |||
| 826 | if (copy_to_user(p, args, 7)) | ||
| 827 | err = -EFAULT; | ||
| 828 | |||
| 829 | return err; | ||
| 830 | } | ||
diff --git a/drivers/ide/ide-timings.c b/drivers/ide/ide-timings.c index 8c2f8327f487..81f527af8fae 100644 --- a/drivers/ide/ide-timings.c +++ b/drivers/ide/ide-timings.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
| 25 | #include <linux/hdreg.h> | ||
| 26 | #include <linux/ide.h> | 25 | #include <linux/ide.h> |
| 27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
| 28 | 27 | ||
| @@ -78,15 +77,15 @@ EXPORT_SYMBOL_GPL(ide_timing_find_mode); | |||
| 78 | 77 | ||
| 79 | u16 ide_pio_cycle_time(ide_drive_t *drive, u8 pio) | 78 | u16 ide_pio_cycle_time(ide_drive_t *drive, u8 pio) |
| 80 | { | 79 | { |
| 81 | struct hd_driveid *id = drive->id; | 80 | u16 *id = drive->id; |
| 82 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); | 81 | struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); |
| 83 | u16 cycle = 0; | 82 | u16 cycle = 0; |
| 84 | 83 | ||
| 85 | if (id->field_valid & 2) { | 84 | if (id[ATA_ID_FIELD_VALID] & 2) { |
| 86 | if (id->capability & 8) | 85 | if (ata_id_has_iordy(drive->id)) |
| 87 | cycle = id->eide_pio_iordy; | 86 | cycle = id[ATA_ID_EIDE_PIO_IORDY]; |
| 88 | else | 87 | else |
| 89 | cycle = id->eide_pio; | 88 | cycle = id[ATA_ID_EIDE_PIO]; |
| 90 | 89 | ||
| 91 | /* conservative "downgrade" for all pre-ATA2 drives */ | 90 | /* conservative "downgrade" for all pre-ATA2 drives */ |
| 92 | if (pio < 3 && cycle < t->cycle) | 91 | if (pio < 3 && cycle < t->cycle) |
| @@ -138,7 +137,7 @@ EXPORT_SYMBOL_GPL(ide_timing_merge); | |||
| 138 | int ide_timing_compute(ide_drive_t *drive, u8 speed, | 137 | int ide_timing_compute(ide_drive_t *drive, u8 speed, |
| 139 | struct ide_timing *t, int T, int UT) | 138 | struct ide_timing *t, int T, int UT) |
| 140 | { | 139 | { |
| 141 | struct hd_driveid *id = drive->id; | 140 | u16 *id = drive->id; |
| 142 | struct ide_timing *s, p; | 141 | struct ide_timing *s, p; |
| 143 | 142 | ||
| 144 | /* | 143 | /* |
| @@ -157,16 +156,15 @@ int ide_timing_compute(ide_drive_t *drive, u8 speed, | |||
| 157 | * If the drive is an EIDE drive, it can tell us it needs extended | 156 | * If the drive is an EIDE drive, it can tell us it needs extended |
| 158 | * PIO/MWDMA cycle timing. | 157 | * PIO/MWDMA cycle timing. |
| 159 | */ | 158 | */ |
| 160 | if (id && id->field_valid & 2) { /* EIDE drive */ | 159 | if (id[ATA_ID_FIELD_VALID] & 2) { /* EIDE drive */ |
| 161 | |||
| 162 | memset(&p, 0, sizeof(p)); | 160 | memset(&p, 0, sizeof(p)); |
| 163 | 161 | ||
| 164 | if (speed <= XFER_PIO_2) | 162 | if (speed <= XFER_PIO_2) |
| 165 | p.cycle = p.cyc8b = id->eide_pio; | 163 | p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO]; |
| 166 | else if (speed <= XFER_PIO_5) | 164 | else if (speed <= XFER_PIO_5) |
| 167 | p.cycle = p.cyc8b = id->eide_pio_iordy; | 165 | p.cycle = p.cyc8b = id[ATA_ID_EIDE_PIO_IORDY]; |
| 168 | else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) | 166 | else if (speed >= XFER_MW_DMA_0 && speed <= XFER_MW_DMA_2) |
| 169 | p.cycle = id->eide_dma_min; | 167 | p.cycle = id[ATA_ID_EIDE_DMA_MIN]; |
| 170 | 168 | ||
| 171 | ide_timing_merge(&p, t, t, IDE_TIMING_CYCLE | IDE_TIMING_CYC8B); | 169 | ide_timing_merge(&p, t, t, IDE_TIMING_CYCLE | IDE_TIMING_CYC8B); |
| 172 | } | 170 | } |
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index 772451600e4d..9dcf5aed92cb 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c | |||
| @@ -44,8 +44,6 @@ | |||
| 44 | * inspiration from lots of linux users, esp. hamish@zot.apana.org.au | 44 | * inspiration from lots of linux users, esp. hamish@zot.apana.org.au |
| 45 | */ | 45 | */ |
| 46 | 46 | ||
| 47 | #define _IDE_C /* Tell ide.h it's really us */ | ||
| 48 | |||
| 49 | #include <linux/module.h> | 47 | #include <linux/module.h> |
| 50 | #include <linux/types.h> | 48 | #include <linux/types.h> |
| 51 | #include <linux/string.h> | 49 | #include <linux/string.h> |
| @@ -58,6 +56,7 @@ | |||
| 58 | #include <linux/init.h> | 56 | #include <linux/init.h> |
| 59 | #include <linux/pci.h> | 57 | #include <linux/pci.h> |
| 60 | #include <linux/ide.h> | 58 | #include <linux/ide.h> |
| 59 | #include <linux/hdreg.h> | ||
| 61 | #include <linux/completion.h> | 60 | #include <linux/completion.h> |
| 62 | #include <linux/device.h> | 61 | #include <linux/device.h> |
| 63 | 62 | ||
| @@ -97,8 +96,6 @@ void ide_init_port_data(ide_hwif_t *hwif, unsigned int index) | |||
| 97 | hwif->name[2] = 'e'; | 96 | hwif->name[2] = 'e'; |
| 98 | hwif->name[3] = '0' + index; | 97 | hwif->name[3] = '0' + index; |
| 99 | 98 | ||
| 100 | hwif->bus_state = BUSSTATE_ON; | ||
| 101 | |||
| 102 | init_completion(&hwif->gendev_rel_comp); | 99 | init_completion(&hwif->gendev_rel_comp); |
| 103 | 100 | ||
| 104 | hwif->tp_ops = &default_tp_ops; | 101 | hwif->tp_ops = &default_tp_ops; |
| @@ -119,7 +116,7 @@ static void ide_port_init_devices_data(ide_hwif_t *hwif) | |||
| 119 | drive->media = ide_disk; | 116 | drive->media = ide_disk; |
| 120 | drive->select.all = (unit<<4)|0xa0; | 117 | drive->select.all = (unit<<4)|0xa0; |
| 121 | drive->hwif = hwif; | 118 | drive->hwif = hwif; |
| 122 | drive->ready_stat = READY_STAT; | 119 | drive->ready_stat = ATA_DRDY; |
| 123 | drive->bad_wstat = BAD_W_STAT; | 120 | drive->bad_wstat = BAD_W_STAT; |
| 124 | drive->special.b.recalibrate = 1; | 121 | drive->special.b.recalibrate = 1; |
| 125 | drive->special.b.set_geometry = 1; | 122 | drive->special.b.set_geometry = 1; |
| @@ -253,42 +250,9 @@ void ide_init_port_hw(ide_hwif_t *hwif, hw_regs_t *hw) | |||
| 253 | 250 | ||
| 254 | DEFINE_MUTEX(ide_setting_mtx); | 251 | DEFINE_MUTEX(ide_setting_mtx); |
| 255 | 252 | ||
| 256 | EXPORT_SYMBOL_GPL(ide_setting_mtx); | 253 | ide_devset_get(io_32bit, io_32bit); |
| 257 | |||
| 258 | /** | ||
| 259 | * ide_spin_wait_hwgroup - wait for group | ||
| 260 | * @drive: drive in the group | ||
| 261 | * | ||
| 262 | * Wait for an IDE device group to go non busy and then return | ||
| 263 | * holding the ide_lock which guards the hwgroup->busy status | ||
| 264 | * and right to use it. | ||
| 265 | */ | ||
| 266 | 254 | ||
| 267 | int ide_spin_wait_hwgroup (ide_drive_t *drive) | 255 | static int set_io_32bit(ide_drive_t *drive, int arg) |
| 268 | { | ||
| 269 | ide_hwgroup_t *hwgroup = HWGROUP(drive); | ||
| 270 | unsigned long timeout = jiffies + (3 * HZ); | ||
| 271 | |||
| 272 | spin_lock_irq(&ide_lock); | ||
| 273 | |||
| 274 | while (hwgroup->busy) { | ||
| 275 | unsigned long lflags; | ||
| 276 | spin_unlock_irq(&ide_lock); | ||
| 277 | local_irq_set(lflags); | ||
| 278 | if (time_after(jiffies, timeout)) { | ||
| 279 | local_irq_restore(lflags); | ||
| 280 | printk(KERN_ERR "%s: channel busy\n", drive->name); | ||
| 281 | return -EBUSY; | ||
| 282 | } | ||
| 283 | local_irq_restore(lflags); | ||
| 284 | spin_lock_irq(&ide_lock); | ||
| 285 | } | ||
| 286 | return 0; | ||
| 287 | } | ||
| 288 | |||
| 289 | EXPORT_SYMBOL(ide_spin_wait_hwgroup); | ||
| 290 | |||
| 291 | int set_io_32bit(ide_drive_t *drive, int arg) | ||
| 292 | { | 256 | { |
| 293 | if (drive->no_io_32bit) | 257 | if (drive->no_io_32bit) |
| 294 | return -EPERM; | 258 | return -EPERM; |
| @@ -296,53 +260,39 @@ int set_io_32bit(ide_drive_t *drive, int arg) | |||
| 296 | if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1)) | 260 | if (arg < 0 || arg > 1 + (SUPPORT_VLB_SYNC << 1)) |
| 297 | return -EINVAL; | 261 | return -EINVAL; |
| 298 | 262 | ||
| 299 | if (ide_spin_wait_hwgroup(drive)) | ||
| 300 | return -EBUSY; | ||
| 301 | |||
| 302 | drive->io_32bit = arg; | 263 | drive->io_32bit = arg; |
| 303 | 264 | ||
| 304 | spin_unlock_irq(&ide_lock); | ||
| 305 | |||
| 306 | return 0; | 265 | return 0; |
| 307 | } | 266 | } |
| 308 | 267 | ||
| 268 | ide_devset_get(ksettings, keep_settings); | ||
| 269 | |||
| 309 | static int set_ksettings(ide_drive_t *drive, int arg) | 270 | static int set_ksettings(ide_drive_t *drive, int arg) |
| 310 | { | 271 | { |
| 311 | if (arg < 0 || arg > 1) | 272 | if (arg < 0 || arg > 1) |
| 312 | return -EINVAL; | 273 | return -EINVAL; |
| 313 | 274 | ||
| 314 | if (ide_spin_wait_hwgroup(drive)) | ||
| 315 | return -EBUSY; | ||
| 316 | drive->keep_settings = arg; | 275 | drive->keep_settings = arg; |
| 317 | spin_unlock_irq(&ide_lock); | ||
| 318 | 276 | ||
| 319 | return 0; | 277 | return 0; |
| 320 | } | 278 | } |
| 321 | 279 | ||
| 322 | int set_using_dma(ide_drive_t *drive, int arg) | 280 | ide_devset_get(using_dma, using_dma); |
| 281 | |||
| 282 | static int set_using_dma(ide_drive_t *drive, int arg) | ||
| 323 | { | 283 | { |
| 324 | #ifdef CONFIG_BLK_DEV_IDEDMA | 284 | #ifdef CONFIG_BLK_DEV_IDEDMA |
| 325 | ide_hwif_t *hwif = drive->hwif; | ||
| 326 | int err = -EPERM; | 285 | int err = -EPERM; |
| 327 | 286 | ||
| 328 | if (arg < 0 || arg > 1) | 287 | if (arg < 0 || arg > 1) |
| 329 | return -EINVAL; | 288 | return -EINVAL; |
| 330 | 289 | ||
| 331 | if (!drive->id || !(drive->id->capability & 1)) | 290 | if (ata_id_has_dma(drive->id) == 0) |
| 332 | goto out; | 291 | goto out; |
| 333 | 292 | ||
| 334 | if (hwif->dma_ops == NULL) | 293 | if (drive->hwif->dma_ops == NULL) |
| 335 | goto out; | 294 | goto out; |
| 336 | 295 | ||
| 337 | err = -EBUSY; | ||
| 338 | if (ide_spin_wait_hwgroup(drive)) | ||
| 339 | goto out; | ||
| 340 | /* | ||
| 341 | * set ->busy flag, unlock and let it ride | ||
| 342 | */ | ||
| 343 | hwif->hwgroup->busy = 1; | ||
| 344 | spin_unlock_irq(&ide_lock); | ||
| 345 | |||
| 346 | err = 0; | 296 | err = 0; |
| 347 | 297 | ||
| 348 | if (arg) { | 298 | if (arg) { |
| @@ -351,12 +301,6 @@ int set_using_dma(ide_drive_t *drive, int arg) | |||
| 351 | } else | 301 | } else |
| 352 | ide_dma_off(drive); | 302 | ide_dma_off(drive); |
| 353 | 303 | ||
| 354 | /* | ||
| 355 | * lock, clear ->busy flag and unlock before leaving | ||
| 356 | */ | ||
| 357 | spin_lock_irq(&ide_lock); | ||
| 358 | hwif->hwgroup->busy = 0; | ||
| 359 | spin_unlock_irq(&ide_lock); | ||
| 360 | out: | 304 | out: |
| 361 | return err; | 305 | return err; |
| 362 | #else | 306 | #else |
| @@ -367,7 +311,7 @@ out: | |||
| 367 | #endif | 311 | #endif |
| 368 | } | 312 | } |
| 369 | 313 | ||
| 370 | int set_pio_mode(ide_drive_t *drive, int arg) | 314 | static int set_pio_mode(ide_drive_t *drive, int arg) |
| 371 | { | 315 | { |
| 372 | struct request *rq; | 316 | struct request *rq; |
| 373 | ide_hwif_t *hwif = drive->hwif; | 317 | ide_hwif_t *hwif = drive->hwif; |
| @@ -395,6 +339,8 @@ int set_pio_mode(ide_drive_t *drive, int arg) | |||
| 395 | return 0; | 339 | return 0; |
| 396 | } | 340 | } |
| 397 | 341 | ||
| 342 | ide_devset_get(unmaskirq, unmask); | ||
| 343 | |||
| 398 | static int set_unmaskirq(ide_drive_t *drive, int arg) | 344 | static int set_unmaskirq(ide_drive_t *drive, int arg) |
| 399 | { | 345 | { |
| 400 | if (drive->no_unmask) | 346 | if (drive->no_unmask) |
| @@ -403,14 +349,20 @@ static int set_unmaskirq(ide_drive_t *drive, int arg) | |||
| 403 | if (arg < 0 || arg > 1) | 349 | if (arg < 0 || arg > 1) |
| 404 | return -EINVAL; | 350 | return -EINVAL; |
| 405 | 351 | ||
| 406 | if (ide_spin_wait_hwgroup(drive)) | ||
| 407 | return -EBUSY; | ||
| 408 | drive->unmask = arg; | 352 | drive->unmask = arg; |
| 409 | spin_unlock_irq(&ide_lock); | ||
| 410 | 353 | ||
| 411 | return 0; | 354 | return 0; |
| 412 | } | 355 | } |
| 413 | 356 | ||
| 357 | #define ide_gen_devset_rw(_name, _func) \ | ||
| 358 | __IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) | ||
| 359 | |||
| 360 | ide_gen_devset_rw(io_32bit, io_32bit); | ||
| 361 | ide_gen_devset_rw(keepsettings, ksettings); | ||
| 362 | ide_gen_devset_rw(unmaskirq, unmaskirq); | ||
| 363 | ide_gen_devset_rw(using_dma, using_dma); | ||
| 364 | __IDE_DEVSET(pio_mode, 0, NULL, set_pio_mode); | ||
| 365 | |||
| 414 | static int generic_ide_suspend(struct device *dev, pm_message_t mesg) | 366 | static int generic_ide_suspend(struct device *dev, pm_message_t mesg) |
| 415 | { | 367 | { |
| 416 | ide_drive_t *drive = dev->driver_data; | 368 | ide_drive_t *drive = dev->driver_data; |
| @@ -486,138 +438,6 @@ static int generic_ide_resume(struct device *dev) | |||
| 486 | return err; | 438 | return err; |
| 487 | } | 439 | } |
| 488 | 440 | ||
| 489 | static int generic_drive_reset(ide_drive_t *drive) | ||
| 490 | { | ||
| 491 | struct request *rq; | ||
| 492 | int ret = 0; | ||
| 493 | |||
| 494 | rq = blk_get_request(drive->queue, READ, __GFP_WAIT); | ||
| 495 | rq->cmd_type = REQ_TYPE_SPECIAL; | ||
| 496 | rq->cmd_len = 1; | ||
| 497 | rq->cmd[0] = REQ_DRIVE_RESET; | ||
| 498 | rq->cmd_flags |= REQ_SOFTBARRIER; | ||
| 499 | if (blk_execute_rq(drive->queue, NULL, rq, 1)) | ||
| 500 | ret = rq->errors; | ||
| 501 | blk_put_request(rq); | ||
| 502 | return ret; | ||
| 503 | } | ||
| 504 | |||
| 505 | int generic_ide_ioctl(ide_drive_t *drive, struct file *file, struct block_device *bdev, | ||
| 506 | unsigned int cmd, unsigned long arg) | ||
| 507 | { | ||
| 508 | unsigned long flags; | ||
| 509 | ide_driver_t *drv; | ||
| 510 | void __user *p = (void __user *)arg; | ||
| 511 | int err = 0, (*setfunc)(ide_drive_t *, int); | ||
| 512 | u8 *val; | ||
| 513 | |||
| 514 | switch (cmd) { | ||
| 515 | case HDIO_GET_32BIT: val = &drive->io_32bit; goto read_val; | ||
| 516 | case HDIO_GET_KEEPSETTINGS: val = &drive->keep_settings; goto read_val; | ||
| 517 | case HDIO_GET_UNMASKINTR: val = &drive->unmask; goto read_val; | ||
| 518 | case HDIO_GET_DMA: val = &drive->using_dma; goto read_val; | ||
| 519 | case HDIO_SET_32BIT: setfunc = set_io_32bit; goto set_val; | ||
| 520 | case HDIO_SET_KEEPSETTINGS: setfunc = set_ksettings; goto set_val; | ||
| 521 | case HDIO_SET_PIO_MODE: setfunc = set_pio_mode; goto set_val; | ||
| 522 | case HDIO_SET_UNMASKINTR: setfunc = set_unmaskirq; goto set_val; | ||
| 523 | case HDIO_SET_DMA: setfunc = set_using_dma; goto set_val; | ||
| 524 | } | ||
| 525 | |||
| 526 | switch (cmd) { | ||
| 527 | case HDIO_OBSOLETE_IDENTITY: | ||
| 528 | case HDIO_GET_IDENTITY: | ||
| 529 | if (bdev != bdev->bd_contains) | ||
| 530 | return -EINVAL; | ||
| 531 | if (drive->id_read == 0) | ||
| 532 | return -ENOMSG; | ||
| 533 | if (copy_to_user(p, drive->id, (cmd == HDIO_GET_IDENTITY) ? sizeof(*drive->id) : 142)) | ||
| 534 | return -EFAULT; | ||
| 535 | return 0; | ||
| 536 | |||
| 537 | case HDIO_GET_NICE: | ||
| 538 | return put_user(drive->dsc_overlap << IDE_NICE_DSC_OVERLAP | | ||
| 539 | drive->atapi_overlap << IDE_NICE_ATAPI_OVERLAP | | ||
| 540 | drive->nice1 << IDE_NICE_1, | ||
| 541 | (long __user *) arg); | ||
| 542 | #ifdef CONFIG_IDE_TASK_IOCTL | ||
| 543 | case HDIO_DRIVE_TASKFILE: | ||
| 544 | if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SYS_RAWIO)) | ||
| 545 | return -EACCES; | ||
| 546 | switch(drive->media) { | ||
| 547 | case ide_disk: | ||
| 548 | return ide_taskfile_ioctl(drive, cmd, arg); | ||
| 549 | default: | ||
| 550 | return -ENOMSG; | ||
| 551 | } | ||
| 552 | #endif /* CONFIG_IDE_TASK_IOCTL */ | ||
| 553 | |||
| 554 | case HDIO_DRIVE_CMD: | ||
| 555 | if (!capable(CAP_SYS_RAWIO)) | ||
| 556 | return -EACCES; | ||
| 557 | return ide_cmd_ioctl(drive, cmd, arg); | ||
| 558 | |||
| 559 | case HDIO_DRIVE_TASK: | ||
| 560 | if (!capable(CAP_SYS_RAWIO)) | ||
| 561 | return -EACCES; | ||
| 562 | return ide_task_ioctl(drive, cmd, arg); | ||
| 563 | case HDIO_SET_NICE: | ||
| 564 | if (!capable(CAP_SYS_ADMIN)) return -EACCES; | ||
| 565 | if (arg != (arg & ((1 << IDE_NICE_DSC_OVERLAP) | (1 << IDE_NICE_1)))) | ||
| 566 | return -EPERM; | ||
| 567 | drive->dsc_overlap = (arg >> IDE_NICE_DSC_OVERLAP) & 1; | ||
| 568 | drv = *(ide_driver_t **)bdev->bd_disk->private_data; | ||
| 569 | if (drive->dsc_overlap && !drv->supports_dsc_overlap) { | ||
| 570 | drive->dsc_overlap = 0; | ||
| 571 | return -EPERM; | ||
| 572 | } | ||
| 573 | drive->nice1 = (arg >> IDE_NICE_1) & 1; | ||
| 574 | return 0; | ||
| 575 | case HDIO_DRIVE_RESET: | ||
| 576 | if (!capable(CAP_SYS_ADMIN)) | ||
| 577 | return -EACCES; | ||
| 578 | |||
| 579 | return generic_drive_reset(drive); | ||
| 580 | |||
| 581 | case HDIO_GET_BUSSTATE: | ||
| 582 | if (!capable(CAP_SYS_ADMIN)) | ||
| 583 | return -EACCES; | ||
| 584 | if (put_user(HWIF(drive)->bus_state, (long __user *)arg)) | ||
| 585 | return -EFAULT; | ||
| 586 | return 0; | ||
| 587 | |||
| 588 | case HDIO_SET_BUSSTATE: | ||
| 589 | if (!capable(CAP_SYS_ADMIN)) | ||
| 590 | return -EACCES; | ||
| 591 | return -EOPNOTSUPP; | ||
| 592 | default: | ||
| 593 | return -EINVAL; | ||
| 594 | } | ||
| 595 | |||
| 596 | read_val: | ||
| 597 | mutex_lock(&ide_setting_mtx); | ||
| 598 | spin_lock_irqsave(&ide_lock, flags); | ||
| 599 | err = *val; | ||
| 600 | spin_unlock_irqrestore(&ide_lock, flags); | ||
| 601 | mutex_unlock(&ide_setting_mtx); | ||
| 602 | return err >= 0 ? put_user(err, (long __user *)arg) : err; | ||
| 603 | |||
| 604 | set_val: | ||
| 605 | if (bdev != bdev->bd_contains) | ||
| 606 | err = -EINVAL; | ||
| 607 | else { | ||
| 608 | if (!capable(CAP_SYS_ADMIN)) | ||
| 609 | err = -EACCES; | ||
| 610 | else { | ||
| 611 | mutex_lock(&ide_setting_mtx); | ||
| 612 | err = setfunc(drive, arg); | ||
| 613 | mutex_unlock(&ide_setting_mtx); | ||
| 614 | } | ||
| 615 | } | ||
| 616 | return err; | ||
| 617 | } | ||
| 618 | |||
| 619 | EXPORT_SYMBOL(generic_ide_ioctl); | ||
| 620 | |||
| 621 | /** | 441 | /** |
| 622 | * ide_device_get - get an additional reference to a ide_drive_t | 442 | * ide_device_get - get an additional reference to a ide_drive_t |
| 623 | * @drive: device to get a reference to | 443 | * @drive: device to get a reference to |
| @@ -710,21 +530,21 @@ static ssize_t model_show(struct device *dev, struct device_attribute *attr, | |||
| 710 | char *buf) | 530 | char *buf) |
| 711 | { | 531 | { |
| 712 | ide_drive_t *drive = to_ide_device(dev); | 532 | ide_drive_t *drive = to_ide_device(dev); |
| 713 | return sprintf(buf, "%s\n", drive->id->model); | 533 | return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_PROD]); |
| 714 | } | 534 | } |
| 715 | 535 | ||
| 716 | static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, | 536 | static ssize_t firmware_show(struct device *dev, struct device_attribute *attr, |
| 717 | char *buf) | 537 | char *buf) |
| 718 | { | 538 | { |
| 719 | ide_drive_t *drive = to_ide_device(dev); | 539 | ide_drive_t *drive = to_ide_device(dev); |
| 720 | return sprintf(buf, "%s\n", drive->id->fw_rev); | 540 | return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_FW_REV]); |
| 721 | } | 541 | } |
| 722 | 542 | ||
| 723 | static ssize_t serial_show(struct device *dev, struct device_attribute *attr, | 543 | static ssize_t serial_show(struct device *dev, struct device_attribute *attr, |
| 724 | char *buf) | 544 | char *buf) |
| 725 | { | 545 | { |
| 726 | ide_drive_t *drive = to_ide_device(dev); | 546 | ide_drive_t *drive = to_ide_device(dev); |
| 727 | return sprintf(buf, "%s\n", drive->id->serial_no); | 547 | return sprintf(buf, "%s\n", (char *)&drive->id[ATA_ID_SERNO]); |
| 728 | } | 548 | } |
| 729 | 549 | ||
| 730 | static struct device_attribute ide_dev_attrs[] = { | 550 | static struct device_attribute ide_dev_attrs[] = { |
| @@ -841,7 +661,7 @@ MODULE_PARM_DESC(noprobe, "skip probing for a device"); | |||
| 841 | static unsigned int ide_nowerr; | 661 | static unsigned int ide_nowerr; |
| 842 | 662 | ||
| 843 | module_param_call(nowerr, ide_set_dev_param_mask, NULL, &ide_nowerr, 0); | 663 | module_param_call(nowerr, ide_set_dev_param_mask, NULL, &ide_nowerr, 0); |
| 844 | MODULE_PARM_DESC(nowerr, "ignore the WRERR_STAT bit for a device"); | 664 | MODULE_PARM_DESC(nowerr, "ignore the ATA_DF bit for a device"); |
| 845 | 665 | ||
| 846 | static unsigned int ide_cdroms; | 666 | static unsigned int ide_cdroms; |
| 847 | 667 | ||
| @@ -906,7 +726,7 @@ static void ide_dev_apply_params(ide_drive_t *drive) | |||
| 906 | drive->noprobe = 1; | 726 | drive->noprobe = 1; |
| 907 | } | 727 | } |
| 908 | if (ide_nowerr & (1 << i)) { | 728 | if (ide_nowerr & (1 << i)) { |
| 909 | printk(KERN_INFO "ide: ignoring the WRERR_STAT bit for %s\n", | 729 | printk(KERN_INFO "ide: ignoring the ATA_DF bit for %s\n", |
| 910 | drive->name); | 730 | drive->name); |
| 911 | drive->bad_wstat = BAD_R_STAT; | 731 | drive->bad_wstat = BAD_R_STAT; |
| 912 | } | 732 | } |
| @@ -927,7 +747,7 @@ static void ide_dev_apply_params(ide_drive_t *drive) | |||
| 927 | drive->cyl, drive->head, drive->sect); | 747 | drive->cyl, drive->head, drive->sect); |
| 928 | drive->present = 1; | 748 | drive->present = 1; |
| 929 | drive->media = ide_disk; | 749 | drive->media = ide_disk; |
| 930 | drive->ready_stat = READY_STAT; | 750 | drive->ready_stat = ATA_DRDY; |
| 931 | } | 751 | } |
| 932 | } | 752 | } |
| 933 | 753 | ||
diff --git a/drivers/ide/legacy/ali14xx.c b/drivers/ide/legacy/ali14xx.c index 4ec19737f3c5..7276c96aaa2a 100644 --- a/drivers/ide/legacy/ali14xx.c +++ b/drivers/ide/legacy/ali14xx.c | |||
| @@ -43,7 +43,6 @@ | |||
| 43 | #include <linux/mm.h> | 43 | #include <linux/mm.h> |
| 44 | #include <linux/ioport.h> | 44 | #include <linux/ioport.h> |
| 45 | #include <linux/blkdev.h> | 45 | #include <linux/blkdev.h> |
| 46 | #include <linux/hdreg.h> | ||
| 47 | #include <linux/ide.h> | 46 | #include <linux/ide.h> |
| 48 | #include <linux/init.h> | 47 | #include <linux/init.h> |
| 49 | 48 | ||
diff --git a/drivers/ide/legacy/buddha.c b/drivers/ide/legacy/buddha.c index 7c2afa97f417..c5a3c9ef6a5d 100644 --- a/drivers/ide/legacy/buddha.c +++ b/drivers/ide/legacy/buddha.c | |||
| @@ -20,7 +20,6 @@ | |||
| 20 | #include <linux/mm.h> | 20 | #include <linux/mm.h> |
| 21 | #include <linux/interrupt.h> | 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
| 23 | #include <linux/hdreg.h> | ||
| 24 | #include <linux/zorro.h> | 23 | #include <linux/zorro.h> |
| 25 | #include <linux/ide.h> | 24 | #include <linux/ide.h> |
| 26 | #include <linux/init.h> | 25 | #include <linux/init.h> |
diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c index af791a02a120..689b2e493413 100644 --- a/drivers/ide/legacy/dtc2278.c +++ b/drivers/ide/legacy/dtc2278.c | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | #include <linux/mm.h> | 10 | #include <linux/mm.h> |
| 11 | #include <linux/ioport.h> | 11 | #include <linux/ioport.h> |
| 12 | #include <linux/blkdev.h> | 12 | #include <linux/blkdev.h> |
| 13 | #include <linux/hdreg.h> | ||
| 14 | #include <linux/ide.h> | 13 | #include <linux/ide.h> |
| 15 | #include <linux/init.h> | 14 | #include <linux/init.h> |
| 16 | 15 | ||
diff --git a/drivers/ide/legacy/falconide.c b/drivers/ide/legacy/falconide.c index 724f95073d80..39d500d84b07 100644 --- a/drivers/ide/legacy/falconide.c +++ b/drivers/ide/legacy/falconide.c | |||
| @@ -13,7 +13,6 @@ | |||
| 13 | #include <linux/mm.h> | 13 | #include <linux/mm.h> |
| 14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
| 15 | #include <linux/blkdev.h> | 15 | #include <linux/blkdev.h> |
| 16 | #include <linux/hdreg.h> | ||
| 17 | #include <linux/ide.h> | 16 | #include <linux/ide.h> |
| 18 | #include <linux/init.h> | 17 | #include <linux/init.h> |
| 19 | 18 | ||
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c index 51ba085d7aa8..691506886561 100644 --- a/drivers/ide/legacy/gayle.c +++ b/drivers/ide/legacy/gayle.c | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include <linux/mm.h> | 12 | #include <linux/mm.h> |
| 13 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/blkdev.h> | 14 | #include <linux/blkdev.h> |
| 15 | #include <linux/hdreg.h> | ||
| 16 | #include <linux/ide.h> | 15 | #include <linux/ide.h> |
| 17 | #include <linux/init.h> | 16 | #include <linux/init.h> |
| 18 | #include <linux/zorro.h> | 17 | #include <linux/zorro.h> |
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c index 98f7c95e39ed..5123ea291d07 100644 --- a/drivers/ide/legacy/ht6560b.c +++ b/drivers/ide/legacy/ht6560b.c | |||
| @@ -24,7 +24,6 @@ | |||
| 24 | #include <linux/mm.h> | 24 | #include <linux/mm.h> |
| 25 | #include <linux/ioport.h> | 25 | #include <linux/ioport.h> |
| 26 | #include <linux/blkdev.h> | 26 | #include <linux/blkdev.h> |
| 27 | #include <linux/hdreg.h> | ||
| 28 | #include <linux/ide.h> | 27 | #include <linux/ide.h> |
| 29 | #include <linux/init.h> | 28 | #include <linux/init.h> |
| 30 | 29 | ||
diff --git a/drivers/ide/legacy/ide-cs.c b/drivers/ide/legacy/ide-cs.c index 21bfac137844..ee6fc30d5e2b 100644 --- a/drivers/ide/legacy/ide-cs.c +++ b/drivers/ide/legacy/ide-cs.c | |||
| @@ -38,7 +38,6 @@ | |||
| 38 | #include <linux/timer.h> | 38 | #include <linux/timer.h> |
| 39 | #include <linux/ioport.h> | 39 | #include <linux/ioport.h> |
| 40 | #include <linux/ide.h> | 40 | #include <linux/ide.h> |
| 41 | #include <linux/hdreg.h> | ||
| 42 | #include <linux/major.h> | 41 | #include <linux/major.h> |
| 43 | #include <linux/delay.h> | 42 | #include <linux/delay.h> |
| 44 | #include <asm/io.h> | 43 | #include <asm/io.h> |
diff --git a/drivers/ide/legacy/macide.c b/drivers/ide/legacy/macide.c index a0bb167980e7..43f97cc1d30e 100644 --- a/drivers/ide/legacy/macide.c +++ b/drivers/ide/legacy/macide.c | |||
| @@ -15,7 +15,6 @@ | |||
| 15 | #include <linux/mm.h> | 15 | #include <linux/mm.h> |
| 16 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
| 17 | #include <linux/blkdev.h> | 17 | #include <linux/blkdev.h> |
| 18 | #include <linux/hdreg.h> | ||
| 19 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
| 20 | #include <linux/ide.h> | 19 | #include <linux/ide.h> |
| 21 | 20 | ||
diff --git a/drivers/ide/legacy/q40ide.c b/drivers/ide/legacy/q40ide.c index 4abd8fc78197..4af4a8ce4cdf 100644 --- a/drivers/ide/legacy/q40ide.c +++ b/drivers/ide/legacy/q40ide.c | |||
| @@ -14,8 +14,6 @@ | |||
| 14 | #include <linux/mm.h> | 14 | #include <linux/mm.h> |
| 15 | #include <linux/interrupt.h> | 15 | #include <linux/interrupt.h> |
| 16 | #include <linux/blkdev.h> | 16 | #include <linux/blkdev.h> |
| 17 | #include <linux/hdreg.h> | ||
| 18 | |||
| 19 | #include <linux/ide.h> | 17 | #include <linux/ide.h> |
| 20 | 18 | ||
| 21 | /* | 19 | /* |
diff --git a/drivers/ide/legacy/qd65xx.c b/drivers/ide/legacy/qd65xx.c index 2338f344ea24..ec408b3a7100 100644 --- a/drivers/ide/legacy/qd65xx.c +++ b/drivers/ide/legacy/qd65xx.c | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | #include <linux/mm.h> | 27 | #include <linux/mm.h> |
| 28 | #include <linux/ioport.h> | 28 | #include <linux/ioport.h> |
| 29 | #include <linux/blkdev.h> | 29 | #include <linux/blkdev.h> |
| 30 | #include <linux/hdreg.h> | ||
| 31 | #include <linux/ide.h> | 30 | #include <linux/ide.h> |
| 32 | #include <linux/init.h> | 31 | #include <linux/init.h> |
| 33 | #include <asm/system.h> | 32 | #include <asm/system.h> |
| @@ -151,12 +150,14 @@ static int qd_find_disk_type (ide_drive_t *drive, | |||
| 151 | int *active_time, int *recovery_time) | 150 | int *active_time, int *recovery_time) |
| 152 | { | 151 | { |
| 153 | struct qd65xx_timing_s *p; | 152 | struct qd65xx_timing_s *p; |
| 154 | char model[40]; | 153 | char *m = (char *)&drive->id[ATA_ID_PROD]; |
| 154 | char model[ATA_ID_PROD_LEN]; | ||
| 155 | 155 | ||
| 156 | if (!*drive->id->model) return 0; | 156 | if (*m == 0) |
| 157 | return 0; | ||
| 157 | 158 | ||
| 158 | strncpy(model,drive->id->model,40); | 159 | strncpy(model, m, ATA_ID_PROD_LEN); |
| 159 | ide_fixstring(model,40,1); /* byte-swap */ | 160 | ide_fixstring(model, ATA_ID_PROD_LEN, 1); /* byte-swap */ |
| 160 | 161 | ||
| 161 | for (p = qd65xx_timing ; p->offset != -1 ; p++) { | 162 | for (p = qd65xx_timing ; p->offset != -1 ; p++) { |
| 162 | if (!strncmp(p->model, model+p->offset, 4)) { | 163 | if (!strncmp(p->model, model+p->offset, 4)) { |
| @@ -185,20 +186,20 @@ static void qd_set_timing (ide_drive_t *drive, u8 timing) | |||
| 185 | 186 | ||
| 186 | static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio) | 187 | static void qd6500_set_pio_mode(ide_drive_t *drive, const u8 pio) |
| 187 | { | 188 | { |
| 189 | u16 *id = drive->id; | ||
| 188 | int active_time = 175; | 190 | int active_time = 175; |
| 189 | int recovery_time = 415; /* worst case values from the dos driver */ | 191 | int recovery_time = 415; /* worst case values from the dos driver */ |
| 190 | 192 | ||
| 191 | /* | 193 | /* |
| 192 | * FIXME: use "pio" value | 194 | * FIXME: use "pio" value |
| 193 | */ | 195 | */ |
| 194 | if (drive->id && !qd_find_disk_type(drive, &active_time, &recovery_time) | 196 | if (!qd_find_disk_type(drive, &active_time, &recovery_time) && |
| 195 | && drive->id->tPIO && (drive->id->field_valid & 0x02) | 197 | (id[ATA_ID_OLD_PIO_MODES] & 0xff) && (id[ATA_ID_FIELD_VALID] & 2) && |
| 196 | && drive->id->eide_pio >= 240) { | 198 | id[ATA_ID_EIDE_PIO] >= 240) { |
| 197 | |||
| 198 | printk(KERN_INFO "%s: PIO mode%d\n", drive->name, | 199 | printk(KERN_INFO "%s: PIO mode%d\n", drive->name, |
| 199 | drive->id->tPIO); | 200 | id[ATA_ID_OLD_PIO_MODES] & 0xff); |
| 200 | active_time = 110; | 201 | active_time = 110; |
| 201 | recovery_time = drive->id->eide_pio - 120; | 202 | recovery_time = drive->id[ATA_ID_EIDE_PIO] - 120; |
| 202 | } | 203 | } |
| 203 | 204 | ||
| 204 | qd_set_timing(drive, qd6500_compute_timing(HWIF(drive), active_time, recovery_time)); | 205 | qd_set_timing(drive, qd6500_compute_timing(HWIF(drive), active_time, recovery_time)); |
diff --git a/drivers/ide/legacy/umc8672.c b/drivers/ide/legacy/umc8672.c index b54a14a57755..1da076e0c917 100644 --- a/drivers/ide/legacy/umc8672.c +++ b/drivers/ide/legacy/umc8672.c | |||
| @@ -45,7 +45,6 @@ | |||
| 45 | #include <linux/mm.h> | 45 | #include <linux/mm.h> |
| 46 | #include <linux/ioport.h> | 46 | #include <linux/ioport.h> |
| 47 | #include <linux/blkdev.h> | 47 | #include <linux/blkdev.h> |
| 48 | #include <linux/hdreg.h> | ||
| 49 | #include <linux/ide.h> | 48 | #include <linux/ide.h> |
| 50 | #include <linux/init.h> | 49 | #include <linux/init.h> |
| 51 | 50 | ||
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c index 3187215e8f89..e7475ba559c7 100644 --- a/drivers/ide/pci/aec62xx.c +++ b/drivers/ide/pci/aec62xx.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
| 8 | #include <linux/types.h> | 8 | #include <linux/types.h> |
| 9 | #include <linux/pci.h> | 9 | #include <linux/pci.h> |
| 10 | #include <linux/hdreg.h> | ||
| 11 | #include <linux/ide.h> | 10 | #include <linux/ide.h> |
| 12 | #include <linux/init.h> | 11 | #include <linux/init.h> |
| 13 | 12 | ||
| @@ -140,7 +139,7 @@ static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 140 | drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); | 139 | drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); |
| 141 | } | 140 | } |
| 142 | 141 | ||
| 143 | static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev) | 142 | static unsigned int init_chipset_aec62xx(struct pci_dev *dev) |
| 144 | { | 143 | { |
| 145 | /* These are necessary to get AEC6280 Macintosh cards to work */ | 144 | /* These are necessary to get AEC6280 Macintosh cards to work */ |
| 146 | if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) || | 145 | if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) || |
| @@ -308,6 +307,8 @@ static struct pci_driver driver = { | |||
| 308 | .id_table = aec62xx_pci_tbl, | 307 | .id_table = aec62xx_pci_tbl, |
| 309 | .probe = aec62xx_init_one, | 308 | .probe = aec62xx_init_one, |
| 310 | .remove = __devexit_p(aec62xx_remove), | 309 | .remove = __devexit_p(aec62xx_remove), |
| 310 | .suspend = ide_pci_suspend, | ||
| 311 | .resume = ide_pci_resume, | ||
| 311 | }; | 312 | }; |
| 312 | 313 | ||
| 313 | static int __init aec62xx_ide_init(void) | 314 | static int __init aec62xx_ide_init(void) |
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index d647526af557..053c75263918 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c | |||
| @@ -31,7 +31,6 @@ | |||
| 31 | #include <linux/types.h> | 31 | #include <linux/types.h> |
| 32 | #include <linux/kernel.h> | 32 | #include <linux/kernel.h> |
| 33 | #include <linux/pci.h> | 33 | #include <linux/pci.h> |
| 34 | #include <linux/hdreg.h> | ||
| 35 | #include <linux/ide.h> | 34 | #include <linux/ide.h> |
| 36 | #include <linux/init.h> | 35 | #include <linux/init.h> |
| 37 | #include <linux/dmi.h> | 36 | #include <linux/dmi.h> |
| @@ -134,8 +133,8 @@ static u8 ali_udma_filter(ide_drive_t *drive) | |||
| 134 | if (m5229_revision > 0x20 && m5229_revision < 0xC2) { | 133 | if (m5229_revision > 0x20 && m5229_revision < 0xC2) { |
| 135 | if (drive->media != ide_disk) | 134 | if (drive->media != ide_disk) |
| 136 | return 0; | 135 | return 0; |
| 137 | if (chip_is_1543c_e && strstr(drive->id->model, "WDC ") && | 136 | if (wdc_udma == 0 && chip_is_1543c_e && |
| 138 | wdc_udma == 0) | 137 | strstr((char *)&drive->id[ATA_ID_PROD], "WDC ")) |
| 139 | return 0; | 138 | return 0; |
| 140 | } | 139 | } |
| 141 | 140 | ||
| @@ -214,7 +213,7 @@ static int ali15x3_dma_setup(ide_drive_t *drive) | |||
| 214 | * appropriate also sets up the 1533 southbridge. | 213 | * appropriate also sets up the 1533 southbridge. |
| 215 | */ | 214 | */ |
| 216 | 215 | ||
| 217 | static unsigned int __devinit init_chipset_ali15x3(struct pci_dev *dev) | 216 | static unsigned int init_chipset_ali15x3(struct pci_dev *dev) |
| 218 | { | 217 | { |
| 219 | unsigned long flags; | 218 | unsigned long flags; |
| 220 | u8 tmpbyte; | 219 | u8 tmpbyte; |
| @@ -582,6 +581,8 @@ static struct pci_driver driver = { | |||
| 582 | .id_table = alim15x3_pci_tbl, | 581 | .id_table = alim15x3_pci_tbl, |
| 583 | .probe = alim15x3_init_one, | 582 | .probe = alim15x3_init_one, |
| 584 | .remove = ide_pci_remove, | 583 | .remove = ide_pci_remove, |
| 584 | .suspend = ide_pci_suspend, | ||
| 585 | .resume = ide_pci_resume, | ||
| 585 | }; | 586 | }; |
| 586 | 587 | ||
| 587 | static int __init ali15x3_ide_init(void) | 588 | static int __init ali15x3_ide_init(void) |
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c index 1e66a960a96a..824471f91bf5 100644 --- a/drivers/ide/pci/amd74xx.c +++ b/drivers/ide/pci/amd74xx.c | |||
| @@ -112,13 +112,13 @@ static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 112 | amd_set_drive(drive, XFER_PIO_0 + pio); | 112 | amd_set_drive(drive, XFER_PIO_0 + pio); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | static void __devinit amd7409_cable_detect(struct pci_dev *dev) | 115 | static void amd7409_cable_detect(struct pci_dev *dev) |
| 116 | { | 116 | { |
| 117 | /* no host side cable detection */ | 117 | /* no host side cable detection */ |
| 118 | amd_80w = 0x03; | 118 | amd_80w = 0x03; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | static void __devinit amd7411_cable_detect(struct pci_dev *dev) | 121 | static void amd7411_cable_detect(struct pci_dev *dev) |
| 122 | { | 122 | { |
| 123 | int i; | 123 | int i; |
| 124 | u32 u = 0; | 124 | u32 u = 0; |
| @@ -140,7 +140,7 @@ static void __devinit amd7411_cable_detect(struct pci_dev *dev) | |||
| 140 | * The initialization callback. Initialize drive independent registers. | 140 | * The initialization callback. Initialize drive independent registers. |
| 141 | */ | 141 | */ |
| 142 | 142 | ||
| 143 | static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev) | 143 | static unsigned int init_chipset_amd74xx(struct pci_dev *dev) |
| 144 | { | 144 | { |
| 145 | u8 t = 0, offset = amd_offset(dev); | 145 | u8 t = 0, offset = amd_offset(dev); |
| 146 | 146 | ||
| @@ -324,6 +324,8 @@ static struct pci_driver driver = { | |||
| 324 | .id_table = amd74xx_pci_tbl, | 324 | .id_table = amd74xx_pci_tbl, |
| 325 | .probe = amd74xx_probe, | 325 | .probe = amd74xx_probe, |
| 326 | .remove = ide_pci_remove, | 326 | .remove = ide_pci_remove, |
| 327 | .suspend = ide_pci_suspend, | ||
| 328 | .resume = ide_pci_resume, | ||
| 327 | }; | 329 | }; |
| 328 | 330 | ||
| 329 | static int __init amd74xx_ide_init(void) | 331 | static int __init amd74xx_ide_init(void) |
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c index 41f6cb6c163a..e4437034dd08 100644 --- a/drivers/ide/pci/atiixp.c +++ b/drivers/ide/pci/atiixp.c | |||
| @@ -7,7 +7,6 @@ | |||
| 7 | #include <linux/module.h> | 7 | #include <linux/module.h> |
| 8 | #include <linux/kernel.h> | 8 | #include <linux/kernel.h> |
| 9 | #include <linux/pci.h> | 9 | #include <linux/pci.h> |
| 10 | #include <linux/hdreg.h> | ||
| 11 | #include <linux/ide.h> | 10 | #include <linux/ide.h> |
| 12 | #include <linux/init.h> | 11 | #include <linux/init.h> |
| 13 | 12 | ||
| @@ -188,6 +187,8 @@ static struct pci_driver driver = { | |||
| 188 | .id_table = atiixp_pci_tbl, | 187 | .id_table = atiixp_pci_tbl, |
| 189 | .probe = atiixp_init_one, | 188 | .probe = atiixp_init_one, |
| 190 | .remove = ide_pci_remove, | 189 | .remove = ide_pci_remove, |
| 190 | .suspend = ide_pci_suspend, | ||
| 191 | .resume = ide_pci_resume, | ||
| 191 | }; | 192 | }; |
| 192 | 193 | ||
| 193 | static int __init atiixp_ide_init(void) | 194 | static int __init atiixp_ide_init(void) |
diff --git a/drivers/ide/pci/cmd640.c b/drivers/ide/pci/cmd640.c index e6c62006ca1a..7f39cdb41410 100644 --- a/drivers/ide/pci/cmd640.c +++ b/drivers/ide/pci/cmd640.c | |||
| @@ -103,7 +103,6 @@ | |||
| 103 | #include <linux/types.h> | 103 | #include <linux/types.h> |
| 104 | #include <linux/kernel.h> | 104 | #include <linux/kernel.h> |
| 105 | #include <linux/delay.h> | 105 | #include <linux/delay.h> |
| 106 | #include <linux/hdreg.h> | ||
| 107 | #include <linux/ide.h> | 106 | #include <linux/ide.h> |
| 108 | #include <linux/init.h> | 107 | #include <linux/init.h> |
| 109 | 108 | ||
| @@ -375,6 +374,21 @@ static void cmd640_dump_regs(void) | |||
| 375 | } | 374 | } |
| 376 | #endif | 375 | #endif |
| 377 | 376 | ||
| 377 | static void __set_prefetch_mode(ide_drive_t *drive, int mode) | ||
| 378 | { | ||
| 379 | if (mode) { /* want prefetch on? */ | ||
| 380 | #if CMD640_PREFETCH_MASKS | ||
| 381 | drive->no_unmask = 1; | ||
| 382 | drive->unmask = 0; | ||
| 383 | #endif | ||
| 384 | drive->no_io_32bit = 0; | ||
| 385 | } else { | ||
| 386 | drive->no_unmask = 0; | ||
| 387 | drive->no_io_32bit = 1; | ||
| 388 | drive->io_32bit = 0; | ||
| 389 | } | ||
| 390 | } | ||
| 391 | |||
| 378 | #ifndef CONFIG_BLK_DEV_CMD640_ENHANCED | 392 | #ifndef CONFIG_BLK_DEV_CMD640_ENHANCED |
| 379 | /* | 393 | /* |
| 380 | * Check whether prefetch is on for a drive, | 394 | * Check whether prefetch is on for a drive, |
| @@ -384,19 +398,10 @@ static void __init check_prefetch(ide_drive_t *drive, unsigned int index) | |||
| 384 | { | 398 | { |
| 385 | u8 b = get_cmd640_reg(prefetch_regs[index]); | 399 | u8 b = get_cmd640_reg(prefetch_regs[index]); |
| 386 | 400 | ||
| 387 | if (b & prefetch_masks[index]) { /* is prefetch off? */ | 401 | __set_prefetch_mode(drive, (b & prefetch_masks[index]) ? 0 : 1); |
| 388 | drive->no_unmask = 0; | ||
| 389 | drive->no_io_32bit = 1; | ||
| 390 | drive->io_32bit = 0; | ||
| 391 | } else { | ||
| 392 | #if CMD640_PREFETCH_MASKS | ||
| 393 | drive->no_unmask = 1; | ||
| 394 | drive->unmask = 0; | ||
| 395 | #endif | ||
| 396 | drive->no_io_32bit = 0; | ||
| 397 | } | ||
| 398 | } | 402 | } |
| 399 | #else | 403 | #else |
| 404 | |||
| 400 | /* | 405 | /* |
| 401 | * Sets prefetch mode for a drive. | 406 | * Sets prefetch mode for a drive. |
| 402 | */ | 407 | */ |
| @@ -408,19 +413,11 @@ static void set_prefetch_mode(ide_drive_t *drive, unsigned int index, int mode) | |||
| 408 | 413 | ||
| 409 | spin_lock_irqsave(&cmd640_lock, flags); | 414 | spin_lock_irqsave(&cmd640_lock, flags); |
| 410 | b = __get_cmd640_reg(reg); | 415 | b = __get_cmd640_reg(reg); |
| 411 | if (mode) { /* want prefetch on? */ | 416 | __set_prefetch_mode(drive, mode); |
| 412 | #if CMD640_PREFETCH_MASKS | 417 | if (mode) |
| 413 | drive->no_unmask = 1; | ||
| 414 | drive->unmask = 0; | ||
| 415 | #endif | ||
| 416 | drive->no_io_32bit = 0; | ||
| 417 | b &= ~prefetch_masks[index]; /* enable prefetch */ | 418 | b &= ~prefetch_masks[index]; /* enable prefetch */ |
| 418 | } else { | 419 | else |
| 419 | drive->no_unmask = 0; | ||
| 420 | drive->no_io_32bit = 1; | ||
| 421 | drive->io_32bit = 0; | ||
| 422 | b |= prefetch_masks[index]; /* disable prefetch */ | 420 | b |= prefetch_masks[index]; /* disable prefetch */ |
| 423 | } | ||
| 424 | __put_cmd640_reg(reg, b); | 421 | __put_cmd640_reg(reg, b); |
| 425 | spin_unlock_irqrestore(&cmd640_lock, flags); | 422 | spin_unlock_irqrestore(&cmd640_lock, flags); |
| 426 | } | 423 | } |
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c index e064398e03b4..456dee18b660 100644 --- a/drivers/ide/pci/cmd64x.c +++ b/drivers/ide/pci/cmd64x.c | |||
| @@ -13,7 +13,6 @@ | |||
| 13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
| 15 | #include <linux/pci.h> | 15 | #include <linux/pci.h> |
| 16 | #include <linux/hdreg.h> | ||
| 17 | #include <linux/ide.h> | 16 | #include <linux/ide.h> |
| 18 | #include <linux/init.h> | 17 | #include <linux/init.h> |
| 19 | 18 | ||
| @@ -332,7 +331,7 @@ static int cmd646_1_dma_end(ide_drive_t *drive) | |||
| 332 | return (dma_stat & 7) != 4; | 331 | return (dma_stat & 7) != 4; |
| 333 | } | 332 | } |
| 334 | 333 | ||
| 335 | static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev) | 334 | static unsigned int init_chipset_cmd64x(struct pci_dev *dev) |
| 336 | { | 335 | { |
| 337 | u8 mrdmode = 0; | 336 | u8 mrdmode = 0; |
| 338 | 337 | ||
| @@ -511,6 +510,8 @@ static struct pci_driver driver = { | |||
| 511 | .id_table = cmd64x_pci_tbl, | 510 | .id_table = cmd64x_pci_tbl, |
| 512 | .probe = cmd64x_init_one, | 511 | .probe = cmd64x_init_one, |
| 513 | .remove = ide_pci_remove, | 512 | .remove = ide_pci_remove, |
| 513 | .suspend = ide_pci_suspend, | ||
| 514 | .resume = ide_pci_resume, | ||
| 514 | }; | 515 | }; |
| 515 | 516 | ||
| 516 | static int __init cmd64x_ide_init(void) | 517 | static int __init cmd64x_ide_init(void) |
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c index 151844fcbb07..d6341f7c4144 100644 --- a/drivers/ide/pci/cs5520.c +++ b/drivers/ide/pci/cs5520.c | |||
| @@ -35,7 +35,6 @@ | |||
| 35 | #include <linux/module.h> | 35 | #include <linux/module.h> |
| 36 | #include <linux/types.h> | 36 | #include <linux/types.h> |
| 37 | #include <linux/kernel.h> | 37 | #include <linux/kernel.h> |
| 38 | #include <linux/hdreg.h> | ||
| 39 | #include <linux/init.h> | 38 | #include <linux/init.h> |
| 40 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
| 41 | #include <linux/ide.h> | 40 | #include <linux/ide.h> |
| @@ -150,6 +149,8 @@ static struct pci_driver driver = { | |||
| 150 | .name = "Cyrix_IDE", | 149 | .name = "Cyrix_IDE", |
| 151 | .id_table = cs5520_pci_tbl, | 150 | .id_table = cs5520_pci_tbl, |
| 152 | .probe = cs5520_init_one, | 151 | .probe = cs5520_init_one, |
| 152 | .suspend = ide_pci_suspend, | ||
| 153 | .resume = ide_pci_resume, | ||
| 153 | }; | 154 | }; |
| 154 | 155 | ||
| 155 | static int __init cs5520_ide_init(void) | 156 | static int __init cs5520_ide_init(void) |
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c index f235db8c678b..da42fa7e9f97 100644 --- a/drivers/ide/pci/cs5530.c +++ b/drivers/ide/pci/cs5530.c | |||
| @@ -15,7 +15,6 @@ | |||
| 15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
| 17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
| 18 | #include <linux/hdreg.h> | ||
| 19 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
| 20 | #include <linux/init.h> | 19 | #include <linux/init.h> |
| 21 | #include <linux/ide.h> | 20 | #include <linux/ide.h> |
| @@ -81,17 +80,19 @@ static void cs5530_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 81 | static u8 cs5530_udma_filter(ide_drive_t *drive) | 80 | static u8 cs5530_udma_filter(ide_drive_t *drive) |
| 82 | { | 81 | { |
| 83 | ide_hwif_t *hwif = drive->hwif; | 82 | ide_hwif_t *hwif = drive->hwif; |
| 84 | ide_drive_t *mate = &hwif->drives[(drive->dn & 1) ^ 1]; | 83 | ide_drive_t *mate = ide_get_pair_dev(drive); |
| 85 | struct hd_driveid *mateid = mate->id; | 84 | u16 *mateid = mate->id; |
| 86 | u8 mask = hwif->ultra_mask; | 85 | u8 mask = hwif->ultra_mask; |
| 87 | 86 | ||
| 88 | if (mate->present == 0) | 87 | if (mate == NULL) |
| 89 | goto out; | 88 | goto out; |
| 90 | 89 | ||
| 91 | if ((mateid->capability & 1) && __ide_dma_bad_drive(mate) == 0) { | 90 | if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) { |
| 92 | if ((mateid->field_valid & 4) && (mateid->dma_ultra & 7)) | 91 | if ((mateid[ATA_ID_FIELD_VALID] & 4) && |
| 92 | (mateid[ATA_ID_UDMA_MODES] & 7)) | ||
| 93 | goto out; | 93 | goto out; |
| 94 | if ((mateid->field_valid & 2) && (mateid->dma_mword & 7)) | 94 | if ((mateid[ATA_ID_FIELD_VALID] & 2) && |
| 95 | (mateid[ATA_ID_MWDMA_MODES] & 7)) | ||
| 95 | mask = 0; | 96 | mask = 0; |
| 96 | } | 97 | } |
| 97 | out: | 98 | out: |
| @@ -133,7 +134,7 @@ static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode) | |||
| 133 | * Initialize the cs5530 bridge for reliable IDE DMA operation. | 134 | * Initialize the cs5530 bridge for reliable IDE DMA operation. |
| 134 | */ | 135 | */ |
| 135 | 136 | ||
| 136 | static unsigned int __devinit init_chipset_cs5530(struct pci_dev *dev) | 137 | static unsigned int init_chipset_cs5530(struct pci_dev *dev) |
| 137 | { | 138 | { |
| 138 | struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; | 139 | struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; |
| 139 | 140 | ||
| @@ -271,6 +272,8 @@ static struct pci_driver driver = { | |||
| 271 | .id_table = cs5530_pci_tbl, | 272 | .id_table = cs5530_pci_tbl, |
| 272 | .probe = cs5530_init_one, | 273 | .probe = cs5530_init_one, |
| 273 | .remove = ide_pci_remove, | 274 | .remove = ide_pci_remove, |
| 275 | .suspend = ide_pci_suspend, | ||
| 276 | .resume = ide_pci_resume, | ||
| 274 | }; | 277 | }; |
| 275 | 278 | ||
| 276 | static int __init cs5530_ide_init(void) | 279 | static int __init cs5530_ide_init(void) |
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c index dd3dc23af995..1e5bc59ea2fb 100644 --- a/drivers/ide/pci/cs5535.c +++ b/drivers/ide/pci/cs5535.c | |||
| @@ -80,12 +80,12 @@ static void cs5535_set_speed(ide_drive_t *drive, const u8 speed) | |||
| 80 | 80 | ||
| 81 | /* Set the PIO timings */ | 81 | /* Set the PIO timings */ |
| 82 | if (speed < XFER_SW_DMA_0) { | 82 | if (speed < XFER_SW_DMA_0) { |
| 83 | ide_drive_t *pair = ide_get_paired_drive(drive); | 83 | ide_drive_t *pair = ide_get_pair_dev(drive); |
| 84 | u8 cmd, pioa; | 84 | u8 cmd, pioa; |
| 85 | 85 | ||
| 86 | cmd = pioa = speed - XFER_PIO_0; | 86 | cmd = pioa = speed - XFER_PIO_0; |
| 87 | 87 | ||
| 88 | if (pair->present) { | 88 | if (pair) { |
| 89 | u8 piob = ide_get_best_pio_mode(pair, 255, 4); | 89 | u8 piob = ide_get_best_pio_mode(pair, 255, 4); |
| 90 | 90 | ||
| 91 | if (piob < cmd) | 91 | if (piob < cmd) |
| @@ -193,10 +193,12 @@ static const struct pci_device_id cs5535_pci_tbl[] = { | |||
| 193 | MODULE_DEVICE_TABLE(pci, cs5535_pci_tbl); | 193 | MODULE_DEVICE_TABLE(pci, cs5535_pci_tbl); |
| 194 | 194 | ||
| 195 | static struct pci_driver driver = { | 195 | static struct pci_driver driver = { |
| 196 | .name = "CS5535_IDE", | 196 | .name = "CS5535_IDE", |
| 197 | .id_table = cs5535_pci_tbl, | 197 | .id_table = cs5535_pci_tbl, |
| 198 | .probe = cs5535_init_one, | 198 | .probe = cs5535_init_one, |
| 199 | .remove = ide_pci_remove, | 199 | .remove = ide_pci_remove, |
| 200 | .suspend = ide_pci_suspend, | ||
| 201 | .resume = ide_pci_resume, | ||
| 200 | }; | 202 | }; |
| 201 | 203 | ||
| 202 | static int __init cs5535_ide_init(void) | 204 | static int __init cs5535_ide_init(void) |
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c index e6d8ee88d56d..69820e9224d1 100644 --- a/drivers/ide/pci/cy82c693.c +++ b/drivers/ide/pci/cy82c693.c | |||
| @@ -332,7 +332,7 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 332 | /* | 332 | /* |
| 333 | * this function is called during init and is used to setup the cy82c693 chip | 333 | * this function is called during init and is used to setup the cy82c693 chip |
| 334 | */ | 334 | */ |
| 335 | static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev) | 335 | static unsigned int init_chipset_cy82c693(struct pci_dev *dev) |
| 336 | { | 336 | { |
| 337 | if (PCI_FUNC(dev->devfn) != 1) | 337 | if (PCI_FUNC(dev->devfn) != 1) |
| 338 | return 0; | 338 | return 0; |
| @@ -448,6 +448,8 @@ static struct pci_driver driver = { | |||
| 448 | .id_table = cy82c693_pci_tbl, | 448 | .id_table = cy82c693_pci_tbl, |
| 449 | .probe = cy82c693_init_one, | 449 | .probe = cy82c693_init_one, |
| 450 | .remove = __devexit_p(cy82c693_remove), | 450 | .remove = __devexit_p(cy82c693_remove), |
| 451 | .suspend = ide_pci_suspend, | ||
| 452 | .resume = ide_pci_resume, | ||
| 451 | }; | 453 | }; |
| 452 | 454 | ||
| 453 | static int __init cy82c693_ide_init(void) | 455 | static int __init cy82c693_ide_init(void) |
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c index f84bfb4f600f..83b63b365e51 100644 --- a/drivers/ide/pci/delkin_cb.c +++ b/drivers/ide/pci/delkin_cb.c | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | 19 | ||
| 20 | #include <linux/types.h> | 20 | #include <linux/types.h> |
| 21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
| 22 | #include <linux/hdreg.h> | ||
| 23 | #include <linux/ide.h> | 22 | #include <linux/ide.h> |
| 24 | #include <linux/init.h> | 23 | #include <linux/init.h> |
| 25 | #include <linux/pci.h> | 24 | #include <linux/pci.h> |
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c index b07d4f4273b3..092b238cb250 100644 --- a/drivers/ide/pci/generic.c +++ b/drivers/ide/pci/generic.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
| 23 | #include <linux/module.h> | 23 | #include <linux/module.h> |
| 24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
| 25 | #include <linux/hdreg.h> | ||
| 26 | #include <linux/pci.h> | 25 | #include <linux/pci.h> |
| 27 | #include <linux/ide.h> | 26 | #include <linux/ide.h> |
| 28 | #include <linux/init.h> | 27 | #include <linux/init.h> |
| @@ -172,6 +171,8 @@ static struct pci_driver driver = { | |||
| 172 | .id_table = generic_pci_tbl, | 171 | .id_table = generic_pci_tbl, |
| 173 | .probe = generic_init_one, | 172 | .probe = generic_init_one, |
| 174 | .remove = ide_pci_remove, | 173 | .remove = ide_pci_remove, |
| 174 | .suspend = ide_pci_suspend, | ||
| 175 | .resume = ide_pci_resume, | ||
| 175 | }; | 176 | }; |
| 176 | 177 | ||
| 177 | static int __init generic_ide_init(void) | 178 | static int __init generic_ide_init(void) |
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c index 6009b0b9655d..644de29f8fe4 100644 --- a/drivers/ide/pci/hpt34x.c +++ b/drivers/ide/pci/hpt34x.c | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
| 28 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
| 29 | #include <linux/ioport.h> | 29 | #include <linux/ioport.h> |
| 30 | #include <linux/hdreg.h> | ||
| 31 | #include <linux/interrupt.h> | 30 | #include <linux/interrupt.h> |
| 32 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
| 33 | #include <linux/init.h> | 32 | #include <linux/init.h> |
| @@ -79,7 +78,7 @@ static void hpt34x_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 79 | */ | 78 | */ |
| 80 | #define HPT34X_PCI_INIT_REG 0x80 | 79 | #define HPT34X_PCI_INIT_REG 0x80 |
| 81 | 80 | ||
| 82 | static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev) | 81 | static unsigned int init_chipset_hpt34x(struct pci_dev *dev) |
| 83 | { | 82 | { |
| 84 | int i = 0; | 83 | int i = 0; |
| 85 | unsigned long hpt34xIoBase = pci_resource_start(dev, 4); | 84 | unsigned long hpt34xIoBase = pci_resource_start(dev, 4); |
| @@ -172,6 +171,8 @@ static struct pci_driver driver = { | |||
| 172 | .id_table = hpt34x_pci_tbl, | 171 | .id_table = hpt34x_pci_tbl, |
| 173 | .probe = hpt34x_init_one, | 172 | .probe = hpt34x_init_one, |
| 174 | .remove = ide_pci_remove, | 173 | .remove = ide_pci_remove, |
| 174 | .suspend = ide_pci_suspend, | ||
| 175 | .resume = ide_pci_resume, | ||
| 175 | }; | 176 | }; |
| 176 | 177 | ||
| 177 | static int __init hpt34x_ide_init(void) | 178 | static int __init hpt34x_ide_init(void) |
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c index c37ab1743819..a194022b6a61 100644 --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c | |||
| @@ -122,7 +122,6 @@ | |||
| 122 | #include <linux/kernel.h> | 122 | #include <linux/kernel.h> |
| 123 | #include <linux/delay.h> | 123 | #include <linux/delay.h> |
| 124 | #include <linux/blkdev.h> | 124 | #include <linux/blkdev.h> |
| 125 | #include <linux/hdreg.h> | ||
| 126 | #include <linux/interrupt.h> | 125 | #include <linux/interrupt.h> |
| 127 | #include <linux/pci.h> | 126 | #include <linux/pci.h> |
| 128 | #include <linux/init.h> | 127 | #include <linux/init.h> |
| @@ -605,10 +604,10 @@ static const struct hpt_info hpt371n __devinitdata = { | |||
| 605 | 604 | ||
| 606 | static int check_in_drive_list(ide_drive_t *drive, const char **list) | 605 | static int check_in_drive_list(ide_drive_t *drive, const char **list) |
| 607 | { | 606 | { |
| 608 | struct hd_driveid *id = drive->id; | 607 | char *m = (char *)&drive->id[ATA_ID_PROD]; |
| 609 | 608 | ||
| 610 | while (*list) | 609 | while (*list) |
| 611 | if (!strcmp(*list++,id->model)) | 610 | if (!strcmp(*list++, m)) |
| 612 | return 1; | 611 | return 1; |
| 613 | return 0; | 612 | return 0; |
| 614 | } | 613 | } |
| @@ -655,7 +654,7 @@ static u8 hpt3xx_udma_filter(ide_drive_t *drive) | |||
| 655 | case HPT372A: | 654 | case HPT372A: |
| 656 | case HPT372N: | 655 | case HPT372N: |
| 657 | case HPT374 : | 656 | case HPT374 : |
| 658 | if (ide_dev_is_sata(drive->id)) | 657 | if (ata_id_is_sata(drive->id)) |
| 659 | mask &= ~0x0e; | 658 | mask &= ~0x0e; |
| 660 | /* Fall thru */ | 659 | /* Fall thru */ |
| 661 | default: | 660 | default: |
| @@ -675,7 +674,7 @@ static u8 hpt3xx_mdma_filter(ide_drive_t *drive) | |||
| 675 | case HPT372A: | 674 | case HPT372A: |
| 676 | case HPT372N: | 675 | case HPT372N: |
| 677 | case HPT374 : | 676 | case HPT374 : |
| 678 | if (ide_dev_is_sata(drive->id)) | 677 | if (ata_id_is_sata(drive->id)) |
| 679 | return 0x00; | 678 | return 0x00; |
| 680 | /* Fall thru */ | 679 | /* Fall thru */ |
| 681 | default: | 680 | default: |
| @@ -731,11 +730,11 @@ static void hpt3xx_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 731 | 730 | ||
| 732 | static void hpt3xx_quirkproc(ide_drive_t *drive) | 731 | static void hpt3xx_quirkproc(ide_drive_t *drive) |
| 733 | { | 732 | { |
| 734 | struct hd_driveid *id = drive->id; | 733 | char *m = (char *)&drive->id[ATA_ID_PROD]; |
| 735 | const char **list = quirk_drives; | 734 | const char **list = quirk_drives; |
| 736 | 735 | ||
| 737 | while (*list) | 736 | while (*list) |
| 738 | if (strstr(id->model, *list++)) { | 737 | if (strstr(m, *list++)) { |
| 739 | drive->quirk_list = 1; | 738 | drive->quirk_list = 1; |
| 740 | return; | 739 | return; |
| 741 | } | 740 | } |
| @@ -944,7 +943,7 @@ static void hpt3xxn_rw_disk(ide_drive_t *drive, struct request *rq) | |||
| 944 | * Perform a calibration cycle on the DPLL. | 943 | * Perform a calibration cycle on the DPLL. |
| 945 | * Returns 1 if this succeeds | 944 | * Returns 1 if this succeeds |
| 946 | */ | 945 | */ |
| 947 | static int __devinit hpt37x_calibrate_dpll(struct pci_dev *dev, u16 f_low, u16 f_high) | 946 | static int hpt37x_calibrate_dpll(struct pci_dev *dev, u16 f_low, u16 f_high) |
| 948 | { | 947 | { |
| 949 | u32 dpll = (f_high << 16) | f_low | 0x100; | 948 | u32 dpll = (f_high << 16) | f_low | 0x100; |
| 950 | u8 scr2; | 949 | u8 scr2; |
| @@ -972,7 +971,37 @@ static int __devinit hpt37x_calibrate_dpll(struct pci_dev *dev, u16 f_low, u16 f | |||
| 972 | return 1; | 971 | return 1; |
| 973 | } | 972 | } |
| 974 | 973 | ||
| 975 | static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev) | 974 | static void hpt3xx_disable_fast_irq(struct pci_dev *dev, u8 mcr_addr) |
| 975 | { | ||
| 976 | struct ide_host *host = pci_get_drvdata(dev); | ||
| 977 | struct hpt_info *info = host->host_priv + (&dev->dev == host->dev[1]); | ||
| 978 | u8 chip_type = info->chip_type; | ||
| 979 | u8 new_mcr, old_mcr = 0; | ||
| 980 | |||
| 981 | /* | ||
| 982 | * Disable the "fast interrupt" prediction. Don't hold off | ||
| 983 | * on interrupts. (== 0x01 despite what the docs say) | ||
| 984 | */ | ||
| 985 | pci_read_config_byte(dev, mcr_addr + 1, &old_mcr); | ||
| 986 | |||
| 987 | if (chip_type >= HPT374) | ||
| 988 | new_mcr = old_mcr & ~0x07; | ||
| 989 | else if (chip_type >= HPT370) { | ||
| 990 | new_mcr = old_mcr; | ||
| 991 | new_mcr &= ~0x02; | ||
| 992 | #ifdef HPT_DELAY_INTERRUPT | ||
| 993 | new_mcr &= ~0x01; | ||
| 994 | #else | ||
| 995 | new_mcr |= 0x01; | ||
| 996 | #endif | ||
| 997 | } else /* HPT366 and HPT368 */ | ||
| 998 | new_mcr = old_mcr & ~0x80; | ||
| 999 | |||
| 1000 | if (new_mcr != old_mcr) | ||
| 1001 | pci_write_config_byte(dev, mcr_addr + 1, new_mcr); | ||
| 1002 | } | ||
| 1003 | |||
| 1004 | static unsigned int init_chipset_hpt366(struct pci_dev *dev) | ||
| 976 | { | 1005 | { |
| 977 | unsigned long io_base = pci_resource_start(dev, 4); | 1006 | unsigned long io_base = pci_resource_start(dev, 4); |
| 978 | struct hpt_info *info = hpt3xx_get_info(&dev->dev); | 1007 | struct hpt_info *info = hpt3xx_get_info(&dev->dev); |
| @@ -1209,9 +1238,11 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev) | |||
| 1209 | * NOTE: This register is only writeable via I/O space. | 1238 | * NOTE: This register is only writeable via I/O space. |
| 1210 | */ | 1239 | */ |
| 1211 | if (chip_type == HPT371N && clock == ATA_CLOCK_66MHZ) | 1240 | if (chip_type == HPT371N && clock == ATA_CLOCK_66MHZ) |
| 1212 | |||
| 1213 | outb(inb(io_base + 0x9c) | 0x04, io_base + 0x9c); | 1241 | outb(inb(io_base + 0x9c) | 0x04, io_base + 0x9c); |
| 1214 | 1242 | ||
| 1243 | hpt3xx_disable_fast_irq(dev, 0x50); | ||
| 1244 | hpt3xx_disable_fast_irq(dev, 0x54); | ||
| 1245 | |||
| 1215 | return dev->irq; | 1246 | return dev->irq; |
| 1216 | } | 1247 | } |
| 1217 | 1248 | ||
| @@ -1265,7 +1296,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
| 1265 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); | 1296 | struct hpt_info *info = hpt3xx_get_info(hwif->dev); |
| 1266 | int serialize = HPT_SERIALIZE_IO; | 1297 | int serialize = HPT_SERIALIZE_IO; |
| 1267 | u8 chip_type = info->chip_type; | 1298 | u8 chip_type = info->chip_type; |
| 1268 | u8 new_mcr, old_mcr = 0; | ||
| 1269 | 1299 | ||
| 1270 | /* Cache the channel's MISC. control registers' offset */ | 1300 | /* Cache the channel's MISC. control registers' offset */ |
| 1271 | hwif->select_data = hwif->channel ? 0x54 : 0x50; | 1301 | hwif->select_data = hwif->channel ? 0x54 : 0x50; |
| @@ -1288,29 +1318,6 @@ static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) | |||
| 1288 | /* Serialize access to this device if needed */ | 1318 | /* Serialize access to this device if needed */ |
| 1289 | if (serialize && hwif->mate) | 1319 | if (serialize && hwif->mate) |
| 1290 | hwif->serialized = hwif->mate->serialized = 1; | 1320 | hwif->serialized = hwif->mate->serialized = 1; |
| 1291 | |||
| 1292 | /* | ||
| 1293 | * Disable the "fast interrupt" prediction. Don't hold off | ||
| 1294 | * on interrupts. (== 0x01 despite what the docs say) | ||
| 1295 | */ | ||
| 1296 | pci_read_config_byte(dev, hwif->select_data + 1, &old_mcr); | ||
| 1297 | |||
| 1298 | if (info->chip_type >= HPT374) | ||
| 1299 | new_mcr = old_mcr & ~0x07; | ||
| 1300 | else if (info->chip_type >= HPT370) { | ||
| 1301 | new_mcr = old_mcr; | ||
| 1302 | new_mcr &= ~0x02; | ||
| 1303 | |||
| 1304 | #ifdef HPT_DELAY_INTERRUPT | ||
| 1305 | new_mcr &= ~0x01; | ||
| 1306 | #else | ||
| 1307 | new_mcr |= 0x01; | ||
| 1308 | #endif | ||
| 1309 | } else /* HPT366 and HPT368 */ | ||
| 1310 | new_mcr = old_mcr & ~0x80; | ||
| 1311 | |||
| 1312 | if (new_mcr != old_mcr) | ||
| 1313 | pci_write_config_byte(dev, hwif->select_data + 1, new_mcr); | ||
| 1314 | } | 1321 | } |
| 1315 | 1322 | ||
| 1316 | static int __devinit init_dma_hpt366(ide_hwif_t *hwif, | 1323 | static int __devinit init_dma_hpt366(ide_hwif_t *hwif, |
| @@ -1620,6 +1627,8 @@ static struct pci_driver driver = { | |||
| 1620 | .id_table = hpt366_pci_tbl, | 1627 | .id_table = hpt366_pci_tbl, |
| 1621 | .probe = hpt366_init_one, | 1628 | .probe = hpt366_init_one, |
| 1622 | .remove = __devexit_p(hpt366_remove), | 1629 | .remove = __devexit_p(hpt366_remove), |
| 1630 | .suspend = ide_pci_suspend, | ||
| 1631 | .resume = ide_pci_resume, | ||
| 1623 | }; | 1632 | }; |
| 1624 | 1633 | ||
| 1625 | static int __init hpt366_ide_init(void) | 1634 | static int __init hpt366_ide_init(void) |
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c index 652e47dd7e89..0954ccd08d6f 100644 --- a/drivers/ide/pci/it8213.c +++ b/drivers/ide/pci/it8213.c | |||
| @@ -10,7 +10,6 @@ | |||
| 10 | #include <linux/types.h> | 10 | #include <linux/types.h> |
| 11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
| 12 | #include <linux/pci.h> | 12 | #include <linux/pci.h> |
| 13 | #include <linux/hdreg.h> | ||
| 14 | #include <linux/ide.h> | 13 | #include <linux/ide.h> |
| 15 | #include <linux/init.h> | 14 | #include <linux/init.h> |
| 16 | 15 | ||
| @@ -195,6 +194,8 @@ static struct pci_driver driver = { | |||
| 195 | .id_table = it8213_pci_tbl, | 194 | .id_table = it8213_pci_tbl, |
| 196 | .probe = it8213_init_one, | 195 | .probe = it8213_init_one, |
| 197 | .remove = ide_pci_remove, | 196 | .remove = ide_pci_remove, |
| 197 | .suspend = ide_pci_suspend, | ||
| 198 | .resume = ide_pci_resume, | ||
| 198 | }; | 199 | }; |
| 199 | 200 | ||
| 200 | static int __init it8213_ide_init(void) | 201 | static int __init it8213_ide_init(void) |
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c index 4a1508a707cc..46edd083b348 100644 --- a/drivers/ide/pci/it821x.c +++ b/drivers/ide/pci/it821x.c | |||
| @@ -63,7 +63,6 @@ | |||
| 63 | #include <linux/types.h> | 63 | #include <linux/types.h> |
| 64 | #include <linux/module.h> | 64 | #include <linux/module.h> |
| 65 | #include <linux/pci.h> | 65 | #include <linux/pci.h> |
| 66 | #include <linux/hdreg.h> | ||
| 67 | #include <linux/ide.h> | 66 | #include <linux/ide.h> |
| 68 | #include <linux/init.h> | 67 | #include <linux/init.h> |
| 69 | 68 | ||
| @@ -446,8 +445,7 @@ static u8 it821x_cable_detect(ide_hwif_t *hwif) | |||
| 446 | static void it821x_quirkproc(ide_drive_t *drive) | 445 | static void it821x_quirkproc(ide_drive_t *drive) |
| 447 | { | 446 | { |
| 448 | struct it821x_dev *itdev = ide_get_hwifdata(drive->hwif); | 447 | struct it821x_dev *itdev = ide_get_hwifdata(drive->hwif); |
| 449 | struct hd_driveid *id = drive->id; | 448 | u16 *id = drive->id; |
| 450 | u16 *idbits = (u16 *)drive->id; | ||
| 451 | 449 | ||
| 452 | if (!itdev->smart) { | 450 | if (!itdev->smart) { |
| 453 | /* | 451 | /* |
| @@ -466,36 +464,36 @@ static void it821x_quirkproc(ide_drive_t *drive) | |||
| 466 | */ | 464 | */ |
| 467 | 465 | ||
| 468 | /* Check for RAID v native */ | 466 | /* Check for RAID v native */ |
| 469 | if(strstr(id->model, "Integrated Technology Express")) { | 467 | if (strstr((char *)&id[ATA_ID_PROD], |
| 468 | "Integrated Technology Express")) { | ||
| 470 | /* In raid mode the ident block is slightly buggy | 469 | /* In raid mode the ident block is slightly buggy |
| 471 | We need to set the bits so that the IDE layer knows | 470 | We need to set the bits so that the IDE layer knows |
| 472 | LBA28. LBA48 and DMA ar valid */ | 471 | LBA28. LBA48 and DMA ar valid */ |
| 473 | id->capability |= 3; /* LBA28, DMA */ | 472 | id[ATA_ID_CAPABILITY] |= (3 << 8); /* LBA28, DMA */ |
| 474 | id->command_set_2 |= 0x0400; /* LBA48 valid */ | 473 | id[ATA_ID_COMMAND_SET_2] |= 0x0400; /* LBA48 valid */ |
| 475 | id->cfs_enable_2 |= 0x0400; /* LBA48 on */ | 474 | id[ATA_ID_CFS_ENABLE_2] |= 0x0400; /* LBA48 on */ |
| 476 | /* Reporting logic */ | 475 | /* Reporting logic */ |
| 477 | printk(KERN_INFO "%s: IT8212 %sRAID %d volume", | 476 | printk(KERN_INFO "%s: IT8212 %sRAID %d volume", |
| 478 | drive->name, | 477 | drive->name, id[147] ? "Bootable " : "", |
| 479 | idbits[147] ? "Bootable ":"", | 478 | id[ATA_ID_CSFO]); |
| 480 | idbits[129]); | 479 | if (id[ATA_ID_CSFO] != 1) |
| 481 | if(idbits[129] != 1) | 480 | printk(KERN_CONT "(%dK stripe)", id[146]); |
| 482 | printk("(%dK stripe)", idbits[146]); | 481 | printk(KERN_CONT ".\n"); |
| 483 | printk(".\n"); | ||
| 484 | } else { | 482 | } else { |
| 485 | /* Non RAID volume. Fixups to stop the core code | 483 | /* Non RAID volume. Fixups to stop the core code |
| 486 | doing unsupported things */ | 484 | doing unsupported things */ |
| 487 | id->field_valid &= 3; | 485 | id[ATA_ID_FIELD_VALID] &= 3; |
| 488 | id->queue_depth = 0; | 486 | id[ATA_ID_QUEUE_DEPTH] = 0; |
| 489 | id->command_set_1 = 0; | 487 | id[ATA_ID_COMMAND_SET_1] = 0; |
| 490 | id->command_set_2 &= 0xC400; | 488 | id[ATA_ID_COMMAND_SET_2] &= 0xC400; |
| 491 | id->cfsse &= 0xC000; | 489 | id[ATA_ID_CFSSE] &= 0xC000; |
| 492 | id->cfs_enable_1 = 0; | 490 | id[ATA_ID_CFS_ENABLE_1] = 0; |
| 493 | id->cfs_enable_2 &= 0xC400; | 491 | id[ATA_ID_CFS_ENABLE_2] &= 0xC400; |
| 494 | id->csf_default &= 0xC000; | 492 | id[ATA_ID_CSF_DEFAULT] &= 0xC000; |
| 495 | id->word127 = 0; | 493 | id[127] = 0; |
| 496 | id->dlf = 0; | 494 | id[ATA_ID_DLF] = 0; |
| 497 | id->csfo = 0; | 495 | id[ATA_ID_CSFO] = 0; |
| 498 | id->cfa_power = 0; | 496 | id[ATA_ID_CFA_POWER] = 0; |
| 499 | printk(KERN_INFO "%s: Performing identify fixups.\n", | 497 | printk(KERN_INFO "%s: Performing identify fixups.\n", |
| 500 | drive->name); | 498 | drive->name); |
| 501 | } | 499 | } |
| @@ -505,8 +503,8 @@ static void it821x_quirkproc(ide_drive_t *drive) | |||
| 505 | * IDE core that DMA is supported (it821x hardware | 503 | * IDE core that DMA is supported (it821x hardware |
| 506 | * takes care of DMA mode programming). | 504 | * takes care of DMA mode programming). |
| 507 | */ | 505 | */ |
| 508 | if (id->capability & 1) { | 506 | if (ata_id_has_dma(id)) { |
| 509 | id->dma_mword |= 0x0101; | 507 | id[ATA_ID_MWDMA_MODES] |= 0x0101; |
| 510 | drive->current_speed = XFER_MW_DMA_0; | 508 | drive->current_speed = XFER_MW_DMA_0; |
| 511 | } | 509 | } |
| 512 | } | 510 | } |
| @@ -588,7 +586,7 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif) | |||
| 588 | hwif->mwdma_mask = ATA_MWDMA2; | 586 | hwif->mwdma_mask = ATA_MWDMA2; |
| 589 | } | 587 | } |
| 590 | 588 | ||
| 591 | static void __devinit it8212_disable_raid(struct pci_dev *dev) | 589 | static void it8212_disable_raid(struct pci_dev *dev) |
| 592 | { | 590 | { |
| 593 | /* Reset local CPU, and set BIOS not ready */ | 591 | /* Reset local CPU, and set BIOS not ready */ |
| 594 | pci_write_config_byte(dev, 0x5E, 0x01); | 592 | pci_write_config_byte(dev, 0x5E, 0x01); |
| @@ -605,7 +603,7 @@ static void __devinit it8212_disable_raid(struct pci_dev *dev) | |||
| 605 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); | 603 | pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); |
| 606 | } | 604 | } |
| 607 | 605 | ||
| 608 | static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev) | 606 | static unsigned int init_chipset_it821x(struct pci_dev *dev) |
| 609 | { | 607 | { |
| 610 | u8 conf; | 608 | u8 conf; |
| 611 | static char *mode[2] = { "pass through", "smart" }; | 609 | static char *mode[2] = { "pass through", "smart" }; |
| @@ -687,6 +685,8 @@ static struct pci_driver driver = { | |||
| 687 | .id_table = it821x_pci_tbl, | 685 | .id_table = it821x_pci_tbl, |
| 688 | .probe = it821x_init_one, | 686 | .probe = it821x_init_one, |
| 689 | .remove = __devexit_p(it821x_remove), | 687 | .remove = __devexit_p(it821x_remove), |
| 688 | .suspend = ide_pci_suspend, | ||
| 689 | .resume = ide_pci_resume, | ||
| 690 | }; | 690 | }; |
| 691 | 691 | ||
| 692 | static int __init it821x_ide_init(void) | 692 | static int __init it821x_ide_init(void) |
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c index bb9d09d8f196..acd647110648 100644 --- a/drivers/ide/pci/jmicron.c +++ b/drivers/ide/pci/jmicron.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | #include <linux/types.h> | 8 | #include <linux/types.h> |
| 9 | #include <linux/module.h> | 9 | #include <linux/module.h> |
| 10 | #include <linux/pci.h> | 10 | #include <linux/pci.h> |
| 11 | #include <linux/hdreg.h> | ||
| 12 | #include <linux/ide.h> | 11 | #include <linux/ide.h> |
| 13 | #include <linux/init.h> | 12 | #include <linux/init.h> |
| 14 | 13 | ||
| @@ -155,6 +154,8 @@ static struct pci_driver driver = { | |||
| 155 | .id_table = jmicron_pci_tbl, | 154 | .id_table = jmicron_pci_tbl, |
| 156 | .probe = jmicron_init_one, | 155 | .probe = jmicron_init_one, |
| 157 | .remove = ide_pci_remove, | 156 | .remove = ide_pci_remove, |
| 157 | .suspend = ide_pci_suspend, | ||
| 158 | .resume = ide_pci_resume, | ||
| 158 | }; | 159 | }; |
| 159 | 160 | ||
| 160 | static int __init jmicron_ide_init(void) | 161 | static int __init jmicron_ide_init(void) |
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c index ffefcd15196c..53bd645736d9 100644 --- a/drivers/ide/pci/ns87415.c +++ b/drivers/ide/pci/ns87415.c | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
| 12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
| 13 | #include <linux/interrupt.h> | 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/hdreg.h> | ||
| 15 | #include <linux/pci.h> | 14 | #include <linux/pci.h> |
| 16 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
| 17 | #include <linux/ide.h> | 16 | #include <linux/ide.h> |
| @@ -274,9 +273,9 @@ static void __devinit init_hwif_ns87415 (ide_hwif_t *hwif) | |||
| 274 | do { | 273 | do { |
| 275 | udelay(50); | 274 | udelay(50); |
| 276 | stat = hwif->tp_ops->read_status(hwif); | 275 | stat = hwif->tp_ops->read_status(hwif); |
| 277 | if (stat == 0xff) | 276 | if (stat == 0xff) |
| 278 | break; | 277 | break; |
| 279 | } while ((stat & BUSY_STAT) && --timeout); | 278 | } while ((stat & ATA_BUSY) && --timeout); |
| 280 | #endif | 279 | #endif |
| 281 | } | 280 | } |
| 282 | 281 | ||
| @@ -340,6 +339,8 @@ static struct pci_driver driver = { | |||
| 340 | .id_table = ns87415_pci_tbl, | 339 | .id_table = ns87415_pci_tbl, |
| 341 | .probe = ns87415_init_one, | 340 | .probe = ns87415_init_one, |
| 342 | .remove = ide_pci_remove, | 341 | .remove = ide_pci_remove, |
| 342 | .suspend = ide_pci_suspend, | ||
| 343 | .resume = ide_pci_resume, | ||
| 343 | }; | 344 | }; |
| 344 | 345 | ||
| 345 | static int __init ns87415_ide_init(void) | 346 | static int __init ns87415_ide_init(void) |
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c index e28e672ddafc..3de11ddcf863 100644 --- a/drivers/ide/pci/opti621.c +++ b/drivers/ide/pci/opti621.c | |||
| @@ -85,7 +85,6 @@ | |||
| 85 | #include <linux/module.h> | 85 | #include <linux/module.h> |
| 86 | #include <linux/kernel.h> | 86 | #include <linux/kernel.h> |
| 87 | #include <linux/pci.h> | 87 | #include <linux/pci.h> |
| 88 | #include <linux/hdreg.h> | ||
| 89 | #include <linux/ide.h> | 88 | #include <linux/ide.h> |
| 90 | 89 | ||
| 91 | #include <asm/io.h> | 90 | #include <asm/io.h> |
| @@ -137,7 +136,7 @@ static u8 read_reg(int reg) | |||
| 137 | static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) | 136 | static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) |
| 138 | { | 137 | { |
| 139 | ide_hwif_t *hwif = drive->hwif; | 138 | ide_hwif_t *hwif = drive->hwif; |
| 140 | ide_drive_t *pair = ide_get_paired_drive(drive); | 139 | ide_drive_t *pair = ide_get_pair_dev(drive); |
| 141 | unsigned long flags; | 140 | unsigned long flags; |
| 142 | u8 tim, misc, addr_pio = pio, clk; | 141 | u8 tim, misc, addr_pio = pio, clk; |
| 143 | 142 | ||
| @@ -153,7 +152,7 @@ static void opti621_set_pio_mode(ide_drive_t *drive, const u8 pio) | |||
| 153 | 152 | ||
| 154 | drive->drive_data = XFER_PIO_0 + pio; | 153 | drive->drive_data = XFER_PIO_0 + pio; |
| 155 | 154 | ||
| 156 | if (pair->present) { | 155 | if (pair) { |
| 157 | if (pair->drive_data && pair->drive_data < drive->drive_data) | 156 | if (pair->drive_data && pair->drive_data < drive->drive_data) |
| 158 | addr_pio = pair->drive_data - XFER_PIO_0; | 157 | addr_pio = pair->drive_data - XFER_PIO_0; |
| 159 | } | 158 | } |
| @@ -226,6 +225,8 @@ static struct pci_driver driver = { | |||
| 226 | .id_table = opti621_pci_tbl, | 225 | .id_table = opti621_pci_tbl, |
| 227 | .probe = opti621_init_one, | 226 | .probe = opti621_init_one, |
| 228 | .remove = ide_pci_remove, | 227 | .remove = ide_pci_remove, |
| 228 | .suspend = ide_pci_suspend, | ||
| 229 | .resume = ide_pci_resume, | ||
| 229 | }; | 230 | }; |
| 230 | 231 | ||
| 231 | static int __init opti621_ide_init(void) | 232 | static int __init opti621_ide_init(void) |
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c index d477da6b5858..9fc59962553b 100644 --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | #include <linux/types.h> | 19 | #include <linux/types.h> |
| 20 | #include <linux/kernel.h> | 20 | #include <linux/kernel.h> |
| 21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
| 22 | #include <linux/hdreg.h> | ||
| 23 | #include <linux/pci.h> | 22 | #include <linux/pci.h> |
| 24 | #include <linux/init.h> | 23 | #include <linux/init.h> |
| 25 | #include <linux/ide.h> | 24 | #include <linux/ide.h> |
| @@ -203,10 +202,10 @@ static u8 pdcnew_cable_detect(ide_hwif_t *hwif) | |||
| 203 | 202 | ||
| 204 | static void pdcnew_quirkproc(ide_drive_t *drive) | 203 | static void pdcnew_quirkproc(ide_drive_t *drive) |
| 205 | { | 204 | { |
| 206 | const char **list, *model = drive->id->model; | 205 | const char **list, *m = (char *)&drive->id[ATA_ID_PROD]; |
| 207 | 206 | ||
| 208 | for (list = pdc_quirk_drives; *list != NULL; list++) | 207 | for (list = pdc_quirk_drives; *list != NULL; list++) |
| 209 | if (strstr(model, *list) != NULL) { | 208 | if (strstr(m, *list) != NULL) { |
| 210 | drive->quirk_list = 2; | 209 | drive->quirk_list = 2; |
| 211 | return; | 210 | return; |
| 212 | } | 211 | } |
| @@ -227,7 +226,7 @@ static void pdcnew_reset(ide_drive_t *drive) | |||
| 227 | * read_counter - Read the byte count registers | 226 | * read_counter - Read the byte count registers |
| 228 | * @dma_base: for the port address | 227 | * @dma_base: for the port address |
| 229 | */ | 228 | */ |
| 230 | static long __devinit read_counter(u32 dma_base) | 229 | static long read_counter(u32 dma_base) |
| 231 | { | 230 | { |
| 232 | u32 pri_dma_base = dma_base, sec_dma_base = dma_base + 0x08; | 231 | u32 pri_dma_base = dma_base, sec_dma_base = dma_base + 0x08; |
| 233 | u8 cnt0, cnt1, cnt2, cnt3; | 232 | u8 cnt0, cnt1, cnt2, cnt3; |
| @@ -267,7 +266,7 @@ static long __devinit read_counter(u32 dma_base) | |||
| 267 | * @dma_base: for the port address | 266 | * @dma_base: for the port address |
| 268 | * E.g. 16949000 on 33 MHz PCI bus, i.e. half of the PCI clock. | 267 | * E.g. 16949000 on 33 MHz PCI bus, i.e. half of the PCI clock. |
| 269 | */ | 268 | */ |
| 270 | static long __devinit detect_pll_input_clock(unsigned long dma_base) | 269 | static long detect_pll_input_clock(unsigned long dma_base) |
| 271 | { | 270 | { |
| 272 | struct timeval start_time, end_time; | 271 | struct timeval start_time, end_time; |
| 273 | long start_count, end_count; | 272 | long start_count, end_count; |
| @@ -310,7 +309,7 @@ static long __devinit detect_pll_input_clock(unsigned long dma_base) | |||
| 310 | } | 309 | } |
| 311 | 310 | ||
| 312 | #ifdef CONFIG_PPC_PMAC | 311 | #ifdef CONFIG_PPC_PMAC |
| 313 | static void __devinit apple_kiwi_init(struct pci_dev *pdev) | 312 | static void apple_kiwi_init(struct pci_dev *pdev) |
| 314 | { | 313 | { |
| 315 | struct device_node *np = pci_device_to_OF_node(pdev); | 314 | struct device_node *np = pci_device_to_OF_node(pdev); |
| 316 | u8 conf; | 315 | u8 conf; |
| @@ -326,7 +325,7 @@ static void __devinit apple_kiwi_init(struct pci_dev *pdev) | |||
| 326 | } | 325 | } |
| 327 | #endif /* CONFIG_PPC_PMAC */ | 326 | #endif /* CONFIG_PPC_PMAC */ |
| 328 | 327 | ||
| 329 | static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev) | 328 | static unsigned int init_chipset_pdcnew(struct pci_dev *dev) |
| 330 | { | 329 | { |
| 331 | const char *name = DRV_NAME; | 330 | const char *name = DRV_NAME; |
| 332 | unsigned long dma_base = pci_resource_start(dev, 4); | 331 | unsigned long dma_base = pci_resource_start(dev, 4); |
| @@ -567,6 +566,8 @@ static struct pci_driver driver = { | |||
| 567 | .id_table = pdc202new_pci_tbl, | 566 | .id_table = pdc202new_pci_tbl, |
| 568 | .probe = pdc202new_init_one, | 567 | .probe = pdc202new_init_one, |
| 569 | .remove = __devexit_p(pdc202new_remove), | 568 | .remove = __devexit_p(pdc202new_remove), |
| 569 | .suspend = ide_pci_suspend, | ||
| 570 | .resume = ide_pci_resume, | ||
| 570 | }; | 571 | }; |
| 571 | 572 | ||
| 572 | static int __init pdc202new_ide_init(void) | 573 | static int __init pdc202new_ide_init(void) |
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index de9a27400462..cb6d2a00c514 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c | |||
| @@ -13,7 +13,6 @@ | |||
| 13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
| 14 | #include <linux/delay.h> | 14 | #include <linux/delay.h> |
| 15 | #include <linux/blkdev.h> | 15 | #include <linux/blkdev.h> |
| 16 | #include <linux/hdreg.h> | ||
| 17 | #include <linux/pci.h> | 16 | #include <linux/pci.h> |
| 18 | #include <linux/init.h> | 17 | #include <linux/init.h> |
| 19 | #include <linux/ide.h> | 18 | #include <linux/ide.h> |
| @@ -86,7 +85,7 @@ static void pdc202xx_set_mode(ide_drive_t *drive, const u8 speed) | |||
| 86 | * Prefetch_EN / IORDY_EN / PA[3:0] bits of register A | 85 | * Prefetch_EN / IORDY_EN / PA[3:0] bits of register A |
| 87 | */ | 86 | */ |
| 88 | AP &= ~0x3f; | 87 | AP &= ~0x3f; |
| 89 | if (drive->id->capability & 4) | 88 | if (ata_id_iordy_disable(drive->id)) |
| 90 | AP |= 0x20; /* set IORDY_EN bit */ | 89 | AP |= 0x20; /* set IORDY_EN bit */ |
| 91 | if (drive->media == ide_disk) | 90 | if (drive->media == ide_disk) |
| 92 | AP |= 0x10; /* set Prefetch_EN bit */ | 91 | AP |= 0x10; /* set Prefetch_EN bit */ |
| @@ -154,10 +153,10 @@ static void pdc_old_disable_66MHz_clock(ide_hwif_t *hwif) | |||
| 154 | 153 | ||
| 155 | static void pdc202xx_quirkproc(ide_drive_t *drive) | 154 | static void pdc202xx_quirkproc(ide_drive_t *drive) |
| 156 | { | 155 | { |
| 157 | const char **list, *model = drive->id->model; | 156 | const char **list, *m = (char *)&drive->id[ATA_ID_PROD]; |
| 158 | 157 | ||
| 159 | for (list = pdc_quirk_drives; *list != NULL; list++) | 158 | for (list = pdc_quirk_drives; *list != NULL; list++) |
| 160 | if (strstr(model, *list) != NULL) { | 159 | if (strstr(m, *list) != NULL) { |
| 161 | drive->quirk_list = 2; | 160 | drive->quirk_list = 2; |
| 162 | return; | 161 | return; |
| 163 | } | 162 | } |
| @@ -265,7 +264,7 @@ static void pdc202xx_dma_timeout(ide_drive_t *drive) | |||
| 265 | ide_dma_timeout(drive); | 264 | ide_dma_timeout(drive); |
| 266 | } | 265 | } |
| 267 | 266 | ||
| 268 | static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev) | 267 | static unsigned int init_chipset_pdc202xx(struct pci_dev *dev) |
| 269 | { | 268 | { |
| 270 | unsigned long dmabase = pci_resource_start(dev, 4); | 269 | unsigned long dmabase = pci_resource_start(dev, 4); |
| 271 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; | 270 | u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; |
| @@ -432,6 +431,8 @@ static struct pci_driver driver = { | |||
| 432 | .id_table = pdc202xx_pci_tbl, | 431 | .id_table = pdc202xx_pci_tbl, |
| 433 | .probe = pdc202xx_init_one, | 432 | .probe = pdc202xx_init_one, |
| 434 | .remove = ide_pci_remove, | 433 | .remove = ide_pci_remove, |
| 434 | .suspend = ide_pci_suspend, | ||
| 435 | .resume = ide_pci_resume, | ||
| 435 | }; | 436 | }; |
| 436 | 437 | ||
| 437 | static int __init pdc202xx_ide_init(void) | 438 | static int __init pdc202xx_ide_init(void) |
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c index 30cfc815fe31..a06c03f8e295 100644 --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c | |||
| @@ -48,7 +48,6 @@ | |||
| 48 | #include <linux/module.h> | 48 | #include <linux/module.h> |
| 49 | #include <linux/kernel.h> | 49 | #include <linux/kernel.h> |
| 50 | #include <linux/pci.h> | 50 | #include <linux/pci.h> |
| 51 | #include <linux/hdreg.h> | ||
| 52 | #include <linux/ide.h> | 51 | #include <linux/ide.h> |
| 53 | #include <linux/init.h> | 52 | #include <linux/init.h> |
| 54 | 53 | ||
| @@ -205,7 +204,7 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
| 205 | * out to be nice and simple. | 204 | * out to be nice and simple. |
| 206 | */ | 205 | */ |
| 207 | 206 | ||
| 208 | static unsigned int __devinit init_chipset_ich(struct pci_dev *dev) | 207 | static unsigned int init_chipset_ich(struct pci_dev *dev) |
| 209 | { | 208 | { |
| 210 | u32 extra = 0; | 209 | u32 extra = 0; |
| 211 | 210 | ||
| @@ -450,6 +449,8 @@ static struct pci_driver driver = { | |||
| 450 | .id_table = piix_pci_tbl, | 449 | .id_table = piix_pci_tbl, |
| 451 | .probe = piix_init_one, | 450 | .probe = piix_init_one, |
| 452 | .remove = ide_pci_remove, | 451 | .remove = ide_pci_remove, |
| 452 | .suspend = ide_pci_suspend, | ||
| 453 | .resume = ide_pci_resume, | ||
| 453 | }; | 454 | }; |
| 454 | 455 | ||
| 455 | static int __init piix_ide_init(void) | 456 | static int __init piix_ide_init(void) |
diff --git a/drivers/ide/pci/rz1000.c b/drivers/ide/pci/rz1000.c index 8d11ee838a2a..c117a068761b 100644 --- a/drivers/ide/pci/rz1000.c +++ b/drivers/ide/pci/rz1000.c | |||
| @@ -16,7 +16,6 @@ | |||
| 16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
| 17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
| 18 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
| 19 | #include <linux/hdreg.h> | ||
| 20 | #include <linux/pci.h> | 19 | #include <linux/pci.h> |
| 21 | #include <linux/ide.h> | 20 | #include <linux/ide.h> |
| 22 | #include <linux/init.h> | 21 | #include <linux/init.h> |
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c index 8efaed16fea3..bdc1fed41260 100644 --- a/drivers/ide/pci/sc1200.c +++ b/drivers/ide/pci/sc1200.c | |||
| @@ -14,7 +14,6 @@ | |||
| 14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
| 16 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
| 17 | #include <linux/hdreg.h> | ||
| 18 | #include <linux/pci.h> | 17 | #include <linux/pci.h> |
| 19 | #include <linux/init.h> | 18 | #include <linux/init.h> |
| 20 | #include <linux/ide.h> | 19 | #include <linux/ide.h> |
| @@ -104,17 +103,19 @@ static void sc1200_tunepio(ide_drive_t *drive, u8 pio) | |||
| 104 | static u8 sc1200_udma_filter(ide_drive_t *drive) | 103 | static u8 sc1200_udma_filter(ide_drive_t *drive) |
| 105 | { | 104 | { |
| 106 | ide_hwif_t *hwif = drive->hwif; | 105 | ide_hwif_t *hwif = drive->hwif; |
| 107 | ide_drive_t *mate = &hwif->drives[(drive->dn & 1) ^ 1]; | 106 | ide_drive_t *mate = ide_get_pair_dev(drive); |
| 108 | struct hd_driveid *mateid = mate->id; | 107 | u16 *mateid = mate->id; |
| 109 | u8 mask = hwif->ultra_mask; | 108 | u8 mask = hwif->ultra_mask; |
| 110 | 109 | ||
| 111 | if (mate->present == 0) | 110 | if (mate == NULL) |
| 112 | goto out; | 111 | goto out; |
| 113 | 112 | ||
| 114 | if ((mateid->capability & 1) && __ide_dma_bad_drive(mate) == 0) { | 113 | if (ata_id_has_dma(mateid) && __ide_dma_bad_drive(mate) == 0) { |
| 115 | if ((mateid->field_valid & 4) && (mateid->dma_ultra & 7)) | 114 | if ((mateid[ATA_ID_FIELD_VALID] & 4) && |
| 115 | (mateid[ATA_ID_UDMA_MODES] & 7)) | ||
| 116 | goto out; | 116 | goto out; |
| 117 | if ((mateid->field_valid & 2) && (mateid->dma_mword & 7)) | 117 | if ((mateid[ATA_ID_FIELD_VALID] & 2) && |
| 118 | (mateid[ATA_ID_MWDMA_MODES] & 7)) | ||
| 118 | mask = 0; | 119 | mask = 0; |
| 119 | } | 120 | } |
| 120 | out: | 121 | out: |
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c index 44cccd1e086a..e92a874b31df 100644 --- a/drivers/ide/pci/scc_pata.c +++ b/drivers/ide/pci/scc_pata.c | |||
| @@ -26,7 +26,6 @@ | |||
| 26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
| 27 | #include <linux/pci.h> | 27 | #include <linux/pci.h> |
| 28 | #include <linux/delay.h> | 28 | #include <linux/delay.h> |
| 29 | #include <linux/hdreg.h> | ||
| 30 | #include <linux/ide.h> | 29 | #include <linux/ide.h> |
| 31 | #include <linux/init.h> | 30 | #include <linux/init.h> |
| 32 | 31 | ||
| @@ -400,7 +399,7 @@ static int scc_dma_end(ide_drive_t *drive) | |||
| 400 | /* errata A308 workaround: Step5 (check data loss) */ | 399 | /* errata A308 workaround: Step5 (check data loss) */ |
| 401 | /* We don't check non ide_disk because it is limited to UDMA4 */ | 400 | /* We don't check non ide_disk because it is limited to UDMA4 */ |
| 402 | if (!(in_be32((void __iomem *)hwif->io_ports.ctl_addr) | 401 | if (!(in_be32((void __iomem *)hwif->io_ports.ctl_addr) |
| 403 | & ERR_STAT) && | 402 | & ATA_ERR) && |
| 404 | drive->media == ide_disk && drive->current_speed > XFER_UDMA_4) { | 403 | drive->media == ide_disk && drive->current_speed > XFER_UDMA_4) { |
| 405 | reg = in_be32((void __iomem *)intsts_port); | 404 | reg = in_be32((void __iomem *)intsts_port); |
| 406 | if (!(reg & INTSTS_ACTEINT)) { | 405 | if (!(reg & INTSTS_ACTEINT)) { |
| @@ -504,7 +503,7 @@ static int scc_dma_test_irq(ide_drive_t *drive) | |||
| 504 | 503 | ||
| 505 | /* SCC errata A252,A308 workaround: Step4 */ | 504 | /* SCC errata A252,A308 workaround: Step4 */ |
| 506 | if ((in_be32((void __iomem *)hwif->io_ports.ctl_addr) | 505 | if ((in_be32((void __iomem *)hwif->io_ports.ctl_addr) |
| 507 | & ERR_STAT) && | 506 | & ATA_ERR) && |
| 508 | (int_stat & INTSTS_INTRQ)) | 507 | (int_stat & INTSTS_INTRQ)) |
| 509 | return 1; | 508 | return 1; |
| 510 | 509 | ||
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c index c3bdc6e51a48..3dff2aea317e 100644 --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c | |||
| @@ -32,7 +32,6 @@ | |||
| 32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
| 33 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
| 34 | #include <linux/pci.h> | 34 | #include <linux/pci.h> |
| 35 | #include <linux/hdreg.h> | ||
| 36 | #include <linux/ide.h> | 35 | #include <linux/ide.h> |
| 37 | #include <linux/init.h> | 36 | #include <linux/init.h> |
| 38 | 37 | ||
| @@ -57,8 +56,10 @@ static struct pci_dev *isa_dev; | |||
| 57 | 56 | ||
| 58 | static int check_in_drive_lists (ide_drive_t *drive, const char **list) | 57 | static int check_in_drive_lists (ide_drive_t *drive, const char **list) |
| 59 | { | 58 | { |
| 59 | char *m = (char *)&drive->id[ATA_ID_PROD]; | ||
| 60 | |||
| 60 | while (*list) | 61 | while (*list) |
| 61 | if (!strcmp(*list++, drive->id->model)) | 62 | if (!strcmp(*list++, m)) |
| 62 | return 1; | 63 | return 1; |
| 63 | return 0; | 64 | return 0; |
| 64 | } | 65 | } |
| @@ -174,7 +175,7 @@ static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed) | |||
| 174 | pci_write_config_byte(dev, 0x54, ultra_enable); | 175 | pci_write_config_byte(dev, 0x54, ultra_enable); |
| 175 | } | 176 | } |
| 176 | 177 | ||
| 177 | static unsigned int __devinit init_chipset_svwks(struct pci_dev *dev) | 178 | static unsigned int init_chipset_svwks(struct pci_dev *dev) |
| 178 | { | 179 | { |
| 179 | unsigned int reg; | 180 | unsigned int reg; |
| 180 | u8 btr; | 181 | u8 btr; |
| @@ -447,6 +448,8 @@ static struct pci_driver driver = { | |||
| 447 | .id_table = svwks_pci_tbl, | 448 | .id_table = svwks_pci_tbl, |
| 448 | .probe = svwks_init_one, | 449 | .probe = svwks_init_one, |
| 449 | .remove = ide_pci_remove, | 450 | .remove = ide_pci_remove, |
| 451 | .suspend = ide_pci_suspend, | ||
| 452 | .resume = ide_pci_resume, | ||
| 450 | }; | 453 | }; |
| 451 | 454 | ||
| 452 | static int __init svwks_ide_init(void) | 455 | static int __init svwks_ide_init(void) |
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c index 681306c9d79b..1017fb4f6317 100644 --- a/drivers/ide/pci/sgiioc4.c +++ b/drivers/ide/pci/sgiioc4.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | #include <linux/types.h> | 22 | #include <linux/types.h> |
| 23 | #include <linux/pci.h> | 23 | #include <linux/pci.h> |
| 24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
| 25 | #include <linux/hdreg.h> | ||
| 26 | #include <linux/init.h> | 25 | #include <linux/init.h> |
| 27 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
| 28 | #include <linux/ioport.h> | 27 | #include <linux/ioport.h> |
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c index db2b88a369ab..174a873b4c64 100644 --- a/drivers/ide/pci/siimage.c +++ b/drivers/ide/pci/siimage.c | |||
| @@ -39,7 +39,6 @@ | |||
| 39 | #include <linux/types.h> | 39 | #include <linux/types.h> |
| 40 | #include <linux/module.h> | 40 | #include <linux/module.h> |
| 41 | #include <linux/pci.h> | 41 | #include <linux/pci.h> |
| 42 | #include <linux/hdreg.h> | ||
| 43 | #include <linux/ide.h> | 42 | #include <linux/ide.h> |
| 44 | #include <linux/init.h> | 43 | #include <linux/init.h> |
| 45 | #include <linux/io.h> | 44 | #include <linux/io.h> |
| @@ -223,7 +222,9 @@ static u8 sil_pata_udma_filter(ide_drive_t *drive) | |||
| 223 | 222 | ||
| 224 | static u8 sil_sata_udma_filter(ide_drive_t *drive) | 223 | static u8 sil_sata_udma_filter(ide_drive_t *drive) |
| 225 | { | 224 | { |
| 226 | return strstr(drive->id->model, "Maxtor") ? ATA_UDMA5 : ATA_UDMA6; | 225 | char *m = (char *)&drive->id[ATA_ID_PROD]; |
| 226 | |||
| 227 | return strstr(m, "Maxtor") ? ATA_UDMA5 : ATA_UDMA6; | ||
| 227 | } | 228 | } |
| 228 | 229 | ||
| 229 | /** | 230 | /** |
| @@ -243,7 +244,7 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio) | |||
| 243 | 244 | ||
| 244 | ide_hwif_t *hwif = HWIF(drive); | 245 | ide_hwif_t *hwif = HWIF(drive); |
| 245 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 246 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| 246 | ide_drive_t *pair = ide_get_paired_drive(drive); | 247 | ide_drive_t *pair = ide_get_pair_dev(drive); |
| 247 | u32 speedt = 0; | 248 | u32 speedt = 0; |
| 248 | u16 speedp = 0; | 249 | u16 speedp = 0; |
| 249 | unsigned long addr = siimage_seldev(drive, 0x04); | 250 | unsigned long addr = siimage_seldev(drive, 0x04); |
| @@ -257,7 +258,7 @@ static void sil_set_pio_mode(ide_drive_t *drive, u8 pio) | |||
| 257 | u8 unit = drive->select.b.unit; | 258 | u8 unit = drive->select.b.unit; |
| 258 | 259 | ||
| 259 | /* trim *taskfile* PIO to the slowest of the master/slave */ | 260 | /* trim *taskfile* PIO to the slowest of the master/slave */ |
| 260 | if (pair->present) { | 261 | if (pair) { |
| 261 | u8 pair_pio = ide_get_best_pio_mode(pair, 255, 4); | 262 | u8 pair_pio = ide_get_best_pio_mode(pair, 255, 4); |
| 262 | 263 | ||
| 263 | if (pair_pio < tf_pio) | 264 | if (pair_pio < tf_pio) |
| @@ -462,7 +463,7 @@ static void sil_sata_pre_reset(ide_drive_t *drive) | |||
| 462 | * to 133 MHz clocking if the system isn't already set up to do it. | 463 | * to 133 MHz clocking if the system isn't already set up to do it. |
| 463 | */ | 464 | */ |
| 464 | 465 | ||
| 465 | static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev) | 466 | static unsigned int init_chipset_siimage(struct pci_dev *dev) |
| 466 | { | 467 | { |
| 467 | struct ide_host *host = pci_get_drvdata(dev); | 468 | struct ide_host *host = pci_get_drvdata(dev); |
| 468 | void __iomem *ioaddr = host->host_priv; | 469 | void __iomem *ioaddr = host->host_priv; |
| @@ -616,8 +617,8 @@ static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) | |||
| 616 | 617 | ||
| 617 | static int is_dev_seagate_sata(ide_drive_t *drive) | 618 | static int is_dev_seagate_sata(ide_drive_t *drive) |
| 618 | { | 619 | { |
| 619 | const char *s = &drive->id->model[0]; | 620 | const char *s = (const char *)&drive->id[ATA_ID_PROD]; |
| 620 | unsigned len = strnlen(s, sizeof(drive->id->model)); | 621 | unsigned len = strnlen(s, ATA_ID_PROD_LEN); |
| 621 | 622 | ||
| 622 | if ((len > 4) && (!memcmp(s, "ST", 2))) | 623 | if ((len > 4) && (!memcmp(s, "ST", 2))) |
| 623 | if ((!memcmp(s + len - 2, "AS", 2)) || | 624 | if ((!memcmp(s + len - 2, "AS", 2)) || |
| @@ -833,6 +834,8 @@ static struct pci_driver driver = { | |||
| 833 | .id_table = siimage_pci_tbl, | 834 | .id_table = siimage_pci_tbl, |
| 834 | .probe = siimage_init_one, | 835 | .probe = siimage_init_one, |
| 835 | .remove = __devexit_p(siimage_remove), | 836 | .remove = __devexit_p(siimage_remove), |
| 837 | .suspend = ide_pci_suspend, | ||
| 838 | .resume = ide_pci_resume, | ||
| 836 | }; | 839 | }; |
| 837 | 840 | ||
| 838 | static int __init siimage_ide_init(void) | 841 | static int __init siimage_ide_init(void) |
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c index 5efe21d6ef97..734dd41f1f67 100644 --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c | |||
| @@ -47,7 +47,6 @@ | |||
| 47 | #include <linux/types.h> | 47 | #include <linux/types.h> |
| 48 | #include <linux/module.h> | 48 | #include <linux/module.h> |
| 49 | #include <linux/kernel.h> | 49 | #include <linux/kernel.h> |
| 50 | #include <linux/hdreg.h> | ||
| 51 | #include <linux/pci.h> | 50 | #include <linux/pci.h> |
| 52 | #include <linux/init.h> | 51 | #include <linux/init.h> |
| 53 | #include <linux/ide.h> | 52 | #include <linux/ide.h> |
| @@ -448,7 +447,7 @@ static int __devinit sis_find_family(struct pci_dev *dev) | |||
| 448 | return chipset_family; | 447 | return chipset_family; |
| 449 | } | 448 | } |
| 450 | 449 | ||
| 451 | static unsigned int __devinit init_chipset_sis5513(struct pci_dev *dev) | 450 | static unsigned int init_chipset_sis5513(struct pci_dev *dev) |
| 452 | { | 451 | { |
| 453 | /* Make general config ops here | 452 | /* Make general config ops here |
| 454 | 1/ tell IDE channels to operate in Compatibility mode only | 453 | 1/ tell IDE channels to operate in Compatibility mode only |
| @@ -611,6 +610,8 @@ static struct pci_driver driver = { | |||
| 611 | .id_table = sis5513_pci_tbl, | 610 | .id_table = sis5513_pci_tbl, |
| 612 | .probe = sis5513_init_one, | 611 | .probe = sis5513_init_one, |
| 613 | .remove = __devexit_p(sis5513_remove), | 612 | .remove = __devexit_p(sis5513_remove), |
| 613 | .suspend = ide_pci_suspend, | ||
| 614 | .resume = ide_pci_resume, | ||
| 614 | }; | 615 | }; |
| 615 | 616 | ||
| 616 | static int __init sis5513_ide_init(void) | 617 | static int __init sis5513_ide_init(void) |
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c index 73905bcc08fb..37a6b7bdc040 100644 --- a/drivers/ide/pci/sl82c105.c +++ b/drivers/ide/pci/sl82c105.c | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
| 18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/hdreg.h> | ||
| 21 | #include <linux/pci.h> | 20 | #include <linux/pci.h> |
| 22 | #include <linux/ide.h> | 21 | #include <linux/ide.h> |
| 23 | 22 | ||
| @@ -62,7 +61,7 @@ static unsigned int get_pio_timings(ide_drive_t *drive, u8 pio) | |||
| 62 | if (cmd_off == 0) | 61 | if (cmd_off == 0) |
| 63 | cmd_off = 1; | 62 | cmd_off = 1; |
| 64 | 63 | ||
| 65 | if (pio > 2 || ide_dev_has_iordy(drive->id)) | 64 | if (pio > 2 || ata_id_has_iordy(drive->id)) |
| 66 | iordy = 0x40; | 65 | iordy = 0x40; |
| 67 | 66 | ||
| 68 | return (cmd_on - 1) << 8 | (cmd_off - 1) | iordy; | 67 | return (cmd_on - 1) << 8 | (cmd_off - 1) | iordy; |
| @@ -272,7 +271,7 @@ static u8 sl82c105_bridge_revision(struct pci_dev *dev) | |||
| 272 | * channel 0 here at least, but channel 1 has to be enabled by | 271 | * channel 0 here at least, but channel 1 has to be enabled by |
| 273 | * firmware or arch code. We still set both to 16 bits mode. | 272 | * firmware or arch code. We still set both to 16 bits mode. |
| 274 | */ | 273 | */ |
| 275 | static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev) | 274 | static unsigned int init_chipset_sl82c105(struct pci_dev *dev) |
| 276 | { | 275 | { |
| 277 | u32 val; | 276 | u32 val; |
| 278 | 277 | ||
| @@ -351,6 +350,8 @@ static struct pci_driver driver = { | |||
| 351 | .id_table = sl82c105_pci_tbl, | 350 | .id_table = sl82c105_pci_tbl, |
| 352 | .probe = sl82c105_init_one, | 351 | .probe = sl82c105_init_one, |
| 353 | .remove = ide_pci_remove, | 352 | .remove = ide_pci_remove, |
| 353 | .suspend = ide_pci_suspend, | ||
| 354 | .resume = ide_pci_resume, | ||
| 354 | }; | 355 | }; |
| 355 | 356 | ||
| 356 | static int __init sl82c105_ide_init(void) | 357 | static int __init sl82c105_ide_init(void) |
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c index 866d6c65e3a0..a9551a13ac57 100644 --- a/drivers/ide/pci/slc90e66.c +++ b/drivers/ide/pci/slc90e66.c | |||
| @@ -11,7 +11,6 @@ | |||
| 11 | #include <linux/module.h> | 11 | #include <linux/module.h> |
| 12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
| 13 | #include <linux/pci.h> | 13 | #include <linux/pci.h> |
| 14 | #include <linux/hdreg.h> | ||
| 15 | #include <linux/ide.h> | 14 | #include <linux/ide.h> |
| 16 | #include <linux/init.h> | 15 | #include <linux/init.h> |
| 17 | 16 | ||
| @@ -160,6 +159,8 @@ static struct pci_driver driver = { | |||
| 160 | .id_table = slc90e66_pci_tbl, | 159 | .id_table = slc90e66_pci_tbl, |
| 161 | .probe = slc90e66_init_one, | 160 | .probe = slc90e66_init_one, |
| 162 | .remove = ide_pci_remove, | 161 | .remove = ide_pci_remove, |
| 162 | .suspend = ide_pci_suspend, | ||
| 163 | .resume = ide_pci_resume, | ||
| 163 | }; | 164 | }; |
| 164 | 165 | ||
| 165 | static int __init slc90e66_ide_init(void) | 166 | static int __init slc90e66_ide_init(void) |
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c index b77ec35151b3..be8715dcee05 100644 --- a/drivers/ide/pci/triflex.c +++ b/drivers/ide/pci/triflex.c | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | #include <linux/types.h> | 28 | #include <linux/types.h> |
| 29 | #include <linux/module.h> | 29 | #include <linux/module.h> |
| 30 | #include <linux/kernel.h> | 30 | #include <linux/kernel.h> |
| 31 | #include <linux/hdreg.h> | ||
| 32 | #include <linux/pci.h> | 31 | #include <linux/pci.h> |
| 33 | #include <linux/ide.h> | 32 | #include <linux/ide.h> |
| 34 | #include <linux/init.h> | 33 | #include <linux/init.h> |
| @@ -120,6 +119,8 @@ static struct pci_driver driver = { | |||
| 120 | .id_table = triflex_pci_tbl, | 119 | .id_table = triflex_pci_tbl, |
| 121 | .probe = triflex_init_one, | 120 | .probe = triflex_init_one, |
| 122 | .remove = ide_pci_remove, | 121 | .remove = ide_pci_remove, |
| 122 | .suspend = ide_pci_suspend, | ||
| 123 | .resume = ide_pci_resume, | ||
| 123 | }; | 124 | }; |
| 124 | 125 | ||
| 125 | static int __init triflex_ide_init(void) | 126 | static int __init triflex_ide_init(void) |
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c index fd28b49977fd..4dfbc6a68b5b 100644 --- a/drivers/ide/pci/trm290.c +++ b/drivers/ide/pci/trm290.c | |||
| @@ -135,7 +135,6 @@ | |||
| 135 | #include <linux/interrupt.h> | 135 | #include <linux/interrupt.h> |
| 136 | #include <linux/blkdev.h> | 136 | #include <linux/blkdev.h> |
| 137 | #include <linux/init.h> | 137 | #include <linux/init.h> |
| 138 | #include <linux/hdreg.h> | ||
| 139 | #include <linux/pci.h> | 138 | #include <linux/pci.h> |
| 140 | #include <linux/ide.h> | 139 | #include <linux/ide.h> |
| 141 | 140 | ||
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c index 94fb9ab3223f..acacdaab69c2 100644 --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c | |||
| @@ -154,7 +154,7 @@ static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) | |||
| 154 | static void via_set_drive(ide_drive_t *drive, const u8 speed) | 154 | static void via_set_drive(ide_drive_t *drive, const u8 speed) |
| 155 | { | 155 | { |
| 156 | ide_hwif_t *hwif = drive->hwif; | 156 | ide_hwif_t *hwif = drive->hwif; |
| 157 | ide_drive_t *peer = hwif->drives + (~drive->dn & 1); | 157 | ide_drive_t *peer = ide_get_pair_dev(drive); |
| 158 | struct pci_dev *dev = to_pci_dev(hwif->dev); | 158 | struct pci_dev *dev = to_pci_dev(hwif->dev); |
| 159 | struct ide_host *host = pci_get_drvdata(dev); | 159 | struct ide_host *host = pci_get_drvdata(dev); |
| 160 | struct via82cxxx_dev *vdev = host->host_priv; | 160 | struct via82cxxx_dev *vdev = host->host_priv; |
| @@ -173,7 +173,7 @@ static void via_set_drive(ide_drive_t *drive, const u8 speed) | |||
| 173 | 173 | ||
| 174 | ide_timing_compute(drive, speed, &t, T, UT); | 174 | ide_timing_compute(drive, speed, &t, T, UT); |
| 175 | 175 | ||
| 176 | if (peer->present) { | 176 | if (peer) { |
| 177 | ide_timing_compute(peer, peer->current_speed, &p, T, UT); | 177 | ide_timing_compute(peer, peer->current_speed, &p, T, UT); |
| 178 | ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); | 178 | ide_timing_merge(&p, &t, &t, IDE_TIMING_8BIT); |
| 179 | } | 179 | } |
| @@ -215,7 +215,7 @@ static struct via_isa_bridge *via_config_find(struct pci_dev **isa) | |||
| 215 | /* | 215 | /* |
| 216 | * Check and handle 80-wire cable presence | 216 | * Check and handle 80-wire cable presence |
| 217 | */ | 217 | */ |
| 218 | static void __devinit via_cable_detect(struct via82cxxx_dev *vdev, u32 u) | 218 | static void via_cable_detect(struct via82cxxx_dev *vdev, u32 u) |
| 219 | { | 219 | { |
| 220 | int i; | 220 | int i; |
| 221 | 221 | ||
| @@ -267,7 +267,7 @@ static void __devinit via_cable_detect(struct via82cxxx_dev *vdev, u32 u) | |||
| 267 | * and initialize its drive independent registers. | 267 | * and initialize its drive independent registers. |
| 268 | */ | 268 | */ |
| 269 | 269 | ||
| 270 | static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev) | 270 | static unsigned int init_chipset_via82cxxx(struct pci_dev *dev) |
| 271 | { | 271 | { |
| 272 | struct ide_host *host = pci_get_drvdata(dev); | 272 | struct ide_host *host = pci_get_drvdata(dev); |
| 273 | struct via82cxxx_dev *vdev = host->host_priv; | 273 | struct via82cxxx_dev *vdev = host->host_priv; |
| @@ -492,6 +492,8 @@ static struct pci_driver driver = { | |||
| 492 | .id_table = via_pci_tbl, | 492 | .id_table = via_pci_tbl, |
| 493 | .probe = via_init_one, | 493 | .probe = via_init_one, |
| 494 | .remove = __devexit_p(via_remove), | 494 | .remove = __devexit_p(via_remove), |
| 495 | .suspend = ide_pci_suspend, | ||
| 496 | .resume = ide_pci_resume, | ||
| 495 | }; | 497 | }; |
| 496 | 498 | ||
| 497 | static int __init via_ide_init(void) | 499 | static int __init via_ide_init(void) |
diff --git a/drivers/ide/ppc/pmac.c b/drivers/ide/ppc/pmac.c index fa2be26272d5..c3432da78d52 100644 --- a/drivers/ide/ppc/pmac.c +++ b/drivers/ide/ppc/pmac.c | |||
| @@ -669,9 +669,9 @@ static void | |||
| 669 | set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2, | 669 | set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2, |
| 670 | u8 speed) | 670 | u8 speed) |
| 671 | { | 671 | { |
| 672 | u16 *id = drive->id; | ||
| 672 | int cycleTime, accessTime = 0, recTime = 0; | 673 | int cycleTime, accessTime = 0, recTime = 0; |
| 673 | unsigned accessTicks, recTicks; | 674 | unsigned accessTicks, recTicks; |
| 674 | struct hd_driveid *id = drive->id; | ||
| 675 | struct mdma_timings_t* tm = NULL; | 675 | struct mdma_timings_t* tm = NULL; |
| 676 | int i; | 676 | int i; |
| 677 | 677 | ||
| @@ -686,8 +686,8 @@ set_timings_mdma(ide_drive_t *drive, int intf_type, u32 *timings, u32 *timings2, | |||
| 686 | } | 686 | } |
| 687 | 687 | ||
| 688 | /* Check if drive provides explicit DMA cycle time */ | 688 | /* Check if drive provides explicit DMA cycle time */ |
| 689 | if ((id->field_valid & 2) && id->eide_dma_time) | 689 | if ((id[ATA_ID_FIELD_VALID] & 2) && id[ATA_ID_EIDE_DMA_TIME]) |
| 690 | cycleTime = max_t(int, id->eide_dma_time, cycleTime); | 690 | cycleTime = max_t(int, id[ATA_ID_EIDE_DMA_TIME], cycleTime); |
| 691 | 691 | ||
| 692 | /* OHare limits according to some old Apple sources */ | 692 | /* OHare limits according to some old Apple sources */ |
| 693 | if ((intf_type == controller_ohare) && (cycleTime < 150)) | 693 | if ((intf_type == controller_ohare) && (cycleTime < 150)) |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index a8e9e8a69a52..9f1f9163a136 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
| @@ -659,3 +659,36 @@ void ide_pci_remove(struct pci_dev *dev) | |||
| 659 | pci_disable_device(dev); | 659 | pci_disable_device(dev); |
| 660 | } | 660 | } |
| 661 | EXPORT_SYMBOL_GPL(ide_pci_remove); | 661 | EXPORT_SYMBOL_GPL(ide_pci_remove); |
| 662 | |||
| 663 | #ifdef CONFIG_PM | ||
| 664 | int ide_pci_suspend(struct pci_dev *dev, pm_message_t state) | ||
| 665 | { | ||
| 666 | pci_save_state(dev); | ||
| 667 | pci_disable_device(dev); | ||
| 668 | pci_set_power_state(dev, pci_choose_state(dev, state)); | ||
| 669 | |||
| 670 | return 0; | ||
| 671 | } | ||
| 672 | EXPORT_SYMBOL_GPL(ide_pci_suspend); | ||
| 673 | |||
| 674 | int ide_pci_resume(struct pci_dev *dev) | ||
| 675 | { | ||
| 676 | struct ide_host *host = pci_get_drvdata(dev); | ||
| 677 | int rc; | ||
| 678 | |||
| 679 | pci_set_power_state(dev, PCI_D0); | ||
| 680 | |||
| 681 | rc = pci_enable_device(dev); | ||
| 682 | if (rc) | ||
| 683 | return rc; | ||
| 684 | |||
| 685 | pci_restore_state(dev); | ||
| 686 | pci_set_master(dev); | ||
| 687 | |||
| 688 | if (host->init_chipset) | ||
| 689 | host->init_chipset(dev); | ||
| 690 | |||
| 691 | return 0; | ||
| 692 | } | ||
| 693 | EXPORT_SYMBOL_GPL(ide_pci_resume); | ||
| 694 | #endif | ||
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 81c16cba5417..90212ac33be3 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
| @@ -40,7 +40,6 @@ | |||
| 40 | #include <linux/ioport.h> | 40 | #include <linux/ioport.h> |
| 41 | #include <linux/blkdev.h> | 41 | #include <linux/blkdev.h> |
| 42 | #include <linux/errno.h> | 42 | #include <linux/errno.h> |
| 43 | #include <linux/hdreg.h> | ||
| 44 | #include <linux/slab.h> | 43 | #include <linux/slab.h> |
| 45 | #include <linux/ide.h> | 44 | #include <linux/ide.h> |
| 46 | #include <linux/scatterlist.h> | 45 | #include <linux/scatterlist.h> |
| @@ -131,50 +130,6 @@ static inline idescsi_scsi_t *drive_to_idescsi(ide_drive_t *ide_drive) | |||
| 131 | return scsihost_to_idescsi(ide_drive->driver_data); | 130 | return scsihost_to_idescsi(ide_drive->driver_data); |
| 132 | } | 131 | } |
| 133 | 132 | ||
| 134 | /* | ||
| 135 | * PIO data transfer routine using the scatter gather table. | ||
| 136 | */ | ||
| 137 | static void ide_scsi_io_buffers(ide_drive_t *drive, struct ide_atapi_pc *pc, | ||
| 138 | unsigned int bcount, int write) | ||
| 139 | { | ||
| 140 | ide_hwif_t *hwif = drive->hwif; | ||
| 141 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
| 142 | xfer_func_t *xf = write ? tp_ops->output_data : tp_ops->input_data; | ||
| 143 | char *buf; | ||
| 144 | int count; | ||
| 145 | |||
| 146 | while (bcount) { | ||
| 147 | count = min(pc->sg->length - pc->b_count, bcount); | ||
| 148 | if (PageHighMem(sg_page(pc->sg))) { | ||
| 149 | unsigned long flags; | ||
| 150 | |||
| 151 | local_irq_save(flags); | ||
| 152 | buf = kmap_atomic(sg_page(pc->sg), KM_IRQ0) + | ||
| 153 | pc->sg->offset; | ||
| 154 | xf(drive, NULL, buf + pc->b_count, count); | ||
| 155 | kunmap_atomic(buf - pc->sg->offset, KM_IRQ0); | ||
| 156 | local_irq_restore(flags); | ||
| 157 | } else { | ||
| 158 | buf = sg_virt(pc->sg); | ||
| 159 | xf(drive, NULL, buf + pc->b_count, count); | ||
| 160 | } | ||
| 161 | bcount -= count; pc->b_count += count; | ||
| 162 | if (pc->b_count == pc->sg->length) { | ||
| 163 | if (!--pc->sg_cnt) | ||
| 164 | break; | ||
| 165 | pc->sg = sg_next(pc->sg); | ||
| 166 | pc->b_count = 0; | ||
| 167 | } | ||
| 168 | } | ||
| 169 | |||
| 170 | if (bcount) { | ||
| 171 | printk(KERN_ERR "%s: scatter gather table too small, %s\n", | ||
| 172 | drive->name, write ? "padding with zeros" | ||
| 173 | : "discarding data"); | ||
| 174 | ide_pad_transfer(drive, write, bcount); | ||
| 175 | } | ||
| 176 | } | ||
| 177 | |||
| 178 | static void ide_scsi_hex_dump(u8 *data, int len) | 133 | static void ide_scsi_hex_dump(u8 *data, int len) |
| 179 | { | 134 | { |
| 180 | print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0); | 135 | print_hex_dump(KERN_CONT, "", DUMP_PREFIX_NONE, 16, 1, data, len, 0); |
| @@ -244,9 +199,9 @@ idescsi_atapi_error(ide_drive_t *drive, struct request *rq, u8 stat, u8 err) | |||
| 244 | { | 199 | { |
| 245 | ide_hwif_t *hwif = drive->hwif; | 200 | ide_hwif_t *hwif = drive->hwif; |
| 246 | 201 | ||
| 247 | if (hwif->tp_ops->read_status(hwif) & (BUSY_STAT | DRQ_STAT)) | 202 | if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ)) |
| 248 | /* force an abort */ | 203 | /* force an abort */ |
| 249 | hwif->tp_ops->exec_command(hwif, WIN_IDLEIMMEDIATE); | 204 | hwif->tp_ops->exec_command(hwif, ATA_CMD_IDLEIMMEDIATE); |
| 250 | 205 | ||
| 251 | rq->errors++; | 206 | rq->errors++; |
| 252 | 207 | ||
| @@ -344,7 +299,7 @@ static ide_startstop_t idescsi_pc_intr (ide_drive_t *drive) | |||
| 344 | 299 | ||
| 345 | return ide_pc_intr(drive, pc, idescsi_pc_intr, get_timeout(pc), | 300 | return ide_pc_intr(drive, pc, idescsi_pc_intr, get_timeout(pc), |
| 346 | idescsi_expiry, NULL, NULL, NULL, | 301 | idescsi_expiry, NULL, NULL, NULL, |
| 347 | ide_scsi_io_buffers); | 302 | ide_io_buffers); |
| 348 | } | 303 | } |
| 349 | 304 | ||
| 350 | static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) | 305 | static ide_startstop_t idescsi_transfer_pc(ide_drive_t *drive) |
| @@ -430,21 +385,41 @@ static ide_startstop_t idescsi_do_request (ide_drive_t *drive, struct request *r | |||
| 430 | } | 385 | } |
| 431 | 386 | ||
| 432 | #ifdef CONFIG_IDE_PROC_FS | 387 | #ifdef CONFIG_IDE_PROC_FS |
| 433 | static void idescsi_add_settings(ide_drive_t *drive) | 388 | #define ide_scsi_devset_get(name, field) \ |
| 434 | { | 389 | static int get_##name(ide_drive_t *drive) \ |
| 435 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); | 390 | { \ |
| 436 | 391 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); \ | |
| 437 | /* | 392 | return scsi->field; \ |
| 438 | * drive setting name read/write data type min max mul_factor div_factor data pointer set function | 393 | } |
| 439 | */ | 394 | |
| 440 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 1023, 1, 1, &drive->bios_cyl, NULL); | 395 | #define ide_scsi_devset_set(name, field) \ |
| 441 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, &drive->bios_head, NULL); | 396 | static int set_##name(ide_drive_t *drive, int arg) \ |
| 442 | ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, &drive->bios_sect, NULL); | 397 | { \ |
| 443 | ide_add_setting(drive, "transform", SETTING_RW, TYPE_INT, 0, 3, 1, 1, &scsi->transform, NULL); | 398 | idescsi_scsi_t *scsi = drive_to_idescsi(drive); \ |
| 444 | ide_add_setting(drive, "log", SETTING_RW, TYPE_INT, 0, 1, 1, 1, &scsi->log, NULL); | 399 | scsi->field = arg; \ |
| 445 | } | 400 | return 0; \ |
| 446 | #else | 401 | } |
| 447 | static inline void idescsi_add_settings(ide_drive_t *drive) { ; } | 402 | |
| 403 | #define ide_scsi_devset_rw_field(_name, _field) \ | ||
| 404 | ide_scsi_devset_get(_name, _field); \ | ||
| 405 | ide_scsi_devset_set(_name, _field); \ | ||
| 406 | IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name); | ||
| 407 | |||
| 408 | ide_devset_rw_field(bios_cyl, bios_cyl); | ||
| 409 | ide_devset_rw_field(bios_head, bios_head); | ||
| 410 | ide_devset_rw_field(bios_sect, bios_sect); | ||
| 411 | |||
| 412 | ide_scsi_devset_rw_field(transform, transform); | ||
| 413 | ide_scsi_devset_rw_field(log, log); | ||
| 414 | |||
| 415 | static const struct ide_proc_devset idescsi_settings[] = { | ||
| 416 | IDE_PROC_DEVSET(bios_cyl, 0, 1023), | ||
| 417 | IDE_PROC_DEVSET(bios_head, 0, 255), | ||
| 418 | IDE_PROC_DEVSET(bios_sect, 0, 63), | ||
| 419 | IDE_PROC_DEVSET(log, 0, 1), | ||
| 420 | IDE_PROC_DEVSET(transform, 0, 3), | ||
| 421 | { 0 }, | ||
| 422 | }; | ||
| 448 | #endif | 423 | #endif |
| 449 | 424 | ||
| 450 | /* | 425 | /* |
| @@ -452,7 +427,7 @@ static inline void idescsi_add_settings(ide_drive_t *drive) { ; } | |||
| 452 | */ | 427 | */ |
| 453 | static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi) | 428 | static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi) |
| 454 | { | 429 | { |
| 455 | if (drive->id && (drive->id->config & 0x0060) == 0x20) | 430 | if ((drive->id[ATA_ID_CONFIG] & 0x0060) == 0x20) |
| 456 | set_bit(IDE_AFLAG_DRQ_INTERRUPT, &drive->atapi_flags); | 431 | set_bit(IDE_AFLAG_DRQ_INTERRUPT, &drive->atapi_flags); |
| 457 | clear_bit(IDESCSI_SG_TRANSFORM, &scsi->transform); | 432 | clear_bit(IDESCSI_SG_TRANSFORM, &scsi->transform); |
| 458 | #if IDESCSI_DEBUG_LOG | 433 | #if IDESCSI_DEBUG_LOG |
| @@ -461,7 +436,7 @@ static void idescsi_setup (ide_drive_t *drive, idescsi_scsi_t *scsi) | |||
| 461 | 436 | ||
| 462 | drive->pc_callback = ide_scsi_callback; | 437 | drive->pc_callback = ide_scsi_callback; |
| 463 | 438 | ||
| 464 | idescsi_add_settings(drive); | 439 | ide_proc_register_driver(drive, scsi->driver); |
| 465 | } | 440 | } |
| 466 | 441 | ||
| 467 | static void ide_scsi_remove(ide_drive_t *drive) | 442 | static void ide_scsi_remove(ide_drive_t *drive) |
| @@ -503,12 +478,12 @@ static ide_driver_t idescsi_driver = { | |||
| 503 | .remove = ide_scsi_remove, | 478 | .remove = ide_scsi_remove, |
| 504 | .version = IDESCSI_VERSION, | 479 | .version = IDESCSI_VERSION, |
| 505 | .media = ide_scsi, | 480 | .media = ide_scsi, |
| 506 | .supports_dsc_overlap = 0, | ||
| 507 | .do_request = idescsi_do_request, | 481 | .do_request = idescsi_do_request, |
| 508 | .end_request = idescsi_end_request, | 482 | .end_request = idescsi_end_request, |
| 509 | .error = idescsi_atapi_error, | 483 | .error = idescsi_atapi_error, |
| 510 | #ifdef CONFIG_IDE_PROC_FS | 484 | #ifdef CONFIG_IDE_PROC_FS |
| 511 | .proc = idescsi_proc, | 485 | .proc = idescsi_proc, |
| 486 | .settings = idescsi_settings, | ||
| 512 | #endif | 487 | #endif |
| 513 | }; | 488 | }; |
| 514 | 489 | ||
| @@ -811,6 +786,7 @@ static int ide_scsi_probe(ide_drive_t *drive) | |||
| 811 | struct gendisk *g; | 786 | struct gendisk *g; |
| 812 | static int warned; | 787 | static int warned; |
| 813 | int err = -ENOMEM; | 788 | int err = -ENOMEM; |
| 789 | u16 last_lun; | ||
| 814 | 790 | ||
| 815 | if (!warned && drive->media == ide_cdrom) { | 791 | if (!warned && drive->media == ide_cdrom) { |
| 816 | printk(KERN_WARNING "ide-scsi is deprecated for cd burning! Use ide-cd and give dev=/dev/hdX as device\n"); | 792 | printk(KERN_WARNING "ide-scsi is deprecated for cd burning! Use ide-cd and give dev=/dev/hdX as device\n"); |
| @@ -821,7 +797,6 @@ static int ide_scsi_probe(ide_drive_t *drive) | |||
| 821 | return -ENODEV; | 797 | return -ENODEV; |
| 822 | 798 | ||
| 823 | if (!strstr("ide-scsi", drive->driver_req) || | 799 | if (!strstr("ide-scsi", drive->driver_req) || |
| 824 | !drive->present || | ||
| 825 | drive->media == ide_disk || | 800 | drive->media == ide_disk || |
| 826 | !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t)))) | 801 | !(host = scsi_host_alloc(&idescsi_template,sizeof(idescsi_scsi_t)))) |
| 827 | return -ENODEV; | 802 | return -ENODEV; |
| @@ -836,12 +811,12 @@ static int ide_scsi_probe(ide_drive_t *drive) | |||
| 836 | 811 | ||
| 837 | host->max_id = 1; | 812 | host->max_id = 1; |
| 838 | 813 | ||
| 839 | if (drive->id->last_lun) | 814 | last_lun = drive->id[ATA_ID_LAST_LUN]; |
| 840 | debug_log("%s: id->last_lun=%u\n", drive->name, | 815 | if (last_lun) |
| 841 | drive->id->last_lun); | 816 | debug_log("%s: last_lun=%u\n", drive->name, last_lun); |
| 842 | 817 | ||
| 843 | if ((drive->id->last_lun & 0x7) != 7) | 818 | if ((last_lun & 7) != 7) |
| 844 | host->max_lun = (drive->id->last_lun & 0x7) + 1; | 819 | host->max_lun = (last_lun & 7) + 1; |
| 845 | else | 820 | else |
| 846 | host->max_lun = 1; | 821 | host->max_lun = 1; |
| 847 | 822 | ||
| @@ -852,7 +827,6 @@ static int ide_scsi_probe(ide_drive_t *drive) | |||
| 852 | idescsi->host = host; | 827 | idescsi->host = host; |
| 853 | idescsi->disk = g; | 828 | idescsi->disk = g; |
| 854 | g->private_data = &idescsi->driver; | 829 | g->private_data = &idescsi->driver; |
| 855 | ide_proc_register_driver(drive, &idescsi_driver); | ||
| 856 | err = 0; | 830 | err = 0; |
| 857 | idescsi_setup(drive, idescsi); | 831 | idescsi_setup(drive, idescsi); |
| 858 | g->fops = &idescsi_ops; | 832 | g->fops = &idescsi_ops; |
diff --git a/include/linux/ata.h b/include/linux/ata.h index be00973d1a8c..a53318b8cbd0 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #define __LINUX_ATA_H__ | 30 | #define __LINUX_ATA_H__ |
| 31 | 31 | ||
| 32 | #include <linux/types.h> | 32 | #include <linux/types.h> |
| 33 | #include <asm/byteorder.h> | ||
| 33 | 34 | ||
| 34 | /* defines only for the constants which don't work well as enums */ | 35 | /* defines only for the constants which don't work well as enums */ |
| 35 | #define ATA_DMA_BOUNDARY 0xffffUL | 36 | #define ATA_DMA_BOUNDARY 0xffffUL |
| @@ -558,6 +559,15 @@ static inline int ata_id_has_flush(const u16 *id) | |||
| 558 | return id[ATA_ID_COMMAND_SET_2] & (1 << 12); | 559 | return id[ATA_ID_COMMAND_SET_2] & (1 << 12); |
| 559 | } | 560 | } |
| 560 | 561 | ||
| 562 | static inline int ata_id_flush_enabled(const u16 *id) | ||
| 563 | { | ||
| 564 | if (ata_id_has_flush(id) == 0) | ||
| 565 | return 0; | ||
| 566 | if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) | ||
| 567 | return 0; | ||
| 568 | return id[ATA_ID_CFS_ENABLE_2] & (1 << 12); | ||
| 569 | } | ||
| 570 | |||
| 561 | static inline int ata_id_has_flush_ext(const u16 *id) | 571 | static inline int ata_id_has_flush_ext(const u16 *id) |
| 562 | { | 572 | { |
| 563 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) | 573 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) |
| @@ -565,6 +575,19 @@ static inline int ata_id_has_flush_ext(const u16 *id) | |||
| 565 | return id[ATA_ID_COMMAND_SET_2] & (1 << 13); | 575 | return id[ATA_ID_COMMAND_SET_2] & (1 << 13); |
| 566 | } | 576 | } |
| 567 | 577 | ||
| 578 | static inline int ata_id_flush_ext_enabled(const u16 *id) | ||
| 579 | { | ||
| 580 | if (ata_id_has_flush_ext(id) == 0) | ||
| 581 | return 0; | ||
| 582 | if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) | ||
| 583 | return 0; | ||
| 584 | /* | ||
| 585 | * some Maxtor disks have bit 13 defined incorrectly | ||
| 586 | * so check bit 10 too | ||
| 587 | */ | ||
| 588 | return (id[ATA_ID_CFS_ENABLE_2] & 0x2400) == 0x2400; | ||
| 589 | } | ||
| 590 | |||
| 568 | static inline int ata_id_has_lba48(const u16 *id) | 591 | static inline int ata_id_has_lba48(const u16 *id) |
| 569 | { | 592 | { |
| 570 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) | 593 | if ((id[ATA_ID_COMMAND_SET_2] & 0xC000) != 0x4000) |
| @@ -574,6 +597,15 @@ static inline int ata_id_has_lba48(const u16 *id) | |||
| 574 | return id[ATA_ID_COMMAND_SET_2] & (1 << 10); | 597 | return id[ATA_ID_COMMAND_SET_2] & (1 << 10); |
| 575 | } | 598 | } |
| 576 | 599 | ||
| 600 | static inline int ata_id_lba48_enabled(const u16 *id) | ||
| 601 | { | ||
| 602 | if (ata_id_has_lba48(id) == 0) | ||
| 603 | return 0; | ||
| 604 | if ((id[ATA_ID_CSF_DEFAULT] & 0xC000) != 0x4000) | ||
| 605 | return 0; | ||
| 606 | return id[ATA_ID_CFS_ENABLE_2] & (1 << 10); | ||
| 607 | } | ||
| 608 | |||
| 577 | static inline int ata_id_hpa_enabled(const u16 *id) | 609 | static inline int ata_id_hpa_enabled(const u16 *id) |
| 578 | { | 610 | { |
| 579 | /* Yes children, word 83 valid bits cover word 82 data */ | 611 | /* Yes children, word 83 valid bits cover word 82 data */ |
| @@ -645,7 +677,15 @@ static inline unsigned int ata_id_major_version(const u16 *id) | |||
| 645 | 677 | ||
| 646 | static inline int ata_id_is_sata(const u16 *id) | 678 | static inline int ata_id_is_sata(const u16 *id) |
| 647 | { | 679 | { |
| 648 | return ata_id_major_version(id) >= 5 && id[ATA_ID_HW_CONFIG] == 0; | 680 | /* |
| 681 | * See if word 93 is 0 AND drive is at least ATA-5 compatible | ||
| 682 | * verifying that word 80 by casting it to a signed type -- | ||
| 683 | * this trick allows us to filter out the reserved values of | ||
| 684 | * 0x0000 and 0xffff along with the earlier ATA revisions... | ||
| 685 | */ | ||
| 686 | if (id[ATA_ID_HW_CONFIG] == 0 && (short)id[ATA_ID_MAJOR_VER] >= 0x0020) | ||
| 687 | return 1; | ||
| 688 | return 0; | ||
| 649 | } | 689 | } |
| 650 | 690 | ||
| 651 | static inline int ata_id_has_tpm(const u16 *id) | 691 | static inline int ata_id_has_tpm(const u16 *id) |
| @@ -742,6 +782,76 @@ static inline int atapi_id_dmadir(const u16 *dev_id) | |||
| 742 | return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000); | 782 | return ata_id_major_version(dev_id) >= 7 && (dev_id[62] & 0x8000); |
| 743 | } | 783 | } |
| 744 | 784 | ||
| 785 | /* | ||
| 786 | * ata_id_is_lba_capacity_ok() performs a sanity check on | ||
| 787 | * the claimed LBA capacity value for the device. | ||
| 788 | * | ||
| 789 | * Returns 1 if LBA capacity looks sensible, 0 otherwise. | ||
| 790 | * | ||
| 791 | * It is called only once for each device. | ||
| 792 | */ | ||
| 793 | static inline int ata_id_is_lba_capacity_ok(u16 *id) | ||
| 794 | { | ||
| 795 | unsigned long lba_sects, chs_sects, head, tail; | ||
| 796 | |||
| 797 | /* No non-LBA info .. so valid! */ | ||
| 798 | if (id[ATA_ID_CYLS] == 0) | ||
| 799 | return 1; | ||
| 800 | |||
| 801 | lba_sects = ata_id_u32(id, ATA_ID_LBA_CAPACITY); | ||
| 802 | |||
| 803 | /* | ||
| 804 | * The ATA spec tells large drives to return | ||
| 805 | * C/H/S = 16383/16/63 independent of their size. | ||
| 806 | * Some drives can be jumpered to use 15 heads instead of 16. | ||
| 807 | * Some drives can be jumpered to use 4092 cyls instead of 16383. | ||
| 808 | */ | ||
| 809 | if ((id[ATA_ID_CYLS] == 16383 || | ||
| 810 | (id[ATA_ID_CYLS] == 4092 && id[ATA_ID_CUR_CYLS] == 16383)) && | ||
| 811 | id[ATA_ID_SECTORS] == 63 && | ||
| 812 | (id[ATA_ID_HEADS] == 15 || id[ATA_ID_HEADS] == 16) && | ||
| 813 | (lba_sects >= 16383 * 63 * id[ATA_ID_HEADS])) | ||
| 814 | return 1; | ||
| 815 | |||
| 816 | chs_sects = id[ATA_ID_CYLS] * id[ATA_ID_HEADS] * id[ATA_ID_SECTORS]; | ||
| 817 | |||
| 818 | /* perform a rough sanity check on lba_sects: within 10% is OK */ | ||
| 819 | if (lba_sects - chs_sects < chs_sects/10) | ||
| 820 | return 1; | ||
| 821 | |||
| 822 | /* some drives have the word order reversed */ | ||
| 823 | head = (lba_sects >> 16) & 0xffff; | ||
| 824 | tail = lba_sects & 0xffff; | ||
| 825 | lba_sects = head | (tail << 16); | ||
| 826 | |||
| 827 | if (lba_sects - chs_sects < chs_sects/10) { | ||
| 828 | *(__le32 *)&id[ATA_ID_LBA_CAPACITY] = __cpu_to_le32(lba_sects); | ||
| 829 | return 1; /* LBA capacity is (now) good */ | ||
| 830 | } | ||
| 831 | |||
| 832 | return 0; /* LBA capacity value may be bad */ | ||
| 833 | } | ||
| 834 | |||
| 835 | static inline void ata_id_to_hd_driveid(u16 *id) | ||
| 836 | { | ||
| 837 | #ifdef __BIG_ENDIAN | ||
| 838 | /* accessed in struct hd_driveid as 8-bit values */ | ||
| 839 | id[ATA_ID_MAX_MULTSECT] = __cpu_to_le16(id[ATA_ID_MAX_MULTSECT]); | ||
| 840 | id[ATA_ID_CAPABILITY] = __cpu_to_le16(id[ATA_ID_CAPABILITY]); | ||
| 841 | id[ATA_ID_OLD_PIO_MODES] = __cpu_to_le16(id[ATA_ID_OLD_PIO_MODES]); | ||
| 842 | id[ATA_ID_OLD_DMA_MODES] = __cpu_to_le16(id[ATA_ID_OLD_DMA_MODES]); | ||
| 843 | id[ATA_ID_MULTSECT] = __cpu_to_le16(id[ATA_ID_MULTSECT]); | ||
| 844 | |||
| 845 | /* as 32-bit values */ | ||
| 846 | *(u32 *)&id[ATA_ID_LBA_CAPACITY] = ata_id_u32(id, ATA_ID_LBA_CAPACITY); | ||
| 847 | *(u32 *)&id[ATA_ID_SPG] = ata_id_u32(id, ATA_ID_SPG); | ||
| 848 | |||
| 849 | /* as 64-bit value */ | ||
| 850 | *(u64 *)&id[ATA_ID_LBA_CAPACITY_2] = | ||
| 851 | ata_id_u64(id, ATA_ID_LBA_CAPACITY_2); | ||
| 852 | #endif | ||
| 853 | } | ||
| 854 | |||
| 745 | static inline int is_multi_taskfile(struct ata_taskfile *tf) | 855 | static inline int is_multi_taskfile(struct ata_taskfile *tf) |
| 746 | { | 856 | { |
| 747 | return (tf->command == ATA_CMD_READ_MULTI) || | 857 | return (tf->command == ATA_CMD_READ_MULTI) || |
diff --git a/include/linux/ide.h b/include/linux/ide.h index 6514db8fd2e4..a9d82d6e6bdd 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include <linux/init.h> | 9 | #include <linux/init.h> |
| 10 | #include <linux/ioport.h> | 10 | #include <linux/ioport.h> |
| 11 | #include <linux/hdreg.h> | 11 | #include <linux/ata.h> |
| 12 | #include <linux/blkdev.h> | 12 | #include <linux/blkdev.h> |
| 13 | #include <linux/proc_fs.h> | 13 | #include <linux/proc_fs.h> |
| 14 | #include <linux/interrupt.h> | 14 | #include <linux/interrupt.h> |
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <linux/device.h> | 17 | #include <linux/device.h> |
| 18 | #include <linux/pci.h> | 18 | #include <linux/pci.h> |
| 19 | #include <linux/completion.h> | 19 | #include <linux/completion.h> |
| 20 | #include <linux/pm.h> | ||
| 20 | #ifdef CONFIG_BLK_DEV_IDEACPI | 21 | #ifdef CONFIG_BLK_DEV_IDEACPI |
| 21 | #include <acpi/acpi.h> | 22 | #include <acpi/acpi.h> |
| 22 | #endif | 23 | #endif |
| @@ -87,12 +88,13 @@ struct ide_io_ports { | |||
| 87 | }; | 88 | }; |
| 88 | 89 | ||
| 89 | #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) | 90 | #define OK_STAT(stat,good,bad) (((stat)&((good)|(bad)))==(good)) |
| 90 | #define BAD_R_STAT (BUSY_STAT | ERR_STAT) | ||
| 91 | #define BAD_W_STAT (BAD_R_STAT | WRERR_STAT) | ||
| 92 | #define BAD_STAT (BAD_R_STAT | DRQ_STAT) | ||
| 93 | #define DRIVE_READY (READY_STAT | SEEK_STAT) | ||
| 94 | 91 | ||
| 95 | #define BAD_CRC (ABRT_ERR | ICRC_ERR) | 92 | #define BAD_R_STAT (ATA_BUSY | ATA_ERR) |
| 93 | #define BAD_W_STAT (BAD_R_STAT | ATA_DF) | ||
| 94 | #define BAD_STAT (BAD_R_STAT | ATA_DRQ) | ||
| 95 | #define DRIVE_READY (ATA_DRDY | ATA_DSC) | ||
| 96 | |||
| 97 | #define BAD_CRC (ATA_ABORTED | ATA_ICRC) | ||
| 96 | 98 | ||
| 97 | #define SATA_NR_PORTS (3) /* 16 possible ?? */ | 99 | #define SATA_NR_PORTS (3) /* 16 possible ?? */ |
| 98 | 100 | ||
| @@ -125,24 +127,41 @@ struct ide_io_ports { | |||
| 125 | #define PARTN_BITS 6 /* number of minor dev bits for partitions */ | 127 | #define PARTN_BITS 6 /* number of minor dev bits for partitions */ |
| 126 | #define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */ | 128 | #define MAX_DRIVES 2 /* per interface; 2 assumed by lots of code */ |
| 127 | #define SECTOR_SIZE 512 | 129 | #define SECTOR_SIZE 512 |
| 128 | #define SECTOR_WORDS (SECTOR_SIZE / 4) /* number of 32bit words per sector */ | 130 | |
| 129 | #define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t))) | 131 | #define IDE_LARGE_SEEK(b1,b2,t) (((b1) > (b2) + (t)) || ((b2) > (b1) + (t))) |
| 130 | 132 | ||
| 131 | /* | 133 | /* |
| 132 | * Timeouts for various operations: | 134 | * Timeouts for various operations: |
| 133 | */ | 135 | */ |
| 134 | #define WAIT_DRQ (HZ/10) /* 100msec - spec allows up to 20ms */ | 136 | enum { |
| 135 | #define WAIT_READY (5*HZ) /* 5sec - some laptops are very slow */ | 137 | /* spec allows up to 20ms */ |
| 136 | #define WAIT_PIDENTIFY (10*HZ) /* 10sec - should be less than 3ms (?), if all ATAPI CD is closed at boot */ | 138 | WAIT_DRQ = HZ / 10, /* 100ms */ |
| 137 | #define WAIT_WORSTCASE (30*HZ) /* 30sec - worst case when spinning up */ | 139 | /* some laptops are very slow */ |
| 138 | #define WAIT_CMD (10*HZ) /* 10sec - maximum wait for an IRQ to happen */ | 140 | WAIT_READY = 5 * HZ, /* 5s */ |
| 139 | #define WAIT_MIN_SLEEP (2*HZ/100) /* 20msec - minimum sleep time */ | 141 | /* should be less than 3ms (?), if all ATAPI CD is closed at boot */ |
| 142 | WAIT_PIDENTIFY = 10 * HZ, /* 10s */ | ||
| 143 | /* worst case when spinning up */ | ||
| 144 | WAIT_WORSTCASE = 30 * HZ, /* 30s */ | ||
| 145 | /* maximum wait for an IRQ to happen */ | ||
| 146 | WAIT_CMD = 10 * HZ, /* 10s */ | ||
| 147 | /* Some drives require a longer IRQ timeout. */ | ||
| 148 | WAIT_FLOPPY_CMD = 50 * HZ, /* 50s */ | ||
| 149 | /* | ||
| 150 | * Some drives (for example, Seagate STT3401A Travan) require a very | ||
| 151 | * long timeout, because they don't return an interrupt or clear their | ||
| 152 | * BSY bit until after the command completes (even retension commands). | ||
| 153 | */ | ||
| 154 | WAIT_TAPE_CMD = 900 * HZ, /* 900s */ | ||
| 155 | /* minimum sleep time */ | ||
| 156 | WAIT_MIN_SLEEP = HZ / 50, /* 20ms */ | ||
| 157 | }; | ||
| 140 | 158 | ||
| 141 | /* | 159 | /* |
| 142 | * Op codes for special requests to be handled by ide_special_rq(). | 160 | * Op codes for special requests to be handled by ide_special_rq(). |
| 143 | * Values should be in the range of 0x20 to 0x3f. | 161 | * Values should be in the range of 0x20 to 0x3f. |
| 144 | */ | 162 | */ |
| 145 | #define REQ_DRIVE_RESET 0x20 | 163 | #define REQ_DRIVE_RESET 0x20 |
| 164 | #define REQ_DEVSET_EXEC 0x21 | ||
| 146 | 165 | ||
| 147 | /* | 166 | /* |
| 148 | * Check for an interrupt and acknowledge the interrupt status | 167 | * Check for an interrupt and acknowledge the interrupt status |
| @@ -303,8 +322,8 @@ typedef enum { | |||
| 303 | ide_started, /* a drive operation was started, handler was set */ | 322 | ide_started, /* a drive operation was started, handler was set */ |
| 304 | } ide_startstop_t; | 323 | } ide_startstop_t; |
| 305 | 324 | ||
| 325 | struct ide_devset; | ||
| 306 | struct ide_driver_s; | 326 | struct ide_driver_s; |
| 307 | struct ide_settings_s; | ||
| 308 | 327 | ||
| 309 | #ifdef CONFIG_BLK_DEV_IDEACPI | 328 | #ifdef CONFIG_BLK_DEV_IDEACPI |
| 310 | struct ide_acpi_drive_link; | 329 | struct ide_acpi_drive_link; |
| @@ -315,10 +334,10 @@ struct ide_acpi_hwif_link; | |||
| 315 | enum { | 334 | enum { |
| 316 | IDE_AFLAG_DRQ_INTERRUPT = (1 << 0), | 335 | IDE_AFLAG_DRQ_INTERRUPT = (1 << 0), |
| 317 | IDE_AFLAG_MEDIA_CHANGED = (1 << 1), | 336 | IDE_AFLAG_MEDIA_CHANGED = (1 << 1), |
| 318 | |||
| 319 | /* ide-cd */ | ||
| 320 | /* Drive cannot lock the door. */ | 337 | /* Drive cannot lock the door. */ |
| 321 | IDE_AFLAG_NO_DOORLOCK = (1 << 2), | 338 | IDE_AFLAG_NO_DOORLOCK = (1 << 2), |
| 339 | |||
| 340 | /* ide-cd */ | ||
| 322 | /* Drive cannot eject the disc. */ | 341 | /* Drive cannot eject the disc. */ |
| 323 | IDE_AFLAG_NO_EJECT = (1 << 3), | 342 | IDE_AFLAG_NO_EJECT = (1 << 3), |
| 324 | /* Drive is a pre ATAPI 1.2 drive. */ | 343 | /* Drive is a pre ATAPI 1.2 drive. */ |
| @@ -354,21 +373,25 @@ enum { | |||
| 354 | IDE_AFLAG_CLIK_DRIVE = (1 << 19), | 373 | IDE_AFLAG_CLIK_DRIVE = (1 << 19), |
| 355 | /* Requires BH algorithm for packets */ | 374 | /* Requires BH algorithm for packets */ |
| 356 | IDE_AFLAG_ZIP_DRIVE = (1 << 20), | 375 | IDE_AFLAG_ZIP_DRIVE = (1 << 20), |
| 376 | /* Write protect */ | ||
| 377 | IDE_AFLAG_WP = (1 << 21), | ||
| 378 | /* Supports format progress report */ | ||
| 379 | IDE_AFLAG_SRFP = (1 << 22), | ||
| 357 | 380 | ||
| 358 | /* ide-tape */ | 381 | /* ide-tape */ |
| 359 | IDE_AFLAG_IGNORE_DSC = (1 << 21), | 382 | IDE_AFLAG_IGNORE_DSC = (1 << 23), |
| 360 | /* 0 When the tape position is unknown */ | 383 | /* 0 When the tape position is unknown */ |
| 361 | IDE_AFLAG_ADDRESS_VALID = (1 << 22), | 384 | IDE_AFLAG_ADDRESS_VALID = (1 << 24), |
| 362 | /* Device already opened */ | 385 | /* Device already opened */ |
| 363 | IDE_AFLAG_BUSY = (1 << 23), | 386 | IDE_AFLAG_BUSY = (1 << 25), |
| 364 | /* Attempt to auto-detect the current user block size */ | 387 | /* Attempt to auto-detect the current user block size */ |
| 365 | IDE_AFLAG_DETECT_BS = (1 << 24), | 388 | IDE_AFLAG_DETECT_BS = (1 << 26), |
| 366 | /* Currently on a filemark */ | 389 | /* Currently on a filemark */ |
| 367 | IDE_AFLAG_FILEMARK = (1 << 25), | 390 | IDE_AFLAG_FILEMARK = (1 << 27), |
| 368 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ | 391 | /* 0 = no tape is loaded, so we don't rewind after ejecting */ |
| 369 | IDE_AFLAG_MEDIUM_PRESENT = (1 << 26), | 392 | IDE_AFLAG_MEDIUM_PRESENT = (1 << 28), |
| 370 | 393 | ||
| 371 | IDE_AFLAG_NO_AUTOCLOSE = (1 << 27), | 394 | IDE_AFLAG_NO_AUTOCLOSE = (1 << 29), |
| 372 | }; | 395 | }; |
| 373 | 396 | ||
| 374 | struct ide_drive_s { | 397 | struct ide_drive_s { |
| @@ -380,10 +403,10 @@ struct ide_drive_s { | |||
| 380 | struct request *rq; /* current request */ | 403 | struct request *rq; /* current request */ |
| 381 | struct ide_drive_s *next; /* circular list of hwgroup drives */ | 404 | struct ide_drive_s *next; /* circular list of hwgroup drives */ |
| 382 | void *driver_data; /* extra driver data */ | 405 | void *driver_data; /* extra driver data */ |
| 383 | struct hd_driveid *id; /* drive model identification info */ | 406 | u16 *id; /* identification info */ |
| 384 | #ifdef CONFIG_IDE_PROC_FS | 407 | #ifdef CONFIG_IDE_PROC_FS |
| 385 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ | 408 | struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ |
| 386 | struct ide_settings_s *settings;/* /proc/ide/ drive settings */ | 409 | const struct ide_proc_devset *settings; /* /proc/ide/ drive settings */ |
| 387 | #endif | 410 | #endif |
| 388 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ | 411 | struct hwif_s *hwif; /* actually (ide_hwif_t *) */ |
| 389 | 412 | ||
| @@ -395,16 +418,16 @@ struct ide_drive_s { | |||
| 395 | special_t special; /* special action flags */ | 418 | special_t special; /* special action flags */ |
| 396 | select_t select; /* basic drive/head select reg value */ | 419 | select_t select; /* basic drive/head select reg value */ |
| 397 | 420 | ||
| 398 | u8 keep_settings; /* restore settings after drive reset */ | ||
| 399 | u8 using_dma; /* disk is using dma for read/write */ | ||
| 400 | u8 retry_pio; /* retrying dma capable host in pio */ | 421 | u8 retry_pio; /* retrying dma capable host in pio */ |
| 401 | u8 state; /* retry state */ | 422 | u8 state; /* retry state */ |
| 402 | u8 waiting_for_dma; /* dma currently in progress */ | 423 | u8 waiting_for_dma; /* dma currently in progress */ |
| 403 | u8 unmask; /* okay to unmask other irqs */ | ||
| 404 | u8 noflush; /* don't attempt flushes */ | ||
| 405 | u8 dsc_overlap; /* DSC overlap */ | ||
| 406 | u8 nice1; /* give potential excess bandwidth */ | ||
| 407 | 424 | ||
| 425 | unsigned keep_settings : 1; /* restore settings after drive reset */ | ||
| 426 | unsigned using_dma : 1; /* disk is using dma for read/write */ | ||
| 427 | unsigned unmask : 1; /* okay to unmask other irqs */ | ||
| 428 | unsigned noflush : 1; /* don't attempt flushes */ | ||
| 429 | unsigned dsc_overlap : 1; /* DSC overlap */ | ||
| 430 | unsigned nice1 : 1; /* give potential excess bandwidth */ | ||
| 408 | unsigned present : 1; /* drive is physically present */ | 431 | unsigned present : 1; /* drive is physically present */ |
| 409 | unsigned dead : 1; /* device ejected hint */ | 432 | unsigned dead : 1; /* device ejected hint */ |
| 410 | unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ | 433 | unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ |
| @@ -414,23 +437,22 @@ struct ide_drive_s { | |||
| 414 | unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */ | 437 | unsigned forced_geom : 1; /* 1 if hdx=c,h,s was given at boot */ |
| 415 | unsigned no_unmask : 1; /* disallow setting unmask bit */ | 438 | unsigned no_unmask : 1; /* disallow setting unmask bit */ |
| 416 | unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ | 439 | unsigned no_io_32bit : 1; /* disallow enabling 32bit I/O */ |
| 417 | unsigned atapi_overlap : 1; /* ATAPI overlap (not supported) */ | ||
| 418 | unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ | 440 | unsigned doorlocking : 1; /* for removable only: door lock/unlock works */ |
| 419 | unsigned nodma : 1; /* disallow DMA */ | 441 | unsigned nodma : 1; /* disallow DMA */ |
| 420 | unsigned remap_0_to_1 : 1; /* 0=noremap, 1=remap 0->1 (for EZDrive) */ | ||
| 421 | unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ | 442 | unsigned blocked : 1; /* 1=powermanagment told us not to do anything, so sleep nicely */ |
| 422 | unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ | 443 | unsigned scsi : 1; /* 0=default, 1=ide-scsi emulation */ |
| 423 | unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ | 444 | unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ |
| 424 | unsigned post_reset : 1; | 445 | unsigned post_reset : 1; |
| 425 | unsigned udma33_warned : 1; | 446 | unsigned udma33_warned : 1; |
| 447 | unsigned addressing : 2; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */ | ||
| 448 | unsigned wcache : 1; /* status of write cache */ | ||
| 449 | unsigned nowerr : 1; /* used for ignoring ATA_DF */ | ||
| 426 | 450 | ||
| 427 | u8 addressing; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */ | ||
| 428 | u8 quirk_list; /* considered quirky, set for a specific host */ | 451 | u8 quirk_list; /* considered quirky, set for a specific host */ |
| 429 | u8 init_speed; /* transfer rate set at boot */ | 452 | u8 init_speed; /* transfer rate set at boot */ |
| 430 | u8 current_speed; /* current transfer rate set */ | 453 | u8 current_speed; /* current transfer rate set */ |
| 431 | u8 desired_speed; /* desired transfer rate set */ | 454 | u8 desired_speed; /* desired transfer rate set */ |
| 432 | u8 dn; /* now wide spread use */ | 455 | u8 dn; /* now wide spread use */ |
| 433 | u8 wcache; /* status of write cache */ | ||
| 434 | u8 acoustic; /* acoustic management */ | 456 | u8 acoustic; /* acoustic management */ |
| 435 | u8 media; /* disk, cdrom, tape, floppy, ... */ | 457 | u8 media; /* disk, cdrom, tape, floppy, ... */ |
| 436 | u8 ready_stat; /* min status value for drive ready */ | 458 | u8 ready_stat; /* min status value for drive ready */ |
| @@ -438,9 +460,7 @@ struct ide_drive_s { | |||
| 438 | u8 mult_req; /* requested multiple sector setting */ | 460 | u8 mult_req; /* requested multiple sector setting */ |
| 439 | u8 tune_req; /* requested drive tuning setting */ | 461 | u8 tune_req; /* requested drive tuning setting */ |
| 440 | u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ | 462 | u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ |
| 441 | u8 bad_wstat; /* used for ignoring WRERR_STAT */ | 463 | u8 bad_wstat; /* used for ignoring ATA_DF */ |
| 442 | u8 nowerr; /* used for ignoring WRERR_STAT */ | ||
| 443 | u8 sect0; /* offset of first sector for DM6:DDO */ | ||
| 444 | u8 head; /* "real" number of heads */ | 464 | u8 head; /* "real" number of heads */ |
| 445 | u8 sect; /* "real" sectors per track */ | 465 | u8 sect; /* "real" sectors per track */ |
| 446 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ | 466 | u8 bios_head; /* BIOS/fdisk/LILO number of heads */ |
| @@ -474,10 +494,6 @@ typedef struct ide_drive_s ide_drive_t; | |||
| 474 | 494 | ||
| 475 | #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) | 495 | #define to_ide_device(dev)container_of(dev, ide_drive_t, gendev) |
| 476 | 496 | ||
| 477 | #define IDE_CHIPSET_PCI_MASK \ | ||
| 478 | ((1<<ide_pci)|(1<<ide_cmd646)|(1<<ide_ali14xx)) | ||
| 479 | #define IDE_CHIPSET_IS_PCI(c) ((IDE_CHIPSET_PCI_MASK >> (c)) & 1) | ||
| 480 | |||
| 481 | struct ide_task_s; | 497 | struct ide_task_s; |
| 482 | struct ide_port_info; | 498 | struct ide_port_info; |
| 483 | 499 | ||
| @@ -567,7 +583,6 @@ typedef struct hwif_s { | |||
| 567 | u8 major; /* our major number */ | 583 | u8 major; /* our major number */ |
| 568 | u8 index; /* 0 for ide0; 1 for ide1; ... */ | 584 | u8 index; /* 0 for ide0; 1 for ide1; ... */ |
| 569 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ | 585 | u8 channel; /* for dual-port chips: 0=primary, 1=secondary */ |
| 570 | u8 bus_state; /* power state of the IDE bus */ | ||
| 571 | 586 | ||
| 572 | u32 host_flags; | 587 | u32 host_flags; |
| 573 | 588 | ||
| @@ -645,6 +660,7 @@ struct ide_host { | |||
| 645 | ide_hwif_t *ports[MAX_HWIFS]; | 660 | ide_hwif_t *ports[MAX_HWIFS]; |
| 646 | unsigned int n_ports; | 661 | unsigned int n_ports; |
| 647 | struct device *dev[2]; | 662 | struct device *dev[2]; |
| 663 | unsigned int (*init_chipset)(struct pci_dev *); | ||
| 648 | unsigned long host_flags; | 664 | unsigned long host_flags; |
| 649 | void *host_priv; | 665 | void *host_priv; |
| 650 | }; | 666 | }; |
| @@ -692,9 +708,61 @@ typedef struct ide_driver_s ide_driver_t; | |||
| 692 | 708 | ||
| 693 | extern struct mutex ide_setting_mtx; | 709 | extern struct mutex ide_setting_mtx; |
| 694 | 710 | ||
| 695 | int set_io_32bit(ide_drive_t *, int); | 711 | /* |
| 696 | int set_pio_mode(ide_drive_t *, int); | 712 | * configurable drive settings |
| 697 | int set_using_dma(ide_drive_t *, int); | 713 | */ |
| 714 | |||
| 715 | #define DS_SYNC (1 << 0) | ||
| 716 | |||
| 717 | struct ide_devset { | ||
| 718 | int (*get)(ide_drive_t *); | ||
| 719 | int (*set)(ide_drive_t *, int); | ||
| 720 | unsigned int flags; | ||
| 721 | }; | ||
| 722 | |||
| 723 | #define __DEVSET(_flags, _get, _set) { \ | ||
| 724 | .flags = _flags, \ | ||
| 725 | .get = _get, \ | ||
| 726 | .set = _set, \ | ||
| 727 | } | ||
| 728 | |||
| 729 | #define ide_devset_get(name, field) \ | ||
| 730 | static int get_##name(ide_drive_t *drive) \ | ||
| 731 | { \ | ||
| 732 | return drive->field; \ | ||
| 733 | } | ||
| 734 | |||
| 735 | #define ide_devset_set(name, field) \ | ||
| 736 | static int set_##name(ide_drive_t *drive, int arg) \ | ||
| 737 | { \ | ||
| 738 | drive->field = arg; \ | ||
| 739 | return 0; \ | ||
| 740 | } | ||
| 741 | |||
| 742 | #define __IDE_DEVSET(_name, _flags, _get, _set) \ | ||
| 743 | const struct ide_devset ide_devset_##_name = \ | ||
| 744 | __DEVSET(_flags, _get, _set) | ||
| 745 | |||
| 746 | #define IDE_DEVSET(_name, _flags, _get, _set) \ | ||
| 747 | static __IDE_DEVSET(_name, _flags, _get, _set) | ||
| 748 | |||
| 749 | #define ide_devset_rw(_name, _func) \ | ||
| 750 | IDE_DEVSET(_name, 0, get_##_func, set_##_func) | ||
| 751 | |||
| 752 | #define ide_devset_w(_name, _func) \ | ||
| 753 | IDE_DEVSET(_name, 0, NULL, set_##_func) | ||
| 754 | |||
| 755 | #define ide_devset_rw_sync(_name, _func) \ | ||
| 756 | IDE_DEVSET(_name, DS_SYNC, get_##_func, set_##_func) | ||
| 757 | |||
| 758 | #define ide_decl_devset(_name) \ | ||
| 759 | extern const struct ide_devset ide_devset_##_name | ||
| 760 | |||
| 761 | ide_decl_devset(io_32bit); | ||
| 762 | ide_decl_devset(keepsettings); | ||
| 763 | ide_decl_devset(pio_mode); | ||
| 764 | ide_decl_devset(unmaskirq); | ||
| 765 | ide_decl_devset(using_dma); | ||
| 698 | 766 | ||
| 699 | /* ATAPI packet command flags */ | 767 | /* ATAPI packet command flags */ |
| 700 | enum { | 768 | enum { |
| @@ -710,6 +778,12 @@ enum { | |||
| 710 | PC_FLAG_TIMEDOUT = (1 << 7), | 778 | PC_FLAG_TIMEDOUT = (1 << 7), |
| 711 | }; | 779 | }; |
| 712 | 780 | ||
| 781 | /* | ||
| 782 | * With each packet command, we allocate a buffer of IDE_PC_BUFFER_SIZE bytes. | ||
| 783 | * This is used for several packet commands (not for READ/WRITE commands). | ||
| 784 | */ | ||
| 785 | #define IDE_PC_BUFFER_SIZE 256 | ||
| 786 | |||
| 713 | struct ide_atapi_pc { | 787 | struct ide_atapi_pc { |
| 714 | /* actual packet bytes */ | 788 | /* actual packet bytes */ |
| 715 | u8 c[12]; | 789 | u8 c[12]; |
| @@ -739,7 +813,7 @@ struct ide_atapi_pc { | |||
| 739 | * those are more or less driver-specific and some of them are subject | 813 | * those are more or less driver-specific and some of them are subject |
| 740 | * to change/removal later. | 814 | * to change/removal later. |
| 741 | */ | 815 | */ |
| 742 | u8 pc_buf[256]; | 816 | u8 pc_buf[IDE_PC_BUFFER_SIZE]; |
| 743 | 817 | ||
| 744 | /* idetape only */ | 818 | /* idetape only */ |
| 745 | struct idetape_bh *bh; | 819 | struct idetape_bh *bh; |
| @@ -757,37 +831,34 @@ struct ide_atapi_pc { | |||
| 757 | 831 | ||
| 758 | #ifdef CONFIG_IDE_PROC_FS | 832 | #ifdef CONFIG_IDE_PROC_FS |
| 759 | /* | 833 | /* |
| 760 | * configurable drive settings | 834 | * /proc/ide interface |
| 761 | */ | 835 | */ |
| 762 | 836 | ||
| 763 | #define TYPE_INT 0 | 837 | #define ide_devset_rw_field(_name, _field) \ |
| 764 | #define TYPE_BYTE 1 | 838 | ide_devset_get(_name, _field); \ |
| 765 | #define TYPE_SHORT 2 | 839 | ide_devset_set(_name, _field); \ |
| 840 | IDE_DEVSET(_name, DS_SYNC, get_##_name, set_##_name) | ||
| 841 | |||
| 842 | struct ide_proc_devset { | ||
| 843 | const char *name; | ||
| 844 | const struct ide_devset *setting; | ||
| 845 | int min, max; | ||
| 846 | int (*mulf)(ide_drive_t *); | ||
| 847 | int (*divf)(ide_drive_t *); | ||
| 848 | }; | ||
| 766 | 849 | ||
| 767 | #define SETTING_READ (1 << 0) | 850 | #define __IDE_PROC_DEVSET(_name, _min, _max, _mulf, _divf) { \ |
| 768 | #define SETTING_WRITE (1 << 1) | 851 | .name = __stringify(_name), \ |
| 769 | #define SETTING_RW (SETTING_READ | SETTING_WRITE) | 852 | .setting = &ide_devset_##_name, \ |
| 853 | .min = _min, \ | ||
| 854 | .max = _max, \ | ||
| 855 | .mulf = _mulf, \ | ||
| 856 | .divf = _divf, \ | ||
| 857 | } | ||
| 770 | 858 | ||
| 771 | typedef int (ide_procset_t)(ide_drive_t *, int); | 859 | #define IDE_PROC_DEVSET(_name, _min, _max) \ |
| 772 | typedef struct ide_settings_s { | 860 | __IDE_PROC_DEVSET(_name, _min, _max, NULL, NULL) |
| 773 | char *name; | ||
| 774 | int rw; | ||
| 775 | int data_type; | ||
| 776 | int min; | ||
| 777 | int max; | ||
| 778 | int mul_factor; | ||
| 779 | int div_factor; | ||
| 780 | void *data; | ||
| 781 | ide_procset_t *set; | ||
| 782 | int auto_remove; | ||
| 783 | struct ide_settings_s *next; | ||
| 784 | } ide_settings_t; | ||
| 785 | |||
| 786 | int ide_add_setting(ide_drive_t *, const char *, int, int, int, int, int, int, void *, ide_procset_t *set); | ||
| 787 | 861 | ||
| 788 | /* | ||
| 789 | * /proc/ide interface | ||
| 790 | */ | ||
| 791 | typedef struct { | 862 | typedef struct { |
| 792 | const char *name; | 863 | const char *name; |
| 793 | mode_t mode; | 864 | mode_t mode; |
| @@ -804,8 +875,6 @@ void ide_proc_unregister_port(ide_hwif_t *); | |||
| 804 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); | 875 | void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); |
| 805 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); | 876 | void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); |
| 806 | 877 | ||
| 807 | void ide_add_generic_settings(ide_drive_t *); | ||
| 808 | |||
| 809 | read_proc_t proc_ide_read_capacity; | 878 | read_proc_t proc_ide_read_capacity; |
| 810 | read_proc_t proc_ide_read_geometry; | 879 | read_proc_t proc_ide_read_geometry; |
| 811 | 880 | ||
| @@ -833,7 +902,6 @@ static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; } | |||
| 833 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } | 902 | static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } |
| 834 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 903 | static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } |
| 835 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } | 904 | static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } |
| 836 | static inline void ide_add_generic_settings(ide_drive_t *drive) { ; } | ||
| 837 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; | 905 | #define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; |
| 838 | #endif | 906 | #endif |
| 839 | 907 | ||
| @@ -879,7 +947,6 @@ enum { | |||
| 879 | struct ide_driver_s { | 947 | struct ide_driver_s { |
| 880 | const char *version; | 948 | const char *version; |
| 881 | u8 media; | 949 | u8 media; |
| 882 | unsigned supports_dsc_overlap : 1; | ||
| 883 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); | 950 | ide_startstop_t (*do_request)(ide_drive_t *, struct request *, sector_t); |
| 884 | int (*end_request)(ide_drive_t *, int, int); | 951 | int (*end_request)(ide_drive_t *, int, int); |
| 885 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); | 952 | ide_startstop_t (*error)(ide_drive_t *, struct request *rq, u8, u8); |
| @@ -889,7 +956,8 @@ struct ide_driver_s { | |||
| 889 | void (*resume)(ide_drive_t *); | 956 | void (*resume)(ide_drive_t *); |
| 890 | void (*shutdown)(ide_drive_t *); | 957 | void (*shutdown)(ide_drive_t *); |
| 891 | #ifdef CONFIG_IDE_PROC_FS | 958 | #ifdef CONFIG_IDE_PROC_FS |
| 892 | ide_proc_entry_t *proc; | 959 | ide_proc_entry_t *proc; |
| 960 | const struct ide_proc_devset *settings; | ||
| 893 | #endif | 961 | #endif |
| 894 | }; | 962 | }; |
| 895 | 963 | ||
| @@ -898,7 +966,17 @@ struct ide_driver_s { | |||
| 898 | int ide_device_get(ide_drive_t *); | 966 | int ide_device_get(ide_drive_t *); |
| 899 | void ide_device_put(ide_drive_t *); | 967 | void ide_device_put(ide_drive_t *); |
| 900 | 968 | ||
| 901 | int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); | 969 | struct ide_ioctl_devset { |
| 970 | unsigned int get_ioctl; | ||
| 971 | unsigned int set_ioctl; | ||
| 972 | const struct ide_devset *setting; | ||
| 973 | }; | ||
| 974 | |||
| 975 | int ide_setting_ioctl(ide_drive_t *, struct block_device *, unsigned int, | ||
| 976 | unsigned long, const struct ide_ioctl_devset *); | ||
| 977 | |||
| 978 | int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, | ||
| 979 | unsigned, unsigned long); | ||
| 902 | 980 | ||
| 903 | extern int ide_vlb_clk; | 981 | extern int ide_vlb_clk; |
| 904 | extern int ide_pci_clk; | 982 | extern int ide_pci_clk; |
| @@ -920,14 +998,19 @@ ide_startstop_t __ide_error(ide_drive_t *, struct request *, u8, u8); | |||
| 920 | 998 | ||
| 921 | ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); | 999 | ide_startstop_t ide_error (ide_drive_t *drive, const char *msg, byte stat); |
| 922 | 1000 | ||
| 923 | extern void ide_fix_driveid(struct hd_driveid *); | 1001 | void ide_fix_driveid(u16 *); |
| 924 | 1002 | ||
| 925 | extern void ide_fixstring(u8 *, const int, const int); | 1003 | extern void ide_fixstring(u8 *, const int, const int); |
| 926 | 1004 | ||
| 1005 | int ide_busy_sleep(ide_hwif_t *, unsigned long, int); | ||
| 1006 | |||
| 927 | int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); | 1007 | int ide_wait_stat(ide_startstop_t *, ide_drive_t *, u8, u8, unsigned long); |
| 928 | 1008 | ||
| 929 | extern ide_startstop_t ide_do_reset (ide_drive_t *); | 1009 | extern ide_startstop_t ide_do_reset (ide_drive_t *); |
| 930 | 1010 | ||
| 1011 | extern int ide_devset_execute(ide_drive_t *drive, | ||
| 1012 | const struct ide_devset *setting, int arg); | ||
| 1013 | |||
| 931 | extern void ide_do_drive_cmd(ide_drive_t *, struct request *); | 1014 | extern void ide_do_drive_cmd(ide_drive_t *, struct request *); |
| 932 | 1015 | ||
| 933 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); | 1016 | extern void ide_end_drive_cmd(ide_drive_t *, u8, u8); |
| @@ -1051,6 +1134,8 @@ void ide_tf_read(ide_drive_t *, ide_task_t *); | |||
| 1051 | void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int); | 1134 | void ide_input_data(ide_drive_t *, struct request *, void *, unsigned int); |
| 1052 | void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int); | 1135 | void ide_output_data(ide_drive_t *, struct request *, void *, unsigned int); |
| 1053 | 1136 | ||
| 1137 | int ide_io_buffers(ide_drive_t *, struct ide_atapi_pc *, unsigned int, int); | ||
| 1138 | |||
| 1054 | extern void SELECT_DRIVE(ide_drive_t *); | 1139 | extern void SELECT_DRIVE(ide_drive_t *); |
| 1055 | void SELECT_MASK(ide_drive_t *, int); | 1140 | void SELECT_MASK(ide_drive_t *, int); |
| 1056 | 1141 | ||
| @@ -1061,11 +1146,36 @@ extern int drive_is_ready(ide_drive_t *); | |||
| 1061 | 1146 | ||
| 1062 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); | 1147 | void ide_pktcmd_tf_load(ide_drive_t *, u32, u16, u8); |
| 1063 | 1148 | ||
| 1149 | int ide_check_atapi_device(ide_drive_t *, const char *); | ||
| 1150 | |||
| 1151 | void ide_init_pc(struct ide_atapi_pc *); | ||
| 1152 | |||
| 1153 | /* | ||
| 1154 | * Special requests for ide-tape block device strategy routine. | ||
| 1155 | * | ||
| 1156 | * In order to service a character device command, we add special requests to | ||
| 1157 | * the tail of our block device request queue and wait for their completion. | ||
| 1158 | */ | ||
| 1159 | enum { | ||
| 1160 | REQ_IDETAPE_PC1 = (1 << 0), /* packet command (first stage) */ | ||
| 1161 | REQ_IDETAPE_PC2 = (1 << 1), /* packet command (second stage) */ | ||
| 1162 | REQ_IDETAPE_READ = (1 << 2), | ||
| 1163 | REQ_IDETAPE_WRITE = (1 << 3), | ||
| 1164 | }; | ||
| 1165 | |||
| 1166 | void ide_queue_pc_head(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *, | ||
| 1167 | struct request *); | ||
| 1168 | int ide_queue_pc_tail(ide_drive_t *, struct gendisk *, struct ide_atapi_pc *); | ||
| 1169 | |||
| 1170 | int ide_do_test_unit_ready(ide_drive_t *, struct gendisk *); | ||
| 1171 | int ide_do_start_stop(ide_drive_t *, struct gendisk *, int); | ||
| 1172 | int ide_set_media_lock(ide_drive_t *, struct gendisk *, int); | ||
| 1173 | |||
| 1064 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, | 1174 | ide_startstop_t ide_pc_intr(ide_drive_t *drive, struct ide_atapi_pc *pc, |
| 1065 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, | 1175 | ide_handler_t *handler, unsigned int timeout, ide_expiry_t *expiry, |
| 1066 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), | 1176 | void (*update_buffers)(ide_drive_t *, struct ide_atapi_pc *), |
| 1067 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), | 1177 | void (*retry_pc)(ide_drive_t *), void (*dsc_handle)(ide_drive_t *), |
| 1068 | void (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, | 1178 | int (*io_buffers)(ide_drive_t *, struct ide_atapi_pc *, unsigned int, |
| 1069 | int)); | 1179 | int)); |
| 1070 | ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, | 1180 | ide_startstop_t ide_transfer_pc(ide_drive_t *, struct ide_atapi_pc *, |
| 1071 | ide_handler_t *, unsigned int, ide_expiry_t *); | 1181 | ide_handler_t *, unsigned int, ide_expiry_t *); |
| @@ -1080,8 +1190,6 @@ int ide_raw_taskfile(ide_drive_t *, ide_task_t *, u8 *, u16); | |||
| 1080 | int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); | 1190 | int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); |
| 1081 | 1191 | ||
| 1082 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); | 1192 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); |
| 1083 | int ide_cmd_ioctl(ide_drive_t *, unsigned int, unsigned long); | ||
| 1084 | int ide_task_ioctl(ide_drive_t *, unsigned int, unsigned long); | ||
| 1085 | 1193 | ||
| 1086 | extern int ide_driveid_update(ide_drive_t *); | 1194 | extern int ide_driveid_update(ide_drive_t *); |
| 1087 | extern int ide_config_drive_speed(ide_drive_t *, u8); | 1195 | extern int ide_config_drive_speed(ide_drive_t *, u8); |
| @@ -1092,7 +1200,6 @@ extern int ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout); | |||
| 1092 | 1200 | ||
| 1093 | extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout); | 1201 | extern void ide_stall_queue(ide_drive_t *drive, unsigned long timeout); |
| 1094 | 1202 | ||
| 1095 | extern int ide_spin_wait_hwgroup(ide_drive_t *); | ||
| 1096 | extern void ide_timer_expiry(unsigned long); | 1203 | extern void ide_timer_expiry(unsigned long); |
| 1097 | extern irqreturn_t ide_intr(int irq, void *dev_id); | 1204 | extern irqreturn_t ide_intr(int irq, void *dev_id); |
| 1098 | extern void do_ide_request(struct request_queue *); | 1205 | extern void do_ide_request(struct request_queue *); |
| @@ -1229,6 +1336,14 @@ int ide_pci_init_two(struct pci_dev *, struct pci_dev *, | |||
| 1229 | const struct ide_port_info *, void *); | 1336 | const struct ide_port_info *, void *); |
| 1230 | void ide_pci_remove(struct pci_dev *); | 1337 | void ide_pci_remove(struct pci_dev *); |
| 1231 | 1338 | ||
| 1339 | #ifdef CONFIG_PM | ||
| 1340 | int ide_pci_suspend(struct pci_dev *, pm_message_t); | ||
| 1341 | int ide_pci_resume(struct pci_dev *); | ||
| 1342 | #else | ||
| 1343 | #define ide_pci_suspend NULL | ||
| 1344 | #define ide_pci_resume NULL | ||
| 1345 | #endif | ||
| 1346 | |||
| 1232 | void ide_map_sg(ide_drive_t *, struct request *); | 1347 | void ide_map_sg(ide_drive_t *, struct request *); |
| 1233 | void ide_init_sg_cmd(ide_drive_t *, struct request *); | 1348 | void ide_init_sg_cmd(ide_drive_t *, struct request *); |
| 1234 | 1349 | ||
| @@ -1240,7 +1355,7 @@ struct drive_list_entry { | |||
| 1240 | const char *id_firmware; | 1355 | const char *id_firmware; |
| 1241 | }; | 1356 | }; |
| 1242 | 1357 | ||
| 1243 | int ide_in_drive_list(struct hd_driveid *, const struct drive_list_entry *); | 1358 | int ide_in_drive_list(u16 *, const struct drive_list_entry *); |
| 1244 | 1359 | ||
| 1245 | #ifdef CONFIG_BLK_DEV_IDEDMA | 1360 | #ifdef CONFIG_BLK_DEV_IDEDMA |
| 1246 | int __ide_dma_bad_drive(ide_drive_t *); | 1361 | int __ide_dma_bad_drive(ide_drive_t *); |
| @@ -1347,24 +1462,6 @@ const char *ide_xfer_verbose(u8 mode); | |||
| 1347 | extern void ide_toggle_bounce(ide_drive_t *drive, int on); | 1462 | extern void ide_toggle_bounce(ide_drive_t *drive, int on); |
| 1348 | extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); | 1463 | extern int ide_set_xfer_rate(ide_drive_t *drive, u8 rate); |
| 1349 | 1464 | ||
| 1350 | static inline int ide_dev_has_iordy(struct hd_driveid *id) | ||
| 1351 | { | ||
| 1352 | return ((id->field_valid & 2) && (id->capability & 8)) ? 1 : 0; | ||
| 1353 | } | ||
| 1354 | |||
| 1355 | static inline int ide_dev_is_sata(struct hd_driveid *id) | ||
| 1356 | { | ||
| 1357 | /* | ||
| 1358 | * See if word 93 is 0 AND drive is at least ATA-5 compatible | ||
| 1359 | * verifying that word 80 by casting it to a signed type -- | ||
| 1360 | * this trick allows us to filter out the reserved values of | ||
| 1361 | * 0x0000 and 0xffff along with the earlier ATA revisions... | ||
| 1362 | */ | ||
| 1363 | if (id->hw_config == 0 && (short)id->major_rev_num >= 0x0020) | ||
| 1364 | return 1; | ||
| 1365 | return 0; | ||
| 1366 | } | ||
| 1367 | |||
| 1368 | u64 ide_get_lba_addr(struct ide_taskfile *, int); | 1465 | u64 ide_get_lba_addr(struct ide_taskfile *, int); |
| 1369 | u8 ide_dump_status(ide_drive_t *, const char *, u8); | 1466 | u8 ide_dump_status(ide_drive_t *, const char *, u8); |
| 1370 | 1467 | ||
| @@ -1436,13 +1533,6 @@ extern struct mutex ide_cfg_mtx; | |||
| 1436 | extern struct bus_type ide_bus_type; | 1533 | extern struct bus_type ide_bus_type; |
| 1437 | extern struct class *ide_port_class; | 1534 | extern struct class *ide_port_class; |
| 1438 | 1535 | ||
| 1439 | /* check if CACHE FLUSH (EXT) command is supported (bits defined in ATA-6) */ | ||
| 1440 | #define ide_id_has_flush_cache(id) ((id)->cfs_enable_2 & 0x3000) | ||
| 1441 | |||
| 1442 | /* some Maxtor disks have bit 13 defined incorrectly so check bit 10 too */ | ||
| 1443 | #define ide_id_has_flush_cache_ext(id) \ | ||
| 1444 | (((id)->cfs_enable_2 & 0x2400) == 0x2400) | ||
| 1445 | |||
| 1446 | static inline void ide_dump_identify(u8 *id) | 1536 | static inline void ide_dump_identify(u8 *id) |
| 1447 | { | 1537 | { |
| 1448 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0); | 1538 | print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 16, 2, id, 512, 0); |
| @@ -1453,10 +1543,10 @@ static inline int hwif_to_node(ide_hwif_t *hwif) | |||
| 1453 | return hwif->dev ? dev_to_node(hwif->dev) : -1; | 1543 | return hwif->dev ? dev_to_node(hwif->dev) : -1; |
| 1454 | } | 1544 | } |
| 1455 | 1545 | ||
| 1456 | static inline ide_drive_t *ide_get_paired_drive(ide_drive_t *drive) | 1546 | static inline ide_drive_t *ide_get_pair_dev(ide_drive_t *drive) |
| 1457 | { | 1547 | { |
| 1458 | ide_hwif_t *hwif = HWIF(drive); | 1548 | ide_drive_t *peer = &drive->hwif->drives[(drive->dn ^ 1) & 1]; |
| 1459 | 1549 | ||
| 1460 | return &hwif->drives[(drive->dn ^ 1) & 1]; | 1550 | return peer->present ? peer : NULL; |
| 1461 | } | 1551 | } |
| 1462 | #endif /* _IDE_H */ | 1552 | #endif /* _IDE_H */ |
