aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-sa1100/include/mach/ide.h75
-rw-r--r--drivers/ide/Kconfig88
-rw-r--r--drivers/ide/Makefile19
-rw-r--r--drivers/ide/ide-atapi.c2
-rw-r--r--drivers/ide/ide-cd.c61
-rw-r--r--drivers/ide/ide-cd_ioctl.c8
-rw-r--r--drivers/ide/ide-disk.c382
-rw-r--r--drivers/ide/ide-disk.h21
-rw-r--r--drivers/ide/ide-disk_ioctl.c4
-rw-r--r--drivers/ide/ide-disk_proc.c2
-rw-r--r--drivers/ide/ide-dma-sff.c2
-rw-r--r--drivers/ide/ide-floppy.c357
-rw-r--r--drivers/ide/ide-floppy.h41
-rw-r--r--drivers/ide/ide-floppy_ioctl.c23
-rw-r--r--drivers/ide/ide-floppy_proc.c2
-rw-r--r--drivers/ide/ide-gd.c398
-rw-r--r--drivers/ide/ide-gd.h44
-rw-r--r--drivers/ide/ide-iops.c2
-rw-r--r--drivers/ide/ide-probe.c1
-rw-r--r--drivers/ide/ide-proc.c6
-rw-r--r--drivers/ide/ide-tape.c16
-rw-r--r--drivers/ide/pci/Makefile1
-rw-r--r--drivers/ide/pci/delkin_cb.c63
-rw-r--r--drivers/ide/pci/hpt34x.c193
-rw-r--r--drivers/ide/pci/hpt366.c35
-rw-r--r--drivers/ide/pci/scc_pata.c4
-rw-r--r--drivers/ide/pci/sgiioc4.c49
-rw-r--r--drivers/leds/Kconfig2
-rw-r--r--drivers/scsi/ide-scsi.c26
-rw-r--r--include/asm-frv/ide.h10
-rw-r--r--include/asm-m68k/ide.h9
-rw-r--r--include/asm-parisc/ide.h4
-rw-r--r--include/linux/ide.h36
33 files changed, 815 insertions, 1171 deletions
diff --git a/arch/arm/mach-sa1100/include/mach/ide.h b/arch/arm/mach-sa1100/include/mach/ide.h
deleted file mode 100644
index 4c99c8f5e617..000000000000
--- a/arch/arm/mach-sa1100/include/mach/ide.h
+++ /dev/null
@@ -1,75 +0,0 @@
1/*
2 * arch/arm/mach-sa1100/include/mach/ide.h
3 *
4 * Copyright (c) 1998 Hugo Fiennes & Nicolas Pitre
5 *
6 * 18-aug-2000: Cleanup by Erik Mouw (J.A.K.Mouw@its.tudelft.nl)
7 * Get rid of the special ide_init_hwif_ports() functions
8 * and make a generalised function that can be used by all
9 * architectures.
10 */
11
12#include <asm/irq.h>
13#include <mach/hardware.h>
14#include <asm/mach-types.h>
15
16#error "This code is broken and needs update to match with current ide support"
17
18
19/*
20 * Set up a hw structure for a specified data port, control port and IRQ.
21 * This should follow whatever the default interface uses.
22 */
23static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port,
24 unsigned long ctrl_port, int *irq)
25{
26 unsigned long reg = data_port;
27 int i;
28 int regincr = 1;
29
30 /* The Empeg board has the first two address lines unused */
31 if (machine_is_empeg())
32 regincr = 1 << 2;
33
34 /* The LART doesn't use A0 for IDE */
35 if (machine_is_lart())
36 regincr = 1 << 1;
37
38 memset(hw, 0, sizeof(*hw));
39
40 for (i = 0; i <= 7; i++) {
41 hw->io_ports_array[i] = reg;
42 reg += regincr;
43 }
44
45 hw->io_ports.ctl_addr = ctrl_port;
46
47 if (irq)
48 *irq = 0;
49}
50
51/*
52 * This registers the standard ports for this architecture with the IDE
53 * driver.
54 */
55static __inline__ void
56ide_init_default_hwifs(void)
57{
58 if (machine_is_lart()) {
59#ifdef CONFIG_SA1100_LART
60 hw_regs_t hw;
61
62 /* Enable GPIO as interrupt line */
63 GPDR &= ~LART_GPIO_IDE;
64 set_irq_type(LART_IRQ_IDE, IRQ_TYPE_EDGE_RISING);
65
66 /* set PCMCIA interface timing */
67 MECR = 0x00060006;
68
69 /* init the interface */
70 ide_init_hwif_ports(&hw, PCMCIA_IO_0_BASE + 0x0000, PCMCIA_IO_0_BASE + 0x1000, NULL);
71 hw.irq = LART_IRQ_IDE;
72 ide_register_hw(&hw);
73#endif
74 }
75}
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 74a369a6116f..a820ca6fc327 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -84,21 +84,40 @@ config BLK_DEV_IDE_SATA
84 84
85 If unsure, say N. 85 If unsure, say N.
86 86
87config BLK_DEV_IDEDISK 87config IDE_GD
88 tristate "Include IDE/ATA-2 DISK support" 88 tristate "generic ATA/ATAPI disk support"
89 ---help--- 89 default y
90 This will include enhanced support for MFM/RLL/IDE hard disks. If 90 help
91 you have a MFM/RLL/IDE disk, and there is no special reason to use 91 Support for ATA/ATAPI disks (including ATAPI floppy drives).
92 the old hard disk driver instead, say Y. If you have an SCSI-only
93 system, you can say N here.
94 92
95 To compile this driver as a module, choose M here: the 93 To compile this driver as a module, choose M here.
96 module will be called ide-disk. 94 The module will be called ide-gd_mod.
97 Do not compile this driver as a module if your root file system 95
98 (the one containing the directory /) is located on the IDE disk. 96 If unsure, say Y.
97
98config IDE_GD_ATA
99 bool "ATA disk support"
100 depends on IDE_GD
101 default y
102 help
103 This will include support for ATA hard disks.
99 104
100 If unsure, say Y. 105 If unsure, say Y.
101 106
107config IDE_GD_ATAPI
108 bool "ATAPI floppy support"
109 depends on IDE_GD
110 select IDE_ATAPI
111 help
112 This will include support for ATAPI floppy drives
113 (i.e. Iomega ZIP or MKE LS-120).
114
115 For information about jumper settings and the question
116 of when a ZIP drive uses a partition table, see
117 <http://www.win.tue.nl/~aeb/linux/zip/zip-1.html>.
118
119 If unsure, say N.
120
102config BLK_DEV_IDECS 121config BLK_DEV_IDECS
103 tristate "PCMCIA IDE support" 122 tristate "PCMCIA IDE support"
104 depends on PCMCIA 123 depends on PCMCIA
@@ -163,29 +182,6 @@ config BLK_DEV_IDETAPE
163 To compile this driver as a module, choose M here: the 182 To compile this driver as a module, choose M here: the
164 module will be called ide-tape. 183 module will be called ide-tape.
165 184
166config BLK_DEV_IDEFLOPPY
167 tristate "Include IDE/ATAPI FLOPPY support"
168 select IDE_ATAPI
169 ---help---
170 If you have an IDE floppy drive which uses the ATAPI protocol,
171 answer Y. ATAPI is a newer protocol used by IDE CD-ROM/tape/floppy
172 drives, similar to the SCSI protocol.
173
174 The LS-120 and the IDE/ATAPI Iomega ZIP drive are also supported by
175 this driver. For information about jumper settings and the question
176 of when a ZIP drive uses a partition table, see
177 <http://www.win.tue.nl/~aeb/linux/zip/zip-1.html>.
178 (ATAPI PD-CD/CDR drives are not supported by this driver; support
179 for PD-CD/CDR drives is available if you answer Y to
180 "SCSI emulation support", below).
181
182 If you say Y here, the FLOPPY drive will be identified along with
183 other IDE devices, as "hdb" or "hdc", or something similar (check
184 the boot messages with dmesg).
185
186 To compile this driver as a module, choose M here: the
187 module will be called ide-floppy.
188
189config BLK_DEV_IDESCSI 185config BLK_DEV_IDESCSI
190 tristate "SCSI emulation support (DEPRECATED)" 186 tristate "SCSI emulation support (DEPRECATED)"
191 depends on SCSI 187 depends on SCSI
@@ -332,7 +328,7 @@ config IDEPCI_PCIBUS_ORDER
332# TODO: split it on per host driver config options (or module parameters) 328# TODO: split it on per host driver config options (or module parameters)
333config BLK_DEV_OFFBOARD 329config BLK_DEV_OFFBOARD
334 bool "Boot off-board chipsets first support (DEPRECATED)" 330 bool "Boot off-board chipsets first support (DEPRECATED)"
335 depends on BLK_DEV_IDEPCI && (BLK_DEV_AEC62XX || BLK_DEV_GENERIC || BLK_DEV_HPT34X || BLK_DEV_HPT366 || BLK_DEV_PDC202XX_NEW || BLK_DEV_PDC202XX_OLD || BLK_DEV_TC86C001) 331 depends on BLK_DEV_IDEPCI && (BLK_DEV_AEC62XX || BLK_DEV_GENERIC || BLK_DEV_HPT366 || BLK_DEV_PDC202XX_NEW || BLK_DEV_PDC202XX_OLD || BLK_DEV_TC86C001)
336 help 332 help
337 Normally, IDE controllers built into the motherboard (on-board 333 Normally, IDE controllers built into the motherboard (on-board
338 controllers) are assigned to ide0 and ide1 while those on add-in PCI 334 controllers) are assigned to ide0 and ide1 while those on add-in PCI
@@ -482,28 +478,6 @@ config BLK_DEV_CS5535
482 478
483 It is safe to say Y to this question. 479 It is safe to say Y to this question.
484 480
485config BLK_DEV_HPT34X
486 tristate "HPT34X chipset support"
487 depends on BROKEN
488 select BLK_DEV_IDEDMA_PCI
489 help
490 This driver adds up to 4 more EIDE devices sharing a single
491 interrupt. The HPT343 chipset in its current form is a non-bootable
492 controller; the HPT345/HPT363 chipset is a bootable (needs BIOS FIX)
493 PCI UDMA controllers. This driver requires dynamic tuning of the
494 chipset during the ide-probe at boot time. It is reported to support
495 DVD II drives, by the manufacturer.
496
497config HPT34X_AUTODMA
498 bool "HPT34X AUTODMA support (EXPERIMENTAL)"
499 depends on BLK_DEV_HPT34X && EXPERIMENTAL
500 help
501 This is a dangerous thing to attempt currently! Please read the
502 comments at the top of <file:drivers/ide/pci/hpt34x.c>. If you say Y
503 here, then say Y to "Use DMA by default when available" as well.
504
505 If unsure, say N.
506
507config BLK_DEV_HPT366 481config BLK_DEV_HPT366
508 tristate "HPT36X/37X chipset support" 482 tristate "HPT36X/37X chipset support"
509 select BLK_DEV_IDEDMA_PCI 483 select BLK_DEV_IDEDMA_PCI
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index ceaf779054ea..093d3248ca89 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -37,18 +37,25 @@ obj-$(CONFIG_IDE_H8300) += h8300/
37obj-$(CONFIG_IDE_GENERIC) += ide-generic.o 37obj-$(CONFIG_IDE_GENERIC) += ide-generic.o
38obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o 38obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o
39 39
40ide-disk_mod-y += ide-disk.o ide-disk_ioctl.o 40ide-gd_mod-y += ide-gd.o
41ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o 41ide-cd_mod-y += ide-cd.o ide-cd_ioctl.o ide-cd_verbose.o
42ide-floppy_mod-y += ide-floppy.o ide-floppy_ioctl.o
43 42
43ifeq ($(CONFIG_IDE_GD_ATA), y)
44 ide-gd_mod-y += ide-disk.o ide-disk_ioctl.o
44ifeq ($(CONFIG_IDE_PROC_FS), y) 45ifeq ($(CONFIG_IDE_PROC_FS), y)
45 ide-disk_mod-y += ide-disk_proc.o 46 ide-gd_mod-y += ide-disk_proc.o
46 ide-floppy_mod-y += ide-floppy_proc.o 47endif
48endif
49
50ifeq ($(CONFIG_IDE_GD_ATAPI), y)
51 ide-gd_mod-y += ide-floppy.o ide-floppy_ioctl.o
52ifeq ($(CONFIG_IDE_PROC_FS), y)
53 ide-gd_mod-y += ide-floppy_proc.o
54endif
47endif 55endif
48 56
49obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk_mod.o 57obj-$(CONFIG_IDE_GD) += ide-gd_mod.o
50obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o 58obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd_mod.o
51obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy_mod.o
52obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o 59obj-$(CONFIG_BLK_DEV_IDETAPE) += ide-tape.o
53 60
54ifeq ($(CONFIG_BLK_DEV_IDECS), y) 61ifeq ($(CONFIG_BLK_DEV_IDECS), y)
diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c
index 2e305714c209..4e58b9e7a58a 100644
--- a/drivers/ide/ide-atapi.c
+++ b/drivers/ide/ide-atapi.c
@@ -191,7 +191,7 @@ int ide_set_media_lock(ide_drive_t *drive, struct gendisk *disk, int on)
191{ 191{
192 struct ide_atapi_pc pc; 192 struct ide_atapi_pc pc;
193 193
194 if (drive->atapi_flags & IDE_AFLAG_NO_DOORLOCK) 194 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0)
195 return 0; 195 return 0;
196 196
197 ide_init_pc(&pc); 197 ide_init_pc(&pc);
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 3308b1cd3a33..13265a8827da 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -99,7 +99,7 @@ static void ide_cd_put(struct cdrom_info *cd)
99/* Mark that we've seen a media change and invalidate our internal buffers. */ 99/* Mark that we've seen a media change and invalidate our internal buffers. */
100static void cdrom_saw_media_change(ide_drive_t *drive) 100static void cdrom_saw_media_change(ide_drive_t *drive)
101{ 101{
102 drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED; 102 drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED;
103 drive->atapi_flags &= ~IDE_AFLAG_TOC_VALID; 103 drive->atapi_flags &= ~IDE_AFLAG_TOC_VALID;
104} 104}
105 105
@@ -340,8 +340,8 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret)
340 } 340 }
341 341
342 ide_debug_log(IDE_DBG_RQ, "%s: stat: 0x%x, good_stat: 0x%x, " 342 ide_debug_log(IDE_DBG_RQ, "%s: stat: 0x%x, good_stat: 0x%x, "
343 "rq->cmd_type: 0x%x, err: 0x%x\n", __func__, stat, 343 "rq->cmd[0]: 0x%x, rq->cmd_type: 0x%x, err: 0x%x\n",
344 good_stat, rq->cmd_type, err); 344 __func__, stat, good_stat, rq->cmd[0], rq->cmd_type, err);
345 345
346 if (blk_sense_request(rq)) { 346 if (blk_sense_request(rq)) {
347 /* 347 /*
@@ -843,13 +843,10 @@ static void ide_cd_restore_request(ide_drive_t *drive, struct request *rq)
843 rq->q->prep_rq_fn(rq->q, rq); 843 rq->q->prep_rq_fn(rq->q, rq);
844} 844}
845 845
846/*
847 * All other packet commands.
848 */
849static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct request *rq) 846static void ide_cd_request_sense_fixup(ide_drive_t *drive, struct request *rq)
850{ 847{
851 848 ide_debug_log(IDE_DBG_FUNC, "Call %s, rq->cmd[0]: 0x%x\n",
852 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__); 849 __func__, rq->cmd[0]);
853 850
854 /* 851 /*
855 * Some of the trailing request sense fields are optional, 852 * Some of the trailing request sense fields are optional,
@@ -876,7 +873,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
876 if (!sense) 873 if (!sense)
877 sense = &local_sense; 874 sense = &local_sense;
878 875
879 ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd[0]: 0x%x, write: 0x%x, " 876 ide_debug_log(IDE_DBG_PC, "Call %s, cmd[0]: 0x%x, write: 0x%x, "
880 "timeout: %d, cmd_flags: 0x%x\n", __func__, cmd[0], write, 877 "timeout: %d, cmd_flags: 0x%x\n", __func__, cmd[0], write,
881 timeout, cmd_flags); 878 timeout, cmd_flags);
882 879
@@ -1177,8 +1174,9 @@ static ide_startstop_t cdrom_start_rw(ide_drive_t *drive, struct request *rq)
1177 unsigned short sectors_per_frame = 1174 unsigned short sectors_per_frame =
1178 queue_hardsect_size(drive->queue) >> SECTOR_BITS; 1175 queue_hardsect_size(drive->queue) >> SECTOR_BITS;
1179 1176
1180 ide_debug_log(IDE_DBG_RQ, "Call %s, write: 0x%x, secs_per_frame: %u\n", 1177 ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd[0]: 0x%x, write: 0x%x, "
1181 __func__, write, sectors_per_frame); 1178 "secs_per_frame: %u\n",
1179 __func__, rq->cmd[0], write, sectors_per_frame);
1182 1180
1183 if (write) { 1181 if (write) {
1184 /* disk has become write protected */ 1182 /* disk has become write protected */
@@ -1221,7 +1219,8 @@ static ide_startstop_t cdrom_do_newpc_cont(ide_drive_t *drive)
1221static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) 1219static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1222{ 1220{
1223 1221
1224 ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd_type: 0x%x\n", __func__, 1222 ide_debug_log(IDE_DBG_PC, "Call %s, rq->cmd[0]: 0x%x, "
1223 "rq->cmd_type: 0x%x\n", __func__, rq->cmd[0],
1225 rq->cmd_type); 1224 rq->cmd_type);
1226 1225
1227 if (blk_pc_request(rq)) 1226 if (blk_pc_request(rq))
@@ -1257,9 +1256,6 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
1257 } 1256 }
1258} 1257}
1259 1258
1260/*
1261 * cdrom driver request routine.
1262 */
1263static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq, 1259static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1264 sector_t block) 1260 sector_t block)
1265{ 1261{
@@ -1267,8 +1263,10 @@ static ide_startstop_t ide_cd_do_request(ide_drive_t *drive, struct request *rq,
1267 ide_handler_t *fn; 1263 ide_handler_t *fn;
1268 int xferlen; 1264 int xferlen;
1269 1265
1270 ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd_type: 0x%x, block: %llu\n", 1266 ide_debug_log(IDE_DBG_RQ, "Call %s, rq->cmd[0]: 0x%x, "
1271 __func__, rq->cmd_type, (unsigned long long)block); 1267 "rq->cmd_type: 0x%x, block: %llu\n",
1268 __func__, rq->cmd[0], rq->cmd_type,
1269 (unsigned long long)block);
1272 1270
1273 if (blk_fs_request(rq)) { 1271 if (blk_fs_request(rq)) {
1274 if (drive->atapi_flags & IDE_AFLAG_SEEKING) { 1272 if (drive->atapi_flags & IDE_AFLAG_SEEKING) {
@@ -1412,6 +1410,10 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1412 1410
1413 *capacity = 1 + be32_to_cpu(capbuf.lba); 1411 *capacity = 1 + be32_to_cpu(capbuf.lba);
1414 *sectors_per_frame = blocklen >> SECTOR_BITS; 1412 *sectors_per_frame = blocklen >> SECTOR_BITS;
1413
1414 ide_debug_log(IDE_DBG_PROBE, "%s: cap: %lu, sectors_per_frame: %lu\n",
1415 __func__, *capacity, *sectors_per_frame);
1416
1415 return 0; 1417 return 0;
1416} 1418}
1417 1419
@@ -1643,6 +1645,9 @@ void ide_cdrom_update_speed(ide_drive_t *drive, u8 *buf)
1643 maxspeed = be16_to_cpup((__be16 *)&buf[8 + 8]); 1645 maxspeed = be16_to_cpup((__be16 *)&buf[8 + 8]);
1644 } 1646 }
1645 1647
1648 ide_debug_log(IDE_DBG_PROBE, "%s: curspeed: %u, maxspeed: %u\n",
1649 __func__, curspeed, maxspeed);
1650
1646 cd->current_speed = (curspeed + (176/2)) / 176; 1651 cd->current_speed = (curspeed + (176/2)) / 176;
1647 cd->max_speed = (maxspeed + (176/2)) / 176; 1652 cd->max_speed = (maxspeed + (176/2)) / 176;
1648} 1653}
@@ -1732,7 +1737,7 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1732 return 0; 1737 return 0;
1733 1738
1734 if ((buf[8 + 6] & 0x01) == 0) 1739 if ((buf[8 + 6] & 0x01) == 0)
1735 drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; 1740 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
1736 if (buf[8 + 6] & 0x08) 1741 if (buf[8 + 6] & 0x08)
1737 drive->atapi_flags &= ~IDE_AFLAG_NO_EJECT; 1742 drive->atapi_flags &= ~IDE_AFLAG_NO_EJECT;
1738 if (buf[8 + 3] & 0x01) 1743 if (buf[8 + 3] & 0x01)
@@ -1777,7 +1782,7 @@ static int ide_cdrom_probe_capabilities(ide_drive_t *drive)
1777 if ((cdi->mask & CDC_DVD_R) == 0 || (cdi->mask & CDC_DVD_RAM) == 0) 1782 if ((cdi->mask & CDC_DVD_R) == 0 || (cdi->mask & CDC_DVD_RAM) == 0)
1778 printk(KERN_CONT " DVD%s%s", 1783 printk(KERN_CONT " DVD%s%s",
1779 (cdi->mask & CDC_DVD_R) ? "" : "-R", 1784 (cdi->mask & CDC_DVD_R) ? "" : "-R",
1780 (cdi->mask & CDC_DVD_RAM) ? "" : "-RAM"); 1785 (cdi->mask & CDC_DVD_RAM) ? "" : "/RAM");
1781 1786
1782 if ((cdi->mask & CDC_CD_R) == 0 || (cdi->mask & CDC_CD_RW) == 0) 1787 if ((cdi->mask & CDC_CD_R) == 0 || (cdi->mask & CDC_CD_RW) == 0)
1783 printk(KERN_CONT " CD%s%s", 1788 printk(KERN_CONT " CD%s%s",
@@ -1908,6 +1913,16 @@ static const struct ide_proc_devset idecd_settings[] = {
1908 IDE_PROC_DEVSET(dsc_overlap, 0, 1), 1913 IDE_PROC_DEVSET(dsc_overlap, 0, 1),
1909 { 0 }, 1914 { 0 },
1910}; 1915};
1916
1917static ide_proc_entry_t *ide_cd_proc_entries(ide_drive_t *drive)
1918{
1919 return idecd_proc;
1920}
1921
1922static const struct ide_proc_devset *ide_cd_proc_devsets(ide_drive_t *drive)
1923{
1924 return idecd_settings;
1925}
1911#endif 1926#endif
1912 1927
1913static const struct cd_list_entry ide_cd_quirks_list[] = { 1928static const struct cd_list_entry ide_cd_quirks_list[] = {
@@ -1986,8 +2001,8 @@ static int ide_cdrom_setup(ide_drive_t *drive)
1986 if (!drive->queue->unplug_delay) 2001 if (!drive->queue->unplug_delay)
1987 drive->queue->unplug_delay = 1; 2002 drive->queue->unplug_delay = 1;
1988 2003
1989 drive->atapi_flags = IDE_AFLAG_MEDIA_CHANGED | IDE_AFLAG_NO_EJECT | 2004 drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED;
1990 ide_cd_flags(id); 2005 drive->atapi_flags = IDE_AFLAG_NO_EJECT | ide_cd_flags(id);
1991 2006
1992 if ((drive->atapi_flags & IDE_AFLAG_VERTOS_300_SSD) && 2007 if ((drive->atapi_flags & IDE_AFLAG_VERTOS_300_SSD) &&
1993 fw_rev[4] == '1' && fw_rev[6] <= '2') 2008 fw_rev[4] == '1' && fw_rev[6] <= '2')
@@ -2069,8 +2084,8 @@ static ide_driver_t ide_cdrom_driver = {
2069 .end_request = ide_end_request, 2084 .end_request = ide_end_request,
2070 .error = __ide_error, 2085 .error = __ide_error,
2071#ifdef CONFIG_IDE_PROC_FS 2086#ifdef CONFIG_IDE_PROC_FS
2072 .proc = idecd_proc, 2087 .proc_entries = ide_cd_proc_entries,
2073 .settings = idecd_settings, 2088 .proc_devsets = ide_cd_proc_devsets,
2074#endif 2089#endif
2075}; 2090};
2076 2091
diff --git a/drivers/ide/ide-cd_ioctl.c b/drivers/ide/ide-cd_ioctl.c
index 74231b41f611..df3df0041eb6 100644
--- a/drivers/ide/ide-cd_ioctl.c
+++ b/drivers/ide/ide-cd_ioctl.c
@@ -86,8 +86,8 @@ int ide_cdrom_check_media_change_real(struct cdrom_device_info *cdi,
86 86
87 if (slot_nr == CDSL_CURRENT) { 87 if (slot_nr == CDSL_CURRENT) {
88 (void) cdrom_check_status(drive, NULL); 88 (void) cdrom_check_status(drive, NULL);
89 retval = (drive->atapi_flags & IDE_AFLAG_MEDIA_CHANGED) ? 1 : 0; 89 retval = (drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED) ? 1 : 0;
90 drive->atapi_flags &= ~IDE_AFLAG_MEDIA_CHANGED; 90 drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
91 return retval; 91 return retval;
92 } else { 92 } else {
93 return -EINVAL; 93 return -EINVAL;
@@ -136,7 +136,7 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag,
136 sense = &my_sense; 136 sense = &my_sense;
137 137
138 /* If the drive cannot lock the door, just pretend. */ 138 /* If the drive cannot lock the door, just pretend. */
139 if (drive->atapi_flags & IDE_AFLAG_NO_DOORLOCK) { 139 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0) {
140 stat = 0; 140 stat = 0;
141 } else { 141 } else {
142 unsigned char cmd[BLK_MAX_CDB]; 142 unsigned char cmd[BLK_MAX_CDB];
@@ -157,7 +157,7 @@ int ide_cd_lockdoor(ide_drive_t *drive, int lockflag,
157 (sense->asc == 0x24 || sense->asc == 0x20)) { 157 (sense->asc == 0x24 || sense->asc == 0x20)) {
158 printk(KERN_ERR "%s: door locking not supported\n", 158 printk(KERN_ERR "%s: door locking not supported\n",
159 drive->name); 159 drive->name);
160 drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; 160 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
161 stat = 0; 161 stat = 0;
162 } 162 }
163 163
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 3853bde8eedc..223750c1b5a6 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -14,9 +14,6 @@
14 * This is the IDE/ATA disk driver, as evolved from hd.c and ide.c. 14 * This is the IDE/ATA disk driver, as evolved from hd.c and ide.c.
15 */ 15 */
16 16
17#define IDEDISK_VERSION "1.18"
18
19#include <linux/module.h>
20#include <linux/types.h> 17#include <linux/types.h>
21#include <linux/string.h> 18#include <linux/string.h>
22#include <linux/kernel.h> 19#include <linux/kernel.h>
@@ -39,46 +36,8 @@
39#include <asm/io.h> 36#include <asm/io.h>
40#include <asm/div64.h> 37#include <asm/div64.h>
41 38
42#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
43#define IDE_DISK_MINORS (1 << PARTN_BITS)
44#else
45#define IDE_DISK_MINORS 0
46#endif
47
48#include "ide-disk.h" 39#include "ide-disk.h"
49 40
50static DEFINE_MUTEX(idedisk_ref_mutex);
51
52#define to_ide_disk(obj) container_of(obj, struct ide_disk_obj, kref)
53
54static void ide_disk_release(struct kref *);
55
56static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
57{
58 struct ide_disk_obj *idkp = NULL;
59
60 mutex_lock(&idedisk_ref_mutex);
61 idkp = ide_disk_g(disk);
62 if (idkp) {
63 if (ide_device_get(idkp->drive))
64 idkp = NULL;
65 else
66 kref_get(&idkp->kref);
67 }
68 mutex_unlock(&idedisk_ref_mutex);
69 return idkp;
70}
71
72static void ide_disk_put(struct ide_disk_obj *idkp)
73{
74 ide_drive_t *drive = idkp->drive;
75
76 mutex_lock(&idedisk_ref_mutex);
77 kref_put(&idkp->kref, ide_disk_release);
78 ide_device_put(drive);
79 mutex_unlock(&idedisk_ref_mutex);
80}
81
82static const u8 ide_rw_cmds[] = { 41static const u8 ide_rw_cmds[] = {
83 ATA_CMD_READ_MULTI, 42 ATA_CMD_READ_MULTI,
84 ATA_CMD_WRITE_MULTI, 43 ATA_CMD_WRITE_MULTI,
@@ -374,7 +333,7 @@ static void idedisk_check_hpa(ide_drive_t *drive)
374 } 333 }
375} 334}
376 335
377static void init_idedisk_capacity(ide_drive_t *drive) 336static int ide_disk_get_capacity(ide_drive_t *drive)
378{ 337{
379 u16 *id = drive->id; 338 u16 *id = drive->id;
380 int lba; 339 int lba;
@@ -403,11 +362,28 @@ static void init_idedisk_capacity(ide_drive_t *drive)
403 if (ata_id_hpa_enabled(id)) 362 if (ata_id_hpa_enabled(id))
404 idedisk_check_hpa(drive); 363 idedisk_check_hpa(drive);
405 } 364 }
406}
407 365
408sector_t ide_disk_capacity(ide_drive_t *drive) 366 /* limit drive capacity to 137GB if LBA48 cannot be used */
409{ 367 if ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 &&
410 return drive->capacity64; 368 drive->capacity64 > 1ULL << 28) {
369 printk(KERN_WARNING "%s: cannot use LBA48 - full capacity "
370 "%llu sectors (%llu MB)\n",
371 drive->name, (unsigned long long)drive->capacity64,
372 sectors_to_MB(drive->capacity64));
373 drive->capacity64 = 1ULL << 28;
374 }
375
376 if ((drive->hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) &&
377 (drive->dev_flags & IDE_DFLAG_LBA48)) {
378 if (drive->capacity64 > 1ULL << 28) {
379 printk(KERN_INFO "%s: cannot use LBA48 DMA - PIO mode"
380 " will be used for accessing sectors "
381 "> %u\n", drive->name, 1 << 28);
382 } else
383 drive->dev_flags &= ~IDE_DFLAG_LBA48;
384 }
385
386 return 0;
411} 387}
412 388
413static void idedisk_prepare_flush(struct request_queue *q, struct request *rq) 389static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
@@ -508,7 +484,7 @@ static void update_ordered(ide_drive_t *drive)
508 * time we have trimmed the drive capacity if LBA48 is 484 * time we have trimmed the drive capacity if LBA48 is
509 * not available so we don't need to recheck that. 485 * not available so we don't need to recheck that.
510 */ 486 */
511 capacity = ide_disk_capacity(drive); 487 capacity = ide_gd_capacity(drive);
512 barrier = ata_id_flush_enabled(id) && 488 barrier = ata_id_flush_enabled(id) &&
513 (drive->dev_flags & IDE_DFLAG_NOFLUSH) == 0 && 489 (drive->dev_flags & IDE_DFLAG_NOFLUSH) == 0 &&
514 ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 || 490 ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 ||
@@ -616,7 +592,12 @@ ide_ext_devset_rw(wcache, wcache);
616 592
617ide_ext_devset_rw_sync(nowerr, nowerr); 593ide_ext_devset_rw_sync(nowerr, nowerr);
618 594
619static void idedisk_setup(ide_drive_t *drive) 595static int ide_disk_check(ide_drive_t *drive, const char *s)
596{
597 return 1;
598}
599
600static void ide_disk_setup(ide_drive_t *drive)
620{ 601{
621 struct ide_disk_obj *idkp = drive->driver_data; 602 struct ide_disk_obj *idkp = drive->driver_data;
622 ide_hwif_t *hwif = drive->hwif; 603 ide_hwif_t *hwif = drive->hwif;
@@ -652,33 +633,13 @@ static void idedisk_setup(ide_drive_t *drive)
652 drive->queue->max_sectors / 2); 633 drive->queue->max_sectors / 2);
653 634
654 /* calculate drive capacity, and select LBA if possible */ 635 /* calculate drive capacity, and select LBA if possible */
655 init_idedisk_capacity(drive); 636 ide_disk_get_capacity(drive);
656
657 /* limit drive capacity to 137GB if LBA48 cannot be used */
658 if ((drive->dev_flags & IDE_DFLAG_LBA48) == 0 &&
659 drive->capacity64 > 1ULL << 28) {
660 printk(KERN_WARNING "%s: cannot use LBA48 - full capacity "
661 "%llu sectors (%llu MB)\n",
662 drive->name, (unsigned long long)drive->capacity64,
663 sectors_to_MB(drive->capacity64));
664 drive->capacity64 = 1ULL << 28;
665 }
666
667 if ((hwif->host_flags & IDE_HFLAG_NO_LBA48_DMA) &&
668 (drive->dev_flags & IDE_DFLAG_LBA48)) {
669 if (drive->capacity64 > 1ULL << 28) {
670 printk(KERN_INFO "%s: cannot use LBA48 DMA - PIO mode"
671 " will be used for accessing sectors "
672 "> %u\n", drive->name, 1 << 28);
673 } else
674 drive->dev_flags &= ~IDE_DFLAG_LBA48;
675 }
676 637
677 /* 638 /*
678 * if possible, give fdisk access to more of the drive, 639 * if possible, give fdisk access to more of the drive,
679 * by correcting bios_cyls: 640 * by correcting bios_cyls:
680 */ 641 */
681 capacity = ide_disk_capacity(drive); 642 capacity = ide_gd_capacity(drive);
682 643
683 if ((drive->dev_flags & IDE_DFLAG_FORCED_GEOM) == 0) { 644 if ((drive->dev_flags & IDE_DFLAG_FORCED_GEOM) == 0) {
684 if (ata_id_lba48_enabled(drive->id)) { 645 if (ata_id_lba48_enabled(drive->id)) {
@@ -718,9 +679,17 @@ static void idedisk_setup(ide_drive_t *drive)
718 drive->dev_flags |= IDE_DFLAG_WCACHE; 679 drive->dev_flags |= IDE_DFLAG_WCACHE;
719 680
720 set_wcache(drive, 1); 681 set_wcache(drive, 1);
682
683 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 &&
684 (drive->head == 0 || drive->head > 16)) {
685 printk(KERN_ERR "%s: invalid geometry: %d physical heads?\n",
686 drive->name, drive->head);
687 drive->dev_flags &= ~IDE_DFLAG_ATTACH;
688 } else
689 drive->dev_flags |= IDE_DFLAG_ATTACH;
721} 690}
722 691
723static void ide_cacheflush_p(ide_drive_t *drive) 692static void ide_disk_flush(ide_drive_t *drive)
724{ 693{
725 if (ata_id_flush_enabled(drive->id) == 0 || 694 if (ata_id_flush_enabled(drive->id) == 0 ||
726 (drive->dev_flags & IDE_DFLAG_WCACHE) == 0) 695 (drive->dev_flags & IDE_DFLAG_WCACHE) == 0)
@@ -730,267 +699,40 @@ static void ide_cacheflush_p(ide_drive_t *drive)
730 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name); 699 printk(KERN_INFO "%s: wcache flush failed!\n", drive->name);
731} 700}
732 701
733static void ide_disk_remove(ide_drive_t *drive) 702static int ide_disk_init_media(ide_drive_t *drive, struct gendisk *disk)
734{
735 struct ide_disk_obj *idkp = drive->driver_data;
736 struct gendisk *g = idkp->disk;
737
738 ide_proc_unregister_driver(drive, idkp->driver);
739
740 del_gendisk(g);
741
742 ide_cacheflush_p(drive);
743
744 ide_disk_put(idkp);
745}
746
747static void ide_disk_release(struct kref *kref)
748{
749 struct ide_disk_obj *idkp = to_ide_disk(kref);
750 ide_drive_t *drive = idkp->drive;
751 struct gendisk *g = idkp->disk;
752
753 drive->driver_data = NULL;
754 g->private_data = NULL;
755 put_disk(g);
756 kfree(idkp);
757}
758
759static int ide_disk_probe(ide_drive_t *drive);
760
761/*
762 * On HPA drives the capacity needs to be
763 * reinitilized on resume otherwise the disk
764 * can not be used and a hard reset is required
765 */
766static void ide_disk_resume(ide_drive_t *drive)
767{ 703{
768 if (ata_id_hpa_enabled(drive->id)) 704 return 0;
769 init_idedisk_capacity(drive);
770}
771
772static void ide_device_shutdown(ide_drive_t *drive)
773{
774#ifdef CONFIG_ALPHA
775 /* On Alpha, halt(8) doesn't actually turn the machine off,
776 it puts you into the sort of firmware monitor. Typically,
777 it's used to boot another kernel image, so it's not much
778 different from reboot(8). Therefore, we don't need to
779 spin down the disk in this case, especially since Alpha
780 firmware doesn't handle disks in standby mode properly.
781 On the other hand, it's reasonably safe to turn the power
782 off when the shutdown process reaches the firmware prompt,
783 as the firmware initialization takes rather long time -
784 at least 10 seconds, which should be sufficient for
785 the disk to expire its write cache. */
786 if (system_state != SYSTEM_POWER_OFF) {
787#else
788 if (system_state == SYSTEM_RESTART) {
789#endif
790 ide_cacheflush_p(drive);
791 return;
792 }
793
794 printk(KERN_INFO "Shutdown: %s\n", drive->name);
795
796 drive->gendev.bus->suspend(&drive->gendev, PMSG_SUSPEND);
797} 705}
798 706
799static ide_driver_t idedisk_driver = { 707static int ide_disk_set_doorlock(ide_drive_t *drive, struct gendisk *disk,
800 .gen_driver = { 708 int on)
801 .owner = THIS_MODULE,
802 .name = "ide-disk",
803 .bus = &ide_bus_type,
804 },
805 .probe = ide_disk_probe,
806 .remove = ide_disk_remove,
807 .resume = ide_disk_resume,
808 .shutdown = ide_device_shutdown,
809 .version = IDEDISK_VERSION,
810 .do_request = ide_do_rw_disk,
811 .end_request = ide_end_request,
812 .error = __ide_error,
813#ifdef CONFIG_IDE_PROC_FS
814 .proc = ide_disk_proc,
815 .settings = ide_disk_settings,
816#endif
817};
818
819static int idedisk_set_doorlock(ide_drive_t *drive, int on)
820{ 709{
821 ide_task_t task; 710 ide_task_t task;
711 int ret;
712
713 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) == 0)
714 return 0;
822 715
823 memset(&task, 0, sizeof(task)); 716 memset(&task, 0, sizeof(task));
824 task.tf.command = on ? ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK; 717 task.tf.command = on ? ATA_CMD_MEDIA_LOCK : ATA_CMD_MEDIA_UNLOCK;
825 task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; 718 task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
826 719
827 return ide_no_data_taskfile(drive, &task); 720 ret = ide_no_data_taskfile(drive, &task);
828}
829
830static int idedisk_open(struct inode *inode, struct file *filp)
831{
832 struct gendisk *disk = inode->i_bdev->bd_disk;
833 struct ide_disk_obj *idkp;
834 ide_drive_t *drive;
835
836 idkp = ide_disk_get(disk);
837 if (idkp == NULL)
838 return -ENXIO;
839
840 drive = idkp->drive;
841
842 idkp->openers++;
843
844 if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) {
845 check_disk_change(inode->i_bdev);
846 /*
847 * Ignore the return code from door_lock,
848 * since the open() has already succeeded,
849 * and the door_lock is irrelevant at this point.
850 */
851 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) &&
852 idedisk_set_doorlock(drive, 1))
853 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
854 }
855 return 0;
856}
857
858static int idedisk_release(struct inode *inode, struct file *filp)
859{
860 struct gendisk *disk = inode->i_bdev->bd_disk;
861 struct ide_disk_obj *idkp = ide_disk_g(disk);
862 ide_drive_t *drive = idkp->drive;
863
864 if (idkp->openers == 1)
865 ide_cacheflush_p(drive);
866
867 if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) {
868 if ((drive->dev_flags & IDE_DFLAG_DOORLOCKING) &&
869 idedisk_set_doorlock(drive, 0))
870 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
871 }
872 721
873 idkp->openers--; 722 if (ret)
723 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
874 724
875 ide_disk_put(idkp); 725 return ret;
876
877 return 0;
878}
879
880static int idedisk_getgeo(struct block_device *bdev, struct hd_geometry *geo)
881{
882 struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk);
883 ide_drive_t *drive = idkp->drive;
884
885 geo->heads = drive->bios_head;
886 geo->sectors = drive->bios_sect;
887 geo->cylinders = (u16)drive->bios_cyl; /* truncate */
888 return 0;
889} 726}
890 727
891static int idedisk_media_changed(struct gendisk *disk) 728const struct ide_disk_ops ide_ata_disk_ops = {
892{ 729 .check = ide_disk_check,
893 struct ide_disk_obj *idkp = ide_disk_g(disk); 730 .get_capacity = ide_disk_get_capacity,
894 ide_drive_t *drive = idkp->drive; 731 .setup = ide_disk_setup,
895 732 .flush = ide_disk_flush,
896 /* do not scan partitions twice if this is a removable device */ 733 .init_media = ide_disk_init_media,
897 if (drive->dev_flags & IDE_DFLAG_ATTACH) { 734 .set_doorlock = ide_disk_set_doorlock,
898 drive->dev_flags &= ~IDE_DFLAG_ATTACH; 735 .do_request = ide_do_rw_disk,
899 return 0; 736 .end_request = ide_end_request,
900 } 737 .ioctl = ide_disk_ioctl,
901
902 /* if removable, always assume it was changed */
903 return !!(drive->dev_flags & IDE_DFLAG_REMOVABLE);
904}
905
906static int idedisk_revalidate_disk(struct gendisk *disk)
907{
908 struct ide_disk_obj *idkp = ide_disk_g(disk);
909 set_capacity(disk, ide_disk_capacity(idkp->drive));
910 return 0;
911}
912
913static struct block_device_operations idedisk_ops = {
914 .owner = THIS_MODULE,
915 .open = idedisk_open,
916 .release = idedisk_release,
917 .ioctl = ide_disk_ioctl,
918 .getgeo = idedisk_getgeo,
919 .media_changed = idedisk_media_changed,
920 .revalidate_disk = idedisk_revalidate_disk
921}; 738};
922
923MODULE_DESCRIPTION("ATA DISK Driver");
924
925static int ide_disk_probe(ide_drive_t *drive)
926{
927 struct ide_disk_obj *idkp;
928 struct gendisk *g;
929
930 /* strstr("foo", "") is non-NULL */
931 if (!strstr("ide-disk", drive->driver_req))
932 goto failed;
933
934 if (drive->media != ide_disk)
935 goto failed;
936
937 idkp = kzalloc(sizeof(*idkp), GFP_KERNEL);
938 if (!idkp)
939 goto failed;
940
941 g = alloc_disk_node(IDE_DISK_MINORS, hwif_to_node(drive->hwif));
942 if (!g)
943 goto out_free_idkp;
944
945 ide_init_disk(g, drive);
946
947 kref_init(&idkp->kref);
948
949 idkp->drive = drive;
950 idkp->driver = &idedisk_driver;
951 idkp->disk = g;
952
953 g->private_data = &idkp->driver;
954
955 drive->driver_data = idkp;
956
957 idedisk_setup(drive);
958 if ((drive->dev_flags & IDE_DFLAG_LBA) == 0 &&
959 (drive->head == 0 || drive->head > 16)) {
960 printk(KERN_ERR "%s: INVALID GEOMETRY: %d PHYSICAL HEADS?\n",
961 drive->name, drive->head);
962 drive->dev_flags &= ~IDE_DFLAG_ATTACH;
963 } else
964 drive->dev_flags |= IDE_DFLAG_ATTACH;
965
966 g->minors = IDE_DISK_MINORS;
967 g->driverfs_dev = &drive->gendev;
968 g->flags |= GENHD_FL_EXT_DEVT;
969 if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
970 g->flags = GENHD_FL_REMOVABLE;
971 set_capacity(g, ide_disk_capacity(drive));
972 g->fops = &idedisk_ops;
973 add_disk(g);
974 return 0;
975
976out_free_idkp:
977 kfree(idkp);
978failed:
979 return -ENODEV;
980}
981
982static void __exit idedisk_exit(void)
983{
984 driver_unregister(&idedisk_driver.gen_driver);
985}
986
987static int __init idedisk_init(void)
988{
989 return driver_register(&idedisk_driver.gen_driver);
990}
991
992MODULE_ALIAS("ide:*m-disk*");
993MODULE_ALIAS("ide-disk");
994module_init(idedisk_init);
995module_exit(idedisk_exit);
996MODULE_LICENSE("GPL");
diff --git a/drivers/ide/ide-disk.h b/drivers/ide/ide-disk.h
index a82fa4355665..b234b0feaf7b 100644
--- a/drivers/ide/ide-disk.h
+++ b/drivers/ide/ide-disk.h
@@ -1,19 +1,11 @@
1#ifndef __IDE_DISK_H 1#ifndef __IDE_DISK_H
2#define __IDE_DISK_H 2#define __IDE_DISK_H
3 3
4struct ide_disk_obj { 4#include "ide-gd.h"
5 ide_drive_t *drive;
6 ide_driver_t *driver;
7 struct gendisk *disk;
8 struct kref kref;
9 unsigned int openers; /* protected by BKL for now */
10};
11
12#define ide_disk_g(disk) \
13 container_of((disk)->private_data, struct ide_disk_obj, driver)
14 5
6#ifdef CONFIG_IDE_GD_ATA
15/* ide-disk.c */ 7/* ide-disk.c */
16sector_t ide_disk_capacity(ide_drive_t *); 8extern const struct ide_disk_ops ide_ata_disk_ops;
17ide_decl_devset(address); 9ide_decl_devset(address);
18ide_decl_devset(multcount); 10ide_decl_devset(multcount);
19ide_decl_devset(nowerr); 11ide_decl_devset(nowerr);
@@ -21,12 +13,17 @@ ide_decl_devset(wcache);
21ide_decl_devset(acoustic); 13ide_decl_devset(acoustic);
22 14
23/* ide-disk_ioctl.c */ 15/* ide-disk_ioctl.c */
24int ide_disk_ioctl(struct inode *, struct file *, unsigned int, unsigned long); 16int ide_disk_ioctl(ide_drive_t *, struct inode *, struct file *, unsigned int,
17 unsigned long);
25 18
26#ifdef CONFIG_IDE_PROC_FS 19#ifdef CONFIG_IDE_PROC_FS
27/* ide-disk_proc.c */ 20/* ide-disk_proc.c */
28extern ide_proc_entry_t ide_disk_proc[]; 21extern ide_proc_entry_t ide_disk_proc[];
29extern const struct ide_proc_devset ide_disk_settings[]; 22extern const struct ide_proc_devset ide_disk_settings[];
30#endif 23#endif
24#else
25#define ide_disk_proc NULL
26#define ide_disk_settings NULL
27#endif
31 28
32#endif /* __IDE_DISK_H */ 29#endif /* __IDE_DISK_H */
diff --git a/drivers/ide/ide-disk_ioctl.c b/drivers/ide/ide-disk_ioctl.c
index a6cf1a03a806..a49698bcf966 100644
--- a/drivers/ide/ide-disk_ioctl.c
+++ b/drivers/ide/ide-disk_ioctl.c
@@ -13,12 +13,10 @@ static const struct ide_ioctl_devset ide_disk_ioctl_settings[] = {
13{ 0 } 13{ 0 }
14}; 14};
15 15
16int ide_disk_ioctl(struct inode *inode, struct file *file, 16int ide_disk_ioctl(ide_drive_t *drive, struct inode *inode, struct file *file,
17 unsigned int cmd, unsigned long arg) 17 unsigned int cmd, unsigned long arg)
18{ 18{
19 struct block_device *bdev = inode->i_bdev; 19 struct block_device *bdev = inode->i_bdev;
20 struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk);
21 ide_drive_t *drive = idkp->drive;
22 int err; 20 int err;
23 21
24 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings); 22 err = ide_setting_ioctl(drive, bdev, cmd, arg, ide_disk_ioctl_settings);
diff --git a/drivers/ide/ide-disk_proc.c b/drivers/ide/ide-disk_proc.c
index 4724976afe71..1146f4204c6e 100644
--- a/drivers/ide/ide-disk_proc.c
+++ b/drivers/ide/ide-disk_proc.c
@@ -56,7 +56,7 @@ static int proc_idedisk_read_capacity
56 ide_drive_t*drive = (ide_drive_t *)data; 56 ide_drive_t*drive = (ide_drive_t *)data;
57 int len; 57 int len;
58 58
59 len = sprintf(page, "%llu\n", (long long)ide_disk_capacity(drive)); 59 len = sprintf(page, "%llu\n", (long long)ide_gd_capacity(drive));
60 60
61 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 61 PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
62} 62}
diff --git a/drivers/ide/ide-dma-sff.c b/drivers/ide/ide-dma-sff.c
index 0903782689e9..cac431f0df17 100644
--- a/drivers/ide/ide-dma-sff.c
+++ b/drivers/ide/ide-dma-sff.c
@@ -130,7 +130,7 @@ int ide_build_dmatable(ide_drive_t *drive, struct request *rq)
130 xcount = bcount & 0xffff; 130 xcount = bcount & 0xffff;
131 if (is_trm290) 131 if (is_trm290)
132 xcount = ((xcount >> 2) - 1) << 16; 132 xcount = ((xcount >> 2) - 1) << 16;
133 if (xcount == 0x0000) { 133 else if (xcount == 0x0000) {
134 if (count++ >= PRD_ENTRIES) 134 if (count++ >= PRD_ENTRIES)
135 goto use_pio_instead; 135 goto use_pio_instead;
136 *table++ = cpu_to_le32(0x8000); 136 *table++ = cpu_to_le32(0x8000);
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index cf0aa25470ee..aeb1ad782f54 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -15,12 +15,6 @@
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#define PFX DRV_NAME ": "
20
21#define IDEFLOPPY_VERSION "1.00"
22
23#include <linux/module.h>
24#include <linux/types.h> 18#include <linux/types.h>
25#include <linux/string.h> 19#include <linux/string.h>
26#include <linux/kernel.h> 20#include <linux/kernel.h>
@@ -49,19 +43,6 @@
49 43
50#include "ide-floppy.h" 44#include "ide-floppy.h"
51 45
52/* module parameters */
53static unsigned long debug_mask;
54module_param(debug_mask, ulong, 0644);
55
56/* define to see debug info */
57#define IDEFLOPPY_DEBUG_LOG 0
58
59#if IDEFLOPPY_DEBUG_LOG
60#define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args)
61#else
62#define ide_debug_log(lvl, fmt, args...) do {} while (0)
63#endif
64
65/* 46/*
66 * After each failed packet command we issue a request sense command and retry 47 * After each failed packet command we issue a request sense command and retry
67 * the packet command IDEFLOPPY_MAX_PC_RETRIES times. 48 * the packet command IDEFLOPPY_MAX_PC_RETRIES times.
@@ -83,43 +64,13 @@ module_param(debug_mask, ulong, 0644);
83/* Error code returned in rq->errors to the higher part of the driver. */ 64/* Error code returned in rq->errors to the higher part of the driver. */
84#define IDEFLOPPY_ERROR_GENERAL 101 65#define IDEFLOPPY_ERROR_GENERAL 101
85 66
86static DEFINE_MUTEX(idefloppy_ref_mutex);
87
88static void idefloppy_cleanup_obj(struct kref *);
89
90static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk)
91{
92 struct ide_floppy_obj *floppy = NULL;
93
94 mutex_lock(&idefloppy_ref_mutex);
95 floppy = ide_drv_g(disk, ide_floppy_obj);
96 if (floppy) {
97 if (ide_device_get(floppy->drive))
98 floppy = NULL;
99 else
100 kref_get(&floppy->kref);
101 }
102 mutex_unlock(&idefloppy_ref_mutex);
103 return floppy;
104}
105
106static void ide_floppy_put(struct ide_floppy_obj *floppy)
107{
108 ide_drive_t *drive = floppy->drive;
109
110 mutex_lock(&idefloppy_ref_mutex);
111 kref_put(&floppy->kref, idefloppy_cleanup_obj);
112 ide_device_put(drive);
113 mutex_unlock(&idefloppy_ref_mutex);
114}
115
116/* 67/*
117 * Used to finish servicing a request. For read/write requests, we will call 68 * Used to finish servicing a request. For read/write requests, we will call
118 * ide_end_request to pass to the next buffer. 69 * ide_end_request to pass to the next buffer.
119 */ 70 */
120static int idefloppy_end_request(ide_drive_t *drive, int uptodate, int nsecs) 71static int ide_floppy_end_request(ide_drive_t *drive, int uptodate, int nsecs)
121{ 72{
122 idefloppy_floppy_t *floppy = drive->driver_data; 73 struct ide_disk_obj *floppy = drive->driver_data;
123 struct request *rq = HWGROUP(drive)->rq; 74 struct request *rq = HWGROUP(drive)->rq;
124 int error; 75 int error;
125 76
@@ -161,12 +112,12 @@ static void idefloppy_update_buffers(ide_drive_t *drive,
161 struct bio *bio = rq->bio; 112 struct bio *bio = rq->bio;
162 113
163 while ((bio = rq->bio) != NULL) 114 while ((bio = rq->bio) != NULL)
164 idefloppy_end_request(drive, 1, 0); 115 ide_floppy_end_request(drive, 1, 0);
165} 116}
166 117
167static void ide_floppy_callback(ide_drive_t *drive, int dsc) 118static void ide_floppy_callback(ide_drive_t *drive, int dsc)
168{ 119{
169 idefloppy_floppy_t *floppy = drive->driver_data; 120 struct ide_disk_obj *floppy = drive->driver_data;
170 struct ide_atapi_pc *pc = drive->pc; 121 struct ide_atapi_pc *pc = drive->pc;
171 int uptodate = pc->error ? 0 : 1; 122 int uptodate = pc->error ? 0 : 1;
172 123
@@ -200,10 +151,10 @@ static void ide_floppy_callback(ide_drive_t *drive, int dsc)
200 "Aborting request!\n"); 151 "Aborting request!\n");
201 } 152 }
202 153
203 idefloppy_end_request(drive, uptodate, 0); 154 ide_floppy_end_request(drive, uptodate, 0);
204} 155}
205 156
206static void ide_floppy_report_error(idefloppy_floppy_t *floppy, 157static void ide_floppy_report_error(struct ide_disk_obj *floppy,
207 struct ide_atapi_pc *pc) 158 struct ide_atapi_pc *pc)
208{ 159{
209 /* supress error messages resulting from Medium not present */ 160 /* supress error messages resulting from Medium not present */
@@ -222,7 +173,7 @@ static void ide_floppy_report_error(idefloppy_floppy_t *floppy,
222static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive, 173static ide_startstop_t idefloppy_issue_pc(ide_drive_t *drive,
223 struct ide_atapi_pc *pc) 174 struct ide_atapi_pc *pc)
224{ 175{
225 idefloppy_floppy_t *floppy = drive->driver_data; 176 struct ide_disk_obj *floppy = drive->driver_data;
226 177
227 if (floppy->failed_pc == NULL && 178 if (floppy->failed_pc == NULL &&
228 pc->c[0] != GPCMD_REQUEST_SENSE) 179 pc->c[0] != GPCMD_REQUEST_SENSE)
@@ -286,7 +237,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive,
286 struct ide_atapi_pc *pc, struct request *rq, 237 struct ide_atapi_pc *pc, struct request *rq,
287 unsigned long sector) 238 unsigned long sector)
288{ 239{
289 idefloppy_floppy_t *floppy = drive->driver_data; 240 struct ide_disk_obj *floppy = drive->driver_data;
290 int block = sector / floppy->bs_factor; 241 int block = sector / floppy->bs_factor;
291 int blocks = rq->nr_sectors / floppy->bs_factor; 242 int blocks = rq->nr_sectors / floppy->bs_factor;
292 int cmd = rq_data_dir(rq); 243 int cmd = rq_data_dir(rq);
@@ -310,7 +261,7 @@ static void idefloppy_create_rw_cmd(ide_drive_t *drive,
310 pc->flags |= PC_FLAG_DMA_OK; 261 pc->flags |= PC_FLAG_DMA_OK;
311} 262}
312 263
313static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy, 264static void idefloppy_blockpc_cmd(struct ide_disk_obj *floppy,
314 struct ide_atapi_pc *pc, struct request *rq) 265 struct ide_atapi_pc *pc, struct request *rq)
315{ 266{
316 ide_init_pc(pc); 267 ide_init_pc(pc);
@@ -329,13 +280,12 @@ static void idefloppy_blockpc_cmd(idefloppy_floppy_t *floppy,
329 pc->req_xfer = pc->buf_size = rq->data_len; 280 pc->req_xfer = pc->buf_size = rq->data_len;
330} 281}
331 282
332static ide_startstop_t idefloppy_do_request(ide_drive_t *drive, 283static ide_startstop_t ide_floppy_do_request(ide_drive_t *drive,
333 struct request *rq, sector_t block_s) 284 struct request *rq, sector_t block)
334{ 285{
335 idefloppy_floppy_t *floppy = drive->driver_data; 286 struct ide_disk_obj *floppy = drive->driver_data;
336 ide_hwif_t *hwif = drive->hwif; 287 ide_hwif_t *hwif = drive->hwif;
337 struct ide_atapi_pc *pc; 288 struct ide_atapi_pc *pc;
338 unsigned long block = (unsigned long)block_s;
339 289
340 ide_debug_log(IDE_DBG_FUNC, "%s: dev: %s, cmd: 0x%x, cmd_type: %x, " 290 ide_debug_log(IDE_DBG_FUNC, "%s: dev: %s, cmd: 0x%x, cmd_type: %x, "
341 "errors: %d\n", 291 "errors: %d\n",
@@ -353,7 +303,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
353 else 303 else
354 printk(KERN_ERR PFX "%s: I/O error\n", drive->name); 304 printk(KERN_ERR PFX "%s: I/O error\n", drive->name);
355 305
356 idefloppy_end_request(drive, 0, 0); 306 ide_floppy_end_request(drive, 0, 0);
357 return ide_stopped; 307 return ide_stopped;
358 } 308 }
359 if (blk_fs_request(rq)) { 309 if (blk_fs_request(rq)) {
@@ -361,11 +311,11 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
361 (rq->nr_sectors % floppy->bs_factor)) { 311 (rq->nr_sectors % floppy->bs_factor)) {
362 printk(KERN_ERR PFX "%s: unsupported r/w rq size\n", 312 printk(KERN_ERR PFX "%s: unsupported r/w rq size\n",
363 drive->name); 313 drive->name);
364 idefloppy_end_request(drive, 0, 0); 314 ide_floppy_end_request(drive, 0, 0);
365 return ide_stopped; 315 return ide_stopped;
366 } 316 }
367 pc = &floppy->queued_pc; 317 pc = &floppy->queued_pc;
368 idefloppy_create_rw_cmd(drive, pc, rq, block); 318 idefloppy_create_rw_cmd(drive, pc, rq, (unsigned long)block);
369 } else if (blk_special_request(rq)) { 319 } else if (blk_special_request(rq)) {
370 pc = (struct ide_atapi_pc *) rq->buffer; 320 pc = (struct ide_atapi_pc *) rq->buffer;
371 } else if (blk_pc_request(rq)) { 321 } else if (blk_pc_request(rq)) {
@@ -373,7 +323,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
373 idefloppy_blockpc_cmd(floppy, pc, rq); 323 idefloppy_blockpc_cmd(floppy, pc, rq);
374 } else { 324 } else {
375 blk_dump_rq_flags(rq, PFX "unsupported command in queue"); 325 blk_dump_rq_flags(rq, PFX "unsupported command in queue");
376 idefloppy_end_request(drive, 0, 0); 326 ide_floppy_end_request(drive, 0, 0);
377 return ide_stopped; 327 return ide_stopped;
378 } 328 }
379 329
@@ -394,7 +344,7 @@ static ide_startstop_t idefloppy_do_request(ide_drive_t *drive,
394 */ 344 */
395static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive) 345static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
396{ 346{
397 idefloppy_floppy_t *floppy = drive->driver_data; 347 struct ide_disk_obj *floppy = drive->driver_data;
398 struct gendisk *disk = floppy->disk; 348 struct gendisk *disk = floppy->disk;
399 struct ide_atapi_pc pc; 349 struct ide_atapi_pc pc;
400 u8 *page; 350 u8 *page;
@@ -410,11 +360,11 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
410 } 360 }
411 361
412 if (pc.buf[3] & 0x80) 362 if (pc.buf[3] & 0x80)
413 drive->atapi_flags |= IDE_AFLAG_WP; 363 drive->dev_flags |= IDE_DFLAG_WP;
414 else 364 else
415 drive->atapi_flags &= ~IDE_AFLAG_WP; 365 drive->dev_flags &= ~IDE_DFLAG_WP;
416 366
417 set_disk_ro(disk, !!(drive->atapi_flags & IDE_AFLAG_WP)); 367 set_disk_ro(disk, !!(drive->dev_flags & IDE_DFLAG_WP));
418 368
419 page = &pc.buf[8]; 369 page = &pc.buf[8];
420 370
@@ -445,7 +395,9 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
445 drive->name, lba_capacity, capacity); 395 drive->name, lba_capacity, capacity);
446 floppy->blocks = floppy->block_size ? 396 floppy->blocks = floppy->block_size ?
447 capacity / floppy->block_size : 0; 397 capacity / floppy->block_size : 0;
398 drive->capacity64 = floppy->blocks * floppy->bs_factor;
448 } 399 }
400
449 return 0; 401 return 0;
450} 402}
451 403
@@ -455,7 +407,7 @@ static int ide_floppy_get_flexible_disk_page(ide_drive_t *drive)
455 */ 407 */
456static int ide_floppy_get_capacity(ide_drive_t *drive) 408static int ide_floppy_get_capacity(ide_drive_t *drive)
457{ 409{
458 idefloppy_floppy_t *floppy = drive->driver_data; 410 struct ide_disk_obj *floppy = drive->driver_data;
459 struct gendisk *disk = floppy->disk; 411 struct gendisk *disk = floppy->disk;
460 struct ide_atapi_pc pc; 412 struct ide_atapi_pc pc;
461 u8 *cap_desc; 413 u8 *cap_desc;
@@ -466,7 +418,7 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
466 drive->bios_head = drive->bios_sect = 0; 418 drive->bios_head = drive->bios_sect = 0;
467 floppy->blocks = 0; 419 floppy->blocks = 0;
468 floppy->bs_factor = 1; 420 floppy->bs_factor = 1;
469 set_capacity(floppy->disk, 0); 421 drive->capacity64 = 0;
470 422
471 ide_floppy_create_read_capacity_cmd(&pc); 423 ide_floppy_create_read_capacity_cmd(&pc);
472 if (ide_queue_pc_tail(drive, disk, &pc)) { 424 if (ide_queue_pc_tail(drive, disk, &pc)) {
@@ -523,6 +475,8 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
523 "non 512 bytes block size not " 475 "non 512 bytes block size not "
524 "fully supported\n", 476 "fully supported\n",
525 drive->name); 477 drive->name);
478 drive->capacity64 =
479 floppy->blocks * floppy->bs_factor;
526 rc = 0; 480 rc = 0;
527 } 481 }
528 break; 482 break;
@@ -547,21 +501,12 @@ static int ide_floppy_get_capacity(ide_drive_t *drive)
547 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE)) 501 if (!(drive->atapi_flags & IDE_AFLAG_CLIK_DRIVE))
548 (void) ide_floppy_get_flexible_disk_page(drive); 502 (void) ide_floppy_get_flexible_disk_page(drive);
549 503
550 set_capacity(disk, floppy->blocks * floppy->bs_factor);
551
552 return rc; 504 return rc;
553} 505}
554 506
555sector_t ide_floppy_capacity(ide_drive_t *drive) 507static void ide_floppy_setup(ide_drive_t *drive)
556{
557 idefloppy_floppy_t *floppy = drive->driver_data;
558 unsigned long capacity = floppy->blocks * floppy->bs_factor;
559
560 return capacity;
561}
562
563static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
564{ 508{
509 struct ide_disk_obj *floppy = drive->driver_data;
565 u16 *id = drive->id; 510 u16 *id = drive->id;
566 511
567 drive->pc_callback = ide_floppy_callback; 512 drive->pc_callback = ide_floppy_callback;
@@ -592,252 +537,42 @@ static void idefloppy_setup(ide_drive_t *drive, idefloppy_floppy_t *floppy)
592 blk_queue_max_sectors(drive->queue, 64); 537 blk_queue_max_sectors(drive->queue, 64);
593 drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE; 538 drive->atapi_flags |= IDE_AFLAG_CLIK_DRIVE;
594 /* IOMEGA Clik! drives do not support lock/unlock commands */ 539 /* IOMEGA Clik! drives do not support lock/unlock commands */
595 drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; 540 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
596 } 541 }
597 542
598 (void) ide_floppy_get_capacity(drive); 543 (void) ide_floppy_get_capacity(drive);
599 544
600 ide_proc_register_driver(drive, floppy->driver); 545 ide_proc_register_driver(drive, floppy->driver);
601}
602 546
603static void ide_floppy_remove(ide_drive_t *drive) 547 drive->dev_flags |= IDE_DFLAG_ATTACH;
604{
605 idefloppy_floppy_t *floppy = drive->driver_data;
606 struct gendisk *g = floppy->disk;
607
608 ide_proc_unregister_driver(drive, floppy->driver);
609
610 del_gendisk(g);
611
612 ide_floppy_put(floppy);
613} 548}
614 549
615static void idefloppy_cleanup_obj(struct kref *kref) 550static void ide_floppy_flush(ide_drive_t *drive)
616{ 551{
617 struct ide_floppy_obj *floppy = to_ide_drv(kref, ide_floppy_obj);
618 ide_drive_t *drive = floppy->drive;
619 struct gendisk *g = floppy->disk;
620
621 drive->driver_data = NULL;
622 g->private_data = NULL;
623 put_disk(g);
624 kfree(floppy);
625} 552}
626 553
627static int ide_floppy_probe(ide_drive_t *); 554static int ide_floppy_init_media(ide_drive_t *drive, struct gendisk *disk)
628
629static ide_driver_t idefloppy_driver = {
630 .gen_driver = {
631 .owner = THIS_MODULE,
632 .name = "ide-floppy",
633 .bus = &ide_bus_type,
634 },
635 .probe = ide_floppy_probe,
636 .remove = ide_floppy_remove,
637 .version = IDEFLOPPY_VERSION,
638 .do_request = idefloppy_do_request,
639 .end_request = idefloppy_end_request,
640 .error = __ide_error,
641#ifdef CONFIG_IDE_PROC_FS
642 .proc = ide_floppy_proc,
643 .settings = ide_floppy_settings,
644#endif
645};
646
647static int idefloppy_open(struct inode *inode, struct file *filp)
648{ 555{
649 struct gendisk *disk = inode->i_bdev->bd_disk;
650 struct ide_floppy_obj *floppy;
651 ide_drive_t *drive;
652 int ret = 0; 556 int ret = 0;
653 557
654 floppy = ide_floppy_get(disk); 558 if (ide_do_test_unit_ready(drive, disk))
655 if (!floppy) 559 ide_do_start_stop(drive, disk, 1);
656 return -ENXIO;
657
658 drive = floppy->drive;
659
660 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
661
662 floppy->openers++;
663
664 if (floppy->openers == 1) {
665 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS;
666 /* Just in case */
667
668 if (ide_do_test_unit_ready(drive, disk))
669 ide_do_start_stop(drive, disk, 1);
670
671 if (ide_floppy_get_capacity(drive)
672 && (filp->f_flags & O_NDELAY) == 0
673 /*
674 * Allow O_NDELAY to open a drive without a disk, or with an
675 * unreadable disk, so that we can get the format capacity
676 * of the drive or begin the format - Sam
677 */
678 ) {
679 ret = -EIO;
680 goto out_put_floppy;
681 }
682
683 if ((drive->atapi_flags & IDE_AFLAG_WP) && (filp->f_mode & 2)) {
684 ret = -EROFS;
685 goto out_put_floppy;
686 }
687
688 drive->atapi_flags |= IDE_AFLAG_MEDIA_CHANGED;
689 ide_set_media_lock(drive, disk, 1);
690 check_disk_change(inode->i_bdev);
691 } else if (drive->atapi_flags & IDE_AFLAG_FORMAT_IN_PROGRESS) {
692 ret = -EBUSY;
693 goto out_put_floppy;
694 }
695 return 0;
696
697out_put_floppy:
698 floppy->openers--;
699 ide_floppy_put(floppy);
700 return ret;
701}
702
703static int idefloppy_release(struct inode *inode, struct file *filp)
704{
705 struct gendisk *disk = inode->i_bdev->bd_disk;
706 struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj);
707 ide_drive_t *drive = floppy->drive;
708
709 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
710
711 if (floppy->openers == 1) {
712 ide_set_media_lock(drive, disk, 0);
713 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS;
714 }
715
716 floppy->openers--;
717
718 ide_floppy_put(floppy);
719
720 return 0;
721}
722
723static int idefloppy_getgeo(struct block_device *bdev, struct hd_geometry *geo)
724{
725 struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk,
726 ide_floppy_obj);
727 ide_drive_t *drive = floppy->drive;
728 560
729 geo->heads = drive->bios_head; 561 ret = ide_floppy_get_capacity(drive);
730 geo->sectors = drive->bios_sect;
731 geo->cylinders = (u16)drive->bios_cyl; /* truncate */
732 return 0;
733}
734 562
735static int idefloppy_media_changed(struct gendisk *disk) 563 set_capacity(disk, ide_gd_capacity(drive));
736{
737 struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj);
738 ide_drive_t *drive = floppy->drive;
739 int ret;
740 564
741 /* do not scan partitions twice if this is a removable device */
742 if (drive->dev_flags & IDE_DFLAG_ATTACH) {
743 drive->dev_flags &= ~IDE_DFLAG_ATTACH;
744 return 0;
745 }
746 ret = !!(drive->atapi_flags & IDE_AFLAG_MEDIA_CHANGED);
747 drive->atapi_flags &= ~IDE_AFLAG_MEDIA_CHANGED;
748 return ret; 565 return ret;
749} 566}
750 567
751static int idefloppy_revalidate_disk(struct gendisk *disk) 568const struct ide_disk_ops ide_atapi_disk_ops = {
752{ 569 .check = ide_check_atapi_device,
753 struct ide_floppy_obj *floppy = ide_drv_g(disk, ide_floppy_obj); 570 .get_capacity = ide_floppy_get_capacity,
754 set_capacity(disk, ide_floppy_capacity(floppy->drive)); 571 .setup = ide_floppy_setup,
755 return 0; 572 .flush = ide_floppy_flush,
756} 573 .init_media = ide_floppy_init_media,
757 574 .set_doorlock = ide_set_media_lock,
758static struct block_device_operations idefloppy_ops = { 575 .do_request = ide_floppy_do_request,
759 .owner = THIS_MODULE, 576 .end_request = ide_floppy_end_request,
760 .open = idefloppy_open, 577 .ioctl = ide_floppy_ioctl,
761 .release = idefloppy_release,
762 .ioctl = ide_floppy_ioctl,
763 .getgeo = idefloppy_getgeo,
764 .media_changed = idefloppy_media_changed,
765 .revalidate_disk = idefloppy_revalidate_disk
766}; 578};
767
768static int ide_floppy_probe(ide_drive_t *drive)
769{
770 idefloppy_floppy_t *floppy;
771 struct gendisk *g;
772
773 if (!strstr("ide-floppy", drive->driver_req))
774 goto failed;
775
776 if (drive->media != ide_floppy)
777 goto failed;
778
779 if (!ide_check_atapi_device(drive, DRV_NAME)) {
780 printk(KERN_ERR PFX "%s: not supported by this version of "
781 DRV_NAME "\n", drive->name);
782 goto failed;
783 }
784 floppy = kzalloc(sizeof(idefloppy_floppy_t), GFP_KERNEL);
785 if (!floppy) {
786 printk(KERN_ERR PFX "%s: Can't allocate a floppy structure\n",
787 drive->name);
788 goto failed;
789 }
790
791 g = alloc_disk(1 << PARTN_BITS);
792 if (!g)
793 goto out_free_floppy;
794
795 ide_init_disk(g, drive);
796
797 kref_init(&floppy->kref);
798
799 floppy->drive = drive;
800 floppy->driver = &idefloppy_driver;
801 floppy->disk = g;
802
803 g->private_data = &floppy->driver;
804
805 drive->driver_data = floppy;
806
807 drive->debug_mask = debug_mask;
808
809 idefloppy_setup(drive, floppy);
810 drive->dev_flags |= IDE_DFLAG_ATTACH;
811
812 g->minors = 1 << PARTN_BITS;
813 g->driverfs_dev = &drive->gendev;
814 if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
815 g->flags = GENHD_FL_REMOVABLE;
816 g->fops = &idefloppy_ops;
817 add_disk(g);
818 return 0;
819
820out_free_floppy:
821 kfree(floppy);
822failed:
823 return -ENODEV;
824}
825
826static void __exit idefloppy_exit(void)
827{
828 driver_unregister(&idefloppy_driver.gen_driver);
829}
830
831static int __init idefloppy_init(void)
832{
833 printk(KERN_INFO DRV_NAME " driver " IDEFLOPPY_VERSION "\n");
834 return driver_register(&idefloppy_driver.gen_driver);
835}
836
837MODULE_ALIAS("ide:*m-floppy*");
838MODULE_ALIAS("ide-floppy");
839module_init(idefloppy_init);
840module_exit(idefloppy_exit);
841MODULE_LICENSE("GPL");
842MODULE_DESCRIPTION("ATAPI FLOPPY Driver");
843
diff --git a/drivers/ide/ide-floppy.h b/drivers/ide/ide-floppy.h
index 17cf865e583d..c17124dd6079 100644
--- a/drivers/ide/ide-floppy.h
+++ b/drivers/ide/ide-floppy.h
@@ -1,37 +1,9 @@
1#ifndef __IDE_FLOPPY_H 1#ifndef __IDE_FLOPPY_H
2#define __IDE_FLOPPY_H 2#define __IDE_FLOPPY_H
3 3
4/* 4#include "ide-gd.h"
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 */
9typedef 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 /* Last failed packet command */
17 struct ide_atapi_pc *failed_pc;
18 /* used for blk_{fs,pc}_request() requests */
19 struct ide_atapi_pc queued_pc;
20
21 /* Last error information */
22 u8 sense_key, asc, ascq;
23
24 int progress_indication;
25
26 /* Device information */
27 /* Current format */
28 int blocks, block_size, bs_factor;
29 /* Last format capacity descriptor */
30 u8 cap_desc[8];
31 /* Copy of the flexible disk page */
32 u8 flexible_disk_page[32];
33} idefloppy_floppy_t;
34 5
6#ifdef CONFIG_IDE_GD_ATAPI
35/* 7/*
36 * Pages of the SELECT SENSE / MODE SENSE packet commands. 8 * Pages of the SELECT SENSE / MODE SENSE packet commands.
37 * See SFF-8070i spec. 9 * See SFF-8070i spec.
@@ -46,17 +18,22 @@ typedef struct ide_floppy_obj {
46#define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603 18#define IDEFLOPPY_IOCTL_FORMAT_GET_PROGRESS 0x4603
47 19
48/* ide-floppy.c */ 20/* ide-floppy.c */
21extern const struct ide_disk_ops ide_atapi_disk_ops;
49void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8); 22void ide_floppy_create_mode_sense_cmd(struct ide_atapi_pc *, u8);
50void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *); 23void ide_floppy_create_read_capacity_cmd(struct ide_atapi_pc *);
51sector_t ide_floppy_capacity(ide_drive_t *);
52 24
53/* ide-floppy_ioctl.c */ 25/* ide-floppy_ioctl.c */
54int ide_floppy_ioctl(struct inode *, struct file *, unsigned, unsigned long); 26int ide_floppy_ioctl(ide_drive_t *, struct inode *, struct file *, unsigned int,
27 unsigned long);
55 28
56#ifdef CONFIG_IDE_PROC_FS 29#ifdef CONFIG_IDE_PROC_FS
57/* ide-floppy_proc.c */ 30/* ide-floppy_proc.c */
58extern ide_proc_entry_t ide_floppy_proc[]; 31extern ide_proc_entry_t ide_floppy_proc[];
59extern const struct ide_proc_devset ide_floppy_settings[]; 32extern const struct ide_proc_devset ide_floppy_settings[];
60#endif 33#endif
34#else
35#define ide_floppy_proc NULL
36#define ide_floppy_settings NULL
37#endif
61 38
62#endif /*__IDE_FLOPPY_H */ 39#endif /*__IDE_FLOPPY_H */
diff --git a/drivers/ide/ide-floppy_ioctl.c b/drivers/ide/ide-floppy_ioctl.c
index a3a7a0809e2b..409e4c15f9b7 100644
--- a/drivers/ide/ide-floppy_ioctl.c
+++ b/drivers/ide/ide-floppy_ioctl.c
@@ -33,7 +33,7 @@
33 33
34static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg) 34static int ide_floppy_get_format_capacities(ide_drive_t *drive, int __user *arg)
35{ 35{
36 struct ide_floppy_obj *floppy = drive->driver_data; 36 struct ide_disk_obj *floppy = drive->driver_data;
37 struct ide_atapi_pc pc; 37 struct ide_atapi_pc pc;
38 u8 header_len, desc_cnt; 38 u8 header_len, desc_cnt;
39 int i, blocks, length, u_array_size, u_index; 39 int i, blocks, length, u_array_size, u_index;
@@ -113,7 +113,7 @@ static void ide_floppy_create_format_unit_cmd(struct ide_atapi_pc *pc, int b,
113 113
114static int ide_floppy_get_sfrp_bit(ide_drive_t *drive) 114static int ide_floppy_get_sfrp_bit(ide_drive_t *drive)
115{ 115{
116 idefloppy_floppy_t *floppy = drive->driver_data; 116 struct ide_disk_obj *floppy = drive->driver_data;
117 struct ide_atapi_pc pc; 117 struct ide_atapi_pc pc;
118 118
119 drive->atapi_flags &= ~IDE_AFLAG_SRFP; 119 drive->atapi_flags &= ~IDE_AFLAG_SRFP;
@@ -132,17 +132,17 @@ static int ide_floppy_get_sfrp_bit(ide_drive_t *drive)
132 132
133static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg) 133static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg)
134{ 134{
135 idefloppy_floppy_t *floppy = drive->driver_data; 135 struct ide_disk_obj *floppy = drive->driver_data;
136 struct ide_atapi_pc pc; 136 struct ide_atapi_pc pc;
137 int blocks, length, flags, err = 0; 137 int blocks, length, flags, err = 0;
138 138
139 if (floppy->openers > 1) { 139 if (floppy->openers > 1) {
140 /* Don't format if someone is using the disk */ 140 /* Don't format if someone is using the disk */
141 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; 141 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS;
142 return -EBUSY; 142 return -EBUSY;
143 } 143 }
144 144
145 drive->atapi_flags |= IDE_AFLAG_FORMAT_IN_PROGRESS; 145 drive->dev_flags |= IDE_DFLAG_FORMAT_IN_PROGRESS;
146 146
147 /* 147 /*
148 * Send ATAPI_FORMAT_UNIT to the drive. 148 * Send ATAPI_FORMAT_UNIT to the drive.
@@ -174,7 +174,7 @@ static int ide_floppy_format_unit(ide_drive_t *drive, int __user *arg)
174 174
175out: 175out:
176 if (err) 176 if (err)
177 drive->atapi_flags &= ~IDE_AFLAG_FORMAT_IN_PROGRESS; 177 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS;
178 return err; 178 return err;
179} 179}
180 180
@@ -190,7 +190,7 @@ out:
190 190
191static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg) 191static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg)
192{ 192{
193 idefloppy_floppy_t *floppy = drive->driver_data; 193 struct ide_disk_obj *floppy = drive->driver_data;
194 struct ide_atapi_pc pc; 194 struct ide_atapi_pc pc;
195 int progress_indication = 0x10000; 195 int progress_indication = 0x10000;
196 196
@@ -226,7 +226,7 @@ static int ide_floppy_get_format_progress(ide_drive_t *drive, int __user *arg)
226static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc, 226static int ide_floppy_lockdoor(ide_drive_t *drive, struct ide_atapi_pc *pc,
227 unsigned long arg, unsigned int cmd) 227 unsigned long arg, unsigned int cmd)
228{ 228{
229 idefloppy_floppy_t *floppy = drive->driver_data; 229 struct ide_disk_obj *floppy = drive->driver_data;
230 struct gendisk *disk = floppy->disk; 230 struct gendisk *disk = floppy->disk;
231 int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0; 231 int prevent = (arg && cmd != CDROMEJECT) ? 1 : 0;
232 232
@@ -260,13 +260,10 @@ static int ide_floppy_format_ioctl(ide_drive_t *drive, struct file *file,
260 } 260 }
261} 261}
262 262
263int ide_floppy_ioctl(struct inode *inode, struct file *file, 263int ide_floppy_ioctl(ide_drive_t *drive, struct inode *inode,
264 unsigned int cmd, unsigned long arg) 264 struct file *file, unsigned int cmd, unsigned long arg)
265{ 265{
266 struct block_device *bdev = inode->i_bdev; 266 struct block_device *bdev = inode->i_bdev;
267 struct ide_floppy_obj *floppy = ide_drv_g(bdev->bd_disk,
268 ide_floppy_obj);
269 ide_drive_t *drive = floppy->drive;
270 struct ide_atapi_pc pc; 267 struct ide_atapi_pc pc;
271 void __user *argp = (void __user *)arg; 268 void __user *argp = (void __user *)arg;
272 int err; 269 int err;
diff --git a/drivers/ide/ide-floppy_proc.c b/drivers/ide/ide-floppy_proc.c
index 76f0c6c4eca3..3ec762cb60ab 100644
--- a/drivers/ide/ide-floppy_proc.c
+++ b/drivers/ide/ide-floppy_proc.c
@@ -9,7 +9,7 @@ static int proc_idefloppy_read_capacity(char *page, char **start, off_t off,
9 ide_drive_t*drive = (ide_drive_t *)data; 9 ide_drive_t*drive = (ide_drive_t *)data;
10 int len; 10 int len;
11 11
12 len = sprintf(page, "%llu\n", (long long)ide_floppy_capacity(drive)); 12 len = sprintf(page, "%llu\n", (long long)ide_gd_capacity(drive));
13 PROC_IDE_READ_RETURN(page, start, off, count, eof, len); 13 PROC_IDE_READ_RETURN(page, start, off, count, eof, len);
14} 14}
15 15
diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
new file mode 100644
index 000000000000..d44898f46c33
--- /dev/null
+++ b/drivers/ide/ide-gd.c
@@ -0,0 +1,398 @@
1#include <linux/module.h>
2#include <linux/types.h>
3#include <linux/string.h>
4#include <linux/kernel.h>
5#include <linux/errno.h>
6#include <linux/genhd.h>
7#include <linux/mutex.h>
8#include <linux/ide.h>
9#include <linux/hdreg.h>
10
11#if !defined(CONFIG_DEBUG_BLOCK_EXT_DEVT)
12#define IDE_DISK_MINORS (1 << PARTN_BITS)
13#else
14#define IDE_DISK_MINORS 0
15#endif
16
17#include "ide-disk.h"
18#include "ide-floppy.h"
19
20#define IDE_GD_VERSION "1.18"
21
22/* module parameters */
23static unsigned long debug_mask;
24module_param(debug_mask, ulong, 0644);
25
26static DEFINE_MUTEX(ide_disk_ref_mutex);
27
28static void ide_disk_release(struct kref *);
29
30static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
31{
32 struct ide_disk_obj *idkp = NULL;
33
34 mutex_lock(&ide_disk_ref_mutex);
35 idkp = ide_drv_g(disk, ide_disk_obj);
36 if (idkp) {
37 if (ide_device_get(idkp->drive))
38 idkp = NULL;
39 else
40 kref_get(&idkp->kref);
41 }
42 mutex_unlock(&ide_disk_ref_mutex);
43 return idkp;
44}
45
46static void ide_disk_put(struct ide_disk_obj *idkp)
47{
48 ide_drive_t *drive = idkp->drive;
49
50 mutex_lock(&ide_disk_ref_mutex);
51 kref_put(&idkp->kref, ide_disk_release);
52 ide_device_put(drive);
53 mutex_unlock(&ide_disk_ref_mutex);
54}
55
56sector_t ide_gd_capacity(ide_drive_t *drive)
57{
58 return drive->capacity64;
59}
60
61static int ide_gd_probe(ide_drive_t *);
62
63static void ide_gd_remove(ide_drive_t *drive)
64{
65 struct ide_disk_obj *idkp = drive->driver_data;
66 struct gendisk *g = idkp->disk;
67
68 ide_proc_unregister_driver(drive, idkp->driver);
69
70 del_gendisk(g);
71
72 drive->disk_ops->flush(drive);
73
74 ide_disk_put(idkp);
75}
76
77static void ide_disk_release(struct kref *kref)
78{
79 struct ide_disk_obj *idkp = to_ide_drv(kref, ide_disk_obj);
80 ide_drive_t *drive = idkp->drive;
81 struct gendisk *g = idkp->disk;
82
83 drive->disk_ops = NULL;
84 drive->driver_data = NULL;
85 g->private_data = NULL;
86 put_disk(g);
87 kfree(idkp);
88}
89
90/*
91 * On HPA drives the capacity needs to be
92 * reinitilized on resume otherwise the disk
93 * can not be used and a hard reset is required
94 */
95static void ide_gd_resume(ide_drive_t *drive)
96{
97 if (ata_id_hpa_enabled(drive->id))
98 (void)drive->disk_ops->get_capacity(drive);
99}
100
101static void ide_gd_shutdown(ide_drive_t *drive)
102{
103#ifdef CONFIG_ALPHA
104 /* On Alpha, halt(8) doesn't actually turn the machine off,
105 it puts you into the sort of firmware monitor. Typically,
106 it's used to boot another kernel image, so it's not much
107 different from reboot(8). Therefore, we don't need to
108 spin down the disk in this case, especially since Alpha
109 firmware doesn't handle disks in standby mode properly.
110 On the other hand, it's reasonably safe to turn the power
111 off when the shutdown process reaches the firmware prompt,
112 as the firmware initialization takes rather long time -
113 at least 10 seconds, which should be sufficient for
114 the disk to expire its write cache. */
115 if (system_state != SYSTEM_POWER_OFF) {
116#else
117 if (system_state == SYSTEM_RESTART) {
118#endif
119 drive->disk_ops->flush(drive);
120 return;
121 }
122
123 printk(KERN_INFO "Shutdown: %s\n", drive->name);
124
125 drive->gendev.bus->suspend(&drive->gendev, PMSG_SUSPEND);
126}
127
128#ifdef CONFIG_IDE_PROC_FS
129static ide_proc_entry_t *ide_disk_proc_entries(ide_drive_t *drive)
130{
131 return (drive->media == ide_disk) ? ide_disk_proc : ide_floppy_proc;
132}
133
134static const struct ide_proc_devset *ide_disk_proc_devsets(ide_drive_t *drive)
135{
136 return (drive->media == ide_disk) ? ide_disk_settings
137 : ide_floppy_settings;
138}
139#endif
140
141static ide_startstop_t ide_gd_do_request(ide_drive_t *drive,
142 struct request *rq, sector_t sector)
143{
144 return drive->disk_ops->do_request(drive, rq, sector);
145}
146
147static int ide_gd_end_request(ide_drive_t *drive, int uptodate, int nrsecs)
148{
149 return drive->disk_ops->end_request(drive, uptodate, nrsecs);
150}
151
152static ide_driver_t ide_gd_driver = {
153 .gen_driver = {
154 .owner = THIS_MODULE,
155 .name = "ide-gd",
156 .bus = &ide_bus_type,
157 },
158 .probe = ide_gd_probe,
159 .remove = ide_gd_remove,
160 .resume = ide_gd_resume,
161 .shutdown = ide_gd_shutdown,
162 .version = IDE_GD_VERSION,
163 .do_request = ide_gd_do_request,
164 .end_request = ide_gd_end_request,
165 .error = __ide_error,
166#ifdef CONFIG_IDE_PROC_FS
167 .proc_entries = ide_disk_proc_entries,
168 .proc_devsets = ide_disk_proc_devsets,
169#endif
170};
171
172static int ide_gd_open(struct inode *inode, struct file *filp)
173{
174 struct gendisk *disk = inode->i_bdev->bd_disk;
175 struct ide_disk_obj *idkp;
176 ide_drive_t *drive;
177 int ret = 0;
178
179 idkp = ide_disk_get(disk);
180 if (idkp == NULL)
181 return -ENXIO;
182
183 drive = idkp->drive;
184
185 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
186
187 idkp->openers++;
188
189 if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) {
190 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS;
191 /* Just in case */
192
193 ret = drive->disk_ops->init_media(drive, disk);
194
195 /*
196 * Allow O_NDELAY to open a drive without a disk, or with an
197 * unreadable disk, so that we can get the format capacity
198 * of the drive or begin the format - Sam
199 */
200 if (ret && (filp->f_flags & O_NDELAY) == 0) {
201 ret = -EIO;
202 goto out_put_idkp;
203 }
204
205 if ((drive->dev_flags & IDE_DFLAG_WP) && (filp->f_mode & 2)) {
206 ret = -EROFS;
207 goto out_put_idkp;
208 }
209
210 /*
211 * Ignore the return code from door_lock,
212 * since the open() has already succeeded,
213 * and the door_lock is irrelevant at this point.
214 */
215 drive->disk_ops->set_doorlock(drive, disk, 1);
216 drive->dev_flags |= IDE_DFLAG_MEDIA_CHANGED;
217 check_disk_change(inode->i_bdev);
218 } else if (drive->dev_flags & IDE_DFLAG_FORMAT_IN_PROGRESS) {
219 ret = -EBUSY;
220 goto out_put_idkp;
221 }
222 return 0;
223
224out_put_idkp:
225 idkp->openers--;
226 ide_disk_put(idkp);
227 return ret;
228}
229
230static int ide_gd_release(struct inode *inode, struct file *filp)
231{
232 struct gendisk *disk = inode->i_bdev->bd_disk;
233 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
234 ide_drive_t *drive = idkp->drive;
235
236 ide_debug_log(IDE_DBG_FUNC, "Call %s\n", __func__);
237
238 if (idkp->openers == 1)
239 drive->disk_ops->flush(drive);
240
241 if ((drive->dev_flags & IDE_DFLAG_REMOVABLE) && idkp->openers == 1) {
242 drive->disk_ops->set_doorlock(drive, disk, 0);
243 drive->dev_flags &= ~IDE_DFLAG_FORMAT_IN_PROGRESS;
244 }
245
246 idkp->openers--;
247
248 ide_disk_put(idkp);
249
250 return 0;
251}
252
253static int ide_gd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
254{
255 struct ide_disk_obj *idkp = ide_drv_g(bdev->bd_disk, ide_disk_obj);
256 ide_drive_t *drive = idkp->drive;
257
258 geo->heads = drive->bios_head;
259 geo->sectors = drive->bios_sect;
260 geo->cylinders = (u16)drive->bios_cyl; /* truncate */
261 return 0;
262}
263
264static int ide_gd_media_changed(struct gendisk *disk)
265{
266 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
267 ide_drive_t *drive = idkp->drive;
268 int ret;
269
270 /* do not scan partitions twice if this is a removable device */
271 if (drive->dev_flags & IDE_DFLAG_ATTACH) {
272 drive->dev_flags &= ~IDE_DFLAG_ATTACH;
273 return 0;
274 }
275
276 ret = !!(drive->dev_flags & IDE_DFLAG_MEDIA_CHANGED);
277 drive->dev_flags &= ~IDE_DFLAG_MEDIA_CHANGED;
278
279 return ret;
280}
281
282static int ide_gd_revalidate_disk(struct gendisk *disk)
283{
284 struct ide_disk_obj *idkp = ide_drv_g(disk, ide_disk_obj);
285 set_capacity(disk, ide_gd_capacity(idkp->drive));
286 return 0;
287}
288
289static int ide_gd_ioctl(struct inode *inode, struct file *file,
290 unsigned int cmd, unsigned long arg)
291{
292 struct block_device *bdev = inode->i_bdev;
293 struct ide_disk_obj *idkp = ide_drv_g(bdev->bd_disk, ide_disk_obj);
294 ide_drive_t *drive = idkp->drive;
295
296 return drive->disk_ops->ioctl(drive, inode, file, cmd, arg);
297}
298
299static struct block_device_operations ide_gd_ops = {
300 .owner = THIS_MODULE,
301 .open = ide_gd_open,
302 .release = ide_gd_release,
303 .ioctl = ide_gd_ioctl,
304 .getgeo = ide_gd_getgeo,
305 .media_changed = ide_gd_media_changed,
306 .revalidate_disk = ide_gd_revalidate_disk
307};
308
309static int ide_gd_probe(ide_drive_t *drive)
310{
311 const struct ide_disk_ops *disk_ops = NULL;
312 struct ide_disk_obj *idkp;
313 struct gendisk *g;
314
315 /* strstr("foo", "") is non-NULL */
316 if (!strstr("ide-gd", drive->driver_req))
317 goto failed;
318
319#ifdef CONFIG_IDE_GD_ATA
320 if (drive->media == ide_disk)
321 disk_ops = &ide_ata_disk_ops;
322#endif
323#ifdef CONFIG_IDE_GD_ATAPI
324 if (drive->media == ide_floppy)
325 disk_ops = &ide_atapi_disk_ops;
326#endif
327 if (disk_ops == NULL)
328 goto failed;
329
330 if (disk_ops->check(drive, DRV_NAME) == 0) {
331 printk(KERN_ERR PFX "%s: not supported by this driver\n",
332 drive->name);
333 goto failed;
334 }
335
336 idkp = kzalloc(sizeof(*idkp), GFP_KERNEL);
337 if (!idkp) {
338 printk(KERN_ERR PFX "%s: can't allocate a disk structure\n",
339 drive->name);
340 goto failed;
341 }
342
343 g = alloc_disk_node(IDE_DISK_MINORS, hwif_to_node(drive->hwif));
344 if (!g)
345 goto out_free_idkp;
346
347 ide_init_disk(g, drive);
348
349 kref_init(&idkp->kref);
350
351 idkp->drive = drive;
352 idkp->driver = &ide_gd_driver;
353 idkp->disk = g;
354
355 g->private_data = &idkp->driver;
356
357 drive->driver_data = idkp;
358 drive->debug_mask = debug_mask;
359 drive->disk_ops = disk_ops;
360
361 disk_ops->setup(drive);
362
363 set_capacity(g, ide_gd_capacity(drive));
364
365 g->minors = IDE_DISK_MINORS;
366 g->driverfs_dev = &drive->gendev;
367 g->flags |= GENHD_FL_EXT_DEVT;
368 if (drive->dev_flags & IDE_DFLAG_REMOVABLE)
369 g->flags = GENHD_FL_REMOVABLE;
370 g->fops = &ide_gd_ops;
371 add_disk(g);
372 return 0;
373
374out_free_idkp:
375 kfree(idkp);
376failed:
377 return -ENODEV;
378}
379
380static int __init ide_gd_init(void)
381{
382 printk(KERN_INFO DRV_NAME " driver " IDE_GD_VERSION "\n");
383 return driver_register(&ide_gd_driver.gen_driver);
384}
385
386static void __exit ide_gd_exit(void)
387{
388 driver_unregister(&ide_gd_driver.gen_driver);
389}
390
391MODULE_ALIAS("ide:*m-disk*");
392MODULE_ALIAS("ide-disk");
393MODULE_ALIAS("ide:*m-floppy*");
394MODULE_ALIAS("ide-floppy");
395module_init(ide_gd_init);
396module_exit(ide_gd_exit);
397MODULE_LICENSE("GPL");
398MODULE_DESCRIPTION("generic ATA/ATAPI disk driver");
diff --git a/drivers/ide/ide-gd.h b/drivers/ide/ide-gd.h
new file mode 100644
index 000000000000..7d3d101713e0
--- /dev/null
+++ b/drivers/ide/ide-gd.h
@@ -0,0 +1,44 @@
1#ifndef __IDE_GD_H
2#define __IDE_GD_H
3
4#define DRV_NAME "ide-gd"
5#define PFX DRV_NAME ": "
6
7/* define to see debug info */
8#define IDE_GD_DEBUG_LOG 0
9
10#if IDE_GD_DEBUG_LOG
11#define ide_debug_log(lvl, fmt, args...) __ide_debug_log(lvl, fmt, args)
12#else
13#define ide_debug_log(lvl, fmt, args...) do {} while (0)
14#endif
15
16struct ide_disk_obj {
17 ide_drive_t *drive;
18 ide_driver_t *driver;
19 struct gendisk *disk;
20 struct kref kref;
21 unsigned int openers; /* protected by BKL for now */
22
23 /* Last failed packet command */
24 struct ide_atapi_pc *failed_pc;
25 /* used for blk_{fs,pc}_request() requests */
26 struct ide_atapi_pc queued_pc;
27
28 /* Last error information */
29 u8 sense_key, asc, ascq;
30
31 int progress_indication;
32
33 /* Device information */
34 /* Current format */
35 int blocks, block_size, bs_factor;
36 /* Last format capacity descriptor */
37 u8 cap_desc[8];
38 /* Copy of the flexible disk page */
39 u8 flexible_disk_page[32];
40};
41
42sector_t ide_gd_capacity(ide_drive_t *);
43
44#endif /* __IDE_GD_H */
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index b762deb2dacb..bb7a1ed8094e 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -755,7 +755,7 @@ int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
755 755
756 udelay(1); 756 udelay(1);
757 SELECT_DRIVE(drive); 757 SELECT_DRIVE(drive);
758 SELECT_MASK(drive, 0); 758 SELECT_MASK(drive, 1);
759 udelay(1); 759 udelay(1);
760 tp_ops->set_irq(hwif, 0); 760 tp_ops->set_irq(hwif, 0);
761 761
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 19f8c7770a25..1649ea54f76c 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -208,6 +208,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
208 drive->ready_stat = 0; 208 drive->ready_stat = 0;
209 if (ata_id_cdb_intr(id)) 209 if (ata_id_cdb_intr(id))
210 drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT; 210 drive->atapi_flags |= IDE_AFLAG_DRQ_INTERRUPT;
211 drive->dev_flags |= IDE_DFLAG_DOORLOCKING;
211 /* we don't do head unloading on ATAPI devices */ 212 /* we don't do head unloading on ATAPI devices */
212 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD; 213 drive->dev_flags |= IDE_DFLAG_NO_UNLOAD;
213 return; 214 return;
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index b26926487cc0..c31d0dd7a532 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -567,10 +567,10 @@ static void ide_remove_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t
567void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) 567void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver)
568{ 568{
569 mutex_lock(&ide_setting_mtx); 569 mutex_lock(&ide_setting_mtx);
570 drive->settings = driver->settings; 570 drive->settings = driver->proc_devsets(drive);
571 mutex_unlock(&ide_setting_mtx); 571 mutex_unlock(&ide_setting_mtx);
572 572
573 ide_add_proc_entries(drive->proc, driver->proc, drive); 573 ide_add_proc_entries(drive->proc, driver->proc_entries(drive), drive);
574} 574}
575 575
576EXPORT_SYMBOL(ide_proc_register_driver); 576EXPORT_SYMBOL(ide_proc_register_driver);
@@ -591,7 +591,7 @@ void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver)
591{ 591{
592 unsigned long flags; 592 unsigned long flags;
593 593
594 ide_remove_proc_entries(drive->proc, driver->proc); 594 ide_remove_proc_entries(drive->proc, driver->proc_entries(drive));
595 595
596 mutex_lock(&ide_setting_mtx); 596 mutex_lock(&ide_setting_mtx);
597 spin_lock_irqsave(&ide_lock, flags); 597 spin_lock_irqsave(&ide_lock, flags);
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index d879c7797cde..b2b2e5e8d38e 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -2108,7 +2108,7 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive)
2108 2108
2109 /* device lacks locking support according to capabilities page */ 2109 /* device lacks locking support according to capabilities page */
2110 if ((caps[6] & 1) == 0) 2110 if ((caps[6] & 1) == 0)
2111 drive->atapi_flags |= IDE_AFLAG_NO_DOORLOCK; 2111 drive->dev_flags &= ~IDE_DFLAG_DOORLOCKING;
2112 2112
2113 if (caps[7] & 0x02) 2113 if (caps[7] & 0x02)
2114 tape->blk_size = 512; 2114 tape->blk_size = 512;
@@ -2298,6 +2298,16 @@ static ide_proc_entry_t idetape_proc[] = {
2298 { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL }, 2298 { "name", S_IFREG|S_IRUGO, proc_idetape_read_name, NULL },
2299 { NULL, 0, NULL, NULL } 2299 { NULL, 0, NULL, NULL }
2300}; 2300};
2301
2302static ide_proc_entry_t *ide_tape_proc_entries(ide_drive_t *drive)
2303{
2304 return idetape_proc;
2305}
2306
2307static const struct ide_proc_devset *ide_tape_proc_devsets(ide_drive_t *drive)
2308{
2309 return idetape_settings;
2310}
2301#endif 2311#endif
2302 2312
2303static int ide_tape_probe(ide_drive_t *); 2313static int ide_tape_probe(ide_drive_t *);
@@ -2315,8 +2325,8 @@ static ide_driver_t idetape_driver = {
2315 .end_request = idetape_end_request, 2325 .end_request = idetape_end_request,
2316 .error = __ide_error, 2326 .error = __ide_error,
2317#ifdef CONFIG_IDE_PROC_FS 2327#ifdef CONFIG_IDE_PROC_FS
2318 .proc = idetape_proc, 2328 .proc_entries = ide_tape_proc_entries,
2319 .settings = idetape_settings, 2329 .proc_devsets = ide_tape_proc_devsets,
2320#endif 2330#endif
2321}; 2331};
2322 2332
diff --git a/drivers/ide/pci/Makefile b/drivers/ide/pci/Makefile
index 02e6ee7d751d..ab44a1f5f5a9 100644
--- a/drivers/ide/pci/Makefile
+++ b/drivers/ide/pci/Makefile
@@ -11,7 +11,6 @@ obj-$(CONFIG_BLK_DEV_CS5535) += cs5535.o
11obj-$(CONFIG_BLK_DEV_SC1200) += sc1200.o 11obj-$(CONFIG_BLK_DEV_SC1200) += sc1200.o
12obj-$(CONFIG_BLK_DEV_CY82C693) += cy82c693.o 12obj-$(CONFIG_BLK_DEV_CY82C693) += cy82c693.o
13obj-$(CONFIG_BLK_DEV_DELKIN) += delkin_cb.o 13obj-$(CONFIG_BLK_DEV_DELKIN) += delkin_cb.o
14obj-$(CONFIG_BLK_DEV_HPT34X) += hpt34x.o
15obj-$(CONFIG_BLK_DEV_HPT366) += hpt366.o 14obj-$(CONFIG_BLK_DEV_HPT366) += hpt366.o
16obj-$(CONFIG_BLK_DEV_IT8213) += it8213.o 15obj-$(CONFIG_BLK_DEV_IT8213) += it8213.o
17obj-$(CONFIG_BLK_DEV_IT821X) += it821x.o 16obj-$(CONFIG_BLK_DEV_IT821X) += it821x.o
diff --git a/drivers/ide/pci/delkin_cb.c b/drivers/ide/pci/delkin_cb.c
index 8689a706f537..8f1b2d9f0513 100644
--- a/drivers/ide/pci/delkin_cb.c
+++ b/drivers/ide/pci/delkin_cb.c
@@ -46,10 +46,27 @@ static const struct ide_port_ops delkin_cb_port_ops = {
46 .quirkproc = ide_undecoded_slave, 46 .quirkproc = ide_undecoded_slave,
47}; 47};
48 48
49static unsigned int delkin_cb_init_chipset(struct pci_dev *dev)
50{
51 unsigned long base = pci_resource_start(dev, 0);
52 int i;
53
54 outb(0x02, base + 0x1e); /* set nIEN to block interrupts */
55 inb(base + 0x17); /* read status to clear interrupts */
56
57 for (i = 0; i < sizeof(setup); ++i) {
58 if (setup[i])
59 outb(setup[i], base + i);
60 }
61
62 return 0;
63}
64
49static const struct ide_port_info delkin_cb_port_info = { 65static const struct ide_port_info delkin_cb_port_info = {
50 .port_ops = &delkin_cb_port_ops, 66 .port_ops = &delkin_cb_port_ops,
51 .host_flags = IDE_HFLAG_IO_32BIT | IDE_HFLAG_UNMASK_IRQS | 67 .host_flags = IDE_HFLAG_IO_32BIT | IDE_HFLAG_UNMASK_IRQS |
52 IDE_HFLAG_NO_DMA, 68 IDE_HFLAG_NO_DMA,
69 .init_chipset = delkin_cb_init_chipset,
53}; 70};
54 71
55static int __devinit 72static int __devinit
@@ -57,7 +74,7 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
57{ 74{
58 struct ide_host *host; 75 struct ide_host *host;
59 unsigned long base; 76 unsigned long base;
60 int i, rc; 77 int rc;
61 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 78 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
62 79
63 rc = pci_enable_device(dev); 80 rc = pci_enable_device(dev);
@@ -72,12 +89,8 @@ delkin_cb_probe (struct pci_dev *dev, const struct pci_device_id *id)
72 return rc; 89 return rc;
73 } 90 }
74 base = pci_resource_start(dev, 0); 91 base = pci_resource_start(dev, 0);
75 outb(0x02, base + 0x1e); /* set nIEN to block interrupts */ 92
76 inb(base + 0x17); /* read status to clear interrupts */ 93 delkin_cb_init_chipset(dev);
77 for (i = 0; i < sizeof(setup); ++i) {
78 if (setup[i])
79 outb(setup[i], base + i);
80 }
81 94
82 memset(&hw, 0, sizeof(hw)); 95 memset(&hw, 0, sizeof(hw));
83 ide_std_init_ports(&hw, base + 0x10, base + 0x1e); 96 ide_std_init_ports(&hw, base + 0x10, base + 0x1e);
@@ -110,6 +123,40 @@ delkin_cb_remove (struct pci_dev *dev)
110 pci_disable_device(dev); 123 pci_disable_device(dev);
111} 124}
112 125
126#ifdef CONFIG_PM
127static int delkin_cb_suspend(struct pci_dev *dev, pm_message_t state)
128{
129 pci_save_state(dev);
130 pci_disable_device(dev);
131 pci_set_power_state(dev, pci_choose_state(dev, state));
132
133 return 0;
134}
135
136static int delkin_cb_resume(struct pci_dev *dev)
137{
138 struct ide_host *host = pci_get_drvdata(dev);
139 int rc;
140
141 pci_set_power_state(dev, PCI_D0);
142
143 rc = pci_enable_device(dev);
144 if (rc)
145 return rc;
146
147 pci_restore_state(dev);
148 pci_set_master(dev);
149
150 if (host->init_chipset)
151 host->init_chipset(dev);
152
153 return 0;
154}
155#else
156#define delkin_cb_suspend NULL
157#define delkin_cb_resume NULL
158#endif
159
113static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = { 160static struct pci_device_id delkin_cb_pci_tbl[] __devinitdata = {
114 { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 161 { 0x1145, 0xf021, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
115 { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 162 { 0x1145, 0xf024, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
@@ -122,6 +169,8 @@ static struct pci_driver delkin_cb_pci_driver = {
122 .id_table = delkin_cb_pci_tbl, 169 .id_table = delkin_cb_pci_tbl,
123 .probe = delkin_cb_probe, 170 .probe = delkin_cb_probe,
124 .remove = delkin_cb_remove, 171 .remove = delkin_cb_remove,
172 .suspend = delkin_cb_suspend,
173 .resume = delkin_cb_resume,
125}; 174};
126 175
127static int __init delkin_cb_init(void) 176static int __init delkin_cb_init(void)
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
deleted file mode 100644
index fb1a3aa57f07..000000000000
--- a/drivers/ide/pci/hpt34x.c
+++ /dev/null
@@ -1,193 +0,0 @@
1/*
2 * Copyright (C) 1998-2000 Andre Hedrick <andre@linux-ide.org>
3 *
4 * May be copied or modified under the terms of the GNU General Public License
5 *
6 *
7 * 00:12.0 Unknown mass storage controller:
8 * Triones Technologies, Inc.
9 * Unknown device 0003 (rev 01)
10 *
11 * hde: UDMA 2 (0x0000 0x0002) (0x0000 0x0010)
12 * hdf: UDMA 2 (0x0002 0x0012) (0x0010 0x0030)
13 * hde: DMA 2 (0x0000 0x0002) (0x0000 0x0010)
14 * hdf: DMA 2 (0x0002 0x0012) (0x0010 0x0030)
15 * hdg: DMA 1 (0x0012 0x0052) (0x0030 0x0070)
16 * hdh: DMA 1 (0x0052 0x0252) (0x0070 0x00f0)
17 *
18 * ide-pci.c reference
19 *
20 * Since there are two cards that report almost identically,
21 * the only discernable difference is the values reported in pcicmd.
22 * Booting-BIOS card or HPT363 :: pcicmd == 0x07
23 * Non-bootable card or HPT343 :: pcicmd == 0x05
24 */
25
26#include <linux/module.h>
27#include <linux/types.h>
28#include <linux/kernel.h>
29#include <linux/ioport.h>
30#include <linux/interrupt.h>
31#include <linux/pci.h>
32#include <linux/init.h>
33#include <linux/ide.h>
34
35#define DRV_NAME "hpt34x"
36
37#define HPT343_DEBUG_DRIVE_INFO 0
38
39static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed)
40{
41 struct pci_dev *dev = to_pci_dev(drive->hwif->dev);
42 u32 reg1= 0, tmp1 = 0, reg2 = 0, tmp2 = 0;
43 u8 hi_speed, lo_speed;
44
45 hi_speed = speed >> 4;
46 lo_speed = speed & 0x0f;
47
48 if (hi_speed & 7) {
49 hi_speed = (hi_speed & 4) ? 0x01 : 0x10;
50 } else {
51 lo_speed <<= 5;
52 lo_speed >>= 5;
53 }
54
55 pci_read_config_dword(dev, 0x44, &reg1);
56 pci_read_config_dword(dev, 0x48, &reg2);
57 tmp1 = ((lo_speed << (3*drive->dn)) | (reg1 & ~(7 << (3*drive->dn))));
58 tmp2 = ((hi_speed << drive->dn) | (reg2 & ~(0x11 << drive->dn)));
59 pci_write_config_dword(dev, 0x44, tmp1);
60 pci_write_config_dword(dev, 0x48, tmp2);
61
62#if HPT343_DEBUG_DRIVE_INFO
63 printk("%s: %s drive%d (0x%04x 0x%04x) (0x%04x 0x%04x)" \
64 " (0x%02x 0x%02x)\n",
65 drive->name, ide_xfer_verbose(speed),
66 drive->dn, reg1, tmp1, reg2, tmp2,
67 hi_speed, lo_speed);
68#endif /* HPT343_DEBUG_DRIVE_INFO */
69}
70
71static void hpt34x_set_pio_mode(ide_drive_t *drive, const u8 pio)
72{
73 hpt34x_set_mode(drive, XFER_PIO_0 + pio);
74}
75
76/*
77 * If the BIOS does not set the IO base addaress to XX00, 343 will fail.
78 */
79#define HPT34X_PCI_INIT_REG 0x80
80
81static unsigned int init_chipset_hpt34x(struct pci_dev *dev)
82{
83 int i = 0;
84 unsigned long hpt34xIoBase = pci_resource_start(dev, 4);
85 unsigned long hpt_addr[4] = { 0x20, 0x34, 0x28, 0x3c };
86 unsigned long hpt_addr_len[4] = { 7, 3, 7, 3 };
87 u16 cmd;
88 unsigned long flags;
89
90 local_irq_save(flags);
91
92 pci_write_config_byte(dev, HPT34X_PCI_INIT_REG, 0x00);
93 pci_read_config_word(dev, PCI_COMMAND, &cmd);
94
95 if (cmd & PCI_COMMAND_MEMORY)
96 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xF0);
97 else
98 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20);
99
100 /*
101 * Since 20-23 can be assigned and are R/W, we correct them.
102 */
103 pci_write_config_word(dev, PCI_COMMAND, cmd & ~PCI_COMMAND_IO);
104 for(i=0; i<4; i++) {
105 dev->resource[i].start = (hpt34xIoBase + hpt_addr[i]);
106 dev->resource[i].end = dev->resource[i].start + hpt_addr_len[i];
107 dev->resource[i].flags = IORESOURCE_IO;
108 pci_write_config_dword(dev,
109 (PCI_BASE_ADDRESS_0 + (i * 4)),
110 dev->resource[i].start);
111 }
112 pci_write_config_word(dev, PCI_COMMAND, cmd);
113
114 local_irq_restore(flags);
115
116 return dev->irq;
117}
118
119static const struct ide_port_ops hpt34x_port_ops = {
120 .set_pio_mode = hpt34x_set_pio_mode,
121 .set_dma_mode = hpt34x_set_mode,
122};
123
124#define IDE_HFLAGS_HPT34X \
125 (IDE_HFLAG_NO_ATAPI_DMA | \
126 IDE_HFLAG_NO_DSC | \
127 IDE_HFLAG_NO_AUTODMA)
128
129static const struct ide_port_info hpt34x_chipsets[] __devinitdata = {
130 { /* 0: HPT343 */
131 .name = DRV_NAME,
132 .init_chipset = init_chipset_hpt34x,
133 .port_ops = &hpt34x_port_ops,
134 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE,
135 .pio_mask = ATA_PIO5,
136 },
137 { /* 1: HPT345 */
138 .name = DRV_NAME,
139 .init_chipset = init_chipset_hpt34x,
140 .port_ops = &hpt34x_port_ops,
141 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD,
142 .pio_mask = ATA_PIO5,
143#ifdef CONFIG_HPT34X_AUTODMA
144 .swdma_mask = ATA_SWDMA2,
145 .mwdma_mask = ATA_MWDMA2,
146 .udma_mask = ATA_UDMA2,
147#endif
148 }
149};
150
151static int __devinit hpt34x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
152{
153 const struct ide_port_info *d;
154 u16 pcicmd = 0;
155
156 pci_read_config_word(dev, PCI_COMMAND, &pcicmd);
157
158 d = &hpt34x_chipsets[(pcicmd & PCI_COMMAND_MEMORY) ? 1 : 0];
159
160 return ide_pci_init_one(dev, d, NULL);
161}
162
163static const struct pci_device_id hpt34x_pci_tbl[] = {
164 { PCI_VDEVICE(TTI, PCI_DEVICE_ID_TTI_HPT343), 0 },
165 { 0, },
166};
167MODULE_DEVICE_TABLE(pci, hpt34x_pci_tbl);
168
169static struct pci_driver hpt34x_pci_driver = {
170 .name = "HPT34x_IDE",
171 .id_table = hpt34x_pci_tbl,
172 .probe = hpt34x_init_one,
173 .remove = ide_pci_remove,
174 .suspend = ide_pci_suspend,
175 .resume = ide_pci_resume,
176};
177
178static int __init hpt34x_ide_init(void)
179{
180 return ide_pci_register_driver(&hpt34x_pci_driver);
181}
182
183static void __exit hpt34x_ide_exit(void)
184{
185 pci_unregister_driver(&hpt34x_pci_driver);
186}
187
188module_init(hpt34x_ide_init);
189module_exit(hpt34x_ide_exit);
190
191MODULE_AUTHOR("Andre Hedrick");
192MODULE_DESCRIPTION("PCI driver module for Highpoint 34x IDE");
193MODULE_LICENSE("GPL");
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 9cf171cb9376..a7909e9c720e 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -3,7 +3,7 @@
3 * Portions Copyright (C) 2001 Sun Microsystems, Inc. 3 * Portions Copyright (C) 2001 Sun Microsystems, Inc.
4 * Portions Copyright (C) 2003 Red Hat Inc 4 * Portions Copyright (C) 2003 Red Hat Inc
5 * Portions Copyright (C) 2007 Bartlomiej Zolnierkiewicz 5 * Portions Copyright (C) 2007 Bartlomiej Zolnierkiewicz
6 * Portions Copyright (C) 2005-2007 MontaVista Software, Inc. 6 * Portions Copyright (C) 2005-2008 MontaVista Software, Inc.
7 * 7 *
8 * Thanks to HighPoint Technologies for their assistance, and hardware. 8 * Thanks to HighPoint Technologies for their assistance, and hardware.
9 * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his 9 * Special Thanks to Jon Burchmore in SanDiego for the deep pockets, his
@@ -748,26 +748,24 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
748 struct pci_dev *dev = to_pci_dev(hwif->dev); 748 struct pci_dev *dev = to_pci_dev(hwif->dev);
749 struct hpt_info *info = hpt3xx_get_info(hwif->dev); 749 struct hpt_info *info = hpt3xx_get_info(hwif->dev);
750 750
751 if (drive->quirk_list) { 751 if (drive->quirk_list == 0)
752 if (info->chip_type >= HPT370) { 752 return;
753 u8 scr1 = 0; 753
754 754 if (info->chip_type >= HPT370) {
755 pci_read_config_byte(dev, 0x5a, &scr1); 755 u8 scr1 = 0;
756 if (((scr1 & 0x10) >> 4) != mask) { 756
757 if (mask) 757 pci_read_config_byte(dev, 0x5a, &scr1);
758 scr1 |= 0x10; 758 if (((scr1 & 0x10) >> 4) != mask) {
759 else
760 scr1 &= ~0x10;
761 pci_write_config_byte(dev, 0x5a, scr1);
762 }
763 } else {
764 if (mask) 759 if (mask)
765 disable_irq(hwif->irq); 760 scr1 |= 0x10;
766 else 761 else
767 enable_irq (hwif->irq); 762 scr1 &= ~0x10;
763 pci_write_config_byte(dev, 0x5a, scr1);
768 } 764 }
769 } else 765 } else if (mask)
770 outb(ATA_DEVCTL_OBS | (mask ? 2 : 0), hwif->io_ports.ctl_addr); 766 disable_irq(hwif->irq);
767 else
768 enable_irq(hwif->irq);
771} 769}
772 770
773/* 771/*
@@ -1289,7 +1287,6 @@ static u8 hpt3xx_cable_detect(ide_hwif_t *hwif)
1289 1287
1290static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) 1288static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1291{ 1289{
1292 struct pci_dev *dev = to_pci_dev(hwif->dev);
1293 struct hpt_info *info = hpt3xx_get_info(hwif->dev); 1290 struct hpt_info *info = hpt3xx_get_info(hwif->dev);
1294 int serialize = HPT_SERIALIZE_IO; 1291 int serialize = HPT_SERIALIZE_IO;
1295 u8 chip_type = info->chip_type; 1292 u8 chip_type = info->chip_type;
diff --git a/drivers/ide/pci/scc_pata.c b/drivers/ide/pci/scc_pata.c
index 9ce1d8059921..49f163aa51e3 100644
--- a/drivers/ide/pci/scc_pata.c
+++ b/drivers/ide/pci/scc_pata.c
@@ -617,7 +617,6 @@ static int __devinit init_setup_scc(struct pci_dev *dev,
617 unsigned long intmask_port; 617 unsigned long intmask_port;
618 unsigned long mode_port; 618 unsigned long mode_port;
619 unsigned long ecmode_port; 619 unsigned long ecmode_port;
620 unsigned long dma_status_port;
621 u32 reg = 0; 620 u32 reg = 0;
622 struct scc_ports *ports; 621 struct scc_ports *ports;
623 int rc; 622 int rc;
@@ -637,7 +636,6 @@ static int __devinit init_setup_scc(struct pci_dev *dev,
637 intmask_port = dma_base + 0x010; 636 intmask_port = dma_base + 0x010;
638 mode_port = ctl_base + 0x024; 637 mode_port = ctl_base + 0x024;
639 ecmode_port = ctl_base + 0xf00; 638 ecmode_port = ctl_base + 0xf00;
640 dma_status_port = dma_base + 0x004;
641 639
642 /* controller initialization */ 640 /* controller initialization */
643 reg = 0; 641 reg = 0;
@@ -843,8 +841,6 @@ static u8 scc_cable_detect(ide_hwif_t *hwif)
843 841
844static void __devinit init_hwif_scc(ide_hwif_t *hwif) 842static void __devinit init_hwif_scc(ide_hwif_t *hwif)
845{ 843{
846 struct scc_ports *ports = ide_get_hwifdata(hwif);
847
848 /* PTERADD */ 844 /* PTERADD */
849 out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma); 845 out_be32((void __iomem *)(hwif->dma_base + 0x018), hwif->dmatable_dma);
850 846
diff --git a/drivers/ide/pci/sgiioc4.c b/drivers/ide/pci/sgiioc4.c
index dd634541ce36..8af9b23499fd 100644
--- a/drivers/ide/pci/sgiioc4.c
+++ b/drivers/ide/pci/sgiioc4.c
@@ -101,18 +101,8 @@ sgiioc4_init_hwif_ports(hw_regs_t * hw, unsigned long data_port,
101 for (i = 0; i <= 7; i++) 101 for (i = 0; i <= 7; i++)
102 hw->io_ports_array[i] = reg + i * 4; 102 hw->io_ports_array[i] = reg + i * 4;
103 103
104 if (ctrl_port) 104 hw->io_ports.ctl_addr = ctrl_port;
105 hw->io_ports.ctl_addr = ctrl_port; 105 hw->io_ports.irq_addr = irq_port;
106
107 if (irq_port)
108 hw->io_ports.irq_addr = irq_port;
109}
110
111static void
112sgiioc4_maskproc(ide_drive_t * drive, int mask)
113{
114 writeb(ATA_DEVCTL_OBS | (mask ? 2 : 0),
115 (void __iomem *)drive->hwif->io_ports.ctl_addr);
116} 106}
117 107
118static int 108static int
@@ -310,16 +300,14 @@ static u8 sgiioc4_read_status(ide_hwif_t *hwif)
310 unsigned long port = hwif->io_ports.status_addr; 300 unsigned long port = hwif->io_ports.status_addr;
311 u8 reg = (u8) readb((void __iomem *) port); 301 u8 reg = (u8) readb((void __iomem *) port);
312 302
313 if ((port & 0xFFF) == 0x11C) { /* Status register of IOC4 */ 303 if (!(reg & ATA_BUSY)) { /* Not busy... check for interrupt */
314 if (!(reg & ATA_BUSY)) { /* Not busy... check for interrupt */ 304 unsigned long other_ir = port - 0x110;
315 unsigned long other_ir = port - 0x110; 305 unsigned int intr_reg = (u32) readl((void __iomem *) other_ir);
316 unsigned int intr_reg = (u32) readl((void __iomem *) other_ir);
317 306
318 /* Clear the Interrupt, Error bits on the IOC4 */ 307 /* Clear the Interrupt, Error bits on the IOC4 */
319 if (intr_reg & 0x03) { 308 if (intr_reg & 0x03) {
320 writel(0x03, (void __iomem *) other_ir); 309 writel(0x03, (void __iomem *) other_ir);
321 intr_reg = (u32) readl((void __iomem *) other_ir); 310 intr_reg = (u32) readl((void __iomem *) other_ir);
322 }
323 } 311 }
324 } 312 }
325 313
@@ -332,13 +320,9 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
332{ 320{
333 struct pci_dev *dev = to_pci_dev(hwif->dev); 321 struct pci_dev *dev = to_pci_dev(hwif->dev);
334 unsigned long dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET; 322 unsigned long dma_base = pci_resource_start(dev, 0) + IOC4_DMA_OFFSET;
335 void __iomem *virt_dma_base;
336 int num_ports = sizeof (ioc4_dma_regs_t); 323 int num_ports = sizeof (ioc4_dma_regs_t);
337 void *pad; 324 void *pad;
338 325
339 if (dma_base == 0)
340 return -1;
341
342 printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name); 326 printk(KERN_INFO " %s: MMIO-DMA\n", hwif->name);
343 327
344 if (request_mem_region(dma_base, num_ports, hwif->name) == NULL) { 328 if (request_mem_region(dma_base, num_ports, hwif->name) == NULL) {
@@ -348,14 +332,8 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
348 return -1; 332 return -1;
349 } 333 }
350 334
351 virt_dma_base = ioremap(dma_base, num_ports); 335 hwif->dma_base = (unsigned long)hwif->io_ports.irq_addr +
352 if (virt_dma_base == NULL) { 336 IOC4_DMA_OFFSET;
353 printk(KERN_ERR "%s(%s) -- ERROR: unable to map addresses "
354 "0x%lx to 0x%lx\n", __func__, hwif->name,
355 dma_base, dma_base + num_ports - 1);
356 goto dma_remap_failure;
357 }
358 hwif->dma_base = (unsigned long) virt_dma_base;
359 337
360 hwif->sg_max_nents = IOC4_PRD_ENTRIES; 338 hwif->sg_max_nents = IOC4_PRD_ENTRIES;
361 339
@@ -379,9 +357,6 @@ ide_dma_sgiioc4(ide_hwif_t *hwif, const struct ide_port_info *d)
379 printk(KERN_INFO "%s: changing from DMA to PIO mode", hwif->name); 357 printk(KERN_INFO "%s: changing from DMA to PIO mode", hwif->name);
380 358
381dma_pci_alloc_failure: 359dma_pci_alloc_failure:
382 iounmap(virt_dma_base);
383
384dma_remap_failure:
385 release_mem_region(dma_base, num_ports); 360 release_mem_region(dma_base, num_ports);
386 361
387 return -1; 362 return -1;
@@ -563,8 +538,6 @@ static const struct ide_port_ops sgiioc4_port_ops = {
563 .set_dma_mode = sgiioc4_set_dma_mode, 538 .set_dma_mode = sgiioc4_set_dma_mode,
564 /* reset DMA engine, clear IRQs */ 539 /* reset DMA engine, clear IRQs */
565 .resetproc = sgiioc4_resetproc, 540 .resetproc = sgiioc4_resetproc,
566 /* mask on/off NIEN register */
567 .maskproc = sgiioc4_maskproc,
568}; 541};
569 542
570static const struct ide_dma_ops sgiioc4_dma_ops = { 543static const struct ide_dma_ops sgiioc4_dma_ops = {
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index e3e40427e00e..c7ff1e11ea85 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -179,7 +179,7 @@ config LEDS_TRIGGER_TIMER
179 179
180config LEDS_TRIGGER_IDE_DISK 180config LEDS_TRIGGER_IDE_DISK
181 bool "LED IDE Disk Trigger" 181 bool "LED IDE Disk Trigger"
182 depends on LEDS_TRIGGERS && BLK_DEV_IDEDISK 182 depends on LEDS_TRIGGERS && IDE_GD_ATA
183 help 183 help
184 This allows LEDs to be controlled by IDE disk activity. 184 This allows LEDs to be controlled by IDE disk activity.
185 If unsure, say Y. 185 If unsure, say Y.
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 740bad435995..afc96e844a25 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -343,6 +343,11 @@ static ide_startstop_t idescsi_do_request (ide_drive_t *drive, struct request *r
343} 343}
344 344
345#ifdef CONFIG_IDE_PROC_FS 345#ifdef CONFIG_IDE_PROC_FS
346static ide_proc_entry_t idescsi_proc[] = {
347 { "capacity", S_IFREG|S_IRUGO, proc_ide_read_capacity, NULL },
348 { NULL, 0, NULL, NULL }
349};
350
346#define ide_scsi_devset_get(name, field) \ 351#define ide_scsi_devset_get(name, field) \
347static int get_##name(ide_drive_t *drive) \ 352static int get_##name(ide_drive_t *drive) \
348{ \ 353{ \
@@ -378,6 +383,16 @@ static const struct ide_proc_devset idescsi_settings[] = {
378 IDE_PROC_DEVSET(transform, 0, 3), 383 IDE_PROC_DEVSET(transform, 0, 3),
379 { 0 }, 384 { 0 },
380}; 385};
386
387static ide_proc_entry_t *ide_scsi_proc_entries(ide_drive_t *drive)
388{
389 return idescsi_proc;
390}
391
392static const struct ide_proc_devset *ide_scsi_proc_devsets(ide_drive_t *drive)
393{
394 return idescsi_settings;
395}
381#endif 396#endif
382 397
383/* 398/*
@@ -419,13 +434,6 @@ static void ide_scsi_remove(ide_drive_t *drive)
419 434
420static int ide_scsi_probe(ide_drive_t *); 435static int ide_scsi_probe(ide_drive_t *);
421 436
422#ifdef CONFIG_IDE_PROC_FS
423static ide_proc_entry_t idescsi_proc[] = {
424 { "capacity", S_IFREG|S_IRUGO, proc_ide_read_capacity, NULL },
425 { NULL, 0, NULL, NULL }
426};
427#endif
428
429static ide_driver_t idescsi_driver = { 437static ide_driver_t idescsi_driver = {
430 .gen_driver = { 438 .gen_driver = {
431 .owner = THIS_MODULE, 439 .owner = THIS_MODULE,
@@ -439,8 +447,8 @@ static ide_driver_t idescsi_driver = {
439 .end_request = idescsi_end_request, 447 .end_request = idescsi_end_request,
440 .error = idescsi_atapi_error, 448 .error = idescsi_atapi_error,
441#ifdef CONFIG_IDE_PROC_FS 449#ifdef CONFIG_IDE_PROC_FS
442 .proc = idescsi_proc, 450 .proc_entries = ide_scsi_proc_entries,
443 .settings = idescsi_settings, 451 .proc_devsets = ide_scsi_proc_devsets,
444#endif 452#endif
445}; 453};
446 454
diff --git a/include/asm-frv/ide.h b/include/asm-frv/ide.h
index 7ebcc56a2229..361076611855 100644
--- a/include/asm-frv/ide.h
+++ b/include/asm-frv/ide.h
@@ -18,15 +18,7 @@
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/irq.h> 19#include <asm/irq.h>
20 20
21/****************************************************************************/ 21#include <asm-generic/ide_iops.h>
22/*
23 * some bits needed for parts of the IDE subsystem to compile
24 */
25#define __ide_mm_insw(port, addr, n) insw((unsigned long) (port), addr, n)
26#define __ide_mm_insl(port, addr, n) insl((unsigned long) (port), addr, n)
27#define __ide_mm_outsw(port, addr, n) outsw((unsigned long) (port), addr, n)
28#define __ide_mm_outsl(port, addr, n) outsl((unsigned long) (port), addr, n)
29
30 22
31#endif /* __KERNEL__ */ 23#endif /* __KERNEL__ */
32#endif /* _ASM_IDE_H */ 24#endif /* _ASM_IDE_H */
diff --git a/include/asm-m68k/ide.h b/include/asm-m68k/ide.h
index 1daf6cbdd9f0..b996a3c8cff5 100644
--- a/include/asm-m68k/ide.h
+++ b/include/asm-m68k/ide.h
@@ -92,15 +92,6 @@
92#define outsw_swapw(port, addr, n) raw_outsw_swapw((u16 *)port, addr, n) 92#define outsw_swapw(port, addr, n) raw_outsw_swapw((u16 *)port, addr, n)
93#endif 93#endif
94 94
95
96/* Q40 and Atari have byteswapped IDE busses and since many interesting
97 * values in the identification string are text, chars and words they
98 * happened to be almost correct without swapping.. However *_capacity
99 * is needed for drives over 8 GB. RZ */
100#if defined(CONFIG_Q40) || defined(CONFIG_ATARI)
101#define M68K_IDE_SWAPW (MACH_IS_Q40 || MACH_IS_ATARI)
102#endif
103
104#ifdef CONFIG_BLK_DEV_FALCON_IDE 95#ifdef CONFIG_BLK_DEV_FALCON_IDE
105#define IDE_ARCH_LOCK 96#define IDE_ARCH_LOCK
106 97
diff --git a/include/asm-parisc/ide.h b/include/asm-parisc/ide.h
index c246ef75017d..81700a2321cf 100644
--- a/include/asm-parisc/ide.h
+++ b/include/asm-parisc/ide.h
@@ -13,10 +13,6 @@
13 13
14#ifdef __KERNEL__ 14#ifdef __KERNEL__
15 15
16#define ide_request_irq(irq,hand,flg,dev,id) request_irq((irq),(hand),(flg),(dev),(id))
17#define ide_free_irq(irq,dev_id) free_irq((irq), (dev_id))
18#define ide_request_region(from,extent,name) request_region((from), (extent), (name))
19#define ide_release_region(from,extent) release_region((from), (extent))
20/* Generic I/O and MEMIO string operations. */ 16/* Generic I/O and MEMIO string operations. */
21 17
22#define __ide_insw insw 18#define __ide_insw insw
diff --git a/include/linux/ide.h b/include/linux/ide.h
index c47e371554c1..89e53cfbc787 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -461,12 +461,26 @@ struct ide_acpi_drive_link;
461struct ide_acpi_hwif_link; 461struct ide_acpi_hwif_link;
462#endif 462#endif
463 463
464struct ide_drive_s;
465
466struct ide_disk_ops {
467 int (*check)(struct ide_drive_s *, const char *);
468 int (*get_capacity)(struct ide_drive_s *);
469 void (*setup)(struct ide_drive_s *);
470 void (*flush)(struct ide_drive_s *);
471 int (*init_media)(struct ide_drive_s *, struct gendisk *);
472 int (*set_doorlock)(struct ide_drive_s *, struct gendisk *,
473 int);
474 ide_startstop_t (*do_request)(struct ide_drive_s *, struct request *,
475 sector_t);
476 int (*end_request)(struct ide_drive_s *, int, int);
477 int (*ioctl)(struct ide_drive_s *, struct inode *,
478 struct file *, unsigned int, unsigned long);
479};
480
464/* ATAPI device flags */ 481/* ATAPI device flags */
465enum { 482enum {
466 IDE_AFLAG_DRQ_INTERRUPT = (1 << 0), 483 IDE_AFLAG_DRQ_INTERRUPT = (1 << 0),
467 IDE_AFLAG_MEDIA_CHANGED = (1 << 1),
468 /* Drive cannot lock the door. */
469 IDE_AFLAG_NO_DOORLOCK = (1 << 2),
470 484
471 /* ide-cd */ 485 /* ide-cd */
472 /* Drive cannot eject the disc. */ 486 /* Drive cannot eject the disc. */
@@ -498,14 +512,10 @@ enum {
498 IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17), 512 IDE_AFLAG_LE_SPEED_FIELDS = (1 << 17),
499 513
500 /* ide-floppy */ 514 /* ide-floppy */
501 /* Format in progress */
502 IDE_AFLAG_FORMAT_IN_PROGRESS = (1 << 18),
503 /* Avoid commands not supported in Clik drive */ 515 /* Avoid commands not supported in Clik drive */
504 IDE_AFLAG_CLIK_DRIVE = (1 << 19), 516 IDE_AFLAG_CLIK_DRIVE = (1 << 19),
505 /* Requires BH algorithm for packets */ 517 /* Requires BH algorithm for packets */
506 IDE_AFLAG_ZIP_DRIVE = (1 << 20), 518 IDE_AFLAG_ZIP_DRIVE = (1 << 20),
507 /* Write protect */
508 IDE_AFLAG_WP = (1 << 21),
509 /* Supports format progress report */ 519 /* Supports format progress report */
510 IDE_AFLAG_SRFP = (1 << 22), 520 IDE_AFLAG_SRFP = (1 << 22),
511 521
@@ -578,7 +588,11 @@ enum {
578 /* don't unload heads */ 588 /* don't unload heads */
579 IDE_DFLAG_NO_UNLOAD = (1 << 27), 589 IDE_DFLAG_NO_UNLOAD = (1 << 27),
580 /* heads unloaded, please don't reset port */ 590 /* heads unloaded, please don't reset port */
581 IDE_DFLAG_PARKED = (1 << 28) 591 IDE_DFLAG_PARKED = (1 << 28),
592 IDE_DFLAG_MEDIA_CHANGED = (1 << 29),
593 /* write protect */
594 IDE_DFLAG_WP = (1 << 30),
595 IDE_DFLAG_FORMAT_IN_PROGRESS = (1 << 31),
582}; 596};
583 597
584struct ide_drive_s { 598struct ide_drive_s {
@@ -597,6 +611,8 @@ struct ide_drive_s {
597#endif 611#endif
598 struct hwif_s *hwif; /* actually (ide_hwif_t *) */ 612 struct hwif_s *hwif; /* actually (ide_hwif_t *) */
599 613
614 const struct ide_disk_ops *disk_ops;
615
600 unsigned long dev_flags; 616 unsigned long dev_flags;
601 617
602 unsigned long sleep; /* sleep until this time */ 618 unsigned long sleep; /* sleep until this time */
@@ -1123,8 +1139,8 @@ struct ide_driver_s {
1123 void (*resume)(ide_drive_t *); 1139 void (*resume)(ide_drive_t *);
1124 void (*shutdown)(ide_drive_t *); 1140 void (*shutdown)(ide_drive_t *);
1125#ifdef CONFIG_IDE_PROC_FS 1141#ifdef CONFIG_IDE_PROC_FS
1126 ide_proc_entry_t *proc; 1142 ide_proc_entry_t * (*proc_entries)(ide_drive_t *);
1127 const struct ide_proc_devset *settings; 1143 const struct ide_proc_devset * (*proc_devsets)(ide_drive_t *);
1128#endif 1144#endif
1129}; 1145};
1130 1146