linux-tegra.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Prathamesh Shete <pshete@nvidia.com>
Cc: bgolaszewski@baylibre.com, linux-gpio@vger.kernel.org,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	jonathanh@nvidia.com, thierry.reding@gmail.com,
	smangipudi@nvidia.com, kyarlagadda@nvidia.com,
	Manish Bhardwaj <mbhardwaj@nvidia.com>
Subject: Re: [PATCH] gpio: tegra186: Check GPIO pin permission before access.
Date: Wed, 14 Sep 2022 15:43:31 +0200	[thread overview]
Message-ID: <CACRpkdZu_6=ZPrNbWVC9wBH5nZvAXcZmWjGb4FtjVZi6fAW1DA@mail.gmail.com> (raw)
In-Reply-To: <20220914122110.7246-1-pshete@nvidia.com>

On Wed, Sep 14, 2022 at 2:21 PM Prathamesh Shete <pshete@nvidia.com> wrote:

> This change checks if we have the necessary permission to
> access the GPIO. For devices that have support for virtualisation
> we need to check both the TEGRA186_GPIO_VM_REG and the
> TEGRA186_GPIO_SCR_REG registers. For device that do not have
> virtualisation support for GPIOs we only need to check the
> TEGRA186_GPIO_SCR_REG register.
>
> Signed-off-by: Manish Bhardwaj <mbhardwaj@nvidia.com>
> Signed-off-by: Prathamesh Shete <pshete@nvidia.com>

Instead of doing this check in each and every single gpio callback,
set up the .init_valid_mask on struct gpio_chip, add a for-loop
looping over all GPIOs and fill in the .valid_mask.

This way the gpiolib core will do the check for you.

git grep init_valid_mask for a bunch of examples on how to use this.

Oh I see Thierry already said the same while I was typing :)

Yours,
Linus Walleij

      parent reply	other threads:[~2022-09-14 13:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 12:21 [PATCH] gpio: tegra186: Check GPIO pin permission before access Prathamesh Shete
2022-09-14 13:22 ` Thierry Reding
2022-10-04  7:48   ` [PATCH v2] " Prathamesh Shete
2022-10-06 11:05     ` Thierry Reding
2022-10-07  5:59       ` [PATCH v3] " Prathamesh Shete
2022-10-07 10:25         ` Thierry Reding
2022-10-17  9:31         ` Linus Walleij
2023-05-23  6:22           ` Jon Hunter
2023-05-23  9:17             ` Bartosz Golaszewski
2023-05-23 13:42               ` Jon Hunter
2023-05-23 16:32                 ` andy.shevchenko
2023-05-23 16:43                   ` andy.shevchenko
2023-05-24 10:50                     ` [PATCH v4] " Prathamesh Shete
2023-05-26 12:29                       ` Bartosz Golaszewski
2022-09-14 13:43 ` Linus Walleij [this message]

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='CACRpkdZu_6=ZPrNbWVC9wBH5nZvAXcZmWjGb4FtjVZi6fAW1DA@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --cc=bgolaszewski@baylibre.com \
    --cc=jonathanh@nvidia.com \
    --cc=kyarlagadda@nvidia.com \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=mbhardwaj@nvidia.com \
    --cc=pshete@nvidia.com \
    --cc=smangipudi@nvidia.com \
    --cc=thierry.reding@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 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).