History

gpio: Add helpers to ease the transition towards immutable irq_chip

Add a couple of new helpers to make it slightly simpler to convert drivers to immutable irq_chip structures: - GPIOCHIP_IRQ_RESOURCE_HELPERS populates the irq_chip structure with the resource management callbacks - gpio_irq_chip_set_chip() populates the gpio_irq_chip.chip structure, avoiding the proliferation of ugly casts

Marc Zyngier committed 4 years ago

Commit 36b78aa1 parent 704f0871 file · +12 −0Browse files

Showing the changes to include (1 of 1 file). Show all

Unified · Split

include/linux/gpio/driver.h+12−0
@@ -583,6 +583,18 @@ void gpiochip_enable_irq(struct gpio_chip *gc, unsigned int offset); · 582 unmodified lines
583583 int gpiochip_irq_reqres(struct irq_data *data);
584584 void gpiochip_irq_relres(struct irq_data *data);
585585
586+/* Paste this in your irq_chip structure */
587+#define GPIOCHIP_IRQ_RESOURCE_HELPERS \
588+ .irq_request_resources = gpiochip_irq_reqres, \
589+ .irq_release_resources = gpiochip_irq_relres
590+
591+static inline void gpio_irq_chip_set_chip(struct gpio_irq_chip *girq,
592+ const struct irq_chip *chip)
593+{
594+ /* Yes, dropping const is ugly, but it isn't like we have a choice */
595+ girq->chip = (struct irq_chip *)chip;
596+}
597+
586598 /* Line status inquiry for drivers */
587599 bool gpiochip_line_is_open_drain(struct gpio_chip *gc, unsigned int offset);
588600 bool gpiochip_line_is_open_source(struct gpio_chip *gc, unsigned int offset);