let ipipe_catch_event return old handler
PATCH 1/1 let ipipe_catch_event return old handler
Hi,
this patch extends ipipe_catch_event() so that the previously registered event handler is returned. The usage scenario are event listeners that hook onto an existing listener for a specific domain, maybe filtering events or simply overruling the original handler.
Note that this patch effectively removes the error detection from ipipe_catch_event(), i.e. requests for event >= IPIPE_NR_EVENTS will be silently ignored now. Regarding Xenomai as Ipipe user, this is a non-issue as return codes are not checked there and only valid events are passed.
Jan
include/linux/ipipe.h +9 -9
@@ -125,9 +125,13 @@typedef void (*ipipe_irq_handler_t )(unsigned irq,void *cookie); +#define IPIPE_SAME_HANDLER ((ipipe_irq_handler_t)(-1)) +typedef int (*ipipe_irq_ackfn_t )(unsigned irq); -#define IPIPE_SAME_HANDLER ((ipipe_irq_handler_t)(-1)) +typedef int (*ipipe_event_handler_t )(unsigned event, +struct ipipe_domain *from, +void *data);struct ipipe_domain {
@@ -150,9 +154,7 @@void *cookie; }____cacheline_aligned irqs[IPIPE_NR_IRQS ]; -int (*evhand[IPIPE_NR_EVENTS ])(unsigned event, -struct ipipe_domain *from, -void *data);/* Event handlers. */ +ipipe_event_handler_t evhand[IPIPE_NR_EVENTS ];/* Event handlers. */ unsigned long long evself;/* Self-monitored event bits. */ #ifdef CONFIG_IPIPE_STATS
@@ -711,11 +713,9 @@clear_bit (IPIPE_SPRINTK_FLAG , &ipd->flags); } -int ipipe_catch_event (struct ipipe_domain *ipd, -unsigned event, -int (*handler)(unsigned event, -struct ipipe_domain *ipd, -void *data)); +ipipe_event_handler_t ipipe_catch_event (struct ipipe_domain *ipd, +unsigned event, +ipipe_event_handler_t handler);cpumask_t ipipe_set_irq_affinity (unsigned irq,cpumask_t cpumask);
kernel/ipipe/generic.c +5 -5
@@ -266,9 +266,9 @@* ipipe_catch_event() -- Interpose or remove an event handler for a * given domain. */ -int ipipe_catch_event (struct ipipe_domain *ipd, -unsigned event, -int (*handler)(unsigned event,struct ipipe_domain *ipd,void *data)) +ipipe_event_handler_t ipipe_catch_event (struct ipipe_domain *ipd, +unsigned event, +ipipe_event_handler_t handler) {int self =0 ;
@@ -278,7 +278,7 @@ }if (event >=IPIPE_NR_EVENTS ) -return -EINVAL ; +return NULL ;if (!xchg (&ipd->evhand[event],handler)) {if (handler) {
@@ -301,7 +301,7 @@ ipd->evself |= (1LL << event); } -return 0 ; +return handler; }cpumask_t ipipe_set_irq_affinity (unsigned irq,cpumask_t cpumask)
Jan Kiszka wrote:
<snip>
Don't you mean this instead?
kernel/ipipe/generic.c line 272
Quoted 7 lines
kernel/ipipe/generic.c +3
-3-int ipipe_catch_event (struct ipipe_domain *ipd, -unsigned event, -int (*handler)(unsigned event,struct ipipe_domain *ipd,void *data)) +ipipe_event_handler_t ipipe_catch_event (struct ipipe_domain *ipd, +unsigned event, +ipipe_event_handler_t handler) {
+ ipipe_event_handler_t old_handler;
kernel/ipipe/generic.c line 282
Quoted 9 lines
kernel/ipipe/generic.c +1
-1int self =0 ;@@ -278,7 +278,7 @@ }if (event >=IPIPE_NR_EVENTS ) -return -EINVAL ; +return NULL ;
- if (!xchg(&ipd->evhand[event],handler)) {
+ if (!(old_handler = xchg(&ipd->evhand[event],handler))) {
> if (handler) {kernel/ipipe/generic.c line 304
Quoted 6 lines
kernel/ipipe/generic.c +1
-1@@ -301,7 +301,7 @@ ipd->evself |= (1LL << event); } -return 0 ; +return handler;
- return handler;
+ return old_handler;
Quoted 11 lines
kernel/ipipe/generic.c +0
-1}cpumask_t ipipe_set_irq_affinity (unsigned irq,cpumask_t cpumask) ------------------------------------------------------------------------_______________________________________________
Adeos-main mailing list
[email protected]
https://mail.gna.org/listinfo/adeos-main
Signature · 1 line
Philippe.
Quoted 37 lines · Philippe Gerum
Jan Kiszka wrote:
<snip>
Don't you mean this instead?
kernel/ipipe/generic.c line 272
Quoted 8 lines
include/linux/ipipe.h +0
-3-int ipipe_catch_event(struct ipipe_domain *ipd, - unsigned event, - int (*handler)(unsigned event, struct ipipe_domain*ipd, void *data))
kernel/ipipe/generic.c +3
-0+ipipe_event_handler_t ipipe_catch_event (struct ipipe_domain *ipd, +unsigned event, +ipipe_event_handler_t handler) {+
ipipe_event_handler_told_handler;Quoted 9 lines
int self = 0;kernel/ipipe/generic.c +1
-1@@ -278,7 +278,7 @@ }if (event >=IPIPE_NR_EVENTS ) -return -EINVAL ; +return NULL ;(quoted diff) +1
-1- if (!xchg(&ipd->evhand[event],handler)) { + if (!(old_handler = xchg(&ipd->evhand[event],handler))) {Quoted 7 lines
kernel/ipipe/generic.c +1
-1if (handler) {@@ -301,7 +301,7 @@ ipd->evself |= (1LL << event); } -return 0 ; +return handler;(quoted diff) +1
-1- return handler; + return old_handler;Quoted 2 lines
(quoted diff) +0
-0}
Quoted 3 lines
kernel/ipipe/generic.c line 307
Quoted 3 lines
kernel/ipipe/generic.c +0
-0cpumask_t ipipe_set_irq_affinity (unsigned irq,cpumask_t cpumask)
Ouch, obviously. A quick hack which was only tested for not breaking existing software.
Jan
Quoted 46 lines · Jan Kiszka
Quoted 44 lines · Philippe Gerum
Jan Kiszka wrote:
<snip>
Don't you mean this instead?
Quoted 8 lines
include/linux/ipipe.h +0
-3-int ipipe_catch_event(struct ipipe_domain *ipd, - unsigned event, - int (*handler)(unsigned event, struct ipipe_domain*ipd, void *data))
kernel/ipipe/generic.c +3
-0+ipipe_event_handler_t ipipe_catch_event (struct ipipe_domain *ipd, +unsigned event, +ipipe_event_handler_t handler){
+
ipipe_event_handler_told_handler;Quoted 9 lines
int self = 0;kernel/ipipe/generic.c +1
-1@@ -278,7 +278,7 @@ }if (event >=IPIPE_NR_EVENTS ) -return -EINVAL ; +return NULL ;(quoted diff) +1
-1- if (!xchg(&ipd->evhand[event],handler)) { + if (!(old_handler = xchg(&ipd->evhand[event],handler))) {Quoted 8 lines
kernel/ipipe/generic.c +1
-1if (handler) {@@ -301,7 +301,7 @@ ipd->evself |= (1LL << event); } -return 0 ; +return handler;(quoted diff) +1
-1- return handler; + return old_handler;Quoted 3 lines
(quoted diff) +0
-0}
Quoted 8 lines
Quoted 3 lines
kernel/ipipe/generic.c line 307
Quoted 3 lines
kernel/ipipe/generic.c +0
-0cpumask_t ipipe_set_irq_affinity (unsigned irq,cpumask_t cpumask)Ouch, obviously. A quick hack which was only tested for not breaking existing software.
Ok, will merge. Thanks.
Signature · 1 line
Philippe.