ide: add ide_proc_register_port()
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Wed, 9 May 2007 22:01:11 +0000 (00:01 +0200)
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Wed, 9 May 2007 22:01:11 +0000 (00:01 +0200)
* create_proc_ide_interfaces() tries to add /proc entries for every probed
  and initialized IDE port, replace it by ide_proc_register_port() which does
  it only for the given port (also rename destroy_proc_ide_interface() to
  ide_proc_unregister_port() for consistency)

* convert {create,destroy}_proc_ide_interface[s]() users to use new functions

* pmac driver depended on proc_ide_create() to add /proc port entries, fix it

* au1xxx-ide, swarm and cs5520 drivers depended indirectly on ide-generic
  driver (CONFIG_IDE_GENERIC=y) to add port /proc entries, fix them

* there is now no need to add /proc entries for IDE ports in proc_ide_create()
  so don't do it

* proc_ide_create() needs now to be called before drivers are probed - fix it,
  while at it make proc_ide_create() create /proc "ide" directory

Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
18 files changed:
drivers/ide/arm/icside.c
drivers/ide/arm/rapide.c
drivers/ide/ide-generic.c
drivers/ide/ide-probe.c
drivers/ide/ide-proc.c
drivers/ide/ide.c
drivers/ide/legacy/ali14xx.c
drivers/ide/legacy/dtc2278.c
drivers/ide/legacy/ht6560b.c
drivers/ide/legacy/qd65xx.c
drivers/ide/legacy/umc8672.c
drivers/ide/mips/au1xxx-ide.c
drivers/ide/mips/swarm.c
drivers/ide/pci/cs5520.c
drivers/ide/pci/sgiioc4.c
drivers/ide/ppc/pmac.c
drivers/ide/setup-pci.c
include/linux/ide.h

index f383ace2a08729024d2460ba2f0b1717a649e9ab..1fe0457243dbbcf824d8ef1f468a5ca9fe275b24 100644 (file)
@@ -591,7 +591,8 @@ icside_register_v5(struct icside_state *state, struct expansion_card *ec)
        state->hwif[0] = hwif;
 
        probe_hwif_init(hwif);
-       create_proc_ide_interfaces();
+
+       ide_proc_register_port(hwif);
 
        return 0;
 }
@@ -679,7 +680,9 @@ icside_register_v6(struct icside_state *state, struct expansion_card *ec)
 
        probe_hwif_init(hwif);
        probe_hwif_init(mate);
-       create_proc_ide_interfaces();
+
+       ide_proc_register_port(hwif);
+       ide_proc_register_port(mate);
 
        return 0;
 
index 9c6c49fdd2b14997d51d441b3ca9399cfd1d1f08..890ea3fac3c6feb80bb50f8ced8a392fe9369aed 100644 (file)
@@ -76,7 +76,7 @@ rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
                hwif->gendev.parent = &ec->dev;
                hwif->noprobe = 0;
                probe_hwif_init(hwif);
-               create_proc_ide_interfaces();
+               ide_proc_register_port(hwif);
                ecard_set_drvdata(ec, hwif);
                goto out;
        }
index 99fd56151131cb4fc92b9f2e9da5091811a37483..0f72b98d727f43ba72f4d68b2a53871ec9806bcd 100644 (file)
@@ -22,8 +22,6 @@ static int __init ide_generic_init(void)
        if (ide_hwifs[0].io_ports[IDE_DATA_OFFSET])
                ide_release_lock();     /* for atari only */
 
-       create_proc_ide_interfaces();
-
        return 0;
 }
 
index 8f15c23aa70d7eaa2e049ad7a0e2be95705886a0..3cebed77f55d27020b8be9b4331571cd80e00844 100644 (file)
@@ -1427,6 +1427,9 @@ int ideprobe_init (void)
                                }
                }
        }
+       for (index = 0; index < MAX_HWIFS; ++index)
+               if (probe[index])
+                       ide_proc_register_port(&ide_hwifs[index]);
        return 0;
 }
 
index 949a6f609d8473231aab82b9b517ee8e48823933..d50bd996ff22939a9613c6399cd9b4d932789bd4 100644 (file)
@@ -39,6 +39,8 @@
 
 #include <asm/io.h>
 
+static struct proc_dir_entry *proc_ide_root;
+
 static int proc_ide_read_imodel
        (char *page, char **start, off_t off, int count, int *eof, void *data)
 {
@@ -783,26 +785,24 @@ static ide_proc_entry_t hwif_entries[] = {
        { NULL, 0, NULL, NULL }
 };
 
-void create_proc_ide_interfaces(void)
+void ide_proc_register_port(ide_hwif_t *hwif)
 {
-       int     h;
+       if (!hwif->present)
+               return;
 
-       for (h = 0; h < MAX_HWIFS; h++) {
-               ide_hwif_t *hwif = &ide_hwifs[h];
+       if (!hwif->proc) {
+               hwif->proc = proc_mkdir(hwif->name, proc_ide_root);
 
-               if (!hwif->present)
-                       continue;
-               if (!hwif->proc) {
-                       hwif->proc = proc_mkdir(hwif->name, proc_ide_root);
-                       if (!hwif->proc)
-                               return;
-                       ide_add_proc_entries(hwif->proc, hwif_entries, hwif);
-               }
-               create_proc_ide_drives(hwif);
+               if (!hwif->proc)
+                       return;
+
+               ide_add_proc_entries(hwif->proc, hwif_entries, hwif);
        }
+
+       create_proc_ide_drives(hwif);
 }
 
-EXPORT_SYMBOL(create_proc_ide_interfaces);
+EXPORT_SYMBOL_GPL(ide_proc_register_port);
 
 #ifdef CONFIG_BLK_DEV_IDEPCI
 void ide_pci_create_host_proc(const char *name, get_info_t *get_info)
@@ -813,7 +813,7 @@ void ide_pci_create_host_proc(const char *name, get_info_t *get_info)
 EXPORT_SYMBOL_GPL(ide_pci_create_host_proc);
 #endif
 
-void destroy_proc_ide_interface(ide_hwif_t *hwif)
+void ide_proc_unregister_port(ide_hwif_t *hwif)
 {
        if (hwif->proc) {
                destroy_proc_ide_drives(hwif);
@@ -860,11 +860,11 @@ void proc_ide_create(void)
 {
        struct proc_dir_entry *entry;
 
+       proc_ide_root = proc_mkdir("ide", NULL);
+
        if (!proc_ide_root)
                return;
 
-       create_proc_ide_interfaces();
-
        entry = create_proc_entry("drivers", 0, proc_ide_root);
        if (entry)
                entry->proc_fops = &ide_drivers_operations;
index 0fc532850bbef92fad9085e1d8b03029f88ddc5f..038f2610e73401b9f945feb2dc8c3d97d0c9b94e 100644 (file)
@@ -347,10 +347,6 @@ static int ide_system_bus_speed(void)
        return system_bus_speed;
 }
 
-#ifdef CONFIG_IDE_PROC_FS
-struct proc_dir_entry *proc_ide_root;
-#endif
-
 static struct resource* hwif_request_region(ide_hwif_t *hwif,
                                            unsigned long addr, int num)
 {
@@ -594,7 +590,7 @@ void ide_unregister(unsigned int index)
 
        spin_unlock_irq(&ide_lock);
 
-       destroy_proc_ide_interface(hwif);
+       ide_proc_unregister_port(hwif);
 
        hwgroup = hwif->hwgroup;
        /*
@@ -799,7 +795,7 @@ found:
 
        if (!initializing) {
                probe_hwif_init_with_fixup(hwif, fixup);
-               create_proc_ide_interfaces();
+               ide_proc_register_port(hwif);
        }
 
        if (hwifp)
@@ -1794,9 +1790,7 @@ static int __init ide_init(void)
 
        init_ide_data();
 
-#ifdef CONFIG_IDE_PROC_FS
-       proc_ide_root = proc_mkdir("ide", NULL);
-#endif
+       proc_ide_create();
 
 #ifdef CONFIG_BLK_DEV_ALI14XX
        if (probe_ali14xx)
@@ -1822,8 +1816,6 @@ static int __init ide_init(void)
        /* Probe for special PCI and other "known" interface chipsets. */
        probe_for_hwifs();
 
-       proc_ide_create();
-
        return 0;
 }
 
index 91961aa030474fa02057f8ed2e8dd270b69f87d3..df17ed68c0bcb393635e2aeac319d1d119d8854b 100644 (file)
@@ -223,7 +223,8 @@ static int __init ali14xx_probe(void)
        probe_hwif_init(hwif);
        probe_hwif_init(mate);
 
-       create_proc_ide_interfaces();
+       ide_proc_register_port(hwif);
+       ide_proc_register_port(mate);
 
        return 0;
 }
index 0219ffa64db663fae60e8bc3e994e1d76bd048c7..36a3f0ac61628767f8ca555d9a476a1101b89bb9 100644 (file)
@@ -138,7 +138,8 @@ static int __init dtc2278_probe(void)
        probe_hwif_init(hwif);
        probe_hwif_init(mate);
 
-       create_proc_ide_interfaces();
+       ide_proc_register_port(hwif);
+       ide_proc_register_port(mate);
 
        return 0;
 }
index a2832643c522f0cc6805ca497cde92e32fb5fbbc..c8f353b1296f9ca84c50bb8e1f127f2b2e3f3bd3 100644 (file)
@@ -357,7 +357,8 @@ int __init ht6560b_init(void)
        probe_hwif_init(hwif);
        probe_hwif_init(mate);
 
-       create_proc_ide_interfaces();
+       ide_proc_register_port(hwif);
+       ide_proc_register_port(mate);
 
        return 0;
 
index 2fb8f50f1293e66df0008c9d0d44b4d6f39e43f4..d1414a75b52371d707aa5375ec5ee4b1221e2ca5 100644 (file)
@@ -427,7 +427,7 @@ static int __init qd_probe(int base)
                qd_setup(hwif, base, config, QD6500_DEF_DATA, QD6500_DEF_DATA,
                         &qd6500_tune_drive);
 
-               create_proc_ide_interfaces();
+               ide_proc_register_port(hwif);
 
                return 1;
        }
@@ -459,7 +459,7 @@ static int __init qd_probe(int base)
                                 &qd6580_tune_drive);
                        qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT);
 
-                       create_proc_ide_interfaces();
+                       ide_proc_register_port(hwif);
 
                        return 1;
                } else {
@@ -479,7 +479,8 @@ static int __init qd_probe(int base)
                                 &qd6580_tune_drive);
                        qd_write_reg(QD_DEF_CONTR,QD_CONTROL_PORT);
 
-                       create_proc_ide_interfaces();
+                       ide_proc_register_port(hwif);
+                       ide_proc_register_port(mate);
 
                        return 0; /* no other qd65xx possible */
                }
index ca7974455578005242b4ec79bdcbffae174835c7..ddc403a0bd829dee9fef1c0fd4ca2f2afb3ce4c9 100644 (file)
@@ -160,7 +160,8 @@ static int __init umc8672_probe(void)
        probe_hwif_init(hwif);
        probe_hwif_init(mate);
 
-       create_proc_ide_interfaces();
+       ide_proc_register_port(hwif);
+       ide_proc_register_port(mate);
 
        return 0;
 }
index d54d9fe92a7d548324b38809d360fe1c280722fa..ca95e990862ebdf36df33f936e47709b8d1ace6a 100644 (file)
@@ -760,6 +760,9 @@ static int au_ide_probe(struct device *dev)
 #endif
 
        probe_hwif_init(hwif);
+
+       ide_proc_register_port(hwif);
+
        dev_set_drvdata(dev, hwif);
 
        printk(KERN_INFO "Au1xxx IDE(builtin) configured for %s\n", mode );
index 81fa06851b27dadfd5c4d34c58aa38b6a276c5f4..6e935d7c63fd987858b256ea0c786b02d737821f 100644 (file)
@@ -129,6 +129,9 @@ static int __devinit swarm_ide_probe(struct device *dev)
        hwif->irq = hwif->hw.irq;
 
        probe_hwif_init(hwif);
+
+       ide_proc_register_port(hwif);
+
        dev_set_drvdata(dev, hwif);
 
        return 0;
index 400859a839f7dcd9b1fb4c25b1796a98e87a12cb..3b88a3a561167c3986b8a0815c1b3161fec8ba7f 100644 (file)
@@ -213,6 +213,7 @@ static ide_pci_device_t cyrix_chipsets[] __devinitdata = {
  
 static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_device_id *id)
 {
+       ide_hwif_t *hwif = NULL, *mate = NULL;
        ata_index_t index;
        ide_pci_device_t *d = &cyrix_chipsets[id->driver_data];
 
@@ -239,10 +240,21 @@ static int __devinit cs5520_init_one(struct pci_dev *dev, const struct pci_devic
 
        ide_pci_setup_ports(dev, d, 14, &index);
 
-       if((index.b.low & 0xf0) != 0xf0)
-               probe_hwif_init(&ide_hwifs[index.b.low]);
-       if((index.b.high & 0xf0) != 0xf0)
-               probe_hwif_init(&ide_hwifs[index.b.high]);
+       if ((index.b.low & 0xf0) != 0xf0)
+               hwif = &ide_hwifs[index.b.low];
+       if ((index.b.high & 0xf0) != 0xf0)
+               mate = &ide_hwifs[index.b.high];
+
+       if (hwif)
+               probe_hwif_init(hwif);
+       if (mate)
+               probe_hwif_init(mate);
+
+       if (hwif)
+               ide_proc_register_port(hwif);
+       if (mate)
+               ide_proc_register_port(mate);
+
        return 0;
 }
 
index fd09b295a69dd0b86c004ada223d03b289b18a14..d3185e29a38eef3c6763c68ef390e4b3aaa0ec69 100644 (file)
@@ -692,7 +692,7 @@ sgiioc4_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t * d)
                return -EIO;
 
        /* Create /proc/ide entries */
-       create_proc_ide_interfaces();
+       ide_proc_register_port(hwif);
 
        return 0;
 }
index a49ebe44babd1d5f0d97c92b3fdd963be0fc7f70..45fc36f0f219feaba9649978c69d697966e2ba57 100644 (file)
@@ -1276,6 +1276,8 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
        /* We probe the hwif now */
        probe_hwif_init(hwif);
 
+       ide_proc_register_port(hwif);
+
        return 0;
 }
 
index 118fb3205ca81cda6f4f260bedeea806883ffa4d..892cda75578242edd1dc54cada2a1dd5f688f79e 100644 (file)
@@ -702,6 +702,7 @@ out:
 
 int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d)
 {
+       ide_hwif_t *hwif = NULL, *mate = NULL;
        ata_index_t index_list;
        int ret;
 
@@ -710,11 +711,19 @@ int ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d)
                goto out;
 
        if ((index_list.b.low & 0xf0) != 0xf0)
-               probe_hwif_init_with_fixup(&ide_hwifs[index_list.b.low], d->fixup);
+               hwif = &ide_hwifs[index_list.b.low];
        if ((index_list.b.high & 0xf0) != 0xf0)
-               probe_hwif_init_with_fixup(&ide_hwifs[index_list.b.high], d->fixup);
+               mate = &ide_hwifs[index_list.b.high];
 
-       create_proc_ide_interfaces();
+       if (hwif)
+               probe_hwif_init_with_fixup(hwif, d->fixup);
+       if (mate)
+               probe_hwif_init_with_fixup(mate, d->fixup);
+
+       if (hwif)
+               ide_proc_register_port(hwif);
+       if (mate)
+               ide_proc_register_port(mate);
 out:
        return ret;
 }
@@ -748,7 +757,15 @@ int ide_setup_pci_devices(struct pci_dev *dev1, struct pci_dev *dev2,
                }
        }
 
-       create_proc_ide_interfaces();
+       for (i = 0; i < 2; i++) {
+               u8 idx[2] = { index_list[i].b.low, index_list[i].b.high };
+               int j;
+
+               for (j = 0; j < 2; j++) {
+                       if ((idx[j] & 0xf0) != 0xf0)
+                               ide_proc_register_port(ide_hwifs + idx[j]);
+               }
+       }
 out:
        return ret;
 }
index bdb97655ef61453be63f22168488b153644256b6..52d482a16dd97c4d4fb36292b84b6aae341d8747 100644 (file)
@@ -909,12 +909,10 @@ typedef struct {
        write_proc_t    *write_proc;
 } ide_proc_entry_t;
 
-extern struct proc_dir_entry *proc_ide_root;
-
 void proc_ide_create(void);
 void proc_ide_destroy(void);
-void create_proc_ide_interfaces(void);
-void destroy_proc_ide_interface(ide_hwif_t *);
+void ide_proc_register_port(ide_hwif_t *);
+void ide_proc_unregister_port(ide_hwif_t *);
 void ide_proc_register_driver(ide_drive_t *, ide_driver_t *);
 void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *);
 
@@ -945,8 +943,8 @@ void ide_pci_create_host_proc(const char *, get_info_t *);
 #else
 static inline void proc_ide_create(void) { ; }
 static inline void proc_ide_destroy(void) { ; }
-static inline void create_proc_ide_interfaces(void) { ; }
-static inline void destroy_proc_ide_interface(ide_hwif_t *hwif) { ; }
+static inline void ide_proc_register_port(ide_hwif_t *hwif) { ; }
+static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; }
 static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
 static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
 static inline void ide_add_generic_settings(ide_drive_t *drive) { ; }