aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/ide/Kconfig2
-rw-r--r--drivers/ide/Makefile9
-rw-r--r--drivers/ide/arm/icside.c6
-rw-r--r--drivers/ide/arm/palm_bk3710.c9
-rw-r--r--drivers/ide/arm/rapide.c6
-rw-r--r--drivers/ide/ide-cd.c39
-rw-r--r--drivers/ide/ide-disk.c12
-rw-r--r--drivers/ide/ide-dma.c2
-rw-r--r--drivers/ide/ide-floppy.c12
-rw-r--r--drivers/ide/ide-generic.c36
-rw-r--r--drivers/ide/ide-iops.c6
-rw-r--r--drivers/ide/ide-probe.c71
-rw-r--r--drivers/ide/ide-proc.c4
-rw-r--r--drivers/ide/ide-tape.c32
-rw-r--r--drivers/ide/ide-taskfile.c12
-rw-r--r--drivers/ide/ide.c47
-rw-r--r--drivers/ide/legacy/gayle.c8
-rw-r--r--drivers/ide/legacy/ht6560b.c24
-rw-r--r--drivers/ide/pci/aec62xx.c76
-rw-r--r--drivers/ide/pci/alim15x3.c18
-rw-r--r--drivers/ide/pci/amd74xx.c155
-rw-r--r--drivers/ide/pci/atiixp.c20
-rw-r--r--drivers/ide/pci/cmd64x.c50
-rw-r--r--drivers/ide/pci/cs5520.c24
-rw-r--r--drivers/ide/pci/cs5530.c20
-rw-r--r--drivers/ide/pci/cs5535.c13
-rw-r--r--drivers/ide/pci/cy82c693.c35
-rw-r--r--drivers/ide/pci/generic.c78
-rw-r--r--drivers/ide/pci/hpt34x.c21
-rw-r--r--drivers/ide/pci/hpt366.c183
-rw-r--r--drivers/ide/pci/it8213.c35
-rw-r--r--drivers/ide/pci/it821x.c74
-rw-r--r--drivers/ide/pci/jmicron.c13
-rw-r--r--drivers/ide/pci/ns87415.c13
-rw-r--r--drivers/ide/pci/opti621.c13
-rw-r--r--drivers/ide/pci/pdc202xx_new.c78
-rw-r--r--drivers/ide/pci/pdc202xx_old.c49
-rw-r--r--drivers/ide/pci/piix.c118
-rw-r--r--drivers/ide/pci/rz1000.c13
-rw-r--r--drivers/ide/pci/sc1200.c50
-rw-r--r--drivers/ide/pci/serverworks.c40
-rw-r--r--drivers/ide/pci/siimage.c161
-rw-r--r--drivers/ide/pci/sis5513.c39
-rw-r--r--drivers/ide/pci/sl82c105.c17
-rw-r--r--drivers/ide/pci/slc90e66.c13
-rw-r--r--drivers/ide/pci/tc86c001.c57
-rw-r--r--drivers/ide/pci/triflex.c13
-rw-r--r--drivers/ide/pci/trm290.c17
-rw-r--r--drivers/ide/pci/via82cxxx.c139
-rw-r--r--drivers/ide/setup-pci.c240
-rw-r--r--drivers/scsi/ide-scsi.c33
-rw-r--r--include/asm-alpha/ide.h44
-rw-r--r--include/asm-arm/ide.h4
-rw-r--r--include/asm-blackfin/ide.h27
-rw-r--r--include/asm-cris/arch-v10/ide.h91
-rw-r--r--include/asm-cris/arch-v32/ide.h56
-rw-r--r--include/asm-cris/ide.h1
-rw-r--r--include/asm-frv/ide.h4
-rw-r--r--include/asm-h8300/ide.h26
-rw-r--r--include/asm-ia64/ide.h51
-rw-r--r--include/asm-m32r/ide.h70
-rw-r--r--include/asm-m68k/ide.h4
-rw-r--r--include/asm-mips/mach-generic/ide.h48
-rw-r--r--include/asm-mn10300/ide.h4
-rw-r--r--include/asm-parisc/ide.h4
-rw-r--r--include/asm-powerpc/ide.h26
-rw-r--r--include/asm-sh/ide.h21
-rw-r--r--include/asm-sparc/ide.h3
-rw-r--r--include/asm-x86/ide.h65
-rw-r--r--include/asm-xtensa/ide.h35
-rw-r--r--include/linux/ide.h32
71 files changed, 1397 insertions, 1474 deletions
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig
index 04d9c4d459d0..130ef64b44f7 100644
--- a/drivers/ide/Kconfig
+++ b/drivers/ide/Kconfig
@@ -314,7 +314,7 @@ comment "IDE chipset support/bugfixes"
314 314
315config IDE_GENERIC 315config IDE_GENERIC
316 tristate "generic/default IDE chipset support" 316 tristate "generic/default IDE chipset support"
317 depends on ALPHA || X86 || IA64 || M32R || MIPS || PPC32 317 depends on ALPHA || X86 || IA64 || M32R || MIPS
318 help 318 help
319 If unsure, say N. 319 If unsure, say N.
320 320
diff --git a/drivers/ide/Makefile b/drivers/ide/Makefile
index 5d414e301a5a..64e0ecdc4ed5 100644
--- a/drivers/ide/Makefile
+++ b/drivers/ide/Makefile
@@ -1,13 +1,6 @@
1# 1#
2# Makefile for the kernel ata, atapi, and ide block device drivers.
3#
4# 12 September 2000, Bartlomiej Zolnierkiewicz <bkz@linux-ide.org>
5# Rewritten to use lists instead of if-statements.
6#
7# Note : at this point, these files are compiled on all systems.
8# In the future, some of these should be built conditionally.
9#
10# link order is important here 2# link order is important here
3#
11 4
12EXTRA_CFLAGS += -Idrivers/ide 5EXTRA_CFLAGS += -Idrivers/ide
13 6
diff --git a/drivers/ide/arm/icside.c b/drivers/ide/arm/icside.c
index f575e8341aec..df4af4083954 100644
--- a/drivers/ide/arm/icside.c
+++ b/drivers/ide/arm/icside.c
@@ -710,8 +710,14 @@ static int __init icside_init(void)
710 return ecard_register_driver(&icside_driver); 710 return ecard_register_driver(&icside_driver);
711} 711}
712 712
713static void __exit icside_exit(void);
714{
715 ecard_unregister_driver(&icside_driver);
716}
717
713MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>"); 718MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
714MODULE_LICENSE("GPL"); 719MODULE_LICENSE("GPL");
715MODULE_DESCRIPTION("ICS IDE driver"); 720MODULE_DESCRIPTION("ICS IDE driver");
716 721
717module_init(icside_init); 722module_init(icside_init);
723module_exit(icside_exit);
diff --git a/drivers/ide/arm/palm_bk3710.c b/drivers/ide/arm/palm_bk3710.c
index 65bb4b8fd570..3e842d60eae9 100644
--- a/drivers/ide/arm/palm_bk3710.c
+++ b/drivers/ide/arm/palm_bk3710.c
@@ -82,6 +82,7 @@ static const struct palm_bk3710_udmatiming palm_bk3710_udmatimings[6] = {
82 {100, 120}, /* UDMA Mode 2 */ 82 {100, 120}, /* UDMA Mode 2 */
83 {100, 90}, /* UDMA Mode 3 */ 83 {100, 90}, /* UDMA Mode 3 */
84 {100, 60}, /* UDMA Mode 4 */ 84 {100, 60}, /* UDMA Mode 4 */
85 {85, 40}, /* UDMA Mode 5 */
85}; 86};
86 87
87static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev, 88static void palm_bk3710_setudmamode(void __iomem *base, unsigned int dev,
@@ -334,12 +335,11 @@ static const struct ide_port_ops palm_bk3710_ports_ops = {
334 .cable_detect = palm_bk3710_cable_detect, 335 .cable_detect = palm_bk3710_cable_detect,
335}; 336};
336 337
337static const struct ide_port_info __devinitdata palm_bk3710_port_info = { 338static struct ide_port_info __devinitdata palm_bk3710_port_info = {
338 .init_dma = palm_bk3710_init_dma, 339 .init_dma = palm_bk3710_init_dma,
339 .port_ops = &palm_bk3710_ports_ops, 340 .port_ops = &palm_bk3710_ports_ops,
340 .host_flags = IDE_HFLAG_MMIO, 341 .host_flags = IDE_HFLAG_MMIO,
341 .pio_mask = ATA_PIO4, 342 .pio_mask = ATA_PIO4,
342 .udma_mask = ATA_UDMA4, /* (input clk 99MHz) */
343 .mwdma_mask = ATA_MWDMA2, 343 .mwdma_mask = ATA_MWDMA2,
344}; 344};
345 345
@@ -352,7 +352,7 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
352 int i, rc; 352 int i, rc;
353 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL }; 353 hw_regs_t hw, *hws[] = { &hw, NULL, NULL, NULL };
354 354
355 clk = clk_get(NULL, "IDECLK"); 355 clk = clk_get(&pdev->dev, "IDECLK");
356 if (IS_ERR(clk)) 356 if (IS_ERR(clk))
357 return -ENODEV; 357 return -ENODEV;
358 358
@@ -392,6 +392,9 @@ static int __devinit palm_bk3710_probe(struct platform_device *pdev)
392 hw.irq = irq->start; 392 hw.irq = irq->start;
393 hw.chipset = ide_palm3710; 393 hw.chipset = ide_palm3710;
394 394
395 palm_bk3710_port_info.udma_mask = rate < 100000000 ? ATA_UDMA4 :
396 ATA_UDMA5;
397
395 rc = ide_host_add(&palm_bk3710_port_info, hws, NULL); 398 rc = ide_host_add(&palm_bk3710_port_info, hws, NULL);
396 if (rc) 399 if (rc)
397 goto out; 400 goto out;
diff --git a/drivers/ide/arm/rapide.c b/drivers/ide/arm/rapide.c
index 2bdd8b734afb..78d27d9ae430 100644
--- a/drivers/ide/arm/rapide.c
+++ b/drivers/ide/arm/rapide.c
@@ -95,7 +95,13 @@ static int __init rapide_init(void)
95 return ecard_register_driver(&rapide_driver); 95 return ecard_register_driver(&rapide_driver);
96} 96}
97 97
98static void __exit rapide_exit(void)
99{
100 ecard_unregister_driver(&rapide_driver);
101}
102
98MODULE_LICENSE("GPL"); 103MODULE_LICENSE("GPL");
99MODULE_DESCRIPTION("Yellowstone RAPIDE driver"); 104MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
100 105
101module_init(rapide_init); 106module_init(rapide_init);
107module_exit(rapide_exit);
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index 4e73aeee4053..e617cf08aef6 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -57,23 +57,29 @@ static DEFINE_MUTEX(idecd_ref_mutex);
57#define ide_cd_g(disk) \ 57#define ide_cd_g(disk) \
58 container_of((disk)->private_data, struct cdrom_info, driver) 58 container_of((disk)->private_data, struct cdrom_info, driver)
59 59
60static void ide_cd_release(struct kref *);
61
60static struct cdrom_info *ide_cd_get(struct gendisk *disk) 62static struct cdrom_info *ide_cd_get(struct gendisk *disk)
61{ 63{
62 struct cdrom_info *cd = NULL; 64 struct cdrom_info *cd = NULL;
63 65
64 mutex_lock(&idecd_ref_mutex); 66 mutex_lock(&idecd_ref_mutex);
65 cd = ide_cd_g(disk); 67 cd = ide_cd_g(disk);
66 if (cd) 68 if (cd) {
67 kref_get(&cd->kref); 69 kref_get(&cd->kref);
70 if (ide_device_get(cd->drive)) {
71 kref_put(&cd->kref, ide_cd_release);
72 cd = NULL;
73 }
74 }
68 mutex_unlock(&idecd_ref_mutex); 75 mutex_unlock(&idecd_ref_mutex);
69 return cd; 76 return cd;
70} 77}
71 78
72static void ide_cd_release(struct kref *);
73
74static void ide_cd_put(struct cdrom_info *cd) 79static void ide_cd_put(struct cdrom_info *cd)
75{ 80{
76 mutex_lock(&idecd_ref_mutex); 81 mutex_lock(&idecd_ref_mutex);
82 ide_device_put(cd->drive);
77 kref_put(&cd->kref, ide_cd_release); 83 kref_put(&cd->kref, ide_cd_release);
78 mutex_unlock(&idecd_ref_mutex); 84 mutex_unlock(&idecd_ref_mutex);
79} 85}
@@ -1305,13 +1311,30 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity,
1305 1311
1306 stat = ide_cd_queue_pc(drive, cmd, 0, &capbuf, &len, sense, 0, 1312 stat = ide_cd_queue_pc(drive, cmd, 0, &capbuf, &len, sense, 0,
1307 REQ_QUIET); 1313 REQ_QUIET);
1308 if (stat == 0) { 1314 if (stat)
1309 *capacity = 1 + be32_to_cpu(capbuf.lba); 1315 return stat;
1310 *sectors_per_frame = 1316
1311 be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS; 1317 /*
1318 * Sanity check the given block size
1319 */
1320 switch (capbuf.blocklen) {
1321 case __constant_cpu_to_be32(512):
1322 case __constant_cpu_to_be32(1024):
1323 case __constant_cpu_to_be32(2048):
1324 case __constant_cpu_to_be32(4096):
1325 break;
1326 default:
1327 printk(KERN_ERR "%s: weird block size %u\n",
1328 drive->name, capbuf.blocklen);
1329 printk(KERN_ERR "%s: default to 2kb block size\n",
1330 drive->name);
1331 capbuf.blocklen = __constant_cpu_to_be32(2048);
1332 break;
1312 } 1333 }
1313 1334
1314 return stat; 1335 *capacity = 1 + be32_to_cpu(capbuf.lba);
1336 *sectors_per_frame = be32_to_cpu(capbuf.blocklen) >> SECTOR_BITS;
1337 return 0;
1315} 1338}
1316 1339
1317static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag, 1340static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag,
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index df5fe5756871..28d85b410f7c 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -56,23 +56,29 @@ static DEFINE_MUTEX(idedisk_ref_mutex);
56#define ide_disk_g(disk) \ 56#define ide_disk_g(disk) \
57 container_of((disk)->private_data, struct ide_disk_obj, driver) 57 container_of((disk)->private_data, struct ide_disk_obj, driver)
58 58
59static void ide_disk_release(struct kref *);
60
59static struct ide_disk_obj *ide_disk_get(struct gendisk *disk) 61static struct ide_disk_obj *ide_disk_get(struct gendisk *disk)
60{ 62{
61 struct ide_disk_obj *idkp = NULL; 63 struct ide_disk_obj *idkp = NULL;
62 64
63 mutex_lock(&idedisk_ref_mutex); 65 mutex_lock(&idedisk_ref_mutex);
64 idkp = ide_disk_g(disk); 66 idkp = ide_disk_g(disk);
65 if (idkp) 67 if (idkp) {
66 kref_get(&idkp->kref); 68 kref_get(&idkp->kref);
69 if (ide_device_get(idkp->drive)) {
70 kref_put(&idkp->kref, ide_disk_release);
71 idkp = NULL;
72 }
73 }
67 mutex_unlock(&idedisk_ref_mutex); 74 mutex_unlock(&idedisk_ref_mutex);
68 return idkp; 75 return idkp;
69} 76}
70 77
71static void ide_disk_release(struct kref *);
72
73static void ide_disk_put(struct ide_disk_obj *idkp) 78static void ide_disk_put(struct ide_disk_obj *idkp)
74{ 79{
75 mutex_lock(&idedisk_ref_mutex); 80 mutex_lock(&idedisk_ref_mutex);
81 ide_device_put(idkp->drive);
76 kref_put(&idkp->kref, ide_disk_release); 82 kref_put(&idkp->kref, ide_disk_release);
77 mutex_unlock(&idedisk_ref_mutex); 83 mutex_unlock(&idedisk_ref_mutex);
78} 84}
diff --git a/drivers/ide/ide-dma.c b/drivers/ide/ide-dma.c
index be99d463dcc7..71c377a7bcf2 100644
--- a/drivers/ide/ide-dma.c
+++ b/drivers/ide/ide-dma.c
@@ -173,7 +173,7 @@ EXPORT_SYMBOL_GPL(ide_build_sglist);
173int ide_build_dmatable (ide_drive_t *drive, struct request *rq) 173int ide_build_dmatable (ide_drive_t *drive, struct request *rq)
174{ 174{
175 ide_hwif_t *hwif = HWIF(drive); 175 ide_hwif_t *hwif = HWIF(drive);
176 unsigned int *table = hwif->dmatable_cpu; 176 __le32 *table = (__le32 *)hwif->dmatable_cpu;
177 unsigned int is_trm290 = (hwif->chipset == ide_trm290) ? 1 : 0; 177 unsigned int is_trm290 = (hwif->chipset == ide_trm290) ? 1 : 0;
178 unsigned int count = 0; 178 unsigned int count = 0;
179 int i; 179 int i;
diff --git a/drivers/ide/ide-floppy.c b/drivers/ide/ide-floppy.c
index 3d8e6dd0f41e..ca11a26746f1 100644
--- a/drivers/ide/ide-floppy.c
+++ b/drivers/ide/ide-floppy.c
@@ -158,23 +158,29 @@ static DEFINE_MUTEX(idefloppy_ref_mutex);
158#define ide_floppy_g(disk) \ 158#define ide_floppy_g(disk) \
159 container_of((disk)->private_data, struct ide_floppy_obj, driver) 159 container_of((disk)->private_data, struct ide_floppy_obj, driver)
160 160
161static void idefloppy_cleanup_obj(struct kref *);
162
161static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk) 163static struct ide_floppy_obj *ide_floppy_get(struct gendisk *disk)
162{ 164{
163 struct ide_floppy_obj *floppy = NULL; 165 struct ide_floppy_obj *floppy = NULL;
164 166
165 mutex_lock(&idefloppy_ref_mutex); 167 mutex_lock(&idefloppy_ref_mutex);
166 floppy = ide_floppy_g(disk); 168 floppy = ide_floppy_g(disk);
167 if (floppy) 169 if (floppy) {
168 kref_get(&floppy->kref); 170 kref_get(&floppy->kref);
171 if (ide_device_get(floppy->drive)) {
172 kref_put(&floppy->kref, idefloppy_cleanup_obj);
173 floppy = NULL;
174 }
175 }
169 mutex_unlock(&idefloppy_ref_mutex); 176 mutex_unlock(&idefloppy_ref_mutex);
170 return floppy; 177 return floppy;
171} 178}
172 179
173static void idefloppy_cleanup_obj(struct kref *);
174
175static void ide_floppy_put(struct ide_floppy_obj *floppy) 180static void ide_floppy_put(struct ide_floppy_obj *floppy)
176{ 181{
177 mutex_lock(&idefloppy_ref_mutex); 182 mutex_lock(&idefloppy_ref_mutex);
183 ide_device_put(floppy->drive);
178 kref_put(&floppy->kref, idefloppy_cleanup_obj); 184 kref_put(&floppy->kref, idefloppy_cleanup_obj);
179 mutex_unlock(&idefloppy_ref_mutex); 185 mutex_unlock(&idefloppy_ref_mutex);
180} 186}
diff --git a/drivers/ide/ide-generic.c b/drivers/ide/ide-generic.c
index 31d98fec775f..8fe8b5b9cf7d 100644
--- a/drivers/ide/ide-generic.c
+++ b/drivers/ide/ide-generic.c
@@ -20,6 +20,11 @@
20#include <linux/module.h> 20#include <linux/module.h>
21#include <linux/ide.h> 21#include <linux/ide.h>
22 22
23/* FIXME: convert m32r to use ide_platform host driver */
24#ifdef CONFIG_M32R
25#include <asm/m32r.h>
26#endif
27
23#define DRV_NAME "ide_generic" 28#define DRV_NAME "ide_generic"
24 29
25static int probe_mask = 0x03; 30static int probe_mask = 0x03;
@@ -80,6 +85,21 @@ static int __init ide_generic_sysfs_init(void)
80 return 0; 85 return 0;
81} 86}
82 87
88#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) \
89 || defined(CONFIG_PLAT_OPSPUT)
90static const u16 legacy_bases[] = { 0x1f0 };
91static const int legacy_irqs[] = { PLD_IRQ_CFIREQ };
92#elif defined(CONFIG_PLAT_MAPPI3)
93static const u16 legacy_bases[] = { 0x1f0, 0x170 };
94static const int legacy_irqs[] = { PLD_IRQ_CFIREQ, PLD_IRQ_IDEIREQ };
95#elif defined(CONFIG_ALPHA)
96static const u16 legacy_bases[] = { 0x1f0, 0x170, 0x1e8, 0x168 };
97static const int legacy_irqs[] = { 14, 15, 11, 10 };
98#else
99static const u16 legacy_bases[] = { 0x1f0, 0x170, 0x1e8, 0x168, 0x1e0, 0x160 };
100static const int legacy_irqs[] = { 14, 15, 11, 10, 8, 12 };
101#endif
102
83static int __init ide_generic_init(void) 103static int __init ide_generic_init(void)
84{ 104{
85 hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS]; 105 hw_regs_t hw[MAX_HWIFS], *hws[MAX_HWIFS];
@@ -87,11 +107,17 @@ static int __init ide_generic_init(void)
87 unsigned long io_addr; 107 unsigned long io_addr;
88 int i, rc; 108 int i, rc;
89 109
110#ifdef CONFIG_MIPS
111 if (!ide_probe_legacy())
112 return -ENODEV;
113#endif
90 printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module " 114 printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" module "
91 "parameter for probing all legacy ISA IDE ports\n"); 115 "parameter for probing all legacy ISA IDE ports\n");
92 116
93 for (i = 0; i < MAX_HWIFS; i++) { 117 memset(hws, 0, sizeof(hw_regs_t *) * MAX_HWIFS);
94 io_addr = ide_default_io_base(i); 118
119 for (i = 0; i < ARRAY_SIZE(legacy_bases); i++) {
120 io_addr = legacy_bases[i];
95 121
96 hws[i] = NULL; 122 hws[i] = NULL;
97 123
@@ -113,7 +139,11 @@ static int __init ide_generic_init(void)
113 139
114 memset(&hw[i], 0, sizeof(hw[i])); 140 memset(&hw[i], 0, sizeof(hw[i]));
115 ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206); 141 ide_std_init_ports(&hw[i], io_addr, io_addr + 0x206);
116 hw[i].irq = ide_default_irq(io_addr); 142#ifdef CONFIG_IA64
143 hw[i].irq = isa_irq_to_vector(legacy_irqs[i]);
144#else
145 hw[i].irq = legacy_irqs[i];
146#endif
117 hw[i].chipset = ide_generic; 147 hw[i].chipset = ide_generic;
118 148
119 hws[i] = &hw[i]; 149 hws[i] = &hw[i];
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c
index 07da5fb9eaff..8aae91764513 100644
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -510,10 +510,8 @@ void ide_fixstring (u8 *s, const int bytecount, const int byteswap)
510 510
511 if (byteswap) { 511 if (byteswap) {
512 /* convert from big-endian to host byte order */ 512 /* convert from big-endian to host byte order */
513 for (p = end ; p != s;) { 513 for (p = end ; p != s;)
514 unsigned short *pp = (unsigned short *) (p -= 2); 514 be16_to_cpus((u16 *)(p -= 2));
515 *pp = ntohs(*pp);
516 }
517 } 515 }
518 /* strip leading blanks */ 516 /* strip leading blanks */
519 while (s != end && *s == ' ') 517 while (s != end && *s == ' ')
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 4aa76c453755..994e41099b42 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -134,18 +134,6 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
134#endif 134#endif
135 ide_fix_driveid(id); 135 ide_fix_driveid(id);
136 136
137#if defined (CONFIG_SCSI_EATA_PIO) || defined (CONFIG_SCSI_EATA)
138 /*
139 * EATA SCSI controllers do a hardware ATA emulation:
140 * Ignore them if there is a driver for them available.
141 */
142 if ((id->model[0] == 'P' && id->model[1] == 'M') ||
143 (id->model[0] == 'S' && id->model[1] == 'K')) {
144 printk("%s: EATA SCSI HBA %.10s\n", drive->name, id->model);
145 goto err_misc;
146 }
147#endif /* CONFIG_SCSI_EATA || CONFIG_SCSI_EATA_PIO */
148
149 /* 137 /*
150 * WIN_IDENTIFY returns little-endian info, 138 * WIN_IDENTIFY returns little-endian info,
151 * WIN_PIDENTIFY *usually* returns little-endian info. 139 * WIN_PIDENTIFY *usually* returns little-endian info.
@@ -167,7 +155,8 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
167 if (strstr(id->model, "E X A B Y T E N E S T")) 155 if (strstr(id->model, "E X A B Y T E N E S T"))
168 goto err_misc; 156 goto err_misc;
169 157
170 printk("%s: %s, ", drive->name, id->model); 158 printk(KERN_INFO "%s: %s, ", drive->name, id->model);
159
171 drive->present = 1; 160 drive->present = 1;
172 drive->dead = 0; 161 drive->dead = 0;
173 162
@@ -176,16 +165,17 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
176 */ 165 */
177 if (cmd == WIN_PIDENTIFY) { 166 if (cmd == WIN_PIDENTIFY) {
178 u8 type = (id->config >> 8) & 0x1f; 167 u8 type = (id->config >> 8) & 0x1f;
179 printk("ATAPI "); 168
169 printk(KERN_CONT "ATAPI ");
180 switch (type) { 170 switch (type) {
181 case ide_floppy: 171 case ide_floppy:
182 if (!strstr(id->model, "CD-ROM")) { 172 if (!strstr(id->model, "CD-ROM")) {
183 if (!strstr(id->model, "oppy") && 173 if (!strstr(id->model, "oppy") &&
184 !strstr(id->model, "poyp") && 174 !strstr(id->model, "poyp") &&
185 !strstr(id->model, "ZIP")) 175 !strstr(id->model, "ZIP"))
186 printk("cdrom or floppy?, assuming "); 176 printk(KERN_CONT "cdrom or floppy?, assuming ");
187 if (drive->media != ide_cdrom) { 177 if (drive->media != ide_cdrom) {
188 printk ("FLOPPY"); 178 printk(KERN_CONT "FLOPPY");
189 drive->removable = 1; 179 drive->removable = 1;
190 break; 180 break;
191 } 181 }
@@ -198,25 +188,25 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
198 /* kludge for Apple PowerBook internal zip */ 188 /* kludge for Apple PowerBook internal zip */
199 if (!strstr(id->model, "CD-ROM") && 189 if (!strstr(id->model, "CD-ROM") &&
200 strstr(id->model, "ZIP")) { 190 strstr(id->model, "ZIP")) {
201 printk ("FLOPPY"); 191 printk(KERN_CONT "FLOPPY");
202 type = ide_floppy; 192 type = ide_floppy;
203 break; 193 break;
204 } 194 }
205#endif 195#endif
206 printk ("CD/DVD-ROM"); 196 printk(KERN_CONT "CD/DVD-ROM");
207 break; 197 break;
208 case ide_tape: 198 case ide_tape:
209 printk ("TAPE"); 199 printk(KERN_CONT "TAPE");
210 break; 200 break;
211 case ide_optical: 201 case ide_optical:
212 printk ("OPTICAL"); 202 printk(KERN_CONT "OPTICAL");
213 drive->removable = 1; 203 drive->removable = 1;
214 break; 204 break;
215 default: 205 default:
216 printk("UNKNOWN (type %d)", type); 206 printk(KERN_CONT "UNKNOWN (type %d)", type);
217 break; 207 break;
218 } 208 }
219 printk (" drive\n"); 209 printk(KERN_CONT " drive\n");
220 drive->media = type; 210 drive->media = type;
221 /* an ATAPI device ignores DRDY */ 211 /* an ATAPI device ignores DRDY */
222 drive->ready_stat = 0; 212 drive->ready_stat = 0;
@@ -236,7 +226,9 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
236 drive->removable = 1; 226 drive->removable = 1;
237 227
238 drive->media = ide_disk; 228 drive->media = ide_disk;
239 printk("%s DISK drive\n", (id->config == 0x848a) ? "CFA" : "ATA" ); 229
230 printk(KERN_CONT "%s DISK drive\n",
231 (id->config == 0x848a) ? "CFA" : "ATA");
240 232
241 return; 233 return;
242 234
@@ -387,7 +379,7 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd)
387 /* Mmmm.. multiple IRQs.. 379 /* Mmmm.. multiple IRQs..
388 * don't know which was ours 380 * don't know which was ours
389 */ 381 */
390 printk("%s: IRQ probe failed (0x%lx)\n", 382 printk(KERN_ERR "%s: IRQ probe failed (0x%lx)\n",
391 drive->name, cookie); 383 drive->name, cookie);
392 } 384 }
393 } 385 }
@@ -456,7 +448,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
456 return 4; 448 return 4;
457 } 449 }
458#ifdef DEBUG 450#ifdef DEBUG
459 printk("probing for %s: present=%d, media=%d, probetype=%s\n", 451 printk(KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n",
460 drive->name, drive->present, drive->media, 452 drive->name, drive->present, drive->media,
461 (cmd == WIN_IDENTIFY) ? "ATA" : "ATAPI"); 453 (cmd == WIN_IDENTIFY) ? "ATA" : "ATAPI");
462#endif 454#endif
@@ -534,7 +526,8 @@ static void enable_nest (ide_drive_t *drive)
534 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 526 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
535 u8 stat; 527 u8 stat;
536 528
537 printk("%s: enabling %s -- ", hwif->name, drive->id->model); 529 printk(KERN_INFO "%s: enabling %s -- ", hwif->name, drive->id->model);
530
538 SELECT_DRIVE(drive); 531 SELECT_DRIVE(drive);
539 msleep(50); 532 msleep(50);
540 tp_ops->exec_command(hwif, EXABYTE_ENABLE_NEST); 533 tp_ops->exec_command(hwif, EXABYTE_ENABLE_NEST);
@@ -883,7 +876,7 @@ static void save_match(ide_hwif_t *hwif, ide_hwif_t *new, ide_hwif_t **match)
883 if (m && m->hwgroup && m->hwgroup != new->hwgroup) { 876 if (m && m->hwgroup && m->hwgroup != new->hwgroup) {
884 if (!new->hwgroup) 877 if (!new->hwgroup)
885 return; 878 return;
886 printk("%s: potential irq problem with %s and %s\n", 879 printk(KERN_WARNING "%s: potential IRQ problem with %s and %s\n",
887 hwif->name, new->name, m->name); 880 hwif->name, new->name, m->name);
888 } 881 }
889 if (!m || m->irq != hwif->irq) /* don't undo a prior perfect match */ 882 if (!m || m->irq != hwif->irq) /* don't undo a prior perfect match */
@@ -1142,17 +1135,17 @@ static int init_irq (ide_hwif_t *hwif)
1142 } 1135 }
1143 1136
1144#if !defined(__mc68000__) 1137#if !defined(__mc68000__)
1145 printk("%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, 1138 printk(KERN_INFO "%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name,
1146 io_ports->data_addr, io_ports->status_addr, 1139 io_ports->data_addr, io_ports->status_addr,
1147 io_ports->ctl_addr, hwif->irq); 1140 io_ports->ctl_addr, hwif->irq);
1148#else 1141#else
1149 printk("%s at 0x%08lx on irq %d", hwif->name, 1142 printk(KERN_INFO "%s at 0x%08lx on irq %d", hwif->name,
1150 io_ports->data_addr, hwif->irq); 1143 io_ports->data_addr, hwif->irq);
1151#endif /* __mc68000__ */ 1144#endif /* __mc68000__ */
1152 if (match) 1145 if (match)
1153 printk(" (%sed with %s)", 1146 printk(KERN_CONT " (%sed with %s)",
1154 hwif->sharing_irq ? "shar" : "serializ", match->name); 1147 hwif->sharing_irq ? "shar" : "serializ", match->name);
1155 printk("\n"); 1148 printk(KERN_CONT "\n");
1156 1149
1157 mutex_unlock(&ide_cfg_mtx); 1150 mutex_unlock(&ide_cfg_mtx);
1158 return 0; 1151 return 0;
@@ -1287,7 +1280,7 @@ static int hwif_init(ide_hwif_t *hwif)
1287 if (!hwif->irq) { 1280 if (!hwif->irq) {
1288 hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); 1281 hwif->irq = __ide_default_irq(hwif->io_ports.data_addr);
1289 if (!hwif->irq) { 1282 if (!hwif->irq) {
1290 printk("%s: DISABLED, NO IRQ\n", hwif->name); 1283 printk(KERN_ERR "%s: disabled, no IRQ\n", hwif->name);
1291 return 0; 1284 return 0;
1292 } 1285 }
1293 } 1286 }
@@ -1317,16 +1310,16 @@ static int hwif_init(ide_hwif_t *hwif)
1317 */ 1310 */
1318 hwif->irq = __ide_default_irq(hwif->io_ports.data_addr); 1311 hwif->irq = __ide_default_irq(hwif->io_ports.data_addr);
1319 if (!hwif->irq) { 1312 if (!hwif->irq) {
1320 printk("%s: Disabled unable to get IRQ %d.\n", 1313 printk(KERN_ERR "%s: disabled, unable to get IRQ %d\n",
1321 hwif->name, old_irq); 1314 hwif->name, old_irq);
1322 goto out; 1315 goto out;
1323 } 1316 }
1324 if (init_irq(hwif)) { 1317 if (init_irq(hwif)) {
1325 printk("%s: probed IRQ %d and default IRQ %d failed.\n", 1318 printk(KERN_ERR "%s: probed IRQ %d and default IRQ %d failed\n",
1326 hwif->name, old_irq, hwif->irq); 1319 hwif->name, old_irq, hwif->irq);
1327 goto out; 1320 goto out;
1328 } 1321 }
1329 printk("%s: probed IRQ %d failed, using default.\n", 1322 printk(KERN_WARNING "%s: probed IRQ %d failed, using default\n",
1330 hwif->name, hwif->irq); 1323 hwif->name, hwif->irq);
1331 1324
1332done: 1325done:
@@ -1595,6 +1588,8 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *d,
1595 1588
1596 ide_init_port_data(hwif, idx); 1589 ide_init_port_data(hwif, idx);
1597 1590
1591 hwif->host = host;
1592
1598 host->ports[i] = hwif; 1593 host->ports[i] = hwif;
1599 host->n_ports++; 1594 host->n_ports++;
1600 } 1595 }
@@ -1604,6 +1599,12 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *d,
1604 return NULL; 1599 return NULL;
1605 } 1600 }
1606 1601
1602 if (hws[0])
1603 host->dev[0] = hws[0]->dev;
1604
1605 if (d)
1606 host->host_flags = d->host_flags;
1607
1607 return host; 1608 return host;
1608} 1609}
1609EXPORT_SYMBOL_GPL(ide_host_alloc_all); 1610EXPORT_SYMBOL_GPL(ide_host_alloc_all);
diff --git a/drivers/ide/ide-proc.c b/drivers/ide/ide-proc.c
index 151c91e933da..f66c9c3f6fc6 100644
--- a/drivers/ide/ide-proc.c
+++ b/drivers/ide/ide-proc.c
@@ -105,7 +105,7 @@ static int proc_ide_read_identify
105 len = sprintf(page, "\n"); 105 len = sprintf(page, "\n");
106 106
107 if (drive) { 107 if (drive) {
108 unsigned short *val = (unsigned short *) page; 108 __le16 *val = (__le16 *)page;
109 109
110 err = taskfile_lib_get_identify(drive, page); 110 err = taskfile_lib_get_identify(drive, page);
111 if (!err) { 111 if (!err) {
@@ -113,7 +113,7 @@ static int proc_ide_read_identify
113 page = out; 113 page = out;
114 do { 114 do {
115 out += sprintf(out, "%04x%c", 115 out += sprintf(out, "%04x%c",
116 le16_to_cpu(*val), (++i & 7) ? ' ' : '\n'); 116 le16_to_cpup(val), (++i & 7) ? ' ' : '\n');
117 val += 1; 117 val += 1;
118 } while (i < (SECTOR_WORDS * 2)); 118 } while (i < (SECTOR_WORDS * 2));
119 len = out - page; 119 len = out - page;
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c
index 6962ca4891a1..82c2afe4d28a 100644
--- a/drivers/ide/ide-tape.c
+++ b/drivers/ide/ide-tape.c
@@ -322,23 +322,29 @@ static struct class *idetape_sysfs_class;
322#define ide_tape_g(disk) \ 322#define ide_tape_g(disk) \
323 container_of((disk)->private_data, struct ide_tape_obj, driver) 323 container_of((disk)->private_data, struct ide_tape_obj, driver)
324 324
325static void ide_tape_release(struct kref *);
326
325static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) 327static struct ide_tape_obj *ide_tape_get(struct gendisk *disk)
326{ 328{
327 struct ide_tape_obj *tape = NULL; 329 struct ide_tape_obj *tape = NULL;
328 330
329 mutex_lock(&idetape_ref_mutex); 331 mutex_lock(&idetape_ref_mutex);
330 tape = ide_tape_g(disk); 332 tape = ide_tape_g(disk);
331 if (tape) 333 if (tape) {
332 kref_get(&tape->kref); 334 kref_get(&tape->kref);
335 if (ide_device_get(tape->drive)) {
336 kref_put(&tape->kref, ide_tape_release);
337 tape = NULL;
338 }
339 }
333 mutex_unlock(&idetape_ref_mutex); 340 mutex_unlock(&idetape_ref_mutex);
334 return tape; 341 return tape;
335} 342}
336 343
337static void ide_tape_release(struct kref *);
338
339static void ide_tape_put(struct ide_tape_obj *tape) 344static void ide_tape_put(struct ide_tape_obj *tape)
340{ 345{
341 mutex_lock(&idetape_ref_mutex); 346 mutex_lock(&idetape_ref_mutex);
347 ide_device_put(tape->drive);
342 kref_put(&tape->kref, ide_tape_release); 348 kref_put(&tape->kref, ide_tape_release);
343 mutex_unlock(&idetape_ref_mutex); 349 mutex_unlock(&idetape_ref_mutex);
344} 350}
@@ -649,10 +655,10 @@ static void ide_tape_callback(ide_drive_t *drive)
649 uptodate = 0; 655 uptodate = 0;
650 } else { 656 } else {
651 debug_log(DBG_SENSE, "Block Location - %u\n", 657 debug_log(DBG_SENSE, "Block Location - %u\n",
652 be32_to_cpu(*(u32 *)&readpos[4])); 658 be32_to_cpup((__be32 *)&readpos[4]));
653 659
654 tape->partition = readpos[1]; 660 tape->partition = readpos[1];
655 tape->first_frame = be32_to_cpu(*(u32 *)&readpos[4]); 661 tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]);
656 set_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); 662 set_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags);
657 } 663 }
658 } 664 }
@@ -2375,23 +2381,23 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive)
2375 caps = pc.buf + 4 + pc.buf[3]; 2381 caps = pc.buf + 4 + pc.buf[3];
2376 2382
2377 /* convert to host order and save for later use */ 2383 /* convert to host order and save for later use */
2378 speed = be16_to_cpu(*(u16 *)&caps[14]); 2384 speed = be16_to_cpup((__be16 *)&caps[14]);
2379 max_speed = be16_to_cpu(*(u16 *)&caps[8]); 2385 max_speed = be16_to_cpup((__be16 *)&caps[8]);
2380 2386
2381 put_unaligned(max_speed, (u16 *)&caps[8]); 2387 *(u16 *)&caps[8] = max_speed;
2382 put_unaligned(be16_to_cpu(*(u16 *)&caps[12]), (u16 *)&caps[12]); 2388 *(u16 *)&caps[12] = be16_to_cpup((__be16 *)&caps[12]);
2383 put_unaligned(speed, (u16 *)&caps[14]); 2389 *(u16 *)&caps[14] = speed;
2384 put_unaligned(be16_to_cpu(*(u16 *)&caps[16]), (u16 *)&caps[16]); 2390 *(u16 *)&caps[16] = be16_to_cpup((__be16 *)&caps[16]);
2385 2391
2386 if (!speed) { 2392 if (!speed) {
2387 printk(KERN_INFO "ide-tape: %s: invalid tape speed " 2393 printk(KERN_INFO "ide-tape: %s: invalid tape speed "
2388 "(assuming 650KB/sec)\n", drive->name); 2394 "(assuming 650KB/sec)\n", drive->name);
2389 put_unaligned(650, (u16 *)&caps[14]); 2395 *(u16 *)&caps[14] = 650;
2390 } 2396 }
2391 if (!max_speed) { 2397 if (!max_speed) {
2392 printk(KERN_INFO "ide-tape: %s: invalid max_speed " 2398 printk(KERN_INFO "ide-tape: %s: invalid max_speed "
2393 "(assuming 650KB/sec)\n", drive->name); 2399 "(assuming 650KB/sec)\n", drive->name);
2394 put_unaligned(650, (u16 *)&caps[8]); 2400 *(u16 *)&caps[8] = 650;
2395 } 2401 }
2396 2402
2397 memcpy(&tape->caps, caps, 20); 2403 memcpy(&tape->caps, caps, 20);
diff --git a/drivers/ide/ide-taskfile.c b/drivers/ide/ide-taskfile.c
index aeddbbd69e86..7fb6f1c86272 100644
--- a/drivers/ide/ide-taskfile.c
+++ b/drivers/ide/ide-taskfile.c
@@ -126,7 +126,10 @@ EXPORT_SYMBOL_GPL(do_rw_taskfile);
126static ide_startstop_t set_multmode_intr(ide_drive_t *drive) 126static ide_startstop_t set_multmode_intr(ide_drive_t *drive)
127{ 127{
128 ide_hwif_t *hwif = drive->hwif; 128 ide_hwif_t *hwif = drive->hwif;
129 u8 stat = hwif->tp_ops->read_status(hwif); 129 u8 stat;
130
131 local_irq_enable_in_hardirq();
132 stat = hwif->tp_ops->read_status(hwif);
130 133
131 if (OK_STAT(stat, READY_STAT, BAD_STAT)) 134 if (OK_STAT(stat, READY_STAT, BAD_STAT))
132 drive->mult_count = drive->mult_req; 135 drive->mult_count = drive->mult_req;
@@ -147,6 +150,8 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive)
147 int retries = 5; 150 int retries = 5;
148 u8 stat; 151 u8 stat;
149 152
153 local_irq_enable_in_hardirq();
154
150 while (1) { 155 while (1) {
151 stat = hwif->tp_ops->read_status(hwif); 156 stat = hwif->tp_ops->read_status(hwif);
152 if ((stat & BUSY_STAT) == 0 || retries-- == 0) 157 if ((stat & BUSY_STAT) == 0 || retries-- == 0)
@@ -170,7 +175,10 @@ static ide_startstop_t set_geometry_intr(ide_drive_t *drive)
170static ide_startstop_t recal_intr(ide_drive_t *drive) 175static ide_startstop_t recal_intr(ide_drive_t *drive)
171{ 176{
172 ide_hwif_t *hwif = drive->hwif; 177 ide_hwif_t *hwif = drive->hwif;
173 u8 stat = hwif->tp_ops->read_status(hwif); 178 u8 stat;
179
180 local_irq_enable_in_hardirq();
181 stat = hwif->tp_ops->read_status(hwif);
174 182
175 if (!OK_STAT(stat, READY_STAT, BAD_STAT)) 183 if (!OK_STAT(stat, READY_STAT, BAD_STAT))
176 return ide_error(drive, "recal_intr", stat); 184 return ide_error(drive, "recal_intr", stat);
diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c
index 60f0ca66aa93..772451600e4d 100644
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -618,6 +618,53 @@ set_val:
618 618
619EXPORT_SYMBOL(generic_ide_ioctl); 619EXPORT_SYMBOL(generic_ide_ioctl);
620 620
621/**
622 * ide_device_get - get an additional reference to a ide_drive_t
623 * @drive: device to get a reference to
624 *
625 * Gets a reference to the ide_drive_t and increments the use count of the
626 * underlying LLDD module.
627 */
628int ide_device_get(ide_drive_t *drive)
629{
630 struct device *host_dev;
631 struct module *module;
632
633 if (!get_device(&drive->gendev))
634 return -ENXIO;
635
636 host_dev = drive->hwif->host->dev[0];
637 module = host_dev ? host_dev->driver->owner : NULL;
638
639 if (module && !try_module_get(module)) {
640 put_device(&drive->gendev);
641 return -ENXIO;
642 }
643
644 return 0;
645}
646EXPORT_SYMBOL_GPL(ide_device_get);
647
648/**
649 * ide_device_put - release a reference to a ide_drive_t
650 * @drive: device to release a reference on
651 *
652 * Release a reference to the ide_drive_t and decrements the use count of
653 * the underlying LLDD module.
654 */
655void ide_device_put(ide_drive_t *drive)
656{
657#ifdef CONFIG_MODULE_UNLOAD
658 struct device *host_dev = drive->hwif->host->dev[0];
659 struct module *module = host_dev ? host_dev->driver->owner : NULL;
660
661 if (module)
662 module_put(module);
663#endif
664 put_device(&drive->gendev);
665}
666EXPORT_SYMBOL_GPL(ide_device_put);
667
621static int ide_bus_match(struct device *dev, struct device_driver *drv) 668static int ide_bus_match(struct device *dev, struct device_driver *drv)
622{ 669{
623 return 1; 670 return 1;
diff --git a/drivers/ide/legacy/gayle.c b/drivers/ide/legacy/gayle.c
index dd5c467d8dd0..51ba085d7aa8 100644
--- a/drivers/ide/legacy/gayle.c
+++ b/drivers/ide/legacy/gayle.c
@@ -127,7 +127,7 @@ static int __init gayle_init(void)
127 unsigned long phys_base, res_start, res_n; 127 unsigned long phys_base, res_start, res_n;
128 unsigned long base, ctrlport, irqport; 128 unsigned long base, ctrlport, irqport;
129 ide_ack_intr_t *ack_intr; 129 ide_ack_intr_t *ack_intr;
130 int a4000, i; 130 int a4000, i, rc;
131 hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL }; 131 hw_regs_t hw[GAYLE_NUM_HWIFS], *hws[] = { NULL, NULL, NULL, NULL };
132 132
133 if (!MACH_IS_AMIGA) 133 if (!MACH_IS_AMIGA)
@@ -179,7 +179,11 @@ found:
179 hws[i] = &hw[i]; 179 hws[i] = &hw[i];
180 } 180 }
181 181
182 return ide_host_add(NULL, hws, NULL); 182 rc = ide_host_add(NULL, hws, NULL);
183 if (rc)
184 release_mem_region(res_start, res_n);
185
186 return rc;
183} 187}
184 188
185module_init(gayle_init); 189module_init(gayle_init);
diff --git a/drivers/ide/legacy/ht6560b.c b/drivers/ide/legacy/ht6560b.c
index 7bc8fd59ea9e..98f7c95e39ed 100644
--- a/drivers/ide/legacy/ht6560b.c
+++ b/drivers/ide/legacy/ht6560b.c
@@ -3,34 +3,12 @@
3 */ 3 */
4 4
5/* 5/*
6 *
7 * Version 0.01 Initial version hacked out of ide.c
8 *
9 * Version 0.02 Added support for PIO modes, auto-tune
10 *
11 * Version 0.03 Some cleanups
12 *
13 * Version 0.05 PIO mode cycle timings auto-tune using bus-speed
14 *
15 * Version 0.06 Prefetch mode now defaults no OFF. To set
16 * prefetch mode OFF/ON use "hdparm -p8/-p9".
17 * Unmask irq is disabled when prefetch mode
18 * is enabled.
19 *
20 * Version 0.07 Trying to fix CD-ROM detection problem.
21 * "Prefetch" mode bit OFF for ide disks and
22 * ON for anything else.
23 *
24 * Version 0.08 Need to force prefetch for CDs and other non-disk
25 * devices. (not sure which devices exactly need
26 * prefetch)
27 *
28 * HT-6560B EIDE-controller support 6 * HT-6560B EIDE-controller support
29 * To activate controller support use kernel parameter "ide0=ht6560b". 7 * To activate controller support use kernel parameter "ide0=ht6560b".
30 * Use hdparm utility to enable PIO mode support. 8 * Use hdparm utility to enable PIO mode support.
31 * 9 *
32 * Author: Mikko Ala-Fossi <maf@iki.fi> 10 * Author: Mikko Ala-Fossi <maf@iki.fi>
33 * Jan Evert van Grootheest <janevert@caiway.nl> 11 * Jan Evert van Grootheest <j.e.van.grootheest@caiway.nl>
34 * 12 *
35 * Try: http://www.maf.iki.fi/~maf/ht6560b/ 13 * Try: http://www.maf.iki.fi/~maf/ht6560b/
36 */ 14 */
diff --git a/drivers/ide/pci/aec62xx.c b/drivers/ide/pci/aec62xx.c
index fbc43e121e6b..e0c8fe7d9fea 100644
--- a/drivers/ide/pci/aec62xx.c
+++ b/drivers/ide/pci/aec62xx.c
@@ -13,6 +13,8 @@
13 13
14#include <asm/io.h> 14#include <asm/io.h>
15 15
16#define DRV_NAME "aec62xx"
17
16struct chipset_bus_clock_list_entry { 18struct chipset_bus_clock_list_entry {
17 u8 xfer_speed; 19 u8 xfer_speed;
18 u8 chipset_settings; 20 u8 chipset_settings;
@@ -59,10 +61,6 @@ static const struct chipset_bus_clock_list_entry aec6xxx_34_base [] = {
59 { 0, 0x00, 0x00 } 61 { 0, 0x00, 0x00 }
60}; 62};
61 63
62#define BUSCLOCK(D) \
63 ((struct chipset_bus_clock_list_entry *) pci_get_drvdata((D)))
64
65
66/* 64/*
67 * TO DO: active tuning and correction of cards without a bios. 65 * TO DO: active tuning and correction of cards without a bios.
68 */ 66 */
@@ -88,6 +86,8 @@ static void aec6210_set_mode(ide_drive_t *drive, const u8 speed)
88{ 86{
89 ide_hwif_t *hwif = HWIF(drive); 87 ide_hwif_t *hwif = HWIF(drive);
90 struct pci_dev *dev = to_pci_dev(hwif->dev); 88 struct pci_dev *dev = to_pci_dev(hwif->dev);
89 struct ide_host *host = pci_get_drvdata(dev);
90 struct chipset_bus_clock_list_entry *bus_clock = host->host_priv;
91 u16 d_conf = 0; 91 u16 d_conf = 0;
92 u8 ultra = 0, ultra_conf = 0; 92 u8 ultra = 0, ultra_conf = 0;
93 u8 tmp0 = 0, tmp1 = 0, tmp2 = 0; 93 u8 tmp0 = 0, tmp1 = 0, tmp2 = 0;
@@ -96,7 +96,7 @@ static void aec6210_set_mode(ide_drive_t *drive, const u8 speed)
96 local_irq_save(flags); 96 local_irq_save(flags);
97 /* 0x40|(2*drive->dn): Active, 0x41|(2*drive->dn): Recovery */ 97 /* 0x40|(2*drive->dn): Active, 0x41|(2*drive->dn): Recovery */
98 pci_read_config_word(dev, 0x40|(2*drive->dn), &d_conf); 98 pci_read_config_word(dev, 0x40|(2*drive->dn), &d_conf);
99 tmp0 = pci_bus_clock_list(speed, BUSCLOCK(dev)); 99 tmp0 = pci_bus_clock_list(speed, bus_clock);
100 d_conf = ((tmp0 & 0xf0) << 4) | (tmp0 & 0xf); 100 d_conf = ((tmp0 & 0xf0) << 4) | (tmp0 & 0xf);
101 pci_write_config_word(dev, 0x40|(2*drive->dn), d_conf); 101 pci_write_config_word(dev, 0x40|(2*drive->dn), d_conf);
102 102
@@ -104,7 +104,7 @@ static void aec6210_set_mode(ide_drive_t *drive, const u8 speed)
104 tmp2 = 0x00; 104 tmp2 = 0x00;
105 pci_read_config_byte(dev, 0x54, &ultra); 105 pci_read_config_byte(dev, 0x54, &ultra);
106 tmp1 = ((0x00 << (2*drive->dn)) | (ultra & ~(3 << (2*drive->dn)))); 106 tmp1 = ((0x00 << (2*drive->dn)) | (ultra & ~(3 << (2*drive->dn))));
107 ultra_conf = pci_bus_clock_list_ultra(speed, BUSCLOCK(dev)); 107 ultra_conf = pci_bus_clock_list_ultra(speed, bus_clock);
108 tmp2 = ((ultra_conf << (2*drive->dn)) | (tmp1 & ~(3 << (2*drive->dn)))); 108 tmp2 = ((ultra_conf << (2*drive->dn)) | (tmp1 & ~(3 << (2*drive->dn))));
109 pci_write_config_byte(dev, 0x54, tmp2); 109 pci_write_config_byte(dev, 0x54, tmp2);
110 local_irq_restore(flags); 110 local_irq_restore(flags);
@@ -114,6 +114,8 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed)
114{ 114{
115 ide_hwif_t *hwif = HWIF(drive); 115 ide_hwif_t *hwif = HWIF(drive);
116 struct pci_dev *dev = to_pci_dev(hwif->dev); 116 struct pci_dev *dev = to_pci_dev(hwif->dev);
117 struct ide_host *host = pci_get_drvdata(dev);
118 struct chipset_bus_clock_list_entry *bus_clock = host->host_priv;
117 u8 unit = (drive->select.b.unit & 0x01); 119 u8 unit = (drive->select.b.unit & 0x01);
118 u8 tmp1 = 0, tmp2 = 0; 120 u8 tmp1 = 0, tmp2 = 0;
119 u8 ultra = 0, drive_conf = 0, ultra_conf = 0; 121 u8 ultra = 0, drive_conf = 0, ultra_conf = 0;
@@ -122,12 +124,12 @@ static void aec6260_set_mode(ide_drive_t *drive, const u8 speed)
122 local_irq_save(flags); 124 local_irq_save(flags);
123 /* high 4-bits: Active, low 4-bits: Recovery */ 125 /* high 4-bits: Active, low 4-bits: Recovery */
124 pci_read_config_byte(dev, 0x40|drive->dn, &drive_conf); 126 pci_read_config_byte(dev, 0x40|drive->dn, &drive_conf);
125 drive_conf = pci_bus_clock_list(speed, BUSCLOCK(dev)); 127 drive_conf = pci_bus_clock_list(speed, bus_clock);
126 pci_write_config_byte(dev, 0x40|drive->dn, drive_conf); 128 pci_write_config_byte(dev, 0x40|drive->dn, drive_conf);
127 129
128 pci_read_config_byte(dev, (0x44|hwif->channel), &ultra); 130 pci_read_config_byte(dev, (0x44|hwif->channel), &ultra);
129 tmp1 = ((0x00 << (4*unit)) | (ultra & ~(7 << (4*unit)))); 131 tmp1 = ((0x00 << (4*unit)) | (ultra & ~(7 << (4*unit))));
130 ultra_conf = pci_bus_clock_list_ultra(speed, BUSCLOCK(dev)); 132 ultra_conf = pci_bus_clock_list_ultra(speed, bus_clock);
131 tmp2 = ((ultra_conf << (4*unit)) | (tmp1 & ~(7 << (4*unit)))); 133 tmp2 = ((ultra_conf << (4*unit)) | (tmp1 & ~(7 << (4*unit))));
132 pci_write_config_byte(dev, (0x44|hwif->channel), tmp2); 134 pci_write_config_byte(dev, (0x44|hwif->channel), tmp2);
133 local_irq_restore(flags); 135 local_irq_restore(flags);
@@ -138,15 +140,8 @@ static void aec_set_pio_mode(ide_drive_t *drive, const u8 pio)
138 drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0); 140 drive->hwif->port_ops->set_dma_mode(drive, pio + XFER_PIO_0);
139} 141}
140 142
141static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev, const char *name) 143static unsigned int __devinit init_chipset_aec62xx(struct pci_dev *dev)
142{ 144{
143 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
144
145 if (bus_speed <= 33)
146 pci_set_drvdata(dev, (void *) aec6xxx_33_base);
147 else
148 pci_set_drvdata(dev, (void *) aec6xxx_34_base);
149
150 /* These are necessary to get AEC6280 Macintosh cards to work */ 145 /* These are necessary to get AEC6280 Macintosh cards to work */
151 if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) || 146 if ((dev->device == PCI_DEVICE_ID_ARTOP_ATP865) ||
152 (dev->device == PCI_DEVICE_ID_ARTOP_ATP865R)) { 147 (dev->device == PCI_DEVICE_ID_ARTOP_ATP865R)) {
@@ -187,8 +182,8 @@ static const struct ide_port_ops atp86x_port_ops = {
187}; 182};
188 183
189static const struct ide_port_info aec62xx_chipsets[] __devinitdata = { 184static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
190 { /* 0 */ 185 { /* 0: AEC6210 */
191 .name = "AEC6210", 186 .name = DRV_NAME,
192 .init_chipset = init_chipset_aec62xx, 187 .init_chipset = init_chipset_aec62xx,
193 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 188 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
194 .port_ops = &atp850_port_ops, 189 .port_ops = &atp850_port_ops,
@@ -199,8 +194,9 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
199 .pio_mask = ATA_PIO4, 194 .pio_mask = ATA_PIO4,
200 .mwdma_mask = ATA_MWDMA2, 195 .mwdma_mask = ATA_MWDMA2,
201 .udma_mask = ATA_UDMA2, 196 .udma_mask = ATA_UDMA2,
202 },{ /* 1 */ 197 },
203 .name = "AEC6260", 198 { /* 1: AEC6260 */
199 .name = DRV_NAME,
204 .init_chipset = init_chipset_aec62xx, 200 .init_chipset = init_chipset_aec62xx,
205 .port_ops = &atp86x_port_ops, 201 .port_ops = &atp86x_port_ops,
206 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA | 202 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | IDE_HFLAG_NO_AUTODMA |
@@ -208,8 +204,9 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
208 .pio_mask = ATA_PIO4, 204 .pio_mask = ATA_PIO4,
209 .mwdma_mask = ATA_MWDMA2, 205 .mwdma_mask = ATA_MWDMA2,
210 .udma_mask = ATA_UDMA4, 206 .udma_mask = ATA_UDMA4,
211 },{ /* 2 */ 207 },
212 .name = "AEC6260R", 208 { /* 2: AEC6260R */
209 .name = DRV_NAME,
213 .init_chipset = init_chipset_aec62xx, 210 .init_chipset = init_chipset_aec62xx,
214 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 211 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
215 .port_ops = &atp86x_port_ops, 212 .port_ops = &atp86x_port_ops,
@@ -218,8 +215,9 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
218 .pio_mask = ATA_PIO4, 215 .pio_mask = ATA_PIO4,
219 .mwdma_mask = ATA_MWDMA2, 216 .mwdma_mask = ATA_MWDMA2,
220 .udma_mask = ATA_UDMA4, 217 .udma_mask = ATA_UDMA4,
221 },{ /* 3 */ 218 },
222 .name = "AEC6280", 219 { /* 3: AEC6280 */
220 .name = DRV_NAME,
223 .init_chipset = init_chipset_aec62xx, 221 .init_chipset = init_chipset_aec62xx,
224 .port_ops = &atp86x_port_ops, 222 .port_ops = &atp86x_port_ops,
225 .host_flags = IDE_HFLAG_NO_ATAPI_DMA | 223 .host_flags = IDE_HFLAG_NO_ATAPI_DMA |
@@ -227,8 +225,9 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
227 .pio_mask = ATA_PIO4, 225 .pio_mask = ATA_PIO4,
228 .mwdma_mask = ATA_MWDMA2, 226 .mwdma_mask = ATA_MWDMA2,
229 .udma_mask = ATA_UDMA5, 227 .udma_mask = ATA_UDMA5,
230 },{ /* 4 */ 228 },
231 .name = "AEC6280R", 229 { /* 4: AEC6280R */
230 .name = DRV_NAME,
232 .init_chipset = init_chipset_aec62xx, 231 .init_chipset = init_chipset_aec62xx,
233 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}}, 232 .enablebits = {{0x4a,0x02,0x02}, {0x4a,0x04,0x04}},
234 .port_ops = &atp86x_port_ops, 233 .port_ops = &atp86x_port_ops,
@@ -254,10 +253,17 @@ static const struct ide_port_info aec62xx_chipsets[] __devinitdata = {
254 253
255static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_device_id *id) 254static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_device_id *id)
256{ 255{
256 const struct chipset_bus_clock_list_entry *bus_clock;
257 struct ide_port_info d; 257 struct ide_port_info d;
258 u8 idx = id->driver_data; 258 u8 idx = id->driver_data;
259 int bus_speed = ide_pci_clk ? ide_pci_clk : 33;
259 int err; 260 int err;
260 261
262 if (bus_speed <= 33)
263 bus_clock = aec6xxx_33_base;
264 else
265 bus_clock = aec6xxx_34_base;
266
261 err = pci_enable_device(dev); 267 err = pci_enable_device(dev);
262 if (err) 268 if (err)
263 return err; 269 return err;
@@ -268,18 +274,25 @@ static int __devinit aec62xx_init_one(struct pci_dev *dev, const struct pci_devi
268 unsigned long dma_base = pci_resource_start(dev, 4); 274 unsigned long dma_base = pci_resource_start(dev, 4);
269 275
270 if (inb(dma_base + 2) & 0x10) { 276 if (inb(dma_base + 2) & 0x10) {
271 d.name = (idx == 4) ? "AEC6880R" : "AEC6880"; 277 printk(KERN_INFO DRV_NAME " %s: AEC6880%s card detected"
278 "\n", pci_name(dev), (idx == 4) ? "R" : "");
272 d.udma_mask = ATA_UDMA6; 279 d.udma_mask = ATA_UDMA6;
273 } 280 }
274 } 281 }
275 282
276 err = ide_setup_pci_device(dev, &d); 283 err = ide_pci_init_one(dev, &d, (void *)bus_clock);
277 if (err) 284 if (err)
278 pci_disable_device(dev); 285 pci_disable_device(dev);
279 286
280 return err; 287 return err;
281} 288}
282 289
290static void __devexit aec62xx_remove(struct pci_dev *dev)
291{
292 ide_pci_remove(dev);
293 pci_disable_device(dev);
294}
295
283static const struct pci_device_id aec62xx_pci_tbl[] = { 296static const struct pci_device_id aec62xx_pci_tbl[] = {
284 { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF), 0 }, 297 { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP850UF), 0 },
285 { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP860), 1 }, 298 { PCI_VDEVICE(ARTOP, PCI_DEVICE_ID_ARTOP_ATP860), 1 },
@@ -294,6 +307,7 @@ static struct pci_driver driver = {
294 .name = "AEC62xx_IDE", 307 .name = "AEC62xx_IDE",
295 .id_table = aec62xx_pci_tbl, 308 .id_table = aec62xx_pci_tbl,
296 .probe = aec62xx_init_one, 309 .probe = aec62xx_init_one,
310 .remove = aec62xx_remove,
297}; 311};
298 312
299static int __init aec62xx_ide_init(void) 313static int __init aec62xx_ide_init(void)
@@ -301,7 +315,13 @@ static int __init aec62xx_ide_init(void)
301 return ide_pci_register_driver(&driver); 315 return ide_pci_register_driver(&driver);
302} 316}
303 317
318static void __exit aec62xx_ide_exit(void)
319{
320 pci_unregister_driver(&driver);
321}
322
304module_init(aec62xx_ide_init); 323module_init(aec62xx_ide_init);
324module_exit(aec62xx_ide_exit);
305 325
306MODULE_AUTHOR("Andre Hedrick"); 326MODULE_AUTHOR("Andre Hedrick");
307MODULE_DESCRIPTION("PCI driver module for ARTOP AEC62xx IDE"); 327MODULE_DESCRIPTION("PCI driver module for ARTOP AEC62xx IDE");
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c
index 5ef7817ac64f..b582687e0cd4 100644
--- a/drivers/ide/pci/alim15x3.c
+++ b/drivers/ide/pci/alim15x3.c
@@ -38,6 +38,8 @@
38 38
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#define DRV_NAME "alim15x3"
42
41/* 43/*
42 * Allow UDMA on M1543C-E chipset for WDC disks that ignore CRC checking 44 * Allow UDMA on M1543C-E chipset for WDC disks that ignore CRC checking
43 * (this is DANGEROUS and could result in data corruption). 45 * (this is DANGEROUS and could result in data corruption).
@@ -207,13 +209,12 @@ static int ali15x3_dma_setup(ide_drive_t *drive)
207/** 209/**
208 * init_chipset_ali15x3 - Initialise an ALi IDE controller 210 * init_chipset_ali15x3 - Initialise an ALi IDE controller
209 * @dev: PCI device 211 * @dev: PCI device
210 * @name: Name of the controller
211 * 212 *
212 * This function initializes the ALI IDE controller and where 213 * This function initializes the ALI IDE controller and where
213 * appropriate also sets up the 1533 southbridge. 214 * appropriate also sets up the 1533 southbridge.
214 */ 215 */
215 216
216static unsigned int __devinit init_chipset_ali15x3 (struct pci_dev *dev, const char *name) 217static unsigned int __devinit init_chipset_ali15x3(struct pci_dev *dev)
217{ 218{
218 unsigned long flags; 219 unsigned long flags;
219 u8 tmpbyte; 220 u8 tmpbyte;
@@ -515,7 +516,7 @@ static const struct ide_dma_ops ali_dma_ops = {
515}; 516};
516 517
517static const struct ide_port_info ali15x3_chipset __devinitdata = { 518static const struct ide_port_info ali15x3_chipset __devinitdata = {
518 .name = "ALI15X3", 519 .name = DRV_NAME,
519 .init_chipset = init_chipset_ali15x3, 520 .init_chipset = init_chipset_ali15x3,
520 .init_hwif = init_hwif_ali15x3, 521 .init_hwif = init_hwif_ali15x3,
521 .init_dma = init_dma_ali15x3, 522 .init_dma = init_dma_ali15x3,
@@ -565,7 +566,7 @@ static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_dev
565 if (idx == 0) 566 if (idx == 0)
566 d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; 567 d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX;
567 568
568 return ide_setup_pci_device(dev, &d); 569 return ide_pci_init_one(dev, &d, NULL);
569} 570}
570 571
571 572
@@ -580,6 +581,7 @@ static struct pci_driver driver = {
580 .name = "ALI15x3_IDE", 581 .name = "ALI15x3_IDE",
581 .id_table = alim15x3_pci_tbl, 582 .id_table = alim15x3_pci_tbl,
582 .probe = alim15x3_init_one, 583 .probe = alim15x3_init_one,
584 .remove = ide_pci_remove,
583}; 585};
584 586
585static int __init ali15x3_ide_init(void) 587static int __init ali15x3_ide_init(void)
@@ -587,7 +589,13 @@ static int __init ali15x3_ide_init(void)
587 return ide_pci_register_driver(&driver); 589 return ide_pci_register_driver(&driver);
588} 590}
589 591
592static void __exit ali15x3_ide_exit(void)
593{
594 return pci_unregister_driver(&driver);
595}
596
590module_init(ali15x3_ide_init); 597module_init(ali15x3_ide_init);
598module_exit(ali15x3_ide_exit);
591 599
592MODULE_AUTHOR("Michael Aubry, Andrzej Krzysztofowicz, CJ, Andre Hedrick, Alan Cox"); 600MODULE_AUTHOR("Michael Aubry, Andrzej Krzysztofowicz, CJ, Andre Hedrick, Alan Cox");
593MODULE_DESCRIPTION("PCI driver module for ALi 15x3 IDE"); 601MODULE_DESCRIPTION("PCI driver module for ALi 15x3 IDE");
diff --git a/drivers/ide/pci/amd74xx.c b/drivers/ide/pci/amd74xx.c
index ef7d971031ee..2cea7bf51a0f 100644
--- a/drivers/ide/pci/amd74xx.c
+++ b/drivers/ide/pci/amd74xx.c
@@ -21,6 +21,8 @@
21#include <linux/init.h> 21#include <linux/init.h>
22#include <linux/ide.h> 22#include <linux/ide.h>
23 23
24#define DRV_NAME "amd74xx"
25
24enum { 26enum {
25 AMD_IDE_CONFIG = 0x41, 27 AMD_IDE_CONFIG = 0x41,
26 AMD_CABLE_DETECT = 0x42, 28 AMD_CABLE_DETECT = 0x42,
@@ -110,15 +112,13 @@ static void amd_set_pio_mode(ide_drive_t *drive, const u8 pio)
110 amd_set_drive(drive, XFER_PIO_0 + pio); 112 amd_set_drive(drive, XFER_PIO_0 + pio);
111} 113}
112 114
113static void __devinit amd7409_cable_detect(struct pci_dev *dev, 115static void __devinit amd7409_cable_detect(struct pci_dev *dev)
114 const char *name)
115{ 116{
116 /* no host side cable detection */ 117 /* no host side cable detection */
117 amd_80w = 0x03; 118 amd_80w = 0x03;
118} 119}
119 120
120static void __devinit amd7411_cable_detect(struct pci_dev *dev, 121static void __devinit amd7411_cable_detect(struct pci_dev *dev)
121 const char *name)
122{ 122{
123 int i; 123 int i;
124 u32 u = 0; 124 u32 u = 0;
@@ -129,9 +129,9 @@ static void __devinit amd7411_cable_detect(struct pci_dev *dev,
129 amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0); 129 amd_80w = ((t & 0x3) ? 1 : 0) | ((t & 0xc) ? 2 : 0);
130 for (i = 24; i >= 0; i -= 8) 130 for (i = 24; i >= 0; i -= 8)
131 if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) { 131 if (((u >> i) & 4) && !(amd_80w & (1 << (1 - (i >> 4))))) {
132 printk(KERN_WARNING "%s: BIOS didn't set cable bits " 132 printk(KERN_WARNING DRV_NAME " %s: BIOS didn't set "
133 "correctly. Enabling workaround.\n", 133 "cable bits correctly. Enabling workaround.\n",
134 name); 134 pci_name(dev));
135 amd_80w |= (1 << (1 - (i >> 4))); 135 amd_80w |= (1 << (1 - (i >> 4)));
136 } 136 }
137} 137}
@@ -140,8 +140,7 @@ static void __devinit amd7411_cable_detect(struct pci_dev *dev,
140 * The initialization callback. Initialize drive independent registers. 140 * The initialization callback. Initialize drive independent registers.
141 */ 141 */
142 142
143static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev, 143static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev)
144 const char *name)
145{ 144{
146 u8 t = 0, offset = amd_offset(dev); 145 u8 t = 0, offset = amd_offset(dev);
147 146
@@ -154,9 +153,9 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev,
154 ; /* no UDMA > 2 */ 153 ; /* no UDMA > 2 */
155 else if (dev->vendor == PCI_VENDOR_ID_AMD && 154 else if (dev->vendor == PCI_VENDOR_ID_AMD &&
156 dev->device == PCI_DEVICE_ID_AMD_VIPER_7409) 155 dev->device == PCI_DEVICE_ID_AMD_VIPER_7409)
157 amd7409_cable_detect(dev, name); 156 amd7409_cable_detect(dev);
158 else 157 else
159 amd7411_cable_detect(dev, name); 158 amd7411_cable_detect(dev);
160 159
161/* 160/*
162 * Take care of prefetch & postwrite. 161 * Take care of prefetch & postwrite.
@@ -173,24 +172,6 @@ static unsigned int __devinit init_chipset_amd74xx(struct pci_dev *dev,
173 t |= 0xf0; 172 t |= 0xf0;
174 pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t); 173 pci_write_config_byte(dev, AMD_IDE_CONFIG + offset, t);
175 174
176/*
177 * Determine the system bus clock.
178 */
179
180 amd_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000;
181
182 switch (amd_clock) {
183 case 33000: amd_clock = 33333; break;
184 case 37000: amd_clock = 37500; break;
185 case 41000: amd_clock = 41666; break;
186 }
187
188 if (amd_clock < 20000 || amd_clock > 50000) {
189 printk(KERN_WARNING "%s: User given PCI clock speed impossible (%d), using 33 MHz instead.\n",
190 name, amd_clock);
191 amd_clock = 33333;
192 }
193
194 return dev->irq; 175 return dev->irq;
195} 176}
196 177
@@ -222,9 +203,9 @@ static const struct ide_port_ops amd_port_ops = {
222 IDE_HFLAG_IO_32BIT | \ 203 IDE_HFLAG_IO_32BIT | \
223 IDE_HFLAG_UNMASK_IRQS) 204 IDE_HFLAG_UNMASK_IRQS)
224 205
225#define DECLARE_AMD_DEV(name_str, swdma, udma) \ 206#define DECLARE_AMD_DEV(swdma, udma) \
226 { \ 207 { \
227 .name = name_str, \ 208 .name = DRV_NAME, \
228 .init_chipset = init_chipset_amd74xx, \ 209 .init_chipset = init_chipset_amd74xx, \
229 .init_hwif = init_hwif_amd74xx, \ 210 .init_hwif = init_hwif_amd74xx, \
230 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \ 211 .enablebits = {{0x40,0x02,0x02}, {0x40,0x01,0x01}}, \
@@ -236,9 +217,9 @@ static const struct ide_port_ops amd_port_ops = {
236 .udma_mask = udma, \ 217 .udma_mask = udma, \
237 } 218 }
238 219
239#define DECLARE_NV_DEV(name_str, udma) \ 220#define DECLARE_NV_DEV(udma) \
240 { \ 221 { \
241 .name = name_str, \ 222 .name = DRV_NAME, \
242 .init_chipset = init_chipset_amd74xx, \ 223 .init_chipset = init_chipset_amd74xx, \
243 .init_hwif = init_hwif_amd74xx, \ 224 .init_hwif = init_hwif_amd74xx, \
244 .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \ 225 .enablebits = {{0x50,0x02,0x02}, {0x50,0x01,0x01}}, \
@@ -251,31 +232,15 @@ static const struct ide_port_ops amd_port_ops = {
251 } 232 }
252 233
253static const struct ide_port_info amd74xx_chipsets[] __devinitdata = { 234static const struct ide_port_info amd74xx_chipsets[] __devinitdata = {
254 /* 0 */ DECLARE_AMD_DEV("AMD7401", 0x00, ATA_UDMA2), 235 /* 0: AMD7401 */ DECLARE_AMD_DEV(0x00, ATA_UDMA2),
255 /* 1 */ DECLARE_AMD_DEV("AMD7409", ATA_SWDMA2, ATA_UDMA4), 236 /* 1: AMD7409 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA4),
256 /* 2 */ DECLARE_AMD_DEV("AMD7411", ATA_SWDMA2, ATA_UDMA5), 237 /* 2: AMD7411/7441 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA5),
257 /* 3 */ DECLARE_AMD_DEV("AMD7441", ATA_SWDMA2, ATA_UDMA5), 238 /* 3: AMD8111 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA6),
258 /* 4 */ DECLARE_AMD_DEV("AMD8111", ATA_SWDMA2, ATA_UDMA6), 239
259 240 /* 4: NFORCE */ DECLARE_NV_DEV(ATA_UDMA5),
260 /* 5 */ DECLARE_NV_DEV("NFORCE", ATA_UDMA5), 241 /* 5: >= NFORCE2 */ DECLARE_NV_DEV(ATA_UDMA6),
261 /* 6 */ DECLARE_NV_DEV("NFORCE2", ATA_UDMA6), 242
262 /* 7 */ DECLARE_NV_DEV("NFORCE2-U400R", ATA_UDMA6), 243 /* 6: AMD5536 */ DECLARE_AMD_DEV(ATA_SWDMA2, ATA_UDMA5),
263 /* 8 */ DECLARE_NV_DEV("NFORCE2-U400R-SATA", ATA_UDMA6),
264 /* 9 */ DECLARE_NV_DEV("NFORCE3-150", ATA_UDMA6),
265 /* 10 */ DECLARE_NV_DEV("NFORCE3-250", ATA_UDMA6),
266 /* 11 */ DECLARE_NV_DEV("NFORCE3-250-SATA", ATA_UDMA6),
267 /* 12 */ DECLARE_NV_DEV("NFORCE3-250-SATA2", ATA_UDMA6),
268 /* 13 */ DECLARE_NV_DEV("NFORCE-CK804", ATA_UDMA6),
269 /* 14 */ DECLARE_NV_DEV("NFORCE-MCP04", ATA_UDMA6),
270 /* 15 */ DECLARE_NV_DEV("NFORCE-MCP51", ATA_UDMA6),
271 /* 16 */ DECLARE_NV_DEV("NFORCE-MCP55", ATA_UDMA6),
272 /* 17 */ DECLARE_NV_DEV("NFORCE-MCP61", ATA_UDMA6),
273 /* 18 */ DECLARE_NV_DEV("NFORCE-MCP65", ATA_UDMA6),
274 /* 19 */ DECLARE_NV_DEV("NFORCE-MCP67", ATA_UDMA6),
275 /* 20 */ DECLARE_NV_DEV("NFORCE-MCP73", ATA_UDMA6),
276 /* 21 */ DECLARE_NV_DEV("NFORCE-MCP77", ATA_UDMA6),
277
278 /* 22 */ DECLARE_AMD_DEV("AMD5536", ATA_SWDMA2, ATA_UDMA5),
279}; 244};
280 245
281static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id) 246static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_id *id)
@@ -292,47 +257,64 @@ static int __devinit amd74xx_probe(struct pci_dev *dev, const struct pci_device_
292 if (dev->revision <= 7) 257 if (dev->revision <= 7)
293 d.swdma_mask = 0; 258 d.swdma_mask = 0;
294 d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX; 259 d.host_flags |= IDE_HFLAG_CLEAR_SIMPLEX;
295 } else if (idx == 4) { 260 } else if (idx == 3) {
296 if (dev->subsystem_vendor == PCI_VENDOR_ID_AMD && 261 if (dev->subsystem_vendor == PCI_VENDOR_ID_AMD &&
297 dev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE) 262 dev->subsystem_device == PCI_DEVICE_ID_AMD_SERENADE)
298 d.udma_mask = ATA_UDMA5; 263 d.udma_mask = ATA_UDMA5;
299 } 264 }
300 265
301 printk(KERN_INFO "%s: %s (rev %02x) UDMA%s controller\n", 266 printk(KERN_INFO "%s %s: UDMA%s controller\n",
302 d.name, pci_name(dev), dev->revision, 267 d.name, pci_name(dev), amd_dma[fls(d.udma_mask) - 1]);
303 amd_dma[fls(d.udma_mask) - 1]); 268
269 /*
270 * Determine the system bus clock.
271 */
272 amd_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000;
273
274 switch (amd_clock) {
275 case 33000: amd_clock = 33333; break;
276 case 37000: amd_clock = 37500; break;
277 case 41000: amd_clock = 41666; break;
278 }
279
280 if (amd_clock < 20000 || amd_clock > 50000) {
281 printk(KERN_WARNING "%s: User given PCI clock speed impossible"
282 " (%d), using 33 MHz instead.\n",
283 d.name, amd_clock);
284 amd_clock = 33333;
285 }
304 286
305 return ide_setup_pci_device(dev, &d); 287 return ide_pci_init_one(dev, &d, NULL);
306} 288}
307 289
308static const struct pci_device_id amd74xx_pci_tbl[] = { 290static const struct pci_device_id amd74xx_pci_tbl[] = {
309 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 }, 291 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_COBRA_7401), 0 },
310 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), 1 }, 292 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7409), 1 },
311 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7411), 2 }, 293 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_VIPER_7411), 2 },
312 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_OPUS_7441), 3 }, 294 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_OPUS_7441), 2 },
313 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_8111_IDE), 4 }, 295 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_8111_IDE), 3 },
314 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE), 5 }, 296 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_IDE), 4 },
315 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE), 6 }, 297 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2_IDE), 5 },
316 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE), 7 }, 298 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_IDE), 5 },
317#ifdef CONFIG_BLK_DEV_IDE_SATA 299#ifdef CONFIG_BLK_DEV_IDE_SATA
318 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA), 8 }, 300 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE2S_SATA), 5 },
319#endif 301#endif
320 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE), 9 }, 302 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3_IDE), 5 },
321 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE), 10 }, 303 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_IDE), 5 },
322#ifdef CONFIG_BLK_DEV_IDE_SATA 304#ifdef CONFIG_BLK_DEV_IDE_SATA
323 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA), 11 }, 305 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA), 5 },
324 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2), 12 }, 306 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE3S_SATA2), 5 },
325#endif 307#endif
326 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE), 13 }, 308 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_CK804_IDE), 5 },
327 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE), 14 }, 309 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP04_IDE), 5 },
328 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 15 }, 310 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP51_IDE), 5 },
329 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 16 }, 311 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP55_IDE), 5 },
330 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 17 }, 312 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP61_IDE), 5 },
331 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), 18 }, 313 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP65_IDE), 5 },
332 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 19 }, 314 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP67_IDE), 5 },
333 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), 20 }, 315 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP73_IDE), 5 },
334 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), 21 }, 316 { PCI_VDEVICE(NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP77_IDE), 5 },
335 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 22 }, 317 { PCI_VDEVICE(AMD, PCI_DEVICE_ID_AMD_CS5536_IDE), 6 },
336 { 0, }, 318 { 0, },
337}; 319};
338MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl); 320MODULE_DEVICE_TABLE(pci, amd74xx_pci_tbl);
@@ -341,6 +323,7 @@ static struct pci_driver driver = {
341 .name = "AMD_IDE", 323 .name = "AMD_IDE",
342 .id_table = amd74xx_pci_tbl, 324 .id_table = amd74xx_pci_tbl,
343 .probe = amd74xx_probe, 325 .probe = amd74xx_probe,
326 .remove = ide_pci_remove,
344}; 327};
345 328
346static int __init amd74xx_ide_init(void) 329static int __init amd74xx_ide_init(void)
@@ -348,7 +331,13 @@ static int __init amd74xx_ide_init(void)
348 return ide_pci_register_driver(&driver); 331 return ide_pci_register_driver(&driver);
349} 332}
350 333
334static void __exit amd74xx_ide_exit(void)
335{
336 pci_unregister_driver(&driver);
337}
338
351module_init(amd74xx_ide_init); 339module_init(amd74xx_ide_init);
340module_exit(amd74xx_ide_exit);
352 341
353MODULE_AUTHOR("Vojtech Pavlik"); 342MODULE_AUTHOR("Vojtech Pavlik");
354MODULE_DESCRIPTION("AMD PCI IDE driver"); 343MODULE_DESCRIPTION("AMD PCI IDE driver");
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c
index 8b637181681a..332f08f43b56 100644
--- a/drivers/ide/pci/atiixp.c
+++ b/drivers/ide/pci/atiixp.c
@@ -11,6 +11,8 @@
11#include <linux/ide.h> 11#include <linux/ide.h>
12#include <linux/init.h> 12#include <linux/init.h>
13 13
14#define DRV_NAME "atiixp"
15
14#define ATIIXP_IDE_PIO_TIMING 0x40 16#define ATIIXP_IDE_PIO_TIMING 0x40
15#define ATIIXP_IDE_MDMA_TIMING 0x44 17#define ATIIXP_IDE_MDMA_TIMING 0x44
16#define ATIIXP_IDE_PIO_CONTROL 0x48 18#define ATIIXP_IDE_PIO_CONTROL 0x48
@@ -137,16 +139,17 @@ static const struct ide_port_ops atiixp_port_ops = {
137}; 139};
138 140
139static const struct ide_port_info atiixp_pci_info[] __devinitdata = { 141static const struct ide_port_info atiixp_pci_info[] __devinitdata = {
140 { /* 0 */ 142 { /* 0: IXP200/300/400/700 */
141 .name = "ATIIXP", 143 .name = DRV_NAME,
142 .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}}, 144 .enablebits = {{0x48,0x01,0x00}, {0x48,0x08,0x00}},
143 .port_ops = &atiixp_port_ops, 145 .port_ops = &atiixp_port_ops,
144 .host_flags = IDE_HFLAG_LEGACY_IRQS, 146 .host_flags = IDE_HFLAG_LEGACY_IRQS,
145 .pio_mask = ATA_PIO4, 147 .pio_mask = ATA_PIO4,
146 .mwdma_mask = ATA_MWDMA2, 148 .mwdma_mask = ATA_MWDMA2,
147 .udma_mask = ATA_UDMA5, 149 .udma_mask = ATA_UDMA5,
148 },{ /* 1 */ 150 },
149 .name = "SB600_PATA", 151 { /* 1: IXP600 */
152 .name = DRV_NAME,
150 .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}}, 153 .enablebits = {{0x48,0x01,0x00}, {0x00,0x00,0x00}},
151 .port_ops = &atiixp_port_ops, 154 .port_ops = &atiixp_port_ops,
152 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS, 155 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_LEGACY_IRQS,
@@ -167,7 +170,7 @@ static const struct ide_port_info atiixp_pci_info[] __devinitdata = {
167 170
168static int __devinit atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id) 171static int __devinit atiixp_init_one(struct pci_dev *dev, const struct pci_device_id *id)
169{ 172{
170 return ide_setup_pci_device(dev, &atiixp_pci_info[id->driver_data]); 173 return ide_pci_init_one(dev, &atiixp_pci_info[id->driver_data], NULL);
171} 174}
172 175
173static const struct pci_device_id atiixp_pci_tbl[] = { 176static const struct pci_device_id atiixp_pci_tbl[] = {
@@ -184,6 +187,7 @@ static struct pci_driver driver = {
184 .name = "ATIIXP_IDE", 187 .name = "ATIIXP_IDE",
185 .id_table = atiixp_pci_tbl, 188 .id_table = atiixp_pci_tbl,
186 .probe = atiixp_init_one, 189 .probe = atiixp_init_one,
190 .remove = ide_pci_remove,
187}; 191};
188 192
189static int __init atiixp_ide_init(void) 193static int __init atiixp_ide_init(void)
@@ -191,7 +195,13 @@ static int __init atiixp_ide_init(void)
191 return ide_pci_register_driver(&driver); 195 return ide_pci_register_driver(&driver);
192} 196}
193 197
198static void __exit atiixp_ide_exit(void)
199{
200 pci_unregister_driver(&driver);
201}
202
194module_init(atiixp_ide_init); 203module_init(atiixp_ide_init);
204module_exit(atiixp_ide_exit);
195 205
196MODULE_AUTHOR("HUI YU"); 206MODULE_AUTHOR("HUI YU");
197MODULE_DESCRIPTION("PCI driver module for ATI IXP IDE"); 207MODULE_DESCRIPTION("PCI driver module for ATI IXP IDE");
diff --git a/drivers/ide/pci/cmd64x.c b/drivers/ide/pci/cmd64x.c
index ce58bfcdb3c6..1360b4fa9fd3 100644
--- a/drivers/ide/pci/cmd64x.c
+++ b/drivers/ide/pci/cmd64x.c
@@ -19,6 +19,8 @@
19 19
20#include <asm/io.h> 20#include <asm/io.h>
21 21
22#define DRV_NAME "cmd64x"
23
22#define CMD_DEBUG 0 24#define CMD_DEBUG 0
23 25
24#if CMD_DEBUG 26#if CMD_DEBUG
@@ -330,28 +332,10 @@ static int cmd646_1_dma_end(ide_drive_t *drive)
330 return (dma_stat & 7) != 4; 332 return (dma_stat & 7) != 4;
331} 333}
332 334
333static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev, const char *name) 335static unsigned int __devinit init_chipset_cmd64x(struct pci_dev *dev)
334{ 336{
335 u8 mrdmode = 0; 337 u8 mrdmode = 0;
336 338
337 if (dev->device == PCI_DEVICE_ID_CMD_646) {
338
339 switch (dev->revision) {
340 case 0x07:
341 case 0x05:
342 printk("%s: UltraDMA capable\n", name);
343 break;
344 case 0x03:
345 default:
346 printk("%s: MultiWord DMA force limited\n", name);
347 break;
348 case 0x01:
349 printk("%s: MultiWord DMA limited, "
350 "IRQ workaround enabled\n", name);
351 break;
352 }
353 }
354
355 /* Set a good latency timer and cache line size value. */ 339 /* Set a good latency timer and cache line size value. */
356 (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64); 340 (void) pci_write_config_byte(dev, PCI_LATENCY_TIMER, 64);
357 /* FIXME: pci_set_master() to ensure a good latency timer value */ 341 /* FIXME: pci_set_master() to ensure a good latency timer value */
@@ -425,8 +409,8 @@ static const struct ide_dma_ops cmd648_dma_ops = {
425}; 409};
426 410
427static const struct ide_port_info cmd64x_chipsets[] __devinitdata = { 411static const struct ide_port_info cmd64x_chipsets[] __devinitdata = {
428 { /* 0 */ 412 { /* 0: CMD643 */
429 .name = "CMD643", 413 .name = DRV_NAME,
430 .init_chipset = init_chipset_cmd64x, 414 .init_chipset = init_chipset_cmd64x,
431 .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}}, 415 .enablebits = {{0x00,0x00,0x00}, {0x51,0x08,0x08}},
432 .port_ops = &cmd64x_port_ops, 416 .port_ops = &cmd64x_port_ops,
@@ -436,8 +420,9 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = {
436 .pio_mask = ATA_PIO5, 420 .pio_mask = ATA_PIO5,
437 .mwdma_mask = ATA_MWDMA2, 421 .mwdma_mask = ATA_MWDMA2,
438 .udma_mask = 0x00, /* no udma */ 422 .udma_mask = 0x00, /* no udma */
439 },{ /* 1 */ 423 },
440 .name = "CMD646", 424 { /* 1: CMD646 */
425 .name = DRV_NAME,
441 .init_chipset = init_chipset_cmd64x, 426 .init_chipset = init_chipset_cmd64x,
442 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 427 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
443 .chipset = ide_cmd646, 428 .chipset = ide_cmd646,
@@ -447,8 +432,9 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = {
447 .pio_mask = ATA_PIO5, 432 .pio_mask = ATA_PIO5,
448 .mwdma_mask = ATA_MWDMA2, 433 .mwdma_mask = ATA_MWDMA2,
449 .udma_mask = ATA_UDMA2, 434 .udma_mask = ATA_UDMA2,
450 },{ /* 2 */ 435 },
451 .name = "CMD648", 436 { /* 2: CMD648 */
437 .name = DRV_NAME,
452 .init_chipset = init_chipset_cmd64x, 438 .init_chipset = init_chipset_cmd64x,
453 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 439 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
454 .port_ops = &cmd64x_port_ops, 440 .port_ops = &cmd64x_port_ops,
@@ -457,8 +443,9 @@ static const struct ide_port_info cmd64x_chipsets[] __devinitdata = {
457 .pio_mask = ATA_PIO5, 443 .pio_mask = ATA_PIO5,
458 .mwdma_mask = ATA_MWDMA2, 444 .mwdma_mask = ATA_MWDMA2,
459 .udma_mask = ATA_UDMA4, 445 .udma_mask = ATA_UDMA4,
460 },{ /* 3 */ 446 },
461 .name = "CMD649", 447 { /* 3: CMD649 */
448 .name = DRV_NAME,
462 .init_chipset = init_chipset_cmd64x, 449 .init_chipset = init_chipset_cmd64x,
463 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}}, 450 .enablebits = {{0x51,0x04,0x04}, {0x51,0x08,0x08}},
464 .port_ops = &cmd64x_port_ops, 451 .port_ops = &cmd64x_port_ops,
@@ -507,7 +494,7 @@ static int __devinit cmd64x_init_one(struct pci_dev *dev, const struct pci_devic
507 } 494 }
508 } 495 }
509 496
510 return ide_setup_pci_device(dev, &d); 497 return ide_pci_init_one(dev, &d, NULL);
511} 498}
512 499
513static const struct pci_device_id cmd64x_pci_tbl[] = { 500static const struct pci_device_id cmd64x_pci_tbl[] = {
@@ -523,6 +510,7 @@ static struct pci_driver driver = {
523 .name = "CMD64x_IDE", 510 .name = "CMD64x_IDE",
524 .id_table = cmd64x_pci_tbl, 511 .id_table = cmd64x_pci_tbl,
525 .probe = cmd64x_init_one, 512 .probe = cmd64x_init_one,
513 .remove = ide_pci_remove,
526}; 514};
527 515
528static int __init cmd64x_ide_init(void) 516static int __init cmd64x_ide_init(void)
@@ -530,7 +518,13 @@ static int __init cmd64x_ide_init(void)
530 return ide_pci_register_driver(&driver); 518 return ide_pci_register_driver(&driver);
531} 519}
532 520
521static void __exit cmd64x_ide_exit(void)
522{
523 pci_unregister_driver(&driver);
524}
525
533module_init(cmd64x_ide_init); 526module_init(cmd64x_ide_init);
527module_exit(cmd64x_ide_exit);
534 528
535MODULE_AUTHOR("Eddie Dost, David Miller, Andre Hedrick"); 529MODULE_AUTHOR("Eddie Dost, David Miller, Andre Hedrick");
536MODULE_DESCRIPTION("PCI driver module for CMD64x IDE"); 530MODULE_DESCRIPTION("PCI driver module for CMD64x IDE");
diff --git a/drivers/ide/pci/cs5520.c b/drivers/ide/pci/cs5520.c
index b03d8ae947e6..c0364b287f17 100644
--- a/drivers/ide/pci/cs5520.c
+++ b/drivers/ide/pci/cs5520.c
@@ -41,6 +41,8 @@
41#include <linux/ide.h> 41#include <linux/ide.h>
42#include <linux/dma-mapping.h> 42#include <linux/dma-mapping.h>
43 43
44#define DRV_NAME "cs5520"
45
44struct pio_clocks 46struct pio_clocks
45{ 47{
46 int address; 48 int address;
@@ -92,18 +94,11 @@ static const struct ide_port_ops cs5520_port_ops = {
92 .set_dma_mode = cs5520_set_dma_mode, 94 .set_dma_mode = cs5520_set_dma_mode,
93}; 95};
94 96
95#define DECLARE_CS_DEV(name_str) \ 97static const struct ide_port_info cyrix_chipset __devinitdata = {
96 { \ 98 .name = DRV_NAME,
97 .name = name_str, \ 99 .port_ops = &cs5520_port_ops,
98 .port_ops = &cs5520_port_ops, \ 100 .host_flags = IDE_HFLAG_ISA_PORTS | IDE_HFLAG_CS5520,
99 .host_flags = IDE_HFLAG_ISA_PORTS | \ 101 .pio_mask = ATA_PIO4,
100 IDE_HFLAG_CS5520, \
101 .pio_mask = ATA_PIO4, \
102 }
103
104static const struct ide_port_info cyrix_chipsets[] __devinitdata = {
105 /* 0 */ DECLARE_CS_DEV("Cyrix 5510"),
106 /* 1 */ DECLARE_CS_DEV("Cyrix 5520")
107}; 102};
108 103
109/* 104/*
@@ -114,7 +109,7 @@ static const struct ide_port_info cyrix_chipsets[] __devinitdata = {
114 109
115static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id) 110static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
116{ 111{
117 const struct ide_port_info *d = &cyrix_chipsets[id->driver_data]; 112 const struct ide_port_info *d = &cyrix_chipset;
118 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; 113 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
119 114
120 ide_setup_pci_noise(dev, d); 115 ide_setup_pci_noise(dev, d);
@@ -128,7 +123,8 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
128 } 123 }
129 pci_set_master(dev); 124 pci_set_master(dev);
130 if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) { 125 if (pci_set_dma_mask(dev, DMA_32BIT_MASK)) {
131 printk(KERN_WARNING "cs5520: No suitable DMA available.\n"); 126 printk(KERN_WARNING "%s: No suitable DMA available.\n",
127 d->name);
132 return -ENODEV; 128 return -ENODEV;
133 } 129 }
134 130
diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c
index f5534c1ff349..f235db8c678b 100644
--- a/drivers/ide/pci/cs5530.c
+++ b/drivers/ide/pci/cs5530.c
@@ -22,6 +22,8 @@
22 22
23#include <asm/io.h> 23#include <asm/io.h>
24 24
25#define DRV_NAME "cs5530"
26
25/* 27/*
26 * Here are the standard PIO mode 0-4 timings for each "format". 28 * Here are the standard PIO mode 0-4 timings for each "format".
27 * Format-0 uses fast data reg timings, with slower command reg timings. 29 * Format-0 uses fast data reg timings, with slower command reg timings.
@@ -127,12 +129,11 @@ static void cs5530_set_dma_mode(ide_drive_t *drive, const u8 mode)
127/** 129/**
128 * init_chipset_5530 - set up 5530 bridge 130 * init_chipset_5530 - set up 5530 bridge
129 * @dev: PCI device 131 * @dev: PCI device
130 * @name: device name
131 * 132 *
132 * Initialize the cs5530 bridge for reliable IDE DMA operation. 133 * Initialize the cs5530 bridge for reliable IDE DMA operation.
133 */ 134 */
134 135
135static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const char *name) 136static unsigned int __devinit init_chipset_cs5530(struct pci_dev *dev)
136{ 137{
137 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL; 138 struct pci_dev *master_0 = NULL, *cs5530_0 = NULL;
138 139
@@ -151,11 +152,11 @@ static unsigned int __devinit init_chipset_cs5530 (struct pci_dev *dev, const ch
151 } 152 }
152 } 153 }
153 if (!master_0) { 154 if (!master_0) {
154 printk(KERN_ERR "%s: unable to locate PCI MASTER function\n", name); 155 printk(KERN_ERR DRV_NAME ": unable to locate PCI MASTER function\n");
155 goto out; 156 goto out;
156 } 157 }
157 if (!cs5530_0) { 158 if (!cs5530_0) {
158 printk(KERN_ERR "%s: unable to locate CS5530 LEGACY function\n", name); 159 printk(KERN_ERR DRV_NAME ": unable to locate CS5530 LEGACY function\n");
159 goto out; 160 goto out;
160 } 161 }
161 162
@@ -243,7 +244,7 @@ static const struct ide_port_ops cs5530_port_ops = {
243}; 244};
244 245
245static const struct ide_port_info cs5530_chipset __devinitdata = { 246static const struct ide_port_info cs5530_chipset __devinitdata = {
246 .name = "CS5530", 247 .name = DRV_NAME,
247 .init_chipset = init_chipset_cs5530, 248 .init_chipset = init_chipset_cs5530,
248 .init_hwif = init_hwif_cs5530, 249 .init_hwif = init_hwif_cs5530,
249 .port_ops = &cs5530_port_ops, 250 .port_ops = &cs5530_port_ops,
@@ -256,7 +257,7 @@ static const struct ide_port_info cs5530_chipset __devinitdata = {
256 257
257static int __devinit cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id) 258static int __devinit cs5530_init_one(struct pci_dev *dev, const struct pci_device_id *id)
258{ 259{
259 return ide_setup_pci_device(dev, &cs5530_chipset); 260 return ide_pci_init_one(dev, &cs5530_chipset, NULL);
260} 261}
261 262
262static const struct pci_device_id cs5530_pci_tbl[] = { 263static const struct pci_device_id cs5530_pci_tbl[] = {
@@ -269,6 +270,7 @@ static struct pci_driver driver = {
269 .name = "CS5530 IDE", 270 .name = "CS5530 IDE",
270 .id_table = cs5530_pci_tbl, 271 .id_table = cs5530_pci_tbl,
271 .probe = cs5530_init_one, 272 .probe = cs5530_init_one,
273 .remove = ide_pci_remove,
272}; 274};
273 275
274static int __init cs5530_ide_init(void) 276static int __init cs5530_ide_init(void)
@@ -276,7 +278,13 @@ static int __init cs5530_ide_init(void)
276 return ide_pci_register_driver(&driver); 278 return ide_pci_register_driver(&driver);
277} 279}
278 280
281static void __exit cs5530_ide_exit(void)
282{
283 pci_unregister_driver(&driver);
284}
285
279module_init(cs5530_ide_init); 286module_init(cs5530_ide_init);
287module_exit(cs5530_ide_exit);
280 288
281MODULE_AUTHOR("Mark Lord"); 289MODULE_AUTHOR("Mark Lord");
282MODULE_DESCRIPTION("PCI driver module for Cyrix/NS 5530 IDE"); 290MODULE_DESCRIPTION("PCI driver module for Cyrix/NS 5530 IDE");
diff --git a/drivers/ide/pci/cs5535.c b/drivers/ide/pci/cs5535.c
index 5404fe4f701d..f7b50cdeefa6 100644
--- a/drivers/ide/pci/cs5535.c
+++ b/drivers/ide/pci/cs5535.c
@@ -26,6 +26,8 @@
26#include <linux/pci.h> 26#include <linux/pci.h>
27#include <linux/ide.h> 27#include <linux/ide.h>
28 28
29#define DRV_NAME "cs5535"
30
29#define MSR_ATAC_BASE 0x51300000 31#define MSR_ATAC_BASE 0x51300000
30#define ATAC_GLD_MSR_CAP (MSR_ATAC_BASE+0) 32#define ATAC_GLD_MSR_CAP (MSR_ATAC_BASE+0)
31#define ATAC_GLD_MSR_CONFIG (MSR_ATAC_BASE+0x01) 33#define ATAC_GLD_MSR_CONFIG (MSR_ATAC_BASE+0x01)
@@ -169,7 +171,7 @@ static const struct ide_port_ops cs5535_port_ops = {
169}; 171};
170 172
171static const struct ide_port_info cs5535_chipset __devinitdata = { 173static const struct ide_port_info cs5535_chipset __devinitdata = {
172 .name = "CS5535", 174 .name = DRV_NAME,
173 .port_ops = &cs5535_port_ops, 175 .port_ops = &cs5535_port_ops,
174 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE, 176 .host_flags = IDE_HFLAG_SINGLE | IDE_HFLAG_POST_SET_MODE,
175 .pio_mask = ATA_PIO4, 177 .pio_mask = ATA_PIO4,
@@ -180,7 +182,7 @@ static const struct ide_port_info cs5535_chipset __devinitdata = {
180static int __devinit cs5535_init_one(struct pci_dev *dev, 182static int __devinit cs5535_init_one(struct pci_dev *dev,
181 const struct pci_device_id *id) 183 const struct pci_device_id *id)
182{ 184{
183 return ide_setup_pci_device(dev, &cs5535_chipset); 185 return ide_pci_init_one(dev, &cs5535_chipset, NULL);
184} 186}
185 187
186static const struct pci_device_id cs5535_pci_tbl[] = { 188static const struct pci_device_id cs5535_pci_tbl[] = {
@@ -194,6 +196,7 @@ static struct pci_driver driver = {
194 .name = "CS5535_IDE", 196 .name = "CS5535_IDE",
195 .id_table = cs5535_pci_tbl, 197 .id_table = cs5535_pci_tbl,
196 .probe = cs5535_init_one, 198 .probe = cs5535_init_one,
199 .remove = ide_pci_remove,
197}; 200};
198 201
199static int __init cs5535_ide_init(void) 202static int __init cs5535_ide_init(void)
@@ -201,7 +204,13 @@ static int __init cs5535_ide_init(void)
201 return ide_pci_register_driver(&driver); 204 return ide_pci_register_driver(&driver);
202} 205}
203 206
207static void __exit cs5535_ide_exit(void)
208{
209 pci_unregister_driver(&driver);
210}
211
204module_init(cs5535_ide_init); 212module_init(cs5535_ide_init);
213module_exit(cs5535_ide_exit);
205 214
206MODULE_AUTHOR("AMD"); 215MODULE_AUTHOR("AMD");
207MODULE_DESCRIPTION("PCI driver module for AMD/NS CS5535 IDE"); 216MODULE_DESCRIPTION("PCI driver module for AMD/NS CS5535 IDE");
diff --git a/drivers/ide/pci/cy82c693.c b/drivers/ide/pci/cy82c693.c
index e14ad5530fa4..bfae2f882f48 100644
--- a/drivers/ide/pci/cy82c693.c
+++ b/drivers/ide/pci/cy82c693.c
@@ -48,6 +48,8 @@
48 48
49#include <asm/io.h> 49#include <asm/io.h>
50 50
51#define DRV_NAME "cy82c693"
52
51/* the current version */ 53/* the current version */
52#define CY82_VERSION "CY82C693U driver v0.34 99-13-12 Andreas S. Krebs (akrebs@altavista.net)" 54#define CY82_VERSION "CY82C693U driver v0.34 99-13-12 Andreas S. Krebs (akrebs@altavista.net)"
53 55
@@ -330,7 +332,7 @@ static void cy82c693_set_pio_mode(ide_drive_t *drive, const u8 pio)
330/* 332/*
331 * this function is called during init and is used to setup the cy82c693 chip 333 * this function is called during init and is used to setup the cy82c693 chip
332 */ 334 */
333static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const char *name) 335static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev)
334{ 336{
335 if (PCI_FUNC(dev->devfn) != 1) 337 if (PCI_FUNC(dev->devfn) != 1)
336 return 0; 338 return 0;
@@ -349,8 +351,8 @@ static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const c
349 data = inb(CY82_DATA_PORT); 351 data = inb(CY82_DATA_PORT);
350 352
351#if CY82C693_DEBUG_INFO 353#if CY82C693_DEBUG_INFO
352 printk(KERN_INFO "%s: Peripheral Configuration Register: 0x%X\n", 354 printk(KERN_INFO DRV_NAME ": Peripheral Configuration Register: 0x%X\n",
353 name, data); 355 data);
354#endif /* CY82C693_DEBUG_INFO */ 356#endif /* CY82C693_DEBUG_INFO */
355 357
356 /* 358 /*
@@ -371,8 +373,8 @@ static unsigned int __devinit init_chipset_cy82c693(struct pci_dev *dev, const c
371 outb(data, CY82_DATA_PORT); 373 outb(data, CY82_DATA_PORT);
372 374
373#if CY82C693_DEBUG_INFO 375#if CY82C693_DEBUG_INFO
374 printk(KERN_INFO "%s: New Peripheral Configuration Register: 0x%X\n", 376 printk(KERN_INFO ": New Peripheral Configuration Register: 0x%X\n",
375 name, data); 377 data);
376#endif /* CY82C693_DEBUG_INFO */ 378#endif /* CY82C693_DEBUG_INFO */
377 379
378#endif /* CY82C693_SETDMA_CLOCK */ 380#endif /* CY82C693_SETDMA_CLOCK */
@@ -398,7 +400,7 @@ static const struct ide_port_ops cy82c693_port_ops = {
398}; 400};
399 401
400static const struct ide_port_info cy82c693_chipset __devinitdata = { 402static const struct ide_port_info cy82c693_chipset __devinitdata = {
401 .name = "CY82C693", 403 .name = DRV_NAME,
402 .init_chipset = init_chipset_cy82c693, 404 .init_chipset = init_chipset_cy82c693,
403 .init_iops = init_iops_cy82c693, 405 .init_iops = init_iops_cy82c693,
404 .port_ops = &cy82c693_port_ops, 406 .port_ops = &cy82c693_port_ops,
@@ -419,12 +421,22 @@ static int __devinit cy82c693_init_one(struct pci_dev *dev, const struct pci_dev
419 if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && 421 if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE &&
420 PCI_FUNC(dev->devfn) == 1) { 422 PCI_FUNC(dev->devfn) == 1) {
421 dev2 = pci_get_slot(dev->bus, dev->devfn + 1); 423 dev2 = pci_get_slot(dev->bus, dev->devfn + 1);
422 ret = ide_setup_pci_devices(dev, dev2, &cy82c693_chipset); 424 ret = ide_pci_init_two(dev, dev2, &cy82c693_chipset, NULL);
423 /* We leak pci refs here but thats ok - we can't be unloaded */ 425 if (ret)
426 pci_dev_put(dev2);
424 } 427 }
425 return ret; 428 return ret;
426} 429}
427 430
431static void __devexit cy82c693_remove(struct pci_dev *dev)
432{
433 struct ide_host *host = pci_get_drvdata(dev);
434 struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL;
435
436 ide_pci_remove(dev);
437 pci_dev_put(dev2);
438}
439
428static const struct pci_device_id cy82c693_pci_tbl[] = { 440static const struct pci_device_id cy82c693_pci_tbl[] = {
429 { PCI_VDEVICE(CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693), 0 }, 441 { PCI_VDEVICE(CONTAQ, PCI_DEVICE_ID_CONTAQ_82C693), 0 },
430 { 0, }, 442 { 0, },
@@ -435,6 +447,7 @@ static struct pci_driver driver = {
435 .name = "Cypress_IDE", 447 .name = "Cypress_IDE",
436 .id_table = cy82c693_pci_tbl, 448 .id_table = cy82c693_pci_tbl,
437 .probe = cy82c693_init_one, 449 .probe = cy82c693_init_one,
450 .remove = cy82c693_remove,
438}; 451};
439 452
440static int __init cy82c693_ide_init(void) 453static int __init cy82c693_ide_init(void)
@@ -442,7 +455,13 @@ static int __init cy82c693_ide_init(void)
442 return ide_pci_register_driver(&driver); 455 return ide_pci_register_driver(&driver);
443} 456}
444 457
458static void __exit cy82c693_ide_exit(void)
459{
460 pci_unregister_driver(&driver);
461}
462
445module_init(cy82c693_ide_init); 463module_init(cy82c693_ide_init);
464module_exit(cy82c693_ide_exit);
446 465
447MODULE_AUTHOR("Andreas Krebs, Andre Hedrick"); 466MODULE_AUTHOR("Andreas Krebs, Andre Hedrick");
448MODULE_DESCRIPTION("PCI driver module for the Cypress CY82C693 IDE"); 467MODULE_DESCRIPTION("PCI driver module for the Cypress CY82C693 IDE");
diff --git a/drivers/ide/pci/generic.c b/drivers/ide/pci/generic.c
index 041720e22762..b07d4f4273b3 100644
--- a/drivers/ide/pci/generic.c
+++ b/drivers/ide/pci/generic.c
@@ -27,6 +27,8 @@
27#include <linux/ide.h> 27#include <linux/ide.h>
28#include <linux/init.h> 28#include <linux/init.h>
29 29
30#define DRV_NAME "ide_pci_generic"
31
30static int ide_generic_all; /* Set to claim all devices */ 32static int ide_generic_all; /* Set to claim all devices */
31 33
32module_param_named(all_generic_ide, ide_generic_all, bool, 0444); 34module_param_named(all_generic_ide, ide_generic_all, bool, 0444);
@@ -34,9 +36,9 @@ MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE st
34 36
35#define IDE_HFLAGS_UMC (IDE_HFLAG_NO_DMA | IDE_HFLAG_FORCE_LEGACY_IRQS) 37#define IDE_HFLAGS_UMC (IDE_HFLAG_NO_DMA | IDE_HFLAG_FORCE_LEGACY_IRQS)
36 38
37#define DECLARE_GENERIC_PCI_DEV(name_str, extra_flags) \ 39#define DECLARE_GENERIC_PCI_DEV(extra_flags) \
38 { \ 40 { \
39 .name = name_str, \ 41 .name = DRV_NAME, \
40 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | \ 42 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | \
41 extra_flags, \ 43 extra_flags, \
42 .swdma_mask = ATA_SWDMA2, \ 44 .swdma_mask = ATA_SWDMA2, \
@@ -45,10 +47,11 @@ MODULE_PARM_DESC(all_generic_ide, "IDE generic will claim all unknown PCI IDE st
45 } 47 }
46 48
47static const struct ide_port_info generic_chipsets[] __devinitdata = { 49static const struct ide_port_info generic_chipsets[] __devinitdata = {
48 /* 0 */ DECLARE_GENERIC_PCI_DEV("Unknown", 0), 50 /* 0: Unknown */
51 DECLARE_GENERIC_PCI_DEV(0),
49 52
50 { /* 1 */ 53 { /* 1: NS87410 */
51 .name = "NS87410", 54 .name = DRV_NAME,
52 .enablebits = { {0x43, 0x08, 0x08}, {0x47, 0x08, 0x08} }, 55 .enablebits = { {0x43, 0x08, 0x08}, {0x47, 0x08, 0x08} },
53 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA, 56 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA,
54 .swdma_mask = ATA_SWDMA2, 57 .swdma_mask = ATA_SWDMA2,
@@ -56,17 +59,15 @@ static const struct ide_port_info generic_chipsets[] __devinitdata = {
56 .udma_mask = ATA_UDMA6, 59 .udma_mask = ATA_UDMA6,
57 }, 60 },
58 61
59 /* 2 */ DECLARE_GENERIC_PCI_DEV("SAMURAI", 0), 62 /* 2: SAMURAI / HT6565 / HINT_IDE */
60 /* 3 */ DECLARE_GENERIC_PCI_DEV("HT6565", 0), 63 DECLARE_GENERIC_PCI_DEV(0),
61 /* 4 */ DECLARE_GENERIC_PCI_DEV("UM8673F", IDE_HFLAGS_UMC), 64 /* 3: UM8673F / UM8886A / UM8886BF */
62 /* 5 */ DECLARE_GENERIC_PCI_DEV("UM8886A", IDE_HFLAGS_UMC), 65 DECLARE_GENERIC_PCI_DEV(IDE_HFLAGS_UMC),
63 /* 6 */ DECLARE_GENERIC_PCI_DEV("UM8886BF", IDE_HFLAGS_UMC), 66 /* 4: VIA_IDE / OPTI621V / Piccolo010{2,3,5} */
64 /* 7 */ DECLARE_GENERIC_PCI_DEV("HINT_IDE", 0), 67 DECLARE_GENERIC_PCI_DEV(IDE_HFLAG_NO_AUTODMA),
65 /* 8 */ DECLARE_GENERIC_PCI_DEV("VIA_IDE", IDE_HFLAG_NO_AUTODMA), 68
66 /* 9 */ DECLARE_GENERIC_PCI_DEV("OPTI621V", IDE_HFLAG_NO_AUTODMA), 69 { /* 5: VIA8237SATA */
67 70 .name = DRV_NAME,
68 { /* 10 */
69 .name = "VIA8237SATA",
70 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA | 71 .host_flags = IDE_HFLAG_TRUST_BIOS_FOR_DMA |
71 IDE_HFLAG_OFF_BOARD, 72 IDE_HFLAG_OFF_BOARD,
72 .swdma_mask = ATA_SWDMA2, 73 .swdma_mask = ATA_SWDMA2,
@@ -74,12 +75,8 @@ static const struct ide_port_info generic_chipsets[] __devinitdata = {
74 .udma_mask = ATA_UDMA6, 75 .udma_mask = ATA_UDMA6,
75 }, 76 },
76 77
77 /* 11 */ DECLARE_GENERIC_PCI_DEV("Piccolo0102", IDE_HFLAG_NO_AUTODMA), 78 { /* 6: Revolution */
78 /* 12 */ DECLARE_GENERIC_PCI_DEV("Piccolo0103", IDE_HFLAG_NO_AUTODMA), 79 .name = DRV_NAME,
79 /* 13 */ DECLARE_GENERIC_PCI_DEV("Piccolo0105", IDE_HFLAG_NO_AUTODMA),
80
81 { /* 14 */
82 .name = "Revolution",
83 .host_flags = IDE_HFLAG_CLEAR_SIMPLEX | 80 .host_flags = IDE_HFLAG_CLEAR_SIMPLEX |
84 IDE_HFLAG_TRUST_BIOS_FOR_DMA | 81 IDE_HFLAG_TRUST_BIOS_FOR_DMA |
85 IDE_HFLAG_OFF_BOARD, 82 IDE_HFLAG_OFF_BOARD,
@@ -134,12 +131,12 @@ static int __devinit generic_init_one(struct pci_dev *dev, const struct pci_devi
134 u16 command; 131 u16 command;
135 pci_read_config_word(dev, PCI_COMMAND, &command); 132 pci_read_config_word(dev, PCI_COMMAND, &command);
136 if (!(command & PCI_COMMAND_IO)) { 133 if (!(command & PCI_COMMAND_IO)) {
137 printk(KERN_INFO "Skipping disabled %s IDE " 134 printk(KERN_INFO "%s %s: skipping disabled "
138 "controller.\n", d->name); 135 "controller\n", d->name, pci_name(dev));
139 goto out; 136 goto out;
140 } 137 }
141 } 138 }
142 ret = ide_setup_pci_device(dev, d); 139 ret = ide_pci_init_one(dev, d, NULL);
143out: 140out:
144 return ret; 141 return ret;
145} 142}
@@ -147,20 +144,20 @@ out:
147static const struct pci_device_id generic_pci_tbl[] = { 144static const struct pci_device_id generic_pci_tbl[] = {
148 { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_87410), 1 }, 145 { PCI_VDEVICE(NS, PCI_DEVICE_ID_NS_87410), 1 },
149 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE), 2 }, 146 { PCI_VDEVICE(PCTECH, PCI_DEVICE_ID_PCTECH_SAMURAI_IDE), 2 },
150 { PCI_VDEVICE(HOLTEK, PCI_DEVICE_ID_HOLTEK_6565), 3 }, 147 { PCI_VDEVICE(HOLTEK, PCI_DEVICE_ID_HOLTEK_6565), 2 },
151 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8673F), 4 }, 148 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8673F), 3 },
152 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886A), 5 }, 149 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886A), 3 },
153 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886BF), 6 }, 150 { PCI_VDEVICE(UMC, PCI_DEVICE_ID_UMC_UM8886BF), 3 },
154 { PCI_VDEVICE(HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE), 7 }, 151 { PCI_VDEVICE(HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE), 2 },
155 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C561), 8 }, 152 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_82C561), 4 },
156 { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C558), 9 }, 153 { PCI_VDEVICE(OPTI, PCI_DEVICE_ID_OPTI_82C558), 4 },
157#ifdef CONFIG_BLK_DEV_IDE_SATA 154#ifdef CONFIG_BLK_DEV_IDE_SATA
158 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8237_SATA), 10 }, 155 { PCI_VDEVICE(VIA, PCI_DEVICE_ID_VIA_8237_SATA), 5 },
159#endif 156#endif
160 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO), 11 }, 157 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO), 4 },
161 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), 12 }, 158 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), 4 },
162 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), 13 }, 159 { PCI_VDEVICE(TOSHIBA, PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), 4 },
163 { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), 14 }, 160 { PCI_VDEVICE(NETCELL, PCI_DEVICE_ID_REVOLUTION), 6 },
164 /* 161 /*
165 * Must come last. If you add entries adjust 162 * Must come last. If you add entries adjust
166 * this table and generic_chipsets[] appropriately. 163 * this table and generic_chipsets[] appropriately.
@@ -174,6 +171,7 @@ static struct pci_driver driver = {
174 .name = "PCI_IDE", 171 .name = "PCI_IDE",
175 .id_table = generic_pci_tbl, 172 .id_table = generic_pci_tbl,
176 .probe = generic_init_one, 173 .probe = generic_init_one,
174 .remove = ide_pci_remove,
177}; 175};
178 176
179static int __init generic_ide_init(void) 177static int __init generic_ide_init(void)
@@ -181,7 +179,13 @@ static int __init generic_ide_init(void)
181 return ide_pci_register_driver(&driver); 179 return ide_pci_register_driver(&driver);
182} 180}
183 181
182static void __exit generic_ide_exit(void)
183{
184 pci_unregister_driver(&driver);
185}
186
184module_init(generic_ide_init); 187module_init(generic_ide_init);
188module_exit(generic_ide_exit);
185 189
186MODULE_AUTHOR("Andre Hedrick"); 190MODULE_AUTHOR("Andre Hedrick");
187MODULE_DESCRIPTION("PCI driver module for generic PCI IDE"); 191MODULE_DESCRIPTION("PCI driver module for generic PCI IDE");
diff --git a/drivers/ide/pci/hpt34x.c b/drivers/ide/pci/hpt34x.c
index 9e1d1c4741da..6009b0b9655d 100644
--- a/drivers/ide/pci/hpt34x.c
+++ b/drivers/ide/pci/hpt34x.c
@@ -33,6 +33,8 @@
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/ide.h> 34#include <linux/ide.h>
35 35
36#define DRV_NAME "hpt34x"
37
36#define HPT343_DEBUG_DRIVE_INFO 0 38#define HPT343_DEBUG_DRIVE_INFO 0
37 39
38static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed) 40static void hpt34x_set_mode(ide_drive_t *drive, const u8 speed)
@@ -77,7 +79,7 @@ static void hpt34x_set_pio_mode(ide_drive_t *drive, const u8 pio)
77 */ 79 */
78#define HPT34X_PCI_INIT_REG 0x80 80#define HPT34X_PCI_INIT_REG 0x80
79 81
80static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev, const char *name) 82static unsigned int __devinit init_chipset_hpt34x(struct pci_dev *dev)
81{ 83{
82 int i = 0; 84 int i = 0;
83 unsigned long hpt34xIoBase = pci_resource_start(dev, 4); 85 unsigned long hpt34xIoBase = pci_resource_start(dev, 4);
@@ -126,15 +128,15 @@ static const struct ide_port_ops hpt34x_port_ops = {
126 IDE_HFLAG_NO_AUTODMA) 128 IDE_HFLAG_NO_AUTODMA)
127 129
128static const struct ide_port_info hpt34x_chipsets[] __devinitdata = { 130static const struct ide_port_info hpt34x_chipsets[] __devinitdata = {
129 { /* 0 */ 131 { /* 0: HPT343 */
130 .name = "HPT343", 132 .name = DRV_NAME,
131 .init_chipset = init_chipset_hpt34x, 133 .init_chipset = init_chipset_hpt34x,
132 .port_ops = &hpt34x_port_ops, 134 .port_ops = &hpt34x_port_ops,
133 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE, 135 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_NON_BOOTABLE,
134 .pio_mask = ATA_PIO5, 136 .pio_mask = ATA_PIO5,
135 }, 137 },
136 { /* 1 */ 138 { /* 1: HPT345 */
137 .name = "HPT345", 139 .name = DRV_NAME,
138 .init_chipset = init_chipset_hpt34x, 140 .init_chipset = init_chipset_hpt34x,
139 .port_ops = &hpt34x_port_ops, 141 .port_ops = &hpt34x_port_ops,
140 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD, 142 .host_flags = IDE_HFLAGS_HPT34X | IDE_HFLAG_OFF_BOARD,
@@ -156,7 +158,7 @@ static int __devinit hpt34x_init_one(struct pci_dev *dev, const struct pci_devic
156 158
157 d = &hpt34x_chipsets[(pcicmd & PCI_COMMAND_MEMORY) ? 1 : 0]; 159 d = &hpt34x_chipsets[(pcicmd & PCI_COMMAND_MEMORY) ? 1 : 0];
158 160
159 return ide_setup_pci_device(dev, d); 161 return ide_pci_init_one(dev, d, NULL);
160} 162}
161 163
162static const struct pci_device_id hpt34x_pci_tbl[] = { 164static const struct pci_device_id hpt34x_pci_tbl[] = {
@@ -169,6 +171,7 @@ static struct pci_driver driver = {
169 .name = "HPT34x_IDE", 171 .name = "HPT34x_IDE",
170 .id_table = hpt34x_pci_tbl, 172 .id_table = hpt34x_pci_tbl,
171 .probe = hpt34x_init_one, 173 .probe = hpt34x_init_one,
174 .remove = ide_pci_remove,
172}; 175};
173 176
174static int __init hpt34x_ide_init(void) 177static int __init hpt34x_ide_init(void)
@@ -176,7 +179,13 @@ static int __init hpt34x_ide_init(void)
176 return ide_pci_register_driver(&driver); 179 return ide_pci_register_driver(&driver);
177} 180}
178 181
182static void __exit hpt34x_ide_exit(void)
183{
184 pci_unregister_driver(&driver);
185}
186
179module_init(hpt34x_ide_init); 187module_init(hpt34x_ide_init);
188module_exit(hpt34x_ide_exit);
180 189
181MODULE_AUTHOR("Andre Hedrick"); 190MODULE_AUTHOR("Andre Hedrick");
182MODULE_DESCRIPTION("PCI driver module for Highpoint 34x IDE"); 191MODULE_DESCRIPTION("PCI driver module for Highpoint 34x IDE");
diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c
index 1f1135ce7cd6..5271b246b88c 100644
--- a/drivers/ide/pci/hpt366.c
+++ b/drivers/ide/pci/hpt366.c
@@ -131,6 +131,8 @@
131#include <asm/uaccess.h> 131#include <asm/uaccess.h>
132#include <asm/io.h> 132#include <asm/io.h>
133 133
134#define DRV_NAME "hpt366"
135
134/* various tuning parameters */ 136/* various tuning parameters */
135#define HPT_RESET_STATE_ENGINE 137#define HPT_RESET_STATE_ENGINE
136#undef HPT_DELAY_INTERRUPT 138#undef HPT_DELAY_INTERRUPT
@@ -620,7 +622,8 @@ static u8 hpt3xx_udma_filter(ide_drive_t *drive)
620{ 622{
621 ide_hwif_t *hwif = HWIF(drive); 623 ide_hwif_t *hwif = HWIF(drive);
622 struct pci_dev *dev = to_pci_dev(hwif->dev); 624 struct pci_dev *dev = to_pci_dev(hwif->dev);
623 struct hpt_info *info = pci_get_drvdata(dev); 625 struct ide_host *host = pci_get_drvdata(dev);
626 struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
624 u8 mask = hwif->ultra_mask; 627 u8 mask = hwif->ultra_mask;
625 628
626 switch (info->chip_type) { 629 switch (info->chip_type) {
@@ -660,7 +663,8 @@ static u8 hpt3xx_mdma_filter(ide_drive_t *drive)
660{ 663{
661 ide_hwif_t *hwif = HWIF(drive); 664 ide_hwif_t *hwif = HWIF(drive);
662 struct pci_dev *dev = to_pci_dev(hwif->dev); 665 struct pci_dev *dev = to_pci_dev(hwif->dev);
663 struct hpt_info *info = pci_get_drvdata(dev); 666 struct ide_host *host = pci_get_drvdata(dev);
667 struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
664 668
665 switch (info->chip_type) { 669 switch (info->chip_type) {
666 case HPT372 : 670 case HPT372 :
@@ -694,8 +698,10 @@ static u32 get_speed_setting(u8 speed, struct hpt_info *info)
694 698
695static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed) 699static void hpt3xx_set_mode(ide_drive_t *drive, const u8 speed)
696{ 700{
697 struct pci_dev *dev = to_pci_dev(drive->hwif->dev); 701 ide_hwif_t *hwif = drive->hwif;
698 struct hpt_info *info = pci_get_drvdata(dev); 702 struct pci_dev *dev = to_pci_dev(hwif->dev);
703 struct ide_host *host = pci_get_drvdata(dev);
704 struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
699 struct hpt_timings *t = info->timings; 705 struct hpt_timings *t = info->timings;
700 u8 itr_addr = 0x40 + (drive->dn * 4); 706 u8 itr_addr = 0x40 + (drive->dn * 4);
701 u32 old_itr = 0; 707 u32 old_itr = 0;
@@ -738,7 +744,8 @@ static void hpt3xx_maskproc(ide_drive_t *drive, int mask)
738{ 744{
739 ide_hwif_t *hwif = HWIF(drive); 745 ide_hwif_t *hwif = HWIF(drive);
740 struct pci_dev *dev = to_pci_dev(hwif->dev); 746 struct pci_dev *dev = to_pci_dev(hwif->dev);
741 struct hpt_info *info = pci_get_drvdata(dev); 747 struct ide_host *host = pci_get_drvdata(dev);
748 struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
742 749
743 if (drive->quirk_list) { 750 if (drive->quirk_list) {
744 if (info->chip_type >= HPT370) { 751 if (info->chip_type >= HPT370) {
@@ -963,24 +970,16 @@ static int __devinit hpt37x_calibrate_dpll(struct pci_dev *dev, u16 f_low, u16 f
963 return 1; 970 return 1;
964} 971}
965 972
966static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const char *name) 973static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev)
967{ 974{
968 struct hpt_info *info = kmalloc(sizeof(struct hpt_info), GFP_KERNEL);
969 unsigned long io_base = pci_resource_start(dev, 4); 975 unsigned long io_base = pci_resource_start(dev, 4);
976 struct ide_host *host = pci_get_drvdata(dev);
977 struct hpt_info *info = host->host_priv + (&dev->dev == host->dev[1]);
978 const char *name = DRV_NAME;
970 u8 pci_clk, dpll_clk = 0; /* PCI and DPLL clock in MHz */ 979 u8 pci_clk, dpll_clk = 0; /* PCI and DPLL clock in MHz */
971 u8 chip_type; 980 u8 chip_type;
972 enum ata_clock clock; 981 enum ata_clock clock;
973 982
974 if (info == NULL) {
975 printk(KERN_ERR "%s: out of memory!\n", name);
976 return -ENOMEM;
977 }
978
979 /*
980 * Copy everything from a static "template" structure
981 * to just allocated per-chip hpt_info structure.
982 */
983 memcpy(info, pci_get_drvdata(dev), sizeof(struct hpt_info));
984 chip_type = info->chip_type; 983 chip_type = info->chip_type;
985 984
986 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4)); 985 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, (L1_CACHE_BYTES / 4));
@@ -1048,8 +1047,8 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
1048 if ((temp & 0xFFFFF000) != 0xABCDE000) { 1047 if ((temp & 0xFFFFF000) != 0xABCDE000) {
1049 int i; 1048 int i;
1050 1049
1051 printk(KERN_WARNING "%s: no clock data saved by BIOS\n", 1050 printk(KERN_WARNING "%s %s: no clock data saved by "
1052 name); 1051 "BIOS\n", name, pci_name(dev));
1053 1052
1054 /* Calculate the average value of f_CNT. */ 1053 /* Calculate the average value of f_CNT. */
1055 for (temp = i = 0; i < 128; i++) { 1054 for (temp = i = 0; i < 128; i++) {
@@ -1074,8 +1073,9 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
1074 else 1073 else
1075 pci_clk = 66; 1074 pci_clk = 66;
1076 1075
1077 printk(KERN_INFO "%s: DPLL base: %d MHz, f_CNT: %d, " 1076 printk(KERN_INFO "%s %s: DPLL base: %d MHz, f_CNT: %d, "
1078 "assuming %d MHz PCI\n", name, dpll_clk, f_cnt, pci_clk); 1077 "assuming %d MHz PCI\n", name, pci_name(dev),
1078 dpll_clk, f_cnt, pci_clk);
1079 } else { 1079 } else {
1080 u32 itr1 = 0; 1080 u32 itr1 = 0;
1081 1081
@@ -1141,8 +1141,8 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
1141 } 1141 }
1142 1142
1143 if (info->timings->clock_table[clock] == NULL) { 1143 if (info->timings->clock_table[clock] == NULL) {
1144 printk(KERN_ERR "%s: unknown bus timing!\n", name); 1144 printk(KERN_ERR "%s %s: unknown bus timing!\n",
1145 kfree(info); 1145 name, pci_name(dev));
1146 return -EIO; 1146 return -EIO;
1147 } 1147 }
1148 1148
@@ -1168,17 +1168,19 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
1168 f_low += adjust >> 1; 1168 f_low += adjust >> 1;
1169 } 1169 }
1170 if (adjust == 8) { 1170 if (adjust == 8) {
1171 printk(KERN_ERR "%s: DPLL did not stabilize!\n", name); 1171 printk(KERN_ERR "%s %s: DPLL did not stabilize!\n",
1172 kfree(info); 1172 name, pci_name(dev));
1173 return -EIO; 1173 return -EIO;
1174 } 1174 }
1175 1175
1176 printk("%s: using %d MHz DPLL clock\n", name, dpll_clk); 1176 printk(KERN_INFO "%s %s: using %d MHz DPLL clock\n",
1177 name, pci_name(dev), dpll_clk);
1177 } else { 1178 } else {
1178 /* Mark the fact that we're not using the DPLL. */ 1179 /* Mark the fact that we're not using the DPLL. */
1179 dpll_clk = 0; 1180 dpll_clk = 0;
1180 1181
1181 printk("%s: using %d MHz PCI clock\n", name, pci_clk); 1182 printk(KERN_INFO "%s %s: using %d MHz PCI clock\n",
1183 name, pci_name(dev), pci_clk);
1182 } 1184 }
1183 1185
1184 /* Store the clock frequencies. */ 1186 /* Store the clock frequencies. */
@@ -1186,9 +1188,6 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
1186 info->pci_clk = pci_clk; 1188 info->pci_clk = pci_clk;
1187 info->clock = clock; 1189 info->clock = clock;
1188 1190
1189 /* Point to this chip's own instance of the hpt_info structure. */
1190 pci_set_drvdata(dev, info);
1191
1192 if (chip_type >= HPT370) { 1191 if (chip_type >= HPT370) {
1193 u8 mcr1, mcr4; 1192 u8 mcr1, mcr4;
1194 1193
@@ -1218,7 +1217,8 @@ static unsigned int __devinit init_chipset_hpt366(struct pci_dev *dev, const cha
1218static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif) 1217static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif)
1219{ 1218{
1220 struct pci_dev *dev = to_pci_dev(hwif->dev); 1219 struct pci_dev *dev = to_pci_dev(hwif->dev);
1221 struct hpt_info *info = pci_get_drvdata(dev); 1220 struct ide_host *host = pci_get_drvdata(dev);
1221 struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
1222 u8 chip_type = info->chip_type; 1222 u8 chip_type = info->chip_type;
1223 u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02; 1223 u8 scr1 = 0, ata66 = hwif->channel ? 0x01 : 0x02;
1224 1224
@@ -1262,7 +1262,8 @@ static u8 __devinit hpt3xx_cable_detect(ide_hwif_t *hwif)
1262static void __devinit init_hwif_hpt366(ide_hwif_t *hwif) 1262static void __devinit init_hwif_hpt366(ide_hwif_t *hwif)
1263{ 1263{
1264 struct pci_dev *dev = to_pci_dev(hwif->dev); 1264 struct pci_dev *dev = to_pci_dev(hwif->dev);
1265 struct hpt_info *info = pci_get_drvdata(dev); 1265 struct ide_host *host = pci_get_drvdata(dev);
1266 struct hpt_info *info = host->host_priv + (hwif->dev == host->dev[1]);
1266 int serialize = HPT_SERIALIZE_IO; 1267 int serialize = HPT_SERIALIZE_IO;
1267 u8 chip_type = info->chip_type; 1268 u8 chip_type = info->chip_type;
1268 u8 new_mcr, old_mcr = 0; 1269 u8 new_mcr, old_mcr = 0;
@@ -1364,7 +1365,8 @@ static void __devinit hpt374_init(struct pci_dev *dev, struct pci_dev *dev2)
1364 if (dev2->irq != dev->irq) { 1365 if (dev2->irq != dev->irq) {
1365 /* FIXME: we need a core pci_set_interrupt() */ 1366 /* FIXME: we need a core pci_set_interrupt() */
1366 dev2->irq = dev->irq; 1367 dev2->irq = dev->irq;
1367 printk(KERN_INFO "HPT374: PCI config space interrupt fixed\n"); 1368 printk(KERN_INFO DRV_NAME " %s: PCI config space interrupt "
1369 "fixed\n", pci_name(dev2));
1368 } 1370 }
1369} 1371}
1370 1372
@@ -1399,8 +1401,8 @@ static int __devinit hpt36x_init(struct pci_dev *dev, struct pci_dev *dev2)
1399 pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin2); 1401 pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin2);
1400 1402
1401 if (pin1 != pin2 && dev->irq == dev2->irq) { 1403 if (pin1 != pin2 && dev->irq == dev2->irq) {
1402 printk(KERN_INFO "HPT36x: onboard version of chipset, " 1404 printk(KERN_INFO DRV_NAME " %s: onboard version of chipset, "
1403 "pin1=%d pin2=%d\n", pin1, pin2); 1405 "pin1=%d pin2=%d\n", pci_name(dev), pin1, pin2);
1404 return 1; 1406 return 1;
1405 } 1407 }
1406 1408
@@ -1455,8 +1457,8 @@ static const struct ide_dma_ops hpt36x_dma_ops = {
1455}; 1457};
1456 1458
1457static const struct ide_port_info hpt366_chipsets[] __devinitdata = { 1459static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
1458 { /* 0 */ 1460 { /* 0: HPT36x */
1459 .name = "HPT36x", 1461 .name = DRV_NAME,
1460 .init_chipset = init_chipset_hpt366, 1462 .init_chipset = init_chipset_hpt366,
1461 .init_hwif = init_hwif_hpt366, 1463 .init_hwif = init_hwif_hpt366,
1462 .init_dma = init_dma_hpt366, 1464 .init_dma = init_dma_hpt366,
@@ -1472,53 +1474,9 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
1472 .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE, 1474 .host_flags = IDE_HFLAGS_HPT3XX | IDE_HFLAG_SINGLE,
1473 .pio_mask = ATA_PIO4, 1475 .pio_mask = ATA_PIO4,
1474 .mwdma_mask = ATA_MWDMA2, 1476 .mwdma_mask = ATA_MWDMA2,
1475 },{ /* 1 */ 1477 },
1476 .name = "HPT372A", 1478 { /* 1: HPT3xx */
1477 .init_chipset = init_chipset_hpt366, 1479 .name = DRV_NAME,
1478 .init_hwif = init_hwif_hpt366,
1479 .init_dma = init_dma_hpt366,
1480 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
1481 .port_ops = &hpt3xx_port_ops,
1482 .dma_ops = &hpt37x_dma_ops,
1483 .host_flags = IDE_HFLAGS_HPT3XX,
1484 .pio_mask = ATA_PIO4,
1485 .mwdma_mask = ATA_MWDMA2,
1486 },{ /* 2 */
1487 .name = "HPT302",
1488 .init_chipset = init_chipset_hpt366,
1489 .init_hwif = init_hwif_hpt366,
1490 .init_dma = init_dma_hpt366,
1491 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
1492 .port_ops = &hpt3xx_port_ops,
1493 .dma_ops = &hpt37x_dma_ops,
1494 .host_flags = IDE_HFLAGS_HPT3XX,
1495 .pio_mask = ATA_PIO4,
1496 .mwdma_mask = ATA_MWDMA2,
1497 },{ /* 3 */
1498 .name = "HPT371",
1499 .init_chipset = init_chipset_hpt366,
1500 .init_hwif = init_hwif_hpt366,
1501 .init_dma = init_dma_hpt366,
1502 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
1503 .port_ops = &hpt3xx_port_ops,
1504 .dma_ops = &hpt37x_dma_ops,
1505 .host_flags = IDE_HFLAGS_HPT3XX,
1506 .pio_mask = ATA_PIO4,
1507 .mwdma_mask = ATA_MWDMA2,
1508 },{ /* 4 */
1509 .name = "HPT374",
1510 .init_chipset = init_chipset_hpt366,
1511 .init_hwif = init_hwif_hpt366,
1512 .init_dma = init_dma_hpt366,
1513 .enablebits = {{0x50,0x04,0x04}, {0x54,0x04,0x04}},
1514 .udma_mask = ATA_UDMA5,
1515 .port_ops = &hpt3xx_port_ops,
1516 .dma_ops = &hpt37x_dma_ops,
1517 .host_flags = IDE_HFLAGS_HPT3XX,
1518 .pio_mask = ATA_PIO4,
1519 .mwdma_mask = ATA_MWDMA2,
1520 },{ /* 5 */
1521 .name = "HPT372N",
1522 .init_chipset = init_chipset_hpt366, 1480 .init_chipset = init_chipset_hpt366,
1523 .init_hwif = init_hwif_hpt366, 1481 .init_hwif = init_hwif_hpt366,
1524 .init_dma = init_dma_hpt366, 1482 .init_dma = init_dma_hpt366,
@@ -1542,10 +1500,12 @@ static const struct ide_port_info hpt366_chipsets[] __devinitdata = {
1542static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) 1500static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id)
1543{ 1501{
1544 const struct hpt_info *info = NULL; 1502 const struct hpt_info *info = NULL;
1503 struct hpt_info *dyn_info;
1545 struct pci_dev *dev2 = NULL; 1504 struct pci_dev *dev2 = NULL;
1546 struct ide_port_info d; 1505 struct ide_port_info d;
1547 u8 idx = id->driver_data; 1506 u8 idx = id->driver_data;
1548 u8 rev = dev->revision; 1507 u8 rev = dev->revision;
1508 int ret;
1549 1509
1550 if ((idx == 0 || idx == 4) && (PCI_FUNC(dev->devfn) & 1)) 1510 if ((idx == 0 || idx == 4) && (PCI_FUNC(dev->devfn) & 1))
1551 return -ENODEV; 1511 return -ENODEV;
@@ -1582,24 +1542,35 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
1582 break; 1542 break;
1583 } 1543 }
1584 1544
1585 d = hpt366_chipsets[idx]; 1545 printk(KERN_INFO DRV_NAME ": %s chipset detected\n", info->chip_name);
1546
1547 d = hpt366_chipsets[min_t(u8, idx, 1)];
1586 1548
1587 d.name = info->chip_name;
1588 d.udma_mask = info->udma_mask; 1549 d.udma_mask = info->udma_mask;
1589 1550
1590 /* fixup ->dma_ops for HPT370/HPT370A */ 1551 /* fixup ->dma_ops for HPT370/HPT370A */
1591 if (info == &hpt370 || info == &hpt370a) 1552 if (info == &hpt370 || info == &hpt370a)
1592 d.dma_ops = &hpt370_dma_ops; 1553 d.dma_ops = &hpt370_dma_ops;
1593 1554
1594 pci_set_drvdata(dev, (void *)info);
1595
1596 if (info == &hpt36x || info == &hpt374) 1555 if (info == &hpt36x || info == &hpt374)
1597 dev2 = pci_get_slot(dev->bus, dev->devfn + 1); 1556 dev2 = pci_get_slot(dev->bus, dev->devfn + 1);
1598 1557
1599 if (dev2) { 1558 dyn_info = kzalloc(sizeof(*dyn_info) * (dev2 ? 2 : 1), GFP_KERNEL);
1600 int ret; 1559 if (dyn_info == NULL) {
1560 printk(KERN_ERR "%s %s: out of memory!\n",
1561 d.name, pci_name(dev));
1562 pci_dev_put(dev2);
1563 return -ENOMEM;
1564 }
1565
1566 /*
1567 * Copy everything from a static "template" structure
1568 * to just allocated per-chip hpt_info structure.
1569 */
1570 memcpy(dyn_info, info, sizeof(*dyn_info));
1601 1571
1602 pci_set_drvdata(dev2, (void *)info); 1572 if (dev2) {
1573 memcpy(dyn_info + 1, info, sizeof(*dyn_info));
1603 1574
1604 if (info == &hpt374) 1575 if (info == &hpt374)
1605 hpt374_init(dev, dev2); 1576 hpt374_init(dev, dev2);
@@ -1608,13 +1579,30 @@ static int __devinit hpt366_init_one(struct pci_dev *dev, const struct pci_devic
1608 d.host_flags &= ~IDE_HFLAG_NON_BOOTABLE; 1579 d.host_flags &= ~IDE_HFLAG_NON_BOOTABLE;
1609 } 1580 }
1610 1581
1611 ret = ide_setup_pci_devices(dev, dev2, &d); 1582 ret = ide_pci_init_two(dev, dev2, &d, dyn_info);
1612 if (ret < 0) 1583 if (ret < 0) {
1613 pci_dev_put(dev2); 1584 pci_dev_put(dev2);
1585 kfree(dyn_info);
1586 }
1614 return ret; 1587 return ret;
1615 } 1588 }
1616 1589
1617 return ide_setup_pci_device(dev, &d); 1590 ret = ide_pci_init_one(dev, &d, dyn_info);
1591 if (ret < 0)
1592 kfree(dyn_info);
1593
1594 return ret;
1595}
1596
1597static void __devexit hpt366_remove(struct pci_dev *dev)
1598{
1599 struct ide_host *host = pci_get_drvdata(dev);
1600 struct ide_info *info = host->host_priv;
1601 struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL;
1602
1603 ide_pci_remove(dev);
1604 pci_dev_put(dev2);
1605 kfree(info);
1618} 1606}
1619 1607
1620static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = { 1608static const struct pci_device_id hpt366_pci_tbl[] __devinitconst = {
@@ -1632,6 +1620,7 @@ static struct pci_driver driver = {
1632 .name = "HPT366_IDE", 1620 .name = "HPT366_IDE",
1633 .id_table = hpt366_pci_tbl, 1621 .id_table = hpt366_pci_tbl,
1634 .probe = hpt366_init_one, 1622 .probe = hpt366_init_one,
1623 .remove = hpt366_remove,
1635}; 1624};
1636 1625
1637static int __init hpt366_ide_init(void) 1626static int __init hpt366_ide_init(void)
@@ -1639,7 +1628,13 @@ static int __init hpt366_ide_init(void)
1639 return ide_pci_register_driver(&driver); 1628 return ide_pci_register_driver(&driver);
1640} 1629}
1641 1630
1631static void __exit hpt366_ide_exit(void)
1632{
1633 pci_unregister_driver(&driver);
1634}
1635
1642module_init(hpt366_ide_init); 1636module_init(hpt366_ide_init);
1637module_exit(hpt366_ide_exit);
1643 1638
1644MODULE_AUTHOR("Andre Hedrick"); 1639MODULE_AUTHOR("Andre Hedrick");
1645MODULE_DESCRIPTION("PCI driver module for Highpoint HPT366 IDE"); 1640MODULE_DESCRIPTION("PCI driver module for Highpoint HPT366 IDE");
diff --git a/drivers/ide/pci/it8213.c b/drivers/ide/pci/it8213.c
index 2b71bdf74e73..6eba8f188264 100644
--- a/drivers/ide/pci/it8213.c
+++ b/drivers/ide/pci/it8213.c
@@ -14,6 +14,8 @@
14#include <linux/ide.h> 14#include <linux/ide.h>
15#include <linux/init.h> 15#include <linux/init.h>
16 16
17#define DRV_NAME "it8213"
18
17/** 19/**
18 * it8213_set_pio_mode - set host controller for PIO mode 20 * it8213_set_pio_mode - set host controller for PIO mode
19 * @drive: drive 21 * @drive: drive
@@ -155,23 +157,17 @@ static const struct ide_port_ops it8213_port_ops = {
155 .cable_detect = it8213_cable_detect, 157 .cable_detect = it8213_cable_detect,
156}; 158};
157 159
158#define DECLARE_ITE_DEV(name_str) \ 160static const struct ide_port_info it8213_chipset __devinitdata = {
159 { \ 161 .name = DRV_NAME,
160 .name = name_str, \ 162 .enablebits = { {0x41, 0x80, 0x80} },
161 .enablebits = { {0x41, 0x80, 0x80} }, \ 163 .port_ops = &it8213_port_ops,
162 .port_ops = &it8213_port_ops, \ 164 .host_flags = IDE_HFLAG_SINGLE,
163 .host_flags = IDE_HFLAG_SINGLE, \ 165 .pio_mask = ATA_PIO4,
164 .pio_mask = ATA_PIO4, \ 166 .swdma_mask = ATA_SWDMA2_ONLY,
165 .swdma_mask = ATA_SWDMA2_ONLY, \ 167 .mwdma_mask = ATA_MWDMA12_ONLY,
166 .mwdma_mask = ATA_MWDMA12_ONLY, \ 168 .udma_mask = ATA_UDMA6,
167 .udma_mask = ATA_UDMA6, \
168 }
169
170static const struct ide_port_info it8213_chipsets[] __devinitdata = {
171 /* 0 */ DECLARE_ITE_DEV("IT8213"),
172}; 169};
173 170
174
175/** 171/**
176 * it8213_init_one - pci layer discovery entry 172 * it8213_init_one - pci layer discovery entry
177 * @dev: PCI device 173 * @dev: PCI device
@@ -184,7 +180,7 @@ static const struct ide_port_info it8213_chipsets[] __devinitdata = {
184 180
185static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_device_id *id) 181static int __devinit it8213_init_one(struct pci_dev *dev, const struct pci_device_id *id)
186{ 182{
187 return ide_setup_pci_device(dev, &it8213_chipsets[id->driver_data]); 183 return ide_pci_init_one(dev, &it8213_chipset, NULL);
188} 184}
189 185
190static const struct pci_device_id it8213_pci_tbl[] = { 186static const struct pci_device_id it8213_pci_tbl[] = {
@@ -198,6 +194,7 @@ static struct pci_driver driver = {
198 .name = "ITE8213_IDE", 194 .name = "ITE8213_IDE",
199 .id_table = it8213_pci_tbl, 195 .id_table = it8213_pci_tbl,
200 .probe = it8213_init_one, 196 .probe = it8213_init_one,
197 .remove = ide_pci_remove,
201}; 198};
202 199
203static int __init it8213_ide_init(void) 200static int __init it8213_ide_init(void)
@@ -205,7 +202,13 @@ static int __init it8213_ide_init(void)
205 return ide_pci_register_driver(&driver); 202 return ide_pci_register_driver(&driver);
206} 203}
207 204
205static void __exit it8213_ide_exit(void)
206{
207 pci_unregister_driver(&driver);
208}
209
208module_init(it8213_ide_init); 210module_init(it8213_ide_init);
211module_exit(it8213_ide_exit);
209 212
210MODULE_AUTHOR("Jack Lee, Alan Cox"); 213MODULE_AUTHOR("Jack Lee, Alan Cox");
211MODULE_DESCRIPTION("PCI driver module for the ITE 8213"); 214MODULE_DESCRIPTION("PCI driver module for the ITE 8213");
diff --git a/drivers/ide/pci/it821x.c b/drivers/ide/pci/it821x.c
index cbf647202994..e16a1d113a2a 100644
--- a/drivers/ide/pci/it821x.c
+++ b/drivers/ide/pci/it821x.c
@@ -67,6 +67,8 @@
67#include <linux/ide.h> 67#include <linux/ide.h>
68#include <linux/init.h> 68#include <linux/init.h>
69 69
70#define DRV_NAME "it821x"
71
70struct it821x_dev 72struct it821x_dev
71{ 73{
72 unsigned int smart:1, /* Are we in smart raid mode */ 74 unsigned int smart:1, /* Are we in smart raid mode */
@@ -534,8 +536,9 @@ static struct ide_dma_ops it821x_pass_through_dma_ops = {
534static void __devinit init_hwif_it821x(ide_hwif_t *hwif) 536static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
535{ 537{
536 struct pci_dev *dev = to_pci_dev(hwif->dev); 538 struct pci_dev *dev = to_pci_dev(hwif->dev);
537 struct it821x_dev **itdevs = (struct it821x_dev **)pci_get_drvdata(dev); 539 struct ide_host *host = pci_get_drvdata(dev);
538 struct it821x_dev *idev = itdevs[hwif->channel]; 540 struct it821x_dev *itdevs = host->host_priv;
541 struct it821x_dev *idev = itdevs + hwif->channel;
539 u8 conf; 542 u8 conf;
540 543
541 ide_set_hwifdata(hwif, idev); 544 ide_set_hwifdata(hwif, idev);
@@ -568,7 +571,8 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
568 idev->timing10 = 1; 571 idev->timing10 = 1;
569 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA; 572 hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
570 if (idev->smart == 0) 573 if (idev->smart == 0)
571 printk(KERN_WARNING "it821x: Revision 0x10, workarounds activated.\n"); 574 printk(KERN_WARNING DRV_NAME " %s: revision 0x10, "
575 "workarounds activated\n", pci_name(dev));
572 } 576 }
573 577
574 if (idev->smart == 0) { 578 if (idev->smart == 0) {
@@ -601,18 +605,20 @@ static void __devinit it8212_disable_raid(struct pci_dev *dev)
601 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20); 605 pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0x20);
602} 606}
603 607
604static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const char *name) 608static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev)
605{ 609{
606 u8 conf; 610 u8 conf;
607 static char *mode[2] = { "pass through", "smart" }; 611 static char *mode[2] = { "pass through", "smart" };
608 612
609 /* Force the card into bypass mode if so requested */ 613 /* Force the card into bypass mode if so requested */
610 if (it8212_noraid) { 614 if (it8212_noraid) {
611 printk(KERN_INFO "it8212: forcing bypass mode.\n"); 615 printk(KERN_INFO DRV_NAME " %s: forcing bypass mode\n",
616 pci_name(dev));
612 it8212_disable_raid(dev); 617 it8212_disable_raid(dev);
613 } 618 }
614 pci_read_config_byte(dev, 0x50, &conf); 619 pci_read_config_byte(dev, 0x50, &conf);
615 printk(KERN_INFO "it821x: controller in %s mode.\n", mode[conf & 1]); 620 printk(KERN_INFO DRV_NAME " %s: controller in %s mode\n",
621 pci_name(dev), mode[conf & 1]);
616 return 0; 622 return 0;
617} 623}
618 624
@@ -624,17 +630,12 @@ static const struct ide_port_ops it821x_port_ops = {
624 .cable_detect = it821x_cable_detect, 630 .cable_detect = it821x_cable_detect,
625}; 631};
626 632
627#define DECLARE_ITE_DEV(name_str) \ 633static const struct ide_port_info it821x_chipset __devinitdata = {
628 { \ 634 .name = DRV_NAME,
629 .name = name_str, \ 635 .init_chipset = init_chipset_it821x,
630 .init_chipset = init_chipset_it821x, \ 636 .init_hwif = init_hwif_it821x,
631 .init_hwif = init_hwif_it821x, \ 637 .port_ops = &it821x_port_ops,
632 .port_ops = &it821x_port_ops, \ 638 .pio_mask = ATA_PIO4,
633 .pio_mask = ATA_PIO4, \
634 }
635
636static const struct ide_port_info it821x_chipsets[] __devinitdata = {
637 /* 0 */ DECLARE_ITE_DEV("IT8212"),
638}; 639};
639 640
640/** 641/**
@@ -648,23 +649,29 @@ static const struct ide_port_info it821x_chipsets[] __devinitdata = {
648 649
649static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) 650static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
650{ 651{
651 struct it821x_dev *itdevs[2] = { NULL, NULL} , *itdev; 652 struct it821x_dev *itdevs;
652 unsigned int i; 653 int rc;
653
654 for (i = 0; i < 2; i++) {
655 itdev = kzalloc(sizeof(*itdev), GFP_KERNEL);
656 if (itdev == NULL) {
657 kfree(itdevs[0]);
658 printk(KERN_ERR "it821x: out of memory\n");
659 return -ENOMEM;
660 }
661 654
662 itdevs[i] = itdev; 655 itdevs = kzalloc(2 * sizeof(*itdevs), GFP_KERNEL);
656 if (itdevs == NULL) {
657 printk(KERN_ERR DRV_NAME " %s: out of memory\n", pci_name(dev));
658 return -ENOMEM;
663 } 659 }
664 660
665 pci_set_drvdata(dev, itdevs); 661 rc = ide_pci_init_one(dev, &it821x_chipset, itdevs);
662 if (rc)
663 kfree(itdevs);
666 664
667 return ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]); 665 return rc;
666}
667
668static void __devexit it821x_remove(struct pci_dev *dev)
669{
670 struct ide_host *host = pci_get_drvdata(dev);
671 struct it821x_dev *itdevs = host->host_priv;
672
673 ide_pci_remove(dev);
674 kfree(itdevs);
668} 675}
669 676
670static const struct pci_device_id it821x_pci_tbl[] = { 677static const struct pci_device_id it821x_pci_tbl[] = {
@@ -679,6 +686,7 @@ static struct pci_driver driver = {
679 .name = "ITE821x IDE", 686 .name = "ITE821x IDE",
680 .id_table = it821x_pci_tbl, 687 .id_table = it821x_pci_tbl,
681 .probe = it821x_init_one, 688 .probe = it821x_init_one,
689 .remove = it821x_remove,
682}; 690};
683 691
684static int __init it821x_ide_init(void) 692static int __init it821x_ide_init(void)
@@ -686,7 +694,13 @@ static int __init it821x_ide_init(void)
686 return ide_pci_register_driver(&driver); 694 return ide_pci_register_driver(&driver);
687} 695}
688 696
697static void __exit it821x_ide_exit(void)
698{
699 pci_unregister_driver(&driver);
700}
701
689module_init(it821x_ide_init); 702module_init(it821x_ide_init);
703module_exit(it821x_ide_exit);
690 704
691module_param_named(noraid, it8212_noraid, int, S_IRUGO); 705module_param_named(noraid, it8212_noraid, int, S_IRUGO);
692MODULE_PARM_DESC(noraid, "Force card into bypass mode"); 706MODULE_PARM_DESC(noraid, "Force card into bypass mode");
diff --git a/drivers/ide/pci/jmicron.c b/drivers/ide/pci/jmicron.c
index 96ef7394f283..545b6e172d9b 100644
--- a/drivers/ide/pci/jmicron.c
+++ b/drivers/ide/pci/jmicron.c
@@ -12,6 +12,8 @@
12#include <linux/ide.h> 12#include <linux/ide.h>
13#include <linux/init.h> 13#include <linux/init.h>
14 14
15#define DRV_NAME "jmicron"
16
15typedef enum { 17typedef enum {
16 PORT_PATA0 = 0, 18 PORT_PATA0 = 0,
17 PORT_PATA1 = 1, 19 PORT_PATA1 = 1,
@@ -102,7 +104,7 @@ static const struct ide_port_ops jmicron_port_ops = {
102}; 104};
103 105
104static const struct ide_port_info jmicron_chipset __devinitdata = { 106static const struct ide_port_info jmicron_chipset __devinitdata = {
105 .name = "JMB", 107 .name = DRV_NAME,
106 .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } }, 108 .enablebits = { { 0x40, 0x01, 0x01 }, { 0x40, 0x10, 0x10 } },
107 .port_ops = &jmicron_port_ops, 109 .port_ops = &jmicron_port_ops,
108 .pio_mask = ATA_PIO5, 110 .pio_mask = ATA_PIO5,
@@ -121,7 +123,7 @@ static const struct ide_port_info jmicron_chipset __devinitdata = {
121 123
122static int __devinit jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id) 124static int __devinit jmicron_init_one(struct pci_dev *dev, const struct pci_device_id *id)
123{ 125{
124 return ide_setup_pci_device(dev, &jmicron_chipset); 126 return ide_pci_init_one(dev, &jmicron_chipset, NULL);
125} 127}
126 128
127/* All JMB PATA controllers have and will continue to have the same 129/* All JMB PATA controllers have and will continue to have the same
@@ -152,6 +154,7 @@ static struct pci_driver driver = {
152 .name = "JMicron IDE", 154 .name = "JMicron IDE",
153 .id_table = jmicron_pci_tbl, 155 .id_table = jmicron_pci_tbl,
154 .probe = jmicron_init_one, 156 .probe = jmicron_init_one,
157 .remove = ide_pci_remove,
155}; 158};
156 159
157static int __init jmicron_ide_init(void) 160static int __init jmicron_ide_init(void)
@@ -159,7 +162,13 @@ static int __init jmicron_ide_init(void)
159 return ide_pci_register_driver(&driver); 162 return ide_pci_register_driver(&driver);
160} 163}
161 164
165static void __exit jmicron_ide_exit(void)
166{
167 pci_unregister_driver(&driver);
168}
169
162module_init(jmicron_ide_init); 170module_init(jmicron_ide_init);
171module_exit(jmicron_ide_exit);
163 172
164MODULE_AUTHOR("Alan Cox"); 173MODULE_AUTHOR("Alan Cox");
165MODULE_DESCRIPTION("PCI driver module for the JMicron in legacy modes"); 174MODULE_DESCRIPTION("PCI driver module for the JMicron in legacy modes");
diff --git a/drivers/ide/pci/ns87415.c b/drivers/ide/pci/ns87415.c
index 5cd2b32ff0ef..ffefcd15196c 100644
--- a/drivers/ide/pci/ns87415.c
+++ b/drivers/ide/pci/ns87415.c
@@ -19,6 +19,8 @@
19 19
20#include <asm/io.h> 20#include <asm/io.h>
21 21
22#define DRV_NAME "ns87415"
23
22#ifdef CONFIG_SUPERIO 24#ifdef CONFIG_SUPERIO
23/* SUPERIO 87560 is a PoS chip that NatSem denies exists. 25/* SUPERIO 87560 is a PoS chip that NatSem denies exists.
24 * Unfortunately, it's built-in on all Astro-based PA-RISC workstations 26 * Unfortunately, it's built-in on all Astro-based PA-RISC workstations
@@ -305,7 +307,7 @@ static const struct ide_dma_ops ns87415_dma_ops = {
305}; 307};
306 308
307static const struct ide_port_info ns87415_chipset __devinitdata = { 309static const struct ide_port_info ns87415_chipset __devinitdata = {
308 .name = "NS87415", 310 .name = DRV_NAME,
309 .init_hwif = init_hwif_ns87415, 311 .init_hwif = init_hwif_ns87415,
310 .port_ops = &ns87415_port_ops, 312 .port_ops = &ns87415_port_ops,
311 .dma_ops = &ns87415_dma_ops, 313 .dma_ops = &ns87415_dma_ops,
@@ -324,7 +326,7 @@ static int __devinit ns87415_init_one(struct pci_dev *dev, const struct pci_devi
324 d.tp_ops = &superio_tp_ops; 326 d.tp_ops = &superio_tp_ops;
325 } 327 }
326#endif 328#endif
327 return ide_setup_pci_device(dev, &d); 329 return ide_pci_init_one(dev, &d, NULL);
328} 330}
329 331
330static const struct pci_device_id ns87415_pci_tbl[] = { 332static const struct pci_device_id ns87415_pci_tbl[] = {
@@ -337,6 +339,7 @@ static struct pci_driver driver = {
337 .name = "NS87415_IDE", 339 .name = "NS87415_IDE",
338 .id_table = ns87415_pci_tbl, 340 .id_table = ns87415_pci_tbl,
339 .probe = ns87415_init_one, 341 .probe = ns87415_init_one,
342 .remove = ide_pci_remove,
340}; 343};
341 344
342static int __init ns87415_ide_init(void) 345static int __init ns87415_ide_init(void)
@@ -344,7 +347,13 @@ static int __init ns87415_ide_init(void)
344 return ide_pci_register_driver(&driver); 347 return ide_pci_register_driver(&driver);
345} 348}
346 349
350static void __exit ns87415_ide_exit(void)
351{
352 pci_unregister_driver(&driver);
353}
354
347module_init(ns87415_ide_init); 355module_init(ns87415_ide_init);
356module_exit(ns87415_ide_exit);
348 357
349MODULE_AUTHOR("Mark Lord, Eddie Dost, Andre Hedrick"); 358MODULE_AUTHOR("Mark Lord, Eddie Dost, Andre Hedrick");
350MODULE_DESCRIPTION("PCI driver module for NS87415 IDE"); 359MODULE_DESCRIPTION("PCI driver module for NS87415 IDE");
diff --git a/drivers/ide/pci/opti621.c b/drivers/ide/pci/opti621.c
index 725c80508d90..e28e672ddafc 100644
--- a/drivers/ide/pci/opti621.c
+++ b/drivers/ide/pci/opti621.c
@@ -90,6 +90,8 @@
90 90
91#include <asm/io.h> 91#include <asm/io.h>
92 92
93#define DRV_NAME "opti621"
94
93#define READ_REG 0 /* index of Read cycle timing register */ 95#define READ_REG 0 /* index of Read cycle timing register */
94#define WRITE_REG 1 /* index of Write cycle timing register */ 96#define WRITE_REG 1 /* index of Write cycle timing register */
95#define CNTRL_REG 3 /* index of Control register */ 97#define CNTRL_REG 3 /* index of Control register */
@@ -200,7 +202,7 @@ static const struct ide_port_ops opti621_port_ops = {
200}; 202};
201 203
202static const struct ide_port_info opti621_chipset __devinitdata = { 204static const struct ide_port_info opti621_chipset __devinitdata = {
203 .name = "OPTI621/X", 205 .name = DRV_NAME,
204 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} }, 206 .enablebits = { {0x45, 0x80, 0x00}, {0x40, 0x08, 0x00} },
205 .port_ops = &opti621_port_ops, 207 .port_ops = &opti621_port_ops,
206 .host_flags = IDE_HFLAG_NO_DMA, 208 .host_flags = IDE_HFLAG_NO_DMA,
@@ -209,7 +211,7 @@ static const struct ide_port_info opti621_chipset __devinitdata = {
209 211
210static int __devinit opti621_init_one(struct pci_dev *dev, const struct pci_device_id *id) 212static int __devinit opti621_init_one(struct pci_dev *dev, const struct pci_device_id *id)
211{ 213{
212 return ide_setup_pci_device(dev, &opti621_chipset); 214 return ide_pci_init_one(dev, &opti621_chipset, NULL);
213} 215}
214 216
215static const struct pci_device_id opti621_pci_tbl[] = { 217static const struct pci_device_id opti621_pci_tbl[] = {
@@ -223,6 +225,7 @@ static struct pci_driver driver = {
223 .name = "Opti621_IDE", 225 .name = "Opti621_IDE",
224 .id_table = opti621_pci_tbl, 226 .id_table = opti621_pci_tbl,
225 .probe = opti621_init_one, 227 .probe = opti621_init_one,
228 .remove = ide_pci_remove,
226}; 229};
227 230
228static int __init opti621_ide_init(void) 231static int __init opti621_ide_init(void)
@@ -230,7 +233,13 @@ static int __init opti621_ide_init(void)
230 return ide_pci_register_driver(&driver); 233 return ide_pci_register_driver(&driver);
231} 234}
232 235
236static void __exit opti621_ide_exit(void)
237{
238 pci_unregister_driver(&driver);
239}
240
233module_init(opti621_ide_init); 241module_init(opti621_ide_init);
242module_exit(opti621_ide_exit);
234 243
235MODULE_AUTHOR("Jaromir Koutek, Jan Harkes, Mark Lord"); 244MODULE_AUTHOR("Jaromir Koutek, Jan Harkes, Mark Lord");
236MODULE_DESCRIPTION("PCI driver module for Opti621 IDE"); 245MODULE_DESCRIPTION("PCI driver module for Opti621 IDE");
diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c
index 070df8ab3b21..998615fa285f 100644
--- a/drivers/ide/pci/pdc202xx_new.c
+++ b/drivers/ide/pci/pdc202xx_new.c
@@ -31,6 +31,8 @@
31#include <asm/pci-bridge.h> 31#include <asm/pci-bridge.h>
32#endif 32#endif
33 33
34#define DRV_NAME "pdc202xx_new"
35
34#undef DEBUG 36#undef DEBUG
35 37
36#ifdef DEBUG 38#ifdef DEBUG
@@ -324,8 +326,9 @@ static void __devinit apple_kiwi_init(struct pci_dev *pdev)
324} 326}
325#endif /* CONFIG_PPC_PMAC */ 327#endif /* CONFIG_PPC_PMAC */
326 328
327static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const char *name) 329static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev)
328{ 330{
331 const char *name = DRV_NAME;
329 unsigned long dma_base = pci_resource_start(dev, 4); 332 unsigned long dma_base = pci_resource_start(dev, 4);
330 unsigned long sec_dma_base = dma_base + 0x08; 333 unsigned long sec_dma_base = dma_base + 0x08;
331 long pll_input, pll_output, ratio; 334 long pll_input, pll_output, ratio;
@@ -358,12 +361,13 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha
358 * registers setting. 361 * registers setting.
359 */ 362 */
360 pll_input = detect_pll_input_clock(dma_base); 363 pll_input = detect_pll_input_clock(dma_base);
361 printk("%s: PLL input clock is %ld kHz\n", name, pll_input / 1000); 364 printk(KERN_INFO "%s %s: PLL input clock is %ld kHz\n",
365 name, pci_name(dev), pll_input / 1000);
362 366
363 /* Sanity check */ 367 /* Sanity check */
364 if (unlikely(pll_input < 5000000L || pll_input > 70000000L)) { 368 if (unlikely(pll_input < 5000000L || pll_input > 70000000L)) {
365 printk(KERN_ERR "%s: Bad PLL input clock %ld Hz, giving up!\n", 369 printk(KERN_ERR "%s %s: Bad PLL input clock %ld Hz, giving up!"
366 name, pll_input); 370 "\n", name, pci_name(dev), pll_input);
367 goto out; 371 goto out;
368 } 372 }
369 373
@@ -399,7 +403,8 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha
399 r = 0x00; 403 r = 0x00;
400 } else { 404 } else {
401 /* Invalid ratio */ 405 /* Invalid ratio */
402 printk(KERN_ERR "%s: Bad ratio %ld, giving up!\n", name, ratio); 406 printk(KERN_ERR "%s %s: Bad ratio %ld, giving up!\n",
407 name, pci_name(dev), ratio);
403 goto out; 408 goto out;
404 } 409 }
405 410
@@ -409,7 +414,8 @@ static unsigned int __devinit init_chipset_pdcnew(struct pci_dev *dev, const cha
409 414
410 if (unlikely(f < 0 || f > 127)) { 415 if (unlikely(f < 0 || f > 127)) {
411 /* Invalid F */ 416 /* Invalid F */
412 printk(KERN_ERR "%s: F[%d] invalid!\n", name, f); 417 printk(KERN_ERR "%s %s: F[%d] invalid!\n",
418 name, pci_name(dev), f);
413 goto out; 419 goto out;
414 } 420 }
415 421
@@ -455,8 +461,8 @@ static struct pci_dev * __devinit pdc20270_get_dev2(struct pci_dev *dev)
455 461
456 if (dev2->irq != dev->irq) { 462 if (dev2->irq != dev->irq) {
457 dev2->irq = dev->irq; 463 dev2->irq = dev->irq;
458 printk(KERN_INFO "PDC20270: PCI config space " 464 printk(KERN_INFO DRV_NAME " %s: PCI config space "
459 "interrupt fixed\n"); 465 "interrupt fixed\n", pci_name(dev));
460 } 466 }
461 467
462 return dev2; 468 return dev2;
@@ -473,9 +479,9 @@ static const struct ide_port_ops pdcnew_port_ops = {
473 .cable_detect = pdcnew_cable_detect, 479 .cable_detect = pdcnew_cable_detect,
474}; 480};
475 481
476#define DECLARE_PDCNEW_DEV(name_str, udma) \ 482#define DECLARE_PDCNEW_DEV(udma) \
477 { \ 483 { \
478 .name = name_str, \ 484 .name = DRV_NAME, \
479 .init_chipset = init_chipset_pdcnew, \ 485 .init_chipset = init_chipset_pdcnew, \
480 .port_ops = &pdcnew_port_ops, \ 486 .port_ops = &pdcnew_port_ops, \
481 .host_flags = IDE_HFLAG_POST_SET_MODE | \ 487 .host_flags = IDE_HFLAG_POST_SET_MODE | \
@@ -487,13 +493,8 @@ static const struct ide_port_ops pdcnew_port_ops = {
487 } 493 }
488 494
489static const struct ide_port_info pdcnew_chipsets[] __devinitdata = { 495static const struct ide_port_info pdcnew_chipsets[] __devinitdata = {
490 /* 0 */ DECLARE_PDCNEW_DEV("PDC20268", ATA_UDMA5), 496 /* 0: PDC202{68,70} */ DECLARE_PDCNEW_DEV(ATA_UDMA5),
491 /* 1 */ DECLARE_PDCNEW_DEV("PDC20269", ATA_UDMA6), 497 /* 1: PDC202{69,71,75,76,77} */ DECLARE_PDCNEW_DEV(ATA_UDMA6),
492 /* 2 */ DECLARE_PDCNEW_DEV("PDC20270", ATA_UDMA5),
493 /* 3 */ DECLARE_PDCNEW_DEV("PDC20271", ATA_UDMA6),
494 /* 4 */ DECLARE_PDCNEW_DEV("PDC20275", ATA_UDMA6),
495 /* 5 */ DECLARE_PDCNEW_DEV("PDC20276", ATA_UDMA6),
496 /* 6 */ DECLARE_PDCNEW_DEV("PDC20277", ATA_UDMA6),
497}; 498};
498 499
499/** 500/**
@@ -507,13 +508,10 @@ static const struct ide_port_info pdcnew_chipsets[] __devinitdata = {
507 508
508static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_device_id *id) 509static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_device_id *id)
509{ 510{
510 const struct ide_port_info *d; 511 const struct ide_port_info *d = &pdcnew_chipsets[id->driver_data];
511 struct pci_dev *bridge = dev->bus->self; 512 struct pci_dev *bridge = dev->bus->self;
512 u8 idx = id->driver_data;
513
514 d = &pdcnew_chipsets[idx];
515 513
516 if (idx == 2 && bridge && 514 if (dev->device == PCI_DEVICE_ID_PROMISE_20270 && bridge &&
517 bridge->vendor == PCI_VENDOR_ID_DEC && 515 bridge->vendor == PCI_VENDOR_ID_DEC &&
518 bridge->device == PCI_DEVICE_ID_DEC_21150) { 516 bridge->device == PCI_DEVICE_ID_DEC_21150) {
519 struct pci_dev *dev2; 517 struct pci_dev *dev2;
@@ -524,33 +522,42 @@ static int __devinit pdc202new_init_one(struct pci_dev *dev, const struct pci_de
524 dev2 = pdc20270_get_dev2(dev); 522 dev2 = pdc20270_get_dev2(dev);
525 523
526 if (dev2) { 524 if (dev2) {
527 int ret = ide_setup_pci_devices(dev, dev2, d); 525 int ret = ide_pci_init_two(dev, dev2, d, NULL);
528 if (ret < 0) 526 if (ret < 0)
529 pci_dev_put(dev2); 527 pci_dev_put(dev2);
530 return ret; 528 return ret;
531 } 529 }
532 } 530 }
533 531
534 if (idx == 5 && bridge && 532 if (dev->device == PCI_DEVICE_ID_PROMISE_20276 && bridge &&
535 bridge->vendor == PCI_VENDOR_ID_INTEL && 533 bridge->vendor == PCI_VENDOR_ID_INTEL &&
536 (bridge->device == PCI_DEVICE_ID_INTEL_I960 || 534 (bridge->device == PCI_DEVICE_ID_INTEL_I960 ||
537 bridge->device == PCI_DEVICE_ID_INTEL_I960RM)) { 535 bridge->device == PCI_DEVICE_ID_INTEL_I960RM)) {
538 printk(KERN_INFO "PDC20276: attached to I2O RAID controller, " 536 printk(KERN_INFO DRV_NAME " %s: attached to I2O RAID controller,"
539 "skipping\n"); 537 " skipping\n", pci_name(dev));
540 return -ENODEV; 538 return -ENODEV;
541 } 539 }
542 540
543 return ide_setup_pci_device(dev, d); 541 return ide_pci_init_one(dev, d, NULL);
542}
543
544static void __devexit pdc202new_remove(struct pci_dev *dev)
545{
546 struct ide_host *host = pci_get_drvdata(dev);
547 struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL;
548
549 ide_pci_remove(dev);
550 pci_dev_put(dev2);
544} 551}
545 552
546static const struct pci_device_id pdc202new_pci_tbl[] = { 553static const struct pci_device_id pdc202new_pci_tbl[] = {
547 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20268), 0 }, 554 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20268), 0 },
548 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20269), 1 }, 555 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20269), 1 },
549 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20270), 2 }, 556 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20270), 0 },
550 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20271), 3 }, 557 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20271), 1 },
551 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20275), 4 }, 558 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20275), 1 },
552 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20276), 5 }, 559 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20276), 1 },
553 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20277), 6 }, 560 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20277), 1 },
554 { 0, }, 561 { 0, },
555}; 562};
556MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl); 563MODULE_DEVICE_TABLE(pci, pdc202new_pci_tbl);
@@ -559,6 +566,7 @@ static struct pci_driver driver = {
559 .name = "Promise_IDE", 566 .name = "Promise_IDE",
560 .id_table = pdc202new_pci_tbl, 567 .id_table = pdc202new_pci_tbl,
561 .probe = pdc202new_init_one, 568 .probe = pdc202new_init_one,
569 .remove = pdc202new_remove,
562}; 570};
563 571
564static int __init pdc202new_ide_init(void) 572static int __init pdc202new_ide_init(void)
@@ -566,7 +574,13 @@ static int __init pdc202new_ide_init(void)
566 return ide_pci_register_driver(&driver); 574 return ide_pci_register_driver(&driver);
567} 575}
568 576
577static void __exit pdc202new_ide_exit(void)
578{
579 pci_unregister_driver(&driver);
580}
581
569module_init(pdc202new_ide_init); 582module_init(pdc202new_ide_init);
583module_exit(pdc202new_ide_exit);
570 584
571MODULE_AUTHOR("Andre Hedrick, Frank Tiernan"); 585MODULE_AUTHOR("Andre Hedrick, Frank Tiernan");
572MODULE_DESCRIPTION("PCI driver module for Promise PDC20268 and higher"); 586MODULE_DESCRIPTION("PCI driver module for Promise PDC20268 and higher");
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c
index e54dc653b8c4..6ff2def58da0 100644
--- a/drivers/ide/pci/pdc202xx_old.c
+++ b/drivers/ide/pci/pdc202xx_old.c
@@ -20,6 +20,8 @@
20 20
21#include <asm/io.h> 21#include <asm/io.h>
22 22
23#define DRV_NAME "pdc202xx_old"
24
23#define PDC202XX_DEBUG_DRIVE_INFO 0 25#define PDC202XX_DEBUG_DRIVE_INFO 0
24 26
25static const char *pdc_quirk_drives[] = { 27static const char *pdc_quirk_drives[] = {
@@ -263,8 +265,7 @@ static void pdc202xx_dma_timeout(ide_drive_t *drive)
263 ide_dma_timeout(drive); 265 ide_dma_timeout(drive);
264} 266}
265 267
266static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev, 268static unsigned int __devinit init_chipset_pdc202xx(struct pci_dev *dev)
267 const char *name)
268{ 269{
269 unsigned long dmabase = pci_resource_start(dev, 4); 270 unsigned long dmabase = pci_resource_start(dev, 4);
270 u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0; 271 u8 udma_speed_flag = 0, primary_mode = 0, secondary_mode = 0;
@@ -304,8 +305,8 @@ static void __devinit pdc202ata4_fixup_irq(struct pci_dev *dev,
304 if (irq != irq2) { 305 if (irq != irq2) {
305 pci_write_config_byte(dev, 306 pci_write_config_byte(dev,
306 (PCI_INTERRUPT_LINE)|0x80, irq); /* 0xbc */ 307 (PCI_INTERRUPT_LINE)|0x80, irq); /* 0xbc */
307 printk(KERN_INFO "%s: PCI config space interrupt " 308 printk(KERN_INFO "%s %s: PCI config space interrupt "
308 "mirror fixed\n", name); 309 "mirror fixed\n", name, pci_name(dev));
309 } 310 }
310 } 311 }
311} 312}
@@ -350,9 +351,9 @@ static const struct ide_dma_ops pdc2026x_dma_ops = {
350 .dma_timeout = pdc202xx_dma_timeout, 351 .dma_timeout = pdc202xx_dma_timeout,
351}; 352};
352 353
353#define DECLARE_PDC2026X_DEV(name_str, udma, extra_flags) \ 354#define DECLARE_PDC2026X_DEV(udma, extra_flags) \
354 { \ 355 { \
355 .name = name_str, \ 356 .name = DRV_NAME, \
356 .init_chipset = init_chipset_pdc202xx, \ 357 .init_chipset = init_chipset_pdc202xx, \
357 .port_ops = &pdc2026x_port_ops, \ 358 .port_ops = &pdc2026x_port_ops, \
358 .dma_ops = &pdc2026x_dma_ops, \ 359 .dma_ops = &pdc2026x_dma_ops, \
@@ -363,8 +364,8 @@ static const struct ide_dma_ops pdc2026x_dma_ops = {
363 } 364 }
364 365
365static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = { 366static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = {
366 { /* 0 */ 367 { /* 0: PDC20246 */
367 .name = "PDC20246", 368 .name = DRV_NAME,
368 .init_chipset = init_chipset_pdc202xx, 369 .init_chipset = init_chipset_pdc202xx,
369 .port_ops = &pdc20246_port_ops, 370 .port_ops = &pdc20246_port_ops,
370 .dma_ops = &pdc20246_dma_ops, 371 .dma_ops = &pdc20246_dma_ops,
@@ -374,10 +375,10 @@ static const struct ide_port_info pdc202xx_chipsets[] __devinitdata = {
374 .udma_mask = ATA_UDMA2, 375 .udma_mask = ATA_UDMA2,
375 }, 376 },
376 377
377 /* 1 */ DECLARE_PDC2026X_DEV("PDC20262", ATA_UDMA4, 0), 378 /* 1: PDC2026{2,3} */
378 /* 2 */ DECLARE_PDC2026X_DEV("PDC20263", ATA_UDMA4, 0), 379 DECLARE_PDC2026X_DEV(ATA_UDMA4, 0),
379 /* 3 */ DECLARE_PDC2026X_DEV("PDC20265", ATA_UDMA5, IDE_HFLAG_RQSIZE_256), 380 /* 2: PDC2026{5,7} */
380 /* 4 */ DECLARE_PDC2026X_DEV("PDC20267", ATA_UDMA5, IDE_HFLAG_RQSIZE_256), 381 DECLARE_PDC2026X_DEV(ATA_UDMA5, IDE_HFLAG_RQSIZE_256),
381}; 382};
382 383
383/** 384/**
@@ -396,31 +397,32 @@ static int __devinit pdc202xx_init_one(struct pci_dev *dev, const struct pci_dev
396 397
397 d = &pdc202xx_chipsets[idx]; 398 d = &pdc202xx_chipsets[idx];
398 399
399 if (idx < 3) 400 if (idx < 2)
400 pdc202ata4_fixup_irq(dev, d->name); 401 pdc202ata4_fixup_irq(dev, d->name);
401 402
402 if (idx == 3) { 403 if (dev->vendor == PCI_DEVICE_ID_PROMISE_20265) {
403 struct pci_dev *bridge = dev->bus->self; 404 struct pci_dev *bridge = dev->bus->self;
404 405
405 if (bridge && 406 if (bridge &&
406 bridge->vendor == PCI_VENDOR_ID_INTEL && 407 bridge->vendor == PCI_VENDOR_ID_INTEL &&
407 (bridge->device == PCI_DEVICE_ID_INTEL_I960 || 408 (bridge->device == PCI_DEVICE_ID_INTEL_I960 ||
408 bridge->device == PCI_DEVICE_ID_INTEL_I960RM)) { 409 bridge->device == PCI_DEVICE_ID_INTEL_I960RM)) {
409 printk(KERN_INFO "ide: Skipping Promise PDC20265 " 410 printk(KERN_INFO DRV_NAME " %s: skipping Promise "
410 "attached to I2O RAID controller\n"); 411 "PDC20265 attached to I2O RAID controller\n",
412 pci_name(dev));
411 return -ENODEV; 413 return -ENODEV;
412 } 414 }
413 } 415 }
414 416
415 return ide_setup_pci_device(dev, d); 417 return ide_pci_init_one(dev, d, NULL);
416} 418}
417 419
418static const struct pci_device_id pdc202xx_pci_tbl[] = { 420static const struct pci_device_id pdc202xx_pci_tbl[] = {
419 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20246), 0 }, 421 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20246), 0 },
420 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20262), 1 }, 422 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20262), 1 },
421 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20263), 2 }, 423 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20263), 1 },
422 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20265), 3 }, 424 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20265), 2 },
423 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20267), 4 }, 425 { PCI_VDEVICE(PROMISE, PCI_DEVICE_ID_PROMISE_20267), 2 },
424 { 0, }, 426 { 0, },
425}; 427};
426MODULE_DEVICE_TABLE(pci, pdc202xx_pci_tbl); 428MODULE_DEVICE_TABLE(pci, pdc202xx_pci_tbl);
@@ -429,6 +431,7 @@ static struct pci_driver driver = {
429 .name = "Promise_Old_IDE", 431 .name = "Promise_Old_IDE",
430 .id_table = pdc202xx_pci_tbl, 432 .id_table = pdc202xx_pci_tbl,
431 .probe = pdc202xx_init_one, 433 .probe = pdc202xx_init_one,
434 .remove = ide_pci_remove,
432}; 435};
433 436
434static int __init pdc202xx_ide_init(void) 437static int __init pdc202xx_ide_init(void)
@@ -436,7 +439,13 @@ static int __init pdc202xx_ide_init(void)
436 return ide_pci_register_driver(&driver); 439 return ide_pci_register_driver(&driver);
437} 440}
438 441
442static void __exit pdc202xx_ide_exit(void)
443{
444 pci_unregister_driver(&driver);
445}
446
439module_init(pdc202xx_ide_init); 447module_init(pdc202xx_ide_init);
448module_exit(pdc202xx_ide_exit);
440 449
441MODULE_AUTHOR("Andre Hedrick, Frank Tiernan"); 450MODULE_AUTHOR("Andre Hedrick, Frank Tiernan");
442MODULE_DESCRIPTION("PCI driver module for older Promise IDE"); 451MODULE_DESCRIPTION("PCI driver module for older Promise IDE");
diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c
index 0ce41b4dddaf..7fc3022dcf68 100644
--- a/drivers/ide/pci/piix.c
+++ b/drivers/ide/pci/piix.c
@@ -54,6 +54,8 @@
54 54
55#include <asm/io.h> 55#include <asm/io.h>
56 56
57#define DRV_NAME "piix"
58
57static int no_piix_dma; 59static int no_piix_dma;
58 60
59/** 61/**
@@ -198,13 +200,12 @@ static void piix_set_dma_mode(ide_drive_t *drive, const u8 speed)
198/** 200/**
199 * init_chipset_ich - set up the ICH chipset 201 * init_chipset_ich - set up the ICH chipset
200 * @dev: PCI device to set up 202 * @dev: PCI device to set up
201 * @name: Name of the device
202 * 203 *
203 * Initialize the PCI device as required. For the ICH this turns 204 * Initialize the PCI device as required. For the ICH this turns
204 * out to be nice and simple. 205 * out to be nice and simple.
205 */ 206 */
206 207
207static unsigned int __devinit init_chipset_ich(struct pci_dev *dev, const char *name) 208static unsigned int __devinit init_chipset_ich(struct pci_dev *dev)
208{ 209{
209 u32 extra = 0; 210 u32 extra = 0;
210 211
@@ -314,9 +315,9 @@ static const struct ide_port_ops piix_port_ops = {
314 #define IDE_HFLAGS_PIIX 0 315 #define IDE_HFLAGS_PIIX 0
315#endif 316#endif
316 317
317#define DECLARE_PIIX_DEV(name_str, udma) \ 318#define DECLARE_PIIX_DEV(udma) \
318 { \ 319 { \
319 .name = name_str, \ 320 .name = DRV_NAME, \
320 .init_hwif = init_hwif_piix, \ 321 .init_hwif = init_hwif_piix, \
321 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ 322 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \
322 .port_ops = &piix_port_ops, \ 323 .port_ops = &piix_port_ops, \
@@ -327,9 +328,9 @@ static const struct ide_port_ops piix_port_ops = {
327 .udma_mask = udma, \ 328 .udma_mask = udma, \
328 } 329 }
329 330
330#define DECLARE_ICH_DEV(name_str, udma) \ 331#define DECLARE_ICH_DEV(udma) \
331 { \ 332 { \
332 .name = name_str, \ 333 .name = DRV_NAME, \
333 .init_chipset = init_chipset_ich, \ 334 .init_chipset = init_chipset_ich, \
334 .init_hwif = init_hwif_ich, \ 335 .init_hwif = init_hwif_ich, \
335 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \ 336 .enablebits = {{0x41,0x80,0x80}, {0x43,0x80,0x80}}, \
@@ -342,45 +343,31 @@ static const struct ide_port_ops piix_port_ops = {
342 } 343 }
343 344
344static const struct ide_port_info piix_pci_info[] __devinitdata = { 345static const struct ide_port_info piix_pci_info[] __devinitdata = {
345 /* 0 */ DECLARE_PIIX_DEV("PIIXa", 0x00), /* no udma */ 346 /* 0: MPIIX */
346 /* 1 */ DECLARE_PIIX_DEV("PIIXb", 0x00), /* no udma */
347
348 /* 2 */
349 { /* 347 { /*
350 * MPIIX actually has only a single IDE channel mapped to 348 * MPIIX actually has only a single IDE channel mapped to
351 * the primary or secondary ports depending on the value 349 * the primary or secondary ports depending on the value
352 * of the bit 14 of the IDETIM register at offset 0x6c 350 * of the bit 14 of the IDETIM register at offset 0x6c
353 */ 351 */
354 .name = "MPIIX", 352 .name = DRV_NAME,
355 .enablebits = {{0x6d,0xc0,0x80}, {0x6d,0xc0,0xc0}}, 353 .enablebits = {{0x6d,0xc0,0x80}, {0x6d,0xc0,0xc0}},
356 .host_flags = IDE_HFLAG_ISA_PORTS | IDE_HFLAG_NO_DMA | 354 .host_flags = IDE_HFLAG_ISA_PORTS | IDE_HFLAG_NO_DMA |
357 IDE_HFLAGS_PIIX, 355 IDE_HFLAGS_PIIX,
358 .pio_mask = ATA_PIO4, 356 .pio_mask = ATA_PIO4,
359 /* This is a painful system best to let it self tune for now */ 357 /* This is a painful system best to let it self tune for now */
360 }, 358 },
361 359 /* 1: PIIXa/PIIXb/PIIX3 */
362 /* 3 */ DECLARE_PIIX_DEV("PIIX3", 0x00), /* no udma */ 360 DECLARE_PIIX_DEV(0x00), /* no udma */
363 /* 4 */ DECLARE_PIIX_DEV("PIIX4", ATA_UDMA2), 361 /* 2: PIIX4 */
364 /* 5 */ DECLARE_ICH_DEV("ICH0", ATA_UDMA2), 362 DECLARE_PIIX_DEV(ATA_UDMA2),
365 /* 6 */ DECLARE_PIIX_DEV("PIIX4", ATA_UDMA2), 363 /* 3: ICH0 */
366 /* 7 */ DECLARE_ICH_DEV("ICH", ATA_UDMA4), 364 DECLARE_ICH_DEV(ATA_UDMA2),
367 /* 8 */ DECLARE_PIIX_DEV("PIIX4", ATA_UDMA4), 365 /* 4: ICH */
368 /* 9 */ DECLARE_PIIX_DEV("PIIX4", ATA_UDMA2), 366 DECLARE_ICH_DEV(ATA_UDMA4),
369 /* 10 */ DECLARE_ICH_DEV("ICH2", ATA_UDMA5), 367 /* 5: PIIX4 */
370 /* 11 */ DECLARE_ICH_DEV("ICH2M", ATA_UDMA5), 368 DECLARE_PIIX_DEV(ATA_UDMA4),
371 /* 12 */ DECLARE_ICH_DEV("ICH3M", ATA_UDMA5), 369 /* 6: ICH[2-7]/ICH[2-3]M/C-ICH/ICH5-SATA/ESB2/ICH8M */
372 /* 13 */ DECLARE_ICH_DEV("ICH3", ATA_UDMA5), 370 DECLARE_ICH_DEV(ATA_UDMA5),
373 /* 14 */ DECLARE_ICH_DEV("ICH4", ATA_UDMA5),
374 /* 15 */ DECLARE_ICH_DEV("ICH5", ATA_UDMA5),
375 /* 16 */ DECLARE_ICH_DEV("C-ICH", ATA_UDMA5),
376 /* 17 */ DECLARE_ICH_DEV("ICH4", ATA_UDMA5),
377 /* 18 */ DECLARE_ICH_DEV("ICH5-SATA", ATA_UDMA5),
378 /* 19 */ DECLARE_ICH_DEV("ICH5", ATA_UDMA5),
379 /* 20 */ DECLARE_ICH_DEV("ICH6", ATA_UDMA5),
380 /* 21 */ DECLARE_ICH_DEV("ICH7", ATA_UDMA5),
381 /* 22 */ DECLARE_ICH_DEV("ICH4", ATA_UDMA5),
382 /* 23 */ DECLARE_ICH_DEV("ESB2", ATA_UDMA5),
383 /* 24 */ DECLARE_ICH_DEV("ICH8M", ATA_UDMA5),
384}; 371};
385 372
386/** 373/**
@@ -394,7 +381,7 @@ static const struct ide_port_info piix_pci_info[] __devinitdata = {
394 381
395static int __devinit piix_init_one(struct pci_dev *dev, const struct pci_device_id *id) 382static int __devinit piix_init_one(struct pci_dev *dev, const struct pci_device_id *id)
396{ 383{
397 return ide_setup_pci_device(dev, &piix_pci_info[id->driver_data]); 384 return ide_pci_init_one(dev, &piix_pci_info[id->driver_data], NULL);
398} 385}
399 386
400/** 387/**
@@ -421,39 +408,39 @@ static void __devinit piix_check_450nx(void)
421 no_piix_dma = 2; 408 no_piix_dma = 2;
422 } 409 }
423 if(no_piix_dma) 410 if(no_piix_dma)
424 printk(KERN_WARNING "piix: 450NX errata present, disabling IDE DMA.\n"); 411 printk(KERN_WARNING DRV_NAME ": 450NX errata present, disabling IDE DMA.\n");
425 if(no_piix_dma == 2) 412 if(no_piix_dma == 2)
426 printk(KERN_WARNING "piix: A BIOS update may resolve this.\n"); 413 printk(KERN_WARNING DRV_NAME ": A BIOS update may resolve this.\n");
427} 414}
428 415
429static const struct pci_device_id piix_pci_tbl[] = { 416static const struct pci_device_id piix_pci_tbl[] = {
430 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_0), 0 }, 417 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_0), 1 },
431 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_1), 1 }, 418 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371FB_1), 1 },
432 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371MX), 2 }, 419 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371MX), 0 },
433 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371SB_1), 3 }, 420 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371SB_1), 1 },
434 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371AB), 4 }, 421 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82371AB), 2 },
435 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AB_1), 5 }, 422 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AB_1), 3 },
436 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82443MX_1), 6 }, 423 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82443MX_1), 2 },
437 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AA_1), 7 }, 424 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801AA_1), 4 },
438 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82372FB_1), 8 }, 425 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82372FB_1), 5 },
439 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82451NX), 9 }, 426 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82451NX), 2 },
440 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_9), 10 }, 427 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_9), 6 },
441 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_8), 11 }, 428 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801BA_8), 6 },
442 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_10), 12 }, 429 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_10), 6 },
443 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_11), 13 }, 430 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801CA_11), 6 },
444 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_11), 14 }, 431 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_11), 6 },
445 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_11), 15 }, 432 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_11), 6 },
446 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801E_11), 16 }, 433 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801E_11), 6 },
447 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_10), 17 }, 434 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_10), 6 },
448#ifdef CONFIG_BLK_DEV_IDE_SATA 435#ifdef CONFIG_BLK_DEV_IDE_SATA
449 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_1), 18 }, 436 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801EB_1), 6 },
450#endif 437#endif
451 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB_2), 19 }, 438 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB_2), 6 },
452 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH6_19), 20 }, 439 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH6_19), 6 },
453 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH7_21), 21 }, 440 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH7_21), 6 },
454 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_1), 22 }, 441 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_82801DB_1), 6 },
455 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB2_18), 23 }, 442 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ESB2_18), 6 },
456 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH8_6), 24 }, 443 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ICH8_6), 6 },
457 { 0, }, 444 { 0, },
458}; 445};
459MODULE_DEVICE_TABLE(pci, piix_pci_tbl); 446MODULE_DEVICE_TABLE(pci, piix_pci_tbl);
@@ -462,6 +449,7 @@ static struct pci_driver driver = {
462 .name = "PIIX_IDE", 449 .name = "PIIX_IDE",
463 .id_table = piix_pci_tbl, 450 .id_table = piix_pci_tbl,
464 .probe = piix_init_one, 451 .probe = piix_init_one,
452 .remove = ide_pci_remove,
465}; 453};
466 454
467static int __init piix_ide_init(void) 455static int __init piix_ide_init(void)
@@ -470,7 +458,13 @@ static int __init piix_ide_init(void)
470 return ide_pci_register_driver(&driver); 458 return ide_pci_register_driver(&driver);
471} 459}
472 460
461static void __exit piix_ide_exit(void)
462{
463 pci_unregister_driver(&driver);
464}
465
473module_init(piix_ide_init); 466module_init(piix_ide_init);
467module_exit(piix_ide_exit);
474 468
475MODULE_AUTHOR("Andre Hedrick, Andrzej Krzysztofowicz"); 469MODULE_AUTHOR("Andre Hedrick, Andrzej Krzysztofowicz");
476MODULE_DESCRIPTION("PCI driver module for Intel PIIX IDE"); 470MODULE_DESCRIPTION("PCI driver module for Intel PIIX IDE");
diff --git a/drivers/ide/pci/rz1000.c b/drivers/ide/pci/rz1000.c
index 532154adba29..8d11ee838a2a 100644
--- a/drivers/ide/pci/rz1000.c
+++ b/drivers/ide/pci/rz1000.c
@@ -21,6 +21,8 @@
21#include <linux/ide.h> 21#include <linux/ide.h>
22#include <linux/init.h> 22#include <linux/init.h>
23 23
24#define DRV_NAME "rz1000"
25
24static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif) 26static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif)
25{ 27{
26 struct pci_dev *dev = to_pci_dev(hwif->dev); 28 struct pci_dev *dev = to_pci_dev(hwif->dev);
@@ -40,7 +42,7 @@ static void __devinit init_hwif_rz1000 (ide_hwif_t *hwif)
40} 42}
41 43
42static const struct ide_port_info rz1000_chipset __devinitdata = { 44static const struct ide_port_info rz1000_chipset __devinitdata = {
43 .name = "RZ100x", 45 .name = DRV_NAME,
44 .init_hwif = init_hwif_rz1000, 46 .init_hwif = init_hwif_rz1000,
45 .chipset = ide_rz1000, 47 .chipset = ide_rz1000,
46 .host_flags = IDE_HFLAG_NO_DMA, 48 .host_flags = IDE_HFLAG_NO_DMA,
@@ -48,7 +50,7 @@ static const struct ide_port_info rz1000_chipset __devinitdata = {
48 50
49static int __devinit rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id) 51static int __devinit rz1000_init_one(struct pci_dev *dev, const struct pci_device_id *id)
50{ 52{
51 return ide_setup_pci_device(dev, &rz1000_chipset); 53 return ide_pci_init_one(dev, &rz1000_chipset, NULL);
52} 54}
53 55
54static const struct pci_device_id rz1000_pci_tbl[] = { 56static const struct pci_device_id rz1000_pci_tbl[] = {
@@ -62,6 +64,7 @@ static struct pci_driver driver = {
62 .name = "RZ1000_IDE", 64 .name = "RZ1000_IDE",
63 .id_table = rz1000_pci_tbl, 65 .id_table = rz1000_pci_tbl,
64 .probe = rz1000_init_one, 66 .probe = rz1000_init_one,
67 .remove = ide_pci_remove,
65}; 68};
66 69
67static int __init rz1000_ide_init(void) 70static int __init rz1000_ide_init(void)
@@ -69,7 +72,13 @@ static int __init rz1000_ide_init(void)
69 return ide_pci_register_driver(&driver); 72 return ide_pci_register_driver(&driver);
70} 73}
71 74
75static void __exit rz1000_ide_exit(void)
76{
77 pci_unregister_driver(&driver);
78}
79
72module_init(rz1000_ide_init); 80module_init(rz1000_ide_init);
81module_exit(rz1000_ide_exit);
73 82
74MODULE_AUTHOR("Andre Hedrick"); 83MODULE_AUTHOR("Andre Hedrick");
75MODULE_DESCRIPTION("PCI driver module for RZ1000 IDE"); 84MODULE_DESCRIPTION("PCI driver module for RZ1000 IDE");
diff --git a/drivers/ide/pci/sc1200.c b/drivers/ide/pci/sc1200.c
index 14c787b5d95f..8efaed16fea3 100644
--- a/drivers/ide/pci/sc1200.c
+++ b/drivers/ide/pci/sc1200.c
@@ -22,6 +22,8 @@
22 22
23#include <asm/io.h> 23#include <asm/io.h>
24 24
25#define DRV_NAME "sc1200"
26
25#define SC1200_REV_A 0x00 27#define SC1200_REV_A 0x00
26#define SC1200_REV_B1 0x01 28#define SC1200_REV_B1 0x01
27#define SC1200_REV_B3 0x02 29#define SC1200_REV_B3 0x02
@@ -234,21 +236,11 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state)
234 * we only save state when going from full power to less 236 * we only save state when going from full power to less
235 */ 237 */
236 if (state.event == PM_EVENT_ON) { 238 if (state.event == PM_EVENT_ON) {
237 struct sc1200_saved_state *ss; 239 struct ide_host *host = pci_get_drvdata(dev);
240 struct sc1200_saved_state *ss = host->host_priv;
238 unsigned int r; 241 unsigned int r;
239 242
240 /* 243 /*
241 * allocate a permanent save area, if not already allocated
242 */
243 ss = (struct sc1200_saved_state *)pci_get_drvdata(dev);
244 if (ss == NULL) {
245 ss = kmalloc(sizeof(*ss), GFP_KERNEL);
246 if (ss == NULL)
247 return -ENOMEM;
248 pci_set_drvdata(dev, ss);
249 }
250
251 /*
252 * save timing registers 244 * save timing registers
253 * (this may be unnecessary if BIOS also does it) 245 * (this may be unnecessary if BIOS also does it)
254 */ 246 */
@@ -263,7 +255,8 @@ static int sc1200_suspend (struct pci_dev *dev, pm_message_t state)
263 255
264static int sc1200_resume (struct pci_dev *dev) 256static int sc1200_resume (struct pci_dev *dev)
265{ 257{
266 struct sc1200_saved_state *ss; 258 struct ide_host *host = pci_get_drvdata(dev);
259 struct sc1200_saved_state *ss = host->host_priv;
267 unsigned int r; 260 unsigned int r;
268 int i; 261 int i;
269 262
@@ -271,16 +264,12 @@ static int sc1200_resume (struct pci_dev *dev)
271 if (i) 264 if (i)
272 return i; 265 return i;
273 266
274 ss = (struct sc1200_saved_state *)pci_get_drvdata(dev);
275
276 /* 267 /*
277 * restore timing registers 268 * restore timing registers
278 * (this may be unnecessary if BIOS also does it) 269 * (this may be unnecessary if BIOS also does it)
279 */ 270 */
280 if (ss) { 271 for (r = 0; r < 8; r++)
281 for (r = 0; r < 8; r++) 272 pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]);
282 pci_write_config_dword(dev, 0x40 + r * 4, ss->regs[r]);
283 }
284 273
285 return 0; 274 return 0;
286} 275}
@@ -304,7 +293,7 @@ static const struct ide_dma_ops sc1200_dma_ops = {
304}; 293};
305 294
306static const struct ide_port_info sc1200_chipset __devinitdata = { 295static const struct ide_port_info sc1200_chipset __devinitdata = {
307 .name = "SC1200", 296 .name = DRV_NAME,
308 .port_ops = &sc1200_port_ops, 297 .port_ops = &sc1200_port_ops,
309 .dma_ops = &sc1200_dma_ops, 298 .dma_ops = &sc1200_dma_ops,
310 .host_flags = IDE_HFLAG_SERIALIZE | 299 .host_flags = IDE_HFLAG_SERIALIZE |
@@ -317,7 +306,19 @@ static const struct ide_port_info sc1200_chipset __devinitdata = {
317 306
318static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id) 307static int __devinit sc1200_init_one(struct pci_dev *dev, const struct pci_device_id *id)
319{ 308{
320 return ide_setup_pci_device(dev, &sc1200_chipset); 309 struct sc1200_saved_state *ss = NULL;
310 int rc;
311
312#ifdef CONFIG_PM
313 ss = kmalloc(sizeof(*ss), GFP_KERNEL);
314 if (ss == NULL)
315 return -ENOMEM;
316#endif
317 rc = ide_pci_init_one(dev, &sc1200_chipset, ss);
318 if (rc)
319 kfree(ss);
320
321 return rc;
321} 322}
322 323
323static const struct pci_device_id sc1200_pci_tbl[] = { 324static const struct pci_device_id sc1200_pci_tbl[] = {
@@ -330,6 +331,7 @@ static struct pci_driver driver = {
330 .name = "SC1200_IDE", 331 .name = "SC1200_IDE",
331 .id_table = sc1200_pci_tbl, 332 .id_table = sc1200_pci_tbl,
332 .probe = sc1200_init_one, 333 .probe = sc1200_init_one,
334 .remove = ide_pci_remove,
333#ifdef CONFIG_PM 335#ifdef CONFIG_PM
334 .suspend = sc1200_suspend, 336 .suspend = sc1200_suspend,
335 .resume = sc1200_resume, 337 .resume = sc1200_resume,
@@ -341,7 +343,13 @@ static int __init sc1200_ide_init(void)
341 return ide_pci_register_driver(&driver); 343 return ide_pci_register_driver(&driver);
342} 344}
343 345
346static void __exit sc1200_ide_exit(void)
347{
348 pci_unregister_driver(&driver);
349}
350
344module_init(sc1200_ide_init); 351module_init(sc1200_ide_init);
352module_exit(sc1200_ide_exit);
345 353
346MODULE_AUTHOR("Mark Lord"); 354MODULE_AUTHOR("Mark Lord");
347MODULE_DESCRIPTION("PCI driver module for NS SC1200 IDE"); 355MODULE_DESCRIPTION("PCI driver module for NS SC1200 IDE");
diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c
index 127ccb45e261..d173f2937722 100644
--- a/drivers/ide/pci/serverworks.c
+++ b/drivers/ide/pci/serverworks.c
@@ -38,6 +38,8 @@
38 38
39#include <asm/io.h> 39#include <asm/io.h>
40 40
41#define DRV_NAME "serverworks"
42
41#define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */ 43#define SVWKS_CSB5_REVISION_NEW 0x92 /* min PCI_REVISION_ID for UDMA5 (A2.0) */
42#define SVWKS_CSB6_REVISION 0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */ 44#define SVWKS_CSB6_REVISION 0xa0 /* min PCI_REVISION_ID for UDMA4 (A1.0) */
43 45
@@ -172,7 +174,7 @@ static void svwks_set_dma_mode(ide_drive_t *drive, const u8 speed)
172 pci_write_config_byte(dev, 0x54, ultra_enable); 174 pci_write_config_byte(dev, 0x54, ultra_enable);
173} 175}
174 176
175static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const char *name) 177static unsigned int __devinit init_chipset_svwks(struct pci_dev *dev)
176{ 178{
177 unsigned int reg; 179 unsigned int reg;
178 u8 btr; 180 u8 btr;
@@ -188,7 +190,8 @@ static unsigned int __devinit init_chipset_svwks (struct pci_dev *dev, const cha
188 pci_read_config_dword(isa_dev, 0x64, &reg); 190 pci_read_config_dword(isa_dev, 0x64, &reg);
189 reg &= ~0x00002000; /* disable 600ns interrupt mask */ 191 reg &= ~0x00002000; /* disable 600ns interrupt mask */
190 if(!(reg & 0x00004000)) 192 if(!(reg & 0x00004000))
191 printk(KERN_DEBUG "%s: UDMA not BIOS enabled.\n", name); 193 printk(KERN_DEBUG DRV_NAME " %s: UDMA not BIOS "
194 "enabled.\n", pci_name(dev));
192 reg |= 0x00004000; /* enable UDMA/33 support */ 195 reg |= 0x00004000; /* enable UDMA/33 support */
193 pci_write_config_dword(isa_dev, 0x64, reg); 196 pci_write_config_dword(isa_dev, 0x64, reg);
194 } 197 }
@@ -352,40 +355,44 @@ static const struct ide_port_ops svwks_port_ops = {
352#define IDE_HFLAGS_SVWKS IDE_HFLAG_LEGACY_IRQS 355#define IDE_HFLAGS_SVWKS IDE_HFLAG_LEGACY_IRQS
353 356
354static const struct ide_port_info serverworks_chipsets[] __devinitdata = { 357static const struct ide_port_info serverworks_chipsets[] __devinitdata = {
355 { /* 0 */ 358 { /* 0: OSB4 */
356 .name = "SvrWks OSB4", 359 .name = DRV_NAME,
357 .init_chipset = init_chipset_svwks, 360 .init_chipset = init_chipset_svwks,
358 .port_ops = &osb4_port_ops, 361 .port_ops = &osb4_port_ops,
359 .host_flags = IDE_HFLAGS_SVWKS, 362 .host_flags = IDE_HFLAGS_SVWKS,
360 .pio_mask = ATA_PIO4, 363 .pio_mask = ATA_PIO4,
361 .mwdma_mask = ATA_MWDMA2, 364 .mwdma_mask = ATA_MWDMA2,
362 .udma_mask = 0x00, /* UDMA is problematic on OSB4 */ 365 .udma_mask = 0x00, /* UDMA is problematic on OSB4 */
363 },{ /* 1 */ 366 },
364 .name = "SvrWks CSB5", 367 { /* 1: CSB5 */
368 .name = DRV_NAME,
365 .init_chipset = init_chipset_svwks, 369 .init_chipset = init_chipset_svwks,
366 .port_ops = &svwks_port_ops, 370 .port_ops = &svwks_port_ops,
367 .host_flags = IDE_HFLAGS_SVWKS, 371 .host_flags = IDE_HFLAGS_SVWKS,
368 .pio_mask = ATA_PIO4, 372 .pio_mask = ATA_PIO4,
369 .mwdma_mask = ATA_MWDMA2, 373 .mwdma_mask = ATA_MWDMA2,
370 .udma_mask = ATA_UDMA5, 374 .udma_mask = ATA_UDMA5,
371 },{ /* 2 */ 375 },
372 .name = "SvrWks CSB6", 376 { /* 2: CSB6 */
377 .name = DRV_NAME,
373 .init_chipset = init_chipset_svwks, 378 .init_chipset = init_chipset_svwks,
374 .port_ops = &svwks_port_ops, 379 .port_ops = &svwks_port_ops,
375 .host_flags = IDE_HFLAGS_SVWKS, 380 .host_flags = IDE_HFLAGS_SVWKS,
376 .pio_mask = ATA_PIO4, 381 .pio_mask = ATA_PIO4,
377 .mwdma_mask = ATA_MWDMA2, 382 .mwdma_mask = ATA_MWDMA2,
378 .udma_mask = ATA_UDMA5, 383 .udma_mask = ATA_UDMA5,
379 },{ /* 3 */ 384 },
380 .name = "SvrWks CSB6", 385 { /* 3: CSB6-2 */
386 .name = DRV_NAME,
381 .init_chipset = init_chipset_svwks, 387 .init_chipset = init_chipset_svwks,
382 .port_ops = &svwks_port_ops, 388 .port_ops = &svwks_port_ops,
383 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, 389 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE,
384 .pio_mask = ATA_PIO4, 390 .pio_mask = ATA_PIO4,
385 .mwdma_mask = ATA_MWDMA2, 391 .mwdma_mask = ATA_MWDMA2,
386 .udma_mask = ATA_UDMA5, 392 .udma_mask = ATA_UDMA5,
387 },{ /* 4 */ 393 },
388 .name = "SvrWks HT1000", 394 { /* 4: HT1000 */
395 .name = DRV_NAME,
389 .init_chipset = init_chipset_svwks, 396 .init_chipset = init_chipset_svwks,
390 .port_ops = &svwks_port_ops, 397 .port_ops = &svwks_port_ops,
391 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE, 398 .host_flags = IDE_HFLAGS_SVWKS | IDE_HFLAG_SINGLE,
@@ -422,7 +429,7 @@ static int __devinit svwks_init_one(struct pci_dev *dev, const struct pci_device
422 d.host_flags &= ~IDE_HFLAG_SINGLE; 429 d.host_flags &= ~IDE_HFLAG_SINGLE;
423 } 430 }
424 431
425 return ide_setup_pci_device(dev, &d); 432 return ide_pci_init_one(dev, &d, NULL);
426} 433}
427 434
428static const struct pci_device_id svwks_pci_tbl[] = { 435static const struct pci_device_id svwks_pci_tbl[] = {
@@ -439,6 +446,7 @@ static struct pci_driver driver = {
439 .name = "Serverworks_IDE", 446 .name = "Serverworks_IDE",
440 .id_table = svwks_pci_tbl, 447 .id_table = svwks_pci_tbl,
441 .probe = svwks_init_one, 448 .probe = svwks_init_one,
449 .remove = ide_pci_remove,
442}; 450};
443 451
444static int __init svwks_ide_init(void) 452static int __init svwks_ide_init(void)
@@ -446,7 +454,13 @@ static int __init svwks_ide_init(void)
446 return ide_pci_register_driver(&driver); 454 return ide_pci_register_driver(&driver);
447} 455}
448 456
457static void __exit svwks_ide_exit(void)
458{
459 pci_unregister_driver(&driver);
460}
461
449module_init(svwks_ide_init); 462module_init(svwks_ide_init);
463module_exit(svwks_ide_exit);
450 464
451MODULE_AUTHOR("Michael Aubry. Andrzej Krzysztofowicz, Andre Hedrick"); 465MODULE_AUTHOR("Michael Aubry. Andrzej Krzysztofowicz, Andre Hedrick");
452MODULE_DESCRIPTION("PCI driver module for Serverworks OSB4/CSB5/CSB6 IDE"); 466MODULE_DESCRIPTION("PCI driver module for Serverworks OSB4/CSB5/CSB6 IDE");
diff --git a/drivers/ide/pci/siimage.c b/drivers/ide/pci/siimage.c
index 5965a35d94ae..b8ad9ad6cf0d 100644
--- a/drivers/ide/pci/siimage.c
+++ b/drivers/ide/pci/siimage.c
@@ -44,6 +44,8 @@
44#include <linux/init.h> 44#include <linux/init.h>
45#include <linux/io.h> 45#include <linux/io.h>
46 46
47#define DRV_NAME "siimage"
48
47/** 49/**
48 * pdev_is_sata - check if device is SATA 50 * pdev_is_sata - check if device is SATA
49 * @pdev: PCI device to check 51 * @pdev: PCI device to check
@@ -127,9 +129,10 @@ static inline unsigned long siimage_seldev(ide_drive_t *drive, int r)
127 129
128static u8 sil_ioread8(struct pci_dev *dev, unsigned long addr) 130static u8 sil_ioread8(struct pci_dev *dev, unsigned long addr)
129{ 131{
132 struct ide_host *host = pci_get_drvdata(dev);
130 u8 tmp = 0; 133 u8 tmp = 0;
131 134
132 if (pci_get_drvdata(dev)) 135 if (host->host_priv)
133 tmp = readb((void __iomem *)addr); 136 tmp = readb((void __iomem *)addr);
134 else 137 else
135 pci_read_config_byte(dev, addr, &tmp); 138 pci_read_config_byte(dev, addr, &tmp);
@@ -139,9 +142,10 @@ static u8 sil_ioread8(struct pci_dev *dev, unsigned long addr)
139 142
140static u16 sil_ioread16(struct pci_dev *dev, unsigned long addr) 143static u16 sil_ioread16(struct pci_dev *dev, unsigned long addr)
141{ 144{
145 struct ide_host *host = pci_get_drvdata(dev);
142 u16 tmp = 0; 146 u16 tmp = 0;
143 147
144 if (pci_get_drvdata(dev)) 148 if (host->host_priv)
145 tmp = readw((void __iomem *)addr); 149 tmp = readw((void __iomem *)addr);
146 else 150 else
147 pci_read_config_word(dev, addr, &tmp); 151 pci_read_config_word(dev, addr, &tmp);
@@ -151,7 +155,9 @@ static u16 sil_ioread16(struct pci_dev *dev, unsigned long addr)
151 155
152static void sil_iowrite8(struct pci_dev *dev, u8 val, unsigned long addr) 156static void sil_iowrite8(struct pci_dev *dev, u8 val, unsigned long addr)
153{ 157{
154 if (pci_get_drvdata(dev)) 158 struct ide_host *host = pci_get_drvdata(dev);
159
160 if (host->host_priv)
155 writeb(val, (void __iomem *)addr); 161 writeb(val, (void __iomem *)addr);
156 else 162 else
157 pci_write_config_byte(dev, addr, val); 163 pci_write_config_byte(dev, addr, val);
@@ -159,7 +165,9 @@ static void sil_iowrite8(struct pci_dev *dev, u8 val, unsigned long addr)
159 165
160static void sil_iowrite16(struct pci_dev *dev, u16 val, unsigned long addr) 166static void sil_iowrite16(struct pci_dev *dev, u16 val, unsigned long addr)
161{ 167{
162 if (pci_get_drvdata(dev)) 168 struct ide_host *host = pci_get_drvdata(dev);
169
170 if (host->host_priv)
163 writew(val, (void __iomem *)addr); 171 writew(val, (void __iomem *)addr);
164 else 172 else
165 pci_write_config_word(dev, addr, val); 173 pci_write_config_word(dev, addr, val);
@@ -167,7 +175,9 @@ static void sil_iowrite16(struct pci_dev *dev, u16 val, unsigned long addr)
167 175
168static void sil_iowrite32(struct pci_dev *dev, u32 val, unsigned long addr) 176static void sil_iowrite32(struct pci_dev *dev, u32 val, unsigned long addr)
169{ 177{
170 if (pci_get_drvdata(dev)) 178 struct ide_host *host = pci_get_drvdata(dev);
179
180 if (host->host_priv)
171 writel(val, (void __iomem *)addr); 181 writel(val, (void __iomem *)addr);
172 else 182 else
173 pci_write_config_dword(dev, addr, val); 183 pci_write_config_dword(dev, addr, val);
@@ -445,66 +455,24 @@ static void sil_sata_pre_reset(ide_drive_t *drive)
445} 455}
446 456
447/** 457/**
448 * setup_mmio_siimage - switch controller into MMIO mode
449 * @dev: PCI device we are configuring
450 * @name: device name
451 *
452 * Attempt to put the device into MMIO mode. There are some slight
453 * complications here with certain systems where the MMIO BAR isn't
454 * mapped, so we have to be sure that we can fall back to I/O.
455 */
456
457static unsigned int setup_mmio_siimage(struct pci_dev *dev, const char *name)
458{
459 resource_size_t bar5 = pci_resource_start(dev, 5);
460 unsigned long barsize = pci_resource_len(dev, 5);
461 void __iomem *ioaddr;
462
463 /*
464 * Drop back to PIO if we can't map the MMIO. Some systems
465 * seem to get terminally confused in the PCI spaces.
466 */
467 if (!request_mem_region(bar5, barsize, name)) {
468 printk(KERN_WARNING "siimage: IDE controller MMIO ports not "
469 "available.\n");
470 return 0;
471 }
472
473 ioaddr = ioremap(bar5, barsize);
474 if (ioaddr == NULL) {
475 release_mem_region(bar5, barsize);
476 return 0;
477 }
478
479 pci_set_master(dev);
480 pci_set_drvdata(dev, (void *) ioaddr);
481
482 return 1;
483}
484
485/**
486 * init_chipset_siimage - set up an SI device 458 * init_chipset_siimage - set up an SI device
487 * @dev: PCI device 459 * @dev: PCI device
488 * @name: device name
489 * 460 *
490 * Perform the initial PCI set up for this device. Attempt to switch 461 * Perform the initial PCI set up for this device. Attempt to switch
491 * to 133 MHz clocking if the system isn't already set up to do it. 462 * to 133 MHz clocking if the system isn't already set up to do it.
492 */ 463 */
493 464
494static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev, 465static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev)
495 const char *name)
496{ 466{
467 struct ide_host *host = pci_get_drvdata(dev);
468 void __iomem *ioaddr = host->host_priv;
497 unsigned long base, scsc_addr; 469 unsigned long base, scsc_addr;
498 void __iomem *ioaddr = NULL; 470 u8 rev = dev->revision, tmp;
499 u8 rev = dev->revision, tmp, BA5_EN;
500 471
501 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, rev ? 1 : 255); 472 pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, rev ? 1 : 255);
502 473
503 pci_read_config_byte(dev, 0x8A, &BA5_EN); 474 if (ioaddr)
504 475 pci_set_master(dev);
505 if ((BA5_EN & 0x01) || pci_resource_start(dev, 5))
506 if (setup_mmio_siimage(dev, name))
507 ioaddr = pci_get_drvdata(dev);
508 476
509 base = (unsigned long)ioaddr; 477 base = (unsigned long)ioaddr;
510 478
@@ -571,7 +539,8 @@ static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev,
571 { "== 100", "== 133", "== 2X PCI", "DISABLED!" }; 539 { "== 100", "== 133", "== 2X PCI", "DISABLED!" };
572 540
573 tmp >>= 4; 541 tmp >>= 4;
574 printk(KERN_INFO "%s: BASE CLOCK %s\n", name, clk_str[tmp & 3]); 542 printk(KERN_INFO DRV_NAME " %s: BASE CLOCK %s\n",
543 pci_name(dev), clk_str[tmp & 3]);
575 } 544 }
576 545
577 return 0; 546 return 0;
@@ -592,7 +561,8 @@ static unsigned int __devinit init_chipset_siimage(struct pci_dev *dev,
592static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif) 561static void __devinit init_mmio_iops_siimage(ide_hwif_t *hwif)
593{ 562{
594 struct pci_dev *dev = to_pci_dev(hwif->dev); 563 struct pci_dev *dev = to_pci_dev(hwif->dev);
595 void *addr = pci_get_drvdata(dev); 564 struct ide_host *host = pci_get_drvdata(dev);
565 void *addr = host->host_priv;
596 u8 ch = hwif->channel; 566 u8 ch = hwif->channel;
597 struct ide_io_ports *io_ports = &hwif->io_ports; 567 struct ide_io_ports *io_ports = &hwif->io_ports;
598 unsigned long base; 568 unsigned long base;
@@ -691,16 +661,15 @@ static void __devinit sil_quirkproc(ide_drive_t *drive)
691static void __devinit init_iops_siimage(ide_hwif_t *hwif) 661static void __devinit init_iops_siimage(ide_hwif_t *hwif)
692{ 662{
693 struct pci_dev *dev = to_pci_dev(hwif->dev); 663 struct pci_dev *dev = to_pci_dev(hwif->dev);
664 struct ide_host *host = pci_get_drvdata(dev);
694 665
695 hwif->hwif_data = NULL; 666 hwif->hwif_data = NULL;
696 667
697 /* Pessimal until we finish probing */ 668 /* Pessimal until we finish probing */
698 hwif->rqsize = 15; 669 hwif->rqsize = 15;
699 670
700 if (pci_get_drvdata(dev) == NULL) 671 if (host->host_priv)
701 return; 672 init_mmio_iops_siimage(hwif);
702
703 init_mmio_iops_siimage(hwif);
704} 673}
705 674
706/** 675/**
@@ -748,9 +717,9 @@ static const struct ide_dma_ops sil_dma_ops = {
748 .dma_lost_irq = ide_dma_lost_irq, 717 .dma_lost_irq = ide_dma_lost_irq,
749}; 718};
750 719
751#define DECLARE_SII_DEV(name_str, p_ops) \ 720#define DECLARE_SII_DEV(p_ops) \
752 { \ 721 { \
753 .name = name_str, \ 722 .name = DRV_NAME, \
754 .init_chipset = init_chipset_siimage, \ 723 .init_chipset = init_chipset_siimage, \
755 .init_iops = init_iops_siimage, \ 724 .init_iops = init_iops_siimage, \
756 .port_ops = p_ops, \ 725 .port_ops = p_ops, \
@@ -761,9 +730,8 @@ static const struct ide_dma_ops sil_dma_ops = {
761 } 730 }
762 731
763static const struct ide_port_info siimage_chipsets[] __devinitdata = { 732static const struct ide_port_info siimage_chipsets[] __devinitdata = {
764 /* 0 */ DECLARE_SII_DEV("SiI680", &sil_pata_port_ops), 733 /* 0: SiI680 */ DECLARE_SII_DEV(&sil_pata_port_ops),
765 /* 1 */ DECLARE_SII_DEV("SiI3112 Serial ATA", &sil_sata_port_ops), 734 /* 1: SiI3112 */ DECLARE_SII_DEV(&sil_sata_port_ops)
766 /* 2 */ DECLARE_SII_DEV("Adaptec AAR-1210SA", &sil_sata_port_ops)
767}; 735};
768 736
769/** 737/**
@@ -778,8 +746,13 @@ static const struct ide_port_info siimage_chipsets[] __devinitdata = {
778static int __devinit siimage_init_one(struct pci_dev *dev, 746static int __devinit siimage_init_one(struct pci_dev *dev,
779 const struct pci_device_id *id) 747 const struct pci_device_id *id)
780{ 748{
749 void __iomem *ioaddr = NULL;
750 resource_size_t bar5 = pci_resource_start(dev, 5);
751 unsigned long barsize = pci_resource_len(dev, 5);
752 int rc;
781 struct ide_port_info d; 753 struct ide_port_info d;
782 u8 idx = id->driver_data; 754 u8 idx = id->driver_data;
755 u8 BA5_EN;
783 756
784 d = siimage_chipsets[idx]; 757 d = siimage_chipsets[idx];
785 758
@@ -787,7 +760,7 @@ static int __devinit siimage_init_one(struct pci_dev *dev,
787 static int first = 1; 760 static int first = 1;
788 761
789 if (first) { 762 if (first) {
790 printk(KERN_INFO "siimage: For full SATA support you " 763 printk(KERN_INFO DRV_NAME ": For full SATA support you "
791 "should use the libata sata_sil module.\n"); 764 "should use the libata sata_sil module.\n");
792 first = 0; 765 first = 0;
793 } 766 }
@@ -795,14 +768,61 @@ static int __devinit siimage_init_one(struct pci_dev *dev,
795 d.host_flags |= IDE_HFLAG_NO_ATAPI_DMA; 768 d.host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
796 } 769 }
797 770
798 return ide_setup_pci_device(dev, &d); 771 rc = pci_enable_device(dev);
772 if (rc)
773 return rc;
774
775 pci_read_config_byte(dev, 0x8A, &BA5_EN);
776 if ((BA5_EN & 0x01) || bar5) {
777 /*
778 * Drop back to PIO if we can't map the MMIO. Some systems
779 * seem to get terminally confused in the PCI spaces.
780 */
781 if (!request_mem_region(bar5, barsize, d.name)) {
782 printk(KERN_WARNING DRV_NAME " %s: MMIO ports not "
783 "available\n", pci_name(dev));
784 } else {
785 ioaddr = ioremap(bar5, barsize);
786 if (ioaddr == NULL)
787 release_mem_region(bar5, barsize);
788 }
789 }
790
791 rc = ide_pci_init_one(dev, &d, ioaddr);
792 if (rc) {
793 if (ioaddr) {
794 iounmap(ioaddr);
795 release_mem_region(bar5, barsize);
796 }
797 pci_disable_device(dev);
798 }
799
800 return rc;
801}
802
803static void __devexit siimage_remove(struct pci_dev *dev)
804{
805 struct ide_host *host = pci_get_drvdata(dev);
806 void __iomem *ioaddr = host->host_priv;
807
808 ide_pci_remove(dev);
809
810 if (ioaddr) {
811 resource_size_t bar5 = pci_resource_start(dev, 5);
812 unsigned long barsize = pci_resource_len(dev, 5);
813
814 iounmap(ioaddr);
815 release_mem_region(bar5, barsize);
816 }
817
818 pci_disable_device(dev);
799} 819}
800 820
801static const struct pci_device_id siimage_pci_tbl[] = { 821static const struct pci_device_id siimage_pci_tbl[] = {
802 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_680), 0 }, 822 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_680), 0 },
803#ifdef CONFIG_BLK_DEV_IDE_SATA 823#ifdef CONFIG_BLK_DEV_IDE_SATA
804 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_3112), 1 }, 824 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_3112), 1 },
805 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_1210SA), 2 }, 825 { PCI_VDEVICE(CMD, PCI_DEVICE_ID_SII_1210SA), 1 },
806#endif 826#endif
807 { 0, }, 827 { 0, },
808}; 828};
@@ -812,6 +832,7 @@ static struct pci_driver driver = {
812 .name = "SiI_IDE", 832 .name = "SiI_IDE",
813 .id_table = siimage_pci_tbl, 833 .id_table = siimage_pci_tbl,
814 .probe = siimage_init_one, 834 .probe = siimage_init_one,
835 .remove = siimage_remove,
815}; 836};
816 837
817static int __init siimage_ide_init(void) 838static int __init siimage_ide_init(void)
@@ -819,7 +840,13 @@ static int __init siimage_ide_init(void)
819 return ide_pci_register_driver(&driver); 840 return ide_pci_register_driver(&driver);
820} 841}
821 842
843static void __exit siimage_ide_exit(void)
844{
845 pci_unregister_driver(&driver);
846}
847
822module_init(siimage_ide_init); 848module_init(siimage_ide_init);
849module_exit(siimage_ide_exit);
823 850
824MODULE_AUTHOR("Andre Hedrick, Alan Cox"); 851MODULE_AUTHOR("Andre Hedrick, Alan Cox");
825MODULE_DESCRIPTION("PCI driver module for SiI IDE"); 852MODULE_DESCRIPTION("PCI driver module for SiI IDE");
diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c
index 2389945ca95d..cc95f90b53b7 100644
--- a/drivers/ide/pci/sis5513.c
+++ b/drivers/ide/pci/sis5513.c
@@ -52,6 +52,8 @@
52#include <linux/init.h> 52#include <linux/init.h>
53#include <linux/ide.h> 53#include <linux/ide.h>
54 54
55#define DRV_NAME "sis5513"
56
55/* registers layout and init values are chipset family dependant */ 57/* registers layout and init values are chipset family dependant */
56 58
57#define ATA_16 0x01 59#define ATA_16 0x01
@@ -380,8 +382,9 @@ static int __devinit sis_find_family(struct pci_dev *dev)
380 } 382 }
381 pci_dev_put(host); 383 pci_dev_put(host);
382 384
383 printk(KERN_INFO "SIS5513: %s %s controller\n", 385 printk(KERN_INFO DRV_NAME " %s: %s %s controller\n",
384 SiSHostChipInfo[i].name, chipset_capability[chipset_family]); 386 pci_name(dev), SiSHostChipInfo[i].name,
387 chipset_capability[chipset_family]);
385 } 388 }
386 389
387 if (!chipset_family) { /* Belongs to pci-quirks */ 390 if (!chipset_family) { /* Belongs to pci-quirks */
@@ -396,7 +399,8 @@ static int __devinit sis_find_family(struct pci_dev *dev)
396 pci_write_config_dword(dev, 0x54, idemisc); 399 pci_write_config_dword(dev, 0x54, idemisc);
397 400
398 if (trueid == 0x5518) { 401 if (trueid == 0x5518) {
399 printk(KERN_INFO "SIS5513: SiS 962/963 MuTIOL IDE UDMA133 controller\n"); 402 printk(KERN_INFO DRV_NAME " %s: SiS 962/963 MuTIOL IDE UDMA133 controller\n",
403 pci_name(dev));
400 chipset_family = ATA_133; 404 chipset_family = ATA_133;
401 405
402 /* Check for 5513 compability mapping 406 /* Check for 5513 compability mapping
@@ -405,7 +409,8 @@ static int __devinit sis_find_family(struct pci_dev *dev)
405 */ 409 */
406 if ((idemisc & 0x40000000) == 0) { 410 if ((idemisc & 0x40000000) == 0) {
407 pci_write_config_dword(dev, 0x54, idemisc | 0x40000000); 411 pci_write_config_dword(dev, 0x54, idemisc | 0x40000000);
408 printk(KERN_INFO "SIS5513: Switching to 5513 register mapping\n"); 412 printk(KERN_INFO DRV_NAME " %s: Switching to 5513 register mapping\n",
413 pci_name(dev));
409 } 414 }
410 } 415 }
411 } 416 }
@@ -429,10 +434,12 @@ static int __devinit sis_find_family(struct pci_dev *dev)
429 pci_dev_put(lpc_bridge); 434 pci_dev_put(lpc_bridge);
430 435
431 if (lpc_bridge->revision == 0x10 && (prefctl & 0x80)) { 436 if (lpc_bridge->revision == 0x10 && (prefctl & 0x80)) {
432 printk(KERN_INFO "SIS5513: SiS 961B MuTIOL IDE UDMA133 controller\n"); 437 printk(KERN_INFO DRV_NAME " %s: SiS 961B MuTIOL IDE UDMA133 controller\n",
438 pci_name(dev));
433 chipset_family = ATA_133a; 439 chipset_family = ATA_133a;
434 } else { 440 } else {
435 printk(KERN_INFO "SIS5513: SiS 961 MuTIOL IDE UDMA100 controller\n"); 441 printk(KERN_INFO DRV_NAME " %s: SiS 961 MuTIOL IDE UDMA100 controller\n",
442 pci_name(dev));
436 chipset_family = ATA_100; 443 chipset_family = ATA_100;
437 } 444 }
438 } 445 }
@@ -441,8 +448,7 @@ static int __devinit sis_find_family(struct pci_dev *dev)
441 return chipset_family; 448 return chipset_family;
442} 449}
443 450
444static unsigned int __devinit init_chipset_sis5513(struct pci_dev *dev, 451static unsigned int __devinit init_chipset_sis5513(struct pci_dev *dev)
445 const char *name)
446{ 452{
447 /* Make general config ops here 453 /* Make general config ops here
448 1/ tell IDE channels to operate in Compatibility mode only 454 1/ tell IDE channels to operate in Compatibility mode only
@@ -555,7 +561,7 @@ static const struct ide_port_ops sis_ata133_port_ops = {
555}; 561};
556 562
557static const struct ide_port_info sis5513_chipset __devinitdata = { 563static const struct ide_port_info sis5513_chipset __devinitdata = {
558 .name = "SIS5513", 564 .name = DRV_NAME,
559 .init_chipset = init_chipset_sis5513, 565 .init_chipset = init_chipset_sis5513,
560 .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} }, 566 .enablebits = { {0x4a, 0x02, 0x02}, {0x4a, 0x04, 0x04} },
561 .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA, 567 .host_flags = IDE_HFLAG_LEGACY_IRQS | IDE_HFLAG_NO_AUTODMA,
@@ -583,7 +589,13 @@ static int __devinit sis5513_init_one(struct pci_dev *dev, const struct pci_devi
583 589
584 d.udma_mask = udma_rates[chipset_family]; 590 d.udma_mask = udma_rates[chipset_family];
585 591
586 return ide_setup_pci_device(dev, &d); 592 return ide_pci_init_one(dev, &d, NULL);
593}
594
595static void __devexit sis5513_remove(struct pci_dev *dev)
596{
597 ide_pci_remove(dev);
598 pci_disable_device(dev);
587} 599}
588 600
589static const struct pci_device_id sis5513_pci_tbl[] = { 601static const struct pci_device_id sis5513_pci_tbl[] = {
@@ -598,6 +610,7 @@ static struct pci_driver driver = {
598 .name = "SIS_IDE", 610 .name = "SIS_IDE",
599 .id_table = sis5513_pci_tbl, 611 .id_table = sis5513_pci_tbl,
600 .probe = sis5513_init_one, 612 .probe = sis5513_init_one,
613 .remove = sis5513_remove,
601}; 614};
602 615
603static int __init sis5513_ide_init(void) 616static int __init sis5513_ide_init(void)
@@ -605,7 +618,13 @@ static int __init sis5513_ide_init(void)
605 return ide_pci_register_driver(&driver); 618 return ide_pci_register_driver(&driver);
606} 619}
607 620
621static void __exit sis5513_ide_exit(void)
622{
623 pci_unregister_driver(&driver);
624}
625
608module_init(sis5513_ide_init); 626module_init(sis5513_ide_init);
627module_exit(sis5513_ide_exit);
609 628
610MODULE_AUTHOR("Lionel Bouton, L C Chang, Andre Hedrick, Vojtech Pavlik"); 629MODULE_AUTHOR("Lionel Bouton, L C Chang, Andre Hedrick, Vojtech Pavlik");
611MODULE_DESCRIPTION("PCI driver module for SIS IDE"); 630MODULE_DESCRIPTION("PCI driver module for SIS IDE");
diff --git a/drivers/ide/pci/sl82c105.c b/drivers/ide/pci/sl82c105.c
index f82a6502c1b7..73905bcc08fb 100644
--- a/drivers/ide/pci/sl82c105.c
+++ b/drivers/ide/pci/sl82c105.c
@@ -23,6 +23,8 @@
23 23
24#include <asm/io.h> 24#include <asm/io.h>
25 25
26#define DRV_NAME "sl82c105"
27
26#undef DEBUG 28#undef DEBUG
27 29
28#ifdef DEBUG 30#ifdef DEBUG
@@ -270,7 +272,7 @@ static u8 sl82c105_bridge_revision(struct pci_dev *dev)
270 * channel 0 here at least, but channel 1 has to be enabled by 272 * channel 0 here at least, but channel 1 has to be enabled by
271 * firmware or arch code. We still set both to 16 bits mode. 273 * firmware or arch code. We still set both to 16 bits mode.
272 */ 274 */
273static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev, const char *msg) 275static unsigned int __devinit init_chipset_sl82c105(struct pci_dev *dev)
274{ 276{
275 u32 val; 277 u32 val;
276 278
@@ -301,7 +303,7 @@ static const struct ide_dma_ops sl82c105_dma_ops = {
301}; 303};
302 304
303static const struct ide_port_info sl82c105_chipset __devinitdata = { 305static const struct ide_port_info sl82c105_chipset __devinitdata = {
304 .name = "W82C105", 306 .name = DRV_NAME,
305 .init_chipset = init_chipset_sl82c105, 307 .init_chipset = init_chipset_sl82c105,
306 .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}}, 308 .enablebits = {{0x40,0x01,0x01}, {0x40,0x10,0x10}},
307 .port_ops = &sl82c105_port_ops, 309 .port_ops = &sl82c105_port_ops,
@@ -328,14 +330,14 @@ static int __devinit sl82c105_init_one(struct pci_dev *dev, const struct pci_dev
328 * Never ever EVER under any circumstances enable 330 * Never ever EVER under any circumstances enable
329 * DMA when the bridge is this old. 331 * DMA when the bridge is this old.
330 */ 332 */
331 printk(KERN_INFO "W82C105_IDE: Winbond W83C553 bridge " 333 printk(KERN_INFO DRV_NAME ": Winbond W83C553 bridge "
332 "revision %d, BM-DMA disabled\n", rev); 334 "revision %d, BM-DMA disabled\n", rev);
333 d.dma_ops = NULL; 335 d.dma_ops = NULL;
334 d.mwdma_mask = 0; 336 d.mwdma_mask = 0;
335 d.host_flags &= ~IDE_HFLAG_SERIALIZE_DMA; 337 d.host_flags &= ~IDE_HFLAG_SERIALIZE_DMA;
336 } 338 }
337 339
338 return ide_setup_pci_device(dev, &d); 340 return ide_pci_init_one(dev, &d, NULL);
339} 341}
340 342
341static const struct pci_device_id sl82c105_pci_tbl[] = { 343static const struct pci_device_id sl82c105_pci_tbl[] = {
@@ -348,6 +350,7 @@ static struct pci_driver driver = {
348 .name = "W82C105_IDE", 350 .name = "W82C105_IDE",
349 .id_table = sl82c105_pci_tbl, 351 .id_table = sl82c105_pci_tbl,
350 .probe = sl82c105_init_one, 352 .probe = sl82c105_init_one,
353 .remove = ide_pci_remove,
351}; 354};
352 355
353static int __init sl82c105_ide_init(void) 356static int __init sl82c105_ide_init(void)
@@ -355,7 +358,13 @@ static int __init sl82c105_ide_init(void)
355 return ide_pci_register_driver(&driver); 358 return ide_pci_register_driver(&driver);
356} 359}
357 360
361static void __exit sl82c105_ide_exit(void)
362{
363 pci_unregister_driver(&driver);
364}
365
358module_init(sl82c105_ide_init); 366module_init(sl82c105_ide_init);
367module_exit(sl82c105_ide_exit);
359 368
360MODULE_DESCRIPTION("PCI driver module for W82C105 IDE"); 369MODULE_DESCRIPTION("PCI driver module for W82C105 IDE");
361MODULE_LICENSE("GPL"); 370MODULE_LICENSE("GPL");
diff --git a/drivers/ide/pci/slc90e66.c b/drivers/ide/pci/slc90e66.c
index dae6e2c94d86..13d1fa491f26 100644
--- a/drivers/ide/pci/slc90e66.c
+++ b/drivers/ide/pci/slc90e66.c
@@ -15,6 +15,8 @@
15#include <linux/ide.h> 15#include <linux/ide.h>
16#include <linux/init.h> 16#include <linux/init.h>
17 17
18#define DRV_NAME "slc90e66"
19
18static DEFINE_SPINLOCK(slc90e66_lock); 20static DEFINE_SPINLOCK(slc90e66_lock);
19 21
20static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio) 22static void slc90e66_set_pio_mode(ide_drive_t *drive, const u8 pio)
@@ -132,7 +134,7 @@ static const struct ide_port_ops slc90e66_port_ops = {
132}; 134};
133 135
134static const struct ide_port_info slc90e66_chipset __devinitdata = { 136static const struct ide_port_info slc90e66_chipset __devinitdata = {
135 .name = "SLC90E66", 137 .name = DRV_NAME,
136 .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} }, 138 .enablebits = { {0x41, 0x80, 0x80}, {0x43, 0x80, 0x80} },
137 .port_ops = &slc90e66_port_ops, 139 .port_ops = &slc90e66_port_ops,
138 .host_flags = IDE_HFLAG_LEGACY_IRQS, 140 .host_flags = IDE_HFLAG_LEGACY_IRQS,
@@ -144,7 +146,7 @@ static const struct ide_port_info slc90e66_chipset __devinitdata = {
144 146
145static int __devinit slc90e66_init_one(struct pci_dev *dev, const struct pci_device_id *id) 147static int __devinit slc90e66_init_one(struct pci_dev *dev, const struct pci_device_id *id)
146{ 148{
147 return ide_setup_pci_device(dev, &slc90e66_chipset); 149 return ide_pci_init_one(dev, &slc90e66_chipset, NULL);
148} 150}
149 151
150static const struct pci_device_id slc90e66_pci_tbl[] = { 152static const struct pci_device_id slc90e66_pci_tbl[] = {
@@ -157,6 +159,7 @@ static struct pci_driver driver = {
157 .name = "SLC90e66_IDE", 159 .name = "SLC90e66_IDE",
158 .id_table = slc90e66_pci_tbl, 160 .id_table = slc90e66_pci_tbl,
159 .probe = slc90e66_init_one, 161 .probe = slc90e66_init_one,
162 .remove = ide_pci_remove,
160}; 163};
161 164
162static int __init slc90e66_ide_init(void) 165static int __init slc90e66_ide_init(void)
@@ -164,7 +167,13 @@ static int __init slc90e66_ide_init(void)
164 return ide_pci_register_driver(&driver); 167 return ide_pci_register_driver(&driver);
165} 168}
166 169
170static void __exit slc90e66_ide_exit(void)
171{
172 pci_unregister_driver(&driver);
173}
174
167module_init(slc90e66_ide_init); 175module_init(slc90e66_ide_init);
176module_exit(slc90e66_ide_exit);
168 177
169MODULE_AUTHOR("Andre Hedrick"); 178MODULE_AUTHOR("Andre Hedrick");
170MODULE_DESCRIPTION("PCI driver module for SLC90E66 IDE"); 179MODULE_DESCRIPTION("PCI driver module for SLC90E66 IDE");
diff --git a/drivers/ide/pci/tc86c001.c b/drivers/ide/pci/tc86c001.c
index 477e19790102..b1cb8a9ce5a9 100644
--- a/drivers/ide/pci/tc86c001.c
+++ b/drivers/ide/pci/tc86c001.c
@@ -11,6 +11,8 @@
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <linux/ide.h> 12#include <linux/ide.h>
13 13
14#define DRV_NAME "tc86c001"
15
14static void tc86c001_set_mode(ide_drive_t *drive, const u8 speed) 16static void tc86c001_set_mode(ide_drive_t *drive, const u8 speed)
15{ 17{
16 ide_hwif_t *hwif = HWIF(drive); 18 ide_hwif_t *hwif = HWIF(drive);
@@ -173,16 +175,6 @@ static void __devinit init_hwif_tc86c001(ide_hwif_t *hwif)
173 hwif->rqsize = 0xffff; 175 hwif->rqsize = 0xffff;
174} 176}
175 177
176static unsigned int __devinit init_chipset_tc86c001(struct pci_dev *dev,
177 const char *name)
178{
179 int err = pci_request_region(dev, 5, name);
180
181 if (err)
182 printk(KERN_ERR "%s: system control regs already in use", name);
183 return err;
184}
185
186static const struct ide_port_ops tc86c001_port_ops = { 178static const struct ide_port_ops tc86c001_port_ops = {
187 .set_pio_mode = tc86c001_set_pio_mode, 179 .set_pio_mode = tc86c001_set_pio_mode,
188 .set_dma_mode = tc86c001_set_mode, 180 .set_dma_mode = tc86c001_set_mode,
@@ -201,8 +193,7 @@ static const struct ide_dma_ops tc86c001_dma_ops = {
201}; 193};
202 194
203static const struct ide_port_info tc86c001_chipset __devinitdata = { 195static const struct ide_port_info tc86c001_chipset __devinitdata = {
204 .name = "TC86C001", 196 .name = DRV_NAME,
205 .init_chipset = init_chipset_tc86c001,
206 .init_hwif = init_hwif_tc86c001, 197 .init_hwif = init_hwif_tc86c001,
207 .port_ops = &tc86c001_port_ops, 198 .port_ops = &tc86c001_port_ops,
208 .dma_ops = &tc86c001_dma_ops, 199 .dma_ops = &tc86c001_dma_ops,
@@ -215,7 +206,37 @@ static const struct ide_port_info tc86c001_chipset __devinitdata = {
215static int __devinit tc86c001_init_one(struct pci_dev *dev, 206static int __devinit tc86c001_init_one(struct pci_dev *dev,
216 const struct pci_device_id *id) 207 const struct pci_device_id *id)
217{ 208{
218 return ide_setup_pci_device(dev, &tc86c001_chipset); 209 int rc;
210
211 rc = pci_enable_device(dev);
212 if (rc)
213 goto out;
214
215 rc = pci_request_region(dev, 5, DRV_NAME);
216 if (rc) {
217 printk(KERN_ERR DRV_NAME ": system control regs already in use");
218 goto out_disable;
219 }
220
221 rc = ide_pci_init_one(dev, &tc86c001_chipset, NULL);
222 if (rc)
223 goto out_release;
224
225 goto out;
226
227out_release:
228 pci_release_region(dev, 5);
229out_disable:
230 pci_disable_device(dev);
231out:
232 return rc;
233}
234
235static void __devexit tc86c001_remove(struct pci_dev *dev)
236{
237 ide_pci_remove(dev);
238 pci_release_region(dev, 5);
239 pci_disable_device(dev);
219} 240}
220 241
221static const struct pci_device_id tc86c001_pci_tbl[] = { 242static const struct pci_device_id tc86c001_pci_tbl[] = {
@@ -227,14 +248,22 @@ MODULE_DEVICE_TABLE(pci, tc86c001_pci_tbl);
227static struct pci_driver driver = { 248static struct pci_driver driver = {
228 .name = "TC86C001", 249 .name = "TC86C001",
229 .id_table = tc86c001_pci_tbl, 250 .id_table = tc86c001_pci_tbl,
230 .probe = tc86c001_init_one 251 .probe = tc86c001_init_one,
252 .remove = tc86c001_remove,
231}; 253};
232 254
233static int __init tc86c001_ide_init(void) 255static int __init tc86c001_ide_init(void)
234{ 256{
235 return ide_pci_register_driver(&driver); 257 return ide_pci_register_driver(&driver);
236} 258}
259
260static void __exit tc86c001_ide_exit(void)
261{
262 pci_unregister_driver(&driver);
263}
264
237module_init(tc86c001_ide_init); 265module_init(tc86c001_ide_init);
266module_exit(tc86c001_ide_exit);
238 267
239MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>"); 268MODULE_AUTHOR("MontaVista Software, Inc. <source@mvista.com>");
240MODULE_DESCRIPTION("PCI driver module for TC86C001 IDE"); 269MODULE_DESCRIPTION("PCI driver module for TC86C001 IDE");
diff --git a/drivers/ide/pci/triflex.c b/drivers/ide/pci/triflex.c
index db65a558d4ec..b77ec35151b3 100644
--- a/drivers/ide/pci/triflex.c
+++ b/drivers/ide/pci/triflex.c
@@ -33,6 +33,8 @@
33#include <linux/ide.h> 33#include <linux/ide.h>
34#include <linux/init.h> 34#include <linux/init.h>
35 35
36#define DRV_NAME "triflex"
37
36static void triflex_set_mode(ide_drive_t *drive, const u8 speed) 38static void triflex_set_mode(ide_drive_t *drive, const u8 speed)
37{ 39{
38 ide_hwif_t *hwif = HWIF(drive); 40 ide_hwif_t *hwif = HWIF(drive);
@@ -93,7 +95,7 @@ static const struct ide_port_ops triflex_port_ops = {
93}; 95};
94 96
95static const struct ide_port_info triflex_device __devinitdata = { 97static const struct ide_port_info triflex_device __devinitdata = {
96 .name = "TRIFLEX", 98 .name = DRV_NAME,
97 .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}}, 99 .enablebits = {{0x80, 0x01, 0x01}, {0x80, 0x02, 0x02}},
98 .port_ops = &triflex_port_ops, 100 .port_ops = &triflex_port_ops,
99 .pio_mask = ATA_PIO4, 101 .pio_mask = ATA_PIO4,
@@ -104,7 +106,7 @@ static const struct ide_port_info triflex_device __devinitdata = {
104static int __devinit triflex_init_one(struct pci_dev *dev, 106static int __devinit triflex_init_one(struct pci_dev *dev,
105 const struct pci_device_id *id) 107 const struct pci_device_id *id)
106{ 108{
107 return ide_setup_pci_device(dev, &triflex_device); 109 return ide_pci_init_one(dev, &triflex_device, NULL);
108} 110}
109 111
110static const struct pci_device_id triflex_pci_tbl[] = { 112static const struct pci_device_id triflex_pci_tbl[] = {
@@ -117,6 +119,7 @@ static struct pci_driver driver = {
117 .name = "TRIFLEX_IDE", 119 .name = "TRIFLEX_IDE",
118 .id_table = triflex_pci_tbl, 120 .id_table = triflex_pci_tbl,
119 .probe = triflex_init_one, 121 .probe = triflex_init_one,
122 .remove = ide_pci_remove,
120}; 123};
121 124
122static int __init triflex_ide_init(void) 125static int __init triflex_ide_init(void)
@@ -124,7 +127,13 @@ static int __init triflex_ide_init(void)
124 return ide_pci_register_driver(&driver); 127 return ide_pci_register_driver(&driver);
125} 128}
126 129
130static void __exit triflex_ide_exit(void)
131{
132 pci_unregister_driver(&driver);
133}
134
127module_init(triflex_ide_init); 135module_init(triflex_ide_init);
136module_exit(triflex_ide_exit);
128 137
129MODULE_AUTHOR("Torben Mathiasen"); 138MODULE_AUTHOR("Torben Mathiasen");
130MODULE_DESCRIPTION("PCI driver module for Compaq Triflex IDE"); 139MODULE_DESCRIPTION("PCI driver module for Compaq Triflex IDE");
diff --git a/drivers/ide/pci/trm290.c b/drivers/ide/pci/trm290.c
index a8a3138682ef..fd28b49977fd 100644
--- a/drivers/ide/pci/trm290.c
+++ b/drivers/ide/pci/trm290.c
@@ -141,6 +141,8 @@
141 141
142#include <asm/io.h> 142#include <asm/io.h>
143 143
144#define DRV_NAME "trm290"
145
144static void trm290_prepare_drive (ide_drive_t *drive, unsigned int use_dma) 146static void trm290_prepare_drive (ide_drive_t *drive, unsigned int use_dma)
145{ 147{
146 ide_hwif_t *hwif = HWIF(drive); 148 ide_hwif_t *hwif = HWIF(drive);
@@ -245,10 +247,10 @@ static void __devinit init_hwif_trm290(ide_hwif_t *hwif)
245 u8 reg = 0; 247 u8 reg = 0;
246 248
247 if ((dev->class & 5) && cfg_base) 249 if ((dev->class & 5) && cfg_base)
248 printk(KERN_INFO "TRM290: chip"); 250 printk(KERN_INFO DRV_NAME " %s: chip", pci_name(dev));
249 else { 251 else {
250 cfg_base = 0x3df0; 252 cfg_base = 0x3df0;
251 printk(KERN_INFO "TRM290: using default"); 253 printk(KERN_INFO DRV_NAME " %s: using default", pci_name(dev));
252 } 254 }
253 printk(KERN_CONT " config base at 0x%04x\n", cfg_base); 255 printk(KERN_CONT " config base at 0x%04x\n", cfg_base);
254 hwif->config_data = cfg_base; 256 hwif->config_data = cfg_base;
@@ -325,7 +327,7 @@ static struct ide_dma_ops trm290_dma_ops = {
325}; 327};
326 328
327static const struct ide_port_info trm290_chipset __devinitdata = { 329static const struct ide_port_info trm290_chipset __devinitdata = {
328 .name = "TRM290", 330 .name = DRV_NAME,
329 .init_hwif = init_hwif_trm290, 331 .init_hwif = init_hwif_trm290,
330 .chipset = ide_trm290, 332 .chipset = ide_trm290,
331 .port_ops = &trm290_port_ops, 333 .port_ops = &trm290_port_ops,
@@ -340,7 +342,7 @@ static const struct ide_port_info trm290_chipset __devinitdata = {
340 342
341static int __devinit trm290_init_one(struct pci_dev *dev, const struct pci_device_id *id) 343static int __devinit trm290_init_one(struct pci_dev *dev, const struct pci_device_id *id)
342{ 344{
343 return ide_setup_pci_device(dev, &trm290_chipset); 345 return ide_pci_init_one(dev, &trm290_chipset, NULL);
344} 346}
345 347
346static const struct pci_device_id trm290_pci_tbl[] = { 348static const struct pci_device_id trm290_pci_tbl[] = {
@@ -353,6 +355,7 @@ static struct pci_driver driver = {
353 .name = "TRM290_IDE", 355 .name = "TRM290_IDE",
354 .id_table = trm290_pci_tbl, 356 .id_table = trm290_pci_tbl,
355 .probe = trm290_init_one, 357 .probe = trm290_init_one,
358 .remove = ide_pci_remove,
356}; 359};
357 360
358static int __init trm290_ide_init(void) 361static int __init trm290_ide_init(void)
@@ -360,7 +363,13 @@ static int __init trm290_ide_init(void)
360 return ide_pci_register_driver(&driver); 363 return ide_pci_register_driver(&driver);
361} 364}
362 365
366static void __exit trm290_ide_exit(void)
367{
368 pci_unregister_driver(&driver);
369}
370
363module_init(trm290_ide_init); 371module_init(trm290_ide_init);
372module_exit(trm290_ide_exit);
364 373
365MODULE_AUTHOR("Mark Lord"); 374MODULE_AUTHOR("Mark Lord");
366MODULE_DESCRIPTION("PCI driver module for Tekram TRM290 IDE"); 375MODULE_DESCRIPTION("PCI driver module for Tekram TRM290 IDE");
diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c
index 09dc4803ef9d..454d2bf62dce 100644
--- a/drivers/ide/pci/via82cxxx.c
+++ b/drivers/ide/pci/via82cxxx.c
@@ -35,6 +35,8 @@
35#include <asm/processor.h> 35#include <asm/processor.h>
36#endif 36#endif
37 37
38#define DRV_NAME "via82cxxx"
39
38#define VIA_IDE_ENABLE 0x40 40#define VIA_IDE_ENABLE 0x40
39#define VIA_IDE_CONFIG 0x41 41#define VIA_IDE_CONFIG 0x41
40#define VIA_FIFO_CONFIG 0x43 42#define VIA_FIFO_CONFIG 0x43
@@ -113,7 +115,8 @@ struct via82cxxx_dev
113static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing) 115static void via_set_speed(ide_hwif_t *hwif, u8 dn, struct ide_timing *timing)
114{ 116{
115 struct pci_dev *dev = to_pci_dev(hwif->dev); 117 struct pci_dev *dev = to_pci_dev(hwif->dev);
116 struct via82cxxx_dev *vdev = pci_get_drvdata(dev); 118 struct ide_host *host = pci_get_drvdata(dev);
119 struct via82cxxx_dev *vdev = host->host_priv;
117 u8 t; 120 u8 t;
118 121
119 if (~vdev->via_config->flags & VIA_BAD_AST) { 122 if (~vdev->via_config->flags & VIA_BAD_AST) {
@@ -153,7 +156,8 @@ static void via_set_drive(ide_drive_t *drive, const u8 speed)
153 ide_hwif_t *hwif = drive->hwif; 156 ide_hwif_t *hwif = drive->hwif;
154 ide_drive_t *peer = hwif->drives + (~drive->dn & 1); 157 ide_drive_t *peer = hwif->drives + (~drive->dn & 1);
155 struct pci_dev *dev = to_pci_dev(hwif->dev); 158 struct pci_dev *dev = to_pci_dev(hwif->dev);
156 struct via82cxxx_dev *vdev = pci_get_drvdata(dev); 159 struct ide_host *host = pci_get_drvdata(dev);
160 struct via82cxxx_dev *vdev = host->host_priv;
157 struct ide_timing t, p; 161 struct ide_timing t, p;
158 unsigned int T, UT; 162 unsigned int T, UT;
159 163
@@ -258,37 +262,19 @@ static void __devinit via_cable_detect(struct via82cxxx_dev *vdev, u32 u)
258/** 262/**
259 * init_chipset_via82cxxx - initialization handler 263 * init_chipset_via82cxxx - initialization handler
260 * @dev: PCI device 264 * @dev: PCI device
261 * @name: Name of interface
262 * 265 *
263 * The initialization callback. Here we determine the IDE chip type 266 * The initialization callback. Here we determine the IDE chip type
264 * and initialize its drive independent registers. 267 * and initialize its drive independent registers.
265 */ 268 */
266 269
267static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const char *name) 270static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev)
268{ 271{
269 struct pci_dev *isa = NULL; 272 struct ide_host *host = pci_get_drvdata(dev);
270 struct via82cxxx_dev *vdev; 273 struct via82cxxx_dev *vdev = host->host_priv;
271 struct via_isa_bridge *via_config; 274 struct via_isa_bridge *via_config = vdev->via_config;
272 u8 t, v; 275 u8 t, v;
273 u32 u; 276 u32 u;
274 277
275 vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
276 if (!vdev) {
277 printk(KERN_ERR "VP_IDE: out of memory :(\n");
278 return -ENOMEM;
279 }
280 pci_set_drvdata(dev, vdev);
281
282 /*
283 * Find the ISA bridge to see how good the IDE is.
284 */
285 vdev->via_config = via_config = via_config_find(&isa);
286
287 /* We checked this earlier so if it fails here deeep badness
288 is involved */
289
290 BUG_ON(!via_config->id);
291
292 /* 278 /*
293 * Detect cable and configure Clk66 279 * Detect cable and configure Clk66
294 */ 280 */
@@ -334,39 +320,6 @@ static unsigned int __devinit init_chipset_via82cxxx(struct pci_dev *dev, const
334 320
335 pci_write_config_byte(dev, VIA_FIFO_CONFIG, t); 321 pci_write_config_byte(dev, VIA_FIFO_CONFIG, t);
336 322
337 /*
338 * Determine system bus clock.
339 */
340
341 via_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000;
342
343 switch (via_clock) {
344 case 33000: via_clock = 33333; break;
345 case 37000: via_clock = 37500; break;
346 case 41000: via_clock = 41666; break;
347 }
348
349 if (via_clock < 20000 || via_clock > 50000) {
350 printk(KERN_WARNING "VP_IDE: User given PCI clock speed "
351 "impossible (%d), using 33 MHz instead.\n", via_clock);
352 printk(KERN_WARNING "VP_IDE: Use ide0=ata66 if you want "
353 "to assume 80-wire cable.\n");
354 via_clock = 33333;
355 }
356
357 /*
358 * Print the boot message.
359 */
360
361 printk(KERN_INFO "VP_IDE: VIA %s (rev %02x) IDE %sDMA%s "
362 "controller on pci%s\n",
363 via_config->name, isa->revision,
364 via_config->udma_mask ? "U" : "MW",
365 via_dma[via_config->udma_mask ?
366 (fls(via_config->udma_mask) - 1) : 0],
367 pci_name(dev));
368
369 pci_dev_put(isa);
370 return 0; 323 return 0;
371} 324}
372 325
@@ -402,7 +355,8 @@ static int via_cable_override(struct pci_dev *pdev)
402static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif) 355static u8 __devinit via82cxxx_cable_detect(ide_hwif_t *hwif)
403{ 356{
404 struct pci_dev *pdev = to_pci_dev(hwif->dev); 357 struct pci_dev *pdev = to_pci_dev(hwif->dev);
405 struct via82cxxx_dev *vdev = pci_get_drvdata(pdev); 358 struct ide_host *host = pci_get_drvdata(pdev);
359 struct via82cxxx_dev *vdev = host->host_priv;
406 360
407 if (via_cable_override(pdev)) 361 if (via_cable_override(pdev))
408 return ATA_CBL_PATA40_SHORT; 362 return ATA_CBL_PATA40_SHORT;
@@ -420,7 +374,7 @@ static const struct ide_port_ops via_port_ops = {
420}; 374};
421 375
422static const struct ide_port_info via82cxxx_chipset __devinitdata = { 376static const struct ide_port_info via82cxxx_chipset __devinitdata = {
423 .name = "VP_IDE", 377 .name = DRV_NAME,
424 .init_chipset = init_chipset_via82cxxx, 378 .init_chipset = init_chipset_via82cxxx,
425 .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } }, 379 .enablebits = { { 0x40, 0x02, 0x02 }, { 0x40, 0x01, 0x01 } },
426 .port_ops = &via_port_ops, 380 .port_ops = &via_port_ops,
@@ -436,6 +390,8 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i
436{ 390{
437 struct pci_dev *isa = NULL; 391 struct pci_dev *isa = NULL;
438 struct via_isa_bridge *via_config; 392 struct via_isa_bridge *via_config;
393 struct via82cxxx_dev *vdev;
394 int rc;
439 u8 idx = id->driver_data; 395 u8 idx = id->driver_data;
440 struct ide_port_info d; 396 struct ide_port_info d;
441 397
@@ -445,12 +401,42 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i
445 * Find the ISA bridge and check we know what it is. 401 * Find the ISA bridge and check we know what it is.
446 */ 402 */
447 via_config = via_config_find(&isa); 403 via_config = via_config_find(&isa);
448 pci_dev_put(isa);
449 if (!via_config->id) { 404 if (!via_config->id) {
450 printk(KERN_WARNING "VP_IDE: Unknown VIA SouthBridge, disabling DMA.\n"); 405 printk(KERN_WARNING DRV_NAME " %s: unknown chipset, skipping\n",
406 pci_name(dev));
451 return -ENODEV; 407 return -ENODEV;
452 } 408 }
453 409
410 /*
411 * Print the boot message.
412 */
413 printk(KERN_INFO DRV_NAME " %s: VIA %s (rev %02x) IDE %sDMA%s\n",
414 pci_name(dev), via_config->name, isa->revision,
415 via_config->udma_mask ? "U" : "MW",
416 via_dma[via_config->udma_mask ?
417 (fls(via_config->udma_mask) - 1) : 0]);
418
419 pci_dev_put(isa);
420
421 /*
422 * Determine system bus clock.
423 */
424 via_clock = (ide_pci_clk ? ide_pci_clk : 33) * 1000;
425
426 switch (via_clock) {
427 case 33000: via_clock = 33333; break;
428 case 37000: via_clock = 37500; break;
429 case 41000: via_clock = 41666; break;
430 }
431
432 if (via_clock < 20000 || via_clock > 50000) {
433 printk(KERN_WARNING DRV_NAME ": User given PCI clock speed "
434 "impossible (%d), using 33 MHz instead.\n", via_clock);
435 printk(KERN_WARNING DRV_NAME ": Use ide0=ata66 if you want "
436 "to assume 80-wire cable.\n");
437 via_clock = 33333;
438 }
439
454 if (idx == 0) 440 if (idx == 0)
455 d.host_flags |= IDE_HFLAG_NO_AUTODMA; 441 d.host_flags |= IDE_HFLAG_NO_AUTODMA;
456 else 442 else
@@ -466,7 +452,29 @@ static int __devinit via_init_one(struct pci_dev *dev, const struct pci_device_i
466 452
467 d.udma_mask = via_config->udma_mask; 453 d.udma_mask = via_config->udma_mask;
468 454
469 return ide_setup_pci_device(dev, &d); 455 vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
456 if (!vdev) {
457 printk(KERN_ERR DRV_NAME " %s: out of memory :(\n",
458 pci_name(dev));
459 return -ENOMEM;
460 }
461
462 vdev->via_config = via_config;
463
464 rc = ide_pci_init_one(dev, &d, vdev);
465 if (rc)
466 kfree(vdev);
467
468 return rc;
469}
470
471static void __devexit via_remove(struct pci_dev *dev)
472{
473 struct ide_host *host = pci_get_drvdata(dev);
474 struct via82cxxx_dev *vdev = host->host_priv;
475
476 ide_pci_remove(dev);
477 kfree(vdev);
470} 478}
471 479
472static const struct pci_device_id via_pci_tbl[] = { 480static const struct pci_device_id via_pci_tbl[] = {
@@ -483,6 +491,7 @@ static struct pci_driver driver = {
483 .name = "VIA_IDE", 491 .name = "VIA_IDE",
484 .id_table = via_pci_tbl, 492 .id_table = via_pci_tbl,
485 .probe = via_init_one, 493 .probe = via_init_one,
494 .remove = via_remove,
486}; 495};
487 496
488static int __init via_ide_init(void) 497static int __init via_ide_init(void)
@@ -490,7 +499,13 @@ static int __init via_ide_init(void)
490 return ide_pci_register_driver(&driver); 499 return ide_pci_register_driver(&driver);
491} 500}
492 501
502static void __exit via_ide_exit(void)
503{
504 pci_unregister_driver(&driver);
505}
506
493module_init(via_ide_init); 507module_init(via_ide_init);
508module_exit(via_ide_exit);
494 509
495MODULE_AUTHOR("Vojtech Pavlik, Michel Aubry, Jeff Garzik, Andre Hedrick"); 510MODULE_AUTHOR("Vojtech Pavlik, Michel Aubry, Jeff Garzik, Andre Hedrick");
496MODULE_DESCRIPTION("PCI driver module for VIA IDE"); 511MODULE_DESCRIPTION("PCI driver module for VIA IDE");
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c
index b15cad58dc81..a8e9e8a69a52 100644
--- a/drivers/ide/setup-pci.c
+++ b/drivers/ide/setup-pci.c
@@ -39,17 +39,18 @@ static int ide_setup_pci_baseregs(struct pci_dev *dev, const char *name)
39 if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || 39 if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) ||
40 (progif & 5) != 5) { 40 (progif & 5) != 5) {
41 if ((progif & 0xa) != 0xa) { 41 if ((progif & 0xa) != 0xa) {
42 printk(KERN_INFO "%s: device not capable of full " 42 printk(KERN_INFO "%s %s: device not capable of full "
43 "native PCI mode\n", name); 43 "native PCI mode\n", name, pci_name(dev));
44 return -EOPNOTSUPP; 44 return -EOPNOTSUPP;
45 } 45 }
46 printk("%s: placing both ports into native PCI mode\n", name); 46 printk(KERN_INFO "%s %s: placing both ports into native PCI "
47 "mode\n", name, pci_name(dev));
47 (void) pci_write_config_byte(dev, PCI_CLASS_PROG, progif|5); 48 (void) pci_write_config_byte(dev, PCI_CLASS_PROG, progif|5);
48 if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) || 49 if (pci_read_config_byte(dev, PCI_CLASS_PROG, &progif) ||
49 (progif & 5) != 5) { 50 (progif & 5) != 5) {
50 printk(KERN_ERR "%s: rewrite of PROGIF failed, wanted " 51 printk(KERN_ERR "%s %s: rewrite of PROGIF failed, "
51 "0x%04x, got 0x%04x\n", 52 "wanted 0x%04x, got 0x%04x\n",
52 name, progif|5, progif); 53 name, pci_name(dev), progif | 5, progif);
53 return -EOPNOTSUPP; 54 return -EOPNOTSUPP;
54 } 55 }
55 } 56 }
@@ -57,14 +58,14 @@ static int ide_setup_pci_baseregs(struct pci_dev *dev, const char *name)
57} 58}
58 59
59#ifdef CONFIG_BLK_DEV_IDEDMA_PCI 60#ifdef CONFIG_BLK_DEV_IDEDMA_PCI
60static void ide_pci_clear_simplex(unsigned long dma_base, const char *name) 61static int ide_pci_clear_simplex(unsigned long dma_base, const char *name)
61{ 62{
62 u8 dma_stat = inb(dma_base + 2); 63 u8 dma_stat = inb(dma_base + 2);
63 64
64 outb(dma_stat & 0x60, dma_base + 2); 65 outb(dma_stat & 0x60, dma_base + 2);
65 dma_stat = inb(dma_base + 2); 66 dma_stat = inb(dma_base + 2);
66 if (dma_stat & 0x80) 67
67 printk(KERN_INFO "%s: simplex device: DMA forced\n", name); 68 return (dma_stat & 0x80) ? 1 : 0;
68} 69}
69 70
70/** 71/**
@@ -91,7 +92,8 @@ unsigned long ide_pci_dma_base(ide_hwif_t *hwif, const struct ide_port_info *d)
91 dma_base = pci_resource_start(dev, baridx); 92 dma_base = pci_resource_start(dev, baridx);
92 93
93 if (dma_base == 0) { 94 if (dma_base == 0) {
94 printk(KERN_ERR "%s: DMA base is invalid\n", d->name); 95 printk(KERN_ERR "%s %s: DMA base is invalid\n",
96 d->name, pci_name(dev));
95 return 0; 97 return 0;
96 } 98 }
97 } 99 }
@@ -105,13 +107,16 @@ EXPORT_SYMBOL_GPL(ide_pci_dma_base);
105 107
106int ide_pci_check_simplex(ide_hwif_t *hwif, const struct ide_port_info *d) 108int ide_pci_check_simplex(ide_hwif_t *hwif, const struct ide_port_info *d)
107{ 109{
110 struct pci_dev *dev = to_pci_dev(hwif->dev);
108 u8 dma_stat; 111 u8 dma_stat;
109 112
110 if (d->host_flags & (IDE_HFLAG_MMIO | IDE_HFLAG_CS5520)) 113 if (d->host_flags & (IDE_HFLAG_MMIO | IDE_HFLAG_CS5520))
111 goto out; 114 goto out;
112 115
113 if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) { 116 if (d->host_flags & IDE_HFLAG_CLEAR_SIMPLEX) {
114 ide_pci_clear_simplex(hwif->dma_base, d->name); 117 if (ide_pci_clear_simplex(hwif->dma_base, d->name))
118 printk(KERN_INFO "%s %s: simplex device: DMA forced\n",
119 d->name, pci_name(dev));
115 goto out; 120 goto out;
116 } 121 }
117 122
@@ -127,7 +132,8 @@ int ide_pci_check_simplex(ide_hwif_t *hwif, const struct ide_port_info *d)
127 */ 132 */
128 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif); 133 dma_stat = hwif->tp_ops->read_sff_dma_status(hwif);
129 if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) { 134 if ((dma_stat & 0x80) && hwif->mate && hwif->mate->dma_base) {
130 printk(KERN_INFO "%s: simplex device: DMA disabled\n", d->name); 135 printk(KERN_INFO "%s %s: simplex device: DMA disabled\n",
136 d->name, pci_name(dev));
131 return -1; 137 return -1;
132 } 138 }
133out: 139out:
@@ -149,8 +155,8 @@ int ide_pci_set_master(struct pci_dev *dev, const char *name)
149 155
150 if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) || 156 if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd) ||
151 (pcicmd & PCI_COMMAND_MASTER) == 0) { 157 (pcicmd & PCI_COMMAND_MASTER) == 0) {
152 printk(KERN_ERR "%s: error updating PCICMD on %s\n", 158 printk(KERN_ERR "%s %s: error updating PCICMD\n",
153 name, pci_name(dev)); 159 name, pci_name(dev));
154 return -EIO; 160 return -EIO;
155 } 161 }
156 } 162 }
@@ -162,9 +168,9 @@ EXPORT_SYMBOL_GPL(ide_pci_set_master);
162 168
163void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d) 169void ide_setup_pci_noise(struct pci_dev *dev, const struct ide_port_info *d)
164{ 170{
165 printk(KERN_INFO "%s: IDE controller (0x%04x:0x%04x rev 0x%02x) at " 171 printk(KERN_INFO "%s %s: IDE controller (0x%04x:0x%04x rev 0x%02x)\n",
166 " PCI slot %s\n", d->name, dev->vendor, dev->device, 172 d->name, pci_name(dev),
167 dev->revision, pci_name(dev)); 173 dev->vendor, dev->device, dev->revision);
168} 174}
169EXPORT_SYMBOL_GPL(ide_setup_pci_noise); 175EXPORT_SYMBOL_GPL(ide_setup_pci_noise);
170 176
@@ -189,11 +195,12 @@ static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d)
189 if (pci_enable_device(dev)) { 195 if (pci_enable_device(dev)) {
190 ret = pci_enable_device_io(dev); 196 ret = pci_enable_device_io(dev);
191 if (ret < 0) { 197 if (ret < 0) {
192 printk(KERN_WARNING "%s: (ide_setup_pci_device:) " 198 printk(KERN_WARNING "%s %s: couldn't enable device\n",
193 "Could not enable device.\n", d->name); 199 d->name, pci_name(dev));
194 goto out; 200 goto out;
195 } 201 }
196 printk(KERN_WARNING "%s: BIOS configuration fixed.\n", d->name); 202 printk(KERN_WARNING "%s %s: BIOS configuration fixed\n",
203 d->name, pci_name(dev));
197 } 204 }
198 205
199 /* 206 /*
@@ -203,7 +210,8 @@ static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d)
203 */ 210 */
204 ret = pci_set_dma_mask(dev, DMA_32BIT_MASK); 211 ret = pci_set_dma_mask(dev, DMA_32BIT_MASK);
205 if (ret < 0) { 212 if (ret < 0) {
206 printk(KERN_ERR "%s: can't set dma mask\n", d->name); 213 printk(KERN_ERR "%s %s: can't set DMA mask\n",
214 d->name, pci_name(dev));
207 goto out; 215 goto out;
208 } 216 }
209 217
@@ -221,7 +229,8 @@ static int ide_pci_enable(struct pci_dev *dev, const struct ide_port_info *d)
221 229
222 ret = pci_request_selected_regions(dev, bars, d->name); 230 ret = pci_request_selected_regions(dev, bars, d->name);
223 if (ret < 0) 231 if (ret < 0)
224 printk(KERN_ERR "%s: can't reserve resources\n", d->name); 232 printk(KERN_ERR "%s %s: can't reserve resources\n",
233 d->name, pci_name(dev));
225out: 234out:
226 return ret; 235 return ret;
227} 236}
@@ -247,15 +256,18 @@ static int ide_pci_configure(struct pci_dev *dev, const struct ide_port_info *d)
247 */ 256 */
248 if (ide_setup_pci_baseregs(dev, d->name) || 257 if (ide_setup_pci_baseregs(dev, d->name) ||
249 pci_write_config_word(dev, PCI_COMMAND, pcicmd | PCI_COMMAND_IO)) { 258 pci_write_config_word(dev, PCI_COMMAND, pcicmd | PCI_COMMAND_IO)) {
250 printk(KERN_INFO "%s: device disabled (BIOS)\n", d->name); 259 printk(KERN_INFO "%s %s: device disabled (BIOS)\n",
260 d->name, pci_name(dev));
251 return -ENODEV; 261 return -ENODEV;
252 } 262 }
253 if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd)) { 263 if (pci_read_config_word(dev, PCI_COMMAND, &pcicmd)) {
254 printk(KERN_ERR "%s: error accessing PCI regs\n", d->name); 264 printk(KERN_ERR "%s %s: error accessing PCI regs\n",
265 d->name, pci_name(dev));
255 return -EIO; 266 return -EIO;
256 } 267 }
257 if (!(pcicmd & PCI_COMMAND_IO)) { 268 if (!(pcicmd & PCI_COMMAND_IO)) {
258 printk(KERN_ERR "%s: unable to enable IDE controller\n", d->name); 269 printk(KERN_ERR "%s %s: unable to enable IDE controller\n",
270 d->name, pci_name(dev));
259 return -ENXIO; 271 return -ENXIO;
260 } 272 }
261 return 0; 273 return 0;
@@ -311,8 +323,9 @@ static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d,
311 if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) { 323 if ((d->host_flags & IDE_HFLAG_ISA_PORTS) == 0) {
312 if (ide_pci_check_iomem(dev, d, 2 * port) || 324 if (ide_pci_check_iomem(dev, d, 2 * port) ||
313 ide_pci_check_iomem(dev, d, 2 * port + 1)) { 325 ide_pci_check_iomem(dev, d, 2 * port + 1)) {
314 printk(KERN_ERR "%s: I/O baseregs (BIOS) are reported " 326 printk(KERN_ERR "%s %s: I/O baseregs (BIOS) are "
315 "as MEM for port %d!\n", d->name, port); 327 "reported as MEM for port %d!\n",
328 d->name, pci_name(dev), port);
316 return -EINVAL; 329 return -EINVAL;
317 } 330 }
318 331
@@ -325,8 +338,8 @@ static int ide_hw_configure(struct pci_dev *dev, const struct ide_port_info *d,
325 } 338 }
326 339
327 if (!base || !ctl) { 340 if (!base || !ctl) {
328 printk(KERN_ERR "%s: bad PCI BARs for port %d, skipping\n", 341 printk(KERN_ERR "%s %s: bad PCI BARs for port %d, skipping\n",
329 d->name, port); 342 d->name, pci_name(dev), port);
330 return -EINVAL; 343 return -EINVAL;
331 } 344 }
332 345
@@ -393,14 +406,14 @@ int ide_hwif_setup_dma(ide_hwif_t *hwif, const struct ide_port_info *d)
393 * @dev: PCI device 406 * @dev: PCI device
394 * @d: IDE port info 407 * @d: IDE port info
395 * @noisy: verbose flag 408 * @noisy: verbose flag
396 * @config: returned as 1 if we configured the hardware
397 * 409 *
398 * Set up the PCI and controller side of the IDE interface. This brings 410 * Set up the PCI and controller side of the IDE interface. This brings
399 * up the PCI side of the device, checks that the device is enabled 411 * up the PCI side of the device, checks that the device is enabled
400 * and enables it if need be 412 * and enables it if need be
401 */ 413 */
402 414
403static int ide_setup_pci_controller(struct pci_dev *dev, const struct ide_port_info *d, int noisy, int *config) 415static int ide_setup_pci_controller(struct pci_dev *dev,
416 const struct ide_port_info *d, int noisy)
404{ 417{
405 int ret; 418 int ret;
406 u16 pcicmd; 419 u16 pcicmd;
@@ -414,15 +427,16 @@ static int ide_setup_pci_controller(struct pci_dev *dev, const struct ide_port_i
414 427
415 ret = pci_read_config_word(dev, PCI_COMMAND, &pcicmd); 428 ret = pci_read_config_word(dev, PCI_COMMAND, &pcicmd);
416 if (ret < 0) { 429 if (ret < 0) {
417 printk(KERN_ERR "%s: error accessing PCI regs\n", d->name); 430 printk(KERN_ERR "%s %s: error accessing PCI regs\n",
431 d->name, pci_name(dev));
418 goto out; 432 goto out;
419 } 433 }
420 if (!(pcicmd & PCI_COMMAND_IO)) { /* is device disabled? */ 434 if (!(pcicmd & PCI_COMMAND_IO)) { /* is device disabled? */
421 ret = ide_pci_configure(dev, d); 435 ret = ide_pci_configure(dev, d);
422 if (ret < 0) 436 if (ret < 0)
423 goto out; 437 goto out;
424 *config = 1; 438 printk(KERN_INFO "%s %s: device enabled (Linux)\n",
425 printk(KERN_INFO "%s: device enabled (Linux)\n", d->name); 439 d->name, pci_name(dev));
426 } 440 }
427 441
428out: 442out:
@@ -461,7 +475,8 @@ void ide_pci_setup_ports(struct pci_dev *dev, const struct ide_port_info *d,
461 475
462 if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || 476 if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) ||
463 (tmp & e->mask) != e->val)) { 477 (tmp & e->mask) != e->val)) {
464 printk(KERN_INFO "%s: IDE port disabled\n", d->name); 478 printk(KERN_INFO "%s %s: IDE port disabled\n",
479 d->name, pci_name(dev));
465 continue; /* port not enabled */ 480 continue; /* port not enabled */
466 } 481 }
467 482
@@ -487,51 +502,35 @@ static int do_ide_setup_pci_device(struct pci_dev *dev,
487 const struct ide_port_info *d, 502 const struct ide_port_info *d,
488 u8 noisy) 503 u8 noisy)
489{ 504{
490 int tried_config = 0;
491 int pciirq, ret; 505 int pciirq, ret;
492 506
493 ret = ide_setup_pci_controller(dev, d, noisy, &tried_config);
494 if (ret < 0)
495 goto out;
496
497 /* 507 /*
498 * Can we trust the reported IRQ? 508 * Can we trust the reported IRQ?
499 */ 509 */
500 pciirq = dev->irq; 510 pciirq = dev->irq;
501 511
512 /*
513 * This allows offboard ide-pci cards the enable a BIOS,
514 * verify interrupt settings of split-mirror pci-config
515 * space, place chipset into init-mode, and/or preserve
516 * an interrupt if the card is not native ide support.
517 */
518 ret = d->init_chipset ? d->init_chipset(dev) : 0;
519 if (ret < 0)
520 goto out;
521
502 /* Is it an "IDE storage" device in non-PCI mode? */ 522 /* Is it an "IDE storage" device in non-PCI mode? */
503 if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 5) != 5) { 523 if ((dev->class >> 8) == PCI_CLASS_STORAGE_IDE && (dev->class & 5) != 5) {
504 if (noisy) 524 if (noisy)
505 printk(KERN_INFO "%s: not 100%% native mode: " 525 printk(KERN_INFO "%s %s: not 100%% native mode: will "
506 "will probe irqs later\n", d->name); 526 "probe irqs later\n", d->name, pci_name(dev));
507 /*
508 * This allows offboard ide-pci cards the enable a BIOS,
509 * verify interrupt settings of split-mirror pci-config
510 * space, place chipset into init-mode, and/or preserve
511 * an interrupt if the card is not native ide support.
512 */
513 ret = d->init_chipset ? d->init_chipset(dev, d->name) : 0;
514 if (ret < 0)
515 goto out;
516 pciirq = ret; 527 pciirq = ret;
517 } else if (tried_config) { 528 } else if (!pciirq && noisy) {
518 if (noisy) 529 printk(KERN_WARNING "%s %s: bad irq (%d): will probe later\n",
519 printk(KERN_INFO "%s: will probe irqs later\n", d->name); 530 d->name, pci_name(dev), pciirq);
520 pciirq = 0; 531 } else if (noisy) {
521 } else if (!pciirq) { 532 printk(KERN_INFO "%s %s: 100%% native mode on irq %d\n",
522 if (noisy) 533 d->name, pci_name(dev), pciirq);
523 printk(KERN_WARNING "%s: bad irq (%d): will probe later\n",
524 d->name, pciirq);
525 pciirq = 0;
526 } else {
527 if (d->init_chipset) {
528 ret = d->init_chipset(dev, d->name);
529 if (ret < 0)
530 goto out;
531 }
532 if (noisy)
533 printk(KERN_INFO "%s: 100%% native mode on irq %d\n",
534 d->name, pciirq);
535 } 534 }
536 535
537 ret = pciirq; 536 ret = pciirq;
@@ -539,32 +538,77 @@ out:
539 return ret; 538 return ret;
540} 539}
541 540
542int ide_setup_pci_device(struct pci_dev *dev, const struct ide_port_info *d) 541int ide_pci_init_one(struct pci_dev *dev, const struct ide_port_info *d,
542 void *priv)
543{ 543{
544 struct ide_host *host;
544 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; 545 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
545 int ret; 546 int ret;
546 547
547 ret = do_ide_setup_pci_device(dev, d, 1); 548 ret = ide_setup_pci_controller(dev, d, 1);
549 if (ret < 0)
550 goto out;
548 551
549 if (ret >= 0) { 552 ide_pci_setup_ports(dev, d, 0, &hw[0], &hws[0]);
550 /* FIXME: silent failure can happen */
551 ide_pci_setup_ports(dev, d, ret, &hw[0], &hws[0]);
552 553
553 ret = ide_host_add(d, hws, NULL); 554 host = ide_host_alloc(d, hws);
555 if (host == NULL) {
556 ret = -ENOMEM;
557 goto out;
554 } 558 }
555 559
560 host->dev[0] = &dev->dev;
561
562 host->host_priv = priv;
563
564 pci_set_drvdata(dev, host);
565
566 ret = do_ide_setup_pci_device(dev, d, 1);
567 if (ret < 0)
568 goto out;
569
570 /* fixup IRQ */
571 hw[1].irq = hw[0].irq = ret;
572
573 ret = ide_host_register(host, d, hws);
574 if (ret)
575 ide_host_free(host);
576out:
556 return ret; 577 return ret;
557} 578}
558EXPORT_SYMBOL_GPL(ide_setup_pci_device); 579EXPORT_SYMBOL_GPL(ide_pci_init_one);
559 580
560int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2, 581int ide_pci_init_two(struct pci_dev *dev1, struct pci_dev *dev2,
561 const struct ide_port_info *d) 582 const struct ide_port_info *d, void *priv)
562{ 583{
563 struct pci_dev *pdev[] = { dev1, dev2 }; 584 struct pci_dev *pdev[] = { dev1, dev2 };
585 struct ide_host *host;
564 int ret, i; 586 int ret, i;
565 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL }; 587 hw_regs_t hw[4], *hws[] = { NULL, NULL, NULL, NULL };
566 588
567 for (i = 0; i < 2; i++) { 589 for (i = 0; i < 2; i++) {
590 ret = ide_setup_pci_controller(pdev[i], d, !i);
591 if (ret < 0)
592 goto out;
593
594 ide_pci_setup_ports(pdev[i], d, 0, &hw[i*2], &hws[i*2]);
595 }
596
597 host = ide_host_alloc(d, hws);
598 if (host == NULL) {
599 ret = -ENOMEM;
600 goto out;
601 }
602
603 host->dev[0] = &dev1->dev;
604 host->dev[1] = &dev2->dev;
605
606 host->host_priv = priv;
607
608 pci_set_drvdata(pdev[0], host);
609 pci_set_drvdata(pdev[1], host);
610
611 for (i = 0; i < 2; i++) {
568 ret = do_ide_setup_pci_device(pdev[i], d, !i); 612 ret = do_ide_setup_pci_device(pdev[i], d, !i);
569 613
570 /* 614 /*
@@ -574,12 +618,44 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
574 if (ret < 0) 618 if (ret < 0)
575 goto out; 619 goto out;
576 620
577 /* FIXME: silent failure can happen */ 621 /* fixup IRQ */
578 ide_pci_setup_ports(pdev[i], d, ret, &hw[i*2], &hws[i*2]); 622 hw[i*2 + 1].irq = hw[i*2].irq = ret;
579 } 623 }
580 624
581 ret = ide_host_add(d, hws, NULL); 625 ret = ide_host_register(host, d, hws);
626 if (ret)
627 ide_host_free(host);
582out: 628out:
583 return ret; 629 return ret;
584} 630}
585EXPORT_SYMBOL_GPL(ide_setup_pci_devices); 631EXPORT_SYMBOL_GPL(ide_pci_init_two);
632
633void ide_pci_remove(struct pci_dev *dev)
634{
635 struct ide_host *host = pci_get_drvdata(dev);
636 struct pci_dev *dev2 = host->dev[1] ? to_pci_dev(host->dev[1]) : NULL;
637 int bars;
638
639 if (host->host_flags & IDE_HFLAG_SINGLE)
640 bars = (1 << 2) - 1;
641 else
642 bars = (1 << 4) - 1;
643
644 if ((host->host_flags & IDE_HFLAG_NO_DMA) == 0) {
645 if (host->host_flags & IDE_HFLAG_CS5520)
646 bars |= (1 << 2);
647 else
648 bars |= (1 << 4);
649 }
650
651 ide_host_remove(host);
652
653 if (dev2)
654 pci_release_selected_regions(dev2, bars);
655 pci_release_selected_regions(dev, bars);
656
657 if (dev2)
658 pci_disable_device(dev2);
659 pci_disable_device(dev);
660}
661EXPORT_SYMBOL_GPL(ide_pci_remove);
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c
index 538552495d48..b40a673985aa 100644
--- a/drivers/scsi/ide-scsi.c
+++ b/drivers/scsi/ide-scsi.c
@@ -101,8 +101,13 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk)
101 101
102 mutex_lock(&idescsi_ref_mutex); 102 mutex_lock(&idescsi_ref_mutex);
103 scsi = ide_scsi_g(disk); 103 scsi = ide_scsi_g(disk);
104 if (scsi) 104 if (scsi) {
105 scsi_host_get(scsi->host); 105 scsi_host_get(scsi->host);
106 if (ide_device_get(scsi->drive)) {
107 scsi_host_put(scsi->host);
108 scsi = NULL;
109 }
110 }
106 mutex_unlock(&idescsi_ref_mutex); 111 mutex_unlock(&idescsi_ref_mutex);
107 return scsi; 112 return scsi;
108} 113}
@@ -110,6 +115,7 @@ static struct ide_scsi_obj *ide_scsi_get(struct gendisk *disk)
110static void ide_scsi_put(struct ide_scsi_obj *scsi) 115static void ide_scsi_put(struct ide_scsi_obj *scsi)
111{ 116{
112 mutex_lock(&idescsi_ref_mutex); 117 mutex_lock(&idescsi_ref_mutex);
118 ide_device_put(scsi->drive);
113 scsi_host_put(scsi->host); 119 scsi_host_put(scsi->host);
114 mutex_unlock(&idescsi_ref_mutex); 120 mutex_unlock(&idescsi_ref_mutex);
115} 121}
@@ -201,15 +207,15 @@ static int idescsi_check_condition(ide_drive_t *drive,
201 207
202 /* stuff a sense request in front of our current request */ 208 /* stuff a sense request in front of our current request */
203 pc = kzalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); 209 pc = kzalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC);
204 rq = kmalloc(sizeof(struct request), GFP_ATOMIC); 210 rq = blk_get_request(drive->queue, READ, GFP_ATOMIC);
205 buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC); 211 buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC);
206 if (!pc || !rq || !buf) { 212 if (!pc || !rq || !buf) {
207 kfree(buf); 213 kfree(buf);
208 kfree(rq); 214 if (rq)
215 blk_put_request(rq);
209 kfree(pc); 216 kfree(pc);
210 return -ENOMEM; 217 return -ENOMEM;
211 } 218 }
212 blk_rq_init(NULL, rq);
213 rq->special = (char *) pc; 219 rq->special = (char *) pc;
214 pc->rq = rq; 220 pc->rq = rq;
215 pc->buf = buf; 221 pc->buf = buf;
@@ -226,6 +232,7 @@ static int idescsi_check_condition(ide_drive_t *drive,
226 ide_scsi_hex_dump(pc->c, 6); 232 ide_scsi_hex_dump(pc->c, 6);
227 } 233 }
228 rq->rq_disk = scsi->disk; 234 rq->rq_disk = scsi->disk;
235 rq->ref_count++;
229 memcpy(rq->cmd, pc->c, 12); 236 memcpy(rq->cmd, pc->c, 12);
230 ide_do_drive_cmd(drive, rq); 237 ide_do_drive_cmd(drive, rq);
231 return 0; 238 return 0;
@@ -272,7 +279,7 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
272 SCSI_SENSE_BUFFERSIZE); 279 SCSI_SENSE_BUFFERSIZE);
273 kfree(pc->buf); 280 kfree(pc->buf);
274 kfree(pc); 281 kfree(pc);
275 kfree(rq); 282 blk_put_request(rq);
276 pc = opc; 283 pc = opc;
277 rq = pc->rq; 284 rq = pc->rq;
278 pc->scsi_cmd->result = (CHECK_CONDITION << 1) | 285 pc->scsi_cmd->result = (CHECK_CONDITION << 1) |
@@ -303,7 +310,7 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs)
303 pc->done(pc->scsi_cmd); 310 pc->done(pc->scsi_cmd);
304 spin_unlock_irqrestore(host->host_lock, flags); 311 spin_unlock_irqrestore(host->host_lock, flags);
305 kfree(pc); 312 kfree(pc);
306 kfree(rq); 313 blk_put_request(rq);
307 scsi->pc = NULL; 314 scsi->pc = NULL;
308 return 0; 315 return 0;
309} 316}
@@ -577,6 +584,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
577 ide_drive_t *drive = scsi->drive; 584 ide_drive_t *drive = scsi->drive;
578 struct request *rq = NULL; 585 struct request *rq = NULL;
579 struct ide_atapi_pc *pc = NULL; 586 struct ide_atapi_pc *pc = NULL;
587 int write = cmd->sc_data_direction == DMA_TO_DEVICE;
580 588
581 if (!drive) { 589 if (!drive) {
582 scmd_printk (KERN_ERR, cmd, "drive not present\n"); 590 scmd_printk (KERN_ERR, cmd, "drive not present\n");
@@ -584,7 +592,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
584 } 592 }
585 scsi = drive_to_idescsi(drive); 593 scsi = drive_to_idescsi(drive);
586 pc = kmalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); 594 pc = kmalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC);
587 rq = kmalloc(sizeof(struct request), GFP_ATOMIC); 595 rq = blk_get_request(drive->queue, write, GFP_ATOMIC);
588 if (rq == NULL || pc == NULL) { 596 if (rq == NULL || pc == NULL) {
589 printk (KERN_ERR "ide-scsi: %s: out of memory\n", drive->name); 597 printk (KERN_ERR "ide-scsi: %s: out of memory\n", drive->name);
590 goto abort; 598 goto abort;
@@ -614,17 +622,18 @@ static int idescsi_queue (struct scsi_cmnd *cmd,
614 } 622 }
615 } 623 }
616 624
617 blk_rq_init(NULL, rq);
618 rq->special = (char *) pc; 625 rq->special = (char *) pc;
619 rq->cmd_type = REQ_TYPE_SPECIAL; 626 rq->cmd_type = REQ_TYPE_SPECIAL;
620 spin_unlock_irq(host->host_lock); 627 spin_unlock_irq(host->host_lock);
628 rq->ref_count++;
621 memcpy(rq->cmd, pc->c, 12); 629 memcpy(rq->cmd, pc->c, 12);
622 blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL); 630 blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL);
623 spin_lock_irq(host->host_lock); 631 spin_lock_irq(host->host_lock);
624 return 0; 632 return 0;
625abort: 633abort:
626 kfree (pc); 634 kfree (pc);
627 kfree (rq); 635 if (rq)
636 blk_put_request(rq);
628 cmd->result = DID_ERROR << 16; 637 cmd->result = DID_ERROR << 16;
629 done(cmd); 638 done(cmd);
630 return 0; 639 return 0;
@@ -672,7 +681,9 @@ static int idescsi_eh_abort (struct scsi_cmnd *cmd)
672 681
673 if (blk_sense_request(scsi->pc->rq)) 682 if (blk_sense_request(scsi->pc->rq))
674 kfree(scsi->pc->buf); 683 kfree(scsi->pc->buf);
675 kfree(scsi->pc->rq); 684 /* we need to call blk_put_request twice. */
685 blk_put_request(scsi->pc->rq);
686 blk_put_request(scsi->pc->rq);
676 kfree(scsi->pc); 687 kfree(scsi->pc);
677 scsi->pc = NULL; 688 scsi->pc = NULL;
678 689
@@ -724,7 +735,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd)
724 kfree(scsi->pc->buf); 735 kfree(scsi->pc->buf);
725 kfree(scsi->pc); 736 kfree(scsi->pc);
726 scsi->pc = NULL; 737 scsi->pc = NULL;
727 kfree(req); 738 blk_put_request(req);
728 739
729 /* now nuke the drive queue */ 740 /* now nuke the drive queue */
730 while ((req = elv_next_request(drive->queue))) { 741 while ((req = elv_next_request(drive->queue))) {
diff --git a/include/asm-alpha/ide.h b/include/asm-alpha/ide.h
deleted file mode 100644
index f44129abc02c..000000000000
--- a/include/asm-alpha/ide.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/*
2 * linux/include/asm-alpha/ide.h
3 *
4 * Copyright (C) 1994-1996 Linus Torvalds & authors
5 */
6
7/*
8 * This file contains the alpha architecture specific IDE code.
9 */
10
11#ifndef __ASMalpha_IDE_H
12#define __ASMalpha_IDE_H
13
14#ifdef __KERNEL__
15
16static inline int ide_default_irq(unsigned long base)
17{
18 switch (base) {
19 case 0x1f0: return 14;
20 case 0x170: return 15;
21 case 0x1e8: return 11;
22 case 0x168: return 10;
23 default:
24 return 0;
25 }
26}
27
28static inline unsigned long ide_default_io_base(int index)
29{
30 switch (index) {
31 case 0: return 0x1f0;
32 case 1: return 0x170;
33 case 2: return 0x1e8;
34 case 3: return 0x168;
35 default:
36 return 0;
37 }
38}
39
40#include <asm-generic/ide_iops.h>
41
42#endif /* __KERNEL__ */
43
44#endif /* __ASMalpha_IDE_H */
diff --git a/include/asm-arm/ide.h b/include/asm-arm/ide.h
index 88f4d231ce4f..a48019f99d08 100644
--- a/include/asm-arm/ide.h
+++ b/include/asm-arm/ide.h
@@ -13,10 +13,6 @@
13 13
14#ifdef __KERNEL__ 14#ifdef __KERNEL__
15 15
16#ifndef MAX_HWIFS
17#define MAX_HWIFS 4
18#endif
19
20#define __ide_mm_insw(port,addr,len) readsw(port,addr,len) 16#define __ide_mm_insw(port,addr,len) readsw(port,addr,len)
21#define __ide_mm_insl(port,addr,len) readsl(port,addr,len) 17#define __ide_mm_insl(port,addr,len) readsl(port,addr,len)
22#define __ide_mm_outsw(port,addr,len) writesw(port,addr,len) 18#define __ide_mm_outsw(port,addr,len) writesw(port,addr,len)
diff --git a/include/asm-blackfin/ide.h b/include/asm-blackfin/ide.h
deleted file mode 100644
index 5b88de115bf4..000000000000
--- a/include/asm-blackfin/ide.h
+++ /dev/null
@@ -1,27 +0,0 @@
1/****************************************************************************/
2
3/*
4 * linux/include/asm-blackfin/ide.h
5 *
6 * Copyright (C) 1994-1996 Linus Torvalds & authors
7 * Copyright (C) 2001 Lineo Inc., davidm@snapgear.com
8 * Copyright (C) 2002 Greg Ungerer (gerg@snapgear.com)
9 * Copyright (C) 2002 Yoshinori Sato (ysato@users.sourceforge.jp)
10 * Copyright (C) 2005 Hennerich Michael (hennerich@blackfin.uclinux.org)
11 */
12
13/****************************************************************************/
14#ifndef _BLACKFIN_IDE_H
15#define _BLACKFIN_IDE_H
16/****************************************************************************/
17#ifdef __KERNEL__
18/****************************************************************************/
19
20#define MAX_HWIFS 1
21
22#include <asm-generic/ide_iops.h>
23
24/****************************************************************************/
25#endif /* __KERNEL__ */
26#endif /* _BLACKFIN_IDE_H */
27/****************************************************************************/
diff --git a/include/asm-cris/arch-v10/ide.h b/include/asm-cris/arch-v10/ide.h
deleted file mode 100644
index 5366e6239328..000000000000
--- a/include/asm-cris/arch-v10/ide.h
+++ /dev/null
@@ -1,91 +0,0 @@
1/*
2 * linux/include/asm-cris/ide.h
3 *
4 * Copyright (C) 2000, 2001, 2002 Axis Communications AB
5 *
6 * Authors: Bjorn Wesen
7 *
8 */
9
10/*
11 * This file contains the ETRAX 100LX specific IDE code.
12 */
13
14#ifndef __ASMCRIS_IDE_H
15#define __ASMCRIS_IDE_H
16
17#ifdef __KERNEL__
18
19#include <asm/arch/svinto.h>
20#include <asm/io.h>
21#include <asm-generic/ide_iops.h>
22
23
24/* ETRAX 100 can support 4 IDE busses on the same pins (serialized) */
25
26#define MAX_HWIFS 4
27
28static inline int ide_default_irq(unsigned long base)
29{
30 /* all IDE busses share the same IRQ, number 4.
31 * this has the side-effect that ide-probe.c will cluster our 4 interfaces
32 * together in a hwgroup, and will serialize accesses. this is good, because
33 * we can't access more than one interface at the same time on ETRAX100.
34 */
35 return 4;
36}
37
38static inline unsigned long ide_default_io_base(int index)
39{
40 /* we have no real I/O base address per interface, since all go through the
41 * same register. but in a bitfield in that register, we have the i/f number.
42 * so we can use the io_base to remember that bitfield.
43 */
44 static const unsigned long io_bases[MAX_HWIFS] = {
45 IO_FIELD(R_ATA_CTRL_DATA, sel, 0),
46 IO_FIELD(R_ATA_CTRL_DATA, sel, 1),
47 IO_FIELD(R_ATA_CTRL_DATA, sel, 2),
48 IO_FIELD(R_ATA_CTRL_DATA, sel, 3)
49 };
50 return io_bases[index];
51}
52
53/* this is called once for each interface, to setup the port addresses. data_port is the result
54 * of the ide_default_io_base call above. ctrl_port will be 0, but that is don't care for us.
55 */
56
57static inline void ide_init_hwif_ports(hw_regs_t *hw, unsigned long data_port, unsigned long ctrl_port, int *irq)
58{
59 int i;
60
61 /* fill in ports for ATA addresses 0 to 7 */
62 for (i = 0; i <= 7; i++) {
63 hw->io_ports_array[i] = data_port |
64 IO_FIELD(R_ATA_CTRL_DATA, addr, i) |
65 IO_STATE(R_ATA_CTRL_DATA, cs0, active);
66 }
67
68 /* the IDE control register is at ATA address 6, with CS1 active instead of CS0 */
69 hw->io_ports.ctl_addr = data_port |
70 IO_FIELD(R_ATA_CTRL_DATA, addr, 6) |
71 IO_STATE(R_ATA_CTRL_DATA, cs1, active);
72
73 /* whats this for ? */
74 hw->io_ports.irq_addr = 0;
75}
76
77static inline void ide_init_default_hwifs(void)
78{
79 hw_regs_t hw;
80 int index;
81
82 for(index = 0; index < MAX_HWIFS; index++) {
83 ide_init_hwif_ports(&hw, ide_default_io_base(index), 0, NULL);
84 hw.irq = ide_default_irq(ide_default_io_base(index));
85 ide_register_hw(&hw, NULL);
86 }
87}
88
89#endif /* __KERNEL__ */
90
91#endif /* __ASMCRIS_IDE_H */
diff --git a/include/asm-cris/arch-v32/ide.h b/include/asm-cris/arch-v32/ide.h
deleted file mode 100644
index fb9c3627a5b4..000000000000
--- a/include/asm-cris/arch-v32/ide.h
+++ /dev/null
@@ -1,56 +0,0 @@
1/*
2 * linux/include/asm-cris/ide.h
3 *
4 * Copyright (C) 2000-2004 Axis Communications AB
5 *
6 * Authors: Bjorn Wesen, Mikael Starvik
7 *
8 */
9
10/*
11 * This file contains the ETRAX FS specific IDE code.
12 */
13
14#ifndef __ASMCRIS_IDE_H
15#define __ASMCRIS_IDE_H
16
17#ifdef __KERNEL__
18
19#include <asm/arch/hwregs/intr_vect.h>
20#include <asm/arch/hwregs/ata_defs.h>
21#include <asm/io.h>
22#include <asm-generic/ide_iops.h>
23
24
25/* ETRAX FS can support 4 IDE busses on the same pins (serialized) */
26
27#define MAX_HWIFS 4
28
29static inline int ide_default_irq(unsigned long base)
30{
31 /* all IDE busses share the same IRQ,
32 * this has the side-effect that ide-probe.c will cluster our 4 interfaces
33 * together in a hwgroup, and will serialize accesses. this is good, because
34 * we can't access more than one interface at the same time on ETRAX100.
35 */
36 return ATA_INTR_VECT;
37}
38
39static inline unsigned long ide_default_io_base(int index)
40{
41 reg_ata_rw_ctrl2 ctrl2 = {.sel = index};
42 /* we have no real I/O base address per interface, since all go through the
43 * same register. but in a bitfield in that register, we have the i/f number.
44 * so we can use the io_base to remember that bitfield.
45 */
46 ctrl2.sel = index;
47
48 return REG_TYPE_CONV(unsigned long, reg_ata_rw_ctrl2, ctrl2);
49}
50
51#define IDE_ARCH_ACK_INTR
52#define ide_ack_intr(hwif) ((hwif)->ack_intr(hwif))
53
54#endif /* __KERNEL__ */
55
56#endif /* __ASMCRIS_IDE_H */
diff --git a/include/asm-cris/ide.h b/include/asm-cris/ide.h
deleted file mode 100644
index a894f66665f8..000000000000
--- a/include/asm-cris/ide.h
+++ /dev/null
@@ -1 +0,0 @@
1#include <asm/arch/ide.h>
diff --git a/include/asm-frv/ide.h b/include/asm-frv/ide.h
index 8c9a540d4344..7ebcc56a2229 100644
--- a/include/asm-frv/ide.h
+++ b/include/asm-frv/ide.h
@@ -18,10 +18,6 @@
18#include <asm/io.h> 18#include <asm/io.h>
19#include <asm/irq.h> 19#include <asm/irq.h>
20 20
21#ifndef MAX_HWIFS
22#define MAX_HWIFS 8
23#endif
24
25/****************************************************************************/ 21/****************************************************************************/
26/* 22/*
27 * some bits needed for parts of the IDE subsystem to compile 23 * some bits needed for parts of the IDE subsystem to compile
diff --git a/include/asm-h8300/ide.h b/include/asm-h8300/ide.h
deleted file mode 100644
index f8535ce7476e..000000000000
--- a/include/asm-h8300/ide.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/****************************************************************************/
2
3/*
4 * linux/include/asm-h8300/ide.h
5 *
6 * Copyright (C) 1994-1996 Linus Torvalds & authors
7 * Copyright (C) 2001 Lineo Inc., davidm@snapgear.com
8 * Copyright (C) 2002 Greg Ungerer (gerg@snapgear.com)
9 * Copyright (C) 2002 Yoshinori Sato (ysato@users.sourceforge.jp)
10 */
11
12/****************************************************************************/
13#ifndef _H8300_IDE_H
14#define _H8300_IDE_H
15/****************************************************************************/
16#ifdef __KERNEL__
17/****************************************************************************/
18
19#define MAX_HWIFS 1
20
21#include <asm-generic/ide_iops.h>
22
23/****************************************************************************/
24#endif /* __KERNEL__ */
25#endif /* _H8300_IDE_H */
26/****************************************************************************/
diff --git a/include/asm-ia64/ide.h b/include/asm-ia64/ide.h
deleted file mode 100644
index 8fa3f8cd067a..000000000000
--- a/include/asm-ia64/ide.h
+++ /dev/null
@@ -1,51 +0,0 @@
1/*
2 * linux/include/asm-ia64/ide.h
3 *
4 * Copyright (C) 1994-1996 Linus Torvalds & authors
5 */
6
7/*
8 * This file contains the ia64 architecture specific IDE code.
9 */
10
11#ifndef __ASM_IA64_IDE_H
12#define __ASM_IA64_IDE_H
13
14#ifdef __KERNEL__
15
16
17#include <linux/irq.h>
18
19static inline int ide_default_irq(unsigned long base)
20{
21 switch (base) {
22 case 0x1f0: return isa_irq_to_vector(14);
23 case 0x170: return isa_irq_to_vector(15);
24 case 0x1e8: return isa_irq_to_vector(11);
25 case 0x168: return isa_irq_to_vector(10);
26 case 0x1e0: return isa_irq_to_vector(8);
27 case 0x160: return isa_irq_to_vector(12);
28 default:
29 return 0;
30 }
31}
32
33static inline unsigned long ide_default_io_base(int index)
34{
35 switch (index) {
36 case 0: return 0x1f0;
37 case 1: return 0x170;
38 case 2: return 0x1e8;
39 case 3: return 0x168;
40 case 4: return 0x1e0;
41 case 5: return 0x160;
42 default:
43 return 0;
44 }
45}
46
47#include <asm-generic/ide_iops.h>
48
49#endif /* __KERNEL__ */
50
51#endif /* __ASM_IA64_IDE_H */
diff --git a/include/asm-m32r/ide.h b/include/asm-m32r/ide.h
deleted file mode 100644
index 1e7f6474d130..000000000000
--- a/include/asm-m32r/ide.h
+++ /dev/null
@@ -1,70 +0,0 @@
1#ifndef _ASM_M32R_IDE_H
2#define _ASM_M32R_IDE_H
3
4/*
5 * linux/include/asm-m32r/ide.h
6 *
7 * Copyright (C) 1994-1996 Linus Torvalds & authors
8 */
9
10/*
11 * This file contains the i386 architecture specific IDE code.
12 */
13
14#ifdef __KERNEL__
15
16#include <asm/m32r.h>
17
18#ifndef MAX_HWIFS
19# ifdef CONFIG_BLK_DEV_IDEPCI
20#define MAX_HWIFS 10
21# else
22#define MAX_HWIFS 2
23# endif
24#endif
25
26static __inline__ int ide_default_irq(unsigned long base)
27{
28 switch (base) {
29#if defined(CONFIG_PLAT_M32700UT) || defined(CONFIG_PLAT_MAPPI2) \
30 || defined(CONFIG_PLAT_OPSPUT)
31 case 0x1f0: return PLD_IRQ_CFIREQ;
32 default:
33 return 0;
34#elif defined(CONFIG_PLAT_MAPPI3)
35 case 0x1f0: return PLD_IRQ_CFIREQ;
36 case 0x170: return PLD_IRQ_IDEIREQ;
37 default:
38 return 0;
39#else
40 case 0x1f0: return 14;
41 case 0x170: return 15;
42 case 0x1e8: return 11;
43 case 0x168: return 10;
44 case 0x1e0: return 8;
45 case 0x160: return 12;
46 default:
47 return 0;
48#endif
49 }
50}
51
52static __inline__ unsigned long ide_default_io_base(int index)
53{
54 switch (index) {
55 case 0: return 0x1f0;
56 case 1: return 0x170;
57 case 2: return 0x1e8;
58 case 3: return 0x168;
59 case 4: return 0x1e0;
60 case 5: return 0x160;
61 default:
62 return 0;
63 }
64}
65
66#include <asm-generic/ide_iops.h>
67
68#endif /* __KERNEL__ */
69
70#endif /* _ASM_M32R_IDE_H */
diff --git a/include/asm-m68k/ide.h b/include/asm-m68k/ide.h
index 909c6dfd3851..1daf6cbdd9f0 100644
--- a/include/asm-m68k/ide.h
+++ b/include/asm-m68k/ide.h
@@ -45,10 +45,6 @@
45#include <asm/macints.h> 45#include <asm/macints.h>
46#endif 46#endif
47 47
48#ifndef MAX_HWIFS
49#define MAX_HWIFS 4 /* same as the other archs */
50#endif
51
52/* 48/*
53 * Get rid of defs from io.h - ide has its private and conflicting versions 49 * Get rid of defs from io.h - ide has its private and conflicting versions
54 * Since so far no single m68k platform uses ISA/PCI I/O space for IDE, we 50 * Since so far no single m68k platform uses ISA/PCI I/O space for IDE, we
diff --git a/include/asm-mips/mach-generic/ide.h b/include/asm-mips/mach-generic/ide.h
index 0f6c251f5fec..73008f7bdc93 100644
--- a/include/asm-mips/mach-generic/ide.h
+++ b/include/asm-mips/mach-generic/ide.h
@@ -19,14 +19,6 @@
19#include <linux/stddef.h> 19#include <linux/stddef.h>
20#include <asm/processor.h> 20#include <asm/processor.h>
21 21
22#ifndef MAX_HWIFS
23# ifdef CONFIG_BLK_DEV_IDEPCI
24#define MAX_HWIFS 10
25# else
26#define MAX_HWIFS 6
27# endif
28#endif
29
30static __inline__ int ide_probe_legacy(void) 22static __inline__ int ide_probe_legacy(void)
31{ 23{
32#ifdef CONFIG_PCI 24#ifdef CONFIG_PCI
@@ -56,46 +48,6 @@ found:
56#endif 48#endif
57} 49}
58 50
59static __inline__ int ide_default_irq(unsigned long base)
60{
61 switch (base) {
62 case 0x1f0: return 14;
63 case 0x170: return 15;
64 case 0x1e8: return 11;
65 case 0x168: return 10;
66 case 0x1e0: return 8;
67 case 0x160: return 12;
68 default:
69 return 0;
70 }
71}
72
73static __inline__ unsigned long ide_default_io_base(int index)
74{
75 if (!ide_probe_legacy())
76 return 0;
77 /*
78 * If PCI is present then it is not safe to poke around
79 * the other legacy IDE ports. Only 0x1f0 and 0x170 are
80 * defined compatibility mode ports for PCI. A user can
81 * override this using ide= but we must default safe.
82 */
83 if (no_pci_devices()) {
84 switch (index) {
85 case 2: return 0x1e8;
86 case 3: return 0x168;
87 case 4: return 0x1e0;
88 case 5: return 0x160;
89 }
90 }
91 switch (index) {
92 case 0: return 0x1f0;
93 case 1: return 0x170;
94 default:
95 return 0;
96 }
97}
98
99/* MIPS port and memory-mapped I/O string operations. */ 51/* MIPS port and memory-mapped I/O string operations. */
100static inline void __ide_flush_prologue(void) 52static inline void __ide_flush_prologue(void)
101{ 53{
diff --git a/include/asm-mn10300/ide.h b/include/asm-mn10300/ide.h
index dc235121ec42..6adcdd92e83d 100644
--- a/include/asm-mn10300/ide.h
+++ b/include/asm-mn10300/ide.h
@@ -23,10 +23,6 @@
23#undef SUPPORT_VLB_SYNC 23#undef SUPPORT_VLB_SYNC
24#define SUPPORT_VLB_SYNC 0 24#define SUPPORT_VLB_SYNC 0
25 25
26#ifndef MAX_HWIFS
27#define MAX_HWIFS 8
28#endif
29
30/* 26/*
31 * some bits needed for parts of the IDE subsystem to compile 27 * some bits needed for parts of the IDE subsystem to compile
32 */ 28 */
diff --git a/include/asm-parisc/ide.h b/include/asm-parisc/ide.h
index db0c94410095..c246ef75017d 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#ifndef MAX_HWIFS
17#define MAX_HWIFS 2
18#endif
19
20#define ide_request_irq(irq,hand,flg,dev,id) request_irq((irq),(hand),(flg),(dev),(id)) 16#define ide_request_irq(irq,hand,flg,dev,id) request_irq((irq),(hand),(flg),(dev),(id))
21#define ide_free_irq(irq,dev_id) free_irq((irq), (dev_id)) 17#define ide_free_irq(irq,dev_id) free_irq((irq), (dev_id))
22#define ide_request_region(from,extent,name) request_region((from), (extent), (name)) 18#define ide_request_region(from,extent,name) request_region((from), (extent), (name))
diff --git a/include/asm-powerpc/ide.h b/include/asm-powerpc/ide.h
index 3d90bf7d3d73..1aaf27be8741 100644
--- a/include/asm-powerpc/ide.h
+++ b/include/asm-powerpc/ide.h
@@ -14,14 +14,6 @@
14#endif 14#endif
15#include <asm/io.h> 15#include <asm/io.h>
16 16
17#ifndef MAX_HWIFS
18#ifdef __powerpc64__
19#define MAX_HWIFS 10
20#else
21#define MAX_HWIFS 8
22#endif
23#endif
24
25#define __ide_mm_insw(p, a, c) readsw((void __iomem *)(p), (a), (c)) 17#define __ide_mm_insw(p, a, c) readsw((void __iomem *)(p), (a), (c))
26#define __ide_mm_insl(p, a, c) readsl((void __iomem *)(p), (a), (c)) 18#define __ide_mm_insl(p, a, c) readsl((void __iomem *)(p), (a), (c))
27#define __ide_mm_outsw(p, a, c) writesw((void __iomem *)(p), (a), (c)) 19#define __ide_mm_outsw(p, a, c) writesw((void __iomem *)(p), (a), (c))
@@ -40,16 +32,6 @@ static __inline__ int ide_default_irq(unsigned long base)
40 case 0x170: return 15; 32 case 0x170: return 15;
41 } 33 }
42#endif 34#endif
43#ifdef CONFIG_PPC_PREP
44 switch (base) {
45 case 0x1f0: return 13;
46 case 0x170: return 13;
47 case 0x1e8: return 11;
48 case 0x168: return 10;
49 case 0xfff0: return 14; /* MCP(N)750 ide0 */
50 case 0xffe0: return 15; /* MCP(N)750 ide1 */
51 }
52#endif
53 return 0; 35 return 0;
54} 36}
55 37
@@ -62,14 +44,6 @@ static __inline__ unsigned long ide_default_io_base(int index)
62 case 1: return 0x170; 44 case 1: return 0x170;
63 } 45 }
64#endif 46#endif
65#ifdef CONFIG_PPC_PREP
66 switch (index) {
67 case 0: return 0x1f0;
68 case 1: return 0x170;
69 case 2: return 0x1e8;
70 case 3: return 0x168;
71 }
72#endif
73 return 0; 47 return 0;
74} 48}
75 49
diff --git a/include/asm-sh/ide.h b/include/asm-sh/ide.h
deleted file mode 100644
index 58e0bdd52be4..000000000000
--- a/include/asm-sh/ide.h
+++ /dev/null
@@ -1,21 +0,0 @@
1/*
2 * linux/include/asm-sh/ide.h
3 *
4 * Copyright (C) 1994-1996 Linus Torvalds & authors
5 */
6
7/*
8 * This file contains the i386 architecture specific IDE code.
9 * In future, SuperH code.
10 */
11
12#ifndef __ASM_SH_IDE_H
13#define __ASM_SH_IDE_H
14
15#ifdef __KERNEL__
16
17#include <asm-generic/ide_iops.h>
18
19#endif /* __KERNEL__ */
20
21#endif /* __ASM_SH_IDE_H */
diff --git a/include/asm-sparc/ide.h b/include/asm-sparc/ide.h
index 879fcec72dc1..b7af3d658239 100644
--- a/include/asm-sparc/ide.h
+++ b/include/asm-sparc/ide.h
@@ -21,9 +21,6 @@
21#include <asm/psr.h> 21#include <asm/psr.h>
22#endif 22#endif
23 23
24#undef MAX_HWIFS
25#define MAX_HWIFS 2
26
27#define __ide_insl(data_reg, buffer, wcount) \ 24#define __ide_insl(data_reg, buffer, wcount) \
28 __ide_insw(data_reg, buffer, (wcount)<<1) 25 __ide_insw(data_reg, buffer, (wcount)<<1)
29#define __ide_outsl(data_reg, buffer, wcount) \ 26#define __ide_outsl(data_reg, buffer, wcount) \
diff --git a/include/asm-x86/ide.h b/include/asm-x86/ide.h
deleted file mode 100644
index cf9c98e5bdb5..000000000000
--- a/include/asm-x86/ide.h
+++ /dev/null
@@ -1,65 +0,0 @@
1/*
2 * Copyright (C) 1994-1996 Linus Torvalds & authors
3 */
4
5/*
6 * This file contains the i386 architecture specific IDE code.
7 */
8
9#ifndef __ASMi386_IDE_H
10#define __ASMi386_IDE_H
11
12#ifdef __KERNEL__
13
14
15#ifndef MAX_HWIFS
16# ifdef CONFIG_BLK_DEV_IDEPCI
17#define MAX_HWIFS 10
18# else
19#define MAX_HWIFS 6
20# endif
21#endif
22
23static __inline__ int ide_default_irq(unsigned long base)
24{
25 switch (base) {
26 case 0x1f0: return 14;
27 case 0x170: return 15;
28 case 0x1e8: return 11;
29 case 0x168: return 10;
30 case 0x1e0: return 8;
31 case 0x160: return 12;
32 default:
33 return 0;
34 }
35}
36
37static __inline__ unsigned long ide_default_io_base(int index)
38{
39 /*
40 * If PCI is present then it is not safe to poke around
41 * the other legacy IDE ports. Only 0x1f0 and 0x170 are
42 * defined compatibility mode ports for PCI. A user can
43 * override this using ide= but we must default safe.
44 */
45 if (no_pci_devices()) {
46 switch(index) {
47 case 2: return 0x1e8;
48 case 3: return 0x168;
49 case 4: return 0x1e0;
50 case 5: return 0x160;
51 }
52 }
53 switch (index) {
54 case 0: return 0x1f0;
55 case 1: return 0x170;
56 default:
57 return 0;
58 }
59}
60
61#include <asm-generic/ide_iops.h>
62
63#endif /* __KERNEL__ */
64
65#endif /* __ASMi386_IDE_H */
diff --git a/include/asm-xtensa/ide.h b/include/asm-xtensa/ide.h
deleted file mode 100644
index 6b912742a42d..000000000000
--- a/include/asm-xtensa/ide.h
+++ /dev/null
@@ -1,35 +0,0 @@
1/*
2 * include/asm-xtensa/ide.h
3 *
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
6 * for more details.
7 *
8 * Copyright (C) 1994 - 1996 Linus Torvalds & authors
9 * Copyright (C) 2001 - 2005 Tensilica Inc.
10 */
11
12#ifndef _XTENSA_IDE_H
13#define _XTENSA_IDE_H
14
15#ifdef __KERNEL__
16
17
18#ifndef MAX_HWIFS
19# define MAX_HWIFS 1
20#endif
21
22static __inline__ int ide_default_irq(unsigned long base)
23{
24 /* Unsupported! */
25 return 0;
26}
27
28static __inline__ unsigned long ide_default_io_base(int index)
29{
30 /* Unsupported! */
31 return 0;
32}
33
34#endif /* __KERNEL__ */
35#endif /* _XTENSA_IDE_H */
diff --git a/include/linux/ide.h b/include/linux/ide.h
index d67ccca2b964..b846bc44a27e 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -211,7 +211,21 @@ static inline int __ide_default_irq(unsigned long base)
211 return 0; 211 return 0;
212} 212}
213 213
214#if defined(CONFIG_ARM) || defined(CONFIG_FRV) || defined(CONFIG_M68K) || \
215 defined(CONFIG_MIPS) || defined(CONFIG_MN10300) || defined(CONFIG_PARISC) \
216 || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || defined(CONFIG_SPARC64)
214#include <asm/ide.h> 217#include <asm/ide.h>
218#else
219#include <asm-generic/ide_iops.h>
220#endif
221
222#ifndef MAX_HWIFS
223#if defined(CONFIG_BLACKFIN) || defined(CONFIG_H8300) || defined(CONFIG_XTENSA)
224# define MAX_HWIFS 1
225#else
226# define MAX_HWIFS 10
227#endif
228#endif
215 229
216#if !defined(MAX_HWIFS) || defined(CONFIG_EMBEDDED) 230#if !defined(MAX_HWIFS) || defined(CONFIG_EMBEDDED)
217#undef MAX_HWIFS 231#undef MAX_HWIFS
@@ -532,12 +546,16 @@ struct ide_dma_ops {
532 void (*dma_timeout)(struct ide_drive_s *); 546 void (*dma_timeout)(struct ide_drive_s *);
533}; 547};
534 548
549struct ide_host;
550
535typedef struct hwif_s { 551typedef struct hwif_s {
536 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ 552 struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
537 struct hwif_s *mate; /* other hwif from same PCI chip */ 553 struct hwif_s *mate; /* other hwif from same PCI chip */
538 struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */ 554 struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */
539 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 555 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
540 556
557 struct ide_host *host;
558
541 char name[6]; /* name of interface, eg. "ide0" */ 559 char name[6]; /* name of interface, eg. "ide0" */
542 560
543 struct ide_io_ports io_ports; 561 struct ide_io_ports io_ports;
@@ -626,6 +644,9 @@ typedef struct hwif_s {
626struct ide_host { 644struct ide_host {
627 ide_hwif_t *ports[MAX_HWIFS]; 645 ide_hwif_t *ports[MAX_HWIFS];
628 unsigned int n_ports; 646 unsigned int n_ports;
647 struct device *dev[2];
648 unsigned long host_flags;
649 void *host_priv;
629}; 650};
630 651
631/* 652/*
@@ -874,6 +895,9 @@ struct ide_driver_s {
874 895
875#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver) 896#define to_ide_driver(drv) container_of(drv, ide_driver_t, gen_driver)
876 897
898int ide_device_get(ide_drive_t *);
899void ide_device_put(ide_drive_t *);
900
877int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long); 901int generic_ide_ioctl(ide_drive_t *, struct file *, struct block_device *, unsigned, unsigned long);
878 902
879extern int ide_vlb_clk; 903extern int ide_vlb_clk;
@@ -1182,7 +1206,7 @@ enum {
1182 1206
1183struct ide_port_info { 1207struct ide_port_info {
1184 char *name; 1208 char *name;
1185 unsigned int (*init_chipset)(struct pci_dev *, const char *); 1209 unsigned int (*init_chipset)(struct pci_dev *);
1186 void (*init_iops)(ide_hwif_t *); 1210 void (*init_iops)(ide_hwif_t *);
1187 void (*init_hwif)(ide_hwif_t *); 1211 void (*init_hwif)(ide_hwif_t *);
1188 int (*init_dma)(ide_hwif_t *, 1212 int (*init_dma)(ide_hwif_t *,
@@ -1201,8 +1225,10 @@ struct ide_port_info {
1201 u8 udma_mask; 1225 u8 udma_mask;
1202}; 1226};
1203 1227
1204int ide_setup_pci_device(struct pci_dev *, const struct ide_port_info *); 1228int ide_pci_init_one(struct pci_dev *, const struct ide_port_info *, void *);
1205int ide_setup_pci_devices(struct pci_dev *, struct pci_dev *, const struct ide_port_info *); 1229int ide_pci_init_two(struct pci_dev *, struct pci_dev *,
1230 const struct ide_port_info *, void *);
1231void ide_pci_remove(struct pci_dev *);
1206 1232
1207void ide_map_sg(ide_drive_t *, struct request *); 1233void ide_map_sg(ide_drive_t *, struct request *);
1208void ide_init_sg_cmd(ide_drive_t *, struct request *); 1234void ide_init_sg_cmd(ide_drive_t *, struct request *);