From: Albert Lee <albertcc@tw.ibm.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: IDE Linux <linux-ide@vger.kernel.org>,
Tejun Heo <htejun@gmail.com>, Doug Maxey <dwm@maxeymade.com>
Subject: [PATCH 2/5] libata-dev: Make dev->id dynamically allocated
Date: Fri, 10 Mar 2006 23:43:13 +0800 [thread overview]
Message-ID: <44119E91.1080109@tw.ibm.com> (raw)
In-Reply-To: <44119BC9.8080502@tw.ibm.com>
Make dev->id dynamically allocated
Signed-off-by: Albert Lee <albertcc@tw.ibm.com>
---
This is respin of Tejun's patch, too.
Maybe git can pull it from upstream easily?
--- catchup0/include/linux/libata.h 2006-03-10 17:25:48.000000000 +0800
+++ catchup1/include/linux/libata.h 2006-03-10 17:40:50.000000000 +0800
@@ -344,7 +344,7 @@ struct ata_device {
unsigned long flags; /* ATA_DFLAG_xxx */
unsigned int class; /* ATA_DEV_xxx */
unsigned int devno; /* 0 or 1 */
- u16 id[ATA_ID_WORDS]; /* IDENTIFY xxx DEVICE data */
+ u16 *id; /* IDENTIFY xxx DEVICE data */
u8 pio_mode;
u8 dma_mode;
u8 xfer_mode;
@@ -648,10 +648,14 @@ static inline unsigned int ata_tag_valid
return (tag < ATA_MAX_QUEUE) ? 1 : 0;
}
+static inline unsigned int ata_class_present(unsigned int class)
+{
+ return class == ATA_DEV_ATA || class == ATA_DEV_ATAPI;
+}
+
static inline unsigned int ata_dev_present(const struct ata_device *dev)
{
- return ((dev->class == ATA_DEV_ATA) ||
- (dev->class == ATA_DEV_ATAPI));
+ return ata_class_present(dev->class);
}
static inline u8 ata_chk_status(struct ata_port *ap)
--- catchup0/drivers/scsi/libata-core.c 2006-03-10 18:18:04.000000000 +0800
+++ catchup1/drivers/scsi/libata-core.c 2006-03-10 18:19:11.000000000 +0800
@@ -904,7 +904,7 @@ unsigned int ata_pio_need_iordy(const st
* @dev: target device
* @p_class: pointer to class of the target device (may be changed)
* @post_reset: is this read ID post-reset?
- * @id: buffer to fill IDENTIFY page into
+ * @p_id: read IDENTIFY page (newly allocated)
*
* Read ID data from the specified device. ATA_CMD_ID_ATA is
* performed on ATA devices and ATA_CMD_ID_ATAPI on ATAPI
@@ -919,12 +919,13 @@ unsigned int ata_pio_need_iordy(const st
* 0 on success, -errno otherwise.
*/
static int ata_dev_read_id(struct ata_port *ap, struct ata_device *dev,
- unsigned int *p_class, int post_reset, u16 *id)
+ unsigned int *p_class, int post_reset, u16 **p_id)
{
unsigned int class = *p_class;
unsigned int using_edd;
struct ata_taskfile tf;
unsigned int err_mask = 0;
+ u16 *id;
const char *reason;
int rc;
@@ -938,6 +939,13 @@ static int ata_dev_read_id(struct ata_po
ata_dev_select(ap, dev->devno, 1, 1); /* select device 0/1 */
+ id = kmalloc(sizeof(id[0]) * ATA_ID_WORDS, GFP_KERNEL);
+ if (id == NULL) {
+ rc = -ENOMEM;
+ reason = "out of memory";
+ goto err_out;
+ }
+
retry:
ata_tf_init(ap, &tf, dev->devno);
@@ -1028,11 +1036,13 @@ static int ata_dev_read_id(struct ata_po
}
*p_class = class;
+ *p_id = id;
return 0;
err_out:
printk(KERN_WARNING "ata%u: dev %u failed to IDENTIFY (%s)\n",
ap->id, dev->devno, reason);
+ kfree(id);
return rc;
}
@@ -5008,11 +5018,14 @@ void ata_host_set_remove(struct ata_host
int ata_scsi_release(struct Scsi_Host *host)
{
struct ata_port *ap = (struct ata_port *) &host->hostdata[0];
+ int i;
DPRINTK("ENTER\n");
ap->ops->port_disable(ap);
ata_host_remove(ap, 0);
+ for (i = 0; i < ATA_MAX_DEVICES; i++)
+ kfree(ap->device[i].id);
DPRINTK("EXIT\n");
return 1;
next prev parent reply other threads:[~2006-03-10 15:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-10 15:31 [PATCH 0/5] libata-dev: irq-pio minor fixes Albert Lee
2006-03-10 15:38 ` [PATCH 1/5] libata-dev: Add back missing dev->cdb_len = 16 Albert Lee
2006-03-10 15:43 ` Albert Lee [this message]
2006-03-10 15:55 ` [PATCH 5/5] libata-dev: Add back irq-pio patches, etc Albert Lee
2006-03-12 0:27 ` [PATCH 0/5] libata-dev: irq-pio minor fixes Jeff Garzik
2006-03-13 7:12 ` Albert Lee
2006-03-13 7:17 ` Tejun Heo
2006-03-13 7:20 ` [PATCH 0/3] libata-dev: irq-pio minor fixes (respin) Albert Lee
2006-03-13 7:25 ` [PATCH 1/3] libata-dev: Remove trailing whitespaces Albert Lee
2006-03-13 7:48 ` Jeff Garzik
2006-03-13 7:27 ` [PATCH 2/3] libata-dev: Fix merge problem with upstream Albert Lee
2006-03-13 7:28 ` [PATCH 3/3] libata-dev: Remove atapi_packet_task() Albert Lee
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=44119E91.1080109@tw.ibm.com \
--to=albertcc@tw.ibm.com \
--cc=albertl@mail.com \
--cc=dwm@maxeymade.com \
--cc=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).