From: <shao.mingyin@zte.com.cn>
To: <lee@kernel.org>, <mfd@lists.linux.dev>
Cc: <tony@atomide.com>, <linux-omap@vger.kernel.org>,
<support.opensource@diasemi.com>, <patches@opensource.cirrus.com>,
<ckeepax@opensource.cirrus.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH v2 2/3] mfd: arizona: Free only registered diagnostic IRQs
Date: Fri, 27 Nov 2026 12:17:38 +0800 (CST) [thread overview]
Message-ID: <20261127121738923LHjBUaCxdDRPGTYPDZBDV@zte.com.cn> (raw)
In-Reply-To: <20261127121734430rp7P_HaHukJyZYs7OMQjx@zte.com.cn>
arizona_dev_init() requests three diagnostic IRQs before adding MFD
children. If adding the children fails after any of those requests
succeed, the probe error path tears down the IRQ mappings while the
diagnostic IRQ actions are still registered.
Record which requests succeed and free those IRQs before IRQ teardown
on probe failure and on removal. Diagnostic IRQs remain optional, and
a failed request never leads to a call to free its action.
Fixes: 3cc729869475 ("mfd: arizona: Core driver")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
Changes in v2:
- Record successful IRQ requests and share cleanup between probe
failure and removal.
Previous version: https://lore.kernel.org/all/20261107162122461AuQ94DzIh_R4gD8FWdVlC@zte.com.cn/
Build-tested on Linux-next next-20261118 with GCC 13.3.0 for x86_64.
drivers/mfd/arizona-core.c | 49 ++++++++++++++++++++++++++------
include/linux/mfd/arizona/core.h | 1 +
2 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c
index 91975536d14d..8e5b8a75e773 100644
--- a/drivers/mfd/arizona-core.c
+++ b/drivers/mfd/arizona-core.c
@@ -231,6 +231,43 @@ static irqreturn_t arizona_overclocked(int irq, void *data)
return IRQ_HANDLED;
}
+static const struct {
+ int irq;
+ char *name;
+ irq_handler_t handler;
+} arizona_info_irqs[] = {
+ { ARIZONA_IRQ_CLKGEN_ERR, "CLKGEN error", arizona_clkgen_err },
+ { ARIZONA_IRQ_OVERCLOCKED, "Overclocked", arizona_overclocked },
+ { ARIZONA_IRQ_UNDERCLOCKED, "Underclocked", arizona_underclocked },
+};
+
+static void arizona_request_info_irqs(struct arizona *arizona)
+{
+ unsigned int i;
+ int ret;
+
+ for (i = 0; i < ARRAY_SIZE(arizona_info_irqs); i++) {
+ ret = arizona_request_irq(arizona, arizona_info_irqs[i].irq,
+ arizona_info_irqs[i].name,
+ arizona_info_irqs[i].handler,
+ arizona);
+ if (!ret)
+ arizona->info_irq_mask |= BIT(i);
+ }
+}
+
+static void arizona_free_info_irqs(struct arizona *arizona)
+{
+ int i;
+
+ for (i = ARRAY_SIZE(arizona_info_irqs) - 1; i >= 0; i--)
+ if (arizona->info_irq_mask & BIT(i))
+ arizona_free_irq(arizona, arizona_info_irqs[i].irq,
+ arizona);
+
+ arizona->info_irq_mask = 0;
+}
+
#define ARIZONA_REG_POLL_DELAY_US 7500
static inline bool arizona_poll_reg_delay(ktime_t timeout)
@@ -1355,12 +1392,7 @@ int arizona_dev_init(struct arizona *arizona)
pm_runtime_set_autosuspend_delay(arizona->dev, 100);
pm_runtime_use_autosuspend(arizona->dev);
- arizona_request_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, "CLKGEN error",
- arizona_clkgen_err, arizona);
- arizona_request_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, "Overclocked",
- arizona_overclocked, arizona);
- arizona_request_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, "Underclocked",
- arizona_underclocked, arizona);
+ arizona_request_info_irqs(arizona);
ret = mfd_add_devices(arizona->dev, PLATFORM_DEVID_NONE,
subdevs, n_subdevs, NULL, 0, NULL);
@@ -1373,6 +1405,7 @@ int arizona_dev_init(struct arizona *arizona)
return 0;
err_irq:
+ arizona_free_info_irqs(arizona);
arizona_irq_exit(arizona);
err_pm:
pm_runtime_disable(arizona->dev);
@@ -1417,9 +1450,7 @@ int arizona_dev_exit(struct arizona *arizona)
}
mfd_remove_devices(arizona->dev);
- arizona_free_irq(arizona, ARIZONA_IRQ_UNDERCLOCKED, arizona);
- arizona_free_irq(arizona, ARIZONA_IRQ_OVERCLOCKED, arizona);
- arizona_free_irq(arizona, ARIZONA_IRQ_CLKGEN_ERR, arizona);
+ arizona_free_info_irqs(arizona);
arizona_irq_exit(arizona);
arizona_enable_reset(arizona);
diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h
index 6d6f96b2b29f..3a9881a1c0c9 100644
--- a/include/linux/mfd/arizona/core.h
+++ b/include/linux/mfd/arizona/core.h
@@ -136,6 +136,7 @@ struct arizona {
struct irq_domain *virq;
struct regmap_irq_chip_data *aod_irq_chip;
struct regmap_irq_chip_data *irq_chip;
+ unsigned int info_irq_mask;
bool hpdet_clamp;
unsigned int hp_ena;
base-commit: e8017d29067fd1310a65c3494ce1a1b492adbac6
--
2.43.0
next prev parent reply other threads:[~2026-11-27 4:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 4:17 [PATCH v2 0/3] mfd: Fix an out-of-bounds IRQ map and error-path bugs shao.mingyin
2026-11-27 4:17 ` [PATCH v2 1/3] mfd: tps65219: Fix the TPS65214 main IRQ bit mapping shao.mingyin
2026-11-27 4:17 ` shao.mingyin [this message]
2026-11-27 10:27 ` [PATCH v2 2/3] mfd: arizona: Free only registered diagnostic IRQs Charles Keepax
2026-11-27 4:17 ` [PATCH v2 3/3] mfd: da9052: Balance the parent IRQ wake reference shao.mingyin
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=20261127121738923LHjBUaCxdDRPGTYPDZBDV@zte.com.cn \
--to=shao.mingyin@zte.com.cn \
--cc=ckeepax@opensource.cirrus.com \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=patches@opensource.cirrus.com \
--cc=support.opensource@diasemi.com \
--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
all inboxes | Powered by JetHome®