Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: ethernet/sfc: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Solarflare linux maintainers <linux-net-drivers@solarflare.com>
Cc: Edward Cree <ecree@solarflare.com>
Cc: Bert Kenward <bkenward@solarflare.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Bert Kenward <bkenward@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Kees Cook and committed by
David S. Miller
7aa1402e fc8bcaa0

+22 -24
+2 -4
drivers/net/ethernet/sfc/efx.c
··· 471 471 472 472 rx_queue = &channel->rx_queue; 473 473 rx_queue->efx = efx; 474 - setup_timer(&rx_queue->slow_fill, efx_rx_slow_fill, 475 - (unsigned long)rx_queue); 474 + timer_setup(&rx_queue->slow_fill, efx_rx_slow_fill, 0); 476 475 477 476 return channel; 478 477 } ··· 510 511 rx_queue = &channel->rx_queue; 511 512 rx_queue->buffer = NULL; 512 513 memset(&rx_queue->rxd, 0, sizeof(rx_queue->rxd)); 513 - setup_timer(&rx_queue->slow_fill, efx_rx_slow_fill, 514 - (unsigned long)rx_queue); 514 + timer_setup(&rx_queue->slow_fill, efx_rx_slow_fill, 0); 515 515 516 516 return channel; 517 517 }
+1 -1
drivers/net/ethernet/sfc/efx.h
··· 46 46 void efx_init_rx_queue(struct efx_rx_queue *rx_queue); 47 47 void efx_fini_rx_queue(struct efx_rx_queue *rx_queue); 48 48 void efx_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue, bool atomic); 49 - void efx_rx_slow_fill(unsigned long context); 49 + void efx_rx_slow_fill(struct timer_list *t); 50 50 void __efx_rx_packet(struct efx_channel *channel); 51 51 void efx_rx_packet(struct efx_rx_queue *rx_queue, unsigned int index, 52 52 unsigned int n_frags, unsigned int len, u16 flags);
+2 -4
drivers/net/ethernet/sfc/falcon/efx.c
··· 449 449 450 450 rx_queue = &channel->rx_queue; 451 451 rx_queue->efx = efx; 452 - setup_timer(&rx_queue->slow_fill, ef4_rx_slow_fill, 453 - (unsigned long)rx_queue); 452 + timer_setup(&rx_queue->slow_fill, ef4_rx_slow_fill, 0); 454 453 455 454 return channel; 456 455 } ··· 488 489 rx_queue = &channel->rx_queue; 489 490 rx_queue->buffer = NULL; 490 491 memset(&rx_queue->rxd, 0, sizeof(rx_queue->rxd)); 491 - setup_timer(&rx_queue->slow_fill, ef4_rx_slow_fill, 492 - (unsigned long)rx_queue); 492 + timer_setup(&rx_queue->slow_fill, ef4_rx_slow_fill, 0); 493 493 494 494 return channel; 495 495 }
+1 -1
drivers/net/ethernet/sfc/falcon/efx.h
··· 45 45 void ef4_init_rx_queue(struct ef4_rx_queue *rx_queue); 46 46 void ef4_fini_rx_queue(struct ef4_rx_queue *rx_queue); 47 47 void ef4_fast_push_rx_descriptors(struct ef4_rx_queue *rx_queue, bool atomic); 48 - void ef4_rx_slow_fill(unsigned long context); 48 + void ef4_rx_slow_fill(struct timer_list *t); 49 49 void __ef4_rx_packet(struct ef4_channel *channel); 50 50 void ef4_rx_packet(struct ef4_rx_queue *rx_queue, unsigned int index, 51 51 unsigned int n_frags, unsigned int len, u16 flags);
+6 -5
drivers/net/ethernet/sfc/falcon/falcon.c
··· 1454 1454 } 1455 1455 } 1456 1456 1457 - static void falcon_stats_timer_func(unsigned long context) 1457 + static void falcon_stats_timer_func(struct timer_list *t) 1458 1458 { 1459 - struct ef4_nic *efx = (struct ef4_nic *)context; 1460 - struct falcon_nic_data *nic_data = efx->nic_data; 1459 + struct falcon_nic_data *nic_data = from_timer(nic_data, t, 1460 + stats_timer); 1461 + struct ef4_nic *efx = nic_data->efx; 1461 1462 1462 1463 spin_lock(&efx->stats_lock); 1463 1464 ··· 2296 2295 if (!nic_data) 2297 2296 return -ENOMEM; 2298 2297 efx->nic_data = nic_data; 2298 + nic_data->efx = efx; 2299 2299 2300 2300 rc = -ENODEV; 2301 2301 ··· 2404 2402 } 2405 2403 2406 2404 nic_data->stats_disable_count = 1; 2407 - setup_timer(&nic_data->stats_timer, &falcon_stats_timer_func, 2408 - (unsigned long)efx); 2405 + timer_setup(&nic_data->stats_timer, falcon_stats_timer_func, 0); 2409 2406 2410 2407 return 0; 2411 2408
+2
drivers/net/ethernet/sfc/falcon/nic.h
··· 267 267 /** 268 268 * struct falcon_nic_data - Falcon NIC state 269 269 * @pci_dev2: Secondary function of Falcon A 270 + * @efx: ef4_nic pointer 270 271 * @board: Board state and functions 271 272 * @stats: Hardware statistics 272 273 * @stats_disable_count: Nest count for disabling statistics fetches ··· 281 280 */ 282 281 struct falcon_nic_data { 283 282 struct pci_dev *pci_dev2; 283 + struct ef4_nic *efx; 284 284 struct falcon_board board; 285 285 u64 stats[FALCON_STAT_COUNT]; 286 286 unsigned int stats_disable_count;
+2 -2
drivers/net/ethernet/sfc/falcon/rx.c
··· 376 376 ef4_nic_notify_rx_desc(rx_queue); 377 377 } 378 378 379 - void ef4_rx_slow_fill(unsigned long context) 379 + void ef4_rx_slow_fill(struct timer_list *t) 380 380 { 381 - struct ef4_rx_queue *rx_queue = (struct ef4_rx_queue *)context; 381 + struct ef4_rx_queue *rx_queue = from_timer(rx_queue, t, slow_fill); 382 382 383 383 /* Post an event to cause NAPI to run and refill the queue */ 384 384 ef4_nic_generate_fill_event(rx_queue);
+4 -5
drivers/net/ethernet/sfc/mcdi.c
··· 48 48 /* followed by request/response buffer */ 49 49 }; 50 50 51 - static void efx_mcdi_timeout_async(unsigned long context); 51 + static void efx_mcdi_timeout_async(struct timer_list *t); 52 52 static int efx_mcdi_drv_attach(struct efx_nic *efx, bool driver_operating, 53 53 bool *was_attached_out); 54 54 static bool efx_mcdi_poll_once(struct efx_nic *efx); ··· 87 87 mcdi->mode = MCDI_MODE_POLL; 88 88 spin_lock_init(&mcdi->async_lock); 89 89 INIT_LIST_HEAD(&mcdi->async_list); 90 - setup_timer(&mcdi->async_timer, efx_mcdi_timeout_async, 91 - (unsigned long)mcdi); 90 + timer_setup(&mcdi->async_timer, efx_mcdi_timeout_async, 0); 92 91 93 92 (void) efx_mcdi_poll_reboot(efx); 94 93 mcdi->new_epoch = true; ··· 607 608 } 608 609 } 609 610 610 - static void efx_mcdi_timeout_async(unsigned long context) 611 + static void efx_mcdi_timeout_async(struct timer_list *t) 611 612 { 612 - struct efx_mcdi_iface *mcdi = (struct efx_mcdi_iface *)context; 613 + struct efx_mcdi_iface *mcdi = from_timer(mcdi, t, async_timer); 613 614 614 615 efx_mcdi_complete_async(mcdi, true); 615 616 }
+2 -2
drivers/net/ethernet/sfc/rx.c
··· 376 376 efx_nic_notify_rx_desc(rx_queue); 377 377 } 378 378 379 - void efx_rx_slow_fill(unsigned long context) 379 + void efx_rx_slow_fill(struct timer_list *t) 380 380 { 381 - struct efx_rx_queue *rx_queue = (struct efx_rx_queue *)context; 381 + struct efx_rx_queue *rx_queue = from_timer(rx_queue, t, slow_fill); 382 382 383 383 /* Post an event to cause NAPI to run and refill the queue */ 384 384 efx_nic_generate_fill_event(rx_queue);