From patchwork Thu Oct 5 00:50:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9986119 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 C40BE60291 for ; Thu, 5 Oct 2017 00:51:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3B2428C1A for ; Thu, 5 Oct 2017 00:51:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A858C28C41; Thu, 5 Oct 2017 00:51:19 +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=unavailable 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 66DEE28C1A for ; Thu, 5 Oct 2017 00:51:17 +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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Subject:To:From :Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=VVHIBFnBxfu08Gwm4tdUbIztmapqZcaM9UwYh6JdjD4=; b=aaUovcC11isF5Q OpYN3UKoNE0X+q4KhYa55iquay1pRSsRnqAJayHpM6ceAD7zXAqWJtWxHt1yPGcp+LCioT635RyR4 8f4uskwXz5dzZgcOtWMnWGaHff0Nagd98DiiMwSaa3tjIFxlKcdmpe+cxII2tXUaiE5rPQ5fDLSu4 HvBv5oTViymArZpN6p7EVyP0c6eZWcSw8eo0m4rEgi8LR/1cBCzDHMzkI9kWLSaCtRVCpMj7EyKd0 PXv4envJsnF4exPFjmBfOqOgvW5OdeC/GqSfdmnplE/ggZvJ91wvON2SWaw/aBmjl4uA2VpPJhzDd kRLJxg6R2xPjrUJ9xOJw==; 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 1dzuNa-0007oe-AG; Thu, 05 Oct 2017 00:51:10 +0000 Received: from mail-pf0-x233.google.com ([2607:f8b0:400e:c00::233]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dzuNW-0007hT-LF for linux-arm-kernel@lists.infradead.org; Thu, 05 Oct 2017 00:51:08 +0000 Received: by mail-pf0-x233.google.com with SMTP id r68so7130492pfj.3 for ; Wed, 04 Oct 2017 17:50:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=6Qkq6RW0VYgJklfACKtByt33ByrEz97uT6ih44NPjb4=; b=aryu0wi38H/MqU7Wcwj5kG60VuBzW+GEV50lVFOHdRdx0p9XIGrMsS5nAcGojNzZ84 5Eoz3QbzuoZEqXFznYCwSu1qJztaZ1Vd1TFXIVbq1W1JMaZu/fL3z6Ihb2yuOGVllTQV 0W7dg5YCxYve1c7xEfHuNiOSHKFmIZcJhKIjM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=6Qkq6RW0VYgJklfACKtByt33ByrEz97uT6ih44NPjb4=; b=lb5ROLa+2vlAcdNXdxVgilme+7CoIzy6pYHlBBW5Z2byvYB1phlYwx/mAZsKAUUL6J zcMEV0qPRYJaRlxSHalLsVa7DxwBDMc7468vbYg+6lZX62qxdrbuMdtII5IEBXjMmPwI SyYnjxgGTKtM91KiCmtWoYitQwtgbP82rSbiOIffk4Cos1peDywGHrFrTeVSVYl4R4eZ szaJKc9dhP6zgx5WBfxi/aMSYjEeArCze3uqc9Vhnjc29pz23TUkhRyle2VGcRAXu6j6 jPzgMNNLoUyqqTldWS3QJyHEEX9vH31e5u7xdpUK4XYdMOZMDbR1qe1bfXrEA5cQ3IPx MUjA== X-Gm-Message-State: AHPjjUjYFjUolxoM4mNbnHsrtX+wEL9zpIkVbnc2JegWg+m/mJBp4Ewz JZdgsmcpmX+Et4slSHQ9j7ruEg== X-Google-Smtp-Source: AOwi7QDS2lahbbqZGqRmKzQDh9mjX0lqpra0En3ne6jVglbb18F1pRukaKs8R37Mqz/5eDwNkyF86w== X-Received: by 10.84.194.1 with SMTP id g1mr21346833pld.74.1507164645303; Wed, 04 Oct 2017 17:50:45 -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 g5sm28187478pfe.94.2017.10.04.17.50.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Oct 2017 17:50:44 -0700 (PDT) Date: Wed, 4 Oct 2017 17:50:43 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Subject: [PATCH] ethernet/broadcom: Convert timers to use timer_setup() Message-ID: <20171005005043.GA23290@beast> MIME-Version: 1.0 Content-Disposition: inline X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171004_175106_745012_680F76D5 X-CRM114-Status: GOOD ( 14.17 ) 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 , Arnd Bergmann , netdev@vger.kernel.org, Jarod Wilson , bcm-kernel-feedback-list@broadcom.com, Thomas Gleixner , "David S. Miller" , linux-arm-kernel@lists.infradead.org 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 Cc: Thomas Gleixner Signed-off-by: Kees Cook --- This requires commit 686fef928bba ("timer: Prepare to change timer callback argument type") in v4.14-rc3, but should be otherwise stand-alone. --- drivers/net/ethernet/broadcom/bcm63xx_enet.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c index 4f3845a58126..99c2270d4677 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); } @@ -1857,9 +1854,7 @@ static int bcm_enet_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); /* init the mib update lock&work */ mutex_init(&priv->mib_update_lock); @@ -2021,9 +2016,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++) { @@ -2332,9 +2327,7 @@ static int bcm_enetsw_open(struct net_device *dev) } /* start phy polling timer */ - init_timer(&priv->swphy_poll); - priv->swphy_poll.function = swphy_poll_timer; - priv->swphy_poll.data = (unsigned long)priv; + timer_setup(&priv->swphy_poll, swphy_poll_timer, 0); priv->swphy_poll.expires = jiffies; add_timer(&priv->swphy_poll); return 0; @@ -2759,9 +2752,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;