From: Shawn Guo <shawn.guo@freescale.com>
To: Grant Likely <grant.likely@secretlab.ca>
Cc: Shawn Guo <shawn.guo@linaro.org>, <linaro-dev@lists.linaro.org>,
<sameo@linux.intel.com>, <patches@linaro.org>,
<devicetree-discuss@lists.ozlabs.org>,
<linux-mmc@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/5] mmc: sdhci: make sdhci-esdhc-imx driver self registered
Date: Fri, 25 Mar 2011 17:36:50 +0800 [thread overview]
Message-ID: <20110325093649.GA17228@S2100-06.ap.freescale.net> (raw)
In-Reply-To: <20110324042858.GD27881@ponder.secretlab.ca>
On Wed, Mar 23, 2011 at 10:28:58PM -0600, Grant Likely wrote:
> On Mon, Mar 21, 2011 at 04:06:59PM +0800, Shawn Guo wrote:
> > The patch turns the common stuff to in sdhci-pltfm.c into functions,
> > and add sdhci-esdhc-imx its own .probe and .remove which in turn call
> > into the common functions, so that sdhci-esdhc-imx driver registers
> > itself and keep all sdhci-esdhc-imx specific things like
> > sdhci_esdhc_imx_pdata away from sdhci-pltfm.c which is common.
> >
> > Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
>
> Hi Shawn,
>
Hi Grant,
> Thanks for all this work, I think it is the right thing to do. A few
> relatively minor comments below, but otherwise I like it.
>
> g.
>
> > ---
> > drivers/mmc/host/sdhci-esdhc-imx.c | 98 +++++++++++++++++++++++++++++-------
> > drivers/mmc/host/sdhci-pltfm.c | 84 +++++++++++++++++++++++++++++--
> > drivers/mmc/host/sdhci-pltfm.h | 11 ++++-
>
> I think this patch should be split in 2. One patch to refactor
> edhci-pltfm* to create the common utility functions, and one patch to
> convert the imx driver.
>
I squashed this whole series into one patch in a relevant patch set
I just posted out minutes ago, primarily to reduce the patch quantity
and ease the bisect, since it's logically integral.
[...]
> > +static int __init sdhci_esdhc_imx_init(void)
> > +{
> > + return platform_driver_register(&sdhci_esdhc_imx_driver);
> > +}
> > +
> > +static void __exit sdhci_esdhc_imx_exit(void)
> > +{
> > + platform_driver_unregister(&sdhci_esdhc_imx_driver);
> > +}
> > +
> > +module_init(sdhci_esdhc_imx_init);
> > +module_exit(sdhci_esdhc_imx_exit);
>
> Typically, I like to see module_init() and module_exit() immediately
> adjacent to the functions they register.
>
Incorporated in the new patch set just posted ...
> > +
> > +MODULE_DESCRIPTION("SDHCI driver for i.MX eSDHC");
> > +MODULE_AUTHOR("Wolfram Sang <w.sang@pengutronix.de>");
> > +MODULE_LICENSE("GPL v2");
> > diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
> > index ccc04ac..38b8cb4 100644
> > --- a/drivers/mmc/host/sdhci-pltfm.c
> > +++ b/drivers/mmc/host/sdhci-pltfm.c
> > @@ -44,6 +44,83 @@
> > static struct sdhci_ops sdhci_pltfm_ops = {
> > };
> >
> > +struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev,
> > + struct sdhci_pltfm_data *pdata)
>
> Since there is no chance of *pdata being passed via the
> pdev->dev.platform_data pointer (there aren't any users in mainline of
> that feature) then I would take the opportunity to rename this
> parameter and structure to eliminate any confusion. 'struct
> sdhci_pltfm' would be sufficient I think.
>
The chance comes along with the new patch set (function
sdhci_esdhc_probe in sdhci-esdhc.c). And I would not rename 'struct
sdhci_pltfmi_data' to 'struct sdhci_pltfm' in terms of that we have
another name of 'struct sdhci_pltfm_host'. But yes, pdata does
confuse. Any suggestion? I can fix all of them with a follow-up
patch against the new series.
> > +{
> > + struct sdhci_host *host;
> > + struct sdhci_pltfm_host *pltfm_host;
> > + struct resource *iomem;
> > + int ret;
> > +
> > + iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > + if (!iomem) {
> > + ret = -ENOMEM;
> > + goto err;
> > + }
> > +
> > + if (resource_size(iomem) < 0x100)
> > + dev_err(&pdev->dev, "Invalid iomem size!\n");
> > +
> > + /* Some PCI-based MFD need the parent here */
> > + if (pdev->dev.parent != &platform_bus)
> > + host = sdhci_alloc_host(pdev->dev.parent, sizeof(*pltfm_host));
> > + else
> > + host = sdhci_alloc_host(&pdev->dev, sizeof(*pltfm_host));
> > +
> > + if (IS_ERR(host)) {
> > + ret = PTR_ERR(host);
> > + goto err;
> > + }
> > +
> > + pltfm_host = sdhci_priv(host);
> > +
> > + host->hw_name = "SDHCI";
> > + if (pdata && pdata->ops)
> > + 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),
> > + mmc_hostname(host->mmc))) {
> > + dev_err(&pdev->dev, "cannot request region\n");
> > + ret = -EBUSY;
> > + goto err_request;
> > + }
> > +
> > + host->ioaddr = ioremap(iomem->start, resource_size(iomem));
> > + if (!host->ioaddr) {
> > + dev_err(&pdev->dev, "failed to remap registers\n");
> > + ret = -ENOMEM;
> > + goto err_remap;
> > + }
> > +
> > + platform_set_drvdata(pdev, host);
> > +
> > + return host;
> > +
> > +err_remap:
> > + release_mem_region(iomem->start, resource_size(iomem));
> > +err_request:
> > + sdhci_free_host(host);
> > +err:
> > + pr_err("%s failed %d\n", __func__, ret);
> > + return NULL;
> > +}
>
> Since the bulk of this function is a direct clone of the
> body of sdhci_pltfm_probe(), this patch should also modify
> sdhci_pltfm_probe() to use the new utility function. That will also
> make it clearer to readers that this new block is simply a refactor of
> the old.
>
Good suggestion. Will take it next time where applies ...
--
Regards,
Shawn
next prev parent reply other threads:[~2011-03-25 9:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-21 8:06 [PATCH 0/5] make sdhci device drivers self registered Shawn Guo
2011-03-21 8:06 ` [PATCH 1/5] mmc: sdhci: make sdhci-esdhc-imx driver " Shawn Guo
2011-03-24 4:28 ` Grant Likely
2011-03-25 9:36 ` Shawn Guo [this message]
2011-03-21 8:07 ` [PATCH 2/5] mmc: sdhci: make sdhci-cns3xxx " Shawn Guo
2011-03-21 8:07 ` [PATCH 3/5] mmc: sdhci: make sdhci-dove " Shawn Guo
2011-03-21 8:07 ` [PATCH 4/5] mmc: sdhci: make sdhci-tegra " Shawn Guo
2011-03-21 8:07 ` [PATCH 5/5] mmc: sdhci: update Makefile/Kconfig for sdhci_pltfm change Shawn Guo
2011-03-21 12:39 ` [PATCH 0/5] make sdhci device drivers self registered Arnd Bergmann
2011-03-21 12:52 ` Shawn Guo
2011-03-21 12:54 ` Wolfram Sang
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=20110325093649.GA17228@S2100-06.ap.freescale.net \
--to=shawn.guo@freescale.com \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=grant.likely@secretlab.ca \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=patches@linaro.org \
--cc=sameo@linux.intel.com \
--cc=shawn.guo@linaro.org \
/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;
as well as URLs for NNTP newsgroup(s).