From 96cae7f9dead812a1a8f342499278d3721636182 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Mon, 9 Jun 2025 12:04:03 +0100 Subject: [PATCH] drivers: Fix from_timer() for Linux v6.16 In Linux v6.16, commit 41cb08555c41 ("treewide, timers: Rename from_timer() to timer_container_of()") renamed 'from_timer()' to 'timer_container_of()'. Given that this is a macro we can simplfy see if the macro 'timer_container_of' is defined and if so use this otherwise fall back to 'from_timer()'. Update the necessary drivers to fix the build for Linux v6.16. JIRA LINQPJ14-60 Change-Id: I7f622b5d046a92da2ade755e6a697c1810f61275 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3383387 (cherry picked from commit 320ec84efd492c0c2711c69104fabc30b4f15ecb) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3461850 GVS: buildbot_gerritrpt Reviewed-by: Brad Griffis --- drivers/block/tegra_virt_storage/tegra_hv_vblk.c | 4 ++++ drivers/misc/bluedroid_pm.c | 11 +++++++---- drivers/nvpps/nvpps_main.c | 14 ++++++++++++-- drivers/tty/serial/wch_35x/wch_serial.c | 5 +++++ drivers/watchdog/softdog-platform.c | 4 ++++ 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/block/tegra_virt_storage/tegra_hv_vblk.c b/drivers/block/tegra_virt_storage/tegra_hv_vblk.c index a9190c93..2208c69e 100644 --- a/drivers/block/tegra_virt_storage/tegra_hv_vblk.c +++ b/drivers/block/tegra_virt_storage/tegra_hv_vblk.c @@ -2369,7 +2369,11 @@ static irqreturn_t ivc_irq_handler(int irq, void *data) */ static void bio_request_timeout_callback(struct timer_list *timer) { +#if defined(timer_container_of) /* Linux v6.16 */ + struct vsc_request *req = timer_container_of(req, timer, timer); +#else struct vsc_request *req = from_timer(req, timer, timer); +#endif dev_err(req->vblkdev->device, "Request id %d timed out. curr ctr: %llu sched ctr: %llu\n", req->id, _arch_counter_get_cntvct(), req->time); diff --git a/drivers/misc/bluedroid_pm.c b/drivers/misc/bluedroid_pm.c index aa6a89cc..38d16b42 100644 --- a/drivers/misc/bluedroid_pm.c +++ b/drivers/misc/bluedroid_pm.c @@ -134,10 +134,13 @@ static void bluedroid_pm_gpio_set_value(struct gpio_desc *gpio, int value) */ static void bluedroid_pm_timer_expire(struct timer_list *timer) { - - struct bluedroid_pm_data *bluedroid_pm = - from_timer(bluedroid_pm, timer, - bluedroid_pm_timer); +#if defined(timer_container_of) /* Linux v6.16 */ + struct bluedroid_pm_data *bluedroid_pm = timer_container_of(bluedroid_pm, + timer, bluedroid_pm_timer); +#else + struct bluedroid_pm_data *bluedroid_pm = from_timer(bluedroid_pm, + timer, bluedroid_pm_timer); +#endif /* * if bluedroid_pm data is NULL or timer is deleted with TX busy. diff --git a/drivers/nvpps/nvpps_main.c b/drivers/nvpps/nvpps_main.c index 9ab548db..93cdda33 100644 --- a/drivers/nvpps/nvpps_main.c +++ b/drivers/nvpps/nvpps_main.c @@ -287,7 +287,12 @@ static irqreturn_t nvpps_gpio_isr(int irq, void *data) static void tsc_timer_callback(struct timer_list *t) { - struct nvpps_device_data *pdev_data = (struct nvpps_device_data *)from_timer(pdev_data, t, tsc_timer); + struct nvpps_device_data *pdev_data = +#if defined(timer_container_of) /* Linux v6.16 */ + timer_container_of(pdev_data, t, tsc_timer); +#else + from_timer(pdev_data, t, tsc_timer); +#endif if (pdev_data->soc_data.ops->ptp_tsc_get_is_locked_fn) { /* check and trigger sync if PTP-TSC is unlocked */ @@ -305,7 +310,12 @@ static void tsc_timer_callback(struct timer_list *t) static void nvpps_timer_callback(struct timer_list *t) { - struct nvpps_device_data *pdev_data = (struct nvpps_device_data *)from_timer(pdev_data, t, timer); + struct nvpps_device_data *pdev_data = +#if defined(timer_container_of) /* Linux v6.16 */ + timer_container_of(pdev_data, t, timer); +#else + from_timer(pdev_data, t, timer); +#endif /* get timestamps for this event */ nvpps_get_ts(pdev_data, 0); diff --git a/drivers/tty/serial/wch_35x/wch_serial.c b/drivers/tty/serial/wch_35x/wch_serial.c index fb0cac2f..b868f255 100644 --- a/drivers/tty/serial/wch_35x/wch_serial.c +++ b/drivers/tty/serial/wch_35x/wch_serial.c @@ -2114,7 +2114,12 @@ static void wch_ser_set_termios(struct ser_port *port, struct WCHTERMIOS *termio static void wch_ser_timeout(struct timer_list *t) { +#if defined(timer_container_of) /* Linux v6.16 */ + struct wch_ser_port *sp = timer_container_of(sp, t, timer); +#else struct wch_ser_port *sp = from_timer(sp, t, timer); +#endif + unsigned int timeout; unsigned int iir; iir = READ_UART_IIR(sp); diff --git a/drivers/watchdog/softdog-platform.c b/drivers/watchdog/softdog-platform.c index 22f5191b..f7234c36 100644 --- a/drivers/watchdog/softdog-platform.c +++ b/drivers/watchdog/softdog-platform.c @@ -37,7 +37,11 @@ struct softdog_platform_wdt { /* If the timer expires.. */ static void softdog_platform_watchdog_fire(struct timer_list *t) { +#if defined(timer_container_of) /* Linux v6.16 */ + struct softdog_platform_wdt *swdt = timer_container_of(swdt, t, watchdog_ticktock); +#else struct softdog_platform_wdt *swdt = from_timer(swdt, t, watchdog_ticktock); +#endif if (swdt->is_stopped) return;