Commit 4911487a authored by Tejun Heo's avatar Tejun Heo Committed by Jeff Garzik

libata: allocate ap separately from shost

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: default avatarTejun Heo <htejun@gmail.com>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent bf335542
...@@ -5792,13 +5792,18 @@ static struct ata_port * ata_port_add(const struct ata_probe_ent *ent, ...@@ -5792,13 +5792,18 @@ static struct ata_port * ata_port_add(const struct ata_probe_ent *ent,
return NULL; return NULL;
} }
shost = scsi_host_alloc(ent->sht, sizeof(struct ata_port)); ap = kzalloc(sizeof(struct ata_port), GFP_KERNEL);
if (!shost) if (!ap)
return NULL; 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(ap, host, ent, port_no);
ata_port_init_shost(ap, shost); ata_port_init_shost(ap, shost);
...@@ -5824,9 +5829,13 @@ static void ata_host_release(struct device *gendev, void *res) ...@@ -5824,9 +5829,13 @@ static void ata_host_release(struct device *gendev, void *res)
for (i = 0; i < host->n_ports; i++) { for (i = 0; i < host->n_ports; i++) {
struct ata_port *ap = host->ports[i]; struct ata_port *ap = host->ports[i];
if (ap) if (!ap)
continue;
if (ap->scsi_host)
scsi_host_put(ap->scsi_host); scsi_host_put(ap->scsi_host);
kfree(ap);
host->ports[i] = NULL; host->ports[i] = NULL;
} }
......
...@@ -1231,7 +1231,7 @@ static inline void ata_pad_free(struct ata_port *ap, struct device *dev) ...@@ -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) 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__ */ #endif /* __LINUX_LIBATA_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment