it821x: convert to use ->host_priv
While at it: * Allocate both struct it821x_dev instances at once. * Don't leak itdevs on ide_pci_init_one() failure. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
This commit is contained in:
@@ -534,8 +534,9 @@ static struct ide_dma_ops it821x_pass_through_dma_ops = {
|
|||||||
static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
|
static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
|
||||||
{
|
{
|
||||||
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
struct pci_dev *dev = to_pci_dev(hwif->dev);
|
||||||
struct it821x_dev **itdevs = (struct it821x_dev **)pci_get_drvdata(dev);
|
struct ide_host *host = pci_get_drvdata(dev);
|
||||||
struct it821x_dev *idev = itdevs[hwif->channel];
|
struct it821x_dev *itdevs = host->host_priv;
|
||||||
|
struct it821x_dev *idev = itdevs + hwif->channel;
|
||||||
u8 conf;
|
u8 conf;
|
||||||
|
|
||||||
ide_set_hwifdata(hwif, idev);
|
ide_set_hwifdata(hwif, idev);
|
||||||
@@ -648,23 +649,20 @@ static const struct ide_port_info it821x_chipsets[] __devinitdata = {
|
|||||||
|
|
||||||
static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
|
static int __devinit it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
|
||||||
{
|
{
|
||||||
struct it821x_dev *itdevs[2] = { NULL, NULL} , *itdev;
|
struct it821x_dev *itdevs;
|
||||||
unsigned int i;
|
int rc;
|
||||||
|
|
||||||
for (i = 0; i < 2; i++) {
|
itdevs = kzalloc(2 * sizeof(*itdevs), GFP_KERNEL);
|
||||||
itdev = kzalloc(sizeof(*itdev), GFP_KERNEL);
|
if (itdevs == NULL) {
|
||||||
if (itdev == NULL) {
|
|
||||||
kfree(itdevs[0]);
|
|
||||||
printk(KERN_ERR "it821x: out of memory\n");
|
printk(KERN_ERR "it821x: out of memory\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
itdevs[i] = itdev;
|
rc = ide_pci_init_one(dev, &it821x_chipsets[id->driver_data], itdevs);
|
||||||
}
|
if (rc)
|
||||||
|
kfree(itdevs);
|
||||||
|
|
||||||
pci_set_drvdata(dev, itdevs);
|
return rc;
|
||||||
|
|
||||||
return ide_pci_init_one(dev, &it821x_chipsets[id->driver_data], NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pci_device_id it821x_pci_tbl[] = {
|
static const struct pci_device_id it821x_pci_tbl[] = {
|
||||||
|
Reference in New Issue
Block a user