From: Jon Hunter <jonathanh@nvidia.com>
To: Kartik Rajput <kkartik@nvidia.com>,
linus.walleij@linaro.org, brgl@bgdev.pl,
thierry.reding@gmail.com, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-tegra@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v3 1/2] gpio: tegra186: Use generic macro for port definitions
Date: Fri, 10 Oct 2025 10:33:20 +0100 [thread overview]
Message-ID: <b6355a70-07a2-49ae-8715-ddc052515f6b@nvidia.com> (raw)
In-Reply-To: <20251010092913.711906-1-kkartik@nvidia.com>
On 10/10/2025 10:29, Kartik Rajput wrote:
> Introduce a generic macro TEGRA_GPIO_PORT to define SoC specific
> ports macros. This simplifies the code and avoids unnecessary
> duplication.
>
> Suggested-by: Jon Hunter <jonathanh@nvidia.com>
> Signed-off-by: Kartik Rajput <kkartik@nvidia.com>
> ---
> drivers/gpio/gpio-tegra186.c | 87 +++++++++++-------------------------
> 1 file changed, 25 insertions(+), 62 deletions(-)
>
> diff --git a/drivers/gpio/gpio-tegra186.c b/drivers/gpio/gpio-tegra186.c
> index 4d3db6e06eeb..7ea541d6d537 100644
> --- a/drivers/gpio/gpio-tegra186.c
> +++ b/drivers/gpio/gpio-tegra186.c
> @@ -1002,14 +1002,17 @@ static int tegra186_gpio_probe(struct platform_device *pdev)
> return devm_gpiochip_add_data(&pdev->dev, &gpio->gpio, gpio);
> }
>
> -#define TEGRA186_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
> - [TEGRA186_MAIN_GPIO_PORT_##_name] = { \
> - .name = #_name, \
> - .bank = _bank, \
> - .port = _port, \
> - .pins = _pins, \
> +#define TEGRA_GPIO_PORT(_prefix, _name, _bank, _port, _pins) \
> + [_prefix##_GPIO_PORT_##_name] = { \
> + .name = #_name, \
> + .bank = _bank, \
> + .port = _port, \
> + .pins = _pins, \
> }
>
> +#define TEGRA186_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
> + TEGRA_GPIO_PORT(TEGRA186_MAIN, _name, _bank, _port, _pins)
> +
> static const struct tegra_gpio_port tegra186_main_ports[] = {
> TEGRA186_MAIN_GPIO_PORT( A, 2, 0, 7),
> TEGRA186_MAIN_GPIO_PORT( B, 3, 0, 7),
> @@ -1045,13 +1048,8 @@ static const struct tegra_gpio_soc tegra186_main_soc = {
> .has_vm_support = false,
> };
>
> -#define TEGRA186_AON_GPIO_PORT(_name, _bank, _port, _pins) \
> - [TEGRA186_AON_GPIO_PORT_##_name] = { \
> - .name = #_name, \
> - .bank = _bank, \
> - .port = _port, \
> - .pins = _pins, \
> - }
> +#define TEGRA186_AON_GPIO_PORT(_name, _bank, _port, _pins) \
> + TEGRA_GPIO_PORT(TEGRA186_AON, _name, _bank, _port, _pins)
>
> static const struct tegra_gpio_port tegra186_aon_ports[] = {
> TEGRA186_AON_GPIO_PORT( S, 0, 1, 5),
> @@ -1073,13 +1071,8 @@ static const struct tegra_gpio_soc tegra186_aon_soc = {
> .has_vm_support = false,
> };
>
> -#define TEGRA194_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
> - [TEGRA194_MAIN_GPIO_PORT_##_name] = { \
> - .name = #_name, \
> - .bank = _bank, \
> - .port = _port, \
> - .pins = _pins, \
> - }
> +#define TEGRA194_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
> + TEGRA_GPIO_PORT(TEGRA194_MAIN, _name, _bank, _port, _pins)
>
> static const struct tegra_gpio_port tegra194_main_ports[] = {
> TEGRA194_MAIN_GPIO_PORT( A, 1, 2, 8),
> @@ -1129,13 +1122,8 @@ static const struct tegra_gpio_soc tegra194_main_soc = {
> .has_vm_support = true,
> };
>
> -#define TEGRA194_AON_GPIO_PORT(_name, _bank, _port, _pins) \
> - [TEGRA194_AON_GPIO_PORT_##_name] = { \
> - .name = #_name, \
> - .bank = _bank, \
> - .port = _port, \
> - .pins = _pins, \
> - }
> +#define TEGRA194_AON_GPIO_PORT(_name, _bank, _port, _pins) \
> + TEGRA_GPIO_PORT(TEGRA194_AON, _name, _bank, _port, _pins)
>
> static const struct tegra_gpio_port tegra194_aon_ports[] = {
> TEGRA194_AON_GPIO_PORT(AA, 0, 3, 8),
> @@ -1155,13 +1143,8 @@ static const struct tegra_gpio_soc tegra194_aon_soc = {
> .has_vm_support = false,
> };
>
> -#define TEGRA234_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
> - [TEGRA234_MAIN_GPIO_PORT_##_name] = { \
> - .name = #_name, \
> - .bank = _bank, \
> - .port = _port, \
> - .pins = _pins, \
> - }
> +#define TEGRA234_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
> + TEGRA_GPIO_PORT(TEGRA234_MAIN, _name, _bank, _port, _pins)
>
> static const struct tegra_gpio_port tegra234_main_ports[] = {
> TEGRA234_MAIN_GPIO_PORT( A, 0, 0, 8),
> @@ -1200,13 +1183,8 @@ static const struct tegra_gpio_soc tegra234_main_soc = {
> .has_vm_support = true,
> };
>
> -#define TEGRA234_AON_GPIO_PORT(_name, _bank, _port, _pins) \
> - [TEGRA234_AON_GPIO_PORT_##_name] = { \
> - .name = #_name, \
> - .bank = _bank, \
> - .port = _port, \
> - .pins = _pins, \
> - }
> +#define TEGRA234_AON_GPIO_PORT(_name, _bank, _port, _pins) \
> + TEGRA_GPIO_PORT(TEGRA234_AON, _name, _bank, _port, _pins)
>
> static const struct tegra_gpio_port tegra234_aon_ports[] = {
> TEGRA234_AON_GPIO_PORT(AA, 0, 4, 8),
> @@ -1227,13 +1205,8 @@ static const struct tegra_gpio_soc tegra234_aon_soc = {
> .has_vm_support = false,
> };
>
> -#define TEGRA241_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
> - [TEGRA241_MAIN_GPIO_PORT_##_name] = { \
> - .name = #_name, \
> - .bank = _bank, \
> - .port = _port, \
> - .pins = _pins, \
> - }
> +#define TEGRA241_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
> + TEGRA_GPIO_PORT(TEGRA241_MAIN, _name, _bank, _port, _pins)
>
> static const struct tegra_gpio_port tegra241_main_ports[] = {
> TEGRA241_MAIN_GPIO_PORT(A, 0, 0, 8),
> @@ -1258,13 +1231,8 @@ static const struct tegra_gpio_soc tegra241_main_soc = {
> .has_vm_support = false,
> };
>
> -#define TEGRA241_AON_GPIO_PORT(_name, _bank, _port, _pins) \
> - [TEGRA241_AON_GPIO_PORT_##_name] = { \
> - .name = #_name, \
> - .bank = _bank, \
> - .port = _port, \
> - .pins = _pins, \
> - }
> +#define TEGRA241_AON_GPIO_PORT(_name, _bank, _port, _pins) \
> + TEGRA_GPIO_PORT(TEGRA241_AON, _name, _bank, _port, _pins)
>
> static const struct tegra_gpio_port tegra241_aon_ports[] = {
> TEGRA241_AON_GPIO_PORT(AA, 0, 0, 8),
> @@ -1280,13 +1248,8 @@ static const struct tegra_gpio_soc tegra241_aon_soc = {
> .has_vm_support = false,
> };
>
> -#define TEGRA256_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
> - [TEGRA256_MAIN_GPIO_PORT_##_name] = { \
> - .name = #_name, \
> - .bank = _bank, \
> - .port = _port, \
> - .pins = _pins, \
> - }
> +#define TEGRA256_MAIN_GPIO_PORT(_name, _bank, _port, _pins) \
> + TEGRA_GPIO_PORT(TEGRA256_MAIN, _name, _bank, _port, _pins)
>
> static const struct tegra_gpio_port tegra256_main_ports[] = {
> TEGRA256_MAIN_GPIO_PORT(A, 0, 0, 8),
Thanks! Looks good to me ...
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Jon
--
nvpublic
prev parent reply other threads:[~2025-10-10 9:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-10 9:29 Kartik Rajput
2025-10-10 9:29 ` [PATCH v3 2/2] gpio: tegra186: Add support for Tegra410 Kartik Rajput
2025-10-10 10:04 ` Jon Hunter
2025-10-10 10:09 ` Kartik Rajput
2025-10-10 9:33 ` Jon Hunter [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=b6355a70-07a2-49ae-8715-ddc052515f6b@nvidia.com \
--to=jonathanh@nvidia.com \
--cc=brgl@bgdev.pl \
--cc=devicetree@vger.kernel.org \
--cc=kkartik@nvidia.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--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
all inboxes | Powered by JetHome®