All of lore.kernel.org
 help / color / mirror / Atom feed
* [Adeos-main] [PATCH] let ipipe_catch_event return old handler
@ 2006-04-21 14:38 Jan Kiszka
  2006-04-21 15:12 ` [Xenomai-core] " Philippe Gerum
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Kiszka @ 2006-04-21 14:38 UTC (permalink / raw)
  To: adeos-main; +Cc: Philippe Gerum


[-- Attachment #1.1: Type: text/plain, Size: 574 bytes --]

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

[-- Attachment #1.2: catch_event.patch --]
[-- Type: text/plain, Size: 2451 bytes --]

Index: linux-2.6.16.1/include/linux/ipipe.h
===================================================================
--- linux-2.6.16.1.orig/include/linux/ipipe.h
+++ linux-2.6.16.1/include/linux/ipipe.h
@@ -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);
Index: linux-2.6.16.1/kernel/ipipe/generic.c
===================================================================
--- linux-2.6.16.1.orig/kernel/ipipe/generic.c
+++ linux-2.6.16.1/kernel/ipipe/generic.c
@@ -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)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-04-21 15:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-21 14:38 [Adeos-main] [PATCH] let ipipe_catch_event return old handler Jan Kiszka
2006-04-21 15:12 ` [Xenomai-core] " Philippe Gerum
2006-04-21 15:38   ` Jan Kiszka
2006-04-21 15:47     ` Philippe Gerum

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.