From cd1ed09ac6a6f3de1dcf08fb58ff2346f4f04472 Mon Sep 17 00:00:00 2001 From: Aaron Taylor Date: Fri, 30 Apr 2021 01:10:49 -0700 Subject: [PATCH] Updated host/uos_download.c to use new timer API introduced in Linux 4.14.0. See also: - https://lwn.net/Articles/735887/ - https://stackoverflow.com/questions/53839625 --- host/uos_download.c | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/host/uos_download.c b/host/uos_download.c index 6a323c7..c01b393 100644 --- a/host/uos_download.c +++ b/host/uos_download.c @@ -812,9 +812,9 @@ exit: /* Perform hardware reset of the device */ void -reset_timer(unsigned long arg) +reset_timer(struct timer_list *arg) { - mic_ctx_t *mic_ctx = (mic_ctx_t *)arg; + mic_ctx_t *mic_ctx = from_timer(mic_ctx, arg, boot_timer); uint32_t scratch2 = 0; uint32_t postcode = mic_getpostcode(mic_ctx); @@ -865,22 +865,16 @@ reset_timer(unsigned long arg) return; } - mic_ctx->boot_timer.function = reset_timer; - mic_ctx->boot_timer.data = (unsigned long)mic_ctx; mic_ctx->boot_timer.expires = jiffies + HZ; - - add_timer(&mic_ctx->boot_timer); + timer_setup(&mic_ctx->boot_timer, reset_timer, 0); } void adapter_wait_reset(mic_ctx_t *mic_ctx) { - mic_ctx->boot_timer.function = reset_timer; - mic_ctx->boot_timer.data = (unsigned long)mic_ctx; mic_ctx->boot_timer.expires = jiffies + HZ; mic_ctx->boot_start = jiffies; - - add_timer(&mic_ctx->boot_timer); + timer_setup(&mic_ctx->boot_timer, reset_timer, 0); } void @@ -1051,9 +1045,9 @@ adapter_remove(mic_ctx_t *mic_ctx) #define MIC_MAX_BOOT_TIME 180 // Maximum number of seconds to wait for boot to complete static void -online_timer(unsigned long arg) +online_timer(struct timer_list *arg) { - mic_ctx_t *mic_ctx = (mic_ctx_t *)arg; + mic_ctx_t *mic_ctx = from_timer(mic_ctx, arg, boot_timer); uint64_t delay = (jiffies - mic_ctx->boot_start) / HZ; if (mic_ctx->state == MIC_ONLINE) @@ -1065,19 +1059,17 @@ online_timer(unsigned long arg) return; } - mic_ctx->boot_timer.function = online_timer; - mic_ctx->boot_timer.data = (unsigned long)mic_ctx; mic_ctx->boot_timer.expires = jiffies + HZ; - add_timer(&mic_ctx->boot_timer); + timer_setup(&mic_ctx->boot_timer, online_timer, 0); if (!(delay % 5)) printk("Waiting for MIC %d boot %lld\n", mic_ctx->bi_id, delay); } static void -boot_timer(unsigned long arg) +boot_timer(struct timer_list *arg) { - mic_ctx_t *mic_ctx = (mic_ctx_t *)arg; + mic_ctx_t *mic_ctx = from_timer(mic_ctx, arg, boot_timer); struct micvnet_info *vnet_info = (struct micvnet_info *) mic_ctx->bi_vethinfo; uint64_t delay = (jiffies - mic_ctx->boot_start) / HZ; bool timer_restart = false; @@ -1102,18 +1094,13 @@ boot_timer(unsigned long arg) timer_restart = (mic_ctx->state != MIC_ONLINE)? true: false; if (timer_restart) { - mic_ctx->boot_timer.function = boot_timer; - mic_ctx->boot_timer.data = (unsigned long)mic_ctx; mic_ctx->boot_timer.expires = jiffies + HZ; - - add_timer(&mic_ctx->boot_timer); + timer_setup(&mic_ctx->boot_timer, boot_timer, 0); return; } - mic_ctx->boot_timer.function = online_timer; - mic_ctx->boot_timer.data = (unsigned long)mic_ctx; mic_ctx->boot_timer.expires = jiffies + HZ; - add_timer(&mic_ctx->boot_timer); + timer_setup(&mic_ctx->boot_timer, online_timer, 0); printk("MIC %d Network link is up\n", mic_ctx->bi_id); schedule_work(&mic_ctx->boot_ws); @@ -1166,12 +1153,9 @@ ioremap_work(struct work_struct *work) int adapter_post_boot_device(mic_ctx_t *mic_ctx) { - mic_ctx->boot_timer.function = boot_timer; - mic_ctx->boot_timer.data = (unsigned long)mic_ctx; mic_ctx->boot_timer.expires = jiffies + HZ; mic_ctx->boot_start = jiffies; - - add_timer(&mic_ctx->boot_timer); + timer_setup(&mic_ctx->boot_timer, boot_timer, 0); return 0; } @@ -1497,7 +1481,6 @@ adapter_init_device(mic_ctx_t *mic_ctx) mutex_init (&mic_ctx->state_lock); init_waitqueue_head(&mic_ctx->resetwq); init_waitqueue_head(&mic_ctx->ioremapwq); - init_timer(&mic_ctx->boot_timer); if (!(mic_ctx->resetworkq = __mic_create_singlethread_workqueue("RESET WORK"))) return -ENOMEM; if (!(mic_ctx->ioremapworkq = __mic_create_singlethread_workqueue("IOREMAP_WORK"))) { -- 2.20.1