aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/Kconfig2
-rw-r--r--drivers/ide/Makefile2
-rw-r--r--drivers/ide/cy82c693.c2
-rw-r--r--drivers/ide/hpt366.c16
-rw-r--r--drivers/ide/ht6560b.c1
-rw-r--r--drivers/ide/ide-acpi.c4
-rw-r--r--drivers/ide/ide-atapi.c3
-rw-r--r--drivers/ide/ide-cd.c41
-rw-r--r--drivers/ide/ide-cd.h3
-rw-r--r--drivers/ide/ide-cd_ioctl.c14
-rw-r--r--drivers/ide/ide-cs.c158
-rw-r--r--drivers/ide/ide-disk.c16
-rw-r--r--drivers/ide/ide-disk_ioctl.c7
-rw-r--r--drivers/ide/ide-dma.c11
-rw-r--r--drivers/ide/ide-floppy.c4
-rw-r--r--drivers/ide/ide-floppy_ioctl.c7
-rw-r--r--drivers/ide/ide-gd.c29
-rw-r--r--drivers/ide/ide-io.c58
-rw-r--r--drivers/ide/ide-park.c2
-rw-r--r--drivers/ide/ide-scan-pci.c2
-rw-r--r--drivers/ide/ide-tape.c20
-rw-r--r--drivers/ide/ide-taskfile.c2
-rw-r--r--drivers/ide/piix.c4
-rw-r--r--drivers/ide/pmac.c4
-rw-r--r--drivers/ide/sis5513.c4
-rw-r--r--drivers/ide/triflex.c2
-rw-r--r--drivers/ide/via82cxxx.c2
27 files changed, 158 insertions, 262 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 98ccfeb3f5aa..9827c5e686cb 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -134,7 +134,7 @@ config BLK_DEV_IDECD
134 module will be called ide-cd. 134 module will be called ide-cd.
135 135
136config BLK_DEV_IDECD_VERBOSE_ERRORS 136config BLK_DEV_IDECD_VERBOSE_ERRORS
137 bool "Verbose error logging for IDE/ATAPI CDROM driver" if EMBEDDED 137 bool "Verbose error logging for IDE/ATAPI CDROM driver" if EXPERT
138 depends on BLK_DEV_IDECD 138 depends on BLK_DEV_IDECD
139 default y 139 default y
140 help 140 help
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index 81df925f0e8b..7f879b2397b0 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -2,7 +2,7 @@
2# link order is important here 2# link order is important here
3# 3#
4 4
5EXTRA_CFLAGS += -Idrivers/ide 5ccflags-y := -Idrivers/ide
6 6
7ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \ 7ide-core-y += ide.o ide-ioctls.o ide-io.o ide-iops.o ide-lib.o ide-probe.o \
8 ide-taskfile.o ide-pm.o ide-park.o ide-sysfs.o ide-devsets.o \ 8 ide-taskfile.o ide-pm.o ide-park.o ide-sysfs.o ide-devsets.o \
diff --git a/drivers/ide/cy82c693.c b/drivers/ide/cy82c693.c
index 9383f67deae1..3be60da52123 100644
--- a/drivers/ide/cy82c693.c
+++ b/drivers/ide/cy82c693.c
@@ -67,7 +67,7 @@ static void cy82c693_set_dma_mode(ide_hwif_t *hwif, ide_drive_t *drive)
67 67
68 /* 68 /*
69 * note: below we set the value for Bus Master IDE TimeOut Register 69 * note: below we set the value for Bus Master IDE TimeOut Register
70 * I'm not absolutly sure what this does, but it solved my problem 70 * I'm not absolutely sure what this does, but it solved my problem
71 * with IDE DMA and sound, so I now can play sound and work with 71 * with IDE DMA and sound, so I now can play sound and work with
72 * my IDE driver at the same time :-) 72 * my IDE driver at the same time :-)
73 * 73 *
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c
index 45163693f737..58c51cddc100 100644
--- a/drivers/ide/hpt366.c
+++ b/drivers/ide/hpt366.c
@@ -12,7 +12,7 @@
12 * 12 *
13 * 13 *
14 * HighPoint has its own drivers (open source except for the RAID part) 14 * HighPoint has its own drivers (open source except for the RAID part)
15 * available from http://www.highpoint-tech.com/BIOS%20+%20Driver/. 15 * available from http://www.highpoint-tech.com/USA_new/service_support.htm
16 * This may be useful to anyone wanting to work on this driver, however do not 16 * This may be useful to anyone wanting to work on this driver, however do not
17 * trust them too much since the code tends to become less and less meaningful 17 * trust them too much since the code tends to become less and less meaningful
18 * as the time passes... :-/ 18 * as the time passes... :-/
@@ -838,7 +838,7 @@ static void hpt3xxn_set_clock(ide_hwif_t *hwif, u8 mode)
838 838
839static void hpt3xxn_rw_disk(ide_drive_t *drive, struct request *rq) 839static void hpt3xxn_rw_disk(ide_drive_t *drive, struct request *rq)
840{ 840{
841 hpt3xxn_set_clock(drive->hwif, rq_data_dir(rq) ? 0x23 : 0x21); 841 hpt3xxn_set_clock(drive->hwif, rq_data_dir(rq) ? 0x21 : 0x23);
842} 842}
843 843
844/** 844/**
@@ -1173,8 +1173,9 @@ static u8 hpt3xx_cable_detect(ide_hwif_t *hwif)
1173 u16 mcr; 1173 u16 mcr;
1174 1174
1175 pci_read_config_word(dev, mcr_addr, &mcr); 1175 pci_read_config_word(dev, mcr_addr, &mcr);
1176 pci_write_config_word(dev, mcr_addr, (mcr | 0x8000)); 1176 pci_write_config_word(dev, mcr_addr, mcr | 0x8000);
1177 /* now read cable id register */ 1177 /* Debounce, then read cable ID register */
1178 udelay(10);
1178 pci_read_config_byte(dev, 0x5a, &scr1); 1179 pci_read_config_byte(dev, 0x5a, &scr1);
1179 pci_write_config_word(dev, mcr_addr, mcr); 1180 pci_write_config_word(dev, mcr_addr, mcr);
1180 } else if (chip_type >= HPT370) { 1181 } else if (chip_type >= HPT370) {
@@ -1185,10 +1186,11 @@ static u8 hpt3xx_cable_detect(ide_hwif_t *hwif)
1185 u8 scr2 = 0; 1186 u8 scr2 = 0;
1186 1187
1187 pci_read_config_byte(dev, 0x5b, &scr2); 1188 pci_read_config_byte(dev, 0x5b, &scr2);
1188 pci_write_config_byte(dev, 0x5b, (scr2 & ~1)); 1189 pci_write_config_byte(dev, 0x5b, scr2 & ~1);
1189 /* now read cable id register */ 1190 /* Debounce, then read cable ID register */
1191 udelay(10);
1190 pci_read_config_byte(dev, 0x5a, &scr1); 1192 pci_read_config_byte(dev, 0x5a, &scr1);
1191 pci_write_config_byte(dev, 0x5b, scr2); 1193 pci_write_config_byte(dev, 0x5b, scr2);
1192 } else 1194 } else
1193 pci_read_config_byte(dev, 0x5a, &scr1); 1195 pci_read_config_byte(dev, 0x5a, &scr1);
1194 1196
diff --git a/drivers/ide/ht6560b.c b/drivers/ide/ht6560b.c
index d81e49680c3f..808bcdcbf8e1 100644
--- a/drivers/ide/ht6560b.c
+++ b/drivers/ide/ht6560b.c
@@ -10,7 +10,6 @@
10 * Author: Mikko Ala-Fossi <maf@iki.fi> 10 * Author: Mikko Ala-Fossi <maf@iki.fi>
11 * Jan Evert van Grootheest <j.e.van.grootheest@caiway.nl> 11 * Jan Evert van Grootheest <j.e.van.grootheest@caiway.nl>
12 * 12 *
13 * Try: http://www.maf.iki.fi/~maf/ht6560b/
14 */ 13 */
15 14
16#define DRV_NAME "ht6560b" 15#define DRV_NAME "ht6560b"
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index c26c11905ffe..2af8cb460a3b 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -416,21 +416,21 @@ void ide_acpi_get_timing(ide_hwif_t *hwif)
416 416
417 out_obj = output.pointer; 417 out_obj = output.pointer;
418 if (out_obj->type != ACPI_TYPE_BUFFER) { 418 if (out_obj->type != ACPI_TYPE_BUFFER) {
419 kfree(output.pointer);
420 DEBPRINT("Run _GTM: error: " 419 DEBPRINT("Run _GTM: error: "
421 "expected object type of ACPI_TYPE_BUFFER, " 420 "expected object type of ACPI_TYPE_BUFFER, "
422 "got 0x%x\n", out_obj->type); 421 "got 0x%x\n", out_obj->type);
422 kfree(output.pointer);
423 return; 423 return;
424 } 424 }
425 425
426 if (!out_obj->buffer.length || !out_obj->buffer.pointer || 426 if (!out_obj->buffer.length || !out_obj->buffer.pointer ||
427 out_obj->buffer.length != sizeof(struct GTM_buffer)) { 427 out_obj->buffer.length != sizeof(struct GTM_buffer)) {
428 kfree(output.pointer);
429 printk(KERN_ERR 428 printk(KERN_ERR
430 "%s: unexpected _GTM length (0x%x)[should be 0x%zx] or " 429 "%s: unexpected _GTM length (0x%x)[should be 0x%zx] or "
431 "addr (0x%p)\n", 430 "addr (0x%p)\n",
432 __func__, out_obj->buffer.length, 431 __func__, out_obj->buffer.length,
433 sizeof(struct GTM_buffer), out_obj->buffer.pointer); 432 sizeof(struct GTM_buffer), out_obj->buffer.pointer);
433 kfree(output.pointer);
434 return; 434 return;
435 } 435 }
436 436
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index e88a2cf17711..6f218e014e99 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -233,8 +233,7 @@ int ide_queue_sense_rq(ide_drive_t *drive, void *special)
233 233
234 drive->hwif->rq = NULL; 234 drive->hwif->rq = NULL;
235 235
236 elv_add_request(drive->queue, &drive->sense_rq, 236 elv_add_request(drive->queue, &drive->sense_rq, ELEVATOR_INSERT_FRONT);
237 ELEVATOR_INSERT_FRONT, 0);
238 return 0; 237 return 0;
239} 238}
240EXPORT_SYMBOL_GPL(ide_queue_sense_rq); 239EXPORT_SYMBOL_GPL(ide_queue_sense_rq);
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 31fc76960a8f..04b09564bfa9 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -31,7 +31,6 @@
31#include <linux/delay.h> 31#include <linux/delay.h>
32#include <linux/timer.h> 32#include <linux/timer.h>
33#include <linux/seq_file.h> 33#include <linux/seq_file.h>
34#include <linux/smp_lock.h>
35#include <linux/slab.h> 34#include <linux/slab.h>
36#include <linux/interrupt.h> 35#include <linux/interrupt.h>
37#include <linux/errno.h> 36#include <linux/errno.h>
@@ -52,6 +51,7 @@
52 51
53#include "ide-cd.h" 52#include "ide-cd.h"
54 53
54static DEFINE_MUTEX(ide_cd_mutex);
55static DEFINE_MUTEX(idecd_ref_mutex); 55static DEFINE_MUTEX(idecd_ref_mutex);
56 56
57static void ide_cd_release(struct device *); 57static void ide_cd_release(struct device *);
@@ -258,17 +258,10 @@ static int ide_cd_breathe(ide_drive_t *drive, struct request *rq)
258 if (time_after(jiffies, info->write_timeout)) 258 if (time_after(jiffies, info->write_timeout))
259 return 0; 259 return 0;
260 else { 260 else {
261 struct request_queue *q = drive->queue;
262 unsigned long flags;
263
264 /* 261 /*
265 * take a breather relying on the unplug timer to kick us again 262 * take a breather
266 */ 263 */
267 264 blk_delay_queue(drive->queue, 1);
268 spin_lock_irqsave(q->queue_lock, flags);
269 blk_plug_device(q);
270 spin_unlock_irqrestore(q->queue_lock, flags);
271
272 return 1; 265 return 1;
273 } 266 }
274} 267}
@@ -785,7 +778,8 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
785 sector_t block) 778 sector_t block)
786{ 779{
787 struct ide_cmd cmd; 780 struct ide_cmd cmd;
788 int uptodate = 0, nsectors; 781 int uptodate = 0;
782 unsigned int nsectors;
789 783
790 ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, block: %llu", 784 ide_debug_log(IDE_DBG_RQ, "cmd: 0x%x, block: %llu",
791 rq->cmd[0], (unsigned long long)block); 785 rq->cmd[0], (unsigned long long)block);
@@ -1177,7 +1171,7 @@ static struct cdrom_device_ops ide_cdrom_dops = {
1177 .open = ide_cdrom_open_real, 1171 .open = ide_cdrom_open_real,
1178 .release = ide_cdrom_release_real, 1172 .release = ide_cdrom_release_real,
1179 .drive_status = ide_cdrom_drive_status, 1173 .drive_status = ide_cdrom_drive_status,
1180 .media_changed = ide_cdrom_check_media_change_real, 1174 .check_events = ide_cdrom_check_events_real,
1181 .tray_move = ide_cdrom_tray_move, 1175 .tray_move = ide_cdrom_tray_move,
1182 .lock_door = ide_cdrom_lock_door, 1176 .lock_door = ide_cdrom_lock_door,
1183 .select_speed = ide_cdrom_select_speed, 1177 .select_speed = ide_cdrom_select_speed,
@@ -1514,8 +1508,6 @@ static int ide_cdrom_setup(ide_drive_t *drive)
1514 blk_queue_dma_alignment(q, 31); 1508 blk_queue_dma_alignment(q, 31);
1515 blk_queue_update_dma_pad(q, 15); 1509 blk_queue_update_dma_pad(q, 15);
1516 1510
1517 q->unplug_delay = max((1 * HZ) / 1000, 1);
1518
1519 drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED; 1511 drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED;
1520 drive->atapi_flags = IDE_AFLAG_NO_EJECT | ide_cd_flags(id); 1512 drive->atapi_flags = IDE_AFLAG_NO_EJECT | ide_cd_flags(id);
1521 1513
@@ -1602,7 +1594,7 @@ static int idecd_open(struct block_device *bdev, fmode_t mode)
1602 struct cdrom_info *info; 1594 struct cdrom_info *info;
1603 int rc = -ENXIO; 1595 int rc = -ENXIO;
1604 1596
1605 lock_kernel(); 1597 mutex_lock(&ide_cd_mutex);
1606 info = ide_cd_get(bdev->bd_disk); 1598 info = ide_cd_get(bdev->bd_disk);
1607 if (!info) 1599 if (!info)
1608 goto out; 1600 goto out;
@@ -1611,7 +1603,7 @@ static int idecd_open(struct block_device *bdev, fmode_t mode)
1611 if (rc < 0) 1603 if (rc < 0)
1612 ide_cd_put(info); 1604 ide_cd_put(info);
1613out: 1605out:
1614 unlock_kernel(); 1606 mutex_unlock(&ide_cd_mutex);
1615 return rc; 1607 return rc;
1616} 1608}
1617 1609
@@ -1619,11 +1611,11 @@ static int idecd_release(struct gendisk *disk, fmode_t mode)
1619{ 1611{
1620 struct cdrom_info *info = ide_drv_g(disk, cdrom_info); 1612 struct cdrom_info *info = ide_drv_g(disk, cdrom_info);
1621 1613
1622 lock_kernel(); 1614 mutex_lock(&ide_cd_mutex);
1623 cdrom_release(&info->devinfo, mode); 1615 cdrom_release(&info->devinfo, mode);
1624 1616
1625 ide_cd_put(info); 1617 ide_cd_put(info);
1626 unlock_kernel(); 1618 mutex_unlock(&ide_cd_mutex);
1627 1619
1628 return 0; 1620 return 0;
1629} 1621}
@@ -1694,18 +1686,19 @@ static int idecd_ioctl(struct block_device *bdev, fmode_t mode,
1694{ 1686{
1695 int ret; 1687 int ret;
1696 1688
1697 lock_kernel(); 1689 mutex_lock(&ide_cd_mutex);
1698 ret = idecd_locked_ioctl(bdev, mode, cmd, arg); 1690 ret = idecd_locked_ioctl(bdev, mode, cmd, arg);
1699 unlock_kernel(); 1691 mutex_unlock(&ide_cd_mutex);
1700 1692
1701 return ret; 1693 return ret;
1702} 1694}
1703 1695
1704 1696
1705static int idecd_media_changed(struct gendisk *disk) 1697static unsigned int idecd_check_events(struct gendisk *disk,
1698 unsigned int clearing)
1706{ 1699{
1707 struct cdrom_info *info = ide_drv_g(disk, cdrom_info); 1700 struct cdrom_info *info = ide_drv_g(disk, cdrom_info);
1708 return cdrom_media_changed(&info->devinfo); 1701 return cdrom_check_events(&info->devinfo, clearing);
1709} 1702}
1710 1703
1711static int idecd_revalidate_disk(struct gendisk *disk) 1704static int idecd_revalidate_disk(struct gendisk *disk)
@@ -1723,7 +1716,7 @@ static const struct block_device_operations idecd_ops = {
1723 .open = idecd_open, 1716 .open = idecd_open,
1724 .release = idecd_release, 1717 .release = idecd_release,
1725 .ioctl = idecd_ioctl, 1718 .ioctl = idecd_ioctl,
1726 .media_changed = idecd_media_changed, 1719 .check_events = idecd_check_events,
1727 .revalidate_disk = idecd_revalidate_disk 1720 .revalidate_disk = idecd_revalidate_disk
1728}; 1721};
1729 1722
@@ -1789,7 +1782,7 @@ static int ide_cd_probe(ide_drive_t *drive)
1789 1782
1790 ide_cd_read_toc(drive, &sense); 1783 ide_cd_read_toc(drive, &sense);
1791 g->fops = &idecd_ops; 1784 g->fops = &idecd_ops;
1792 g->flags |= GENHD_FL_REMOVABLE; 1785 g->flags |= GENHD_FL_REMOVABLE | GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE;
1793 add_disk(g); 1786 add_disk(g);
1794 return 0; 1787 return 0;
1795 1788
diff --git a/drivers/ide/ide-cd.h b/drivers/ide/ide-cd.h
index 93a3cf1b0f3f..1efc936f5b66 100644
--- a/drivers/ide/ide-cd.h
+++ b/drivers/ide/ide-cd.h
@@ -111,7 +111,8 @@ int cdrom_check_status(ide_drive_t *, struct request_sense *);
111int ide_cdrom_open_real(struct cdrom_device_info *, int); 111int ide_cdrom_open_real(struct cdrom_device_info *, int);
112void ide_cdrom_release_real(struct cdrom_device_info *); 112void ide_cdrom_release_real(struct cdrom_device_info *);
113int ide_cdrom_drive_status(struct cdrom_device_info *, int); 113int ide_cdrom_drive_status(struct cdrom_device_info *, int);
114int ide_cdrom_check_media_change_real(struct cdrom_device_info *, int); 114unsigned int ide_cdrom_check_events_real(struct cdrom_device_info *,
115 unsigned int clearing, int slot_nr);
115int ide_cdrom_tray_move(struct cdrom_device_info *, int); 116int ide_cdrom_tray_move(struct cdrom_device_info *, int);
116int ide_cdrom_lock_door(struct cdrom_device_info *, int); 117int ide_cdrom_lock_door(struct cdrom_device_info *, int);
117int ide_cdrom_select_speed(struct cdrom_device_info *, int); 118int ide_cdrom_select_speed(struct cdrom_device_info *, int);
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
index 766b3deeb23c..02caa7dd51c8 100644
--- a/drivers/ide/ide-cd_ioctl.c
+++ b/drivers/ide/ide-cd_ioctl.c
@@ -79,8 +79,14 @@ int ide_cdrom_drive_status(struct cdrom_device_info *cdi, int slot_nr)
79 return CDS_DRIVE_NOT_READY; 79 return CDS_DRIVE_NOT_READY;
80} 80}
81 81
82int ide_cdrom_check_media_change_real(struct cdrom_device_info *cdi, 82/*
83 int slot_nr) 83 * ide-cd always generates media changed event if media is missing, which
84 * makes it impossible to use for proper event reporting, so disk->events
85 * is cleared to 0 and the following function is used only to trigger
86 * revalidation and never propagated to userland.
87 */
88unsigned int ide_cdrom_check_events_real(struct cdrom_device_info *cdi,
89 unsigned int clearing, int slot_nr)
84{ 90{
85 ide_drive_t *drive = cdi->handle; 91 ide_drive_t *drive = cdi->handle;
86 int retval; 92 int retval;
@@ -89,9 +95,9 @@ int ide_cdrom_check_media_change_real(struct cdrom_device_info *cdi,
89 (void) cdrom_check_status(drive, NULL); 95 (void) cdrom_check_status(drive, NULL);
90 retval = (drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED) ? 1 : 0; 96 retval = (drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED) ? 1 : 0;
91 drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED; 97 drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
92 return retval; 98 return retval ? DISK_EVENT_MEDIA_CHANGE : 0;
93 } else { 99 } else {
94 return -EINVAL; 100 return 0;
95 } 101 }
96} 102}
97 103
diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c
index 2a4cb9c18f01..d2f3db3cf3ed 100644
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -43,7 +43,6 @@
43#include <asm/io.h> 43#include <asm/io.h>
44#include <asm/system.h> 44#include <asm/system.h>
45 45
46#include <pcmcia/cs.h>
47#include <pcmcia/cistpl.h> 46#include <pcmcia/cistpl.h>
48#include <pcmcia/ds.h> 47#include <pcmcia/ds.h>
49#include <pcmcia/cisreg.h> 48#include <pcmcia/cisreg.h>
@@ -72,17 +71,6 @@ static int ide_config(struct pcmcia_device *);
72 71
73static void ide_detach(struct pcmcia_device *p_dev); 72static void ide_detach(struct pcmcia_device *p_dev);
74 73
75
76
77
78/*======================================================================
79
80 ide_attach() creates an "instance" of the driver, allocating
81 local data structures for one device. The device is registered
82 with Card Services.
83
84======================================================================*/
85
86static int ide_probe(struct pcmcia_device *link) 74static int ide_probe(struct pcmcia_device *link)
87{ 75{
88 ide_info_t *info; 76 ide_info_t *info;
@@ -97,23 +85,12 @@ static int ide_probe(struct pcmcia_device *link)
97 info->p_dev = link; 85 info->p_dev = link;
98 link->priv = info; 86 link->priv = info;
99 87
100 link->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO; 88 link->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IO |
101 link->resource[1]->flags |= IO_DATA_PATH_WIDTH_8; 89 CONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC;
102 link->conf.Attributes = CONF_ENABLE_IRQ;
103 link->conf.IntType = INT_MEMORY_AND_IO;
104 90
105 return ide_config(link); 91 return ide_config(link);
106} /* ide_attach */ 92} /* ide_attach */
107 93
108/*======================================================================
109
110 This deletes a driver "instance". The device is de-registered
111 with Card Services. If it has been released, all local data
112 structures are freed. Otherwise, the structures will be freed
113 when the device is released.
114
115======================================================================*/
116
117static void ide_detach(struct pcmcia_device *link) 94static void ide_detach(struct pcmcia_device *link)
118{ 95{
119 ide_info_t *info = link->priv; 96 ide_info_t *info = link->priv;
@@ -187,79 +164,31 @@ out_release:
187 return NULL; 164 return NULL;
188} 165}
189 166
190/*====================================================================== 167static int pcmcia_check_one_config(struct pcmcia_device *pdev, void *priv_data)
191
192 ide_config() is scheduled to run after a CARD_INSERTION event
193 is received, to configure the PCMCIA socket, and to make the
194 ide device available to the system.
195
196======================================================================*/
197
198struct pcmcia_config_check {
199 unsigned long ctl_base;
200 int skip_vcc;
201 int is_kme;
202};
203
204static int pcmcia_check_one_config(struct pcmcia_device *pdev,
205 cistpl_cftable_entry_t *cfg,
206 cistpl_cftable_entry_t *dflt,
207 unsigned int vcc,
208 void *priv_data)
209{ 168{
210 struct pcmcia_config_check *stk = priv_data; 169 int *is_kme = priv_data;
211
212 /* Check for matching Vcc, unless we're desperate */
213 if (!stk->skip_vcc) {
214 if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
215 if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] / 10000)
216 return -ENODEV;
217 } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
218 if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] / 10000)
219 return -ENODEV;
220 }
221 }
222 170
223 if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) 171 if (!(pdev->resource[0]->flags & IO_DATA_PATH_WIDTH_8)) {
224 pdev->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; 172 pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
225 else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM)) 173 pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_AUTO;
226 pdev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000; 174 }
227 175 pdev->resource[1]->flags &= ~IO_DATA_PATH_WIDTH;
228 if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) { 176 pdev->resource[1]->flags |= IO_DATA_PATH_WIDTH_8;
229 cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io; 177
230 pdev->io_lines = io->flags & CISTPL_IO_LINES_MASK; 178 if (pdev->resource[1]->end) {
231 179 pdev->resource[0]->end = 8;
232 pdev->conf.ConfigIndex = cfg->index; 180 pdev->resource[1]->end = (*is_kme) ? 2 : 1;
233 pdev->resource[0]->start = io->win[0].base; 181 } else {
234 if (!(io->flags & CISTPL_IO_16BIT)) { 182 if (pdev->resource[0]->end < 16)
235 pdev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
236 pdev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
237 }
238 if (io->nwin == 2) {
239 pdev->resource[0]->end = 8;
240 pdev->resource[1]->start = io->win[1].base;
241 pdev->resource[1]->end = (stk->is_kme) ? 2 : 1;
242 if (pcmcia_request_io(pdev) != 0)
243 return -ENODEV;
244 stk->ctl_base = pdev->resource[1]->start;
245 } else if ((io->nwin == 1) && (io->win[0].len >= 16)) {
246 pdev->resource[0]->end = io->win[0].len;
247 pdev->resource[1]->end = 0;
248 if (pcmcia_request_io(pdev) != 0)
249 return -ENODEV;
250 stk->ctl_base = pdev->resource[0]->start + 0x0e;
251 } else
252 return -ENODEV; 183 return -ENODEV;
253 /* If we've got this far, we're done */
254 return 0;
255 } 184 }
256 return -ENODEV; 185
186 return pcmcia_request_io(pdev);
257} 187}
258 188
259static int ide_config(struct pcmcia_device *link) 189static int ide_config(struct pcmcia_device *link)
260{ 190{
261 ide_info_t *info = link->priv; 191 ide_info_t *info = link->priv;
262 struct pcmcia_config_check *stk = NULL;
263 int ret = 0, is_kme = 0; 192 int ret = 0, is_kme = 0;
264 unsigned long io_base, ctl_base; 193 unsigned long io_base, ctl_base;
265 struct ide_host *host; 194 struct ide_host *host;
@@ -270,23 +199,21 @@ static int ide_config(struct pcmcia_device *link)
270 ((link->card_id == PRODID_KME_KXLC005_A) || 199 ((link->card_id == PRODID_KME_KXLC005_A) ||
271 (link->card_id == PRODID_KME_KXLC005_B))); 200 (link->card_id == PRODID_KME_KXLC005_B)));
272 201
273 stk = kzalloc(sizeof(*stk), GFP_KERNEL); 202 if (pcmcia_loop_config(link, pcmcia_check_one_config, &is_kme)) {
274 if (!stk) 203 link->config_flags &= ~CONF_AUTO_CHECK_VCC;
275 goto err_mem; 204 if (pcmcia_loop_config(link, pcmcia_check_one_config, &is_kme))
276 stk->is_kme = is_kme;
277 stk->skip_vcc = io_base = ctl_base = 0;
278
279 if (pcmcia_loop_config(link, pcmcia_check_one_config, stk)) {
280 stk->skip_vcc = 1;
281 if (pcmcia_loop_config(link, pcmcia_check_one_config, stk))
282 goto failed; /* No suitable config found */ 205 goto failed; /* No suitable config found */
283 } 206 }
284 io_base = link->resource[0]->start; 207 io_base = link->resource[0]->start;
285 ctl_base = stk->ctl_base; 208 if (link->resource[1]->end)
209 ctl_base = link->resource[1]->start;
210 else
211 ctl_base = link->resource[0]->start + 0x0e;
286 212
287 if (!link->irq) 213 if (!link->irq)
288 goto failed; 214 goto failed;
289 ret = pcmcia_request_configuration(link, &link->conf); 215
216 ret = pcmcia_enable_device(link);
290 if (ret) 217 if (ret)
291 goto failed; 218 goto failed;
292 219
@@ -311,29 +238,15 @@ static int ide_config(struct pcmcia_device *link)
311 info->host = host; 238 info->host = host;
312 dev_info(&link->dev, "ide-cs: hd%c: Vpp = %d.%d\n", 239 dev_info(&link->dev, "ide-cs: hd%c: Vpp = %d.%d\n",
313 'a' + host->ports[0]->index * 2, 240 'a' + host->ports[0]->index * 2,
314 link->conf.Vpp / 10, link->conf.Vpp % 10); 241 link->vpp / 10, link->vpp % 10);
315 242
316 kfree(stk);
317 return 0; 243 return 0;
318 244
319err_mem:
320 printk(KERN_NOTICE "ide-cs: ide_config failed memory allocation\n");
321 goto failed;
322
323failed: 245failed:
324 kfree(stk);
325 ide_release(link); 246 ide_release(link);
326 return -ENODEV; 247 return -ENODEV;
327} /* ide_config */ 248} /* ide_config */
328 249
329/*======================================================================
330
331 After a card is removed, ide_release() will unregister the net
332 device, and release the PCMCIA configuration. If the device is
333 still open, this will be postponed until it is closed.
334
335======================================================================*/
336
337static void ide_release(struct pcmcia_device *link) 250static void ide_release(struct pcmcia_device *link)
338{ 251{
339 ide_info_t *info = link->priv; 252 ide_info_t *info = link->priv;
@@ -359,16 +272,7 @@ static void ide_release(struct pcmcia_device *link)
359} /* ide_release */ 272} /* ide_release */
360 273
361 274
362/*====================================================================== 275static const struct pcmcia_device_id ide_ids[] = {
363
364 The card status event handler. Mostly, this schedules other
365 stuff to run after an event is received. A CARD_REMOVAL event
366 also sets some flags to discourage the ide drivers from
367 talking to the ports.
368
369======================================================================*/
370
371static struct pcmcia_device_id ide_ids[] = {
372 PCMCIA_DEVICE_FUNC_ID(4), 276 PCMCIA_DEVICE_FUNC_ID(4),
373 PCMCIA_DEVICE_MANF_CARD(0x0000, 0x0000), /* Corsair */ 277 PCMCIA_DEVICE_MANF_CARD(0x0000, 0x0000), /* Corsair */
374 PCMCIA_DEVICE_MANF_CARD(0x0007, 0x0000), /* Hitachi */ 278 PCMCIA_DEVICE_MANF_CARD(0x0007, 0x0000), /* Hitachi */
@@ -440,9 +344,7 @@ MODULE_DEVICE_TABLE(pcmcia, ide_ids);
440 344
441static struct pcmcia_driver ide_cs_driver = { 345static struct pcmcia_driver ide_cs_driver = {
442 .owner = THIS_MODULE, 346 .owner = THIS_MODULE,
443 .drv = { 347 .name = "ide-cs",
444 .name = "ide-cs",
445 },
446 .probe = ide_probe, 348 .probe = ide_probe,
447 .remove = ide_detach, 349 .remove = ide_detach,
448 .id_table = ide_ids, 350 .id_table = ide_ids,
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 7433e07de30e..274798068a54 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -435,12 +435,11 @@ static int idedisk_prep_fn(struct request_queue *q, struct request *rq)
435 if (!(rq->cmd_flags & REQ_FLUSH)) 435 if (!(rq->cmd_flags & REQ_FLUSH))
436 return BLKPREP_OK; 436 return BLKPREP_OK;
437 437
438 cmd = kmalloc(sizeof(*cmd), GFP_ATOMIC); 438 cmd = kzalloc(sizeof(*cmd), GFP_ATOMIC);
439 439
440 /* FIXME: map struct ide_taskfile on rq->cmd[] */ 440 /* FIXME: map struct ide_taskfile on rq->cmd[] */
441 BUG_ON(cmd == NULL); 441 BUG_ON(cmd == NULL);
442 442
443 memset(cmd, 0, sizeof(*cmd));
444 if (ata_id_flush_ext_enabled(drive->id) && 443 if (ata_id_flush_ext_enabled(drive->id) &&
445 (drive->capacity64 >= (1UL << 28))) 444 (drive->capacity64 >= (1UL << 28)))
446 cmd->tf.command = ATA_CMD_FLUSH_EXT; 445 cmd->tf.command = ATA_CMD_FLUSH_EXT;
@@ -516,10 +515,10 @@ static int ide_do_setfeature(ide_drive_t *drive, u8 feature, u8 nsect)
516 return ide_no_data_taskfile(drive, &cmd); 515 return ide_no_data_taskfile(drive, &cmd);
517} 516}
518 517
519static void update_ordered(ide_drive_t *drive) 518static void update_flush(ide_drive_t *drive)
520{ 519{
521 u16 *id = drive->id; 520 u16 *id = drive->id;
522 unsigned ordered = QUEUE_ORDERED_NONE; 521 unsigned flush = 0;
523 522
524 if (drive->dev_flags & IDE_DFLAG_WCACHE) { 523 if (drive->dev_flags & IDE_DFLAG_WCACHE) {
525 unsigned long long capacity; 524 unsigned long long capacity;
@@ -543,13 +542,12 @@ static void update_ordered(ide_drive_t *drive)
543 drive->name, barrier ? "" : "not "); 542 drive->name, barrier ? "" : "not ");
544 543
545 if (barrier) { 544 if (barrier) {
546 ordered = QUEUE_ORDERED_DRAIN_FLUSH; 545 flush = REQ_FLUSH;
547 blk_queue_prep_rq(drive->queue, idedisk_prep_fn); 546 blk_queue_prep_rq(drive->queue, idedisk_prep_fn);
548 } 547 }
549 } else 548 }
550 ordered = QUEUE_ORDERED_DRAIN;
551 549
552 blk_queue_ordered(drive->queue, ordered); 550 blk_queue_flush(drive->queue, flush);
553} 551}
554 552
555ide_devset_get_flag(wcache, IDE_DFLAG_WCACHE); 553ide_devset_get_flag(wcache, IDE_DFLAG_WCACHE);
@@ -572,7 +570,7 @@ static int set_wcache(ide_drive_t *drive, int arg)
572 } 570 }
573 } 571 }
574 572
575 update_ordered(drive); 573 update_flush(drive);
576 574
577 return err; 575 return err;
578} 576}
diff --git a/drivers/ide/ide-disk_ioctl.c b/drivers/ide/ide-disk_ioctl.c
index ec94c66918f6..da36f729ff32 100644
--- a/drivers/ide/ide-disk_ioctl.c
+++ b/drivers/ide/ide-disk_ioctl.c
@@ -1,10 +1,11 @@
1#include <linux/kernel.h> 1#include <linux/kernel.h>
2#include <linux/ide.h> 2#include <linux/ide.h>
3#include <linux/hdreg.h> 3#include <linux/hdreg.h>
4#include <linux/smp_lock.h> 4#include <linux/mutex.h>
5 5
6#include "ide-disk.h" 6#include "ide-disk.h"
7 7
8static DEFINE_MUTEX(ide_disk_ioctl_mutex);
8static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = { 9static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = {
9{ HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address }, 10{ HDIO_GET_ADDRESS, HDIO_SET_ADDRESS, &ide_devset_address },
10{ HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount }, 11{ HDIO_GET_MULTCOUNT, HDIO_SET_MULTCOUNT, &ide_devset_multcount },
@@ -19,13 +20,13 @@ int ide_disk_ioctl(ide_drive_t *drive, struct block_device *bdev, fmode_t mode,
19{ 20{
20 int err; 21 int err;
21 22
22 lock_kernel(); 23 mutex_lock(&ide_disk_ioctl_mutex);
23 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); 24 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings);
24 if (err != -EOPNOTSUPP) 25 if (err != -EOPNOTSUPP)
25 goto out; 26 goto out;
26 27
27 err = generic_ide_ioctl(drive, bdev, cmd, arg); 28 err = generic_ide_ioctl(drive, bdev, cmd, arg);
28out: 29out:
29 unlock_kernel(); 30 mutex_unlock(&ide_disk_ioctl_mutex);
30 return err; 31 return err;
31} 32}
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index 06b14bc9a1d4..d4136908f916 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -449,7 +449,6 @@ ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
449 ide_hwif_t *hwif = drive->hwif; 449 ide_hwif_t *hwif = drive->hwif;
450 const struct ide_dma_ops *dma_ops = hwif->dma_ops; 450 const struct ide_dma_ops *dma_ops = hwif->dma_ops;
451 struct ide_cmd *cmd = &hwif->cmd; 451 struct ide_cmd *cmd = &hwif->cmd;
452 struct request *rq;
453 ide_startstop_t ret = ide_stopped; 452 ide_startstop_t ret = ide_stopped;
454 453
455 /* 454 /*
@@ -487,14 +486,10 @@ ide_startstop_t ide_dma_timeout_retry(ide_drive_t *drive, int error)
487 ide_dma_off_quietly(drive); 486 ide_dma_off_quietly(drive);
488 487
489 /* 488 /*
490 * un-busy drive etc and make sure request is sane 489 * make sure request is sane
491 */ 490 */
492 rq = hwif->rq; 491 if (hwif->rq)
493 if (rq) { 492 hwif->rq->errors = 0;
494 hwif->rq = NULL;
495 rq->errors = 0;
496 ide_requeue_and_plug(drive, rq);
497 }
498 return ret; 493 return ret;
499} 494}
500 495
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 5406b6ea3ad1..61fdf544fbd6 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -73,7 +73,7 @@ static int ide_floppy_callback(ide_drive_t *drive, int dsc)
73 drive->failed_pc = NULL; 73 drive->failed_pc = NULL;
74 74
75 if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 || 75 if (pc->c[0] == GPCMD_READ_10 || pc->c[0] == GPCMD_WRITE_10 ||
76 (rq && rq->cmd_type == REQ_TYPE_BLOCK_PC)) 76 rq->cmd_type == REQ_TYPE_BLOCK_PC)
77 uptodate = 1; /* FIXME */ 77 uptodate = 1; /* FIXME */
78 else if (pc->c[0] == GPCMD_REQUEST_SENSE) { 78 else if (pc->c[0] == GPCMD_REQUEST_SENSE) {
79 79
@@ -107,7 +107,7 @@ static int ide_floppy_callback(ide_drive_t *drive, int dsc)
107static void ide_floppy_report_error(struct ide_disk_obj *floppy, 107static void ide_floppy_report_error(struct ide_disk_obj *floppy,
108 struct ide_atapi_pc *pc) 108 struct ide_atapi_pc *pc)
109{ 109{
110 /* supress error messages resulting from Medium not present */ 110 /* suppress error messages resulting from Medium not present */
111 if (floppy->sense_key == 0x02 && 111 if (floppy->sense_key == 0x02 &&
112 floppy->asc == 0x3a && 112 floppy->asc == 0x3a &&
113 floppy->ascq == 0x00) 113 floppy->ascq == 0x00)
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c
index fd3d05ab3417..d267b7affad6 100644
--- a/drivers/ide/ide-floppy_ioctl.c
+++ b/drivers/ide/ide-floppy_ioctl.c
@@ -5,7 +5,7 @@
5#include <linux/kernel.h> 5#include <linux/kernel.h>
6#include <linux/ide.h> 6#include <linux/ide.h>
7#include <linux/cdrom.h> 7#include <linux/cdrom.h>
8#include <linux/smp_lock.h> 8#include <linux/mutex.h>
9 9
10#include <asm/unaligned.h> 10#include <asm/unaligned.h>
11 11
@@ -32,6 +32,7 @@
32 * On exit we set nformats to the number of records we've actually initialized. 32 * On exit we set nformats to the number of records we've actually initialized.
33 */ 33 */
34 34
35static DEFINE_MUTEX(ide_floppy_ioctl_mutex);
35static int ide_floppy_get_format_capacities(ide_drive_t *drive, 36static int ide_floppy_get_format_capacities(ide_drive_t *drive,
36 struct ide_atapi_pc *pc, 37 struct ide_atapi_pc *pc,
37 int __user *arg) 38 int __user *arg)
@@ -276,7 +277,7 @@ int ide_floppy_ioctl(ide_drive_t *drive, struct block_device *bdev,
276 void __user *argp = (void __user *)arg; 277 void __user *argp = (void __user *)arg;
277 int err; 278 int err;
278 279
279 lock_kernel(); 280 mutex_lock(&ide_floppy_ioctl_mutex);
280 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) { 281 if (cmd == CDROMEJECT || cmd == CDROM_LOCKDOOR) {
281 err = ide_floppy_lockdoor(drive, &pc, arg, cmd); 282 err = ide_floppy_lockdoor(drive, &pc, arg, cmd);
282 goto out; 283 goto out;
@@ -298,6 +299,6 @@ int ide_floppy_ioctl(ide_drive_t *drive, struct block_device *bdev,
298 err = generic_ide_ioctl(drive, bdev, cmd, arg); 299 err = generic_ide_ioctl(drive, bdev, cmd, arg);
299 300
300out: 301out:
301 unlock_kernel(); 302 mutex_unlock(&ide_floppy_ioctl_mutex);
302 return err; 303 return err;
303} 304}
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
index 70aeeb18833e..70ea8763567d 100644
--- a/drivers/ide/ide-gd.c
+++ b/drivers/ide/ide-gd.c
@@ -1,4 +1,3 @@
1#include <linux/smp_lock.h>
2#include <linux/module.h> 1#include <linux/module.h>
3#include <linux/types.h> 2#include <linux/types.h>
4#include <linux/string.h> 3#include <linux/string.h>
@@ -23,6 +22,7 @@
23#define IDE_GD_VERSION "1.18" 22#define IDE_GD_VERSION "1.18"
24 23
25/* module parameters */ 24/* module parameters */
25static DEFINE_MUTEX(ide_gd_mutex);
26static unsigned long debug_mask; 26static unsigned long debug_mask;
27module_param(debug_mask, ulong, 0644); 27module_param(debug_mask, ulong, 0644);
28 28
@@ -242,9 +242,9 @@ static int ide_gd_unlocked_open(struct block_device *bdev, fmode_t mode)
242{ 242{
243 int ret; 243 int ret;
244 244
245 lock_kernel(); 245 mutex_lock(&ide_gd_mutex);
246 ret = ide_gd_open(bdev, mode); 246 ret = ide_gd_open(bdev, mode);
247 unlock_kernel(); 247 mutex_unlock(&ide_gd_mutex);
248 248
249 return ret; 249 return ret;
250} 250}
@@ -257,7 +257,7 @@ static int ide_gd_release(struct gendisk *disk, fmode_t mode)
257 257
258 ide_debug_log(IDE_DBG_FUNC, "enter"); 258 ide_debug_log(IDE_DBG_FUNC, "enter");
259 259
260 lock_kernel(); 260 mutex_lock(&ide_gd_mutex);
261 if (idkp->openers == 1) 261 if (idkp->openers == 1)
262 drive->disk_ops->flush(drive); 262 drive->disk_ops->flush(drive);
263 263
@@ -269,7 +269,7 @@ static int ide_gd_release(struct gendisk *disk, fmode_t mode)
269 idkp->openers--; 269 idkp->openers--;
270 270
271 ide_disk_put(idkp); 271 ide_disk_put(idkp);
272 unlock_kernel(); 272 mutex_unlock(&ide_gd_mutex);
273 273
274 return 0; 274 return 0;
275} 275}
@@ -285,11 +285,12 @@ static int ide_gd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
285 return 0; 285 return 0;
286} 286}
287 287
288static int ide_gd_media_changed(struct gendisk *disk) 288static unsigned int ide_gd_check_events(struct gendisk *disk,
289 unsigned int clearing)
289{ 290{
290 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); 291 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
291 ide_drive_t *drive = idkp->drive; 292 ide_drive_t *drive = idkp->drive;
292 int ret; 293 bool ret;
293 294
294 /* do not scan partitions twice if this is a removable device */ 295 /* do not scan partitions twice if this is a removable device */
295 if (drive->dev_flags & IDE_DFLAG_ATTACH) { 296 if (drive->dev_flags & IDE_DFLAG_ATTACH) {
@@ -297,10 +298,16 @@ static int ide_gd_media_changed(struct gendisk *disk)
297 return 0; 298 return 0;
298 } 299 }
299 300
300 ret = !!(drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED); 301 /*
302 * The following is used to force revalidation on the first open on
303 * removeable devices, and never gets reported to userland as
304 * genhd->events is 0. This is intended as removeable ide disk
305 * can't really detect MEDIA_CHANGE events.
306 */
307 ret = drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED;
301 drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED; 308 drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
302 309
303 return ret; 310 return ret ? DISK_EVENT_MEDIA_CHANGE : 0;
304} 311}
305 312
306static void ide_gd_unlock_native_capacity(struct gendisk *disk) 313static void ide_gd_unlock_native_capacity(struct gendisk *disk)
@@ -318,7 +325,7 @@ static int ide_gd_revalidate_disk(struct gendisk *disk)
318 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj); 325 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
319 ide_drive_t *drive = idkp->drive; 326 ide_drive_t *drive = idkp->drive;
320 327
321 if (ide_gd_media_changed(disk)) 328 if (ide_gd_check_events(disk, 0))
322 drive->disk_ops->get_capacity(drive); 329 drive->disk_ops->get_capacity(drive);
323 330
324 set_capacity(disk, ide_gd_capacity(drive)); 331 set_capacity(disk, ide_gd_capacity(drive));
@@ -340,7 +347,7 @@ static const struct block_device_operations ide_gd_ops = {
340 .release = ide_gd_release, 347 .release = ide_gd_release,
341 .ioctl = ide_gd_ioctl, 348 .ioctl = ide_gd_ioctl,
342 .getgeo = ide_gd_getgeo, 349 .getgeo = ide_gd_getgeo,
343 .media_changed = ide_gd_media_changed, 350 .check_events = ide_gd_check_events,
344 .unlock_native_capacity = ide_gd_unlock_native_capacity, 351 .unlock_native_capacity = ide_gd_unlock_native_capacity,
345 .revalidate_disk = ide_gd_revalidate_disk 352 .revalidate_disk = ide_gd_revalidate_disk
346}; 353};
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c
index a381be814070..177db6d5b2f5 100644
--- a/drivers/ide/ide-io.c
+++ b/drivers/ide/ide-io.c
@@ -430,6 +430,26 @@ static inline void ide_unlock_host(struct ide_host *host)
430 } 430 }
431} 431}
432 432
433static void __ide_requeue_and_plug(struct request_queue *q, struct request *rq)
434{
435 if (rq)
436 blk_requeue_request(q, rq);
437 if (rq || blk_peek_request(q)) {
438 /* Use 3ms as that was the old plug delay */
439 blk_delay_queue(q, 3);
440 }
441}
442
443void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq)
444{
445 struct request_queue *q = drive->queue;
446 unsigned long flags;
447
448 spin_lock_irqsave(q->queue_lock, flags);
449 __ide_requeue_and_plug(q, rq);
450 spin_unlock_irqrestore(q->queue_lock, flags);
451}
452
433/* 453/*
434 * Issue a new request to a device. 454 * Issue a new request to a device.
435 */ 455 */
@@ -440,19 +460,7 @@ void do_ide_request(struct request_queue *q)
440 struct ide_host *host = hwif->host; 460 struct ide_host *host = hwif->host;
441 struct request *rq = NULL; 461 struct request *rq = NULL;
442 ide_startstop_t startstop; 462 ide_startstop_t startstop;
443 463 unsigned long queue_run_ms = 3; /* old plug delay */
444 /*
445 * drive is doing pre-flush, ordered write, post-flush sequence. even
446 * though that is 3 requests, it must be seen as a single transaction.
447 * we must not preempt this drive until that is complete
448 */
449 if (blk_queue_flushing(q))
450 /*
451 * small race where queue could get replugged during
452 * the 3-request flush cycle, just yank the plug since
453 * we want it to finish asap
454 */
455 blk_remove_plug(q);
456 464
457 spin_unlock_irq(q->queue_lock); 465 spin_unlock_irq(q->queue_lock);
458 466
@@ -472,6 +480,9 @@ repeat:
472 prev_port = hwif->host->cur_port; 480 prev_port = hwif->host->cur_port;
473 if (drive->dev_flags & IDE_DFLAG_SLEEPING && 481 if (drive->dev_flags & IDE_DFLAG_SLEEPING &&
474 time_after(drive->sleep, jiffies)) { 482 time_after(drive->sleep, jiffies)) {
483 unsigned long left = jiffies - drive->sleep;
484
485 queue_run_ms = jiffies_to_msecs(left + 1);
475 ide_unlock_port(hwif); 486 ide_unlock_port(hwif);
476 goto plug_device; 487 goto plug_device;
477 } 488 }
@@ -559,26 +570,7 @@ plug_device:
559 ide_unlock_host(host); 570 ide_unlock_host(host);
560plug_device_2: 571plug_device_2:
561 spin_lock_irq(q->queue_lock); 572 spin_lock_irq(q->queue_lock);
562 573 __ide_requeue_and_plug(q, rq);
563 if (rq)
564 blk_requeue_request(q, rq);
565 if (!elv_queue_empty(q))
566 blk_plug_device(q);
567}
568
569void ide_requeue_and_plug(ide_drive_t *drive, struct request *rq)
570{
571 struct request_queue *q = drive->queue;
572 unsigned long flags;
573
574 spin_lock_irqsave(q->queue_lock, flags);
575
576 if (rq)
577 blk_requeue_request(q, rq);
578 if (!elv_queue_empty(q))
579 blk_plug_device(q);
580
581 spin_unlock_irqrestore(q->queue_lock, flags);
582} 574}
583 575
584static int drive_is_ready(ide_drive_t *drive) 576static int drive_is_ready(ide_drive_t *drive)
diff --git a/drivers/ide/ide-park.c b/drivers/ide/ide-park.c
index 88a380c5a470..6ab9ab2a5081 100644
--- a/drivers/ide/ide-park.c
+++ b/drivers/ide/ide-park.c
@@ -52,7 +52,7 @@ static void issue_park_cmd(ide_drive_t *drive, unsigned long timeout)
52 rq->cmd[0] = REQ_UNPARK_HEADS; 52 rq->cmd[0] = REQ_UNPARK_HEADS;
53 rq->cmd_len = 1; 53 rq->cmd_len = 1;
54 rq->cmd_type = REQ_TYPE_SPECIAL; 54 rq->cmd_type = REQ_TYPE_SPECIAL;
55 elv_add_request(q, rq, ELEVATOR_INSERT_FRONT, 1); 55 elv_add_request(q, rq, ELEVATOR_INSERT_FRONT);
56 56
57out: 57out:
58 return; 58 return;
diff --git a/drivers/ide/ide-scan-pci.c b/drivers/ide/ide-scan-pci.c
index 0e79efff1deb..c3da53e7bb2b 100644
--- a/drivers/ide/ide-scan-pci.c
+++ b/drivers/ide/ide-scan-pci.c
@@ -88,7 +88,7 @@ static int __init ide_scan_pcibus(void)
88 struct list_head *l, *n; 88 struct list_head *l, *n;
89 89
90 pre_init = 0; 90 pre_init = 0;
91 while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev))) 91 for_each_pci_dev(dev)
92 ide_scan_pcidev(dev); 92 ide_scan_pcidev(dev);
93 93
94 /* 94 /*
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 6d622cb5ac81..7ecb1ade8874 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -32,11 +32,9 @@
32#include <linux/errno.h> 32#include <linux/errno.h>
33#include <linux/genhd.h> 33#include <linux/genhd.h>
34#include <linux/seq_file.h> 34#include <linux/seq_file.h>
35#include <linux/smp_lock.h>
36#include <linux/slab.h> 35#include <linux/slab.h>
37#include <linux/pci.h> 36#include <linux/pci.h>
38#include <linux/ide.h> 37#include <linux/ide.h>
39#include <linux/smp_lock.h>
40#include <linux/completion.h> 38#include <linux/completion.h>
41#include <linux/bitops.h> 39#include <linux/bitops.h>
42#include <linux/mutex.h> 40#include <linux/mutex.h>
@@ -220,6 +218,7 @@ typedef struct ide_tape_obj {
220 char write_prot; 218 char write_prot;
221} idetape_tape_t; 219} idetape_tape_t;
222 220
221static DEFINE_MUTEX(ide_tape_mutex);
223static DEFINE_MUTEX(idetape_ref_mutex); 222static DEFINE_MUTEX(idetape_ref_mutex);
224 223
225static DEFINE_MUTEX(idetape_chrdev_mutex); 224static DEFINE_MUTEX(idetape_chrdev_mutex);
@@ -1426,9 +1425,9 @@ static long idetape_chrdev_ioctl(struct file *file,
1426 unsigned int cmd, unsigned long arg) 1425 unsigned int cmd, unsigned long arg)
1427{ 1426{
1428 long ret; 1427 long ret;
1429 lock_kernel(); 1428 mutex_lock(&ide_tape_mutex);
1430 ret = do_idetape_chrdev_ioctl(file, cmd, arg); 1429 ret = do_idetape_chrdev_ioctl(file, cmd, arg);
1431 unlock_kernel(); 1430 mutex_unlock(&ide_tape_mutex);
1432 return ret; 1431 return ret;
1433} 1432}
1434 1433
@@ -1903,15 +1902,16 @@ static const struct file_operations idetape_fops = {
1903 .unlocked_ioctl = idetape_chrdev_ioctl, 1902 .unlocked_ioctl = idetape_chrdev_ioctl,
1904 .open = idetape_chrdev_open, 1903 .open = idetape_chrdev_open,
1905 .release = idetape_chrdev_release, 1904 .release = idetape_chrdev_release,
1905 .llseek = noop_llseek,
1906}; 1906};
1907 1907
1908static int idetape_open(struct block_device *bdev, fmode_t mode) 1908static int idetape_open(struct block_device *bdev, fmode_t mode)
1909{ 1909{
1910 struct ide_tape_obj *tape; 1910 struct ide_tape_obj *tape;
1911 1911
1912 lock_kernel(); 1912 mutex_lock(&ide_tape_mutex);
1913 tape = ide_tape_get(bdev->bd_disk, false, 0); 1913 tape = ide_tape_get(bdev->bd_disk, false, 0);
1914 unlock_kernel(); 1914 mutex_unlock(&ide_tape_mutex);
1915 1915
1916 if (!tape) 1916 if (!tape)
1917 return -ENXIO; 1917 return -ENXIO;
@@ -1923,9 +1923,9 @@ static int idetape_release(struct gendisk *disk, fmode_t mode)
1923{ 1923{
1924 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj); 1924 struct ide_tape_obj *tape = ide_drv_g(disk, ide_tape_obj);
1925 1925
1926 lock_kernel(); 1926 mutex_lock(&ide_tape_mutex);
1927 ide_tape_put(tape); 1927 ide_tape_put(tape);
1928 unlock_kernel(); 1928 mutex_unlock(&ide_tape_mutex);
1929 1929
1930 return 0; 1930 return 0;
1931} 1931}
@@ -1937,11 +1937,11 @@ static int idetape_ioctl(struct block_device *bdev, fmode_t mode,
1937 ide_drive_t *drive = tape->drive; 1937 ide_drive_t *drive = tape->drive;
1938 int err; 1938 int err;
1939 1939
1940 lock_kernel(); 1940 mutex_lock(&ide_tape_mutex);
1941 err = generic_ide_ioctl(drive, bdev, cmd, arg); 1941 err = generic_ide_ioctl(drive, bdev, cmd, arg);
1942 if (err == -EINVAL) 1942 if (err == -EINVAL)
1943 err = idetape_blkdev_ioctl(drive, cmd, arg); 1943 err = idetape_blkdev_ioctl(drive, cmd, arg);
1944 unlock_kernel(); 1944 mutex_unlock(&ide_tape_mutex);
1945 1945
1946 return err; 1946 return err;
1947} 1947}
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index 34b9872f35d1..600c89a3d137 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -201,7 +201,7 @@ static u8 wait_drive_not_busy(ide_drive_t *drive)
201 u8 stat; 201 u8 stat;
202 202
203 /* 203 /*
204 * Last sector was transfered, wait until device is ready. This can 204 * Last sector was transferred, wait until device is ready. This can
205 * take up to 6 ms on some ATAPI devices, so we will wait max 10 ms. 205 * take up to 6 ms on some ATAPI devices, so we will wait max 10 ms.
206 */ 206 */
207 for (retries = 0; retries < 1000; retries++) { 207 for (retries = 0; retries < 1000; retries++) {
diff --git a/drivers/ide/piix.c b/drivers/ide/piix.c
index 1bdca49e5a03..b59d04c72051 100644
--- a/drivers/ide/piix.c
+++ b/drivers/ide/piix.c
@@ -8,8 +8,8 @@
8 * 8 *
9 * Documentation: 9 * Documentation:
10 * 10 *
11 * Publically available from Intel web site. Errata documentation 11 * Publicly available from Intel web site. Errata documentation
12 * is also publically available. As an aide to anyone hacking on this 12 * is also publicly available. As an aide to anyone hacking on this
13 * driver the list of errata that are relevant is below.going back to 13 * driver the list of errata that are relevant is below.going back to
14 * PIIX4. Older device documentation is now a bit tricky to find. 14 * PIIX4. Older device documentation is now a bit tricky to find.
15 * 15 *
diff --git a/drivers/ide/pmac.c b/drivers/ide/pmac.c
index ebcf8e470a97..1db7c4368dbf 100644
--- a/drivers/ide/pmac.c
+++ b/drivers/ide/pmac.c
@@ -1334,7 +1334,7 @@ out_free_pmif:
1334static int 1334static int
1335pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg) 1335pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
1336{ 1336{
1337 pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata(pdev); 1337 pmac_ide_hwif_t *pmif = pci_get_drvdata(pdev);
1338 int rc = 0; 1338 int rc = 0;
1339 1339
1340 if (mesg.event != pdev->dev.power.power_state.event 1340 if (mesg.event != pdev->dev.power.power_state.event
@@ -1350,7 +1350,7 @@ pmac_ide_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
1350static int 1350static int
1351pmac_ide_pci_resume(struct pci_dev *pdev) 1351pmac_ide_pci_resume(struct pci_dev *pdev)
1352{ 1352{
1353 pmac_ide_hwif_t *pmif = (pmac_ide_hwif_t *)pci_get_drvdata(pdev); 1353 pmac_ide_hwif_t *pmif = pci_get_drvdata(pdev);
1354 int rc = 0; 1354 int rc = 0;
1355 1355
1356 if (pdev->dev.power.power_state.event != PM_EVENT_ON) { 1356 if (pdev->dev.power.power_state.event != PM_EVENT_ON) {
diff --git a/drivers/ide/sis5513.c b/drivers/ide/sis5513.c
index db7f4e761dbc..4a0022567758 100644
--- a/drivers/ide/sis5513.c
+++ b/drivers/ide/sis5513.c
@@ -53,7 +53,7 @@
53 53
54#define DRV_NAME "sis5513" 54#define DRV_NAME "sis5513"
55 55
56/* registers layout and init values are chipset family dependant */ 56/* registers layout and init values are chipset family dependent */
57 57
58#define ATA_16 0x01 58#define ATA_16 0x01
59#define ATA_33 0x02 59#define ATA_33 0x02
@@ -406,7 +406,7 @@ static int __devinit sis_find_family(struct pci_dev *dev)
406 pci_name(dev)); 406 pci_name(dev));
407 chipset_family = ATA_133; 407 chipset_family = ATA_133;
408 408
409 /* Check for 5513 compability mapping 409 /* Check for 5513 compatibility mapping
410 * We must use this, else the port enabled code will fail, 410 * We must use this, else the port enabled code will fail,
411 * as it expects the enablebits at 0x4a. 411 * as it expects the enablebits at 0x4a.
412 */ 412 */
diff --git a/drivers/ide/triflex.c b/drivers/ide/triflex.c
index 7953447eae0f..e53a1b78378b 100644
--- a/drivers/ide/triflex.c
+++ b/drivers/ide/triflex.c
@@ -22,7 +22,7 @@
22 * Loosely based on the piix & svwks drivers. 22 * Loosely based on the piix & svwks drivers.
23 * 23 *
24 * Documentation: 24 * Documentation:
25 * Not publically available. 25 * Not publicly available.
26 */ 26 */
27 27
28#include <linux/types.h> 28#include <linux/types.h>
diff --git a/drivers/ide/via82cxxx.c b/drivers/ide/via82cxxx.c
index d2a0997b78f8..f46f49cfcc28 100644
--- a/drivers/ide/via82cxxx.c
+++ b/drivers/ide/via82cxxx.c
@@ -14,7 +14,7 @@
14 * Andre Hedrick 14 * Andre Hedrick
15 * 15 *
16 * Documentation: 16 * Documentation:
17 * Obsolete device documentation publically available from via.com.tw 17 * Obsolete device documentation publicly available from via.com.tw
18 * Current device documentation available under NDA only 18 * Current device documentation available under NDA only
19 */ 19 */
20 20