aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-probe.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-probe.c')
-rw-r--r--drivers/ide/ide-probe.c252
1 files changed, 119 insertions, 133 deletions
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 70aa86c8807e..06575a12b635 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -50,59 +50,54 @@
50 50
51static void generic_id(ide_drive_t *drive) 51static void generic_id(ide_drive_t *drive)
52{ 52{
53 drive->id->cyls = drive->cyl; 53 u16 *id = drive->id;
54 drive->id->heads = drive->head; 54
55 drive->id->sectors = drive->sect; 55 id[ATA_ID_CUR_CYLS] = id[ATA_ID_CYLS] = drive->cyl;
56 drive->id->cur_cyls = drive->cyl; 56 id[ATA_ID_CUR_HEADS] = id[ATA_ID_HEADS] = drive->head;
57 drive->id->cur_heads = drive->head; 57 id[ATA_ID_CUR_SECTORS] = id[ATA_ID_SECTORS] = drive->sect;
58 drive->id->cur_sectors = drive->sect;
59} 58}
60 59
61static void ide_disk_init_chs(ide_drive_t *drive) 60static void ide_disk_init_chs(ide_drive_t *drive)
62{ 61{
63 struct hd_driveid *id = drive->id; 62 u16 *id = drive->id;
64 63
65 /* Extract geometry if we did not already have one for the drive */ 64 /* Extract geometry if we did not already have one for the drive */
66 if (!drive->cyl || !drive->head || !drive->sect) { 65 if (!drive->cyl || !drive->head || !drive->sect) {
67 drive->cyl = drive->bios_cyl = id->cyls; 66 drive->cyl = drive->bios_cyl = id[ATA_ID_CYLS];
68 drive->head = drive->bios_head = id->heads; 67 drive->head = drive->bios_head = id[ATA_ID_HEADS];
69 drive->sect = drive->bios_sect = id->sectors; 68 drive->sect = drive->bios_sect = id[ATA_ID_SECTORS];
70 } 69 }
71 70
72 /* Handle logical geometry translation by the drive */ 71 /* Handle logical geometry translation by the drive */
73 if ((id->field_valid & 1) && id->cur_cyls && 72 if (ata_id_current_chs_valid(id)) {
74 id->cur_heads && (id->cur_heads <= 16) && id->cur_sectors) { 73 drive->cyl = id[ATA_ID_CUR_CYLS];
75 drive->cyl = id->cur_cyls; 74 drive->head = id[ATA_ID_CUR_HEADS];
76 drive->head = id->cur_heads; 75 drive->sect = id[ATA_ID_CUR_SECTORS];
77 drive->sect = id->cur_sectors;
78 } 76 }
79 77
80 /* Use physical geometry if what we have still makes no sense */ 78 /* Use physical geometry if what we have still makes no sense */
81 if (drive->head > 16 && id->heads && id->heads <= 16) { 79 if (drive->head > 16 && id[ATA_ID_HEADS] && id[ATA_ID_HEADS] <= 16) {
82 drive->cyl = id->cyls; 80 drive->cyl = id[ATA_ID_CYLS];
83 drive->head = id->heads; 81 drive->head = id[ATA_ID_HEADS];
84 drive->sect = id->sectors; 82 drive->sect = id[ATA_ID_SECTORS];
85 } 83 }
86} 84}
87 85
88static void ide_disk_init_mult_count(ide_drive_t *drive) 86static void ide_disk_init_mult_count(ide_drive_t *drive)
89{ 87{
90 struct hd_driveid *id = drive->id; 88 u16 *id = drive->id;
91 89 u8 max_multsect = id[ATA_ID_MAX_MULTSECT] & 0xff;
92 drive->mult_count = 0; 90
93 if (id->max_multsect) { 91 if (max_multsect) {
94#ifdef CONFIG_IDEDISK_MULTI_MODE 92 if ((max_multsect / 2) > 1)
95 id->multsect = ((id->max_multsect/2) > 1) ? id->max_multsect : 0; 93 id[ATA_ID_MULTSECT] = max_multsect | 0x100;
96 id->multsect_valid = id->multsect ? 1 : 0; 94 else
97 drive->mult_req = id->multsect_valid ? id->max_multsect : 0; 95 id[ATA_ID_MULTSECT] &= ~0x1ff;
98 drive->special.b.set_multmode = drive->mult_req ? 1 : 0; 96
99#else /* original, pre IDE-NFG, per request of AC */ 97 drive->mult_req = id[ATA_ID_MULTSECT] & 0xff;
100 drive->mult_req = 0; 98
101 if (drive->mult_req > id->max_multsect) 99 if (drive->mult_req)
102 drive->mult_req = id->max_multsect;
103 if (drive->mult_req || ((id->multsect_valid & 1) && id->multsect))
104 drive->special.b.set_multmode = 1; 100 drive->special.b.set_multmode = 1;
105#endif
106 } 101 }
107} 102}
108 103
@@ -119,10 +114,10 @@ static void ide_disk_init_mult_count(ide_drive_t *drive)
119static inline void do_identify (ide_drive_t *drive, u8 cmd) 114static inline void do_identify (ide_drive_t *drive, u8 cmd)
120{ 115{
121 ide_hwif_t *hwif = HWIF(drive); 116 ide_hwif_t *hwif = HWIF(drive);
122 int bswap = 1; 117 u16 *id = drive->id;
123 struct hd_driveid *id; 118 char *m = (char *)&id[ATA_ID_PROD];
119 int bswap = 1, is_cfa;
124 120
125 id = drive->id;
126 /* read 512 bytes of id info */ 121 /* read 512 bytes of id info */
127 hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); 122 hwif->tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
128 123
@@ -135,27 +130,28 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
135 ide_fix_driveid(id); 130 ide_fix_driveid(id);
136 131
137 /* 132 /*
138 * WIN_IDENTIFY returns little-endian info, 133 * ATA_CMD_ID_ATA returns little-endian info,
139 * WIN_PIDENTIFY *usually* returns little-endian info. 134 * ATA_CMD_ID_ATAPI *usually* returns little-endian info.
140 */ 135 */
141 if (cmd == WIN_PIDENTIFY) { 136 if (cmd == ATA_CMD_ID_ATAPI) {
142 if ((id->model[0] == 'N' && id->model[1] == 'E') /* NEC */ 137 if ((m[0] == 'N' && m[1] == 'E') || /* NEC */
143 || (id->model[0] == 'F' && id->model[1] == 'X') /* Mitsumi */ 138 (m[0] == 'F' && m[1] == 'X') || /* Mitsumi */
144 || (id->model[0] == 'P' && id->model[1] == 'i'))/* Pioneer */ 139 (m[0] == 'P' && m[1] == 'i')) /* Pioneer */
145 /* Vertos drives may still be weird */ 140 /* Vertos drives may still be weird */
146 bswap ^= 1; 141 bswap ^= 1;
147 } 142 }
148 ide_fixstring(id->model, sizeof(id->model), bswap); 143
149 ide_fixstring(id->fw_rev, sizeof(id->fw_rev), bswap); 144 ide_fixstring(m, ATA_ID_PROD_LEN, bswap);
150 ide_fixstring(id->serial_no, sizeof(id->serial_no), bswap); 145 ide_fixstring((char *)&id[ATA_ID_FW_REV], ATA_ID_FW_REV_LEN, bswap);
146 ide_fixstring((char *)&id[ATA_ID_SERNO], ATA_ID_SERNO_LEN, bswap);
151 147
152 /* we depend on this a lot! */ 148 /* we depend on this a lot! */
153 id->model[sizeof(id->model)-1] = '\0'; 149 m[ATA_ID_PROD_LEN - 1] = '\0';
154 150
155 if (strstr(id->model, "E X A B Y T E N E S T")) 151 if (strstr(m, "E X A B Y T E N E S T"))
156 goto err_misc; 152 goto err_misc;
157 153
158 printk(KERN_INFO "%s: %s, ", drive->name, id->model); 154 printk(KERN_INFO "%s: %s, ", drive->name, m);
159 155
160 drive->present = 1; 156 drive->present = 1;
161 drive->dead = 0; 157 drive->dead = 0;
@@ -163,16 +159,16 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
163 /* 159 /*
164 * Check for an ATAPI device 160 * Check for an ATAPI device
165 */ 161 */
166 if (cmd == WIN_PIDENTIFY) { 162 if (cmd == ATA_CMD_ID_ATAPI) {
167 u8 type = (id->config >> 8) & 0x1f; 163 u8 type = (id[ATA_ID_CONFIG] >> 8) & 0x1f;
168 164
169 printk(KERN_CONT "ATAPI "); 165 printk(KERN_CONT "ATAPI ");
170 switch (type) { 166 switch (type) {
171 case ide_floppy: 167 case ide_floppy:
172 if (!strstr(id->model, "CD-ROM")) { 168 if (!strstr(m, "CD-ROM")) {
173 if (!strstr(id->model, "oppy") && 169 if (!strstr(m, "oppy") &&
174 !strstr(id->model, "poyp") && 170 !strstr(m, "poyp") &&
175 !strstr(id->model, "ZIP")) 171 !strstr(m, "ZIP"))
176 printk(KERN_CONT "cdrom or floppy?, assuming "); 172 printk(KERN_CONT "cdrom or floppy?, assuming ");
177 if (drive->media != ide_cdrom) { 173 if (drive->media != ide_cdrom) {
178 printk(KERN_CONT "FLOPPY"); 174 printk(KERN_CONT "FLOPPY");
@@ -186,8 +182,7 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
186 drive->removable = 1; 182 drive->removable = 1;
187#ifdef CONFIG_PPC 183#ifdef CONFIG_PPC
188 /* kludge for Apple PowerBook internal zip */ 184 /* kludge for Apple PowerBook internal zip */
189 if (!strstr(id->model, "CD-ROM") && 185 if (!strstr(m, "CD-ROM") && strstr(m, "ZIP")) {
190 strstr(id->model, "ZIP")) {
191 printk(KERN_CONT "FLOPPY"); 186 printk(KERN_CONT "FLOPPY");
192 type = ide_floppy; 187 type = ide_floppy;
193 break; 188 break;
@@ -217,18 +212,15 @@ static inline void do_identify (ide_drive_t *drive, u8 cmd)
217 * Not an ATAPI device: looks like a "regular" hard disk 212 * Not an ATAPI device: looks like a "regular" hard disk
218 */ 213 */
219 214
220 /* 215 is_cfa = ata_id_is_cfa(id);
221 * 0x848a = CompactFlash device
222 * These are *not* removable in Linux definition of the term
223 */
224 216
225 if ((id->config != 0x848a) && (id->config & (1<<7))) 217 /* CF devices are *not* removable in Linux definition of the term */
218 if (is_cfa == 0 && (id[ATA_ID_CONFIG] & (1 << 7)))
226 drive->removable = 1; 219 drive->removable = 1;
227 220
228 drive->media = ide_disk; 221 drive->media = ide_disk;
229 222
230 printk(KERN_CONT "%s DISK drive\n", 223 printk(KERN_CONT "%s DISK drive\n", is_cfa ? "CFA" : "ATA");
231 (id->config == 0x848a) ? "CFA" : "ATA");
232 224
233 return; 225 return;
234 226
@@ -268,7 +260,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
268 if (io_ports->ctl_addr) { 260 if (io_ports->ctl_addr) {
269 a = tp_ops->read_altstatus(hwif); 261 a = tp_ops->read_altstatus(hwif);
270 s = tp_ops->read_status(hwif); 262 s = tp_ops->read_status(hwif);
271 if ((a ^ s) & ~INDEX_STAT) 263 if ((a ^ s) & ~ATA_IDX)
272 /* ancient Seagate drives, broken interfaces */ 264 /* ancient Seagate drives, broken interfaces */
273 printk(KERN_INFO "%s: probing with STATUS(0x%02x) " 265 printk(KERN_INFO "%s: probing with STATUS(0x%02x) "
274 "instead of ALTSTATUS(0x%02x)\n", 266 "instead of ALTSTATUS(0x%02x)\n",
@@ -281,7 +273,7 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
281 /* set features register for atapi 273 /* set features register for atapi
282 * identify command to be sure of reply 274 * identify command to be sure of reply
283 */ 275 */
284 if (cmd == WIN_PIDENTIFY) { 276 if (cmd == ATA_CMD_ID_ATAPI) {
285 ide_task_t task; 277 ide_task_t task;
286 278
287 memset(&task, 0, sizeof(task)); 279 memset(&task, 0, sizeof(task));
@@ -294,24 +286,16 @@ static int actual_try_to_identify (ide_drive_t *drive, u8 cmd)
294 /* ask drive for ID */ 286 /* ask drive for ID */
295 tp_ops->exec_command(hwif, cmd); 287 tp_ops->exec_command(hwif, cmd);
296 288
297 timeout = ((cmd == WIN_IDENTIFY) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2; 289 timeout = ((cmd == ATA_CMD_ID_ATA) ? WAIT_WORSTCASE : WAIT_PIDENTIFY) / 2;
298 timeout += jiffies;
299 do {
300 if (time_after(jiffies, timeout)) {
301 /* drive timed-out */
302 return 1;
303 }
304 /* give drive a breather */
305 msleep(50);
306 s = use_altstatus ? tp_ops->read_altstatus(hwif)
307 : tp_ops->read_status(hwif);
308 } while (s & BUSY_STAT);
309 290
310 /* wait for IRQ and DRQ_STAT */ 291 if (ide_busy_sleep(hwif, timeout, use_altstatus))
292 return 1;
293
294 /* wait for IRQ and ATA_DRQ */
311 msleep(50); 295 msleep(50);
312 s = tp_ops->read_status(hwif); 296 s = tp_ops->read_status(hwif);
313 297
314 if (OK_STAT(s, DRQ_STAT, BAD_R_STAT)) { 298 if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) {
315 unsigned long flags; 299 unsigned long flags;
316 300
317 /* local CPU only; some systems need this */ 301 /* local CPU only; some systems need this */
@@ -387,19 +371,21 @@ static int try_to_identify (ide_drive_t *drive, u8 cmd)
387 return retval; 371 return retval;
388} 372}
389 373
390static int ide_busy_sleep(ide_hwif_t *hwif) 374int ide_busy_sleep(ide_hwif_t *hwif, unsigned long timeout, int altstatus)
391{ 375{
392 unsigned long timeout = jiffies + WAIT_WORSTCASE;
393 u8 stat; 376 u8 stat;
394 377
378 timeout += jiffies;
379
395 do { 380 do {
396 msleep(50); 381 msleep(50); /* give drive a breather */
397 stat = hwif->tp_ops->read_status(hwif); 382 stat = altstatus ? hwif->tp_ops->read_altstatus(hwif)
398 if ((stat & BUSY_STAT) == 0) 383 : hwif->tp_ops->read_status(hwif);
384 if ((stat & ATA_BUSY) == 0)
399 return 0; 385 return 0;
400 } while (time_before(jiffies, timeout)); 386 } while (time_before(jiffies, timeout));
401 387
402 return 1; 388 return 1; /* drive timed-out */
403} 389}
404 390
405static u8 ide_read_device(ide_drive_t *drive) 391static u8 ide_read_device(ide_drive_t *drive)
@@ -444,13 +430,13 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
444 430
445 if (drive->present) { 431 if (drive->present) {
446 /* avoid waiting for inappropriate probes */ 432 /* avoid waiting for inappropriate probes */
447 if ((drive->media != ide_disk) && (cmd == WIN_IDENTIFY)) 433 if (drive->media != ide_disk && cmd == ATA_CMD_ID_ATA)
448 return 4; 434 return 4;
449 } 435 }
450#ifdef DEBUG 436#ifdef DEBUG
451 printk(KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n", 437 printk(KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n",
452 drive->name, drive->present, drive->media, 438 drive->name, drive->present, drive->media,
453 (cmd == WIN_IDENTIFY) ? "ATA" : "ATAPI"); 439 (cmd == ATA_CMD_ID_ATA) ? "ATA" : "ATAPI");
454#endif 440#endif
455 441
456 /* needed for some systems 442 /* needed for some systems
@@ -464,7 +450,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
464 if (drive->select.b.unit != 0) { 450 if (drive->select.b.unit != 0) {
465 /* exit with drive0 selected */ 451 /* exit with drive0 selected */
466 SELECT_DRIVE(&hwif->drives[0]); 452 SELECT_DRIVE(&hwif->drives[0]);
467 /* allow BUSY_STAT to assert & clear */ 453 /* allow ATA_BUSY to assert & clear */
468 msleep(50); 454 msleep(50);
469 } 455 }
470 /* no i/f present: mmm.. this should be a 4 -ml */ 456 /* no i/f present: mmm.. this should be a 4 -ml */
@@ -473,8 +459,8 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
473 459
474 stat = tp_ops->read_status(hwif); 460 stat = tp_ops->read_status(hwif);
475 461
476 if (OK_STAT(stat, READY_STAT, BUSY_STAT) || 462 if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) ||
477 drive->present || cmd == WIN_PIDENTIFY) { 463 drive->present || cmd == ATA_CMD_ID_ATAPI) {
478 /* send cmd and wait */ 464 /* send cmd and wait */
479 if ((rc = try_to_identify(drive, cmd))) { 465 if ((rc = try_to_identify(drive, cmd))) {
480 /* failed: try again */ 466 /* failed: try again */
@@ -483,17 +469,17 @@ static int do_probe (ide_drive_t *drive, u8 cmd)
483 469
484 stat = tp_ops->read_status(hwif); 470 stat = tp_ops->read_status(hwif);
485 471
486 if (stat == (BUSY_STAT | READY_STAT)) 472 if (stat == (ATA_BUSY | ATA_DRDY))
487 return 4; 473 return 4;
488 474
489 if (rc == 1 && cmd == WIN_PIDENTIFY) { 475 if (rc == 1 && cmd == ATA_CMD_ID_ATAPI) {
490 printk(KERN_ERR "%s: no response (status = 0x%02x), " 476 printk(KERN_ERR "%s: no response (status = 0x%02x), "
491 "resetting drive\n", drive->name, stat); 477 "resetting drive\n", drive->name, stat);
492 msleep(50); 478 msleep(50);
493 SELECT_DRIVE(drive); 479 SELECT_DRIVE(drive);
494 msleep(50); 480 msleep(50);
495 tp_ops->exec_command(hwif, WIN_SRST); 481 tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
496 (void)ide_busy_sleep(hwif); 482 (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0);
497 rc = try_to_identify(drive, cmd); 483 rc = try_to_identify(drive, cmd);
498 } 484 }
499 485
@@ -526,13 +512,14 @@ static void enable_nest (ide_drive_t *drive)
526 const struct ide_tp_ops *tp_ops = hwif->tp_ops; 512 const struct ide_tp_ops *tp_ops = hwif->tp_ops;
527 u8 stat; 513 u8 stat;
528 514
529 printk(KERN_INFO "%s: enabling %s -- ", hwif->name, drive->id->model); 515 printk(KERN_INFO "%s: enabling %s -- ",
516 hwif->name, (char *)&drive->id[ATA_ID_PROD]);
530 517
531 SELECT_DRIVE(drive); 518 SELECT_DRIVE(drive);
532 msleep(50); 519 msleep(50);
533 tp_ops->exec_command(hwif, EXABYTE_ENABLE_NEST); 520 tp_ops->exec_command(hwif, ATA_EXABYTE_ENABLE_NEST);
534 521
535 if (ide_busy_sleep(hwif)) { 522 if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 0)) {
536 printk(KERN_CONT "failed (timeout)\n"); 523 printk(KERN_CONT "failed (timeout)\n");
537 return; 524 return;
538 } 525 }
@@ -545,12 +532,6 @@ static void enable_nest (ide_drive_t *drive)
545 printk(KERN_CONT "failed (status = 0x%02x)\n", stat); 532 printk(KERN_CONT "failed (status = 0x%02x)\n", stat);
546 else 533 else
547 printk(KERN_CONT "success\n"); 534 printk(KERN_CONT "success\n");
548
549 /* if !(success||timed-out) */
550 if (do_probe(drive, WIN_IDENTIFY) >= 2) {
551 /* look for ATAPI device */
552 (void) do_probe(drive, WIN_PIDENTIFY);
553 }
554} 535}
555 536
556/** 537/**
@@ -567,6 +548,8 @@ static void enable_nest (ide_drive_t *drive)
567 548
568static inline u8 probe_for_drive (ide_drive_t *drive) 549static inline u8 probe_for_drive (ide_drive_t *drive)
569{ 550{
551 char *m;
552
570 /* 553 /*
571 * In order to keep things simple we have an id 554 * In order to keep things simple we have an id
572 * block for all drives at all times. If the device 555 * block for all drives at all times. If the device
@@ -576,29 +559,34 @@ static inline u8 probe_for_drive (ide_drive_t *drive)
576 * Also note that 0 everywhere means "can't do X" 559 * Also note that 0 everywhere means "can't do X"
577 */ 560 */
578 561
579 drive->id = kzalloc(SECTOR_WORDS *4, GFP_KERNEL); 562 drive->id = kzalloc(SECTOR_SIZE, GFP_KERNEL);
580 drive->id_read = 0; 563 drive->id_read = 0;
581 if(drive->id == NULL) 564 if(drive->id == NULL)
582 { 565 {
583 printk(KERN_ERR "ide: out of memory for id data.\n"); 566 printk(KERN_ERR "ide: out of memory for id data.\n");
584 return 0; 567 return 0;
585 } 568 }
586 strcpy(drive->id->model, "UNKNOWN"); 569
587 570 m = (char *)&drive->id[ATA_ID_PROD];
571 strcpy(m, "UNKNOWN");
572
588 /* skip probing? */ 573 /* skip probing? */
589 if (!drive->noprobe) 574 if (!drive->noprobe) {
590 { 575retry:
591 /* if !(success||timed-out) */ 576 /* if !(success||timed-out) */
592 if (do_probe(drive, WIN_IDENTIFY) >= 2) { 577 if (do_probe(drive, ATA_CMD_ID_ATA) >= 2)
593 /* look for ATAPI device */ 578 /* look for ATAPI device */
594 (void) do_probe(drive, WIN_PIDENTIFY); 579 (void)do_probe(drive, ATA_CMD_ID_ATAPI);
595 } 580
596 if (!drive->present) 581 if (!drive->present)
597 /* drive not found */ 582 /* drive not found */
598 return 0; 583 return 0;
599 if (strstr(drive->id->model, "E X A B Y T E N E S T")) 584
585 if (strstr(m, "E X A B Y T E N E S T")) {
600 enable_nest(drive); 586 enable_nest(drive);
601 587 goto retry;
588 }
589
602 /* identification failed? */ 590 /* identification failed? */
603 if (!drive->id_read) { 591 if (!drive->id_read) {
604 if (drive->media == ide_disk) { 592 if (drive->media == ide_disk) {
@@ -740,36 +728,38 @@ out:
740 728
741/** 729/**
742 * ide_undecoded_slave - look for bad CF adapters 730 * ide_undecoded_slave - look for bad CF adapters
743 * @drive1: drive 731 * @dev1: slave device
744 * 732 *
745 * Analyse the drives on the interface and attempt to decide if we 733 * Analyse the drives on the interface and attempt to decide if we
746 * have the same drive viewed twice. This occurs with crap CF adapters 734 * have the same drive viewed twice. This occurs with crap CF adapters
747 * and PCMCIA sometimes. 735 * and PCMCIA sometimes.
748 */ 736 */
749 737
750void ide_undecoded_slave(ide_drive_t *drive1) 738void ide_undecoded_slave(ide_drive_t *dev1)
751{ 739{
752 ide_drive_t *drive0 = &drive1->hwif->drives[0]; 740 ide_drive_t *dev0 = &dev1->hwif->drives[0];
753 741
754 if ((drive1->dn & 1) == 0 || drive0->present == 0) 742 if ((dev1->dn & 1) == 0 || dev0->present == 0)
755 return; 743 return;
756 744
757 /* If the models don't match they are not the same product */ 745 /* If the models don't match they are not the same product */
758 if (strcmp(drive0->id->model, drive1->id->model)) 746 if (strcmp((char *)&dev0->id[ATA_ID_PROD],
747 (char *)&dev1->id[ATA_ID_PROD]))
759 return; 748 return;
760 749
761 /* Serial numbers do not match */ 750 /* Serial numbers do not match */
762 if (strncmp(drive0->id->serial_no, drive1->id->serial_no, 20)) 751 if (strncmp((char *)&dev0->id[ATA_ID_SERNO],
752 (char *)&dev1->id[ATA_ID_SERNO], ATA_ID_SERNO_LEN))
763 return; 753 return;
764 754
765 /* No serial number, thankfully very rare for CF */ 755 /* No serial number, thankfully very rare for CF */
766 if (drive0->id->serial_no[0] == 0) 756 if (*(char *)&dev0->id[ATA_ID_SERNO] == 0)
767 return; 757 return;
768 758
769 /* Appears to be an IDE flash adapter with decode bugs */ 759 /* Appears to be an IDE flash adapter with decode bugs */
770 printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n"); 760 printk(KERN_WARNING "ide-probe: ignoring undecoded slave\n");
771 761
772 drive1->present = 0; 762 dev1->present = 0;
773} 763}
774 764
775EXPORT_SYMBOL_GPL(ide_undecoded_slave); 765EXPORT_SYMBOL_GPL(ide_undecoded_slave);
@@ -853,7 +843,7 @@ static void ide_port_tune_devices(ide_hwif_t *hwif)
853 if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT) 843 if (hwif->host_flags & IDE_HFLAG_NO_IO_32BIT)
854 drive->no_io_32bit = 1; 844 drive->no_io_32bit = 1;
855 else 845 else
856 drive->no_io_32bit = drive->id->dword_io ? 1 : 0; 846 drive->no_io_32bit = drive->id[ATA_ID_DWORD_IO] ? 1 : 0;
857 } 847 }
858} 848}
859 849
@@ -1037,11 +1027,6 @@ static int init_irq (ide_hwif_t *hwif)
1037 ide_hwgroup_t *hwgroup; 1027 ide_hwgroup_t *hwgroup;
1038 ide_hwif_t *match = NULL; 1028 ide_hwif_t *match = NULL;
1039 1029
1040
1041 BUG_ON(in_interrupt());
1042 BUG_ON(irqs_disabled());
1043 BUG_ON(hwif == NULL);
1044
1045 mutex_lock(&ide_cfg_mtx); 1030 mutex_lock(&ide_cfg_mtx);
1046 hwif->hwgroup = NULL; 1031 hwif->hwgroup = NULL;
1047#if MAX_HWIFS > 1 1032#if MAX_HWIFS > 1
@@ -1116,7 +1101,8 @@ static int init_irq (ide_hwif_t *hwif)
1116 sa = IRQF_SHARED; 1101 sa = IRQF_SHARED;
1117#endif /* __mc68000__ */ 1102#endif /* __mc68000__ */
1118 1103
1119 if (IDE_CHIPSET_IS_PCI(hwif->chipset)) 1104 if (hwif->chipset == ide_pci || hwif->chipset == ide_cmd646 ||
1105 hwif->chipset == ide_ali14xx)
1120 sa = IRQF_SHARED; 1106 sa = IRQF_SHARED;
1121 1107
1122 if (io_ports->ctl_addr) 1108 if (io_ports->ctl_addr)
@@ -1344,8 +1330,6 @@ static void hwif_register_devices(ide_hwif_t *hwif)
1344 if (!drive->present) 1330 if (!drive->present)
1345 continue; 1331 continue;
1346 1332
1347 ide_add_generic_settings(drive);
1348
1349 snprintf(dev->bus_id, BUS_ID_SIZE, "%u.%u", hwif->index, i); 1333 snprintf(dev->bus_id, BUS_ID_SIZE, "%u.%u", hwif->index, i);
1350 dev->parent = &hwif->gendev; 1334 dev->parent = &hwif->gendev;
1351 dev->bus = &ide_bus_type; 1335 dev->bus = &ide_bus_type;
@@ -1602,8 +1586,10 @@ struct ide_host *ide_host_alloc_all(const struct ide_port_info *d,
1602 if (hws[0]) 1586 if (hws[0])
1603 host->dev[0] = hws[0]->dev; 1587 host->dev[0] = hws[0]->dev;
1604 1588
1605 if (d) 1589 if (d) {
1590 host->init_chipset = d->init_chipset;
1606 host->host_flags = d->host_flags; 1591 host->host_flags = d->host_flags;
1592 }
1607 1593
1608 return host; 1594 return host;
1609} 1595}