diff options
| -rw-r--r-- | drivers/ide/ide-iops.c | 54 | ||||
| -rw-r--r-- | drivers/ide/ide-probe.c | 24 | ||||
| -rw-r--r-- | include/linux/ide.h | 2 |
3 files changed, 18 insertions, 62 deletions
diff --git a/drivers/ide/ide-iops.c b/drivers/ide/ide-iops.c index affbc603987a..317c5dadd7c0 100644 --- a/drivers/ide/ide-iops.c +++ b/drivers/ide/ide-iops.c | |||
| @@ -289,65 +289,19 @@ no_80w: | |||
| 289 | 289 | ||
| 290 | int ide_driveid_update(ide_drive_t *drive) | 290 | int ide_driveid_update(ide_drive_t *drive) |
| 291 | { | 291 | { |
| 292 | ide_hwif_t *hwif = drive->hwif; | ||
| 293 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | ||
| 294 | u16 *id; | 292 | u16 *id; |
| 295 | unsigned long flags; | 293 | int rc; |
| 296 | int use_altstatus = 0, rc; | ||
| 297 | u8 a, uninitialized_var(s); | ||
| 298 | 294 | ||
| 299 | id = kmalloc(SECTOR_SIZE, GFP_ATOMIC); | 295 | id = kmalloc(SECTOR_SIZE, GFP_ATOMIC); |
| 300 | if (id == NULL) | 296 | if (id == NULL) |
| 301 | return 0; | 297 | return 0; |
| 302 | 298 | ||
| 303 | /* | ||
| 304 | * Re-read drive->id for possible DMA mode | ||
| 305 | * change (copied from ide-probe.c) | ||
| 306 | */ | ||
| 307 | |||
| 308 | SELECT_MASK(drive, 1); | 299 | SELECT_MASK(drive, 1); |
| 309 | tp_ops->set_irq(hwif, 0); | 300 | rc = ide_dev_read_id(drive, ATA_CMD_ID_ATA, id); |
| 310 | msleep(50); | 301 | SELECT_MASK(drive, 0); |
| 311 | |||
| 312 | if (hwif->io_ports.ctl_addr && | ||
| 313 | (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) { | ||
| 314 | a = tp_ops->read_altstatus(hwif); | ||
| 315 | s = tp_ops->read_status(hwif); | ||
| 316 | if ((a ^ s) & ~ATA_IDX) | ||
| 317 | /* ancient Seagate drives, broken interfaces */ | ||
| 318 | printk(KERN_INFO "%s: probing with STATUS(0x%02x) " | ||
| 319 | "instead of ALTSTATUS(0x%02x)\n", | ||
| 320 | drive->name, s, a); | ||
| 321 | else | ||
| 322 | /* use non-intrusive polling */ | ||
| 323 | use_altstatus = 1; | ||
| 324 | } | ||
| 325 | |||
| 326 | tp_ops->exec_command(hwif, ATA_CMD_ID_ATA); | ||
| 327 | |||
| 328 | if (ide_busy_sleep(hwif, WAIT_WORSTCASE / 2, use_altstatus)) { | ||
| 329 | rc = 1; | ||
| 330 | goto out_err; | ||
| 331 | } | ||
| 332 | |||
| 333 | msleep(50); /* wait for IRQ and ATA_DRQ */ | ||
| 334 | |||
| 335 | s = tp_ops->read_status(hwif); | ||
| 336 | 302 | ||
| 337 | if (!OK_STAT(s, ATA_DRQ, BAD_R_STAT)) { | 303 | if (rc) |
| 338 | rc = 2; | ||
| 339 | goto out_err; | 304 | goto out_err; |
| 340 | } | ||
| 341 | |||
| 342 | local_irq_save(flags); | ||
| 343 | tp_ops->input_data(drive, NULL, id, SECTOR_SIZE); | ||
| 344 | local_irq_restore(flags); | ||
| 345 | |||
| 346 | (void)tp_ops->read_status(hwif); /* clear drive IRQ */ | ||
| 347 | |||
| 348 | ide_fix_driveid(id); | ||
| 349 | |||
| 350 | SELECT_MASK(drive, 0); | ||
| 351 | 305 | ||
| 352 | drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES]; | 306 | drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES]; |
| 353 | drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES]; | 307 | drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES]; |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 3f9faef5e50e..974067043fba 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
| @@ -181,16 +181,16 @@ static void ide_classify_atapi_dev(ide_drive_t *drive) | |||
| 181 | * do_identify - identify a drive | 181 | * do_identify - identify a drive |
| 182 | * @drive: drive to identify | 182 | * @drive: drive to identify |
| 183 | * @cmd: command used | 183 | * @cmd: command used |
| 184 | * @id: buffer for IDENTIFY data | ||
| 184 | * | 185 | * |
| 185 | * Called when we have issued a drive identify command to | 186 | * Called when we have issued a drive identify command to |
| 186 | * read and parse the results. This function is run with | 187 | * read and parse the results. This function is run with |
| 187 | * interrupts disabled. | 188 | * interrupts disabled. |
| 188 | */ | 189 | */ |
| 189 | 190 | ||
| 190 | static void do_identify(ide_drive_t *drive, u8 cmd) | 191 | static void do_identify(ide_drive_t *drive, u8 cmd, u16 *id) |
| 191 | { | 192 | { |
| 192 | ide_hwif_t *hwif = drive->hwif; | 193 | ide_hwif_t *hwif = drive->hwif; |
| 193 | u16 *id = drive->id; | ||
| 194 | char *m = (char *)&id[ATA_ID_PROD]; | 194 | char *m = (char *)&id[ATA_ID_PROD]; |
| 195 | unsigned long flags; | 195 | unsigned long flags; |
| 196 | int bswap = 1; | 196 | int bswap = 1; |
| @@ -240,19 +240,19 @@ err_misc: | |||
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | /** | 242 | /** |
| 243 | * try_to_identify - send ATA/ATAPI identify | 243 | * ide_dev_read_id - send ATA/ATAPI IDENTIFY command |
| 244 | * @drive: drive to identify | 244 | * @drive: drive to identify |
| 245 | * @cmd: command to use | 245 | * @cmd: command to use |
| 246 | * @id: buffer for IDENTIFY data | ||
| 246 | * | 247 | * |
| 247 | * try_to_identify() sends an ATA(PI) IDENTIFY request to a drive | 248 | * Sends an ATA(PI) IDENTIFY request to a drive and waits for a response. |
| 248 | * and waits for a response. | ||
| 249 | * | 249 | * |
| 250 | * Returns: 0 device was identified | 250 | * Returns: 0 device was identified |
| 251 | * 1 device timed-out (no response to identify request) | 251 | * 1 device timed-out (no response to identify request) |
| 252 | * 2 device aborted the command (refused to identify itself) | 252 | * 2 device aborted the command (refused to identify itself) |
| 253 | */ | 253 | */ |
| 254 | 254 | ||
| 255 | static int try_to_identify(ide_drive_t *drive, u8 cmd) | 255 | int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id) |
| 256 | { | 256 | { |
| 257 | ide_hwif_t *hwif = drive->hwif; | 257 | ide_hwif_t *hwif = drive->hwif; |
| 258 | struct ide_io_ports *io_ports = &hwif->io_ports; | 258 | struct ide_io_ports *io_ports = &hwif->io_ports; |
| @@ -312,7 +312,7 @@ static int try_to_identify(ide_drive_t *drive, u8 cmd) | |||
| 312 | 312 | ||
| 313 | if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) { | 313 | if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) { |
| 314 | /* drive returned ID */ | 314 | /* drive returned ID */ |
| 315 | do_identify(drive, cmd); | 315 | do_identify(drive, cmd, id); |
| 316 | /* drive responded with ID */ | 316 | /* drive responded with ID */ |
| 317 | rc = 0; | 317 | rc = 0; |
| 318 | /* clear drive IRQ */ | 318 | /* clear drive IRQ */ |
| @@ -378,6 +378,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
| 378 | { | 378 | { |
| 379 | ide_hwif_t *hwif = drive->hwif; | 379 | ide_hwif_t *hwif = drive->hwif; |
| 380 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; | 380 | const struct ide_tp_ops *tp_ops = hwif->tp_ops; |
| 381 | u16 *id = drive->id; | ||
| 381 | int rc; | 382 | int rc; |
| 382 | u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; | 383 | u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat; |
| 383 | 384 | ||
| @@ -413,11 +414,10 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
| 413 | 414 | ||
| 414 | if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || | 415 | if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) || |
| 415 | present || cmd == ATA_CMD_ID_ATAPI) { | 416 | present || cmd == ATA_CMD_ID_ATAPI) { |
| 416 | /* send cmd and wait */ | 417 | rc = ide_dev_read_id(drive, cmd, id); |
| 417 | if ((rc = try_to_identify(drive, cmd))) { | 418 | if (rc) |
| 418 | /* failed: try again */ | 419 | /* failed: try again */ |
| 419 | rc = try_to_identify(drive,cmd); | 420 | rc = ide_dev_read_id(drive, cmd, id); |
| 420 | } | ||
| 421 | 421 | ||
| 422 | stat = tp_ops->read_status(hwif); | 422 | stat = tp_ops->read_status(hwif); |
| 423 | 423 | ||
| @@ -432,7 +432,7 @@ static int do_probe (ide_drive_t *drive, u8 cmd) | |||
| 432 | msleep(50); | 432 | msleep(50); |
| 433 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); | 433 | tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET); |
| 434 | (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0); | 434 | (void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0); |
| 435 | rc = try_to_identify(drive, cmd); | 435 | rc = ide_dev_read_id(drive, cmd, id); |
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | /* ensure drive IRQ is clear */ | 438 | /* ensure drive IRQ is clear */ |
diff --git a/include/linux/ide.h b/include/linux/ide.h index bbce9b2bdfc4..854eba8b2ba3 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
| @@ -1235,6 +1235,8 @@ int ide_no_data_taskfile(ide_drive_t *, ide_task_t *); | |||
| 1235 | 1235 | ||
| 1236 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); | 1236 | int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long); |
| 1237 | 1237 | ||
| 1238 | int ide_dev_read_id(ide_drive_t *, u8, u16 *); | ||
| 1239 | |||
| 1238 | extern int ide_driveid_update(ide_drive_t *); | 1240 | extern int ide_driveid_update(ide_drive_t *); |
| 1239 | extern int ide_config_drive_speed(ide_drive_t *, u8); | 1241 | extern int ide_config_drive_speed(ide_drive_t *, u8); |
| 1240 | extern u8 eighty_ninty_three (ide_drive_t *); | 1242 | extern u8 eighty_ninty_three (ide_drive_t *); |
