* [PATCH 0/8] ide: unify code for reading device identify data
@ 2009-01-22 14:18 Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 1/8] ide: fix kmalloc() failure handling in ide_driveid_update() Bartlomiej Zolnierkiewicz
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-22 14:18 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
Transform try_to_identify() into globally usable ide_dev_read_id() and update
ide_driveid_update() to use it instead of duplicating the functionality. Also
remove broken/dead EXABYTENEST handling while at it.
Based on top of pata-2.6 tree.
diffstat:
drivers/ide/ide-iops.c | 118 +++++++++++++++++++-----------------------------
drivers/ide/ide-probe.c | 87 ++++++++++-------------------------
include/linux/ata.h | 2
include/linux/ide.h | 2
4 files changed, 75 insertions(+), 134 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/8] ide: fix kmalloc() failure handling in ide_driveid_update()
2009-01-22 14:18 [PATCH 0/8] ide: unify code for reading device identify data Bartlomiej Zolnierkiewicz
@ 2009-01-22 14:18 ` Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 2/8] ide: propagate AltStatus workarounds to ide_driveid_update() Bartlomiej Zolnierkiewicz
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-22 14:18 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: fix kmalloc() failure handling in ide_driveid_update()
* Doing kmalloc() in the middle of command execution is not only ugly
but leaves drive waiting to send data on kmalloc() failure. Fix it.
While at it:
* Unify error code paths.
* Fixup error message to be more useful and add missing KERN_ERR level.
* Rename 'stat' variable to 's'.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-iops.c | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -293,7 +293,12 @@ int ide_driveid_update(ide_drive_t *driv
const struct ide_tp_ops *tp_ops = hwif->tp_ops;
u16 *id;
unsigned long flags;
- u8 stat;
+ int rc;
+ u8 uninitialized_var(s);
+
+ id = kmalloc(SECTOR_SIZE, GFP_ATOMIC);
+ if (id == NULL)
+ return 0;
/*
* Re-read drive->id for possible DMA mode
@@ -306,25 +311,21 @@ int ide_driveid_update(ide_drive_t *driv
tp_ops->exec_command(hwif, ATA_CMD_ID_ATA);
if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 1)) {
- SELECT_MASK(drive, 0);
- return 0;
+ rc = 1;
+ goto out_err;
}
msleep(50); /* wait for IRQ and ATA_DRQ */
- stat = tp_ops->read_status(hwif);
- if (!OK_STAT(stat, ATA_DRQ, BAD_R_STAT)) {
- SELECT_MASK(drive, 0);
- printk("%s: CHECK for good STATUS\n", drive->name);
- return 0;
+ s = tp_ops->read_status(hwif);
+
+ if (!OK_STAT(s, ATA_DRQ, BAD_R_STAT)) {
+ rc = 2;
+ goto out_err;
}
+
local_irq_save(flags);
SELECT_MASK(drive, 0);
- id = kmalloc(SECTOR_SIZE, GFP_ATOMIC);
- if (!id) {
- local_irq_restore(flags);
- return 0;
- }
tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
(void)tp_ops->read_status(hwif); /* clear drive IRQ */
local_irq_enable();
@@ -342,6 +343,12 @@ int ide_driveid_update(ide_drive_t *driv
ide_dma_off(drive);
return 1;
+out_err:
+ SELECT_MASK(drive, 0);
+ if (rc == 2)
+ printk(KERN_ERR "%s: %s: bad status\n", drive->name, __func__);
+ kfree(id);
+ return 0;
}
int ide_config_drive_speed(ide_drive_t *drive, u8 speed)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/8] ide: propagate AltStatus workarounds to ide_driveid_update()
2009-01-22 14:18 [PATCH 0/8] ide: unify code for reading device identify data Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 1/8] ide: fix kmalloc() failure handling in ide_driveid_update() Bartlomiej Zolnierkiewicz
@ 2009-01-22 14:18 ` Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 3/8] ide: shorten timeout value in ide_driveid_update() Bartlomiej Zolnierkiewicz
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-22 14:18 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: propagate AltStatus workarounds to ide_driveid_update()
Propagate AltStatus workarounds from try_to_identify()
to ide_driveid_update().
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-iops.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -293,8 +293,8 @@ int ide_driveid_update(ide_drive_t *driv
const struct ide_tp_ops *tp_ops = hwif->tp_ops;
u16 *id;
unsigned long flags;
- int rc;
- u8 uninitialized_var(s);
+ int use_altstatus = 0, rc;
+ u8 a, uninitialized_var(s);
id = kmalloc(SECTOR_SIZE, GFP_ATOMIC);
if (id == NULL)
@@ -308,9 +308,24 @@ int ide_driveid_update(ide_drive_t *driv
SELECT_MASK(drive, 1);
tp_ops->set_irq(hwif, 0);
msleep(50);
+
+ if (hwif->io_ports.ctl_addr &&
+ (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) {
+ a = tp_ops->read_altstatus(hwif);
+ s = tp_ops->read_status(hwif);
+ if ((a ^ s) & ~ATA_IDX)
+ /* ancient Seagate drives, broken interfaces */
+ printk(KERN_INFO "%s: probing with STATUS(0x%02x) "
+ "instead of ALTSTATUS(0x%02x)\n",
+ drive->name, s, a);
+ else
+ /* use non-intrusive polling */
+ use_altstatus = 1;
+ }
+
tp_ops->exec_command(hwif, ATA_CMD_ID_ATA);
- if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 1)) {
+ if (ide_busy_sleep(hwif, WAIT_WORSTCASE, use_altstatus)) {
rc = 1;
goto out_err;
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/8] ide: shorten timeout value in ide_driveid_update()
2009-01-22 14:18 [PATCH 0/8] ide: unify code for reading device identify data Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 1/8] ide: fix kmalloc() failure handling in ide_driveid_update() Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 2/8] ide: propagate AltStatus workarounds to ide_driveid_update() Bartlomiej Zolnierkiewicz
@ 2009-01-22 14:18 ` Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 4/8] ide: remove broken EXABYTENEST support Bartlomiej Zolnierkiewicz
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-22 14:18 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: shorten timeout value in ide_driveid_update()
Shorten timeout value in ide_driveid_update() (30s -> 15s)
to match try_to_identify().
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-iops.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -325,7 +325,7 @@ int ide_driveid_update(ide_drive_t *driv
tp_ops->exec_command(hwif, ATA_CMD_ID_ATA);
- if (ide_busy_sleep(hwif, WAIT_WORSTCASE, use_altstatus)) {
+ if (ide_busy_sleep(hwif, WAIT_WORSTCASE / 2, use_altstatus)) {
rc = 1;
goto out_err;
}
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/8] ide: remove broken EXABYTENEST support
2009-01-22 14:18 [PATCH 0/8] ide: unify code for reading device identify data Bartlomiej Zolnierkiewicz
` (2 preceding siblings ...)
2009-01-22 14:18 ` [PATCH 3/8] ide: shorten timeout value in ide_driveid_update() Bartlomiej Zolnierkiewicz
@ 2009-01-22 14:18 ` Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 5/8] ide: classify device type in do_probe() Bartlomiej Zolnierkiewicz
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-22 14:18 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: remove broken EXABYTENEST support
do_identify() marks EXABYTENEST device as non-present and frees
drive->id so enable_nest() has absolutely no chance of working.
The code was like this since at least 2.6.12-rc2 and nobody
has noticed so just remove broken EXABYTENEST support.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-probe.c | 37 -------------------------------------
include/linux/ata.h | 2 --
2 files changed, 39 deletions(-)
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -465,37 +465,6 @@ static int do_probe (ide_drive_t *drive,
return rc;
}
-/*
- *
- */
-static void enable_nest (ide_drive_t *drive)
-{
- ide_hwif_t *hwif = drive->hwif;
- const struct ide_tp_ops *tp_ops = hwif->tp_ops;
- u8 stat;
-
- printk(KERN_INFO "%s: enabling %s -- ",
- hwif->name, (char *)&drive->id[ATA_ID_PROD]);
-
- SELECT_DRIVE(drive);
- msleep(50);
- tp_ops->exec_command(hwif, ATA_EXABYTE_ENABLE_NEST);
-
- if (ide_busy_sleep(hwif, WAIT_WORSTCASE, 0)) {
- printk(KERN_CONT "failed (timeout)\n");
- return;
- }
-
- msleep(50);
-
- stat = tp_ops->read_status(hwif);
-
- if (!OK_STAT(stat, 0, BAD_STAT))
- printk(KERN_CONT "failed (status = 0x%02x)\n", stat);
- else
- printk(KERN_CONT "success\n");
-}
-
/**
* probe_for_drives - upper level drive probe
* @drive: drive to probe for
@@ -534,7 +503,6 @@ static u8 probe_for_drive(ide_drive_t *d
/* skip probing? */
if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) {
-retry:
/* if !(success||timed-out) */
if (do_probe(drive, ATA_CMD_ID_ATA) >= 2)
/* look for ATAPI device */
@@ -544,11 +512,6 @@ retry:
/* drive not found */
return 0;
- if (strstr(m, "E X A B Y T E N E S T")) {
- enable_nest(drive);
- goto retry;
- }
-
/* identification failed? */
if ((drive->dev_flags & IDE_DFLAG_ID_READ) == 0) {
if (drive->media == ide_disk) {
Index: b/include/linux/ata.h
===================================================================
--- a/include/linux/ata.h
+++ b/include/linux/ata.h
@@ -242,8 +242,6 @@ enum {
ATA_CMD_MEDIA_UNLOCK = 0xDF,
/* marked obsolete in the ATA/ATAPI-7 spec */
ATA_CMD_RESTORE = 0x10,
- /* EXABYTE specific */
- ATA_EXABYTE_ENABLE_NEST = 0xF0,
/* READ_LOG_EXT pages */
ATA_LOG_SATA_NCQ = 0x10,
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/8] ide: classify device type in do_probe()
2009-01-22 14:18 [PATCH 0/8] ide: unify code for reading device identify data Bartlomiej Zolnierkiewicz
` (3 preceding siblings ...)
2009-01-22 14:18 ` [PATCH 4/8] ide: remove broken EXABYTENEST support Bartlomiej Zolnierkiewicz
@ 2009-01-22 14:18 ` Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 6/8] ide: sanitize SELECT_MASK() usage in ide_driveid_update() Bartlomiej Zolnierkiewicz
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-22 14:18 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: classify device type in do_probe()
Defer classifying device type from do_identify() to do_probe().
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-probe.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -233,16 +233,6 @@ static void do_identify(ide_drive_t *dri
drive->dev_flags |= IDE_DFLAG_PRESENT;
drive->dev_flags &= ~IDE_DFLAG_DEAD;
- /*
- * Check for an ATAPI device
- */
- if (cmd == ATA_CMD_ID_ATAPI)
- ide_classify_atapi_dev(drive);
- else
- /*
- * Not an ATAPI device: looks like a "regular" hard disk
- */
- ide_classify_ata_dev(drive);
return;
err_misc:
kfree(id);
@@ -480,6 +470,8 @@ static int do_probe (ide_drive_t *drive,
static u8 probe_for_drive(ide_drive_t *drive)
{
char *m;
+ int rc;
+ u8 cmd;
/*
* In order to keep things simple we have an id
@@ -504,9 +496,13 @@ static u8 probe_for_drive(ide_drive_t *d
/* skip probing? */
if ((drive->dev_flags & IDE_DFLAG_NOPROBE) == 0) {
/* if !(success||timed-out) */
- if (do_probe(drive, ATA_CMD_ID_ATA) >= 2)
+ cmd = ATA_CMD_ID_ATA;
+ rc = do_probe(drive, cmd);
+ if (rc >= 2) {
/* look for ATAPI device */
- (void)do_probe(drive, ATA_CMD_ID_ATAPI);
+ cmd = ATA_CMD_ID_ATAPI;
+ rc = do_probe(drive, cmd);
+ }
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
/* drive not found */
@@ -525,8 +521,12 @@ static u8 probe_for_drive(ide_drive_t *d
printk(KERN_WARNING "%s: Unknown device on bus refused identification. Ignoring.\n", drive->name);
drive->dev_flags &= ~IDE_DFLAG_PRESENT;
}
+ } else {
+ if (cmd == ATA_CMD_ID_ATAPI)
+ ide_classify_atapi_dev(drive);
+ else
+ ide_classify_ata_dev(drive);
}
- /* drive was found */
}
if ((drive->dev_flags & IDE_DFLAG_PRESENT) == 0)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 6/8] ide: sanitize SELECT_MASK() usage in ide_driveid_update()
2009-01-22 14:18 [PATCH 0/8] ide: unify code for reading device identify data Bartlomiej Zolnierkiewicz
` (4 preceding siblings ...)
2009-01-22 14:18 ` [PATCH 5/8] ide: classify device type in do_probe() Bartlomiej Zolnierkiewicz
@ 2009-01-22 14:18 ` Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 7/8] ide: clear drive IRQ after re-enabling local IRQs " Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 8/8] ide: use try_to_identify() " Bartlomiej Zolnierkiewicz
7 siblings, 0 replies; 9+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-22 14:18 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: sanitize SELECT_MASK() usage in ide_driveid_update()
Call SELECT_MASK() after ide_fix_driveid().
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-iops.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -340,13 +340,15 @@ int ide_driveid_update(ide_drive_t *driv
}
local_irq_save(flags);
- SELECT_MASK(drive, 0);
tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
(void)tp_ops->read_status(hwif); /* clear drive IRQ */
local_irq_enable();
local_irq_restore(flags);
+
ide_fix_driveid(id);
+ SELECT_MASK(drive, 0);
+
drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES];
drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES];
drive->id[ATA_ID_SWDMA_MODES] = id[ATA_ID_SWDMA_MODES];
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 7/8] ide: clear drive IRQ after re-enabling local IRQs in ide_driveid_update()
2009-01-22 14:18 [PATCH 0/8] ide: unify code for reading device identify data Bartlomiej Zolnierkiewicz
` (5 preceding siblings ...)
2009-01-22 14:18 ` [PATCH 6/8] ide: sanitize SELECT_MASK() usage in ide_driveid_update() Bartlomiej Zolnierkiewicz
@ 2009-01-22 14:18 ` Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 8/8] ide: use try_to_identify() " Bartlomiej Zolnierkiewicz
7 siblings, 0 replies; 9+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-22 14:18 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: clear drive IRQ after re-enabling local IRQs in ide_driveid_update()
Clear drive IRQ after re-enabling local IRQs in ide_driveid_update()
to match try_to_identify().
Also remove superfluous local_irq_enable() call while at it.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-iops.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -341,10 +341,10 @@ int ide_driveid_update(ide_drive_t *driv
local_irq_save(flags);
tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
- (void)tp_ops->read_status(hwif); /* clear drive IRQ */
- local_irq_enable();
local_irq_restore(flags);
+ (void)tp_ops->read_status(hwif); /* clear drive IRQ */
+
ide_fix_driveid(id);
SELECT_MASK(drive, 0);
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 8/8] ide: use try_to_identify() in ide_driveid_update()
2009-01-22 14:18 [PATCH 0/8] ide: unify code for reading device identify data Bartlomiej Zolnierkiewicz
` (6 preceding siblings ...)
2009-01-22 14:18 ` [PATCH 7/8] ide: clear drive IRQ after re-enabling local IRQs " Bartlomiej Zolnierkiewicz
@ 2009-01-22 14:18 ` Bartlomiej Zolnierkiewicz
7 siblings, 0 replies; 9+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2009-01-22 14:18 UTC (permalink / raw)
To: linux-ide; +Cc: Bartlomiej Zolnierkiewicz, linux-kernel
From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Subject: [PATCH] ide: use try_to_identify() in ide_driveid_update()
* Pass pointer to buffer for IDENTIFY data to do_identify()
and try_to_identify().
* Un-static try_to_identify() and use it in ide_driveid_update().
* Rename try_to_identify() to ide_dev_read_id().
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
---
drivers/ide/ide-iops.c | 54 +++---------------------------------------------
drivers/ide/ide-probe.c | 24 ++++++++++-----------
include/linux/ide.h | 2 +
3 files changed, 18 insertions(+), 62 deletions(-)
Index: b/drivers/ide/ide-iops.c
===================================================================
--- a/drivers/ide/ide-iops.c
+++ b/drivers/ide/ide-iops.c
@@ -289,65 +289,19 @@ no_80w:
int ide_driveid_update(ide_drive_t *drive)
{
- ide_hwif_t *hwif = drive->hwif;
- const struct ide_tp_ops *tp_ops = hwif->tp_ops;
u16 *id;
- unsigned long flags;
- int use_altstatus = 0, rc;
- u8 a, uninitialized_var(s);
+ int rc;
id = kmalloc(SECTOR_SIZE, GFP_ATOMIC);
if (id == NULL)
return 0;
- /*
- * Re-read drive->id for possible DMA mode
- * change (copied from ide-probe.c)
- */
-
SELECT_MASK(drive, 1);
- tp_ops->set_irq(hwif, 0);
- msleep(50);
-
- if (hwif->io_ports.ctl_addr &&
- (hwif->host_flags & IDE_HFLAG_BROKEN_ALTSTATUS) == 0) {
- a = tp_ops->read_altstatus(hwif);
- s = tp_ops->read_status(hwif);
- if ((a ^ s) & ~ATA_IDX)
- /* ancient Seagate drives, broken interfaces */
- printk(KERN_INFO "%s: probing with STATUS(0x%02x) "
- "instead of ALTSTATUS(0x%02x)\n",
- drive->name, s, a);
- else
- /* use non-intrusive polling */
- use_altstatus = 1;
- }
-
- tp_ops->exec_command(hwif, ATA_CMD_ID_ATA);
-
- if (ide_busy_sleep(hwif, WAIT_WORSTCASE / 2, use_altstatus)) {
- rc = 1;
- goto out_err;
- }
-
- msleep(50); /* wait for IRQ and ATA_DRQ */
-
- s = tp_ops->read_status(hwif);
+ rc = ide_dev_read_id(drive, ATA_CMD_ID_ATA, id);
+ SELECT_MASK(drive, 0);
- if (!OK_STAT(s, ATA_DRQ, BAD_R_STAT)) {
- rc = 2;
+ if (rc)
goto out_err;
- }
-
- local_irq_save(flags);
- tp_ops->input_data(drive, NULL, id, SECTOR_SIZE);
- local_irq_restore(flags);
-
- (void)tp_ops->read_status(hwif); /* clear drive IRQ */
-
- ide_fix_driveid(id);
-
- SELECT_MASK(drive, 0);
drive->id[ATA_ID_UDMA_MODES] = id[ATA_ID_UDMA_MODES];
drive->id[ATA_ID_MWDMA_MODES] = id[ATA_ID_MWDMA_MODES];
Index: b/drivers/ide/ide-probe.c
===================================================================
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -181,16 +181,16 @@ static void ide_classify_atapi_dev(ide_d
* do_identify - identify a drive
* @drive: drive to identify
* @cmd: command used
+ * @id: buffer for IDENTIFY data
*
* Called when we have issued a drive identify command to
* read and parse the results. This function is run with
* interrupts disabled.
*/
-static void do_identify(ide_drive_t *drive, u8 cmd)
+static void do_identify(ide_drive_t *drive, u8 cmd, u16 *id)
{
ide_hwif_t *hwif = drive->hwif;
- u16 *id = drive->id;
char *m = (char *)&id[ATA_ID_PROD];
unsigned long flags;
int bswap = 1;
@@ -240,19 +240,19 @@ err_misc:
}
/**
- * try_to_identify - send ATA/ATAPI identify
+ * ide_dev_read_id - send ATA/ATAPI IDENTIFY command
* @drive: drive to identify
* @cmd: command to use
+ * @id: buffer for IDENTIFY data
*
- * try_to_identify() sends an ATA(PI) IDENTIFY request to a drive
- * and waits for a response.
+ * Sends an ATA(PI) IDENTIFY request to a drive and waits for a response.
*
* Returns: 0 device was identified
* 1 device timed-out (no response to identify request)
* 2 device aborted the command (refused to identify itself)
*/
-static int try_to_identify(ide_drive_t *drive, u8 cmd)
+int ide_dev_read_id(ide_drive_t *drive, u8 cmd, u16 *id)
{
ide_hwif_t *hwif = drive->hwif;
struct ide_io_ports *io_ports = &hwif->io_ports;
@@ -312,7 +312,7 @@ static int try_to_identify(ide_drive_t *
if (OK_STAT(s, ATA_DRQ, BAD_R_STAT)) {
/* drive returned ID */
- do_identify(drive, cmd);
+ do_identify(drive, cmd, id);
/* drive responded with ID */
rc = 0;
/* clear drive IRQ */
@@ -378,6 +378,7 @@ static int do_probe (ide_drive_t *drive,
{
ide_hwif_t *hwif = drive->hwif;
const struct ide_tp_ops *tp_ops = hwif->tp_ops;
+ u16 *id = drive->id;
int rc;
u8 present = !!(drive->dev_flags & IDE_DFLAG_PRESENT), stat;
@@ -413,11 +414,10 @@ static int do_probe (ide_drive_t *drive,
if (OK_STAT(stat, ATA_DRDY, ATA_BUSY) ||
present || cmd == ATA_CMD_ID_ATAPI) {
- /* send cmd and wait */
- if ((rc = try_to_identify(drive, cmd))) {
+ rc = ide_dev_read_id(drive, cmd, id);
+ if (rc)
/* failed: try again */
- rc = try_to_identify(drive,cmd);
- }
+ rc = ide_dev_read_id(drive, cmd, id);
stat = tp_ops->read_status(hwif);
@@ -432,7 +432,7 @@ static int do_probe (ide_drive_t *drive,
msleep(50);
tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
(void)ide_busy_sleep(hwif, WAIT_WORSTCASE, 0);
- rc = try_to_identify(drive, cmd);
+ rc = ide_dev_read_id(drive, cmd, id);
}
/* ensure drive IRQ is clear */
Index: b/include/linux/ide.h
===================================================================
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -1233,6 +1233,8 @@ int ide_no_data_taskfile(ide_drive_t *,
int ide_taskfile_ioctl(ide_drive_t *, unsigned int, unsigned long);
+int ide_dev_read_id(ide_drive_t *, u8, u16 *);
+
extern int ide_driveid_update(ide_drive_t *);
extern int ide_config_drive_speed(ide_drive_t *, u8);
extern u8 eighty_ninty_three (ide_drive_t *);
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-01-22 14:18 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-22 14:18 [PATCH 0/8] ide: unify code for reading device identify data Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 1/8] ide: fix kmalloc() failure handling in ide_driveid_update() Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 2/8] ide: propagate AltStatus workarounds to ide_driveid_update() Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 3/8] ide: shorten timeout value in ide_driveid_update() Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 4/8] ide: remove broken EXABYTENEST support Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 5/8] ide: classify device type in do_probe() Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 6/8] ide: sanitize SELECT_MASK() usage in ide_driveid_update() Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 7/8] ide: clear drive IRQ after re-enabling local IRQs " Bartlomiej Zolnierkiewicz
2009-01-22 14:18 ` [PATCH 8/8] ide: use try_to_identify() " Bartlomiej Zolnierkiewicz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).