[2/4] irqchip/gic: Implement generic gic_irq() API for GIC & GIC-v3
Commit Message
GIC & GIC-v3 share same gic_irq() implementations, unify them into a
generic API.
Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
---
drivers/irqchip/irq-gic-common.h | 5 +++++
drivers/irqchip/irq-gic-v3.c | 5 -----
drivers/irqchip/irq-gic.c | 5 -----
3 files changed, 5 insertions(+), 10 deletions(-)
Comments
On Thu, 18 Jan 2024 11:27:37 +0000,
Dawei Li <dawei.li@shingroup.cn> wrote:
>
> GIC & GIC-v3 share same gic_irq() implementations, unify them into a
> generic API.
>
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> ---
> drivers/irqchip/irq-gic-common.h | 5 +++++
> drivers/irqchip/irq-gic-v3.c | 5 -----
> drivers/irqchip/irq-gic.c | 5 -----
> 3 files changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/irqchip/irq-gic-common.h b/drivers/irqchip/irq-gic-common.h
> index f407cce9ecaa..ed18db4ab2c5 100644
> --- a/drivers/irqchip/irq-gic-common.h
> +++ b/drivers/irqchip/irq-gic-common.h
> @@ -19,6 +19,11 @@ struct gic_quirk {
> u32 mask;
> };
>
> +static inline unsigned int gic_irq(struct irq_data *d)
> +{
> + return d->hwirq;
> +}
> +
> int gic_configure_irq(unsigned int irq, unsigned int type,
> void __iomem *base, void (*sync_access)(void));
> void gic_dist_config(void __iomem *base, int gic_irqs,
> diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
> index b9d9375a3434..474a498a521e 100644
> --- a/drivers/irqchip/irq-gic-v3.c
> +++ b/drivers/irqchip/irq-gic-v3.c
> @@ -181,11 +181,6 @@ static enum gic_intid_range get_intid_range(struct irq_data *d)
> return __get_intid_range(d->hwirq);
> }
>
> -static inline unsigned int gic_irq(struct irq_data *d)
> -{
> - return d->hwirq;
> -}
> -
I'd rather not do that. If anything, I'd get rid of the helper
altogether, as we have irqd_to_hwirq() that does the same job, and
actually preserves the typing.
M.
Hi Marc,
Thanks for the review.
On Thu, Jan 18, 2024 at 02:03:08PM +0000, Marc Zyngier wrote:
> On Thu, 18 Jan 2024 11:27:37 +0000,
> Dawei Li <dawei.li@shingroup.cn> wrote:
> >
> > GIC & GIC-v3 share same gic_irq() implementations, unify them into a
> > generic API.
> >
> > Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
> > ---
> > drivers/irqchip/irq-gic-common.h | 5 +++++
> > drivers/irqchip/irq-gic-v3.c | 5 -----
> > drivers/irqchip/irq-gic.c | 5 -----
> > 3 files changed, 5 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/irqchip/irq-gic-common.h b/drivers/irqchip/irq-gic-common.h
> > index f407cce9ecaa..ed18db4ab2c5 100644
> > --- a/drivers/irqchip/irq-gic-common.h
> > +++ b/drivers/irqchip/irq-gic-common.h
> > @@ -19,6 +19,11 @@ struct gic_quirk {
> > u32 mask;
> > };
> >
> > +static inline unsigned int gic_irq(struct irq_data *d)
> > +{
> > + return d->hwirq;
> > +}
> > +
> > int gic_configure_irq(unsigned int irq, unsigned int type,
> > void __iomem *base, void (*sync_access)(void));
> > void gic_dist_config(void __iomem *base, int gic_irqs,
> > diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c
> > index b9d9375a3434..474a498a521e 100644
> > --- a/drivers/irqchip/irq-gic-v3.c
> > +++ b/drivers/irqchip/irq-gic-v3.c
> > @@ -181,11 +181,6 @@ static enum gic_intid_range get_intid_range(struct irq_data *d)
> > return __get_intid_range(d->hwirq);
> > }
> >
> > -static inline unsigned int gic_irq(struct irq_data *d)
> > -{
> > - return d->hwirq;
> > -}
> > -
>
> I'd rather not do that. If anything, I'd get rid of the helper
> altogether, as we have irqd_to_hwirq() that does the same job, and
> actually preserves the typing.
Yes, your solution is much better for it's truly generic, independent of
irq chip.
I will send respin of V2 as you suggested, and if I may, add your
suggested-by?
Thanks,
Dawei
>
> M.
>
> --
> Without deviation from the norm, progress is not possible.
>
@@ -19,6 +19,11 @@ struct gic_quirk {
u32 mask;
};
+static inline unsigned int gic_irq(struct irq_data *d)
+{
+ return d->hwirq;
+}
+
int gic_configure_irq(unsigned int irq, unsigned int type,
void __iomem *base, void (*sync_access)(void));
void gic_dist_config(void __iomem *base, int gic_irqs,
@@ -181,11 +181,6 @@ static enum gic_intid_range get_intid_range(struct irq_data *d)
return __get_intid_range(d->hwirq);
}
-static inline unsigned int gic_irq(struct irq_data *d)
-{
- return d->hwirq;
-}
-
static inline bool gic_irq_in_rdist(struct irq_data *d)
{
switch (get_intid_range(d)) {
@@ -162,11 +162,6 @@ static inline void __iomem *gic_cpu_base(struct irq_data *d)
return gic_data_cpu_base(gic_data);
}
-static inline unsigned int gic_irq(struct irq_data *d)
-{
- return d->hwirq;
-}
-
static inline bool cascading_gic_irq(struct irq_data *d)
{
void *data = irq_data_get_irq_handler_data(d);