mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Yu-Chun Lin <eleanor.lin@realtek.com>
To: <linusw@kernel.org>, <brgl@kernel.org>
Cc: <andriy.shevchenko@intel.com>, <linux-gpio@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <tychang@realtek.com>,
	<eleanor.lin@realtek.com>, <stanley_chang@realtek.com>,
	<cy.huang@realtek.com>, <james.tai@realtek.com>
Subject: [PATCH v2 3/5] gpio: rtd1625: Narrow variable scope in loops
Date: Fri, 14 Aug 2026 10:56:55 +0800	[thread overview]
Message-ID: <20260814025657.1400452-4-eleanor.lin@realtek.com> (raw)
In-Reply-To: <20260814025657.1400452-1-eleanor.lin@realtek.com>

Declare 'i' inside the for-loop header and 'hwirq' within the inner block
where it's used to reduce variable visibility.

Link: https://lore.kernel.org/lkml/anUcSPcJjJkLh0Z-@ashevche-desk.local/
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Yu-Chun Lin <eleanor.lin@realtek.com>
---
 drivers/gpio/gpio-rtd1625.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-rtd1625.c b/drivers/gpio/gpio-rtd1625.c
index 0308d7a052e7..8f584287c2e6 100644
--- a/drivers/gpio/gpio-rtd1625.c
+++ b/drivers/gpio/gpio-rtd1625.c
@@ -224,8 +224,7 @@ static void rtd1625_gpio_irq_handle(struct irq_desc *desc)
 	struct irq_chip *chip = irq_desc_get_chip(desc);
 	unsigned int irq = irq_desc_get_irq(desc);
 	struct irq_domain *domain = data->domain;
-	unsigned int reg_offset, i, j, val;
-	irq_hw_number_t hwirq;
+	unsigned int reg_offset, j, val;
 	unsigned long status;
 	u32 irq_type;
 	int ret;
@@ -241,7 +240,7 @@ static void rtd1625_gpio_irq_handle(struct irq_desc *desc)
 
 	chained_irq_enter(chip, desc);
 
-	for (i = 0; i < data->info->num_gpios; i += 32) {
+	for (unsigned int i = 0; i < data->info->num_gpios; i += 32) {
 		reg_offset = get_reg_offset(data, i);
 		ret = regmap_read(data->regmap, reg_offset, &val);
 		if (ret) {
@@ -267,7 +266,8 @@ static void rtd1625_gpio_irq_handle(struct irq_desc *desc)
 		}
 
 		for_each_set_bit(j, &status, 32) {
-			hwirq = i + j;
+			irq_hw_number_t hwirq = i + j;
+
 			irq_type = irq_get_trigger_type(irq_find_mapping(domain, hwirq));
 
 			/*
-- 
2.43.0


  parent reply	other threads:[~2026-08-14  2:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14  2:56 [PATCH v2 0/5] gpio: rtd1625: minor cleanups and log improvements Yu-Chun Lin
2026-08-14  2:56 ` [PATCH v2 1/5] gpio: rtd1625: Minor coding style cleanups Yu-Chun Lin
2026-08-14 12:05   ` Andy Shevchenko
2026-08-14  2:56 ` [PATCH v2 2/5] gpio: rtd1625: Fix variable type for regmap_read() Yu-Chun Lin
2026-08-14 12:05   ` Andy Shevchenko
2026-08-14  2:56 ` Yu-Chun Lin [this message]
2026-08-14 12:07   ` [PATCH v2 3/5] gpio: rtd1625: Narrow variable scope in loops Andy Shevchenko
2026-08-14  2:56 ` [PATCH v2 4/5] gpio: rtd1625: Replace pr_err_ratelimited() with dev_err_ratelimited() Yu-Chun Lin
2026-08-14 12:07   ` Andy Shevchenko
2026-08-14  2:56 ` [PATCH v2 5/5] gpio: rtd1625: Use IRQ_TYPE_DEFAULT macro Yu-Chun Lin
2026-08-14 12:08   ` Andy Shevchenko

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=20260814025657.1400452-4-eleanor.lin@realtek.com \
    --to=eleanor.lin@realtek.com \
    --cc=andriy.shevchenko@intel.com \
    --cc=brgl@kernel.org \
    --cc=cy.huang@realtek.com \
    --cc=james.tai@realtek.com \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stanley_chang@realtek.com \
    --cc=tychang@realtek.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®