linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Simon Horman <horms+renesas@verge.net.au>,
	Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Magnus Damm <magnus.damm@gmail.com>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>
Subject: Re: [PATCH 3/3] pinctrl: sh-pfc: r8a7794: Implement voltage switching for SDHI
Date: Fri, 9 Sep 2016 14:30:06 +0200	[thread overview]
Message-ID: <20160909123005.GC1318@katana> (raw)
In-Reply-To: <CAMuHMdW4=89ro4E2zLRs6fPZk3fPfkHmowNybO107nkJtZqGbw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1296 bytes --]


> > +static int r8a7794_pin_to_pocctrl(struct sh_pfc *pfc, unsigned int pin, u32 *pocctrl)
> > +{
> > +       if (pin < RCAR_GP_PIN(6, 0) || pin > RCAR_GP_PIN(6, 23))
> > +               return -EINVAL;
> > +
> > +       *pocctrl = 0xe606006c;
> > +
> > +       /* GP6_16-23 -> bits 31-24 of pocctrl
> > +        * GP6_06    -> bit  23    of pocctrl
> > +        * GP6_00-05 -> bits 22-17 of pocctrl
> > +        * GP6_07    -> bit  16    of pocctrl
> > +        * GP6_14    -> bit  15    of pocctrl
> > +        * GP6_08-13 -> bits 14-09 of pocctrl
> > +        * GP6_15    -> bit  08    of pocctrl
> > +        */
> > +       if (pin == RCAR_GP_PIN(6, 6) || pin == RCAR_GP_PIN(6, 14))
> > +               return 31 - 2 - (pin & 0x1f);
> > +       else if (pin == RCAR_GP_PIN(6, 7) || pin == RCAR_GP_PIN(6, 15))
> > +               return 31 - 8 - (pin & 0x1f);
> > +       else if (pin < RCAR_GP_PIN(6, 14))
> > +               return 31 - 9 - (pin & 0x1f);
> > +       else
> > +               return 31 + 16 - (pin & 0x1f);
> 
> While your code is correct, I think it's easier for the casual reader to use
> a plain switch () statement, and let the optimizer handle the rest.

Both is fine with me:

Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-09-09 12:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08 11:36 [PATCH 0/3] pinctrl: sh-pfc: r8a779[14]: Implement voltage switching for SDHI Simon Horman
2016-09-08 11:36 ` [PATCH 1/3] pinctrl: sh-pfc: Add PORT_GP_24 helper macro Simon Horman
2016-09-09  7:40   ` Geert Uytterhoeven
2016-09-08 11:36 ` [PATCH 2/3] pinctrl: sh-pfc: r8a7791: Implement voltage switching for SDHI Simon Horman
2016-09-09  7:52   ` Geert Uytterhoeven
2016-09-09 12:30     ` Wolfram Sang
2016-09-08 11:36 ` [PATCH 3/3] pinctrl: sh-pfc: r8a7794: " Simon Horman
2016-09-09  8:08   ` Geert Uytterhoeven
2016-09-09 12:30     ` Wolfram Sang [this message]
2016-09-09 15:26     ` Simon Horman
2016-09-09 16:57       ` Geert Uytterhoeven
2016-09-10  6:14         ` Simon Horman
2016-09-12 12:52 ` [PATCH 0/3] pinctrl: sh-pfc: r8a779[14]: " Linus Walleij

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=20160909123005.GC1318@katana \
    --to=wsa@the-dreams.de \
    --cc=geert@linux-m68k.org \
    --cc=horms+renesas@verge.net.au \
    --cc=laurent.pinchart+renesas@ideasonboard.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=wsa+renesas@sang-engineering.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 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).