From: Tejun Heo <htejun@gmail.com>
To: jgarzik@pobox.com, linux-ide@vger.kernel.org
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 2/4] libata: separate out ata_dev_configure()
Date: Wed, 1 Mar 2006 16:09:35 +0900 [thread overview]
Message-ID: <1141196975603-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <11411969752304-git-send-email-htejun@gmail.com>
Separate out ata_dev_configure() from ata_dev_identify() such that
ata_dev_configure() only configures @dev according to passed in @id.
The function now does not disable device on failure, it just returns
appropirate error code.
As this change leaves ata_dev_identify() with only reading ID, calling
configure and disabling devices according to the results, this patch
also kills ata_dev_identify() and inlines the logic into
ata_bus_probe().
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
drivers/scsi/libata-core.c | 78 ++++++++++++++++++++++----------------------
1 files changed, 39 insertions(+), 39 deletions(-)
9e8f99c18ddb9615403cdeca438a2d3c26b012fb
diff --git a/drivers/scsi/libata-core.c b/drivers/scsi/libata-core.c
index a630cda..dcc6b06 100644
--- a/drivers/scsi/libata-core.c
+++ b/drivers/scsi/libata-core.c
@@ -1050,45 +1050,31 @@ static int ata_dev_read_id(struct ata_po
}
/**
- * ata_dev_identify - obtain IDENTIFY x DEVICE page
- * @ap: port on which device we wish to probe resides
- * @device: device bus address, starting at zero
+ * ata_dev_configure - Configure the specified ATA/ATAPI device
+ * @ap: Port on which target device resides
+ * @dev: Target device to configure
*
- * Following bus reset, we issue the IDENTIFY [PACKET] DEVICE
- * command, and read back the 512-byte device information page.
- * The device information page is fed to us via the standard
- * PIO-IN protocol, but we hand-code it here. (TODO: investigate
- * using standard PIO-IN paths)
- *
- * After reading the device information page, we use several
- * bits of information from it to initialize data structures
- * that will be used during the lifetime of the ata_device.
- * Other data from the info page is used to disqualify certain
- * older ATA devices we do not wish to support.
+ * Configure @dev according to @dev->id. Generic and low-level
+ * driver specific fixups are also applied.
*
* LOCKING:
- * Inherited from caller. Some functions called by this function
- * obtain the host_set lock.
+ * Kernel thread context (may sleep)
+ *
+ * RETURNS:
+ * 0 on success, -errno otherwise
*/
-
-static void ata_dev_identify(struct ata_port *ap, unsigned int device)
+static int ata_dev_configure(struct ata_port *ap, struct ata_device *dev)
{
- struct ata_device *dev = &ap->device[device];
unsigned long xfer_modes;
int i, rc;
if (!ata_dev_present(dev)) {
DPRINTK("ENTER/EXIT (host %u, dev %u) -- nodev\n",
- ap->id, device);
- return;
+ ap->id, dev->devno);
+ return 0;
}
- DPRINTK("ENTER, host %u, dev %u\n", ap->id, device);
-
- WARN_ON(dev->id != NULL);
- rc = ata_dev_read_id(ap, dev, &dev->class, 1, &dev->id);
- if (rc)
- goto err_out;
+ DPRINTK("ENTER, host %u, dev %u\n", ap->id, dev->devno);
/*
* common ATA, ATAPI feature tests
@@ -1097,6 +1083,7 @@ static void ata_dev_identify(struct ata_
/* we require DMA support (bits 8 of word 49) */
if (!ata_id_has_dma(dev->id)) {
printk(KERN_DEBUG "ata%u: no dma\n", ap->id);
+ rc = -EINVAL;
goto err_out_nosup;
}
@@ -1121,12 +1108,12 @@ static void ata_dev_identify(struct ata_
/* print device info to dmesg */
printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors:%s\n",
- ap->id, device,
+ ap->id, dev->devno,
ata_id_major_version(dev->id),
ata_mode_string(xfer_modes),
(unsigned long long)dev->n_sectors,
dev->flags & ATA_DFLAG_LBA48 ? " LBA48" : " LBA");
- } else {
+ } else {
/* CHS */
/* Default translation */
@@ -1143,7 +1130,7 @@ static void ata_dev_identify(struct ata_
/* print device info to dmesg */
printk(KERN_INFO "ata%u: dev %u ATA-%d, max %s, %Lu sectors: CHS %d/%d/%d\n",
- ap->id, device,
+ ap->id, dev->devno,
ata_id_major_version(dev->id),
ata_mode_string(xfer_modes),
(unsigned long long)dev->n_sectors,
@@ -1159,13 +1146,14 @@ static void ata_dev_identify(struct ata_
rc = atapi_cdb_len(dev->id);
if ((rc < 12) || (rc > ATAPI_CDB_LEN)) {
printk(KERN_WARNING "ata%u: unsupported CDB len\n", ap->id);
+ rc = -EINVAL;
goto err_out_nosup;
}
dev->cdb_len = (unsigned int) rc;
/* print device info to dmesg */
printk(KERN_INFO "ata%u: dev %u ATAPI, max %s\n",
- ap->id, device,
+ ap->id, dev->devno,
ata_mode_string(xfer_modes));
}
@@ -1176,14 +1164,13 @@ static void ata_dev_identify(struct ata_
ap->device[i].cdb_len);
DPRINTK("EXIT, drv_stat = 0x%x\n", ata_chk_status(ap));
- return;
+ return 0;
err_out_nosup:
printk(KERN_WARNING "ata%u: dev %u not supported, ignoring\n",
- ap->id, device);
-err_out:
- dev->class++; /* converts ATA_DEV_xxx into ATA_DEV_xxx_UNSUP */
+ ap->id, dev->devno);
DPRINTK("EXIT, err\n");
+ return rc;
}
@@ -1259,11 +1246,24 @@ static int ata_bus_probe(struct ata_port
goto err_out;
for (i = 0; i < ATA_MAX_DEVICES; i++) {
- ata_dev_identify(ap, i);
- if (ata_dev_present(&ap->device[i])) {
- found = 1;
- ata_dev_config(ap,i);
+ struct ata_device *dev = &ap->device[i];
+
+ if (!ata_dev_present(dev))
+ continue;
+
+ WARN_ON(dev->id != NULL);
+ if (ata_dev_read_id(ap, dev, &dev->class, 1, &dev->id)) {
+ dev->class = ATA_DEV_NONE;
+ continue;
}
+
+ if (ata_dev_configure(ap, dev)) {
+ dev->class++; /* disable device */
+ continue;
+ }
+
+ ata_dev_config(ap, i);
+ found = 1;
}
if ((!found) || (ap->flags & ATA_FLAG_PORT_DISABLED))
--
1.2.1
next prev parent reply other threads:[~2006-03-01 7:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-01 7:09 [PATCHSET] libata: reorganize ata_dev_identify(), take 3 Tejun Heo
2006-03-01 7:09 ` Tejun Heo [this message]
2006-03-01 7:09 ` [PATCH 1/4] libata: convert dev->id to pointer Tejun Heo
2006-03-03 22:31 ` Jeff Garzik
2006-03-01 7:09 ` [PATCH 3/4] libata: fold ata_dev_config() into ata_dev_configure() Tejun Heo
2006-03-01 7:09 ` [PATCH 4/4] libata: reorganize ata_bus_probe() Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1141196975603-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=jgarzik@pobox.com \
--cc=linux-ide@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).