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: 826608 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="Pl8kntO8"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yGGSb5VKCz9s0Z for ; Tue, 17 Oct 2017 11:35:43 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758011AbdJQAfa (ORCPT ); Mon, 16 Oct 2017 20:35:30 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:54442 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933219AbdJQAaH (ORCPT ); Mon, 16 Oct 2017 20:30:07 -0400 Received: by mail-pf0-f172.google.com with SMTP id n89so35870pfk.11 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=h4gdaZIxJCzL228k55LcxgYPrLW612nTIDm9sQfEX0v6NWgchfoIDdblCU45Pxrkyf VqbTRuqD9V/YgO8msCY6DSHlWgD8X3abZ7MBdGHT4OsZOi4Slt8Kp3quZKUNRk21WROm esmhklB4bsQnGqMwr6EI/VWhT29j6KOdvPpVVEHw6Mb13ADJupaTujHnYKnPVQoGPSwu BB9lQ85NveUe0Vx6SCN11TiYfDz8Nimmn7Ia2GmAfGgo01u62h/sI9/eE7LE5Dhgy8X3 bon5OoYcN8BmLsLu0ZaGuQp1zihVfAvJzeFUI0idoK/Ch/T+pNhtMZGV1lODplVd97Gu ECVQ== X-Gm-Message-State: AMCzsaV6bJLAtExW+Uf0CRaBiUKa/DIw7yP/zP7w1eAJJ2xyd8i+vdxy 4EZVlySNHRFC8HcdhGFdVoP1pQ== 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" Cc: Kees Cook , Florian Fainelli , bcm-kernel-feedback-list@broadcom.com, Arnd Bergmann , Jarod Wilson , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Thomas Gleixner , linux-kernel@vger.kernel.org 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> 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() 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;