DAHDI in kernel 4.15: Switch to new timer_setup interface.
Upstream kernel 4.14, in commit (686fef928bba6b "timer: Prepare to change timer callback argument type") [1], introduced the timer_setup interface to replace the init_timer/setup_timer interfaces. The primary change is that the timer callback functions now follow the standard kernel pattern where the structure the callback sits in is passed to the callback instead of storing a pointer to an unassociated data type. The setup_timer functions were removed in upstream kernel v4.15, and therefore this change is needed in order to compile DAHDI for kernels >= 4.15. This change follows the same strategy that was done in the kernel to while the existing users of setup_timer were migrated to the new interface. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=686fef928bba6b
This commit is contained in:
@@ -1404,6 +1404,33 @@ static inline short dahdi_txtone_nextsample(struct dahdi_chan *ss)
|
||||
/*! Maximum audio mask */
|
||||
#define DAHDI_FORMAT_AUDIO_MASK ((1 << 16) - 1)
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
|
||||
|
||||
#ifndef TIMER_DATA_TYPE
|
||||
#define TIMER_DATA_TYPE unsigned long
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 13, 0)
|
||||
|
||||
/**
|
||||
* timer_setup - Added in 4.13.0. We can make a direct translation to the
|
||||
* setup_timer interface since DAHDI does not pass any flags to any of the
|
||||
* timer_setup functions.
|
||||
*
|
||||
*/
|
||||
static inline void
|
||||
timer_setup(struct timer_list *timer,
|
||||
void (*timer_callback)(TIMER_DATA_TYPE data),
|
||||
unsigned long flags)
|
||||
{
|
||||
WARN_ON(flags != 0);
|
||||
setup_timer(timer, timer_callback, (TIMER_DATA_TYPE)timer);
|
||||
}
|
||||
|
||||
#define from_timer(var, callback_timer, timer_fieldname) \
|
||||
container_of((struct timer_list *)(callback_timer), \
|
||||
typeof(*var), timer_fieldname)
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
|
||||
#define refcount_read atomic_read
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 16, 0)
|
||||
@@ -1536,6 +1563,14 @@ static inline int strcasecmp(const char *s1, const char *s2)
|
||||
#endif /* 3.10.0 */
|
||||
#endif /* 3.16.0 */
|
||||
#endif /* 4.11.0 */
|
||||
#endif /* 4.13.0 */
|
||||
#else /* >= 4.15.0 */
|
||||
|
||||
#ifndef TIMER_DATA_TYPE
|
||||
#define TIMER_DATA_TYPE struct timer_list *
|
||||
#endif
|
||||
|
||||
#endif /* 4.15.0 */
|
||||
|
||||
#ifndef DEFINE_SPINLOCK
|
||||
#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
|
||||
|
||||
Reference in New Issue
Block a user