Commit ca26f914 authored by Mathis MARION's avatar Mathis MARION Committed by Federico Vaga

Kernel 4.15 compatibility for setup_timer

`setup_timer` is no longer available in kernel 4.15 and onwards,
in favor of `timer_setup`.
Before, we could pass an argument to the callback function as an
unsigned int (generally used with a pointer cast), but now the timer
itself is passed and we retrieve the container struct with a new
macro `from_timer` which is uses `container_of`.
The flags parameter can be set as 0 for the same behavior.
Signed-off-by: 's avatarGwenhael GOAVEC <gwenhael.goavec@femto-st.fr>
Signed-off-by: 's avatarMathis MARION <mathis.marion@grenoble-inp.org>
Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 1a28ef62
......@@ -311,6 +311,14 @@ void fa_calib_config(struct fa_dev *fa)
fa_calib_config_chan(fa, i, temperature, 0);
spin_unlock(&fa->zdev->cset->lock);
}
static void __fa_calib_gain_update(struct fa_dev *fa)
{
fa_calib_config(fa);
mod_timer(&fa->calib_timer, jiffies + HZ * fa_calib_temp_period);
}
/**
* Periodically update gain calibration values
* @fa: FMC ADC device
......@@ -320,14 +328,17 @@ void fa_calib_config(struct fa_dev *fa)
* linear behavior with respect to the temperature.
*
*/
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
static void fa_calib_gain_update(struct timer_list *timer)
{
__fa_calib_gain_update(from_timer(fa, timer, calib_timer));
}
#else
static void fa_calib_gain_update(unsigned long arg)
{
struct fa_dev *fa = (void *)arg;
fa_calib_config(fa);
mod_timer(&fa->calib_timer, jiffies + HZ * fa_calib_temp_period);
__fa_calib_gain_update((void *)arg);
}
#endif
/* Actual verification code */
static int fa_verify_calib_stanza(struct device *msgdev, char *name, int r,
struct fa_calib_stanza *cal)
......@@ -500,7 +511,11 @@ int fa_calib_init(struct fa_dev *fa)
/* Prepare the timely recalibration */
if (fa_calib_is_compensation_on(fa) && fa_calib_temp_period) {
#if KERNEL_VERSION(4, 15, 0) <= LINUX_VERSION_CODE
timer_setup(&fa->calib_timer, fa_calib_gain_update, 0);
#else
setup_timer(&fa->calib_timer, fa_calib_gain_update, (unsigned long)fa);
#endif
mod_timer(&fa->calib_timer,
jiffies + HZ * fa_calib_temp_period);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment