From: Marek Vasut <marek.vasut@gmail.com>
To: zhangfei gao <zhangfei.gao@gmail.com>
Cc: linux-arm-kernel@lists.infradead.org, Chris Ball <cjb@laptop.org>,
Matt Fleming <matt@console-pimps.org>,
"eric.y.miao" <eric.y.miao@gmail.com>,
linux-mmc <linux-mmc@vger.kernel.org>,
Wolfram Sang <w.sang@pengutronix.de>,
Haojian Zhuang <haojian.zhuang@gmail.com>
Subject: Re: [PATCH V3 1/1]MMC: add support of sdhci-pxa driver
Date: Sat, 23 Oct 2010 19:50:31 +0200 [thread overview]
Message-ID: <201010231950.31707.marek.vasut@gmail.com> (raw)
In-Reply-To: <AANLkTi=RNDf-A98LN3AH=JdegHXKRjHvtGCDYtkJ5ADg@mail.gmail.com>
Dne So 23. října 2010 18:47:10 zhangfei gao napsal(a):
> On Sat, Oct 23, 2010 at 10:24 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> >> +/**********************************************************************
> >> *** ****\ + *
> >> * + * Device probing/removal
> >> * + *
> >> *
> >> +\**********************************************************************
> >> ** *****/ +
> >> +static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
> >> +{
> >> + struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
> >> + struct device *dev = &pdev->dev;
> >> + struct sdhci_host *host = NULL;
> >> + struct resource *iomem = NULL;
> >> + struct sdhci_pxa *pxa = NULL;
> >> + int ret, irq;
> >> +
> >> + irq = platform_get_irq(pdev, 0);
> >> + if (irq < 0) {
> >> + dev_err(dev, "no irq specified\n");
> >> + return irq;
> >> + }
> >> +
> >> + iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >> + if (!iomem) {
> >> + dev_err(dev, "no memory specified\n");
> >> + return -ENOENT;
> >> + }
> >> +
> >> + host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pxa));
> >> + if (IS_ERR(host)) {
> >> + dev_err(dev, "failed to alloc host\n");
> >> + return PTR_ERR(host);
> >> + }
> >> +
> >> + pxa = sdhci_priv(host);
> >> + pxa->host = host;
> >> + pxa->pdata = pdata;
> >> + pxa->clk_enable = 0;
> >> +
> >> + pxa->clk = clk_get(dev, "PXA-SDHCLK");
> >> + if (IS_ERR(pxa->clk)) {
> >> + dev_err(dev, "failed to get io clock\n");
> >> + ret = PTR_ERR(pxa->clk);
> >> + goto out;
> >> + }
> >> +
> >> + pxa->res = request_mem_region(iomem->start, resource_size(iomem),
> >> + mmc_hostname(host->mmc));
> >> + if (!pxa->res) {
> >> + dev_err(&pdev->dev, "cannot request region\n");
> >> + ret = -EBUSY;
> >> + goto out;
> >> + }
> >> +
> >> + host->ioaddr = ioremap(iomem->start, resource_size(iomem));
> >> + if (!host->ioaddr) {
> >> + dev_err(&pdev->dev, "failed to remap registers\n");
> >> + ret = -ENOMEM;
> >> + goto out;
> >> + }
> >> +
> >> + host->hw_name = "MMC";
> >> + host->ops = &sdhci_pxa_ops;
> >> + host->irq = irq;
> >> + host->quirks = SDHCI_QUIRK_BROKEN_ADMA |
> >> SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; +
> >
> > Maybe check if these aren't already set in pdata and warn user ?
>
> Here pdata->quirks only provide specific quirk like
> SDHCI_QUIRK_BROKEN_CARD_DETECTION for on-chip device, the common quirk
> is provided above.
Right, but what if the user also provides such a quirk? It's unnecessary ... and
in case the quirk was removed from here later, it'd have to be removed from
user's code too ...
> In sdhci-s3c, host->quirks is modified here via pdata->cd_type, which
> is also a good method.
> Here we transfer SDHCI_QUIRK_BROKEN_CARD_DETECTION directly from pdata
> since it already move to include folder.
>
> >> + if (pdata->quirks)
> >> + host->quirks |= pdata->quirks;
> >> +
> >> + ret = sdhci_add_host(host);
> >> + if (ret) {
> >> + dev_err(&pdev->dev, "failed to add host\n");
> >> + goto out;
> >> + }
> >> +
> >> + if (pxa->pdata->max_speed)
> >> + host->mmc->f_max = pxa->pdata->max_speed;
> >
> > What happens otherwise ?
>
> Otherwise, host->mmc->f_max = host->max_clk set in sdhci_add_host,
> host->max_clk is 50M in 2.0 controller, and 200M in 3.0 controller, if
> controller does not need to provide get_max_clock.
> it's better add defalut value in else condition.
Thanks for clearing this
>
> Thanks Marek for review.
>
> >> +
> >> + platform_set_drvdata(pdev, host);
> >> +
> >> + return 0;
> >> +out:
> >> + if (host) {
> >> + clk_put(pxa->clk);
> >> + if (host->ioaddr)
> >> + iounmap(host->ioaddr);
> >> + if (pxa->res)
> >> + release_mem_region(pxa->res->start,
> >> + resource_size(pxa->res));
> >> + sdhci_free_host(host);
> >> + }
> >> +
> >> + return ret;
> >> +}
> >> +
> >
> > Thanks!
> >
> > Cheers
WARNING: multiple messages have this Message-ID (diff)
From: marek.vasut@gmail.com (Marek Vasut)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V3 1/1]MMC: add support of sdhci-pxa driver
Date: Sat, 23 Oct 2010 19:50:31 +0200 [thread overview]
Message-ID: <201010231950.31707.marek.vasut@gmail.com> (raw)
In-Reply-To: <AANLkTi=RNDf-A98LN3AH=JdegHXKRjHvtGCDYtkJ5ADg@mail.gmail.com>
Dne So 23. ??jna 2010 18:47:10 zhangfei gao napsal(a):
> On Sat, Oct 23, 2010 at 10:24 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> >> +/**********************************************************************
> >> *** ****\ + *
> >> * + * Device probing/removal
> >> * + *
> >> *
> >> +\**********************************************************************
> >> ** *****/ +
> >> +static int __devinit sdhci_pxa_probe(struct platform_device *pdev)
> >> +{
> >> + struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
> >> + struct device *dev = &pdev->dev;
> >> + struct sdhci_host *host = NULL;
> >> + struct resource *iomem = NULL;
> >> + struct sdhci_pxa *pxa = NULL;
> >> + int ret, irq;
> >> +
> >> + irq = platform_get_irq(pdev, 0);
> >> + if (irq < 0) {
> >> + dev_err(dev, "no irq specified\n");
> >> + return irq;
> >> + }
> >> +
> >> + iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> >> + if (!iomem) {
> >> + dev_err(dev, "no memory specified\n");
> >> + return -ENOENT;
> >> + }
> >> +
> >> + host = sdhci_alloc_host(&pdev->dev, sizeof(struct sdhci_pxa));
> >> + if (IS_ERR(host)) {
> >> + dev_err(dev, "failed to alloc host\n");
> >> + return PTR_ERR(host);
> >> + }
> >> +
> >> + pxa = sdhci_priv(host);
> >> + pxa->host = host;
> >> + pxa->pdata = pdata;
> >> + pxa->clk_enable = 0;
> >> +
> >> + pxa->clk = clk_get(dev, "PXA-SDHCLK");
> >> + if (IS_ERR(pxa->clk)) {
> >> + dev_err(dev, "failed to get io clock\n");
> >> + ret = PTR_ERR(pxa->clk);
> >> + goto out;
> >> + }
> >> +
> >> + pxa->res = request_mem_region(iomem->start, resource_size(iomem),
> >> + mmc_hostname(host->mmc));
> >> + if (!pxa->res) {
> >> + dev_err(&pdev->dev, "cannot request region\n");
> >> + ret = -EBUSY;
> >> + goto out;
> >> + }
> >> +
> >> + host->ioaddr = ioremap(iomem->start, resource_size(iomem));
> >> + if (!host->ioaddr) {
> >> + dev_err(&pdev->dev, "failed to remap registers\n");
> >> + ret = -ENOMEM;
> >> + goto out;
> >> + }
> >> +
> >> + host->hw_name = "MMC";
> >> + host->ops = &sdhci_pxa_ops;
> >> + host->irq = irq;
> >> + host->quirks = SDHCI_QUIRK_BROKEN_ADMA |
> >> SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; +
> >
> > Maybe check if these aren't already set in pdata and warn user ?
>
> Here pdata->quirks only provide specific quirk like
> SDHCI_QUIRK_BROKEN_CARD_DETECTION for on-chip device, the common quirk
> is provided above.
Right, but what if the user also provides such a quirk? It's unnecessary ... and
in case the quirk was removed from here later, it'd have to be removed from
user's code too ...
> In sdhci-s3c, host->quirks is modified here via pdata->cd_type, which
> is also a good method.
> Here we transfer SDHCI_QUIRK_BROKEN_CARD_DETECTION directly from pdata
> since it already move to include folder.
>
> >> + if (pdata->quirks)
> >> + host->quirks |= pdata->quirks;
> >> +
> >> + ret = sdhci_add_host(host);
> >> + if (ret) {
> >> + dev_err(&pdev->dev, "failed to add host\n");
> >> + goto out;
> >> + }
> >> +
> >> + if (pxa->pdata->max_speed)
> >> + host->mmc->f_max = pxa->pdata->max_speed;
> >
> > What happens otherwise ?
>
> Otherwise, host->mmc->f_max = host->max_clk set in sdhci_add_host,
> host->max_clk is 50M in 2.0 controller, and 200M in 3.0 controller, if
> controller does not need to provide get_max_clock.
> it's better add defalut value in else condition.
Thanks for clearing this
>
> Thanks Marek for review.
>
> >> +
> >> + platform_set_drvdata(pdev, host);
> >> +
> >> + return 0;
> >> +out:
> >> + if (host) {
> >> + clk_put(pxa->clk);
> >> + if (host->ioaddr)
> >> + iounmap(host->ioaddr);
> >> + if (pxa->res)
> >> + release_mem_region(pxa->res->start,
> >> + resource_size(pxa->res));
> >> + sdhci_free_host(host);
> >> + }
> >> +
> >> + return ret;
> >> +}
> >> +
> >
> > Thanks!
> >
> > Cheers
next prev parent reply other threads:[~2010-10-23 17:50 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-18 12:32 [PATCH V3 1/1]MMC: add support of sdhci-pxa driver zhangfei gao
2010-10-18 14:58 ` Wolfram Sang
2010-10-18 15:25 ` zhangfei gao
2010-10-19 2:03 ` Wolfram Sang
2010-10-19 9:44 ` zhangfei gao
2010-10-21 14:13 ` Chris Ball
2010-10-21 14:20 ` zhangfei gao
2010-10-21 14:52 ` Chris Ball
2010-10-21 14:52 ` Chris Ball
2010-10-22 0:20 ` Marek Vasut
2010-10-22 0:20 ` Marek Vasut
2010-10-22 0:27 ` Chris Ball
2010-10-22 0:27 ` Chris Ball
2010-10-22 8:44 ` Haojian Zhuang
2010-10-22 8:44 ` Haojian Zhuang
2010-10-22 9:58 ` Chris Ball
2010-10-22 9:58 ` Chris Ball
2010-10-22 11:04 ` Chris Ball
2010-10-22 11:04 ` Chris Ball
2010-10-22 14:09 ` zhangfei gao
2010-10-22 14:09 ` zhangfei gao
2010-10-23 14:24 ` Marek Vasut
2010-10-23 14:24 ` Marek Vasut
2010-10-23 16:47 ` zhangfei gao
2010-10-23 16:47 ` zhangfei gao
2010-10-23 17:50 ` Marek Vasut [this message]
2010-10-23 17:50 ` Marek Vasut
2010-10-24 3:26 ` zhangfei gao
2010-10-24 3:26 ` zhangfei gao
2010-10-24 4:02 ` Marek Vasut
2010-10-24 4:02 ` Marek Vasut
2010-10-25 5:48 ` zhangfei gao
2010-10-25 5:48 ` 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=201010231950.31707.marek.vasut@gmail.com \
--to=marek.vasut@gmail.com \
--cc=cjb@laptop.org \
--cc=eric.y.miao@gmail.com \
--cc=haojian.zhuang@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mmc@vger.kernel.org \
--cc=matt@console-pimps.org \
--cc=w.sang@pengutronix.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.