Skip to content

Commit

Permalink
genirq/irq_sim: Shrink devm_irq_domain_create_sim()
Browse files Browse the repository at this point in the history
The custom devres structure manages only a single pointer which can
can be achieved by using devm_add_action_or_reset() as well which
makes the code simpler.

[ tglx: Fixed return value handling - found by smatch ]

Signed-off-by: Bartosz Golaszewski <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
brgl authored and KAGA-KOKO committed Mar 30, 2021
1 parent 6e45791 commit 883ccef
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions kernel/irq/irq_sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ struct irq_sim_irq_ctx {
struct irq_sim_work_ctx *work_ctx;
};

struct irq_sim_devres {
struct irq_domain *domain;
};

static void irq_sim_irqmask(struct irq_data *data)
{
struct irq_sim_irq_ctx *irq_ctx = irq_data_get_irq_chip_data(data);
Expand Down Expand Up @@ -216,11 +212,11 @@ void irq_domain_remove_sim(struct irq_domain *domain)
}
EXPORT_SYMBOL_GPL(irq_domain_remove_sim);

static void devm_irq_domain_release_sim(struct device *dev, void *res)
static void devm_irq_domain_remove_sim(void *data)
{
struct irq_sim_devres *this = res;
struct irq_domain *domain = data;

irq_domain_remove_sim(this->domain);
irq_domain_remove_sim(domain);
}

/**
Expand All @@ -238,20 +234,17 @@ struct irq_domain *devm_irq_domain_create_sim(struct device *dev,
struct fwnode_handle *fwnode,
unsigned int num_irqs)
{
struct irq_sim_devres *dr;
struct irq_domain *domain;
int ret;

dr = devres_alloc(devm_irq_domain_release_sim,
sizeof(*dr), GFP_KERNEL);
if (!dr)
return ERR_PTR(-ENOMEM);
domain = irq_domain_create_sim(fwnode, num_irqs);
if (IS_ERR(domain))
return domain;

dr->domain = irq_domain_create_sim(fwnode, num_irqs);
if (IS_ERR(dr->domain)) {
devres_free(dr);
return dr->domain;
}
ret = devm_add_action_or_reset(dev, devm_irq_domain_remove_sim, domain);
if (ret)
return ERR_PTR(ret);

devres_add(dev, dr);
return dr->domain;
return domain;
}
EXPORT_SYMBOL_GPL(devm_irq_domain_create_sim);

0 comments on commit 883ccef

Please sign in to comment.