All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Prisk <linux@prisktech.co.nz>
To: Axel Lin <axel.lin@ingics.com>, Chris Ball <cjb@laptop.org>
Cc: linux-mmc@vger.kernel.org
Subject: Re: [PATCH] mmc: wmt-sdmmc: Simplify wmt_set_sd_power implementation
Date: Sat, 05 Oct 2013 17:24:54 +1300	[thread overview]
Message-ID: <524F9496.8080209@prisktech.co.nz> (raw)
In-Reply-To: <1380791080.30876.2.camel@phoenix>

On 03/10/13 22:04, Axel Lin wrote:
> Simplify the code to set/clear BM_SD_OFF bit:
>
>            | power_inverted: 0  | power_inverted: 1
> -------------------------------------------------
> enable: 0 | SET BM_SD_OFF      | CLEAR BM_SD_OFF
> -------------------------------------------------
> enable: 1 | CLEAR BM_SD_OFF    | SET BM_SD_OFF
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>   drivers/mmc/host/wmt-sdmmc.c | 30 ++++++++----------------------
>   1 file changed, 8 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/mmc/host/wmt-sdmmc.c b/drivers/mmc/host/wmt-sdmmc.c
> index 34231d5..57858ef 100644
> --- a/drivers/mmc/host/wmt-sdmmc.c
> +++ b/drivers/mmc/host/wmt-sdmmc.c
> @@ -212,28 +212,14 @@ struct wmt_mci_priv {
>   
>   static void wmt_set_sd_power(struct wmt_mci_priv *priv, int enable)
>   {
> -	u32 reg_tmp;
> -	if (enable) {
> -		if (priv->power_inverted) {
> -			reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE);
> -			writeb(reg_tmp | BM_SD_OFF,
> -			       priv->sdmmc_base + SDMMC_BUSMODE);
> -		} else {
> -			reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE);
> -			writeb(reg_tmp & (~BM_SD_OFF),
> -			       priv->sdmmc_base + SDMMC_BUSMODE);
> -		}
> -	} else {
> -		if (priv->power_inverted) {
> -			reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE);
> -			writeb(reg_tmp & (~BM_SD_OFF),
> -			       priv->sdmmc_base + SDMMC_BUSMODE);
> -		} else {
> -			reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE);
> -			writeb(reg_tmp | BM_SD_OFF,
> -			       priv->sdmmc_base + SDMMC_BUSMODE);
> -		}
> -	}
> +	u32 reg_tmp = readb(priv->sdmmc_base + SDMMC_BUSMODE);
> +
> +	if (enable ^ priv->power_inverted)
> +		reg_tmp &= ~BM_SD_OFF;
> +	else
> +		reg_tmp |= BM_SD_OFF;
> +
> +	writeb(reg_tmp, priv->sdmmc_base + SDMMC_BUSMODE);
>   }
>   
>   static void wmt_mci_read_response(struct mmc_host *mmc)
Acked-by: Tony Prisk <linux@prisktech.co.nz>

Thanks Axel - much better code.

Regards
Tony Prisk

  reply	other threads:[~2013-10-05  4:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-03  9:04 [PATCH] mmc: wmt-sdmmc: Simplify wmt_set_sd_power implementation Axel Lin
2013-10-05  4:24 ` Tony Prisk [this message]
2013-10-21  1:21   ` Chris Ball

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=524F9496.8080209@prisktech.co.nz \
    --to=linux@prisktech.co.nz \
    --cc=axel.lin@ingics.com \
    --cc=cjb@laptop.org \
    --cc=linux-mmc@vger.kernel.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 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.