History

genirq/irq_sim: Simplify the API

The interrupt simulator API exposes a lot of custom data structures and functions and doesn't reuse the interfaces already exposed by the irq subsystem. This patch tries to address it. We hide all the simulator-related data structures from users and instead rely on the well-known irq domain. When creating the interrupt simulator the user receives a pointer to a newly created irq_domain and can use it to create mappings for simulated interrupts. It is also possible to pass a handle to fwnode when creating the simulator domain and retrieve it using irq_find_matching_fwnode(). The irq_sim_fire() function is dropped as well. Instead we implement the irq_get/set_irqchip_state interface. We modify the two modules that use the simulator at the same time as adding these changes in order to reduce the intermediate bloat that would result when trying to migrate the drivers in separate patches.

Bartosz Golaszewski committed 6 years ago

Commit 337cbeb1 parent 5c8f77a5 files · +237 −151Browse files

Showing the changes to include/linux (1 of 5 files). Show all

Unified · Split

include/linux/irq_sim.h+9−24
@@ -1,41 +1,26 @@
11 /* SPDX-License-Identifier: GPL-2.0+ */
22 /*
33 * Copyright (C) 2017-2018 Bartosz Golaszewski <brgl@bgdev.pl>
4+ * Copyright (C) 2020 Bartosz Golaszewski <bgolaszewski@baylibre.com>
45 */
56
67 #ifndef _LINUX_IRQ_SIM_H
78 #define _LINUX_IRQ_SIM_H
89
9−#include <linux/irq_work.h>
1010 #include <linux/device.h>
11+#include <linux/fwnode.h>
12+#include <linux/irqdomain.h>
1113
1214 /*
1315 * Provides a framework for allocating simulated interrupts which can be
1416 * requested like normal irqs and enqueued from process context.
1517 */
1618
17−struct irq_sim_work_ctx {
18− struct irq_work work;
19− unsigned long *pending;
20−};
21−
22−struct irq_sim_irq_ctx {
23− int irqnum;
24− bool enabled;
25−};
26−
27−struct irq_sim {
28− struct irq_sim_work_ctx work_ctx;
29− int irq_base;
30− unsigned int irq_count;
31− struct irq_sim_irq_ctx *irqs;
32−};
33−
34−int irq_sim_init(struct irq_sim *sim, unsigned int num_irqs);
35−int devm_irq_sim_init(struct device *dev, struct irq_sim *sim,
36− unsigned int num_irqs);
37−void irq_sim_fini(struct irq_sim *sim);
38−void irq_sim_fire(struct irq_sim *sim, unsigned int offset);
39−int irq_sim_irqnum(struct irq_sim *sim, unsigned int offset);
19+struct irq_domain *irq_domain_create_sim(struct fwnode_handle *fwnode,
20+ unsigned int num_irqs);
21+struct irq_domain *devm_irq_domain_create_sim(struct device *dev,
22+ struct fwnode_handle *fwnode,
23+ unsigned int num_irqs);
24+void irq_domain_remove_sim(struct irq_domain *domain);
4025
4126 #endif /* _LINUX_IRQ_SIM_H */