ide: add ide_proc_register_port()

* 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: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 869c56ee
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
for (h = 0; h < MAX_HWIFS; h++) {
ide_hwif_t *hwif = &ide_hwifs[h];
if (!hwif->present)
continue;
return;
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);
}
}
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;
......
......@@ -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 @@ int ide_register_hw_with_fixup(hw_regs_t *hw, int initializing,
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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
......
......@@ -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 */
}
......
......@@ -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;
}
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -702,6 +702,7 @@ static int do_ide_setup_pci_device(struct pci_dev *dev, ide_pci_device_t *d,
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;
}
......
......@@ -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) { ; }
......
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