Re: [U-Boot] [RFC] mmc: Remove ops from struct mmc and put in mmc_ops

2014-03-03 Thread Marek Vasut
On Wednesday, February 26, 2014 at 06:52:24 PM, Pantelis Antoniou wrote:
 Remove the in-structure ops and put them in mmc_ops with
 a constant pointer to it.
 
 This makes the mmc structure smaller as well as conserving
 code space (in theory).
 
 All in-tree drivers are converted as well; this is done in a
 single patch in order to not break git bisect.
 
 Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com

f_min, voltages ... are also slot-specific , so you want to pull them out as 
well I think.

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] mmc: Remove ops from struct mmc and put in mmc_ops

2014-02-27 Thread Tom Rini
On Wed, Feb 26, 2014 at 07:52:24PM +0200, Pantelis Antoniou wrote:

 Remove the in-structure ops and put them in mmc_ops with
 a constant pointer to it.
 
 This makes the mmc structure smaller as well as conserving
 code space (in theory).
 
 All in-tree drivers are converted as well; this is done in a
 single patch in order to not break git bisect.
 
 Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com
[snip]
 diff --git a/drivers/mmc/omap_hsmmc.c b/drivers/mmc/omap_hsmmc.c
 index d3a8b53..4b27097 100644
 --- a/drivers/mmc/omap_hsmmc.c
 +++ b/drivers/mmc/omap_hsmmc.c
 @@ -70,25 +70,12 @@ static int omap_mmc_setup_gpio_in(int gpio, const char 
 *label)
   return gpio;
  }
  
 -static int omap_mmc_getcd(struct mmc *mmc)
 -{
 - int cd_gpio = ((struct omap_hsmmc_data *)mmc-priv)-cd_gpio;
 - return gpio_get_value(cd_gpio);
 -}
 -
 -static int omap_mmc_getwp(struct mmc *mmc)
 -{
 - int wp_gpio = ((struct omap_hsmmc_data *)mmc-priv)-wp_gpio;
 - return gpio_get_value(wp_gpio);
 -}
  #else
  static inline int omap_mmc_setup_gpio_in(int gpio, const char *label)
  {
   return -1;
  }
  
 -#define omap_mmc_getcd NULL
 -#define omap_mmc_getwp NULL
  #endif

Note that we're not just testing for SPL in the above we're also testing
for OMAP_GPIO being set.  So this breaks am3517_evm tseries_spi mcx
am3517_crane omap3_evm_quick_mmc omap3_evm omap3_zoom1 omap3_sdp3430 and
tseries_mmc.

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] mmc: Remove ops from struct mmc and put in mmc_ops

2014-02-27 Thread Tom Rini
On Thu, Feb 27, 2014 at 04:04:55AM +, Rommel G Custodio wrote:
 Dear Pantelis Antoniou
 
 Pantelis Antoniou panto at antoniou-consulting.com writes:
 
  
  Remove the in-structure ops and put them in mmc_ops with
  a constant pointer to it.
  
  This makes the mmc structure smaller as well as conserving
  code space (in theory).
 
 First build is latest master. Second build was with your patch. Compare size 
 output.
 
 
 [local (powerpc-linux-gnuspe)]$ powerpc-linux-gnuspe-size obj-
 P5040DS_SPIFLASH_master/u-boot
textdata bss dec hex filename
  463352   39236  314064  816652   c760c obj-P5040DS_SPIFLASH_master/u-boot
 
 
 [local (powerpc-linux-gnuspe)]$ powerpc-linux-gnuspe-size obj-
 P5040DS_SPIFLASH/u-boot
textdata bss dec hex filename
  463364   39256  314064  816684   c762c obj-P5040DS_SPIFLASH/u-boot

The size increase on ARM is smaller, but still there too.

So we aren't making the code smaller nor the binaries.  Marek, was this
your request to clean up or ?  Will this help make device model stuff
easier down the line?

-- 
Tom


signature.asc
Description: Digital signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RFC] mmc: Remove ops from struct mmc and put in mmc_ops

2014-02-26 Thread Pantelis Antoniou
Remove the in-structure ops and put them in mmc_ops with
a constant pointer to it.

This makes the mmc structure smaller as well as conserving
code space (in theory).

All in-tree drivers are converted as well; this is done in a
single patch in order to not break git bisect.

Signed-off-by: Pantelis Antoniou pa...@antoniou-consulting.com
---
 drivers/mmc/arm_pl180_mmci.c | 12 +
 drivers/mmc/bfin_sdh.c   | 11 
 drivers/mmc/davinci_mmc.c| 13 -
 drivers/mmc/dw_mmc.c | 10 ---
 drivers/mmc/fsl_esdhc.c  | 14 +-
 drivers/mmc/ftsdc010_mci.c   | 11 +---
 drivers/mmc/gen_atmel_mci.c  | 12 +
 drivers/mmc/mmc.c| 21 ---
 drivers/mmc/mmc_spi.c| 12 +
 drivers/mmc/mxcmmc.c | 12 +
 drivers/mmc/mxsmmc.c | 12 +
 drivers/mmc/omap_hsmmc.c | 63 +++-
 drivers/mmc/pxa_mmc_gen.c| 11 +---
 drivers/mmc/sdhci.c  | 13 +
 drivers/mmc/sh_mmcif.c   | 12 +
 drivers/mmc/tegra_mmc.c  | 19 +++--
 include/mmc.h| 19 -
 17 files changed, 167 insertions(+), 110 deletions(-)

diff --git a/drivers/mmc/arm_pl180_mmci.c b/drivers/mmc/arm_pl180_mmci.c
index 5a55fe7..4490e97 100644
--- a/drivers/mmc/arm_pl180_mmci.c
+++ b/drivers/mmc/arm_pl180_mmci.c
@@ -335,6 +335,12 @@ static void host_set_ios(struct mmc *dev)
udelay(CLK_CHANGE_DELAY);
 }
 
+static const struct mmc_ops arm_pl180_mmci_ops = {
+   .send_cmd = host_request,
+   .set_ios = host_set_ios,
+   .init = mmc_host_reset,
+};
+
 /*
  * mmc_host_init - initialize the mmc controller.
  * Set initial clock and power for mmc slot.
@@ -360,11 +366,7 @@ int arm_pl180_mmci_init(struct pl180_mmc_host *host)
sdi_u32 = readl(host-base-mask0)  ~SDI_MASK0_MASK;
writel(sdi_u32, host-base-mask0);
strncpy(dev-name, host-name, sizeof(dev-name));
-   dev-send_cmd = host_request;
-   dev-set_ios = host_set_ios;
-   dev-init = mmc_host_reset;
-   dev-getcd = NULL;
-   dev-getwp = NULL;
+   dev-ops = arm_pl180_mmci_ops;
dev-host_caps = host-caps;
dev-voltages = host-voltages;
dev-f_min = host-clock_min;
diff --git a/drivers/mmc/bfin_sdh.c b/drivers/mmc/bfin_sdh.c
index bd9b641..f0871ec 100644
--- a/drivers/mmc/bfin_sdh.c
+++ b/drivers/mmc/bfin_sdh.c
@@ -274,6 +274,11 @@ static int bfin_sdh_init(struct mmc *mmc)
return 0;
 }
 
+static const struct mmc_ops bfin_mmc_ops = {
+   .send_cmd   = bfin_sdh_request,
+   .set_ios= bfin_sdh_set_ios,
+   .init   = bfin_sdh_init,
+};
 
 int bfin_mmc_init(bd_t *bis)
 {
@@ -284,11 +289,7 @@ int bfin_mmc_init(bd_t *bis)
if (!mmc)
return -ENOMEM;
sprintf(mmc-name, Blackfin SDH);
-   mmc-send_cmd = bfin_sdh_request;
-   mmc-set_ios = bfin_sdh_set_ios;
-   mmc-init = bfin_sdh_init;
-   mmc-getcd = NULL;
-   mmc-getwp = NULL;
+   mmc-ops = bfin_mmc_ops;
mmc-host_caps = MMC_MODE_4BIT;
 
mmc-voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
diff --git a/drivers/mmc/davinci_mmc.c b/drivers/mmc/davinci_mmc.c
index b380961..29ca4a6 100644
--- a/drivers/mmc/davinci_mmc.c
+++ b/drivers/mmc/davinci_mmc.c
@@ -363,6 +363,12 @@ static void dmmc_set_ios(struct mmc *mmc)
dmmc_set_clock(mmc, mmc-clock);
 }
 
+static const struct mmc_ops dmmc_ops = {
+   .send_cmd   = dmmc_send_cmd,
+   .set_ios= dmmc_set_ios,
+   .init   = dmmc_init,
+};
+
 /* Called from board_mmc_init during startup. Can be called multiple times
  * depending on the number of slots available on board and controller
  */
@@ -375,12 +381,7 @@ int davinci_mmc_init(bd_t *bis, struct davinci_mmc *host)
 
sprintf(mmc-name, davinci);
mmc-priv = host;
-   mmc-send_cmd = dmmc_send_cmd;
-   mmc-set_ios = dmmc_set_ios;
-   mmc-init = dmmc_init;
-   mmc-getcd = NULL;
-   mmc-getwp = NULL;
-
+   mmc-ops = dmmc_ops;
mmc-f_min = 20;
mmc-f_max = 2500;
mmc-voltages = host-voltages;
diff --git a/drivers/mmc/dw_mmc.c b/drivers/mmc/dw_mmc.c
index d45c15c..2e6576e 100644
--- a/drivers/mmc/dw_mmc.c
+++ b/drivers/mmc/dw_mmc.c
@@ -343,6 +343,12 @@ static int dwmci_init(struct mmc *mmc)
return 0;
 }
 
+static const struct mmc_ops dwmci_ops = {
+   .send_cmd   = dwmci_send_cmd,
+   .set_ios= dwmci_set_ios,
+   .init   = dwmci_init,
+};
+
 int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 min_clk)
 {
struct mmc *mmc;
@@ -358,9 +364,7 @@ int add_dwmci(struct dwmci_host *host, u32 max_clk, u32 
min_clk)
host-mmc = mmc;
 
sprintf(mmc-name, %s, host-name);
-   mmc-send_cmd = dwmci_send_cmd;
-   mmc-set_ios = dwmci_set_ios;
-   mmc-init = dwmci_init;
+   mmc-ops = dwmci_ops;
mmc-f_min = min_clk;

Re: [U-Boot] [RFC] mmc: Remove ops from struct mmc and put in mmc_ops

2014-02-26 Thread Rommel G Custodio
Dear Pantelis Antoniou

Pantelis Antoniou panto at antoniou-consulting.com writes:

 
 Remove the in-structure ops and put them in mmc_ops with
 a constant pointer to it.
 
 This makes the mmc structure smaller as well as conserving
 code space (in theory).

First build is latest master. Second build was with your patch. Compare size 
output.


[local (powerpc-linux-gnuspe)]$ powerpc-linux-gnuspe-size obj-
P5040DS_SPIFLASH_master/u-boot
   textdata bss dec hex filename
 463352   39236  314064  816652   c760c obj-P5040DS_SPIFLASH_master/u-boot


[local (powerpc-linux-gnuspe)]$ powerpc-linux-gnuspe-size obj-
P5040DS_SPIFLASH/u-boot
   textdata bss dec hex filename
 463364   39256  314064  816684   c762c obj-P5040DS_SPIFLASH/u-boot

 
 All in-tree drivers are converted as well; this is done in a
 single patch in order to not break git bisect.
 

snipped

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot