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);
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;
}
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__ */