Re: [PATCH 09/18] ide: rework PowerMac media-bay support

2008-02-13 Thread Bartlomiej Zolnierkiewicz

Hi,

On Wednesday 13 February 2008, Michael Ellerman wrote:
 On Fri, 2008-02-08 at 01:45 +0100, Bartlomiej Zolnierkiewicz wrote:
  Rework PowerMac media-bay support in such way that instead of
  un/registering the IDE interface we un/register IDE devices:
  
  * Add ide_port_scan() helper for probing+registerering devices on a port.
  
  * Rename ide_port_unregister_devices() to __ide_port_unregister_devices().
  
  * Add ide_port_unregister_devices() helper for unregistering devices on a 
  port.
  
  * Add 'ide_hwif_t *cd_port' to 'struct media_bay_info', pass 'hwif' instead
of hwif-index to media_bay_set_ide_infos() and use it to setup 'cd_port'.
  
  * Use ide_port_unregister_devices() instead of ide_unregister()
and ide_port_scan() instead of ide_register_hw() in media_bay_step().
  
  * Unexport ide_register_hw() and make it static.
  
  Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
  ---
   drivers/ide/ide-probe.c|   18 ++
   drivers/ide/ide.c  |   22 --
   drivers/ide/ppc/pmac.c |3 ++-
   drivers/macintosh/mediabay.c   |   17 +++--
   include/asm-powerpc/mediabay.h |4 +++-
   include/linux/ide.h|6 ++
   6 files changed, 48 insertions(+), 22 deletions(-)
 
  Index: b/include/asm-powerpc/mediabay.h
  ===
  --- a/include/asm-powerpc/mediabay.h
  +++ b/include/asm-powerpc/mediabay.h
  @@ -22,10 +22,12 @@ int check_media_bay(struct device_node *
   /* Number of bays in the machine or 0 */
   extern int media_bay_count;
   
  +#ifdef CONFIG_BLK_DEV_IDE_PMAC

Does adding:

#include linux/ide.h

after ifdef help?

   int check_media_bay_by_base(unsigned long base, int what);
   /* called by IDE PMAC host driver to register IDE controller for media bay 
  */
   int media_bay_set_ide_infos(struct device_node *which_bay, unsigned long 
  base,
  -   int irq, int index);
  +   int irq, ide_hwif_t *hwif);
  +#endif
   
   #endif /* __KERNEL__ */
   #endif /* _PPC_MEDIABAY_H */
 
 This hunk breaks pmac32_defconfig for me.
 
 include2/asm/mediabay.h:29: error: syntax error before 'ide_hwif_t'
 make[3]: *** [arch/powerpc/platforms/powermac/setup.o] Error 1
 make[2]: *** [arch/powerpc/platforms/powermac] Error 2
 make[1]: *** [arch/powerpc/platforms] Error 2
 make: *** [sub-make] Error 2
 
 cheers
-
To unsubscribe from this list: send the line unsubscribe linux-ide in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/18] ide: rework PowerMac media-bay support

2008-02-07 Thread Bartlomiej Zolnierkiewicz
Rework PowerMac media-bay support in such way that instead of
un/registering the IDE interface we un/register IDE devices:

* Add ide_port_scan() helper for probing+registerering devices on a port.

* Rename ide_port_unregister_devices() to __ide_port_unregister_devices().

* Add ide_port_unregister_devices() helper for unregistering devices on a port.

* Add 'ide_hwif_t *cd_port' to 'struct media_bay_info', pass 'hwif' instead
  of hwif-index to media_bay_set_ide_infos() and use it to setup 'cd_port'.

* Use ide_port_unregister_devices() instead of ide_unregister()
  and ide_port_scan() instead of ide_register_hw() in media_bay_step().

* Unexport ide_register_hw() and make it static.

Signed-off-by: Bartlomiej Zolnierkiewicz [EMAIL PROTECTED]
---
 drivers/ide/ide-probe.c|   18 ++
 drivers/ide/ide.c  |   22 --
 drivers/ide/ppc/pmac.c |3 ++-
 drivers/macintosh/mediabay.c   |   17 +++--
 include/asm-powerpc/mediabay.h |4 +++-
 include/linux/ide.h|6 ++
 6 files changed, 48 insertions(+), 22 deletions(-)

Index: b/drivers/ide/ide-probe.c
===
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -1490,3 +1490,21 @@ int ide_device_add(u8 idx[4], const stru
return ide_device_add_all(idx_all, d);
 }
 EXPORT_SYMBOL_GPL(ide_device_add);
+
+void ide_port_scan(ide_hwif_t *hwif)
+{
+   ide_port_cable_detect(hwif);
+   ide_port_init_devices(hwif);
+
+   if (ide_probe_port(hwif)  0)
+   return;
+
+   hwif-present = 1;
+
+   ide_port_tune_devices(hwif);
+   ide_acpi_port_init_devices(hwif);
+   ide_port_setup_devices(hwif);
+   hwif_register_devices(hwif);
+   ide_proc_port_register_devices(hwif);
+}
+EXPORT_SYMBOL_GPL(ide_port_scan);
Index: b/drivers/ide/ide.c
===
--- a/drivers/ide/ide.c
+++ b/drivers/ide/ide.c
@@ -506,7 +506,7 @@ void ide_remove_port_from_hwgroup(ide_hw
 }
 
 /* Called with ide_lock held. */
-static void ide_port_unregister_devices(ide_hwif_t *hwif)
+static void __ide_port_unregister_devices(ide_hwif_t *hwif)
 {
int i;
 
@@ -522,6 +522,18 @@ static void ide_port_unregister_devices(
}
 }
 
+void ide_port_unregister_devices(ide_hwif_t *hwif)
+{
+   mutex_lock(ide_cfg_mtx);
+   spin_lock_irq(ide_lock);
+   __ide_port_unregister_devices(hwif);
+   hwif-present = 0;
+   ide_port_init_devices_data(hwif);
+   spin_unlock_irq(ide_lock);
+   mutex_unlock(ide_cfg_mtx);
+}
+EXPORT_SYMBOL_GPL(ide_port_unregister_devices);
+
 /**
  * ide_unregister  -   free an IDE interface
  * @index: index of interface (will change soon to a pointer)
@@ -562,7 +574,7 @@ void ide_unregister(unsigned int index, 
hwif = ide_hwifs[index];
if (!hwif-present)
goto abort;
-   ide_port_unregister_devices(hwif);
+   __ide_port_unregister_devices(hwif);
hwif-present = 0;
 
spin_unlock_irq(ide_lock);
@@ -657,8 +669,8 @@ EXPORT_SYMBOL_GPL(ide_init_port_hw);
  * Returns -1 on error.
  */
 
-int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
-   ide_hwif_t **hwifp)
+static int ide_register_hw(hw_regs_t *hw, void (*quirkproc)(ide_drive_t *),
+  ide_hwif_t **hwifp)
 {
int index, retry = 1;
ide_hwif_t *hwif;
@@ -692,8 +704,6 @@ found:
return hwif-present ? index : -1;
 }
 
-EXPORT_SYMBOL(ide_register_hw);
-
 /*
  * Locks for IDE setting functionality
  */
Index: b/drivers/ide/ppc/pmac.c
===
--- a/drivers/ide/ppc/pmac.c
+++ b/drivers/ide/ppc/pmac.c
@@ -1088,7 +1088,8 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p
if (np-parent  np-parent-name
 strcasecmp(np-parent-name, media-bay) == 0) {
 #ifdef CONFIG_PMAC_MEDIABAY
-   media_bay_set_ide_infos(np-parent, pmif-regbase, pmif-irq, 
hwif-index);
+   media_bay_set_ide_infos(np-parent, pmif-regbase, pmif-irq,
+   hwif);
 #endif /* CONFIG_PMAC_MEDIABAY */
pmif-mediabay = 1;
if (!bidp)
Index: b/drivers/macintosh/mediabay.c
===
--- a/drivers/macintosh/mediabay.c
+++ b/drivers/macintosh/mediabay.c
@@ -79,6 +79,7 @@ struct media_bay_info {
int sleeping;
struct semaphorelock;
 #ifdef CONFIG_BLK_DEV_IDE_PMAC
+   ide_hwif_t  *cd_port;
void __iomem*cd_base;
int cd_irq;
int cd_retry;
@@ -450,7 +451,7 @@ int check_media_bay_by_base(unsigned lon
 }
 
 int media_bay_set_ide_infos(struct device_node*