Commit aafd7535 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Ingo Molnar

genirq/irq_sim: Shrink code by using <linux/cleanup.h> helpers

Use the new __free() mechanism to remove all gotos and simplify the error
paths.
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20240122124243.44002-5-brgl@bgdev.pl
parent 8dab7fd4
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (C) 2020 Bartosz Golaszewski <bgolaszewski@baylibre.com> * Copyright (C) 2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>
*/ */
#include <linux/cleanup.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/irq_sim.h> #include <linux/irq_sim.h>
...@@ -163,33 +164,27 @@ static const struct irq_domain_ops irq_sim_domain_ops = { ...@@ -163,33 +164,27 @@ static const struct irq_domain_ops irq_sim_domain_ops = {
struct irq_domain *irq_domain_create_sim(struct fwnode_handle *fwnode, struct irq_domain *irq_domain_create_sim(struct fwnode_handle *fwnode,
unsigned int num_irqs) unsigned int num_irqs)
{ {
struct irq_sim_work_ctx *work_ctx; struct irq_sim_work_ctx *work_ctx __free(kfree) =
kmalloc(sizeof(*work_ctx), GFP_KERNEL);
work_ctx = kmalloc(sizeof(*work_ctx), GFP_KERNEL);
if (!work_ctx) if (!work_ctx)
goto err_out; return ERR_PTR(-ENOMEM);
work_ctx->pending = bitmap_zalloc(num_irqs, GFP_KERNEL); unsigned long *pending __free(bitmap) = bitmap_zalloc(num_irqs, GFP_KERNEL);
if (!work_ctx->pending) if (!pending)
goto err_free_work_ctx; return ERR_PTR(-ENOMEM);
work_ctx->domain = irq_domain_create_linear(fwnode, num_irqs, work_ctx->domain = irq_domain_create_linear(fwnode, num_irqs,
&irq_sim_domain_ops, &irq_sim_domain_ops,
work_ctx); work_ctx);
if (!work_ctx->domain) if (!work_ctx->domain)
goto err_free_bitmap; return ERR_PTR(-ENOMEM);
work_ctx->irq_count = num_irqs; work_ctx->irq_count = num_irqs;
work_ctx->work = IRQ_WORK_INIT_HARD(irq_sim_handle_irq); work_ctx->work = IRQ_WORK_INIT_HARD(irq_sim_handle_irq);
work_ctx->pending = no_free_ptr(pending);
return work_ctx->domain; return no_free_ptr(work_ctx)->domain;
err_free_bitmap:
bitmap_free(work_ctx->pending);
err_free_work_ctx:
kfree(work_ctx);
err_out:
return ERR_PTR(-ENOMEM);
} }
EXPORT_SYMBOL_GPL(irq_domain_create_sim); EXPORT_SYMBOL_GPL(irq_domain_create_sim);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment