public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang@pengutronix.de>
To: zhangfei gao <zhangfei.gao@gmail.com>
Cc: linux-mmc@vger.kernel.org, Chris Ball <cjb@laptop.org>,
	eric.y.miao@gmail.com, Haojian Zhuang <haojian.zhuang@gmail.com>,
	Richard Zhu <r65037@freescale.com>
Subject: Re: [patch] sdhci-pltfm: add call back function
Date: Sun, 26 Sep 2010 18:09:33 +0200	[thread overview]
Message-ID: <20100926160933.GA23180@pengutronix.de> (raw)
In-Reply-To: <AANLkTi=tkP2O+EaY5xSQ8EZAR0rP9gTz34cipC-WTHjf@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 8036 bytes --]

On Sun, Sep 26, 2010 at 04:52:06AM -0400, zhangfei gao wrote:
> Add several call back to sdhci-pltfm.c, help give suggestion

Just formal things, without looking at the code yet.

Make seperate patches out of these, everyone with a proper description.

> 1. struct sdhci_host *(*alloc_host)(struct device *dev), since
> specific driver need some private variable to allocate and free,
> including clk.
> 2. unsigned int  (*get_quirk)(struct sdhci_host *host); add this
> because one driver may serve several device, each one may require
> different quirk, and specific driver is right one to know.
> 3. void (*set_max_speed)(struct sdhci_host *host); this should be done
> after add_host, which impact f_max.
> 4. int (*init)(struct sdhci_host *host, struct sdhci_pltfm_data
> *pdata, void* priv_pdata); copy from Wolfram Sang's patch to transfer
> platform data, copy here for test.

No copying. If you think my patch is useful, add an Acked-by and say your
patches depend on mine.

> 
> From 8c59d0b917f434d7c424ce1e0896af45c3e5fbba Mon Sep 17 00:00:00 2001
> From: Zhangfei Gao <zhangfei.gao@marvell.com>
> Date: Sun, 26 Sep 2010 16:37:11 -0400
> Subject: [PATCH 2/2] sdhci-pltfm: add call back function
> 
> 
> Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
> ---
>  drivers/mmc/host/sdhci-pltfm.c |   24 ++++++++++++++++++------
>  include/linux/sdhci-pltfm.h    |    5 ++++-
>  2 files changed, 22 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
> index e045e3c..e06f047 100644
> --- a/drivers/mmc/host/sdhci-pltfm.c
> +++ b/drivers/mmc/host/sdhci-pltfm.c
> @@ -54,12 +54,17 @@ static int __devinit sdhci_pltfm_probe(struct
> platform_device *pdev)
>  {
>  	struct sdhci_pltfm_data *pdata = pdev->dev.platform_data;
>  	const struct platform_device_id *platid = platform_get_device_id(pdev);
> +	void *priv_pdata = NULL;
>  	struct sdhci_host *host;
>  	struct resource *iomem;
>  	int ret;
> 
> -	if (!pdata && platid && platid->driver_data)
> +	if (platid && platid->driver_data) {
>  		pdata = (void *)platid->driver_data;
> +		priv_pdata = pdev->dev.platform_data;
> +	} else {
> +		pdata = pdev->dev.platform_data;
> +	}
> 
>  	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!iomem) {
> @@ -71,8 +76,8 @@ static int __devinit sdhci_pltfm_probe(struct
> platform_device *pdev)
>  		dev_err(&pdev->dev, "Invalid iomem size. You may "
>  			"experience problems.\n");
> 
> -	if (pdev->dev.parent)
> -		host = sdhci_alloc_host(pdev->dev.parent, 0);
> +	if (pdata && pdata->alloc_host)
> +		host = pdata->alloc_host(&pdev->dev);
>  	else
>  		host = sdhci_alloc_host(&pdev->dev, 0);
> 
> @@ -86,8 +91,7 @@ static int __devinit sdhci_pltfm_probe(struct
> platform_device *pdev)
>  		host->ops = pdata->ops;
>  	else
>  		host->ops = &sdhci_pltfm_ops;
> -	if (pdata)
> -		host->quirks = pdata->quirks;
> +
>  	host->irq = platform_get_irq(pdev, 0);
> 
>  	if (!request_mem_region(iomem->start, resource_size(iomem),
> @@ -105,15 +109,23 @@ static int __devinit sdhci_pltfm_probe(struct
> platform_device *pdev)
>  	}
> 
>  	if (pdata && pdata->init) {
> -		ret = pdata->init(host);
> +		ret = pdata->init(host, pdata, priv_pdata);
>  		if (ret)
>  			goto err_plat_init;
>  	}
> 
> +	if (pdata && pdata->get_quirk)
> +		host->quirks = pdata->get_quirk(host);
> +	else if (pdata)
> +		host->quirks = pdata->quirks;
> +
>  	ret = sdhci_add_host(host);
>  	if (ret)
>  		goto err_add_host;
> 
> +	if (pdata && pdata->set_max_speed)
> +		pdata->set_max_speed(host);
> +
>  	platform_set_drvdata(pdev, host);
> 
>  	return 0;
> diff --git a/include/linux/sdhci-pltfm.h b/include/linux/sdhci-pltfm.h
> index 0239bd7..0d8e8f6 100644
> --- a/include/linux/sdhci-pltfm.h
> +++ b/include/linux/sdhci-pltfm.h
> @@ -28,8 +28,11 @@ struct sdhci_host;
>  struct sdhci_pltfm_data {
>  	struct sdhci_ops *ops;
>  	unsigned int quirks;
> -	int (*init)(struct sdhci_host *host);
> +	int (*init)(struct sdhci_host *host, struct sdhci_pltfm_data *pdata,
> void* priv_pdata);
>  	void (*exit)(struct sdhci_host *host);
> +	void (*set_max_speed)(struct sdhci_host *host);
> +	unsigned int  (*get_quirk)(struct sdhci_host *host);
> +	struct sdhci_host *(*alloc_host)(struct device *dev);
>  };
> 
>  #endif /* _SDHCI_PLTFM_H */
> -- 
> 1.7.0.4

> From 8c59d0b917f434d7c424ce1e0896af45c3e5fbba Mon Sep 17 00:00:00 2001
> From: Zhangfei Gao <zhangfei.gao@marvell.com>
> Date: Sun, 26 Sep 2010 16:37:11 -0400
> Subject: [PATCH 2/2] sdhci-pltfm: add call back function
> 
> 
> Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
> ---
>  drivers/mmc/host/sdhci-pltfm.c |   24 ++++++++++++++++++------
>  include/linux/sdhci-pltfm.h    |    5 ++++-
>  2 files changed, 22 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
> index e045e3c..e06f047 100644
> --- a/drivers/mmc/host/sdhci-pltfm.c
> +++ b/drivers/mmc/host/sdhci-pltfm.c
> @@ -54,12 +54,17 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev)
>  {
>  	struct sdhci_pltfm_data *pdata = pdev->dev.platform_data;
>  	const struct platform_device_id *platid = platform_get_device_id(pdev);
> +	void *priv_pdata = NULL;
>  	struct sdhci_host *host;
>  	struct resource *iomem;
>  	int ret;
>  
> -	if (!pdata && platid && platid->driver_data)
> +	if (platid && platid->driver_data) {
>  		pdata = (void *)platid->driver_data;
> +		priv_pdata = pdev->dev.platform_data;
> +	} else {
> +		pdata = pdev->dev.platform_data;
> +	}
>  
>  	iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>  	if (!iomem) {
> @@ -71,8 +76,8 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev)
>  		dev_err(&pdev->dev, "Invalid iomem size. You may "
>  			"experience problems.\n");
>  
> -	if (pdev->dev.parent)
> -		host = sdhci_alloc_host(pdev->dev.parent, 0);
> +	if (pdata && pdata->alloc_host)
> +		host = pdata->alloc_host(&pdev->dev);
>  	else
>  		host = sdhci_alloc_host(&pdev->dev, 0);
>  
> @@ -86,8 +91,7 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev)
>  		host->ops = pdata->ops;
>  	else
>  		host->ops = &sdhci_pltfm_ops;
> -	if (pdata)
> -		host->quirks = pdata->quirks;
> +
>  	host->irq = platform_get_irq(pdev, 0);
>  
>  	if (!request_mem_region(iomem->start, resource_size(iomem),
> @@ -105,15 +109,23 @@ static int __devinit sdhci_pltfm_probe(struct platform_device *pdev)
>  	}
>  
>  	if (pdata && pdata->init) {
> -		ret = pdata->init(host);
> +		ret = pdata->init(host, pdata, priv_pdata);
>  		if (ret)
>  			goto err_plat_init;
>  	}
>  
> +	if (pdata && pdata->get_quirk)
> +		host->quirks = pdata->get_quirk(host);
> +	else if (pdata)
> +		host->quirks = pdata->quirks;
> +
>  	ret = sdhci_add_host(host);
>  	if (ret)
>  		goto err_add_host;
>  
> +	if (pdata && pdata->set_max_speed)
> +		pdata->set_max_speed(host);
> +
>  	platform_set_drvdata(pdev, host);
>  
>  	return 0;
> diff --git a/include/linux/sdhci-pltfm.h b/include/linux/sdhci-pltfm.h
> index 0239bd7..0d8e8f6 100644
> --- a/include/linux/sdhci-pltfm.h
> +++ b/include/linux/sdhci-pltfm.h
> @@ -28,8 +28,11 @@ struct sdhci_host;
>  struct sdhci_pltfm_data {
>  	struct sdhci_ops *ops;
>  	unsigned int quirks;
> -	int (*init)(struct sdhci_host *host);
> +	int (*init)(struct sdhci_host *host, struct sdhci_pltfm_data *pdata, void* priv_pdata);
>  	void (*exit)(struct sdhci_host *host);
> +	void (*set_max_speed)(struct sdhci_host *host);
> +	unsigned int  (*get_quirk)(struct sdhci_host *host);
> +	struct sdhci_host *(*alloc_host)(struct device *dev);
>  };
>  
>  #endif /* _SDHCI_PLTFM_H */
> -- 
> 1.7.0.4
> 


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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2010-09-26 16:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-26  8:52 [patch] sdhci-pltfm: add call back function zhangfei gao
2010-09-26 16:09 ` Wolfram Sang [this message]
2010-09-27  1:06   ` Eric Miao
2010-09-27 12:41     ` Wolfram Sang
2010-09-27  2:50   ` zhangfei gao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100926160933.GA23180@pengutronix.de \
    --to=w.sang@pengutronix.de \
    --cc=cjb@laptop.org \
    --cc=eric.y.miao@gmail.com \
    --cc=haojian.zhuang@gmail.com \
    --cc=linux-mmc@vger.kernel.org \
    --cc=r65037@freescale.com \
    --cc=zhangfei.gao@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox