Changeset View
Standalone View
sys/compat/linuxkpi/common/include/linux/timer.h
| Show All 29 Lines | |||||
| #define _LINUXKPI_LINUX_TIMER_H_ | #define _LINUXKPI_LINUX_TIMER_H_ | ||||
| #include <linux/types.h> | #include <linux/types.h> | ||||
| #include <sys/param.h> | #include <sys/param.h> | ||||
| #include <sys/kernel.h> | #include <sys/kernel.h> | ||||
| #include <sys/callout.h> | #include <sys/callout.h> | ||||
| #if defined(LINUXKPI_VERSION) && (LINUXKPI_VERSION < 41500) && !defined(_WANT_LKPI_TIMER_CONTAINER_OF) /* 354b46b1a0add */ | |||||
| #define _TIMER_LIST_FUNCTION_ARG unsigned long | |||||
| #else | |||||
| #define _TIMER_LIST_FUNCTION_ARG struct timer_list * | |||||
| #endif | |||||
| #define _TIME_LIST_DATA(_t) ((_TIMER_LIST_FUNCTION_ARG)(_t)->data) | |||||
| struct timer_list { | struct timer_list { | ||||
| struct callout callout; | struct callout callout; | ||||
| union { | void (*function) (_TIMER_LIST_FUNCTION_ARG); | ||||
kib: What about having two function pointers of corresponding types, e.g.
`void (*function)(struct… | |||||
bzAuthorUnsubmitted Done Inline ActionsWell (1) as I said I highly suggest that maintainers of these drivers seek a different solution (either updated LinuxKPI or fully native) as the LinuxKPI is out of date since Jan 2018. Once all the drivers are updated I intend to remove the 415 backward compat hacks. bz: Well
(1) as I said `I highly suggest that maintainers of these drivers seek a different… | |||||
kibUnsubmitted Not Done Inline ActionsSo what do you want from the driver maintainers, for instance lets consider mlx5. There are two calls to setup_timer(), both are trivially convertible to the new KPI. What should I do there? I would gladly test a patch for mlx5 if you have it. kib: So what do you want from the driver maintainers, for instance lets consider mlx5. There are… | |||||
bzAuthorUnsubmitted Done Inline ActionsSorry, what should I write a patch for? I am not maintaining mlx5. bz: Sorry, what should I write a patch for? I am not maintaining mlx5.
If you know how to convert… | |||||
kibUnsubmitted Not Done Inline ActionsThis is the sweeping change, relatively trivial. Since you are pushing the KPI, it makes sense to just convert everything and be done with it. kib: This is the sweeping change, relatively trivial. Since you are pushing the KPI, it makes sense… | |||||
| void (*function) (unsigned long); /* < v4.15 */ | /* #if defined(LINUXKPI_VERSION) && (LINUXKPI_VERSION < 41500) */ /* c1eba5bcb643 */ | ||||
| void (*function_415) (struct timer_list *); | |||||
| }; | |||||
| unsigned long data; | unsigned long data; | ||||
| /* #endif */ | |||||
| unsigned long expires; | unsigned long expires; | ||||
| }; | }; | ||||
| extern unsigned long linux_timer_hz_mask; | extern unsigned long linux_timer_hz_mask; | ||||
| #define TIMER_IRQSAFE 0x0001 | #define TIMER_IRQSAFE 0x0001 | ||||
| #if defined(LINUXKPI_VERSION) && (LINUXKPI_VERSION < 61600) | #if defined(LINUXKPI_VERSION) && (LINUXKPI_VERSION < 61600) && !defined(_WANT_LKPI_TIMER_CONTAINER_OF) | ||||
| #define from_timer(var, arg, field) \ | #define from_timer(var, arg, field) \ | ||||
| container_of(arg, typeof(*(var)), field) | container_of(arg, typeof(*(var)), field) | ||||
| #else | #else | ||||
| #define timer_container_of(var, arg, field) \ | #define timer_container_of(var, arg, field) \ | ||||
| container_of(arg, typeof(*(var)), field) | container_of(arg, typeof(*(var)), field) | ||||
| #endif | #endif | ||||
| #define timer_setup(timer, func, flags) do { \ | #define timer_setup(timer, func, flags) do { \ | ||||
| CTASSERT(((flags) & ~TIMER_IRQSAFE) == 0); \ | CTASSERT(((flags) & ~TIMER_IRQSAFE) == 0); \ | ||||
| (timer)->function_415 = (func); \ | (timer)->function = (func); \ | ||||
| (timer)->data = (unsigned long)(timer); \ | (timer)->data = (unsigned long)(timer); \ | ||||
| callout_init(&(timer)->callout, 1); \ | callout_init(&(timer)->callout, 1); \ | ||||
| } while (0) | } while (0) | ||||
| #define setup_timer(timer, func, dat) do { \ | #define setup_timer(timer, func, dat) do { \ | ||||
| (timer)->function = (func); \ | (timer)->function = (func); \ | ||||
| (timer)->data = (dat); \ | (timer)->data = (dat); \ | ||||
| callout_init(&(timer)->callout, 1); \ | callout_init(&(timer)->callout, 1); \ | ||||
| ▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines | |||||
What about having two function pointers of corresponding types, e.g.
void (*function)(struct timer_list *)
and
void (*function_415)(unsigned long)
in the structure. Then, compiler will flag all places where incompatible assignment is performed, and since most (ab)users of the old interface are already heavily patched it would be just one more patch for them.
Or just change to the new signature. 415 is too old IMO.