drivers/net: netronome: Convert timers to use timer_setup()
authorKees Cook <keescook@chromium.org>
Wed, 25 Oct 2017 10:51:38 +0000 (03:51 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Oct 2017 03:09:15 +0000 (12:09 +0900)
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: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Simon Horman <simon.horman@netronome.com>
Cc: oss-drivers@netronome.com
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/bpf/main.c
drivers/net/ethernet/netronome/nfp/bpf/main.h
drivers/net/ethernet/netronome/nfp/bpf/offload.c
drivers/net/ethernet/netronome/nfp/nfp_net_common.c

index fa0ac90ed956c7007f890ec4335cfbf17d1d3872..f15a186f6c871c6872c1a78e1a1212abbd3e1f1e 100644 (file)
@@ -97,8 +97,9 @@ nfp_bpf_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id)
 
        nn->app_priv = priv;
        spin_lock_init(&priv->rx_filter_lock);
-       setup_timer(&priv->rx_filter_stats_timer,
-                   nfp_net_filter_stats_timer, (unsigned long)nn);
+       priv->nn = nn;
+       timer_setup(&priv->rx_filter_stats_timer,
+                   nfp_net_filter_stats_timer, 0);
 
        ret = nfp_app_nic_vnic_alloc(app, nn, id);
        if (ret)
index 86edc0691a5f2846312810fd700d53ce0d4d7cea..bc604030ff6cbac3adacd46c124dcbf63390aa64 100644 (file)
@@ -209,10 +209,11 @@ struct nfp_net_bpf_priv {
        struct nfp_stat_pair rx_filter, rx_filter_prev;
        unsigned long rx_filter_change;
        struct timer_list rx_filter_stats_timer;
+       struct nfp_net *nn;
        spinlock_t rx_filter_lock;
 };
 
 int nfp_net_bpf_offload(struct nfp_net *nn, struct tc_cls_bpf_offload *cls_bpf);
-void nfp_net_filter_stats_timer(unsigned long data);
+void nfp_net_filter_stats_timer(struct timer_list *t);
 
 #endif
index fbca1ca1f39b450cd2b0c91849f028d102c3e17b..63c8f784705448b62228e782453f0b8dba35f8b1 100644 (file)
 #include "../nfp_net_ctrl.h"
 #include "../nfp_net.h"
 
-void nfp_net_filter_stats_timer(unsigned long data)
+void nfp_net_filter_stats_timer(struct timer_list *t)
 {
-       struct nfp_net *nn = (void *)data;
-       struct nfp_net_bpf_priv *priv;
+       struct nfp_net_bpf_priv *priv = from_timer(priv, t,
+                                                  rx_filter_stats_timer);
+       struct nfp_net *nn = priv->nn;
        struct nfp_stat_pair latest;
 
-       priv = nn->app_priv;
-
        spin_lock_bh(&priv->rx_filter_lock);
 
        if (nn->dp.ctrl & NFP_NET_CFG_CTRL_BPF)
index 2c9109b09faf008b56bf0a51f9dc632e598ae93c..eddf850a6a7ff3bcbbcd018c68d7eefe9c8d4b61 100644 (file)
@@ -177,9 +177,9 @@ static int nfp_net_reconfig_wait(struct nfp_net *nn, unsigned long deadline)
        return timed_out ? -EIO : 0;
 }
 
-static void nfp_net_reconfig_timer(unsigned long data)
+static void nfp_net_reconfig_timer(struct timer_list *t)
 {
-       struct nfp_net *nn = (void *)data;
+       struct nfp_net *nn = from_timer(nn, t, reconfig_timer);
 
        spin_lock_bh(&nn->reconfig_lock);
 
@@ -3537,8 +3537,7 @@ struct nfp_net *nfp_net_alloc(struct pci_dev *pdev, bool needs_netdev,
        spin_lock_init(&nn->reconfig_lock);
        spin_lock_init(&nn->link_status_lock);
 
-       setup_timer(&nn->reconfig_timer,
-                   nfp_net_reconfig_timer, (unsigned long)nn);
+       timer_setup(&nn->reconfig_timer, nfp_net_reconfig_timer, 0);
 
        return nn;
 }