Compatibility layer for hrtimer API
PATCH 1/2 Compatibility layer for hrtimer API
Kernels 2.6.22 to 2.6.24 (inclusive) need some compatibility quirks for the hrtimer API. For older kernels, some required functions were not exported so there's nothing we can do. This means that drivers using the hrtimer infrastructure will no longer work for kernels older than 2.6.22.
--- v4l/compat.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
v4l/compat.h +18 -0
@@ -480,4 +480,22 @@ static inline unsigned long v4l_compat_f }#endif +/* +* Compatibility code for hrtimer API +* This will make hrtimer usable for kernels 2.6.22 and later. +* For earlier kernels, not all required functions are exported +* so there's nothing we can do. +*/ + +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,25 ) && \ +LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,22 ) +#include <linux/hrtimer.h> +/* Forward a hrtimer so it expires after the hrtimer's current now */ +static inline unsigned long hrtimer_forward_now (struct hrtimer *timer, +ktime_t interval) +{ +return hrtimer_forward (timer, timer->base->get_time (), interval); +} +#endif +#endif /* _COMPAT_H */
Signature · 1 line
Jean Delvare
Quoted 17 lines · Jean Delvare
Kernels 2.6.22 to 2.6.24 (inclusive) need some compatibility quirks for the hrtimer API. For older kernels, some required functions were not exported so there's nothing we can do. This means that drivers using the hrtimer infrastructure will no longer work for kernels older than 2.6.22.
Signed-off-by Jean Delvare <[email protected]>--- v4l/compat.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)v4l/compat.h +0
-0@@ -480,4 +480,22 @@ static inline unsigned long v4l_compat_f }#endif
v4l/compat.h static inline unsigned long v4l_compat_f · line 492
Quoted 10 lines
v4l/compat.h +10
-0+/* +* Compatibility code for hrtimer API +* This will make hrtimer usable for kernels 2.6.22 and later. +* For earlier kernels, not all required functions are exported +* so there's nothing we can do. +*/ + +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,25 ) && \ +LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,22 ) +#include <linux/hrtimer.h>
Instead of including hrtimer.h from compat.h it's better if you check if it has already been included and only enable the compat code in that case. That way hrtimer doesn't get included for files that don't need it and might define something that conflicts with something from hrtimer. And it prevents someone from forgetting to include hrtimer when they needed it, but having the error masked because compat.h is doing it for them.
Quoted 9 lines
v4l/compat.h +8
-0+/* Forward a hrtimer so it expires after the hrtimer's current now */ +static inline unsigned long hrtimer_forward_now (struct hrtimer *timer, +ktime_t interval) +{ +return hrtimer_forward (timer, timer->base->get_time (), interval); +} +#endif +#endif /* _COMPAT_H */
Hi Trent,
Quoted 27 lines · Trent Piepho
Quoted 26 lines · Jean Delvare
Kernels 2.6.22 to 2.6.24 (inclusive) need some compatibility quirks for the hrtimer API. For older kernels, some required functions were not exported so there's nothing we can do. This means that drivers using the hrtimer infrastructure will no longer work for kernels older than 2.6.22.
Signed-off-by Jean Delvare <[email protected]>--- v4l/compat.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)v4l/compat.h +9
-0@@ -480,4 +480,22 @@ static inline unsigned long v4l_compat_f }#endif +/* +* Compatibility code for hrtimer API +* This will make hrtimer usable for kernels 2.6.22 and later. +* For earlier kernels, not all required functions are exported +* so there's nothing we can do. +*/ + +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,25 ) && \ +LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,22 )
Quoted 8 lines
v4l/compat.h static inline unsigned long v4l_compat_f · line 492
Quoted 1 line
v4l/compat.h +1
-0+#include <linux/hrtimer.h> Instead of including
hrtimer.hfromcompat.hit's better if you check if it has already been included and only enable the compat code in that case. That way hrtimer doesn't get included for files that don't need it and might define something that conflicts with something from hrtimer. And it prevents someone from forgetting to include hrtimer when they needed it, but having the error masked becausecompat.his doing it for them.
I see. But this will only work if compat.h is included after all headers. If it always the case? I see for example that cx88-input includes <media/ir-common.h> after "compat.h".
Quoted 9 lines
Quoted 9 lines
v4l/compat.h +8
-0+/* Forward a hrtimer so it expires after the hrtimer's current now */ +static inline unsigned long hrtimer_forward_now (struct hrtimer *timer, +ktime_t interval) +{ +return hrtimer_forward (timer, timer->base->get_time (), interval); +} +#endif +#endif /* _COMPAT_H */
Signature · 1 line
Jean Delvare
Quoted 39 lines · Jean Delvare
Hi Trent,
Quoted 27 lines · Trent Piepho
Quoted 26 lines · Jean Delvare
Kernels 2.6.22 to 2.6.24 (inclusive) need some compatibility quirks for the hrtimer API. For older kernels, some required functions were not exported so there's nothing we can do. This means that drivers using the hrtimer infrastructure will no longer work for kernels older than 2.6.22.
Signed-off-by Jean Delvare <[email protected]>--- v4l/compat.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)v4l/compat.h +9
-0@@ -480,4 +480,22 @@ static inline unsigned long v4l_compat_f }#endif +/* +* Compatibility code for hrtimer API +* This will make hrtimer usable for kernels 2.6.22 and later. +* For earlier kernels, not all required functions are exported +* so there's nothing we can do. +*/ + +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,25 ) && \ +LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,22 )Quoted 8 lines
v4l/compat.h static inline unsigned long v4l_compat_f · line 492
Quoted 1 line
v4l/compat.h +1
-0+#include <linux/hrtimer.h> Instead of including
hrtimer.hfromcompat.hit's better if you check if it has already been included and only enable the compat code in that case. That way hrtimer doesn't get included for files that don't need it and might define something that conflicts with something from hrtimer. And it prevents someone from forgetting to include hrtimer when they needed it, but having the error masked becausecompat.his doing it for them.
Quoted 3 lines
I see. But this will only work if
compat.his included after all headers. If it always the case? I see for example that cx88-input includes <media/ir-common.h> after "compat.h".
Headers that come from the kernel come before compat.h and headers that come from the v4l-dvb tree come after compat.h.
Quoted 41 lines · Trent Piepho
Quoted 39 lines · Jean Delvare
Hi Trent,
Quoted 35 lines · Trent Piepho
Quoted 17 lines · Jean Delvare
Kernels 2.6.22 to 2.6.24 (inclusive) need some compatibility quirks for the hrtimer API. For older kernels, some required functions were not exported so there's nothing we can do. This means that drivers using the hrtimer infrastructure will no longer work for kernels older than 2.6.22.
Signed-off-by Jean Delvare <[email protected]>--- v4l/compat.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)v4l/compat.h +0
-0@@ -480,4 +480,22 @@ static inline unsigned long v4l_compat_f }#endif v4l/compat.h static inline unsigned long v4l_compat_f · line 492
Quoted 10 lines
v4l/compat.h +10
-0+/* +* Compatibility code for hrtimer API +* This will make hrtimer usable for kernels 2.6.22 and later. +* For earlier kernels, not all required functions are exported +* so there's nothing we can do. +*/ + +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,25 ) && \ +LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,22 ) +#include <linux/hrtimer.h> Instead of including
hrtimer.hfromcompat.hit's better if you check if it has already been included and only enable the compat code in that case. That way hrtimer doesn't get included for files that don't need it and might define something that conflicts with something from hrtimer. And it prevents someone from forgetting to include hrtimer when they needed it, but having the error masked becausecompat.his doing it for them.
Quoted 6 lines
Quoted 3 lines
I see. But this will only work if
compat.his included after all headers. If it always the case? I see for example that cx88-input includes <media/ir-common.h> after "compat.h".Headers that come from the kernel come before
compat.hand headers that come from the v4l-dvb tree come aftercompat.h.
Ah, OK. I'll send an updated patch as soon as I am done with testing it.
Thanks,
Signature · 1 line
Jean Delvare
Kernels 2.6.22 to 2.6.24 (inclusive) need some compatibility quirks for the hrtimer API. For older kernels, some required functions were not exported so there's nothing we can do. This means that drivers using the hrtimer infrastructure will no longer work for kernels older than 2.6.22.
---
Updated according to Trent's comment: the compatibility code is only included if <linux/htrimer.h> was already included by the driver.
v4l/compat.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
v4l/compat.h +19 -0
@@ -480,4 +480,23 @@ static inline unsigned long v4l_compat_f }#endif +/* +* Compatibility code for hrtimer API +* This will make hrtimer usable for kernels 2.6.22 and later. +* For earlier kernels, not all required functions are exported +* so there's nothing we can do. +*/ + +#ifdef _LINUX_HRTIMER_H +#if LINUX_VERSION_CODE <KERNEL_VERSION (2 ,6 ,25 ) && \ +LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,6 ,22 ) +/* Forward a hrtimer so it expires after the hrtimer's current now */ +static inline unsigned long hrtimer_forward_now (struct hrtimer *timer, +ktime_t interval) +{ +return hrtimer_forward (timer, timer->base->get_time (), interval); +} +#endif +#endif /* _LINUX_HRTIMER_H */ +#endif /* _COMPAT_H */
Signature · 1 line
Jean Delvare