From patchwork Tue Oct 17 00:28:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 826604 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="GFSu9lj0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yGGRw4Szpz9s0Z for ; Tue, 17 Oct 2017 11:35:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933234AbdJQAaI (ORCPT ); Mon, 16 Oct 2017 20:30:08 -0400 Received: from mail-pg0-f53.google.com ([74.125.83.53]:52397 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933190AbdJQAaA (ORCPT ); Mon, 16 Oct 2017 20:30:00 -0400 Received: by mail-pg0-f53.google.com with SMTP id a192so40096pge.9 for ; Mon, 16 Oct 2017 17:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MuDYGpJo7AwrP9QwegkgvcWKZkRcArpQtMtHfAbK4hg=; b=GFSu9lj00NgwMGhnjG+3rvyP09pzAix8MZtokTn8QCYIQQG4LUbDduQd2gtu2IU93S 4B3+pKJGK9Kqs8b08UImGQk0NgQuEyU218tj3E7lFh8ivnYTi8zYYJ4Jt0rwyGhtZoz0 il1Et5hFvuDi7cUrJ3hESOtqbCpyWmuLN3kaU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MuDYGpJo7AwrP9QwegkgvcWKZkRcArpQtMtHfAbK4hg=; b=sVW4YkFKtQPQPYKDgSyLaf2YfZrb4TUwm9ez6wk+9+5XIgmNdGiww//41JoWlxkRds k02QSDwB0RyTnHAaKAFCJblrY87ptnOjjKHxRhiAC+dHda/HV/mj5a/paIezn0QSg+8f cBtpVBAe7UHVzhuCJiw+btecdrl7e4OwNz/Ri56T15chQfz1UopxQrsooecnWPAgGgRt L8OHwjWVKH8MC/d1RXPV/aCNlS6Ydx9vo9DWPUmtiFOuvyxi8K9hfKnRgmuEJn8LA5BT 98GNud0LL9dC0Cu8YGNU0ZMIbhmEkmno0456whfWWxWtZ0wSfk3BcU+oxs/juP4XnTW8 99lA== X-Gm-Message-State: AMCzsaUgqHBXbe5mHli6Eb6Df6zbX2VaMheXel2HJZFJqCUxj0gBr4V2 BJt3kfx1PtIICLps8NQuwmWTmQ== X-Google-Smtp-Source: AOwi7QAthYie5Np5jbAFSBHEDhCV+3c6kwxpjd1wTlwTWeWlTMveapq2VnGG4acoLdp6vGTM1pmdfA== X-Received: by 10.159.252.194 with SMTP id o2mr9269796pls.8.1508200200260; Mon, 16 Oct 2017 17:30:00 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id s87sm2122067pfi.23.2017.10.16.17.29.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 17:29:57 -0700 (PDT) From: Kees Cook To: "David S. Miller" Cc: Kees Cook , Samuel Chessman , netdev@vger.kernel.org, Thomas Gleixner , linux-kernel@vger.kernel.org Subject: [PATCH 06/58] net/ti/tlan: Convert timers to use timer_setup() Date: Mon, 16 Oct 2017 17:28:50 -0700 Message-Id: <1508200182-104605-7-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1508200182-104605-1-git-send-email-keescook@chromium.org> References: <1508200182-104605-1-git-send-email-keescook@chromium.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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: Samuel Chessman Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- drivers/net/ethernet/ti/tlan.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c index c8d53d8c83ee..8f53d762fbc4 100644 --- a/drivers/net/ethernet/ti/tlan.c +++ b/drivers/net/ethernet/ti/tlan.c @@ -172,7 +172,8 @@ static u32 tlan_handle_tx_eoc(struct net_device *, u16); static u32 tlan_handle_status_check(struct net_device *, u16); static u32 tlan_handle_rx_eoc(struct net_device *, u16); -static void tlan_timer(unsigned long); +static void tlan_timer(struct timer_list *t); +static void tlan_phy_monitor(struct timer_list *t); static void tlan_reset_lists(struct net_device *); static void tlan_free_lists(struct net_device *); @@ -190,7 +191,6 @@ static void tlan_phy_power_up(struct net_device *); static void tlan_phy_reset(struct net_device *); static void tlan_phy_start_link(struct net_device *); static void tlan_phy_finish_auto_neg(struct net_device *); -static void tlan_phy_monitor(unsigned long); /* static int tlan_phy_nop(struct net_device *); @@ -254,11 +254,10 @@ tlan_set_timer(struct net_device *dev, u32 ticks, u32 type) spin_unlock_irqrestore(&priv->lock, flags); return; } - priv->timer.function = tlan_timer; + priv->timer.function = (TIMER_FUNC_TYPE)tlan_timer; if (!in_irq()) spin_unlock_irqrestore(&priv->lock, flags); - priv->timer.data = (unsigned long) dev; priv->timer_set_at = jiffies; priv->timer_type = type; mod_timer(&priv->timer, jiffies + ticks); @@ -926,8 +925,8 @@ static int tlan_open(struct net_device *dev) return err; } - init_timer(&priv->timer); - init_timer(&priv->media_timer); + timer_setup(&priv->timer, NULL, 0); + timer_setup(&priv->media_timer, tlan_phy_monitor, 0); tlan_start(dev); @@ -1426,8 +1425,7 @@ static u32 tlan_handle_tx_eof(struct net_device *dev, u16 host_int) tlan_dio_write8(dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK | TLAN_LED_ACT); if (priv->timer.function == NULL) { - priv->timer.function = tlan_timer; - priv->timer.data = (unsigned long) dev; + priv->timer.function = (TIMER_FUNC_TYPE)tlan_timer; priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY; priv->timer_set_at = jiffies; priv->timer_type = TLAN_TIMER_ACTIVITY; @@ -1578,8 +1576,7 @@ static u32 tlan_handle_rx_eof(struct net_device *dev, u16 host_int) tlan_dio_write8(dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK | TLAN_LED_ACT); if (priv->timer.function == NULL) { - priv->timer.function = tlan_timer; - priv->timer.data = (unsigned long) dev; + priv->timer.function = (TIMER_FUNC_TYPE)tlan_timer; priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY; priv->timer_set_at = jiffies; priv->timer_type = TLAN_TIMER_ACTIVITY; @@ -1836,10 +1833,10 @@ ThunderLAN driver timer function * **************************************************************/ -static void tlan_timer(unsigned long data) +static void tlan_timer(struct timer_list *t) { - struct net_device *dev = (struct net_device *) data; - struct tlan_priv *priv = netdev_priv(dev); + struct tlan_priv *priv = from_timer(priv, t, timer); + struct net_device *dev = priv->dev; u32 elapsed; unsigned long flags = 0; @@ -1872,7 +1869,6 @@ static void tlan_timer(unsigned long data) tlan_dio_write8(dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK); } else { - priv->timer.function = tlan_timer; priv->timer.expires = priv->timer_set_at + TLAN_TIMER_ACT_DELAY; spin_unlock_irqrestore(&priv->lock, flags); @@ -2317,8 +2313,6 @@ tlan_finish_reset(struct net_device *dev) } else netdev_info(dev, "Link active\n"); /* Enabling link beat monitoring */ - priv->media_timer.function = tlan_phy_monitor; - priv->media_timer.data = (unsigned long) dev; priv->media_timer.expires = jiffies + HZ; add_timer(&priv->media_timer); } @@ -2763,10 +2757,10 @@ static void tlan_phy_finish_auto_neg(struct net_device *dev) * *******************************************************************/ -static void tlan_phy_monitor(unsigned long data) +static void tlan_phy_monitor(struct timer_list *t) { - struct net_device *dev = (struct net_device *) data; - struct tlan_priv *priv = netdev_priv(dev); + struct tlan_priv *priv = from_timer(priv, t, media_timer); + struct net_device *dev = priv->dev; u16 phy; u16 phy_status;