sdhci_pltfm: pass platform_data on custom init-call
RFC 1/1 sdhci_pltfm: pass platform_data on custom init-call
The custom init call may need more data to perform its job, so we pass it a pointer to the platform_data, too. Now, for drivers extending sdhci-pltfm (like sdhci-cns3xxx), a fixed platform_data is used according to the platform device id. Because that one does not contain board specific information, we simply name the board specific information information priv_pdata and pass it to the init routine as well. (Note: the old behaviour was that you could override the platform id specific data with your own. However, one can still do this by using the "sdhci" id instead of "sdhci-<something>".)
---
This approach has its issues, but all I tried had some. So, let's start arguing over code ;)
drivers/mmc/host/sdhci-esdhc.c | 3 ++- drivers/mmc/host/sdhci-pltfm.c | 11 ++++++++--- include/linux/mmc/sdhci-pltfm.h | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-)
drivers/mmc/host/sdhci-esdhc.c +2 -1
@@ -97,7 +97,8 @@ static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)return clk_get_rate (pltfm_host->clk) /256 /16 ; } -static int esdhc_pltfm_init (struct sdhci_host *host) +static int esdhc_pltfm_init (struct sdhci_host *host, +struct sdhci_pltfm_data *pdata,void *priv_pdata) {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct clk *clk;
drivers/mmc/host/sdhci-pltfm.c +8 -3
@@ -52,15 +52,20 @@ static struct sdhci_ops sdhci_pltfm_ops = {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); +struct sdhci_pltfm_data *pdata; +void *priv_pdata =NULL ;struct sdhci_host *host;struct sdhci_pltfm_host *pltfm_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) {
@@ -108,7 +113,7 @@ 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; }
include/linux/mmc/sdhci-pltfm.h +1 -1
@@ -28,7 +28,7 @@ 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); };
Signature · 1 line
1.7.1
drivers/mmc/host/sdhci-esdhc.c
Quoted 24 lines · Wolfram Sang
The custom init call may need more data to perform its job, so we pass it a pointer to the
platform_data, too. Now, for drivers extending sdhci-pltfm (like sdhci-cns3xxx), a fixedplatform_datais used according to the platform device id. Because that one does not contain board specific information, we simply name the board specific information informationpriv_pdataand pass it to the init routine as well. (Note: the old behaviour was that you could override the platform id specific data with your own. However, one can still do this by using the "sdhci" id instead of "sdhci-<something>".)Signed-off-by Wolfram Sang <[email protected]>---
This approach has its issues, but all I tried had some. So, let's start arguing over code ;)
drivers/mmc/host/sdhci-esdhc.c | 3 ++-
drivers/mmc/host/sdhci-pltfm.c| 11 ++++++++---include/linux/mmc/sdhci-pltfm.h| 2 +-3 files changed, 11 insertions(+), 5 deletions(-)drivers/mmc/host/sdhci-esdhc.c +0
-0
Can not find such file, and specific driver should handle in different patch
include/linux/mmc/sdhci-pltfm.h
Quoted 47 lines
drivers/mmc/host/sdhci-esdhc.c +2
-1@@ -97,7 +97,8 @@ static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host) return clk_get_rate(pltfm_host->clk) / 256 / 16; } -static int esdhc_pltfm_init (struct sdhci_host *host) +static int esdhc_pltfm_init (struct sdhci_host *host, + struct sdhci_pltfm_data *pdata, void *priv_pdata) { struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct clk *clk;drivers/mmc/host/sdhci-pltfm.c +8
-3@@ -52,15 +52,20 @@ static struct sdhci_ops sdhci_pltfm_ops = { 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); + struct sdhci_pltfm_data *pdata; + void *priv_pdata = NULL; struct sdhci_host *host; struct sdhci_pltfm_host *pltfm_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) {@@ -108,7 +113,7 @@ 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; }include/linux/mmc/sdhci-pltfm.h +0
-0
include/linux/mmc/sdhci-pltfm.h should be include/linux/sdhci-pltfm.h
Quoted 20 lines
index 0239bd7..e14fce3 100644
include/linux/mmc/sdhci-pltfm.h +1
-2@@ -28,7 +28,7 @@ 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); }; --1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 21 lines · zhangfei gao
Quoted 20 lines · Wolfram Sang
The custom init call may need more data to perform its job, so we pass it a pointer to the
platform_data, too. Now, for drivers extending sdhci-pltfm (like sdhci-cns3xxx), a fixedplatform_datais used according to the platform device id. Because that one does not contain board specific information, we simply name the board specific information informationpriv_pdataand pass it to the init routine as well. (Note: the old behaviour was that you could override the platform id specific data with your own. However, one can still do this by using the "sdhci" id instead of "sdhci-<something>".)Signed-off-by Wolfram Sang <[email protected]>---
This approach has its issues, but all I tried had some. So, let's start arguing over code ;)
drivers/mmc/host/sdhci-esdhc.c | 3 ++- drivers/mmc/host/sdhci-pltfm.c | 11 ++++++++--- include/linux/mmc/sdhci-pltfm.h | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-)
Quoted 6 lines
drivers/mmc/host/sdhci-esdhc.c
Quoted 4 lines
drivers/mmc/host/sdhci-esdhc.c +0
-0Can not find such file, and specific driver should handle in different patch
Hello
we discussed about a similar issues in this thread:
http://marc.info/?l=linux-mmc&m=128523426925028&w=2
There is here an example how to use the .init call and get the platform struct pointer (that works fine in STM platforms).
To have this working, I prepared some patches (under reviewing):
[PATCH (mmc-next) 1/3] mmc: add suspend/resume in the sdhci-pltfm driver [PATCH (mmc-next) 2/3] mmc: split the sdhci.h to help platforms that uses shdci-pltfm d.d.
[PATCH (mmc-next) 3/3] mmc: fix a warning when compile the sdhci d.d.
Hoping this could be useful.
Regards,
Peppe
Quoted 79 lines
drivers/mmc/host/sdhci-esdhc.c static unsigned int esdhc_pltfm_get_min_clock(struct
Quoted 2 lines
drivers/mmc/host/sdhci-esdhc.c +0
-0@@ -97,7 +97,8 @@ static unsigned int esdhc_pltfm_get_min_clock(struct
sdhci_host*host)drivers/mmc/host/sdhci-pltfm.c static int __devinit sdhci_pltfm_probe(struct
Quoted 37 lines
drivers/mmc/host/sdhci-esdhc.c +2
-1return clk_get_rate (pltfm_host->clk) /256 /16 ; } -static int esdhc_pltfm_init (struct sdhci_host *host) +static int esdhc_pltfm_init (struct sdhci_host *host, +struct sdhci_pltfm_data *pdata,void *priv_pdata) {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct clk *clk;drivers/mmc/host/sdhci-pltfm.c +7
-2@@ -52,15 +52,20 @@ static struct sdhci_ops sdhci_pltfm_ops = {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); +struct sdhci_pltfm_data *pdata; +void *priv_pdata =NULL ;struct sdhci_host *host;struct sdhci_pltfm_host *pltfm_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) {@@ -108,7 +113,7 @@ static int __devinit sdhci_pltfm_probe(struct
platform_device*pdev)include/linux/mmc/sdhci-pltfm.h
Quoted 9 lines
drivers/mmc/host/sdhci-pltfm.c +1
-1}if (pdata && pdata->init) { - ret = pdata->init (host); + ret = pdata->init (host, pdata, priv_pdata);if (ret) goto err_plat_init; }include/linux/mmc/sdhci-pltfm.h +0
-0
include/linux/mmc/sdhci-pltfm.hshould beinclude/linux/sdhci-pltfm.hinclude/linux/mmc/sdhci-pltfm.h struct sdhci_host; · line 31
Quoted 9 lines
index 0239bd7..e14fce3 100644
include/linux/mmc/sdhci-pltfm.h +1
-1@@ -28,7 +28,7 @@ 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);Quoted 11 lines
include/linux/mmc/sdhci-pltfm.h +0
-1void (*exit)(struct sdhci_host *host); }; --1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html