mpc8xx-ide: use ide_find_port()
PATCH 1/5 mpc8xx-ide: use ide_find_port()
--- drivers/ide/ppc/mpc8xx.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/ide/ppc/mpc8xx.c +14 -10
@@ -811,24 +811,28 @@ static int __init mpc8xx_ide_probe(void)#ifdef IDE0_BASE_OFFSET memset (&hw,0 ,sizeof (hw));if (!m8xx_ide_init_ports (&hw,0 )) { -ide_hwif_t *hwif = &ide_hwifs[0 ]; +ide_hwif_t *hwif =ide_find_port (); -ide_init_port_hw (hwif, &hw); - hwif->pio_mask =ATA_PIO4 ; - hwif->port_ops = &m8xx_port_ops; +if (hwif) { +ide_init_port_hw (hwif, &hw); + hwif->pio_mask =ATA_PIO4 ; + hwif->port_ops = &m8xx_port_ops; - idx[0 ] =0 ; + idx[0 ] = hwif->index; + } }#ifdef IDE1_BASE_OFFSET memset (&hw,0 ,sizeof (hw));if (!m8xx_ide_init_ports (&hw,1 )) { -ide_hwif_t *mate = &ide_hwifs[1 ]; +ide_hwif_t *mate =ide_find_port (); -ide_init_port_hw (mate, &hw); - mate->pio_mask =ATA_PIO4 ; - mate->port_ops = &m8xx_port_ops; +if (mate) { +ide_init_port_hw (mate, &hw); + mate->pio_mask =ATA_PIO4 ; + mate->port_ops = &m8xx_port_ops; - idx[1 ] =1 ; + idx[1 ] = mate->index; + } }#endif #endif
PATCH 2/5 ide: sanitize ide_unregister() usage
* Remove ide_unregister() call from ide_exit()
(host drivers take care of unregistering hwif-s themselves).
* Remove ide_unregister() call from probe methods of bast-ide, palm_bk3710, ide-cs and delkin_cb host drivers (ide_find_port() returns only free ide_hwifs[] entries).
--- drivers/ide/arm/bast-ide.c | 6 +----- drivers/ide/arm/palm_bk3710.c | 6 +----- drivers/ide/ide.c | 5 ----- drivers/ide/legacy/ide-cs.c | 6 +----- drivers/ide/pci/delkin_cb.c | 6 +----- 5 files changed, 4 insertions(+), 25 deletions(-)
drivers/ide/arm/bast-ide.c +1 -5
@@ -49,11 +49,7 @@ static int __init bastide_register(unsig i = hwif->index; -if (hwif->present) -ide_unregister (i); -else -ide_init_port_data (hwif, i); - +ide_init_port_data (hwif, i);ide_init_port_hw (hwif, &hw); hwif->port_ops =NULL ;
drivers/ide/arm/palm_bk3710.c +1 -5
@@ -398,11 +398,7 @@ static int __devinit palm_bk3710_probe(s i = hwif->index; -if (hwif->present) -ide_unregister (i); -else -ide_init_port_data (hwif, i); - +ide_init_port_data (hwif, i);ide_init_port_hw (hwif, &hw); hwif->mmio =1 ;
drivers/ide/ide.c +0 -5
@@ -1041,11 +1041,6 @@ out_port_class: static void __exit ide_exit(void) { -int index; - -for (index =0 ; index <MAX_HWIFS ; ++index) -ide_unregister (index); -proc_ide_destroy ();class_destroy (ide_port_class);
drivers/ide/legacy/ide-cs.c +1 -5
@@ -183,11 +183,7 @@ static ide_hwif_t *idecs_register(unsign i = hwif->index; -if (hwif->present) -ide_unregister (i); -else -ide_init_port_data (hwif, i); - +ide_init_port_data (hwif, i);ide_init_port_hw (hwif, &hw); hwif->port_ops = &idecs_port_ops;
drivers/ide/pci/delkin_cb.c +1 -5
@@ -87,11 +87,7 @@ delkin_cb_probe (struct pci_dev *dev, co i = hwif->index; -if (hwif->present) -ide_unregister (i); -else -ide_init_port_data (hwif, i); - +ide_init_port_data (hwif, i);ide_init_port_hw (hwif, &hw); hwif->port_ops = &delkin_cb_port_ops;
PATCH 3/5 ide: make ide_unregister() take 'ide_hwif_t *' as an argument
In reply to Bartlomiej Zolnierkiewicz* Make ide_unregister() take 'ide_hwif_t *hwif' instead of 'unsigned int index' (hwif->index) as an argument and update all users accordingly.
While at it:
* Remove unnecessary checks for hwif != NULL from ide-pnp.c::idepnp_remove() and delkin_cb.c::delkin_cb_remove().
* Remove needless hwif->chipset assignment from scc_pata.c::scc_remove().
--- drivers/ide/arm/rapide.c | 2 +- drivers/ide/ide-pnp.c | 5 +---- drivers/ide/ide.c | 11 ++++------- drivers/ide/legacy/ide-cs.c | 2 +- drivers/ide/legacy/ide_platform.c | 2 +- drivers/ide/mips/au1xxx-ide.c | 2 +- drivers/ide/pci/delkin_cb.c | 3 +-- drivers/ide/pci/scc_pata.c | 3 +-- include/linux/ide.h | 2 +- 9 files changed, 12 insertions(+), 20 deletions(-)
drivers/ide/arm/rapide.c +1 -1
@@ -75,7 +75,7 @@ static void __devexit rapide_remove(struecard_set_drvdata (ec,NULL ); -ide_unregister (hwif->index); +ide_unregister (hwif);ecard_release_resources (ec); }
drivers/ide/ide-pnp.c +1 -4
@@ -82,10 +82,7 @@ static void idepnp_remove(struct pnp_dev {ide_hwif_t *hwif =pnp_get_drvdata (dev); -if (hwif) -ide_unregister (hwif->index); -else -printk (KERN_ERR "idepnp: Unable to remove device, please report.\n" ); +ide_unregister (hwif);release_region (pnp_port_start (dev,1 ),1 );release_region (pnp_port_start (dev,0 ),8 );
drivers/ide/ide.c +4 -7
@@ -229,7 +229,7 @@ EXPORT_SYMBOL_GPL(ide_port_unregister_de/** * ide_unregister - free an IDE interface -* @index: index of interface (will change soon to a pointer) +* @index: IDE interface * * Perform the final unregister of an IDE interface. At the moment * we don't refcount interfaces so this will also get split up.
@@ -249,19 +249,16 @@ EXPORT_SYMBOL_GPL(ide_port_unregister_de* This is raving bonkers. */ -void ide_unregister (unsigned int index) +void ide_unregister (ide_hwif_t *hwif) { -ide_hwif_t *hwif, *g; +ide_hwif_t *g;ide_hwgroup_t *hwgroup;int irq_count =0 ; -BUG_ON (index >=MAX_HWIFS ); -BUG_ON (in_interrupt ());BUG_ON (irqs_disabled ());mutex_lock (&ide_cfg_mtx);spin_lock_irq (&ide_lock); - hwif = &ide_hwifs[index];if (!hwif->present) goto abort;__ide_port_unregister_devices (hwif);
@@ -302,7 +299,7 @@ void ide_unregister(unsigned int index)ide_release_dma_engine (hwif);/* restore hwif data to pristine status */ -ide_init_port_data (hwif, index); +ide_init_port_data (hwif, hwif->index); abort:spin_unlock_irq (&ide_lock);
drivers/ide/legacy/ide-cs.c +1 -1
@@ -386,7 +386,7 @@ void ide_release(struct pcmcia_device *lif (info->ndev) {/* FIXME: if this fails we need to queue the cleanup somehow -- need to investigate the required PCMCIA magic */ -ide_unregister (hwif->index); +ide_unregister (hwif); } info->ndev =0 ;
drivers/ide/legacy/ide_platform.c +1 -1
@@ -120,7 +120,7 @@ static int __devexit plat_ide_remove(str {ide_hwif_t *hwif = pdev->dev.driver_data; -ide_unregister (hwif->index); +ide_unregister (hwif);return 0 ; }
drivers/ide/mips/au1xxx-ide.c +1 -1
@@ -631,7 +631,7 @@ static int au_ide_remove(struct device *ide_hwif_t *hwif =dev_get_drvdata (dev);_auide_hwif *ahwif = &auide_hwif; -ide_unregister (hwif->index); +ide_unregister (hwif);iounmap ((void *)ahwif->regbase);
drivers/ide/pci/delkin_cb.c +1 -2
@@ -119,8 +119,7 @@ delkin_cb_remove (struct pci_dev *dev) {ide_hwif_t *hwif =pci_get_drvdata (dev); -if (hwif) -ide_unregister (hwif->index); +ide_unregister (hwif);pci_release_regions (dev);pci_disable_device (dev);
drivers/ide/pci/scc_pata.c +1 -2
@@ -730,9 +730,8 @@ static void __devexit scc_remove(struct hwif->dmatable_cpu =NULL ; } -ide_unregister (hwif->index); +ide_unregister (hwif); - hwif->chipset = ide_unknown;iounmap ((void *)ports->dma);iounmap ((void *)ports->ctl);pci_release_selected_regions (dev, (1 <<2 ) -1 );
include/linux/ide.h +1 -1
@@ -1205,7 +1205,7 @@ static inline void ide_acpi_set_state(id#endif void ide_remove_port_from_hwgroup (ide_hwif_t *); -void ide_unregister (unsigned int ); +void ide_unregister (ide_hwif_t *);void ide_register_region (struct gendisk *);void ide_unregister_region (struct gendisk *);
PATCH 4/5 ide: fix hwif-s initialization
In reply to Bartlomiej Zolnierkiewicz* Add ide_hwifs[] entry initialization to ide_find_port_slot() and remove ide_init_port_data() calls from host drivers.
* Unexport ide_init_port_data().
* Remove no longer needed init_ide_data().
--- drivers/ide/arm/bast-ide.c | 1 - drivers/ide/arm/palm_bk3710.c | 1 - drivers/ide/cris/ide-cris.c | 2 +- drivers/ide/h8300/ide-h8300.c | 1 - drivers/ide/ide-pnp.c | 1 - drivers/ide/ide-probe.c | 10 +++++++--- drivers/ide/ide.c | 15 --------------- drivers/ide/legacy/buddha.c | 1 - drivers/ide/legacy/falconide.c | 1 - drivers/ide/legacy/gayle.c | 1 - drivers/ide/legacy/ide-cs.c | 1 - drivers/ide/legacy/macide.c | 1 - drivers/ide/legacy/q40ide.c | 1 - drivers/ide/pci/delkin_cb.c | 1 - 14 files changed, 8 insertions(+), 30 deletions(-)
drivers/ide/arm/bast-ide.c +0 -1
@@ -49,7 +49,6 @@ static int __init bastide_register(unsig i = hwif->index; -ide_init_port_data (hwif, i);ide_init_port_hw (hwif, &hw); hwif->port_ops =NULL ;
drivers/ide/arm/palm_bk3710.c +0 -1
@@ -398,7 +398,6 @@ static int __devinit palm_bk3710_probe(s i = hwif->index; -ide_init_port_data (hwif, i);ide_init_port_hw (hwif, &hw); hwif->mmio =1 ;
drivers/ide/cris/ide-cris.c +1 -1
@@ -811,7 +811,7 @@ static int __init init_e100_ide(void) hwif =ide_find_port ();if (hwif ==NULL )continue ; -ide_init_port_data (hwif, hwif->index); +ide_init_port_hw (hwif, &hw); hwif->ata_input_data = &cris_ide_input_data;
drivers/ide/h8300/ide-h8300.c +0 -1
@@ -105,7 +105,6 @@ static int __init h8300_ide_init(void) } index = hwif->index; -ide_init_port_data (hwif, index);ide_init_port_hw (hwif, &hw);hwif_setup (hwif);printk (KERN_INFO "ide%d: H8/300 generic IDE interface\n" , index);
drivers/ide/ide-pnp.c +0 -1
@@ -61,7 +61,6 @@ static int idepnp_probe(struct pnp_dev *u8 index = hwif->index;u8 idx[4 ] = { index,0xff ,0xff ,0xff }; -ide_init_port_data (hwif, index);ide_init_port_hw (hwif, &hw);printk (KERN_INFO "ide%d: generic PnP IDE interface\n" , index);
drivers/ide/ide-probe.c +7 -3
@@ -1478,22 +1478,26 @@ ide_hwif_t *ide_find_port_slot(const strfor (; i <MAX_HWIFS ; i++) { hwif = &ide_hwifs[i];if (hwif->chipset == ide_unknown) -return hwif; + goto out_found; } }else {for (i =2 ; i <MAX_HWIFS ; i++) { hwif = &ide_hwifs[i];if (hwif->chipset == ide_unknown) -return hwif; + goto out_found; }for (i =0 ; i <2 && i <MAX_HWIFS ; i++) { hwif = &ide_hwifs[i];if (hwif->chipset == ide_unknown) -return hwif; + goto out_found; } }return NULL ; + +out_found: +ide_init_port_data (hwif, i); +return hwif; }EXPORT_SYMBOL_GPL (ide_find_port_slot);
drivers/ide/ide.c +0 -15
@@ -121,7 +121,6 @@ void ide_init_port_data(ide_hwif_t *hwifide_port_init_devices_data (hwif); } -EXPORT_SYMBOL_GPL (ide_init_port_data);static void ide_port_init_devices_data (ide_hwif_t *hwif) {
@@ -151,18 +150,6 @@ static void ide_port_init_devices_data(i } } -static void __init init_ide_data (void ) -{ -unsigned int index; - -/* Initialise all interface structures */ -for (index =0 ; index <MAX_HWIFS ; ++index) { -ide_hwif_t *hwif = &ide_hwifs[index]; - -ide_init_port_data (hwif, index); - } -} -void ide_remove_port_from_hwgroup (ide_hwif_t *hwif) {ide_hwgroup_t *hwgroup = hwif->hwgroup;
@@ -1024,8 +1011,6 @@ static int __init ide_init(void) } ide_port_class->dev_release = ide_port_class_release; -init_ide_data (); -proc_ide_create ();return 0 ;
drivers/ide/legacy/buddha.c +0 -1
@@ -225,7 +225,6 @@ fail_base2:if (hwif) {u8 index = hwif->index; -ide_init_port_data (hwif, index);ide_init_port_hw (hwif, &hw); idx[i] = index;
drivers/ide/legacy/falconide.c +0 -1
@@ -87,7 +87,6 @@ static int __init falconide_init(void)u8 index = hwif->index;u8 idx[4 ] = { index,0xff ,0xff ,0xff }; -ide_init_port_data (hwif, index);ide_init_port_hw (hwif, &hw);ide_get_lock (NULL ,NULL );
drivers/ide/legacy/gayle.c +0 -1
@@ -182,7 +182,6 @@ found:if (hwif) {u8 index = hwif->index; -ide_init_port_data (hwif, index);ide_init_port_hw (hwif, &hw); idx[i] = index;
drivers/ide/legacy/ide-cs.c +0 -1
@@ -183,7 +183,6 @@ static ide_hwif_t *idecs_register(unsign i = hwif->index; -ide_init_port_data (hwif, i);ide_init_port_hw (hwif, &hw); hwif->port_ops = &idecs_port_ops;
drivers/ide/legacy/macide.c +0 -1
@@ -125,7 +125,6 @@ static int __init macide_init(void)u8 index = hwif->index;u8 idx[4 ] = { index,0xff ,0xff ,0xff }; -ide_init_port_data (hwif, index);ide_init_port_hw (hwif, &hw);ide_device_add (idx,NULL );
drivers/ide/legacy/q40ide.c +0 -1
@@ -139,7 +139,6 @@ static int __init q40ide_init(void) hwif =ide_find_port ();if (hwif) { -ide_init_port_data (hwif, hwif->index);ide_init_port_hw (hwif, &hw); idx[i] = hwif->index;
drivers/ide/pci/delkin_cb.c +0 -1
@@ -87,7 +87,6 @@ delkin_cb_probe (struct pci_dev *dev, co i = hwif->index; -ide_init_port_data (hwif, i);ide_init_port_hw (hwif, &hw); hwif->port_ops = &delkin_cb_port_ops;
PATCH 5/5 ide: make ide_hwifs[] static
In reply to Bartlomiej ZolnierkiewiczMove ide_hwifs[] from ide.c to ide-probe.c and make it static.
--- drivers/ide/ide-probe.c | 2 ++ drivers/ide/ide.c | 2 -- include/linux/ide.h | 12 ------------ 3 files changed, 2 insertions(+), 14 deletions(-)
drivers/ide/ide-probe.c +2 -0
@@ -39,6 +39,8 @@#include <asm/uaccess.h> #include <asm/io.h> +static ide_hwif_t ide_hwifs[MAX_HWIFS ];/* master data repository */ +/** * generic_id - add a generic drive id * @drive: drive to make an ID block for
drivers/ide/ide.c +0 -2
@@ -91,8 +91,6 @@ DEFINE_MUTEX(ide_cfg_mtx);__cacheline_aligned_in_smp DEFINE_SPINLOCK (ide_lock );EXPORT_SYMBOL (ide_lock); -ide_hwif_t ide_hwifs[MAX_HWIFS ];/* master data repository */ -static void ide_port_init_devices_data (ide_hwif_t *);/*
include/linux/ide.h +0 -12
@@ -788,18 +788,6 @@ struct ide_driver_s {int generic_ide_ioctl (ide_drive_t *,struct file *,struct block_device *,unsigned ,unsigned long ); -/* -* ide_hwifs[] is the master data structure used to keep track -* of just about everything in ide.c. Whenever possible, routines -* should be using pointers to a drive (ide_drive_t *) or -* pointers to a hwif (ide_hwif_t *), rather than indexing this -* structure directly (the allocation/layout may change!). -* -*/ -#ifndef _IDE_C -extern ide_hwif_t ide_hwifs[];/* master data repository */ -#endif -extern int ide_vlb_clk;extern int ide_pci_clk;