Re: [PATCH 3/5] mmc: sdhci: make sdhci-of device drivers self registered

2011-04-21 Thread Shawn Guo
On Tue, Apr 19, 2011 at 12:21:01PM +0200, Wolfram Sang wrote:
 
  +static int __devinit sdhci_esdhc_probe(struct platform_device *pdev)
  +{
  +   struct sdhci_host *host;
  +   int ret;
  +
  +   host = sdhci_pltfm_init(pdev, sdhci_esdhc_pdata);
  +   if (!host)
  +   return -ENOMEM;
 
 Just noticed: Since pltfm_init may fail due to various reasons, maybe
 ERRPTR might be a good idea?
 
Ok.

 [...]
 
  +static int __init sdhci_hlwd_init(void)
  +{
  +   return platform_driver_register(sdhci_hlwd_driver);
  +}
  +module_init(sdhci_hlwd_init);
  +
  +static void __exit sdhci_hlwd_exit(void)
  +{
  +   platform_driver_unregister(sdhci_hlwd_driver);
  +}
  +module_exit(sdhci_hlwd_exit);
  +
  +MODULE_DESCRIPTION(Secure Digital Host Controller Interface OF driver);
  +MODULE_AUTHOR(Xiaobo Xie x@freescale.com, 
  + Anton Vorontsov avoront...@ru.mvista.com);
  +MODULE_LICENSE(GPL v2);
 
 Please double check the authors. It is based on the fsl driver, but the
 copyright should go to
 
  * Copyright (C) 2009 The GameCube Linux Team
  * Copyright (C) 2009 Albert Herranz
 
 I think.
 
Sorry, I misread the current copyright in sdhci-of-hlwd.c.  You are
right.

-- 
Regards,
Shawn

--
To unsubscribe from this list: send the line unsubscribe linux-mmc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/5] mmc: sdhci: make sdhci-of device drivers self registered

2011-04-19 Thread Wolfram Sang

 +static int __devinit sdhci_esdhc_probe(struct platform_device *pdev)
 +{
 + struct sdhci_host *host;
 + int ret;
 +
 + host = sdhci_pltfm_init(pdev, sdhci_esdhc_pdata);
 + if (!host)
 + return -ENOMEM;

Just noticed: Since pltfm_init may fail due to various reasons, maybe
ERRPTR might be a good idea?

[...]

 +static int __init sdhci_hlwd_init(void)
 +{
 + return platform_driver_register(sdhci_hlwd_driver);
 +}
 +module_init(sdhci_hlwd_init);
 +
 +static void __exit sdhci_hlwd_exit(void)
 +{
 + platform_driver_unregister(sdhci_hlwd_driver);
 +}
 +module_exit(sdhci_hlwd_exit);
 +
 +MODULE_DESCRIPTION(Secure Digital Host Controller Interface OF driver);
 +MODULE_AUTHOR(Xiaobo Xie x@freescale.com, 
 +   Anton Vorontsov avoront...@ru.mvista.com);
 +MODULE_LICENSE(GPL v2);

Please double check the authors. It is based on the fsl driver, but the
copyright should go to

 * Copyright (C) 2009 The GameCube Linux Team
 * Copyright (C) 2009 Albert Herranz

I think.

-- 
Pengutronix e.K.   | Wolfram Sang|
Industrial Linux Solutions | http://www.pengutronix.de/  |


signature.asc
Description: Digital signature


Re: [PATCH 3/5] mmc: sdhci: make sdhci-of device drivers self registered

2011-03-31 Thread Grant Likely
On Fri, Mar 25, 2011 at 04:48:49PM +0800, Shawn Guo wrote:
 The patch turns the sdhci-of-core common stuff into helper functions
 added into sdhci-pltfm.c, and makes sdhci-of device drviers self
 registered using the same pair of .probe and .remove used by
 sdhci-pltfm device drivers.
 
 As a result, sdhci-of-core.c and sdhci-of.h can be eliminated with
 those common things merged into sdhci-pltfm.c and sdhci-pltfm.h
 respectively.
 
 Signed-off-by: Shawn Guo shawn@linaro.org
 ---
  drivers/mmc/host/Kconfig  |   15 +--
  drivers/mmc/host/Makefile |7 +-
  drivers/mmc/host/sdhci-of-core.c  |  247 
 -
  drivers/mmc/host/sdhci-of-esdhc.c |   75 +++-
  drivers/mmc/host/sdhci-of-hlwd.c  |   73 +++-
  drivers/mmc/host/sdhci-of.h   |   33 -
  drivers/mmc/host/sdhci-pltfm.c|  100 +++-
  drivers/mmc/host/sdhci-pltfm.h|   14 ++
  8 files changed, 263 insertions(+), 301 deletions(-)
  delete mode 100644 drivers/mmc/host/sdhci-of-core.c
  delete mode 100644 drivers/mmc/host/sdhci-of.h
 
 diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
 index 1db9347..9f360b5 100644
 --- a/drivers/mmc/host/Kconfig
 +++ b/drivers/mmc/host/Kconfig
 @@ -81,19 +81,11 @@ config MMC_RICOH_MMC
  
 If unsure, say Y.
  
 -config MMC_SDHCI_OF
 - tristate SDHCI support on OpenFirmware platforms
 - depends on MMC_SDHCI  OF
 - help
 -   This selects the OF support for Secure Digital Host Controller
 -   Interfaces.
 -
 -   If unsure, say N.
 -
  config MMC_SDHCI_OF_ESDHC
   bool SDHCI OF support for the Freescale eSDHC controller
 - depends on MMC_SDHCI_OF
 + depends on MMC_SDHCI
   depends on PPC_OF
 + select MMC_SDHCI_PLTFM
   select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
   help
 This selects the Freescale eSDHC controller support.
 @@ -102,8 +94,9 @@ config MMC_SDHCI_OF_ESDHC
  
  config MMC_SDHCI_OF_HLWD
   bool SDHCI OF support for the Nintendo Wii SDHCI controllers
 - depends on MMC_SDHCI_OF
 + depends on MMC_SDHCI
   depends on PPC_OF
 + select MMC_SDHCI_PLTFM
   select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
   help
 This selects the Secure Digital Host Controller Interface (SDHCI)
 diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
 index 1d8e43d..0ea8815 100644
 --- a/drivers/mmc/host/Makefile
 +++ b/drivers/mmc/host/Makefile
 @@ -41,11 +41,8 @@ obj-$(CONFIG_MMC_SDHCI_CNS3XXX)+= 
 sdhci-cns3xxx.o
  obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX)+= sdhci-esdhc-imx.o
  obj-$(CONFIG_MMC_SDHCI_DOVE) += sdhci-dove.o
  obj-$(CONFIG_MMC_SDHCI_TEGRA)+= sdhci-tegra.o
 -
 -obj-$(CONFIG_MMC_SDHCI_OF)   += sdhci-of.o
 -sdhci-of-y   := sdhci-of-core.o
 -sdhci-of-$(CONFIG_MMC_SDHCI_OF_ESDHC)+= sdhci-of-esdhc.o
 -sdhci-of-$(CONFIG_MMC_SDHCI_OF_HLWD) += sdhci-of-hlwd.o
 +obj-$(CONFIG_MMC_SDHCI_OF_ESDHC) += sdhci-of-esdhc.o
 +obj-$(CONFIG_MMC_SDHCI_OF_HLWD)  += sdhci-of-hlwd.o
  
  ifeq ($(CONFIG_CB710_DEBUG),y)
   CFLAGS-cb710-mmc+= -DDEBUG
 diff --git a/drivers/mmc/host/sdhci-of-core.c 
 b/drivers/mmc/host/sdhci-of-core.c
 deleted file mode 100644
 index a6c0132..000
 --- a/drivers/mmc/host/sdhci-of-core.c
 +++ /dev/null
 @@ -1,247 +0,0 @@
 -/*
 - * OpenFirmware bindings for Secure Digital Host Controller Interface.
 - *
 - * Copyright (c) 2007 Freescale Semiconductor, Inc.
 - * Copyright (c) 2009 MontaVista Software, Inc.
 - *
 - * Authors: Xiaobo Xie x@freescale.com
 - *   Anton Vorontsov avoront...@ru.mvista.com
 - *
 - * This program is free software; you can redistribute it and/or modify
 - * it under the terms of the GNU General Public License as published by
 - * the Free Software Foundation; either version 2 of the License, or (at
 - * your option) any later version.
 - */
 -
 -#include linux/err.h
 -#include linux/module.h
 -#include linux/init.h
 -#include linux/io.h
 -#include linux/interrupt.h
 -#include linux/delay.h
 -#include linux/of.h
 -#include linux/of_platform.h
 -#include linux/of_address.h
 -#include linux/of_irq.h
 -#include linux/mmc/host.h
 -#ifdef CONFIG_PPC
 -#include asm/machdep.h
 -#endif
 -#include sdhci-of.h
 -#include sdhci.h
 -
 -#ifdef CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
 -
 -/*
 - * These accessors are designed for big endian hosts doing I/O to
 - * little endian controllers incorporating a 32-bit hardware byte swapper.
 - */
 -
 -u32 sdhci_be32bs_readl(struct sdhci_host *host, int reg)
 -{
 - return in_be32(host-ioaddr + reg);
 -}
 -
 -u16 sdhci_be32bs_readw(struct sdhci_host *host, int reg)
 -{
 - return in_be16(host-ioaddr + (reg ^ 0x2));
 -}
 -
 -u8 sdhci_be32bs_readb(struct sdhci_host *host, int reg)
 -{
 - return in_8(host-ioaddr + (reg ^ 0x3));
 -}
 -
 -void sdhci_be32bs_writel(struct sdhci_host *host, u32 val, int reg)
 -{
 - out_be32(host-ioaddr + 

[PATCH 3/5] mmc: sdhci: make sdhci-of device drivers self registered

2011-03-25 Thread Shawn Guo
The patch turns the sdhci-of-core common stuff into helper functions
added into sdhci-pltfm.c, and makes sdhci-of device drviers self
registered using the same pair of .probe and .remove used by
sdhci-pltfm device drivers.

As a result, sdhci-of-core.c and sdhci-of.h can be eliminated with
those common things merged into sdhci-pltfm.c and sdhci-pltfm.h
respectively.

Signed-off-by: Shawn Guo shawn@linaro.org
---
 drivers/mmc/host/Kconfig  |   15 +--
 drivers/mmc/host/Makefile |7 +-
 drivers/mmc/host/sdhci-of-core.c  |  247 -
 drivers/mmc/host/sdhci-of-esdhc.c |   75 +++-
 drivers/mmc/host/sdhci-of-hlwd.c  |   73 +++-
 drivers/mmc/host/sdhci-of.h   |   33 -
 drivers/mmc/host/sdhci-pltfm.c|  100 +++-
 drivers/mmc/host/sdhci-pltfm.h|   14 ++
 8 files changed, 263 insertions(+), 301 deletions(-)
 delete mode 100644 drivers/mmc/host/sdhci-of-core.c
 delete mode 100644 drivers/mmc/host/sdhci-of.h

diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 1db9347..9f360b5 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -81,19 +81,11 @@ config MMC_RICOH_MMC
 
  If unsure, say Y.
 
-config MMC_SDHCI_OF
-   tristate SDHCI support on OpenFirmware platforms
-   depends on MMC_SDHCI  OF
-   help
- This selects the OF support for Secure Digital Host Controller
- Interfaces.
-
- If unsure, say N.
-
 config MMC_SDHCI_OF_ESDHC
bool SDHCI OF support for the Freescale eSDHC controller
-   depends on MMC_SDHCI_OF
+   depends on MMC_SDHCI
depends on PPC_OF
+   select MMC_SDHCI_PLTFM
select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
help
  This selects the Freescale eSDHC controller support.
@@ -102,8 +94,9 @@ config MMC_SDHCI_OF_ESDHC
 
 config MMC_SDHCI_OF_HLWD
bool SDHCI OF support for the Nintendo Wii SDHCI controllers
-   depends on MMC_SDHCI_OF
+   depends on MMC_SDHCI
depends on PPC_OF
+   select MMC_SDHCI_PLTFM
select MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
help
  This selects the Secure Digital Host Controller Interface (SDHCI)
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index 1d8e43d..0ea8815 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -41,11 +41,8 @@ obj-$(CONFIG_MMC_SDHCI_CNS3XXX)  += 
sdhci-cns3xxx.o
 obj-$(CONFIG_MMC_SDHCI_ESDHC_IMX)  += sdhci-esdhc-imx.o
 obj-$(CONFIG_MMC_SDHCI_DOVE)   += sdhci-dove.o
 obj-$(CONFIG_MMC_SDHCI_TEGRA)  += sdhci-tegra.o
-
-obj-$(CONFIG_MMC_SDHCI_OF) += sdhci-of.o
-sdhci-of-y := sdhci-of-core.o
-sdhci-of-$(CONFIG_MMC_SDHCI_OF_ESDHC)  += sdhci-of-esdhc.o
-sdhci-of-$(CONFIG_MMC_SDHCI_OF_HLWD)   += sdhci-of-hlwd.o
+obj-$(CONFIG_MMC_SDHCI_OF_ESDHC)   += sdhci-of-esdhc.o
+obj-$(CONFIG_MMC_SDHCI_OF_HLWD)+= sdhci-of-hlwd.o
 
 ifeq ($(CONFIG_CB710_DEBUG),y)
CFLAGS-cb710-mmc+= -DDEBUG
diff --git a/drivers/mmc/host/sdhci-of-core.c b/drivers/mmc/host/sdhci-of-core.c
deleted file mode 100644
index a6c0132..000
--- a/drivers/mmc/host/sdhci-of-core.c
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * OpenFirmware bindings for Secure Digital Host Controller Interface.
- *
- * Copyright (c) 2007 Freescale Semiconductor, Inc.
- * Copyright (c) 2009 MontaVista Software, Inc.
- *
- * Authors: Xiaobo Xie x@freescale.com
- * Anton Vorontsov avoront...@ru.mvista.com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or (at
- * your option) any later version.
- */
-
-#include linux/err.h
-#include linux/module.h
-#include linux/init.h
-#include linux/io.h
-#include linux/interrupt.h
-#include linux/delay.h
-#include linux/of.h
-#include linux/of_platform.h
-#include linux/of_address.h
-#include linux/of_irq.h
-#include linux/mmc/host.h
-#ifdef CONFIG_PPC
-#include asm/machdep.h
-#endif
-#include sdhci-of.h
-#include sdhci.h
-
-#ifdef CONFIG_MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER
-
-/*
- * These accessors are designed for big endian hosts doing I/O to
- * little endian controllers incorporating a 32-bit hardware byte swapper.
- */
-
-u32 sdhci_be32bs_readl(struct sdhci_host *host, int reg)
-{
-   return in_be32(host-ioaddr + reg);
-}
-
-u16 sdhci_be32bs_readw(struct sdhci_host *host, int reg)
-{
-   return in_be16(host-ioaddr + (reg ^ 0x2));
-}
-
-u8 sdhci_be32bs_readb(struct sdhci_host *host, int reg)
-{
-   return in_8(host-ioaddr + (reg ^ 0x3));
-}
-
-void sdhci_be32bs_writel(struct sdhci_host *host, u32 val, int reg)
-{
-   out_be32(host-ioaddr + reg, val);
-}
-
-void sdhci_be32bs_writew(struct sdhci_host *host, u16 val, int reg)
-{
-   struct sdhci_pltfm_host *pltfm_host =