mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "tip-bot2 for Alexey Charkov" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Alexey Charkov <alchark@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip: irq/drivers] irqchip/irq-vt8500: Use fewer global variables and add error handling
Date: Tue, 06 May 2025 14:04:24 -0000	[thread overview]
Message-ID: <174654026461.406.12839748148881380454.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20250506-vt8500-intc-updates-v2-5-a3a0606cf92d@gmail.com>

The following commit has been merged into the irq/drivers branch of tip:

Commit-ID:     99ad153fbd22fcf7c2bdd774d08fc4bf70029fa6
Gitweb:        https://git.kernel.org/tip/99ad153fbd22fcf7c2bdd774d08fc4bf70029fa6
Author:        Alexey Charkov <alchark@gmail.com>
AuthorDate:    Tue, 06 May 2025 16:46:18 +04:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Tue, 06 May 2025 15:58:27 +02:00

irqchip/irq-vt8500: Use fewer global variables and add error handling

Controller private data doesn't really need to be in a global
statically allocated array - kzalloc it per controller instead,
keeping only one pointer to the primary controller global.

While at that, also add proper error return statuses in the init
path and respective cleanup of resources on errors.

Signed-off-by: Alexey Charkov <alchark@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20250506-vt8500-intc-updates-v2-5-a3a0606cf92d@gmail.com

---
 drivers/irqchip/irq-vt8500.c | 48 ++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/drivers/irqchip/irq-vt8500.c b/drivers/irqchip/irq-vt8500.c
index 15134cb..40c2cff 100644
--- a/drivers/irqchip/irq-vt8500.c
+++ b/drivers/irqchip/irq-vt8500.c
@@ -64,9 +64,6 @@ struct vt8500_irq_data {
 	struct irq_domain	*domain;	/* Domain for this controller */
 };
 
-/* Global variable for accessing io-mem addresses */
-static struct vt8500_irq_data intc[VT8500_INTC_MAX];
-static u32 active_cnt = 0;
 /* Primary interrupt controller data */
 static struct vt8500_irq_data *primary_intc;
 
@@ -203,49 +200,54 @@ static void vt8500_handle_irq_chained(struct irq_desc *desc)
 static int __init vt8500_irq_init(struct device_node *node,
 				  struct device_node *parent)
 {
-	int irq, i;
+	struct vt8500_irq_data *intc;
+	int irq, i, ret = 0;
 
-	if (active_cnt == VT8500_INTC_MAX) {
-		pr_err("%s: Interrupt controllers > VT8500_INTC_MAX\n",
-								__func__);
-		goto out;
-	}
-
-	intc[active_cnt].base = of_iomap(node, 0);
-	intc[active_cnt].domain = irq_domain_add_linear(node, 64,
-			&vt8500_irq_domain_ops,	&intc[active_cnt]);
+	intc = kzalloc(sizeof(*intc), GFP_KERNEL);
+	if (!intc)
+		return -ENOMEM;
 
-	if (!intc[active_cnt].base) {
+	intc->base = of_iomap(node, 0);
+	if (!intc->base) {
 		pr_err("%s: Unable to map IO memory\n", __func__);
-		goto out;
+		ret = -ENOMEM;
+		goto err_free;
 	}
 
-	if (!intc[active_cnt].domain) {
+	intc->domain = irq_domain_add_linear(node,
+					     64,
+					     &vt8500_irq_domain_ops,
+					     intc);
+	if (!intc->domain) {
 		pr_err("%s: Unable to add irq domain!\n", __func__);
-		goto out;
+		ret = -ENOMEM;
+		goto err_unmap;
 	}
 
-	vt8500_init_irq_hw(intc[active_cnt].base);
+	vt8500_init_irq_hw(intc->base);
 
 	pr_info("vt8500-irq: Added interrupt controller\n");
 
-	active_cnt++;
-
 	/* check if this is a chained controller */
 	if (of_irq_count(node) != 0) {
 		for (i = 0; i < of_irq_count(node); i++) {
 			irq = irq_of_parse_and_map(node, i);
 			irq_set_chained_handler_and_data(irq, vt8500_handle_irq_chained,
-							 &intc[active_cnt]);
+							 intc);
 		}
 
 		pr_info("vt8500-irq: Enabled slave->parent interrupts\n");
 	} else {
-		primary_intc = &intc[active_cnt];
+		primary_intc = intc;
 		set_handle_irq(vt8500_handle_irq);
 	}
-out:
 	return 0;
+
+err_unmap:
+	iounmap(intc->base);
+err_free:
+	kfree(intc);
+	return ret;
 }
 
 IRQCHIP_DECLARE(vt8500_irq, "via,vt8500-intc", vt8500_irq_init);

      reply	other threads:[~2025-05-06 14:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06 12:46 [PATCH v2 0/5] irqchip/irq-vt8500: Cleanups and fixes for the irq-vt8500 driver Alexey Charkov
2025-05-06 12:46 ` [PATCH v2 1/5] irqchip/irq-vt8500: Split up ack/mask functions Alexey Charkov
2025-05-06 14:04   ` [tip: irq/drivers] " tip-bot2 for Alexey Charkov
2025-05-06 12:46 ` [PATCH v2 2/5] irqchip/irq-vt8500: Drop redundant copy of the device node pointer Alexey Charkov
2025-05-06 14:04   ` [tip: irq/drivers] " tip-bot2 for Alexey Charkov
2025-05-06 12:46 ` [PATCH v2 3/5] irqchip/irq-vt8500: Don't require 8 interrupts from a chained controller Alexey Charkov
2025-05-06 14:04   ` [tip: irq/drivers] " tip-bot2 for Alexey Charkov
2025-05-06 12:46 ` [PATCH v2 4/5] irqchip/irq-vt8500: Use a dedicated chained handler function Alexey Charkov
2025-05-06 14:04   ` [tip: irq/drivers] " tip-bot2 for Alexey Charkov
2025-05-06 12:46 ` [PATCH v2 5/5] irqchip/irq-vt8500: Use fewer global variables and add error handling Alexey Charkov
2025-05-06 14:04   ` tip-bot2 for Alexey Charkov [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=174654026461.406.12839748148881380454.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=alchark@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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®