Re: [PATCH] genirq: Provide reverse compat handling for irq_chip methods.

From: Yong Zhang
Date: Tue Nov 30 2010 - 21:46:49 EST


On Tue, Nov 30, 2010 at 8:08 PM, Lennert Buytenhek
<buytenh@xxxxxxxxxxxxxx> wrote:
> kernel/irq/chip.c provides compat wrappers for when users of the
> new-style (->irq_foo()) irq_chip methods try to call into irq_chips
> that provide only old-style (->foo()) methods, but doesn't currently
> provide compatibility in the other direction.
>
> As there exist chained irq flow handlers outside kernel/irq/ that have
> not been converted over to call the new methods yet, this means that
> the irq_chips that they are chained off can't be converted to the new
> methods yet.
>
> This patch adds reverse compat wrappers, so that old-style flow
> handlers can call into new-style irq_chips, too, and the flow handlers
> and irq_chips can be converted to the new API independently.
>
> Signed-off-by: Lennert Buytenhek <buytenh@xxxxxxxxxxxx>

This looks just going backward.

If someone introduce a new-style irq-chip, but do not change the
related handler function, there will be compiling error if
GENERIC_HARDIRQS_NO_DEPRECATED is set.
So I think it will encourage the user to use the new API.

Thanks,
Yong

> ---
> Âkernel/irq/chip.c | Â142 +++++++++++++++++++++++++++++++++++++++++++++++++++--
> Â1 files changed, 138 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/irq/chip.c b/kernel/irq/chip.c
> index baa5c4a..9a73b0e 100644
> --- a/kernel/irq/chip.c
> +++ b/kernel/irq/chip.c
> @@ -298,15 +298,106 @@ static int compat_irq_retrigger(struct irq_data *data)
> Â Â Â Âreturn data->chip->retrigger(data->irq);
> Â}
>
> -static void compat_bus_lock(struct irq_data *data)
> +static void compat_irq_bus_lock(struct irq_data *data)
> Â{
> Â Â Â Âdata->chip->bus_lock(data->irq);
> Â}
>
> -static void compat_bus_sync_unlock(struct irq_data *data)
> +static void compat_irq_bus_sync_unlock(struct irq_data *data)
> Â{
> Â Â Â Âdata->chip->bus_sync_unlock(data->irq);
> Â}
> +
> +/* And the other way around */
> +static void compat_mask(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â data->chip->irq_mask(data);
> +}
> +
> +static void compat_unmask(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â data->chip->irq_unmask(data);
> +}
> +
> +static void compat_ack(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â data->chip->irq_ack(data);
> +}
> +
> +static void compat_mask_ack(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â data->chip->irq_mask_ack(data);
> +}
> +
> +static void compat_eoi(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â data->chip->irq_eoi(data);
> +}
> +
> +static void compat_enable(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â data->chip->irq_enable(data);
> +}
> +
> +static void compat_disable(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â data->chip->irq_disable(data);
> +}
> +
> +static void compat_shutdown(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â data->chip->irq_shutdown(data);
> +}
> +
> +static unsigned int compat_startup(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â return data->chip->irq_startup(data);
> +}
> +
> +static int compat_set_affinity(unsigned int irq, const struct cpumask *dest)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â return data->chip->irq_set_affinity(data, dest, 0);
> +}
> +
> +static int compat_set_type(unsigned int irq, unsigned int type)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â return data->chip->irq_set_type(data, type);
> +}
> +
> +static int compat_set_wake(unsigned int irq, unsigned int on)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â return data->chip->irq_set_wake(data, on);
> +}
> +
> +static int compat_retrigger(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â return data->chip->irq_retrigger(data);
> +}
> +
> +static void compat_bus_lock(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â data->chip->irq_bus_lock(data);
> +}
> +
> +static void compat_bus_sync_unlock(unsigned int irq)
> +{
> + Â Â Â struct irq_data *data = irq_get_irq_data(irq);
> + Â Â Â data->chip->irq_bus_sync_unlock(data);
> +}
> Â#endif
>
> Â/*
> @@ -321,12 +412,23 @@ void irq_chip_set_defaults(struct irq_chip *chip)
> Â Â Â Â */
> Â Â Â Âif (chip->enable)
> Â Â Â Â Â Â Â Âchip->irq_enable = compat_irq_enable;
> + Â Â Â else if (chip->irq_enable)
> + Â Â Â Â Â Â Â chip->enable = compat_enable;
> +
> Â Â Â Âif (chip->disable)
> Â Â Â Â Â Â Â Âchip->irq_disable = compat_irq_disable;
> + Â Â Â else if (chip->irq_disable)
> + Â Â Â Â Â Â Â chip->disable = compat_disable;
> +
> Â Â Â Âif (chip->shutdown)
> Â Â Â Â Â Â Â Âchip->irq_shutdown = compat_irq_shutdown;
> + Â Â Â else if (chip->irq_shutdown)
> + Â Â Â Â Â Â Â chip->shutdown = compat_shutdown;
> +
> Â Â Â Âif (chip->startup)
> Â Â Â Â Â Â Â Âchip->irq_startup = compat_irq_startup;
> + Â Â Â else if (chip->irq_startup)
> + Â Â Â Â Â Â Â chip->startup = compat_startup;
> Â#endif
> Â Â Â Â/*
> Â Â Â Â * The real defaults
> @@ -355,27 +457,59 @@ void irq_chip_set_defaults(struct irq_chip *chip)
> Â Â Â Â * Now fix up the remaining compat handlers
> Â Â Â Â */
> Â Â Â Âif (chip->bus_lock)
> - Â Â Â Â Â Â Â chip->irq_bus_lock = compat_bus_lock;
> + Â Â Â Â Â Â Â chip->irq_bus_lock = compat_irq_bus_lock;
> + Â Â Â else if (chip->irq_bus_lock)
> + Â Â Â Â Â Â Â chip->bus_lock = compat_bus_lock;
> +
> Â Â Â Âif (chip->bus_sync_unlock)
> - Â Â Â Â Â Â Â chip->irq_bus_sync_unlock = compat_bus_sync_unlock;
> + Â Â Â Â Â Â Â chip->irq_bus_sync_unlock = compat_irq_bus_sync_unlock;
> + Â Â Â else if (chip->irq_bus_sync_unlock)
> + Â Â Â Â Â Â Â chip->bus_sync_unlock = compat_bus_sync_unlock;
> +
> Â Â Â Âif (chip->mask)
> Â Â Â Â Â Â Â Âchip->irq_mask = compat_irq_mask;
> + Â Â Â else if (chip->irq_mask)
> + Â Â Â Â Â Â Â chip->mask = compat_mask;
> +
> Â Â Â Âif (chip->unmask)
> Â Â Â Â Â Â Â Âchip->irq_unmask = compat_irq_unmask;
> + Â Â Â else if (chip->irq_unmask)
> + Â Â Â Â Â Â Â chip->unmask = compat_unmask;
> +
> Â Â Â Âif (chip->ack)
> Â Â Â Â Â Â Â Âchip->irq_ack = compat_irq_ack;
> + Â Â Â else if (chip->irq_ack)
> + Â Â Â Â Â Â Â chip->ack = compat_ack;
> +
> Â Â Â Âif (chip->mask_ack)
> Â Â Â Â Â Â Â Âchip->irq_mask_ack = compat_irq_mask_ack;
> + Â Â Â else if (chip->irq_mask_ack)
> + Â Â Â Â Â Â Â chip->mask_ack = compat_mask_ack;
> +
> Â Â Â Âif (chip->eoi)
> Â Â Â Â Â Â Â Âchip->irq_eoi = compat_irq_eoi;
> + Â Â Â else if (chip->irq_eoi)
> + Â Â Â Â Â Â Â chip->eoi = compat_eoi;
> +
> Â Â Â Âif (chip->set_affinity)
> Â Â Â Â Â Â Â Âchip->irq_set_affinity = compat_irq_set_affinity;
> + Â Â Â else if (chip->irq_set_affinity)
> + Â Â Â Â Â Â Â chip->set_affinity = compat_set_affinity;
> +
> Â Â Â Âif (chip->set_type)
> Â Â Â Â Â Â Â Âchip->irq_set_type = compat_irq_set_type;
> + Â Â Â else if (chip->irq_set_type)
> + Â Â Â Â Â Â Â chip->set_type = compat_set_type;
> +
> Â Â Â Âif (chip->set_wake)
> Â Â Â Â Â Â Â Âchip->irq_set_wake = compat_irq_set_wake;
> + Â Â Â else if (chip->irq_set_wake)
> + Â Â Â Â Â Â Â chip->set_wake = compat_set_wake;
> +
> Â Â Â Âif (chip->retrigger)
> Â Â Â Â Â Â Â Âchip->irq_retrigger = compat_irq_retrigger;
> + Â Â Â else if (chip->irq_retrigger)
> + Â Â Â Â Â Â Â chip->retrigger = compat_retrigger;
> Â#endif
> Â}
>
> --
> 1.7.1
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
> Please read the FAQ at Âhttp://www.tux.org/lkml/
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/