From: Tejun Heo <htejun@gmail.com>
To: jeff@garzik.org, alan@lxorguk.ukuu.org.uk,
linux-ide@vger.kernel.org, brking@linux.vnet.ibm.com
Cc: Tejun Heo <htejun@gmail.com>
Subject: [PATCH 01/12] libata: allocate ap separately from shost
Date: Wed, 11 Apr 2007 15:42:04 +0900 [thread overview]
Message-ID: <11762737243751-git-send-email-htejun@gmail.com> (raw)
In-Reply-To: <1176273724198-git-send-email-htejun@gmail.com>
Don't embed ap inside shost. Allocate it separately and point it back
from shosts's hostdata. This makes port allocation more flexible and
allows regular ATA and SAS share host alloc/init paths.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
drivers/ata/libata-core.c | 19 ++++++++++++++-----
include/linux/libata.h | 2 +-
2 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 735f0b0..542e9ea 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -5782,13 +5782,18 @@ static struct ata_port * ata_port_add(const struct ata_probe_ent *ent,
return NULL;
}
- shost = scsi_host_alloc(ent->sht, sizeof(struct ata_port));
- if (!shost)
+ ap = kzalloc(sizeof(struct ata_port), GFP_KERNEL);
+ if (!ap)
return NULL;
- shost->transportt = &ata_scsi_transport_template;
+ shost = scsi_host_alloc(ent->sht, sizeof(struct ata_port *));
+ if (!shost) {
+ kfree(ap);
+ return NULL;
+ }
- ap = ata_shost_to_port(shost);
+ *(struct ata_port **)&shost->hostdata[0] = ap;
+ shost->transportt = &ata_scsi_transport_template;
ata_port_init(ap, host, ent, port_no);
ata_port_init_shost(ap, shost);
@@ -5814,9 +5819,13 @@ static void ata_host_release(struct device *gendev, void *res)
for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i];
- if (ap)
+ if (!ap)
+ continue;
+
+ if (ap->scsi_host)
scsi_host_put(ap->scsi_host);
+ kfree(ap);
host->ports[i] = NULL;
}
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 12237d4..ced9dd5 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1231,7 +1231,7 @@ static inline void ata_pad_free(struct ata_port *ap, struct device *dev)
static inline struct ata_port *ata_shost_to_port(struct Scsi_Host *host)
{
- return (struct ata_port *) &host->hostdata[0];
+ return *(struct ata_port **)&host->hostdata[0];
}
#endif /* __LINUX_LIBATA_H__ */
--
1.5.0.3
next prev parent reply other threads:[~2007-04-11 6:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-11 6:42 [PATCHSET] libata: implement new initialization model, take #4 Tejun Heo
2007-04-11 6:42 ` [PATCH 03/12] libata: separate out ata_host_alloc() and ata_host_register() Tejun Heo
2007-04-11 6:42 ` Tejun Heo [this message]
2007-04-11 6:42 ` [PATCH 02/12] libata: separate out ata_host_start() Tejun Heo
2007-04-11 6:42 ` [PATCH 04/12] libata: implement ata_host_alloc_pinfo() and ata_host_register() Tejun Heo
2007-04-11 6:42 ` [PATCH 12/12] libata: kill probe_ent and related helpers Tejun Heo
2007-04-11 6:42 ` [PATCH 08/12] libata: convert drivers with combined SATA/PATA ports to new init model Tejun Heo
2007-04-11 6:42 ` [PATCH 06/12] libata: convert native PCI host handling " Tejun Heo
2007-04-11 6:42 ` [PATCH 09/12] libata: convert ata_pci_init_native_mode() users " Tejun Heo
2007-04-11 6:42 ` [PATCH 10/12] libata: convert the remaining SATA drivers " Tejun Heo
2007-04-11 6:42 ` [PATCH 05/12] libata: convert legacy PCI host handling " Tejun Heo
2007-04-11 6:42 ` [PATCH 07/12] libata: add init helpers including ata_pci_prepare_native_host() Tejun Heo
2007-04-11 6:42 ` [PATCH 11/12] libata: convert the remaining PATA drivers to new init model Tejun Heo
2007-04-11 8:22 ` Alan Cox
2007-04-11 8:37 ` [PATCH 11/12 UPDATED] " Tejun Heo
[not found] <1176821046841-git-send-email-htejun@gmail.com>
2007-04-17 15:04 ` [PATCH 01/12] libata: allocate ap separately from shost Jeff Garzik
-- strict thread matches above, loose matches on Subject: below --
2007-03-09 11:15 [PATCHSET] libata: implement new initialization model, take #3 Tejun Heo
2007-03-09 11:15 ` [PATCH 01/12] libata: allocate ap separately from shost Tejun Heo
2007-03-09 15:00 ` Jeff Garzik
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=11762737243751-git-send-email-htejun@gmail.com \
--to=htejun@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=brking@linux.vnet.ibm.com \
--cc=jeff@garzik.org \
--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).