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
Showing the changes to include (1 of 1 file). Show all
Unified · Split
| @@ -583,6 +583,18 @@ void gpiochip_enable_irq(struct gpio_chip *gc, unsigned int offset); · 582 unmodified lines | ||
| 583 | 583 | int gpiochip_irq_reqres(struct irq_data *data); |
| 584 | 584 | void gpiochip_irq_relres(struct irq_data *data); |
| 585 | 585 | |
| 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 | + | |
| 586 | 598 | /* Line status inquiry for drivers */ |
| 587 | 599 | bool gpiochip_line_is_open_drain(struct gpio_chip *gc, unsigned int offset); |
| 588 | 600 | bool gpiochip_line_is_open_source(struct gpio_chip *gc, unsigned int offset); |