From patchwork Tue Oct 17 00:28:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10010379 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 274AF600CC for ; Tue, 17 Oct 2017 00:30:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1696D286D7 for ; Tue, 17 Oct 2017 00:30:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 09A8D28717; Tue, 17 Oct 2017 00:30:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 71476286D7 for ; Tue, 17 Oct 2017 00:30:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=EssO1I5nPv3qSeFJ6b5pxVzNjkkagb4MYxY3jC9vUUk=; b=Y8RBdeMR/jUjf0eRTrLS3w0TJ1 RdScdmZXHZl3QpHZdrnGmckcRZIs5m7KQ+9fefM18AxBdoMddGGr2tGa8EOuygP29WWBCMTifoGbm wPghvbgMpmHTvUINvCCi0Av/15py35XF2iBrF4CsKd/qWcVKudAo+3flgTgMP0LVaTUxH88+brXYJ wMqqZwPt/OwfxhltbJkhW1rtWttDcT6wtMDAafAHD8QC6rYSzZdA1X8zX0VDxIG+8jVpc+pDeY3e9 z41fxskQQADexCDvzZU6jVjIjn4NccYsOVK4RwCrKKHymMFf0VOrwuJpsqlPN/EcEzoF+uj4QMtJm xWGnoEZg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e4Fm8-0005ul-Eo; Tue, 17 Oct 2017 00:30:28 +0000 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e4Fm3-0004zE-OP for linux-arm-kernel@lists.infradead.org; Tue, 17 Oct 2017 00:30:26 +0000 Received: by mail-pf0-x231.google.com with SMTP id p87so49723pfj.3 for ; Mon, 16 Oct 2017 17:30:07 -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=Q5tBbAPZ8ChkSmgG23lGB7KTk9tjMKltno2ermrLBV4=; b=Pl8kntO850PjtmClE8MgT6xkscay0MTz3r/635TB95MZJDndm6ja0Apd9YGMqCaMZz NDRxI1KC/vf0blVcl7lIM+KQjSrnn0KAmDmAzXL3MCWoXRYECSEG8ZCRerf8vq9cucJG 4w9b6uO1nl6aIfvh2mYS8XPXCbFiyoGVTkCok= 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=Q5tBbAPZ8ChkSmgG23lGB7KTk9tjMKltno2ermrLBV4=; b=TK3Irshweyq4EdtA8wo/1yrM0IA6+2LKDyHtgeJPGYhP8Z7lXOJFK8hHjFPpnHKSoj aqeFK6Fihmc5eLJNRBWGGexnhigqZNSvN6fSAkq5Kbtg3D8ILdzdqr3R97XMhHn/+vyq Io1lNhdvsD/Zdd/iKPo1BPfXWUFOV//upxkG0G3mUlpsNn13BkBe1ADoBjw2W5QZd1rr ESZD4wKpS9Mv2aJMXGFUXe/VSiNKByv3sulm0qE6xJs/p9TI6ZKfpJUikQpGWeiCT9i/ 3n+Ju8ol2QMmOrkWeyBkh7ZG1E0L8p3VaYQVMq8KO7yHkqpy3dw5uY3MkgQ8rn9Vrarw +3oQ== X-Gm-Message-State: AMCzsaVGKls/kE2ikPyx6pPnMrO28rBHDml3BIrjFSbDEsrehfZDtipU zkpcy4wFteeX8MUarN5Gv74ubifv5n0= X-Google-Smtp-Source: AOwi7QBuTzytDbSoiERKUR+xDpZaenSd2taMTVXnhehKfN8dYqF0+F/7LYzsRNQuoG4SK1bxaCZeiA== X-Received: by 10.159.255.5 with SMTP id bi5mr10621261plb.437.1508200206818; Mon, 16 Oct 2017 17:30:06 -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 c22sm17790311pfe.177.2017.10.16.17.29.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Oct 2017 17:30:04 -0700 (PDT) From: Kees Cook To: "David S. Miller" Subject: [PATCH 13/58] ethernet/broadcom: Convert timers to use timer_setup() Date: Mon, 16 Oct 2017 17:28:57 -0700 Message-Id: <1508200182-104605-14-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171016_173023_918245_E9323C24 X-CRM114-Status: GOOD ( 13.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Florian Fainelli , Kees Cook , Arnd Bergmann , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jarod Wilson , bcm-kernel-feedback-list@broadcom.com, Thomas Gleixner , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In preparation for unconditionally passing the struct timer_list pointer to all timer callbacks, switch to using the new timer_setup() and from_timer() helper to pass the timer pointer explicitly. Cc: Florian Fainelli Cc: bcm-kernel-feedback-list@broadcom.com Cc: "David S. Miller" Cc: Arnd Bergmann Cc: Jarod Wilson Cc: netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Kees Cook --- drivers/net/ethernet/broadcom/bcm63xx_enet.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c index f6bc13fe8a99..d9346e2ac720 100644 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c @@ -295,16 +295,13 @@ static int bcm_enet_refill_rx(struct net_device *dev) /* * timer callback to defer refill rx queue in case we're OOM */ -static void bcm_enet_refill_rx_timer(unsigned long data) +static void bcm_enet_refill_rx_timer(struct timer_list *t) { - struct net_device *dev; - struct bcm_enet_priv *priv; - - dev = (struct net_device *)data; - priv = netdev_priv(dev); + struct bcm_enet_priv *priv = from_timer(priv, t, rx_timeout); + struct net_device *dev = priv->net_dev; spin_lock(&priv->rx_lock); - bcm_enet_refill_rx((struct net_device *)data); + bcm_enet_refill_rx(dev); spin_unlock(&priv->rx_lock); } @@ -1860,8 +1857,7 @@ static int bcm_enet_probe(struct platform_device *pdev) spin_lock_init(&priv->rx_lock); /* init rx timeout (used for oom) */ - setup_timer(&priv->rx_timeout, bcm_enet_refill_rx_timer, - (unsigned long)dev); + timer_setup(&priv->rx_timeout, bcm_enet_refill_rx_timer, 0); /* init the mib update lock&work */ mutex_init(&priv->mib_update_lock); @@ -2015,9 +2011,9 @@ static inline int bcm_enet_port_is_rgmii(int portid) /* * enet sw PHY polling */ -static void swphy_poll_timer(unsigned long data) +static void swphy_poll_timer(struct timer_list *t) { - struct bcm_enet_priv *priv = (struct bcm_enet_priv *)data; + struct bcm_enet_priv *priv = from_timer(priv, t, swphy_poll); unsigned int i; for (i = 0; i < priv->num_ports; i++) { @@ -2326,7 +2322,7 @@ static int bcm_enetsw_open(struct net_device *dev) } /* start phy polling timer */ - setup_timer(&priv->swphy_poll, swphy_poll_timer, (unsigned long)priv); + timer_setup(&priv->swphy_poll, swphy_poll_timer, 0); mod_timer(&priv->swphy_poll, jiffies); return 0; @@ -2743,9 +2739,7 @@ static int bcm_enetsw_probe(struct platform_device *pdev) spin_lock_init(&priv->rx_lock); /* init rx timeout (used for oom) */ - init_timer(&priv->rx_timeout); - priv->rx_timeout.function = bcm_enet_refill_rx_timer; - priv->rx_timeout.data = (unsigned long)dev; + timer_setup(&priv->rx_timeout, bcm_enet_refill_rx_timer, 0); /* register netdevice */ dev->netdev_ops = &bcm_enetsw_ops;