From: Jeff Garzik <jgarzik@pobox.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Ash Willis <ashwillis@programmer.net>,
linux-pcmcia@lists.infradead.org,
virtualization@lists.linux-foundation.org,
Tejun Heo <htejun@gmail.com>
Subject: Re: [PATCH 2/3] Make IRQ handlers typesafe.
Date: Fri, 18 Jan 2008 15:43:59 -0500 [thread overview]
Message-ID: <47910F8F.3040107@pobox.com> (raw)
In-Reply-To: <200801190725.24271.rusty@rustcorp.com.au>
Rusty Russell wrote:
> This patch lets interrupt handler functions have their natural type
> (ie. exactly match the data pointer type); for transition it allows
> the old irq_handler_t type as well.
>
> To do this it uses a gcc extension, cast-to-union, which allows a type
> to be cast to any type within the union. When used in a wrapper
> macro, it's a simple way of allowing one of several types.
>
> (Some drivers now need to be cleaned up to compile, previous patch).
>
> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
> ---
> include/linux/interrupt.h | 17 +++++++++++++++--
> include/linux/kernel.h | 7 +++++++
> kernel/irq/devres.c | 10 +++++-----
> kernel/irq/manage.c | 6 +++---
> 4 files changed, 30 insertions(+), 10 deletions(-)
>
> diff -r 0fe1a980708b include/linux/interrupt.h
> --- a/include/linux/interrupt.h Thu Jan 17 14:48:56 2008 +1100
> +++ b/include/linux/interrupt.h Thu Jan 17 15:42:01 2008 +1100
> @@ -69,13 +69,26 @@ struct irqaction {
> };
>
> extern irqreturn_t no_action(int cpl, void *dev_id);
> -extern int __must_check request_irq(unsigned int, irq_handler_t handler,
> +
> +/* Typesafe version of request_irq. Also takes old-style void * handlers. */
> +#define request_irq(irq, handler, flags, name, dev_id) \
> + __request_irq((irq), \
> + check_either_type((handler), irq_handler_t, \
> + int (*)(int, typeof(dev_id))), \
> + (flags), (name), (dev_id))
> +
> +extern int __must_check __request_irq(unsigned int, irq_handler_t handler,
> unsigned long, const char *, void *);
> extern void free_irq(unsigned int, void *);
>
> struct device;
>
> -extern int __must_check devm_request_irq(struct device *dev, unsigned int irq,
> +#define devm_request_irq(dev, irq, handler, flags, name, dev_id) \
> + __devm_request_irq((dev), (irq), \
> + check_either_type((handler), irq_handler_t, \
> + int (*)(int, typeof(dev_id))), \
> + (flags), (name), (dev_id))
> +extern int __must_check __devm_request_irq(struct device *dev, unsigned int irq,
> irq_handler_t handler, unsigned long irqflags,
> const char *devname, void *dev_id);
This is ugly and unnecessary.
Anything that does not use irq_handler_t is broken and should be fixed
(as noted in last email, I think I've covered all this driver work already)
And if by definition everything uses irq_handler_t, there is no need for
any of this "check_either_type" silliness.
Jeff
next prev parent reply other threads:[~2008-01-18 20:44 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-18 20:22 [PATCH 1/3] Improve type handling in interrupt handlers Rusty Russell
2008-01-18 20:25 ` [PATCH 2/3] Make IRQ handlers typesafe Rusty Russell
2008-01-18 20:25 ` Rusty Russell
2008-01-18 20:27 ` [PATCH 3/3] Makes lguest's irq handler typesafe Rusty Russell
2008-01-18 20:27 ` Rusty Russell
2008-01-18 20:45 ` Jeff Garzik
2008-01-18 22:17 ` Rusty Russell
2008-01-18 22:17 ` Rusty Russell
2008-01-18 20:45 ` Jeff Garzik
2008-01-18 23:12 ` Tejun Heo
2008-01-19 1:28 ` Rusty Russell
2008-01-19 1:40 ` Tejun Heo
2008-01-19 1:40 ` Tejun Heo
2008-01-19 1:44 ` Tejun Heo
2008-01-19 3:59 ` Rusty Russell
2008-01-19 3:59 ` Rusty Russell
2008-01-19 4:08 ` Tejun Heo
2008-01-19 4:08 ` Tejun Heo
2008-01-19 23:27 ` Rusty Russell
2008-01-19 23:27 ` Rusty Russell
2008-01-19 1:44 ` Tejun Heo
2008-01-19 1:28 ` Rusty Russell
2008-01-18 23:12 ` Tejun Heo
2008-01-18 20:43 ` Jeff Garzik [this message]
2008-01-18 20:43 ` [PATCH 2/3] Make IRQ handlers typesafe Jeff Garzik
2008-01-18 20:41 ` [PATCH 1/3] Improve type handling in interrupt handlers Jeff Garzik
2008-01-18 22:11 ` Rusty Russell
2008-01-18 22:54 ` Jeff Garzik
2008-01-19 1:29 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=47910F8F.3040107@pobox.com \
--to=jgarzik@pobox.com \
--cc=akpm@linux-foundation.org \
--cc=ashwillis@programmer.net \
--cc=htejun@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pcmcia@lists.infradead.org \
--cc=rusty@rustcorp.com.au \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.