Skip to contentSkip to conversation

IRQ: ease out-of-tree migration to new irq_handler prototype

PATCH In review William D Waddington 2 participants 5 messages Nov 4, 2006 – Nov 5, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IRQ: ease out-of-tree migration to new irq_handler prototype

From: [email protected]

Ease out-of-tree driver migration to new irq_handler prototype. Define empty 3rd argument macro for use in multi kernel version out-of-tree drivers going forward. Backportable drives can do:

(in a header)
#ifndef __PT_REGS

# define __PT_REGS , struct pt_regs *regs
#endif

(in code body)
static irqreturn_t irq_handler(int irq, void *dev_id __PT_REGS)

---

Has this suggestion by Ingo Molnar been implemented? May I submit it? Is this how it's done?

include/linux/interrupt.h renamed from include/linux/interrupt.h.ORIG +8 -0
@@ -66,6 +66,14 @@
 
 typedef irqreturn_t (*irq_handler_t)(int, void *);
 
+/*
+ * Irq handler migration helper - empty 3rd argument
+ * #define __PT_REGS , struct pt_regs *regs
+ * for older kernel versions
+ */
+
+#define __PT_REGS
+
 struct irqaction {
 	irq_handler_t handler;
 	unsigned long flags;

Bill

Signature · 7 lines
--------------------------------------------
William D Waddington
Bainbridge Island, WA, USA
[email protected]
--------------------------------------------
"Even bugs...are unexpected signposts on
the long road of creativity..." - Ken Burtch
#1 lore raw
Quoted 8 lines · William D Waddington

Ease out-of-tree driver migration to new irq_handler prototype. Define empty 3rd argument macro for use in multi kernel version out-of-tree drivers going forward. Backportable drives can do:

(in a header)
#ifndef __PT_REGS

# define __PT_REGS , struct pt_regs *regs
#endif

Backportable drivers should check kernel version themselves and define __PT_REGS themselves.

Quoted 10 lines

(in code body)
static irqreturn_t irq_handler(int irq, void *dev_id __PT_REGS)

include/linux/interrupt.h renamed from include/linux/interrupt.h.ORIG +7 -0
+/*
+ * Irq handler migration helper - empty 3rd argument
+ * #define __PT_REGS , struct pt_regs *regs
+ * for older kernel versions
+ */
+
+#define __PT_REGS
#2 lore raw
Quoted 6 lines · Alexey Dobriyan
Quoted 4 lines · William D Waddington

Ease out-of-tree driver migration to new irq_handler prototype. Define empty 3rd argument macro for use in multi kernel version out-of-tree drivers going forward. Backportable drives can do:

Quoted 8 lines
Quoted 4 lines

(in a header)
#ifndef __PT_REGS

# define __PT_REGS , struct pt_regs *regs
#endif

Backportable drivers should check kernel version themselves and define __PT_REGS themselves.

I think I provided too much information :( It would be sufficiently helpful to just #define __PT_REGS <nothing> in interrupt.h to make things easier for low-life out-of-tree maintainers. There isn't any need to actualy detect version. Just detect __PT_REGS already defined.

The "in a header" above referred to the driver's header - #ifdefs in executable code really looks nasty IMHO.

The "#define __PT_REGS , ..." comment below was intended to be a "helpful" note to driver writers. Like I said, TMI.

Quoted 11 lines

include/linux/interrupt.h line 75

Quoted 11 lines

(in code body)
static irqreturn_t irq_handler(int irq, void *dev_id __PT_REGS)

include/linux/interrupt.h renamed from include/linux/interrupt.h.ORIG +7 -0
+/*
+ * Irq handler migration helper - empty 3rd argument
+ * #define __PT_REGS , struct pt_regs *regs
+ * for older kernel versions
+ */
+
+#define __PT_REGS

How should I tidy this up - if it is acceptable at all? I'm a total noob struggling with a 1-line patch.

Bill

Signature · 7 lines
--------------------------------------------
William D Waddington
Bainbridge Island, WA, USA
[email protected]
--------------------------------------------
"Even bugs...are unexpected signposts on
the long road of creativity..." - Ken Burtch
#3 lore raw
Quoted 13 lines · William D Waddington
Quoted 12 lines · Alexey Dobriyan
Quoted 8 lines · William D Waddington

Ease out-of-tree driver migration to new irq_handler prototype. Define empty 3rd argument macro for use in multi kernel version out-of-tree drivers going forward. Backportable drives can do:

(in a header)
#ifndef __PT_REGS

# define __PT_REGS , struct pt_regs *regs
#endif
Quoted 7 lines
Quoted 2 lines

Backportable drivers should check kernel version themselves and define __PT_REGS themselves.

I think I provided too much information :( It would be sufficiently helpful to just #define __PT_REGS <nothing> in interrupt.h to make things easier for low-life out-of-tree maintainers. There isn't any need to actualy detect version. Just detect __PT_REGS already defined.

Out-of-tree maintainer will have to change his code ANYWAY. And while he is doing that, he can spend 10 seconds to add 5-line version check.

More, if you've followed pt_regs removal patches, you'd noticed that some of them were not trivial. In this case version check is least of his worries.

Quoted 10 lines

The "in a header" above referred to the driver's header - #ifdefs in executable code really looks nasty IMHO.

The "#define __PT_REGS , ..." comment below was intended to be a "helpful" note to driver writers. Like I said, TMI.

Quoted 4 lines
Quoted 2 lines

(in code body)
static irqreturn_t irq_handler(int irq, void *dev_id __PT_REGS)

Quoted 9 lines
Quoted 7 lines

include/linux/interrupt.h line 75

Quoted 7 lines
include/linux/interrupt.h renamed from include/linux/interrupt.h.ORIG +7 -0
+/*
+ * Irq handler migration helper - empty 3rd argument
+ * #define __PT_REGS , struct pt_regs *regs
+ * for older kernel versions
+ */
+
+#define __PT_REGS

How should I tidy this up - if it is acceptable at all?

No, this is not acceptable.

#4 lore raw
Quoted 20 lines · Alexey Dobriyan
Quoted 18 lines · William D Waddington
Quoted 15 lines · Alexey Dobriyan
Quoted 8 lines · William D Waddington

Ease out-of-tree driver migration to new irq_handler prototype. Define empty 3rd argument macro for use in multi kernel version out-of-tree drivers going forward. Backportable drives can do:

(in a header)
#ifndef __PT_REGS

# define __PT_REGS , struct pt_regs *regs
#endif

Backportable drivers should check kernel version themselves and define __PT_REGS themselves.

Quoted 8 lines
Quoted 4 lines

I think I provided too much information :( It would be sufficiently helpful to just #define __PT_REGS <nothing> in interrupt.h to make things easier for low-life out-of-tree maintainers. There isn't any need to actualy detect version. Just detect __PT_REGS already defined.

Out-of-tree maintainer will have to change his code ANYWAY. And while he is doing that, he can spend 10 seconds to add 5-line version check.

I'm a little out of my depth here (obviously) but why is it "better" to require a version check rather than the kernel simply flagging the function change? Rather like HAVE_COMPAT_IOCTL.

With the proposed 1-line kernel patch my drivers build against kernels back to 2.6.9 (the earliest I have around here) without any version checking.

Quoted 3 lines

More, if you've followed pt_regs removal patches, you'd noticed that some of them were not trivial. In this case version check is least of his worries.

Ah. I don't use the *regs arg. The one line patch just keeps the compiler happy. And provides a "tidy" way to detect the interface change if necessary.

Quoted 22 lines
Quoted 11 lines

The "in a header" above referred to the driver's header - #ifdefs in executable code really looks nasty IMHO.

The "#define __PT_REGS , ..." comment below was intended to be a "helpful" note to driver writers. Like I said, TMI.

Quoted 4 lines
Quoted 2 lines

(in code body)
static irqreturn_t irq_handler(int irq, void *dev_id __PT_REGS)

Quoted 9 lines
Quoted 7 lines

include/linux/interrupt.h line 75

Quoted 7 lines
include/linux/interrupt.h renamed from include/linux/interrupt.h.ORIG +7 -0
+/*
+ * Irq handler migration helper - empty 3rd argument
+ * #define __PT_REGS , struct pt_regs *regs
+ * for older kernel versions
+ */
+
+#define __PT_REGS

How should I tidy this up - if it is acceptable at all?

Quoted 1 line

No, this is not acceptable.

Oh well.

Thanks for your time,
Bill

Signature · 7 lines
--------------------------------------------
William D Waddington
Bainbridge Island, WA, USA
[email protected]
--------------------------------------------
"Even bugs...are unexpected signposts on
the long road of creativity..." - Ken Burtch