From patchwork Tue Oct 24 09:29:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10023823 X-Patchwork-Delegate: kvalo@adurom.com 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 76F1660245 for ; Tue, 24 Oct 2017 09:29:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6BF5C289D3 for ; Tue, 24 Oct 2017 09:29:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FCC9289D8; Tue, 24 Oct 2017 09:29:53 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50506289D3 for ; Tue, 24 Oct 2017 09:29:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752077AbdJXJ3k (ORCPT ); Tue, 24 Oct 2017 05:29:40 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:57146 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932362AbdJXJ3b (ORCPT ); Tue, 24 Oct 2017 05:29:31 -0400 Received: by mail-pg0-f65.google.com with SMTP id m18so14040623pgd.13 for ; Tue, 24 Oct 2017 02:29:31 -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=aufwfz8Mm27810lwLBkA0EVH1qq85ZHGtEtJesJA8Bo=; b=KwnxOcCUADotbp6ttGcLBkA/gN+aScJgvwEmAl1bzL76ELqXka1bVfBGtu2l7080AG qcRzyTyWHdWZNZPD8tpcl9z8XAdi2XhSy/EyGJhJUDaMXSOJ8OSNRLOYdWmujR5LDP6u 09cRt2RtN7kN33puamMc/zSoXL/7wAx87MV1s= 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=aufwfz8Mm27810lwLBkA0EVH1qq85ZHGtEtJesJA8Bo=; b=VB7e3Ayyf5tcCoCcM3Wowuz6prFwnt54rmWF0mV+xeEw9/Ulch96iHbYnkFFXMq7Ch Ek9xvMNU8xsi/isrtUTVNcxTBhWEoaYPM4cFRVu3A8KQBb8Emp3LgGCLPSIrrtf3tqFg eaWzg+Oh2qPDp/rsam9tGPqCzUcFUhhR5C2OuhDaGMIlh1FbRiL8RqP07hhgjTeLEGtM sa7cC0I2r3leKhgpm7ugOoA/3dIfz5es0RkXCanxYkw3yeh2jtbciq+EwE7ywjmdGRJy C3FSI9FHvzmg1KQsDz7S5JDyTaJ4BQaCmLZnZth41yHdh/ZhY4eKUWY/H+eGdOuHvFee SlwQ== X-Gm-Message-State: AMCzsaXNHHw+Lb5f2/wSj5YM0MaB2kO8PhXnev7yNdqQC6g3cE0xgYNd ILDHPLBQ2BI025aZ8pDe+hWpzg== X-Google-Smtp-Source: ABhQp+TXJ6Wp6ZhPoBHK6GQv+s6zvxMDHsPYpx6+zYMqtxBJW+F9D1L8zQfMA+XsNX/iDU0IZrQKHw== X-Received: by 10.99.116.76 with SMTP id e12mr13958095pgn.126.1508837370676; Tue, 24 Oct 2017 02:29:30 -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 s71sm17455052pfa.147.2017.10.24.02.29.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Oct 2017 02:29:29 -0700 (PDT) Date: Tue, 24 Oct 2017 02:29:28 -0700 From: Kees Cook To: Kalle Valo Cc: Arvind Yadav , Ingo Molnar , Johannes Berg , "David S. Miller" , Andrew Zaborowski , libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] drivers/wireless: marvell/libertas: Convert timers to use timer_setup() Message-ID: <20171024092928.GA47234@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.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() to pass the timer pointer explicitly. Cc: Kalle Valo Cc: Arvind Yadav Cc: Ingo Molnar Cc: Johannes Berg Cc: "David S. Miller" Cc: Andrew Zaborowski Cc: libertas-dev@lists.infradead.org Cc: linux-wireless@vger.kernel.org Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook --- drivers/net/wireless/marvell/libertas/if_usb.c | 6 +++--- drivers/net/wireless/marvell/libertas/main.c | 21 +++++++++------------ drivers/net/wireless/marvell/libertas_tf/if_usb.c | 6 +++--- drivers/net/wireless/marvell/libertas_tf/main.c | 7 +++---- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/drivers/net/wireless/marvell/libertas/if_usb.c b/drivers/net/wireless/marvell/libertas/if_usb.c index 16e54c757dd0..ffea610f67e2 100644 --- a/drivers/net/wireless/marvell/libertas/if_usb.c +++ b/drivers/net/wireless/marvell/libertas/if_usb.c @@ -161,9 +161,9 @@ static void if_usb_setup_firmware(struct lbs_private *priv) } } -static void if_usb_fw_timeo(unsigned long priv) +static void if_usb_fw_timeo(struct timer_list *t) { - struct if_usb_card *cardp = (void *)priv; + struct if_usb_card *cardp = from_timer(cardp, t, fw_timeout); if (cardp->fwdnldover) { lbs_deb_usb("Download complete, no event. Assuming success\n"); @@ -205,7 +205,7 @@ static int if_usb_probe(struct usb_interface *intf, if (!cardp) goto error; - setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp); + timer_setup(&cardp->fw_timeout, if_usb_fw_timeo, 0); init_waitqueue_head(&cardp->fw_wq); cardp->udev = udev; diff --git a/drivers/net/wireless/marvell/libertas/main.c b/drivers/net/wireless/marvell/libertas/main.c index aefa88f4f29c..f22e1c220cba 100644 --- a/drivers/net/wireless/marvell/libertas/main.c +++ b/drivers/net/wireless/marvell/libertas/main.c @@ -722,9 +722,9 @@ EXPORT_SYMBOL_GPL(lbs_resume); * * @data: &struct lbs_private pointer */ -static void lbs_cmd_timeout_handler(unsigned long data) +static void lbs_cmd_timeout_handler(struct timer_list *t) { - struct lbs_private *priv = (struct lbs_private *)data; + struct lbs_private *priv = from_timer(priv, t, command_timer); unsigned long flags; spin_lock_irqsave(&priv->driver_lock, flags); @@ -756,9 +756,9 @@ static void lbs_cmd_timeout_handler(unsigned long data) * * @data: &struct lbs_private pointer */ -static void lbs_tx_lockup_handler(unsigned long data) +static void lbs_tx_lockup_handler(struct timer_list *t) { - struct lbs_private *priv = (struct lbs_private *)data; + struct lbs_private *priv = from_timer(priv, t, tx_lockup_timer); unsigned long flags; spin_lock_irqsave(&priv->driver_lock, flags); @@ -779,9 +779,9 @@ static void lbs_tx_lockup_handler(unsigned long data) * @data: &struct lbs_private pointer * returns: N/A */ -static void auto_deepsleep_timer_fn(unsigned long data) +static void auto_deepsleep_timer_fn(struct timer_list *t) { - struct lbs_private *priv = (struct lbs_private *)data; + struct lbs_private *priv = from_timer(priv, t, auto_deepsleep_timer); if (priv->is_activity_detected) { priv->is_activity_detected = 0; @@ -847,12 +847,9 @@ static int lbs_init_adapter(struct lbs_private *priv) init_waitqueue_head(&priv->fw_waitq); mutex_init(&priv->lock); - setup_timer(&priv->command_timer, lbs_cmd_timeout_handler, - (unsigned long)priv); - setup_timer(&priv->tx_lockup_timer, lbs_tx_lockup_handler, - (unsigned long)priv); - setup_timer(&priv->auto_deepsleep_timer, auto_deepsleep_timer_fn, - (unsigned long)priv); + timer_setup(&priv->command_timer, lbs_cmd_timeout_handler, 0); + timer_setup(&priv->tx_lockup_timer, lbs_tx_lockup_handler, 0); + timer_setup(&priv->auto_deepsleep_timer, auto_deepsleep_timer_fn, 0); INIT_LIST_HEAD(&priv->cmdfreeq); INIT_LIST_HEAD(&priv->cmdpendingq); diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c b/drivers/net/wireless/marvell/libertas_tf/if_usb.c index e9104eca327b..5153922e7ce1 100644 --- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c +++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c @@ -115,9 +115,9 @@ static void if_usb_setup_firmware(struct lbtf_private *priv) lbtf_deb_leave(LBTF_DEB_USB); } -static void if_usb_fw_timeo(unsigned long priv) +static void if_usb_fw_timeo(struct timer_list *t) { - struct if_usb_card *cardp = (void *)priv; + struct if_usb_card *cardp = from_timer(cardp, t, fw_timeout); lbtf_deb_enter(LBTF_DEB_USB); if (!cardp->fwdnldover) { @@ -156,7 +156,7 @@ static int if_usb_probe(struct usb_interface *intf, if (!cardp) goto error; - setup_timer(&cardp->fw_timeout, if_usb_fw_timeo, (unsigned long)cardp); + timer_setup(&cardp->fw_timeout, if_usb_fw_timeo, 0); init_waitqueue_head(&cardp->fw_wq); cardp->udev = udev; diff --git a/drivers/net/wireless/marvell/libertas_tf/main.c b/drivers/net/wireless/marvell/libertas_tf/main.c index 81228bf73043..1d45da187b9b 100644 --- a/drivers/net/wireless/marvell/libertas_tf/main.c +++ b/drivers/net/wireless/marvell/libertas_tf/main.c @@ -165,9 +165,9 @@ static int lbtf_setup_firmware(struct lbtf_private *priv) * This function handles the timeout of command sending. * It will re-send the same command again. */ -static void command_timer_fn(unsigned long data) +static void command_timer_fn(struct timer_list *t) { - struct lbtf_private *priv = (struct lbtf_private *)data; + struct lbtf_private *priv = from_timer(priv, t, command_timer); unsigned long flags; lbtf_deb_enter(LBTF_DEB_CMD); @@ -196,8 +196,7 @@ static int lbtf_init_adapter(struct lbtf_private *priv) mutex_init(&priv->lock); priv->vif = NULL; - setup_timer(&priv->command_timer, command_timer_fn, - (unsigned long)priv); + timer_setup(&priv->command_timer, command_timer_fn, 0); INIT_LIST_HEAD(&priv->cmdfreeq); INIT_LIST_HEAD(&priv->cmdpendingq);