On Mon, Sep 27, 2010 at 12:09 AM, Wolfram Sang <w.sang@xxxxxxxxxxxxxx> wrote: > 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. No problem, here is just draft for discussion, will submit another three call back functions. > >> >> From 8c59d0b917f434d7c424ce1e0896af45c3e5fbba Mon Sep 17 00:00:00 2001 >> From: Zhangfei Gao <zhangfei.gao@xxxxxxxxxxx> >> 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@xxxxxxxxxxx> >> --- >> 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@xxxxxxxxxxx> >> 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@xxxxxxxxxxx> >> --- >> 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/ | > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > > iEYEARECAAYFAkyfcD0ACgkQD27XaX1/VRt1rgCdHfpBgfsUinbhf4wXCvIMreul > tCwAoIvA7nFDgH4jBIZgLX6xRstcENaG > =3A6W > -----END PGP SIGNATURE----- > > -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html