linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: marek.behun@nic.cz
Cc: ext Tony Lindgren <tony@atomide.com>,
	Shawn Guo <shawnguo@kernel.org>, Rob Herring <robh@kernel.org>,
	"open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 bus+gpio 3/4] drivers: gpio: Add support for GPIOs over Moxtet bus
Date: Fri, 9 Nov 2018 11:12:47 +0100	[thread overview]
Message-ID: <CACRpkdbLQX3ZcuJE_CMxtnJ37f2f=BWHuf0wa1PG6if3-4DSow@mail.gmail.com> (raw)
In-Reply-To: <20181102103539.6077-3-marek.behun@nic.cz>

On Fri, Nov 2, 2018 at 11:35 AM Marek Behún <marek.behun@nic.cz> wrote:

> This adds support for interpreting the input and output bits of one
> device on Moxtet bus as GPIOs.
> This is needed for example by the SFP cage module of Turris Mox.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Overall looks fine, it's OK like this just adding some nitpicking:

> +static const struct moxtet_gpio_desc descs[] = {
> +       [TURRIS_MOX_MODULE_SFP] = {
> +               .in_mask = 0x7,
> +               .out_mask = 0x30,
> +       },
> +};

You can actually use things like:

.in_mask = GENMASK(3,0);

ton indicate exactly which bits you hit, but maybe it is overkill.
(No big deal.)

> +       return (ret & BIT(offset)) ? 1 : 0;

I would usually just clamp like this:

return !!(red & BIT(offset));

> +static int moxtet_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
> +{
> +       struct moxtet_gpio_chip *chip = gpiochip_get_data(gc);
> +
> +       if (chip->desc->in_mask & BIT(offset))
> +               return 1;
> +       else if (chip->desc->out_mask & BIT(offset))
> +               return 0;
> +       else
> +               return -EINVAL;

Maybe insert a comment here that a line is hard wired
as either input or output.

Anyways:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

  reply	other threads:[~2018-11-09 10:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-02 10:35 [PATCH v2 bus+gpio 1/4] bus: Add support for Moxtet bus Marek Behún
2018-11-02 10:35 ` [PATCH v2 bus+gpio 2/4] dt-bindings: bus: Document moxtet bus binding Marek Behún
2018-11-05 22:13   ` Rob Herring
2018-11-02 10:35 ` [PATCH v2 bus+gpio 3/4] drivers: gpio: Add support for GPIOs over Moxtet bus Marek Behún
2018-11-09 10:12   ` Linus Walleij [this message]
2018-11-02 10:35 ` [PATCH v2 bus+gpio 4/4] dt-bindings: gpio: Document GPIOs via " Marek Behún
2018-11-05 22:14   ` Rob Herring
2018-11-09  9:59 ` [PATCH v2 bus+gpio 1/4] bus: Add support for " 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='CACRpkdbLQX3ZcuJE_CMxtnJ37f2f=BWHuf0wa1PG6if3-4DSow@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marek.behun@nic.cz \
    --cc=robh@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=tony@atomide.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).