From patchwork Tue Sep 29 20:25:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 259905 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E1594C531DF for ; Tue, 29 Sep 2020 20:39:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75A692074B for ; Tue, 29 Sep 2020 20:39:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="qK17a97Z"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="EUeUbwhh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729409AbgI2Uiz (ORCPT ); Tue, 29 Sep 2020 16:38:55 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:49846 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729494AbgI2UgI (ORCPT ); Tue, 29 Sep 2020 16:36:08 -0400 Message-Id: <20200929203501.588965483@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1601411765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=dtHtqsW00jC3rvu4LwKJmi9HFJLwcM5f6nIlhACuykk=; b=qK17a97Zs/lhHavAuw0FxEuT6GcoNA9eJJBSapPJ/Ays8X1DAHg2fZRQ3CzzzCUoINALyq 1TYfi3v+F2BUVpxrxM+rqHymNLvRL6ew2wSpm7qYKLDLj/GoP7uOuX9DVBQr6o0GOtHP7Z DZGwJEjaPX1a/8NXiU2A2BJVugN98OlGI5tsIgrLJhd/uPeYj0Dp757mxAMTfYZDgiiQoj h9dfs/vBd3Y+GHa+L8+1gLmTXP6WHfDoxNrfHerwf7dREoWOkFLxoEYpDIZ0LPW2IL/nx4 mBRhWsH8NbTZtRi2jDQszw9qV0IMwYFWIAeNc2BzG8VIQPF+7EOqsfk7GGAX5Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1601411765; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=dtHtqsW00jC3rvu4LwKJmi9HFJLwcM5f6nIlhACuykk=; b=EUeUbwhhkC1Ee5Dx9iTKNml9PWGe5S+zIsfu8+sMcU2oxcieXDsDlyv1Ks+HVilyMw11Mo WYvRig2rt9Ia3/Cg== Date: Tue, 29 Sep 2020 22:25:30 +0200 From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Paul McKenney , Matthew Wilcox , Christian Benvenuti , Govindarajulu Varadarajan <_govind@gmx.com>, Dave Miller , Jakub Kicinski , netdev@vger.kernel.org, Jonathan Corbet , Mauro Carvalho Chehab , linux-doc@vger.kernel.org, Sebastian Andrzej Siewior , Luc Van Oostenryck , Jay Cliburn , Chris Snook , Vishal Kulkarni , Jeff Kirsher , intel-wired-lan@lists.osuosl.org, Shannon Nelson , Pensando Drivers , Andrew Lunn , Heiner Kallweit , Russell King , Thomas Bogendoerfer , Solarflare linux maintainers , Edward Cree , Martin Habets , Jon Mason , Daniel Drake , Ulrich Kunitz , Kalle Valo , linux-wireless@vger.kernel.org, linux-usb@vger.kernel.org, Greg Kroah-Hartman , Arend van Spriel , Franky Lin , Hante Meuleman , Chi-Hsien Lin , Wright Feng , brcm80211-dev-list.pdl@broadcom.com, brcm80211-dev-list@cypress.com, Stanislav Yakovlev , Stanislaw Gruszka , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Intel Linux Wireless , Jouni Malinen , Amitkumar Karwar , Ganapathi Bhat , Xinming Hu , libertas-dev@lists.infradead.org, Pascal Terjan , Ping-Ke Shih Subject: [patch V2 21/36] net: usb: kaweth: Replace kaweth_control() with usb_control_msg() References: <20200929202509.673358734@linutronix.de> MIME-Version: 1.0 Content-transfer-encoding: 8-bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sebastian Andrzej Siewior kaweth_control() is almost the same as usb_control_msg() except for the memory allocation mode (GFP_ATOMIC vs GFP_NOIO) and the in_interrupt() check. All the invocations of kaweth_control() are within the probe function in fully preemtible context so there is no reason to use atomic allocations, GFP_NOIO which is used by usb_control_msg() is perfectly fine. Replace kaweth_control() invocations from probe with usb_control_msg(). Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner Reviewed-by: Greg Kroah-Hartman --- drivers/net/usb/kaweth.c | 93 +++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 63 deletions(-) --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c @@ -282,19 +282,13 @@ static int kaweth_control(struct kaweth_ ****************************************************************/ static int kaweth_read_configuration(struct kaweth_device *kaweth) { - int retval; - - retval = kaweth_control(kaweth, - usb_rcvctrlpipe(kaweth->dev, 0), + return usb_control_msg(kaweth->dev, usb_rcvctrlpipe(kaweth->dev, 0), KAWETH_COMMAND_GET_ETHERNET_DESC, USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, - 0, - 0, - (void *)&kaweth->configuration, + 0, 0, + &kaweth->configuration, sizeof(kaweth->configuration), KAWETH_CONTROL_TIMEOUT); - - return retval; } /**************************************************************** @@ -302,21 +296,14 @@ static int kaweth_read_configuration(str ****************************************************************/ static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size) { - int retval; - netdev_dbg(kaweth->net, "Setting URB size to %d\n", (unsigned)urb_size); - retval = kaweth_control(kaweth, - usb_sndctrlpipe(kaweth->dev, 0), - KAWETH_COMMAND_SET_URB_SIZE, - USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, - urb_size, - 0, - (void *)&kaweth->scratch, - 0, - KAWETH_CONTROL_TIMEOUT); - - return retval; + return usb_control_msg(kaweth->dev, usb_sndctrlpipe(kaweth->dev, 0), + KAWETH_COMMAND_SET_URB_SIZE, + USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, + urb_size, 0, + &kaweth->scratch, 0, + KAWETH_CONTROL_TIMEOUT); } /**************************************************************** @@ -324,21 +311,14 @@ static int kaweth_set_urb_size(struct ka ****************************************************************/ static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait) { - int retval; - netdev_dbg(kaweth->net, "Set SOFS wait to %d\n", (unsigned)sofs_wait); - retval = kaweth_control(kaweth, - usb_sndctrlpipe(kaweth->dev, 0), - KAWETH_COMMAND_SET_SOFS_WAIT, - USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, - sofs_wait, - 0, - (void *)&kaweth->scratch, - 0, - KAWETH_CONTROL_TIMEOUT); - - return retval; + return usb_control_msg(kaweth->dev, usb_sndctrlpipe(kaweth->dev, 0), + KAWETH_COMMAND_SET_SOFS_WAIT, + USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, + sofs_wait, 0, + &kaweth->scratch, 0, + KAWETH_CONTROL_TIMEOUT); } /**************************************************************** @@ -347,22 +327,15 @@ static int kaweth_set_sofs_wait(struct k static int kaweth_set_receive_filter(struct kaweth_device *kaweth, __u16 receive_filter) { - int retval; - netdev_dbg(kaweth->net, "Set receive filter to %d\n", (unsigned)receive_filter); - retval = kaweth_control(kaweth, - usb_sndctrlpipe(kaweth->dev, 0), - KAWETH_COMMAND_SET_PACKET_FILTER, - USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, - receive_filter, - 0, - (void *)&kaweth->scratch, - 0, - KAWETH_CONTROL_TIMEOUT); - - return retval; + return usb_control_msg(kaweth->dev, usb_sndctrlpipe(kaweth->dev, 0), + KAWETH_COMMAND_SET_PACKET_FILTER, + USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, + receive_filter, 0, + &kaweth->scratch, 0, + KAWETH_CONTROL_TIMEOUT); } /**************************************************************** @@ -407,14 +380,11 @@ static int kaweth_download_firmware(stru kaweth->firmware_buf, kaweth); netdev_dbg(kaweth->net, "Firmware length: %d\n", data_len); - return kaweth_control(kaweth, - usb_sndctrlpipe(kaweth->dev, 0), + return usb_control_msg(kaweth->dev, usb_sndctrlpipe(kaweth->dev, 0), KAWETH_COMMAND_SCAN, USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, - 0, - 0, - (void *)kaweth->firmware_buf, - data_len, + 0, 0, + kaweth->firmware_buf, data_len, KAWETH_CONTROL_TIMEOUT); } @@ -433,15 +403,12 @@ static int kaweth_trigger_firmware(struc kaweth->firmware_buf[6] = 0x00; kaweth->firmware_buf[7] = 0x00; - return kaweth_control(kaweth, - usb_sndctrlpipe(kaweth->dev, 0), - KAWETH_COMMAND_SCAN, - USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, - 0, - 0, - (void *)kaweth->firmware_buf, - 8, - KAWETH_CONTROL_TIMEOUT); + return usb_control_msg(kaweth->dev, usb_sndctrlpipe(kaweth->dev, 0), + KAWETH_COMMAND_SCAN, + USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, + 0, 0, + (void *)kaweth->firmware_buf, 8, + KAWETH_CONTROL_TIMEOUT); } /****************************************************************