[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ff0170ef-2566-1c12-0b27-dccb3bff2e7e@rock-chips.com>
Date: Fri, 27 Jan 2017 10:03:19 +0800
From: Shawn Lin <shawn.lin@...k-chips.com>
To: Gerd Hoffmann <kraxel@...hat.com>,
linux-rpi-kernel@...ts.infradead.org
Cc: Stefan Wahren <stefan.wahren@...e.com>,
Eric Anholt <eric@...olt.net>,
Ulf Hansson <ulf.hansson@...aro.org>,
linux-mmc@...r.kernel.org, Florian Fainelli <f.fainelli@...il.com>,
Ray Jui <rjui@...adcom.com>,
Scott Branden <sbranden@...adcom.com>,
"maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE..."
<bcm-kernel-feedback-list@...adcom.com>,
Stephen Warren <swarren@...dotorg.org>,
Lee Jones <lee@...nel.org>,
"moderated list:BROADCOM BCM2835 ARM ARCHITECTURE"
<linux-arm-kernel@...ts.infradead.org>,
open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 01/13] mmc: bcm2835: add bcm2835_read_wait_sdcmd
On 2017/1/27 7:37, Gerd Hoffmann wrote:
> Signed-off-by: Gerd Hoffmann <kraxel@...hat.com>
> ---
> drivers/mmc/host/bcm2835.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
> index 9744517..ceee4cf 100644
> --- a/drivers/mmc/host/bcm2835.c
> +++ b/drivers/mmc/host/bcm2835.c
> @@ -609,6 +609,36 @@ static void bcm2835_prepare_data(struct bcm2835_host *host,
> writel(data->blocks, host->ioaddr + SDHBLC);
> }
>
> +static u32 bcm2835_read_wait_sdcmd(struct bcm2835_host *host, u32 timeout,
> + bool check_fail)
> +{
> + struct device *dev = &host->pdev->dev;
> + unsigned long start = jiffies;
> + unsigned long fastpoll = start + usecs_to_jiffies(10);
> + unsigned long end = start + msecs_to_jiffies(timeout);
> + u32 value;
> +
> + for (;;) {
> + value = readl(host->ioaddr + SDCMD);
> + if (!(value & SDCMD_NEW_FLAG))
> + break;
> + if (check_fail && (value & SDCMD_FAIL_FLAG))
> + break;
> + if (time_after(jiffies, end)) {
> + dev_err(dev, "%s: timeout (%d us)\n",
> + __func__, timeout);
> + break;
> + }
> +
> + /* if it takes longer reduce poll interval */
> + if (time_after(jiffies, fastpoll))
> + udelay(10);
> + else
> + cpu_relax();
> + }
Use readl_poll_timeout intead of open-coding them..
> + return value;
> +}
> +
> bool bcm2835_send_command(struct bcm2835_host *host,
> struct mmc_command *cmd)
> {
>
--
Best Regards
Shawn Lin
Powered by blists - more mailing lists