it821x: remove DECLARE_ITE_DEV() macro
[pandora-kernel.git] / drivers / ide / pci / it821x.c
index cbf6472..a3d8959 100644 (file)
@@ -534,8 +534,9 @@ static struct ide_dma_ops it821x_pass_through_dma_ops = {
 static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
 {
        struct pci_dev *dev = to_pci_dev(hwif->dev);
-       struct it821x_dev **itdevs = (struct it821x_dev **)pci_get_drvdata(dev);
-       struct it821x_dev *idev = itdevs[hwif->channel];
+       struct ide_host *host = pci_get_drvdata(dev);
+       struct it821x_dev *itdevs = host->host_priv;
+       struct it821x_dev *idev = itdevs + hwif->channel;
        u8 conf;
 
        ide_set_hwifdata(hwif, idev);
@@ -568,7 +569,8 @@ static void __devinit init_hwif_it821x(ide_hwif_t *hwif)
                idev->timing10 = 1;
                hwif->host_flags |= IDE_HFLAG_NO_ATAPI_DMA;
                if (idev->smart == 0)
-                       printk(KERN_WARNING "it821x: Revision 0x10, workarounds activated.\n");
+                       printk(KERN_WARNING "it821x %s: revision 0x10, "
+                               "workarounds activated\n", pci_name(dev));
        }
 
        if (idev->smart == 0) {
@@ -608,11 +610,13 @@ static unsigned int __devinit init_chipset_it821x(struct pci_dev *dev, const cha
 
        /* Force the card into bypass mode if so requested */
        if (it8212_noraid) {
-               printk(KERN_INFO "it8212: forcing bypass mode.\n");
+               printk(KERN_INFO "it821x %s: forcing bypass mode\n",
+                       pci_name(dev));
                it8212_disable_raid(dev);
        }
        pci_read_config_byte(dev, 0x50, &conf);
-       printk(KERN_INFO "it821x: controller in %s mode.\n", mode[conf & 1]);
+       printk(KERN_INFO "it821x %s: controller in %s mode\n",
+               pci_name(dev), mode[conf & 1]);
        return 0;
 }
 
@@ -624,17 +628,12 @@ static const struct ide_port_ops it821x_port_ops = {
        .cable_detect           = it821x_cable_detect,
 };
 
-#define DECLARE_ITE_DEV(name_str)                      \
-       {                                               \
-               .name           = name_str,             \
-               .init_chipset   = init_chipset_it821x,  \
-               .init_hwif      = init_hwif_it821x,     \
-               .port_ops       = &it821x_port_ops,     \
-               .pio_mask       = ATA_PIO4,             \
-       }
-
-static const struct ide_port_info it821x_chipsets[] __devinitdata = {
-       /* 0 */ DECLARE_ITE_DEV("IT8212"),
+static const struct ide_port_info it821x_chipset __devinitdata = {
+       .name           = "IT821X",
+       .init_chipset   = init_chipset_it821x,
+       .init_hwif      = init_hwif_it821x,
+       .port_ops       = &it821x_port_ops,
+       .pio_mask       = ATA_PIO4,
 };
 
 /**
@@ -648,23 +647,29 @@ 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)
 {
-       struct it821x_dev *itdevs[2] = { NULL, NULL} , *itdev;
-       unsigned int i;
-
-       for (i = 0; i < 2; i++) {
-               itdev = kzalloc(sizeof(*itdev), GFP_KERNEL);
-               if (itdev == NULL) {
-                       kfree(itdevs[0]);
-                       printk(KERN_ERR "it821x: out of memory\n");
-                       return -ENOMEM;
-               }
+       struct it821x_dev *itdevs;
+       int rc;
 
-               itdevs[i] = itdev;
+       itdevs = kzalloc(2 * sizeof(*itdevs), GFP_KERNEL);
+       if (itdevs == NULL) {
+               printk(KERN_ERR "it821x %s: out of memory\n", pci_name(dev));
+               return -ENOMEM;
        }
 
-       pci_set_drvdata(dev, itdevs);
+       rc = ide_pci_init_one(dev, &it821x_chipset, itdevs);
+       if (rc)
+               kfree(itdevs);
+
+       return rc;
+}
+
+static void __devexit it821x_remove(struct pci_dev *dev)
+{
+       struct ide_host *host = pci_get_drvdata(dev);
+       struct it821x_dev *itdevs = host->host_priv;
 
-       return ide_setup_pci_device(dev, &it821x_chipsets[id->driver_data]);
+       ide_pci_remove(dev);
+       kfree(itdevs);
 }
 
 static const struct pci_device_id it821x_pci_tbl[] = {
@@ -679,6 +684,7 @@ static struct pci_driver driver = {
        .name           = "ITE821x IDE",
        .id_table       = it821x_pci_tbl,
        .probe          = it821x_init_one,
+       .remove         = it821x_remove,
 };
 
 static int __init it821x_ide_init(void)
@@ -686,7 +692,13 @@ static int __init it821x_ide_init(void)
        return ide_pci_register_driver(&driver);
 }
 
+static void __exit it821x_ide_exit(void)
+{
+       pci_unregister_driver(&driver);
+}
+
 module_init(it821x_ide_init);
+module_exit(it821x_ide_exit);
 
 module_param_named(noraid, it8212_noraid, int, S_IRUGO);
 MODULE_PARM_DESC(noraid, "Force card into bypass mode");