From patchwork Sun Nov 29 16:05:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939175 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 701C9C64E7C for ; Sun, 29 Nov 2020 16:07:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37A242080C for ; Sun, 29 Nov 2020 16:07:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qydIOokw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727821AbgK2QHZ (ORCPT ); Sun, 29 Nov 2020 11:07:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgK2QHZ (ORCPT ); Sun, 29 Nov 2020 11:07:25 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED922C0613D2; Sun, 29 Nov 2020 08:06:44 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id 131so8706465pfb.9; Sun, 29 Nov 2020 08:06:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cBTsPIheAREODwP7ehxYmG/rqbt0+8mgZWOAMNTxbTk=; b=qydIOokw2Re/YuYWXJauusN5uESxZCIIW6aCdBgluPCoWysPPFDeGn3FlZcfzyCLX5 aBNJ3nK59ovgVNLhlg0Ppmn0nCSAQ9Kx7PvaVr2rHCRreye7HOMhKCO11kzgvRYHX3t+ z0yva3s2q+AwLtqO+SdmvWQiqSwXzzJ20TheK6yBIMMp+F7An0M6X4nSzrVil8/edjos 60jYMDO3TYNWS5TwNVGS5cTJL5pTgfVbQq0oUDYcDIuKeOF3DzVyO5bsOeuV7EIQZIAT e1gnP8bxX8pe84RO40bup8SGMi0jJpDCGar+/g+lMTclN6ymr5niTcPeJRMhU7BT1HLI oSVA== 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:mime-version:content-transfer-encoding; bh=cBTsPIheAREODwP7ehxYmG/rqbt0+8mgZWOAMNTxbTk=; b=jtwquaSeyLHS054R0R83EedB1EiUim+bS7wgpn0XhwTEda9dlUzn0qeKnWEfSBGeNR BLTqYoE/71a57qvb0fsgUB2EOU671b0nSJrXKjb9DG7wliyk5dThnemFvszCaUI1UuVe SvmuTAl3kThrKZMSp2+AnhmZqtA3hlyVhlAdOzGZmZCw5KImx6DzXDzSGd8w07XfRB8w ysK4JNSpb4P2COIg9Si0kg+Bsj8xlMqIHv/Fy5Q+0TOg+eYbOlftv4huwaCl6lT0KoKz Z6BxVBRZkuD8uhCAKsbvJ3gaFoPZXcw8dU59CPGDjRy+dHPESGyuSBMN4YzRjLosrgNv 7ncQ== X-Gm-Message-State: AOAM531CR+PnRO3sZCXTIgEa4wE0XVbtlxiMrkGCmPdvv/ZPN3EwmG4H NZaCPNOHBqZG7Nd1TPYVjSk= X-Google-Smtp-Source: ABdhPJwQtNEjxcK454KvvMov3fJIFKaXWf6eIuD+5dUDh+BSyS1tPQhWEsFWe0MmlydSZkGlI9+xRQ== X-Received: by 2002:a17:90a:178b:: with SMTP id q11mr21178239pja.132.1606666004396; Sun, 29 Nov 2020 08:06:44 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:06:43 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , "Gustavo A. R. Silva" , Xu Wang , Liu Shixin , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/15] usb: misc: appledisplay: update to use the usb_control_msg_{send|recv}() API Date: Sun, 29 Nov 2020 21:35:58 +0530 Message-Id: <20201129160612.1908074-2-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, instances of usb_control_msg() have been replaced with usb_control_msg_{recv|send}(), and all return value checking conditions have also been modified appropriately. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/appledisplay.c | 46 ++++++++++++++------------------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c index c8098e9b432e..117deb2fdc29 100644 --- a/drivers/usb/misc/appledisplay.c +++ b/drivers/usb/misc/appledisplay.c @@ -132,21 +132,17 @@ static int appledisplay_bl_update_status(struct backlight_device *bd) pdata->msgdata[0] = 0x10; pdata->msgdata[1] = bd->props.brightness; - retval = usb_control_msg( - pdata->udev, - usb_sndctrlpipe(pdata->udev, 0), - USB_REQ_SET_REPORT, - USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, - ACD_USB_BRIGHTNESS, - 0, - pdata->msgdata, 2, - ACD_USB_TIMEOUT); + retval = usb_control_msg_send(pdata->udev, + 0, + USB_REQ_SET_REPORT, + USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, + ACD_USB_BRIGHTNESS, + 0, + pdata->msgdata, 2, + ACD_USB_TIMEOUT, GFP_KERNEL); mutex_unlock(&pdata->sysfslock); - if (retval < 0) - return retval; - else - return 0; + return retval; } static int appledisplay_bl_get_brightness(struct backlight_device *bd) @@ -155,21 +151,17 @@ static int appledisplay_bl_get_brightness(struct backlight_device *bd) int retval, brightness; mutex_lock(&pdata->sysfslock); - retval = usb_control_msg( - pdata->udev, - usb_rcvctrlpipe(pdata->udev, 0), - USB_REQ_GET_REPORT, - USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, - ACD_USB_BRIGHTNESS, - 0, - pdata->msgdata, 2, - ACD_USB_TIMEOUT); - if (retval < 2) { - if (retval >= 0) - retval = -EMSGSIZE; - } else { + retval = usb_control_msg_recv(pdata->udev, + 0, + USB_REQ_GET_REPORT, + USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, + ACD_USB_BRIGHTNESS, + 0, + pdata->msgdata, 2, + ACD_USB_TIMEOUT, GFP_KERNEL); + if (retval == 0) brightness = pdata->msgdata[1]; - } + mutex_unlock(&pdata->sysfslock); if (retval < 0) From patchwork Sun Nov 29 16:05:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939181 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 29BEAC64E90 for ; Sun, 29 Nov 2020 16:07:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4A852074A for ; Sun, 29 Nov 2020 16:07:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="koTRXhfp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728050AbgK2QHe (ORCPT ); Sun, 29 Nov 2020 11:07:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgK2QHd (ORCPT ); Sun, 29 Nov 2020 11:07:33 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B03C0613D3; Sun, 29 Nov 2020 08:06:47 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id e23so3552698pgk.12; Sun, 29 Nov 2020 08:06:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OeM4m0IbwLytr9GIwsSVrv4uTq97qX9ObS/vezts+wA=; b=koTRXhfp+w/oxoWlk2B7qlb5CWzYoIg0/DiGgGrnuPiI1oHCG7nx8r9Askn+kTjMUq zAYrp4yOjaUcik+XT+jVI8/ZaR2zA2DBQHC5QEyS2D+eSo4+QHV92WYsyv8pMCyczK3Q R000j/Eo7NpCWWKT3ZRg2vf/MgZGoViHOTHJq5FL20WARaX9ruFaOX1IL0u0nGOiaXVy bWTZRjvy18tiYWkVdkDInJftzcJigMkRcamU/7Slt6zTD5Od2PTogcFwbfFp3KK6YCUQ wrpvn5oCUIu4cL7kHWd8MJEcRVj5QYZe851CD9wQh889JQ7l7krYkPqJSB1CJ4kmcpv/ cd+w== 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:mime-version:content-transfer-encoding; bh=OeM4m0IbwLytr9GIwsSVrv4uTq97qX9ObS/vezts+wA=; b=SgJlDmvMqAonPW3DdSsFuMBu2Y5SSkfy5P7aLNz5dc+33PDfrHRRAyOIWmTuRiBIpK QzEr5+hYN0y/4LKcDioVX9GXEeo+SSyrwEfX8xkhoUQyGNsmk1VqXdy98llpyGhYbdRK EbBzbHqyC7PKPmiXhdNccXNZepnHfXMiw0QSt/4CzWvLo77U1h7LUp61JHcZdMi+RWCR wCli/ccXMVJ1zrhN0T/MT0CH/pCNOCtza3P35uNMDCBY+D3NTbmq0j2UYBpw2m/CBGg1 XTtAf6V6KaQbsc9bNkepWsYCewVo437OLx/ZJV2K/xWm8l9898iQNVjjhNUhwqNwHzba FIjQ== X-Gm-Message-State: AOAM531rKmjSXdcj52SihMKp6p18QE8zHiBhIBOeatrGpNj5T3hhP+5i QN5tyLHhcTX/LE08YbFNLi8= X-Google-Smtp-Source: ABdhPJyd8GjBeevYOY520PSK5ccsCHlRJGEKNQDIzy+WLi4ZI5Go/T5hjdkXY0P5RBNHK9lZSXshKQ== X-Received: by 2002:a63:4743:: with SMTP id w3mr14261697pgk.147.1606666007385; Sun, 29 Nov 2020 08:06:47 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.06.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:06:46 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/15] usb: misc: cypress_cy7c63: update to use usb_control_msg_recv() Date: Sun, 29 Nov 2020 21:35:59 +0530 Message-Id: <20201129160612.1908074-3-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, the instance of usb_control_msg() has been replaced with usb_control_msg_recv(). Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/cypress_cy7c63.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c index 14faec51d7a5..fc09251fc87c 100644 --- a/drivers/usb/misc/cypress_cy7c63.c +++ b/drivers/usb/misc/cypress_cy7c63.c @@ -70,7 +70,6 @@ static int vendor_command(struct cypress *dev, unsigned char request, unsigned char address, unsigned char data) { int retval = 0; - unsigned int pipe; unsigned char *iobuf; /* allocate some memory for the i/o buffer*/ @@ -83,11 +82,10 @@ static int vendor_command(struct cypress *dev, unsigned char request, dev_dbg(&dev->udev->dev, "Sending usb_control_msg (data: %d)\n", data); /* prepare usb control message and send it upstream */ - pipe = usb_rcvctrlpipe(dev->udev, 0); - retval = usb_control_msg(dev->udev, pipe, request, - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, - address, data, iobuf, CYPRESS_MAX_REQSIZE, - USB_CTRL_GET_TIMEOUT); + retval = usb_control_msg_recv(dev->udev, 0, request, + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, + address, data, iobuf, CYPRESS_MAX_REQSIZE, + USB_CTRL_GET_TIMEOUT, GFP_KERNEL); /* store returned data (more READs to be added) */ switch (request) { From patchwork Sun Nov 29 16:06:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939179 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 ABDA0C3E8C5 for ; Sun, 29 Nov 2020 16:07:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5C5AB2074A for ; Sun, 29 Nov 2020 16:07:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bTT+7/Dy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727981AbgK2QHb (ORCPT ); Sun, 29 Nov 2020 11:07:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgK2QHb (ORCPT ); Sun, 29 Nov 2020 11:07:31 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10DEDC0613D4; Sun, 29 Nov 2020 08:06:51 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id l17so8429517pgk.1; Sun, 29 Nov 2020 08:06:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wYgJ36S1d93ExxyZRxjjA6kLMdxalPYMh/Ef3UGOiwQ=; b=bTT+7/DyFAtjDaSlJcGjkyPWp3JqxBfCQYatinU9uZ1zytBCosuJT80ZZXPx9PdOUT 9QzgUqrkUva1MldSbOlcyax5WH9IpV2xmeTiOXety5CPjt5AImUoNyqs2qFqsSn+3v2Z F73CPOx1ss1YWhWEez0ejdVpixxz+f/6zOiWaKaz/hOelkQ4yEbMvUTi0okA7bk1Ehan rTRg+cRxU2fOGGZjR/fBZ1Y6MjlFu+EgmBjr2JqbXmkF3xMCuB03OQj4bbKcUXTUd0xp LJROBMgxqJ/l12jHDwcynEjh8G4j4VSSRv7lRLl32LgbuIDe5jiJ9oV+gR6CTxaxj2zU N8sg== 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:mime-version:content-transfer-encoding; bh=wYgJ36S1d93ExxyZRxjjA6kLMdxalPYMh/Ef3UGOiwQ=; b=ALnsTrLlo7uyKIxm29F99jnl+SbPZ9EIklYecPBhiOJd81m3Ap7jh67nuNKXgYXeZY vjF0ljHnJs+5G2C1JGXDS6LuwIvsE8bhlbcQ95V6mC+qXgvsF5vr4VAZAxywtdXoXazR A2J1FeBfgkSTE6hWE17OLKHPQHr+b2cRu5sUemvhfB77mkBpoxH1t3JDERJNqHCmPnJc U6SGogos+AY4tZvlNClxzzWbSlUGPpoOJeIqOk5rfVGdF3aiiPdhDtuc+9IaS7owuNuS +LQvQomN81aSh6LDlpfOTisFQ2uSQhr8uIM6JWC2OiuYA80CyieMXvXxJDO+P/LBQ/r3 DfUw== X-Gm-Message-State: AOAM533Wd2Ny5JslIrC0awADLp9g2LVTynMoCCF5b8pf9N/+zGTmI+pN 7ezDpTdUHf/wza9MjDw+7mM= X-Google-Smtp-Source: ABdhPJyutdZ0cpo1qS5hyIx4JVtcFmG0PF5e8CI4v4xhEXBCa6Skb4vPtTVRqs9evx/ZUTDaNZRKpw== X-Received: by 2002:a62:5b05:0:b029:197:fafb:50f3 with SMTP id p5-20020a625b050000b0290197fafb50f3mr15050321pfb.76.1606666010509; Sun, 29 Nov 2020 08:06:50 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:06:49 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/15] usb: misc: cytherm: update to use usb_control_msg_recv() Date: Sun, 29 Nov 2020 21:36:00 +0530 Message-Id: <20201129160612.1908074-4-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, the instance of usb_control_msg() has been replaced with usb_control_msg_recv(). The return value checking enforced by callers of the updated function have also been appropriately updated. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/cytherm.c | 42 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 3e3802aaefa3..75fa4d806a77 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c @@ -51,12 +51,12 @@ static int vendor_command(struct usb_device *dev, unsigned char request, unsigned char value, unsigned char index, void *buf, int size) { - return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), - request, - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, - value, - index, buf, size, - USB_CTRL_GET_TIMEOUT); + return usb_control_msg_recv(dev, 0, + request, + USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, + value, + index, buf, size, + USB_CTRL_GET_TIMEOUT, GFP_KERNEL); } @@ -95,14 +95,14 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *att /* Set brightness */ retval = vendor_command(cytherm->udev, WRITE_RAM, BRIGHTNESS, cytherm->brightness, buffer, 8); - if (retval) - dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); + if (!retval) + dev_dbg(&cytherm->udev->dev, "brightness set correctly\n"); /* Inform µC that we have changed the brightness setting */ retval = vendor_command(cytherm->udev, WRITE_RAM, BRIGHTNESS_SEM, 0x01, buffer, 8); - if (retval) - dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); - + if (!retval) + dev_dbg(&cytherm->udev->dev, "µC informed of change in brightness setting\n"); + kfree(buffer); return count; @@ -130,14 +130,14 @@ static ssize_t temp_show(struct device *dev, struct device_attribute *attr, char /* read temperature */ retval = vendor_command(cytherm->udev, READ_RAM, TEMP, 0, buffer, 8); - if (retval) - dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); + if (!retval) + dev_dbg(&cytherm->udev->dev, "read temperature successfully\n"); temp = buffer[1]; /* read sign */ retval = vendor_command(cytherm->udev, READ_RAM, SIGN, 0, buffer, 8); - if (retval) - dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); + if (!retval) + dev_dbg(&cytherm->udev->dev, "read sign successfully\n"); sign = buffer[1]; kfree(buffer); @@ -165,8 +165,8 @@ static ssize_t button_show(struct device *dev, struct device_attribute *attr, ch /* check button */ retval = vendor_command(cytherm->udev, READ_RAM, BUTTON, 0, buffer, 8); - if (retval) - dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); + if (!retval) + dev_dbg(&cytherm->udev->dev, "checked button successfully\n"); retval = buffer[1]; @@ -193,7 +193,7 @@ static ssize_t port0_show(struct device *dev, struct device_attribute *attr, cha return 0; retval = vendor_command(cytherm->udev, READ_PORT, 0, 0, buffer, 8); - if (retval) + if (!retval) dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); retval = buffer[1]; @@ -226,7 +226,7 @@ static ssize_t port0_store(struct device *dev, struct device_attribute *attr, co retval = vendor_command(cytherm->udev, WRITE_PORT, 0, tmp, buffer, 8); - if (retval) + if (!retval) dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); kfree(buffer); @@ -248,7 +248,7 @@ static ssize_t port1_show(struct device *dev, struct device_attribute *attr, cha return 0; retval = vendor_command(cytherm->udev, READ_PORT, 1, 0, buffer, 8); - if (retval) + if (!retval) dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); retval = buffer[1]; @@ -281,7 +281,7 @@ static ssize_t port1_store(struct device *dev, struct device_attribute *attr, co retval = vendor_command(cytherm->udev, WRITE_PORT, 1, tmp, buffer, 8); - if (retval) + if (!retval) dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); kfree(buffer); From patchwork Sun Nov 29 16:06:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939183 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 62FCAC64E7C for ; Sun, 29 Nov 2020 16:07:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 315CD20829 for ; Sun, 29 Nov 2020 16:07:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AYNXH+yx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728107AbgK2QHh (ORCPT ); Sun, 29 Nov 2020 11:07:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725468AbgK2QHg (ORCPT ); Sun, 29 Nov 2020 11:07:36 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16D88C0617A7; Sun, 29 Nov 2020 08:06:56 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id t3so8395079pgi.11; Sun, 29 Nov 2020 08:06:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GVVJZ09FG8uzoipcul14lMHmm6BPKaCyHUkCOOvuhVM=; b=AYNXH+yxJXdR0fZVJ5eMh/+FIR+RVMk7IOa1brdXFH44gSn/oWL9s11U0bFQQq1pc1 MEl3VYyUH6xaRZ5IbE/aBa6TjKfWlGPAS62JgAPzQXhpJTR0wg7/JdaEuHu0xz1Vb+yD tJsUtshzIMdB3olWaJt+sLiu54BRkthmkRK5/H/Gw3aTIbGe5skJZFkcEK62sM0vqqwj /Ko1Y6uHzgKaD+buhMldlvHbkS4IJDFkadQW2zhTW5ong2rrcTSkBfJBtYyQm9HFlpEK QpF2ffCPsHP7+Gd3/y6SH6tT+tMrFyJdZZdboI83JkXnf8ByNSZqdxPpOia4jX9H6w8q qSqg== 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:mime-version:content-transfer-encoding; bh=GVVJZ09FG8uzoipcul14lMHmm6BPKaCyHUkCOOvuhVM=; b=DarwWm9NE+vc7FAcBB7dlOeGGgB7z+ztNpwJvBBrg/HLQcJMRMfwB5/cnK+NaYNkhc ROq+glhvgarRAzT2ZYd+iQQBvPMjAHjB2kqxRTXX6BdYEOcY9R5OucO1cSc7/txSbAAB YlEJiy8V9IuX+UA30xef0NQJOIBFnzweiv516UF/3WYYtOa7XC8m7ZEd8zSZSkGCbnNx 4z4tqBNKrz6oh8SY/sypeG1XyM2NBwJ/KpxdusPsNUFN+jcdu2axs9ErgH17V1k0LPLQ shOLVW2MN6EAxHZwnRw34zkRlajBtAWgyA7sFJYp4KTkizKb8f330bV4Gj783CXT1YJK NsOQ== X-Gm-Message-State: AOAM530rozLctH1GLtZwTLZ3JWBdqrvR+ud4+kxy/2S9BbP0gmm2FTPT NJAFO5WPcxNuzLhMX9XHALs= X-Google-Smtp-Source: ABdhPJxCLd1E3bV5hbMUDqjxGInVieLRMWltaWa7A8cjShKC8R+EiteOoJNv5F1kM2GbnvRx6LO+ZQ== X-Received: by 2002:a17:90a:8b8b:: with SMTP id z11mr17824406pjn.117.1606666015554; Sun, 29 Nov 2020 08:06:55 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.06.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:06:54 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Matthias Brugger , Anant Thazhemadam , Chunfeng Yun , Bin Liu , Peter Chen Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH 04/15] usb: misc: ehset: update to use the usb_control_msg_{send|recv}() API Date: Sun, 29 Nov 2020 21:36:01 +0530 Message-Id: <20201129160612.1908074-5-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, instances of usb_control_msg() have been replaced with usb_control_msg_{recv|send}() appropriately. Signed-off-by: Anant Thazhemadam Reviewed-by: Peter Chen --- drivers/usb/misc/ehset.c | 70 ++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/drivers/usb/misc/ehset.c b/drivers/usb/misc/ehset.c index 2752e1f4f4d0..068f4fae2965 100644 --- a/drivers/usb/misc/ehset.c +++ b/drivers/usb/misc/ehset.c @@ -30,48 +30,42 @@ static int ehset_probe(struct usb_interface *intf, switch (test_pid) { case TEST_SE0_NAK_PID: - ret = usb_control_msg(hub_udev, usb_sndctrlpipe(hub_udev, 0), - USB_REQ_SET_FEATURE, USB_RT_PORT, - USB_PORT_FEAT_TEST, - (USB_TEST_SE0_NAK << 8) | portnum, - NULL, 0, 1000); + ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE, + USB_RT_PORT, USB_PORT_FEAT_TEST, + (USB_TEST_SE0_NAK << 8) | portnum, + NULL, 0, 1000, GFP_KERNEL); break; case TEST_J_PID: - ret = usb_control_msg(hub_udev, usb_sndctrlpipe(hub_udev, 0), - USB_REQ_SET_FEATURE, USB_RT_PORT, - USB_PORT_FEAT_TEST, - (USB_TEST_J << 8) | portnum, - NULL, 0, 1000); + ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE, + USB_RT_PORT, USB_PORT_FEAT_TEST, + (USB_TEST_J << 8) | portnum, NULL, 0, + 1000, GFP_KERNEL); break; case TEST_K_PID: - ret = usb_control_msg(hub_udev, usb_sndctrlpipe(hub_udev, 0), - USB_REQ_SET_FEATURE, USB_RT_PORT, - USB_PORT_FEAT_TEST, - (USB_TEST_K << 8) | portnum, - NULL, 0, 1000); + ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE, + USB_RT_PORT, USB_PORT_FEAT_TEST, + (USB_TEST_K << 8) | portnum, NULL, 0, + 1000, GFP_KERNEL); break; case TEST_PACKET_PID: - ret = usb_control_msg(hub_udev, usb_sndctrlpipe(hub_udev, 0), - USB_REQ_SET_FEATURE, USB_RT_PORT, - USB_PORT_FEAT_TEST, - (USB_TEST_PACKET << 8) | portnum, - NULL, 0, 1000); + ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE, + USB_RT_PORT, USB_PORT_FEAT_TEST, + (USB_TEST_PACKET << 8) | portnum, + NULL, 0, 1000, GFP_KERNEL); break; case TEST_HS_HOST_PORT_SUSPEND_RESUME: /* Test: wait for 15secs -> suspend -> 15secs delay -> resume */ msleep(15 * 1000); - ret = usb_control_msg(hub_udev, usb_sndctrlpipe(hub_udev, 0), - USB_REQ_SET_FEATURE, USB_RT_PORT, - USB_PORT_FEAT_SUSPEND, portnum, - NULL, 0, 1000); + ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE, + USB_RT_PORT, USB_PORT_FEAT_SUSPEND, + portnum, NULL, 0, 1000, GFP_KERNEL); if (ret < 0) break; msleep(15 * 1000); - ret = usb_control_msg(hub_udev, usb_sndctrlpipe(hub_udev, 0), - USB_REQ_CLEAR_FEATURE, USB_RT_PORT, - USB_PORT_FEAT_SUSPEND, portnum, - NULL, 0, 1000); + ret = usb_control_msg_send(hub_udev, 0, USB_REQ_CLEAR_FEATURE, + USB_RT_PORT, USB_PORT_FEAT_SUSPEND, + portnum, NULL, 0, 1000, GFP_KERNEL); break; case TEST_SINGLE_STEP_GET_DEV_DESC: /* Test: wait for 15secs -> GetDescriptor request */ @@ -80,11 +74,10 @@ static int ehset_probe(struct usb_interface *intf, if (!buf) return -ENOMEM; - ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), - USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, - USB_DT_DEVICE << 8, 0, - buf, USB_DT_DEVICE_SIZE, - USB_CTRL_GET_TIMEOUT); + ret = usb_control_msg_recv(dev, 0, USB_REQ_GET_DESCRIPTOR, + USB_DIR_IN, USB_DT_DEVICE << 8, 0, + buf, USB_DT_DEVICE_SIZE, + USB_CTRL_GET_TIMEOUT, GFP_KERNEL); kfree(buf); break; case TEST_SINGLE_STEP_SET_FEATURE: @@ -100,11 +93,10 @@ static int ehset_probe(struct usb_interface *intf, break; } - ret = usb_control_msg(hub_udev, usb_sndctrlpipe(hub_udev, 0), - USB_REQ_SET_FEATURE, USB_RT_PORT, - USB_PORT_FEAT_TEST, - (6 << 8) | portnum, - NULL, 0, 60 * 1000); + ret = usb_control_msg_send(hub_udev, 0, USB_REQ_SET_FEATURE, + USB_RT_PORT, USB_PORT_FEAT_TEST, + (6 << 8) | portnum, NULL, 0, + 60 * 1000, GFP_KERNEL); break; default: @@ -112,7 +104,7 @@ static int ehset_probe(struct usb_interface *intf, __func__, test_pid); } - return (ret < 0) ? ret : 0; + return ret; } static void ehset_disconnect(struct usb_interface *intf) From patchwork Sun Nov 29 16:06:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939185 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 78F38C3E8C5 for ; Sun, 29 Nov 2020 16:08:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 470C320829 for ; Sun, 29 Nov 2020 16:08:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MsjsA7nr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgK2QHy (ORCPT ); Sun, 29 Nov 2020 11:07:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726669AbgK2QHx (ORCPT ); Sun, 29 Nov 2020 11:07:53 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D65BC061A47; Sun, 29 Nov 2020 08:06:59 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id 131so8706728pfb.9; Sun, 29 Nov 2020 08:06:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=LVhruWIY/P2/Y+4I2ixxsPAsvIG1kQjrmNo/r2JNhsk=; b=MsjsA7nr0iuTWYGF0aBVjMK0svUlyAox0Z2XKhCOUkszW/4DkkpS2UwWPXlJ212cmD iF2FKJzqqm36BbOFzk9ZQU6f77afKYYe5fvrS16UM+NqU863W9lswrnkAoKjaxhn25K6 2evXWmOkLO8gF2ivRWPDLJcpJvy5jKGNTOCFmeIWz8hNZenmxLByRBvPo9x1v0HoSjUv ozVLiJNTCHrmONpu3SnTlgPfvKW1NQEPsx91kW8Cpb6ESQxcEMSh2cG1Go4pi8RNGND2 GBHC1Pf4OIccBCKCiMIRgwCSPZJ3dS3I53mvLHUfmVGUG/aTn4VWYEuYfd09LBQBnel7 Fj4Q== 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:mime-version:content-transfer-encoding; bh=LVhruWIY/P2/Y+4I2ixxsPAsvIG1kQjrmNo/r2JNhsk=; b=Hor2Z629FiT+3pheiFsMIgtenrGaHZ6oBhXcMlBdX+YmM0Bh6KyuPy0xenvAyS2XOl 3osCK5y8u1rfX0Y7RNOvUMaM/HiTEEfytPjmLEnB1rPw2TzjN6jF36W6QZrRNsXQucdN IfmUeY4W+3EzGTDR6ezRqkBqcqYoUl7LQpxNG6T6MEjJfVEKb6DUd4oFtoxsRVZAWj7u qVtE8F3i6qb1+Q7LcrJ8wGH5E+zdZr960gji5focaHpMXlVR8NggKwgQDdpB9qH0+vkW AT9y7cy7rxIRMnKpxhGyvJp46Lv0olhBYQnTzJCtUTXsdJq31iBn2e7UIge9mCJ+zdka plWQ== X-Gm-Message-State: AOAM532bcQcSeBZWfpO7lDj7Jv6WpTuCf81hrtqMFNfhmzLFsVU2JYL5 lFMp5v/lQA1jJQalLCp1OZa+0hn8btj6RxfOOes= X-Google-Smtp-Source: ABdhPJyXXlH513p7X0Vc34qO5ZRXu+ARNpnEZ6sraOo8Eg71GpBS9ac50eM/PDUtheBrzlT8b7u6LQ== X-Received: by 2002:a17:90a:aa0e:: with SMTP id k14mr22086638pjq.153.1606666018593; Sun, 29 Nov 2020 08:06:58 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:06:57 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/15] usb: misc: emi26: update to use usb_control_msg_send() Date: Sun, 29 Nov 2020 21:36:02 +0530 Message-Id: <20201129160612.1908074-6-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, the instance of usb_control_msg() has been replaced with usb_control_msg_send() appropriately. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/emi26.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index 24d841850e05..1093809d34ad 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c @@ -39,18 +39,8 @@ static int emi26_writememory (struct usb_device *dev, int address, const unsigned char *data, int length, __u8 request) { - int result; - unsigned char *buffer = kmemdup(data, length, GFP_KERNEL); - - if (!buffer) { - dev_err(&dev->dev, "kmalloc(%d) failed.\n", length); - return -ENOMEM; - } - /* Note: usb_control_msg returns negative value on error or length of the - * data that was written! */ - result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300); - kfree (buffer); - return result; + return usb_control_msg_send(dev, 0, request, 0x40, address, 0, + data, length, 300, GFP_KERNEL); } /* thanks to drivers/usb/serial/keyspan_pda.c code */ From patchwork Sun Nov 29 16:06:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939189 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 A7DD1C64E7C for ; Sun, 29 Nov 2020 16:08:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6EBF82080C for ; Sun, 29 Nov 2020 16:08:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mI3gsHCR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387416AbgK2QIG (ORCPT ); Sun, 29 Nov 2020 11:08:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387406AbgK2QIF (ORCPT ); Sun, 29 Nov 2020 11:08:05 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F0B2C061A48; Sun, 29 Nov 2020 08:07:02 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id w187so8727570pfd.5; Sun, 29 Nov 2020 08:07:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iH1BJ1F9uJ1BMhbbV1cemuGWuqAz6DqF3K+Ndw2I+uI=; b=mI3gsHCRjiEpdKUznoqVS44zHCKsFy4tJB2YY3ib+9pFtibn9jX/3KU91YEpACCGtB 8Y0ffLlq8EUnuaQVmseg1mIBj8h4VlO3Lx4YXYCKThmPa+esGPd4BEVhWp4/nsYdS92i 57mXEm+1kSB+1ejIV3eXl5RxwRoBWnF5jfsMlH5RHMbnMBsRKPuI/w59D4DDZbdDFVaf E0XNjfrHh5h29TFC0NaBEb9zJw9hZ+RqKfq+Feh1WDG4Op9M8vcgYiW1USkKkRgQPrxr LElVNNBWUU1vDMZ2ytMhYW4O/DKVv0ix69hG8iYZnCdo0VSjRyByDhFadHwzPLTerSAz LBog== 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:mime-version:content-transfer-encoding; bh=iH1BJ1F9uJ1BMhbbV1cemuGWuqAz6DqF3K+Ndw2I+uI=; b=oWgTsFfagOq6imTykudZfQxaD2/iBqvR9z9EFtoaysmfKkR2eFHObx9YUnGG36tMTA JgEwc9KGn8hL1OTVD+7D3YG10MrIEGatHWJFYRDZySwbKzA0j7ewonoxm4GniHAfhFk2 Kz2QRNH+QEB/HT/zR9vZkBg6WDJdTVAYoLKtsNOaYucSgSEDscL5qPlPv8FmDaN3NfgA k7ZhcrkYlC2mM0Pj5Tpt7+NRjisYbqOttY7fI6PqUHCF8wZqeR3486BidONGpYiS/mtl 9MIXIiG6Fu046NzaRQUlf3zu6Xtb4sXFU4ky+PthzXZEsLsCjZWfDah+K23QoBQFJJzO ERHA== X-Gm-Message-State: AOAM5300JlRHorofi8uab8piBXN1qTQKr5lb+oYFIO/8lcr0d+CVm30F U2OxCJRb+dg0d7PRGkRYbG0= X-Google-Smtp-Source: ABdhPJz3Y9dF4RuAj6pT9vsa393RwkrvauNg+pEhUpJwxK177xnekWw9Tv1tbPbi3COV8jkmhvD8lQ== X-Received: by 2002:a63:3841:: with SMTP id h1mr6836784pgn.380.1606666021634; Sun, 29 Nov 2020 08:07:01 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.06.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:07:00 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/15] usb: misc: emi62: update to use usb_control_msg_send() Date: Sun, 29 Nov 2020 21:36:03 +0530 Message-Id: <20201129160612.1908074-7-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, the instance of usb_control_msg() has been replaced with usb_control_msg_send() appropriately. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/emi62.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 3eea60437f56..de984e91085c 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c @@ -48,18 +48,8 @@ static int emi62_writememory(struct usb_device *dev, int address, const unsigned char *data, int length, __u8 request) { - int result; - unsigned char *buffer = kmemdup(data, length, GFP_KERNEL); - - if (!buffer) { - dev_err(&dev->dev, "kmalloc(%d) failed.\n", length); - return -ENOMEM; - } - /* Note: usb_control_msg returns negative value on error or length of the - * data that was written! */ - result = usb_control_msg (dev, usb_sndctrlpipe(dev, 0), request, 0x40, address, 0, buffer, length, 300); - kfree (buffer); - return result; + return usb_control_msg_send(dev, 0, request, 0x40, address, + 0, data, length, 300, GFP_KERNEL); } /* thanks to drivers/usb/serial/keyspan_pda.c code */ From patchwork Sun Nov 29 16:06:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939187 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 C58E8C64E8A for ; Sun, 29 Nov 2020 16:08:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92F8820829 for ; Sun, 29 Nov 2020 16:08:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u2gftksm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387441AbgK2QIG (ORCPT ); Sun, 29 Nov 2020 11:08:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387408AbgK2QIF (ORCPT ); Sun, 29 Nov 2020 11:08:05 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED5D2C061A49; Sun, 29 Nov 2020 08:07:04 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id e23so3553041pgk.12; Sun, 29 Nov 2020 08:07:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Rlm5PUymFHRx39FCcGjfRRBHQ3f0wd7qTZT6jsgLwkA=; b=u2gftksmKXDhcqV1TTEzrprq0GntFOdlbKLKYtZKVg0aT6jSDI633ex4dB88cWjIFl 63w/Huy/IuPUCeZeEuryqAmYHQ5Baw/Ewyte5CNt6nd2OmVg6vlY1vbqFOpFz/1UW/Ob XPWy7PiJoHhll7Fyog+N75aA4K81ABbJ7A/9pkXdstNAmoxje4jj7jSTE4dM8lOVp8Ah YHySrrFbITGrndH+odcN1F4+SlyD0VoyMgQjaavLmk8c1cUbhFgBp5AsOGSeVM+RhY8E 5e5EGkgaysJd7Mbvgeu2QsqtJEuXFWPOpVxZP0Mb+IF8M2OCEmViI+p2ucYovqEnX0Ei CgWw== 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:mime-version:content-transfer-encoding; bh=Rlm5PUymFHRx39FCcGjfRRBHQ3f0wd7qTZT6jsgLwkA=; b=cIB2+ficO8kDeOMTuctg5N4nqUWSS8FDUiixkGwSfGXAnAXDX4NW4j+oXoHc4tBc3p gpmaeTm76xcfCxSG2KDh7qpS5xkNn4rnElVz3GOHHoe1GU5XdcXmVY/TzGVAArqXwocM oSr2X90epTYpbdtPr9hJJN8JTUB8XlOFPTe8yxm+yxjPih2nas6Q3eaacEw9+BS/aBqg 11O94GALgD1PomxYXLDggCcY3tTVo9lPLyz3f7h8IM/eOJWTpiFxBuAerxD+HzmB9Ofx 7YO2QNNnEzRI461jZCjtEK6iQGJuLe5Zz/iTAOwuhl22QWbnclkhOjeIItEIV8VnWw40 MaUg== X-Gm-Message-State: AOAM531DesjykmLdT7ZjMEzykzjea5PJkJu3jPeLAVmT5zm0U6NkEgv2 o3b9Rcrkf5oDTt5YrmgBdtCYYS8LwZO+YzkMl5A= X-Google-Smtp-Source: ABdhPJyfD/UeJNBQCR+1E9Z9FdCM62YisFBFrFlU1OrrCs9PGb7V89bAA1aM7Q+GWDGjFENokPXzsA== X-Received: by 2002:a17:90b:374f:: with SMTP id ne15mr21666351pjb.57.1606666024437; Sun, 29 Nov 2020 08:07:04 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.07.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:07:03 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/15] usb: misc: ezusb: update to use usb_control_msg_send() Date: Sun, 29 Nov 2020 21:36:04 +0530 Message-Id: <20201129160612.1908074-8-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, the instance of usb_control_msg() has been replaced with usb_control_msg_send() appropriately. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/ezusb.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/drivers/usb/misc/ezusb.c b/drivers/usb/misc/ezusb.c index f058d8029761..78aaee56c2b7 100644 --- a/drivers/usb/misc/ezusb.c +++ b/drivers/usb/misc/ezusb.c @@ -31,24 +31,12 @@ static const struct ezusb_fx_type ezusb_fx1 = { static int ezusb_writememory(struct usb_device *dev, int address, unsigned char *data, int length, __u8 request) { - int result; - unsigned char *transfer_buffer; - if (!dev) return -ENODEV; - transfer_buffer = kmemdup(data, length, GFP_KERNEL); - if (!transfer_buffer) { - dev_err(&dev->dev, "%s - kmalloc(%d) failed.\n", - __func__, length); - return -ENOMEM; - } - result = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, + return usb_control_msg_send(dev, 0, request, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, - address, 0, transfer_buffer, length, 3000); - - kfree(transfer_buffer); - return result; + address, 0, data, length, 3000, GFP_KERNEL); } static int ezusb_set_reset(struct usb_device *dev, unsigned short cpucs_reg, From patchwork Sun Nov 29 16:06:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939205 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 CFBAEC83017 for ; Sun, 29 Nov 2020 16:08:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9E85F2080C for ; Sun, 29 Nov 2020 16:08:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qhxudp8P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387556AbgK2QIa (ORCPT ); Sun, 29 Nov 2020 11:08:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387408AbgK2QIL (ORCPT ); Sun, 29 Nov 2020 11:08:11 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45E63C061A4A; Sun, 29 Nov 2020 08:07:08 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id w4so8391166pgg.13; Sun, 29 Nov 2020 08:07:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sDOpWxXfNZ312yhyl51Y7bEUu6zDTfPu30AJ2VVW3j8=; b=qhxudp8PVkUP/lbksQXE9i19mfvs5SKAqy9qF0dpjvCKwPdYU5iAE4xU95CkqDaUAl w95Qi+sgXd4F73f3188Itu00YzjCDQkeuUtKtrNz/y7u+8A50mVX5o3z36u2fGRn4IT0 ASch1WGw1OpaHHChIJPd75zYQDAFJ/6gQ0BTbkKOBjOYOc+LNxChVJUPNppAFwsJnWQ/ 8TC6P8BMCsH03BuQCBIZlVonTVSbtfJfrNw17JFJITq8aKOCg1VgNLO/VUAVN0+Xd53R UAcOAlYZWNUH0T+g6eq7vNI+433fq5k4hq3XC+HElBSO+jZJBIT0MP2OVvQ/zdc6pfEi m2uQ== 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:mime-version:content-transfer-encoding; bh=sDOpWxXfNZ312yhyl51Y7bEUu6zDTfPu30AJ2VVW3j8=; b=JzCDIUyW+UkdgwRK+hR4BMmXBrjQlKMkzyhkq0z0yaH80jYuIiY7kn+ADE6ohfu2w9 jRqDDDTJhoNE9pcaKP5yHHKa/ljWGZSHOi7Zv6KL0md1YUkJLs3ExuoEyJ7jO+Wo9UEt PM8W8tnoSvDWO32qUrCYmmmHgWg2ueITr2X2QPOXcOLmrkXxwPlnPPDR/BYMSmknUEdJ lU6FIMHvknFAd31wiZDMIRlsNLekRMn9c4cwog+ewfTavmSzyKencAFVbu/IS8UtEBqh /FHq9Wb3l3EOVd+CYVifIymqto2yYiICD4Ccpag5nIwYyVhC9qV7IYlXbRHB3H/v6FaP bVOQ== X-Gm-Message-State: AOAM533ItNVtDtnMZoDEBotXDI/jM/oaf+i+smFQoLuD+v1AYgV3RecB kEM61E3vCkltpl1EOaD0nMw= X-Google-Smtp-Source: ABdhPJxIQD+H77NlTQboQEfL3ak09BrLLoNfkuvPrIu+GxZvnK6Rw1IYaKC5G7DzWFrMurunGnaNoA== X-Received: by 2002:a63:455e:: with SMTP id u30mr14244106pgk.113.1606666027735; Sun, 29 Nov 2020 08:07:07 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.07.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:07:07 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Johan Hovold , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/15] usb: misc: idmouse: update to use usb_control_msg_send() Date: Sun, 29 Nov 2020 21:36:05 +0530 Message-Id: <20201129160612.1908074-9-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, the instance of usb_control_msg() has been replaced with usb_control_msg_send() appropriately. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/idmouse.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/usb/misc/idmouse.c b/drivers/usb/misc/idmouse.c index e9437a176518..52126441a633 100644 --- a/drivers/usb/misc/idmouse.c +++ b/drivers/usb/misc/idmouse.c @@ -56,8 +56,9 @@ static const struct usb_device_id idmouse_table[] = { #define FTIP_SCROLL 0x24 #define ftip_command(dev, command, value, index) \ - usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), command, \ - USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, value, index, NULL, 0, 1000) + usb_control_msg_send(dev->udev, 0, command, \ + USB_TYPE_VENDOR | USB_RECIP_ENDPOINT | USB_DIR_OUT, \ + value, index, NULL, 0, 1000, GFP_KERNEL) MODULE_DEVICE_TABLE(usb, idmouse_table); From patchwork Sun Nov 29 16:06:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939195 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 7E413C64E7B for ; Sun, 29 Nov 2020 16:08:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 348E720829 for ; Sun, 29 Nov 2020 16:08:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PIxXXNg+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387495AbgK2QIN (ORCPT ); Sun, 29 Nov 2020 11:08:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387477AbgK2QIL (ORCPT ); Sun, 29 Nov 2020 11:08:11 -0500 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5120C061A4B; Sun, 29 Nov 2020 08:07:11 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id b10so7318144pfo.4; Sun, 29 Nov 2020 08:07:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5CycBkayIPEKy8ugUk9noRpeNNqE1DQEMX4hGWZ348I=; b=PIxXXNg+pnWRPHUK0/ek9Amg+GWPUzIPcCxMkrD0JgekPFsMvsn2tea/kJpNr42GwR ETzQTHgxZgqXz35xtWHca1u+uz7B6tcFDgi8vdlX4FIe0hihQZcTMYzOtIAaixeJqJ87 2pdHicfjVOaB/iQs4UprYt0kSO6jhYN5ZKmmoOD01j5M+M1PMxR8km8HOcZ1AMLRaPjZ 1yI/Ls++eDxbTRMYUOsCI/YDM40HcuwPo8Tljpgkkof+c1yrpoBDTykrw70B8HFw0yBY yoLMrbB6SXCXf1BZ48jiNT0mO7M8nuv9oKGRfDxvRLN1VkwcQ7hAmsc3+gAyAdyH0gUr VCbw== 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:mime-version:content-transfer-encoding; bh=5CycBkayIPEKy8ugUk9noRpeNNqE1DQEMX4hGWZ348I=; b=A7Mgb1toC1zVKQPLIh7A2gj16MFyOD0xtOwlteSzSyhhXrZlPVguieoqyC3MhOmaKv rpZl806dlGFWjp2wt/rwVRfNN5mKdPXj40BXCjE58mSNRGyGY+LQDHhVE506J0IEFiON vl3v40d8SAsfG0H6lHJtOov27ugUS6bL5Ny8Bticq6XJAiSR8oL1/7X9VsN2wjABKyKJ j56f4v54v5u5CbvLOad5DSBXGdC2Ab4V/wWm9zX+djoTm0WAEDXFHYM7D7hgvIZLa8Z4 +Qiy/rJgrgjw1T+/TZ1w/CSloYAXijXfPzLcpD3ZKdHu56Flq+ccdyaSQhSgz68YtzvS 3TTg== X-Gm-Message-State: AOAM533Axzw75AJx0W6X4XlmLPKH81lEop6O68pZ311MlIhTlZbP2DKS /pafqD4WBWSstBRdH1dp/qg= X-Google-Smtp-Source: ABdhPJz59fCfpH/zm5j8/sl9EhXbXXVXZ2drRtTHFYUB5mfSK3+CUEvrHEB0leb9GFaBg+ZE77H8kg== X-Received: by 2002:a17:90b:3687:: with SMTP id mj7mr1192547pjb.76.1606666031200; Sun, 29 Nov 2020 08:07:11 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.07.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:07:10 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Lee Jones , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/15] usb: misc: iowarrior: update to use the usb_control_msg_{send|recv}() API Date: Sun, 29 Nov 2020 21:36:06 +0530 Message-Id: <20201129160612.1908074-10-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, instances of usb_control_msg() have been replaced with usb_control_msg_{recv|send}() appropriately. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/iowarrior.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c index 70ec29681526..53726fffe5df 100644 --- a/drivers/usb/misc/iowarrior.c +++ b/drivers/usb/misc/iowarrior.c @@ -109,12 +109,12 @@ static int usb_get_report(struct usb_device *dev, struct usb_host_interface *inter, unsigned char type, unsigned char id, void *buf, int size) { - return usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), - USB_REQ_GET_REPORT, - USB_DIR_IN | USB_TYPE_CLASS | - USB_RECIP_INTERFACE, (type << 8) + id, - inter->desc.bInterfaceNumber, buf, size, - GET_TIMEOUT*HZ); + return usb_control_msg_recv(dev, 0, + USB_REQ_GET_REPORT, + USB_DIR_IN | USB_TYPE_CLASS | + USB_RECIP_INTERFACE, (type << 8) + id, + inter->desc.bInterfaceNumber, buf, size, + GET_TIMEOUT*HZ, GFP_KERNEL); } //#endif @@ -123,13 +123,13 @@ static int usb_get_report(struct usb_device *dev, static int usb_set_report(struct usb_interface *intf, unsigned char type, unsigned char id, void *buf, int size) { - return usb_control_msg(interface_to_usbdev(intf), - usb_sndctrlpipe(interface_to_usbdev(intf), 0), - USB_REQ_SET_REPORT, - USB_TYPE_CLASS | USB_RECIP_INTERFACE, - (type << 8) + id, - intf->cur_altsetting->desc.bInterfaceNumber, buf, - size, HZ); + return usb_control_msg_send(interface_to_usbdev(intf), + 0, + USB_REQ_SET_REPORT, + USB_TYPE_CLASS | USB_RECIP_INTERFACE, + (type << 8) + id, + intf->cur_altsetting->desc.bInterfaceNumber, buf, + size, HZ, GFP_KERNEL); } /*---------------------*/ @@ -854,10 +854,10 @@ static int iowarrior_probe(struct usb_interface *interface, /* Set the idle timeout to 0, if this is interface 0 */ if (dev->interface->cur_altsetting->desc.bInterfaceNumber == 0) { - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - 0x0A, - USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, - 0, NULL, 0, USB_CTRL_SET_TIMEOUT); + usb_control_msg_send(udev, 0, + 0x0A, + USB_TYPE_CLASS | USB_RECIP_INTERFACE, 0, + 0, NULL, 0, USB_CTRL_SET_TIMEOUT, GFP_KERNEL); } /* allow device read and ioctl */ dev->present = 1; From patchwork Sun Nov 29 16:06:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939197 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 C3967C71156 for ; Sun, 29 Nov 2020 16:08:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8B97C20829 for ; Sun, 29 Nov 2020 16:08:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qr+FI5l1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387518AbgK2QIP (ORCPT ); Sun, 29 Nov 2020 11:08:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387477AbgK2QIO (ORCPT ); Sun, 29 Nov 2020 11:08:14 -0500 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFE00C0613CF; Sun, 29 Nov 2020 08:07:14 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id b6so8722117pfp.7; Sun, 29 Nov 2020 08:07:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bgdeRrn/rBQnDRJ3mL6h7kSEUvCqL6QpWixhCtowYGU=; b=qr+FI5l194+d+QM2vNdpKDJu5l5aSlTiazCzx9nRfePYryhUbJGMJdxF+STdfR+y8I eL8z3JQdPNh75TwgYsYKQpMHeNOMzoHWgG0/y9eF2qwd6md9QnewGv+Rez5Firj5iqaL ttQMv2nc3Me95DZkWeftQUM67bNtGJB2nuzB7tOVVz8BYbfrlT+sNpYHeci6rwQMlisj APBbZNrVNLJcxLfRILXqRihz09riJVhD+u6QKTbwwkV/a9ASrqrbOitYpiR5HyJd0NIN HJ84lWM2SrAr8G19o2gbNQ2xKA1y6duFuEkaDf/GFTCz+Xq/dGh4cXyvrMOegn1hQYSI JvjA== 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:mime-version:content-transfer-encoding; bh=bgdeRrn/rBQnDRJ3mL6h7kSEUvCqL6QpWixhCtowYGU=; b=CtfladR8A795EqX7El89g6YqZhNaEC4aPnYXg1CbMEhb3X4ydH6JiCL8NB268dHMP2 Bm98Pmlb/1TrkSMaCGa0xCDm0FODsCtq0NihlxmmkQhahFMJ4NJY57t6qTDvESOghKaP tCKXQcXNAub2yiXEWyh32z1dJ6IRsYWNKfm6HNglgibnkjIKBKutzqaBV4ZumX3fKjtf o2Bu07E36Y/X1b1LYc/mcPy5icY0SzViAg0zQZ9x1A+PN6GTum/NTphkymQn5gfUv5ha e55o+4Ykua4qS30j/NMuUQssg02JlhB7LqQ3btddEHQP/pjEU8QdosXJyq/O6GNcv87n fUMQ== X-Gm-Message-State: AOAM532pumUA3exr4KkHQkpMt5T+ZEGb2DI56Zhk28CbdKQdmmT+AvsS ITqHSeqKUC53EXKO0GA+SHk= X-Google-Smtp-Source: ABdhPJz7v8pqOW8HbAt4OAC8CJIPaQr22L2+ae0oPP67b13Heqip3VN/9OBZhY8k6g10Rc9FEbsKrQ== X-Received: by 2002:a17:90a:fcc:: with SMTP id 70mr8498192pjz.168.1606666034208; Sun, 29 Nov 2020 08:07:14 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:07:13 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/15] usb: misc: isight_firmware: update to use usb_control_msg_send() Date: Sun, 29 Nov 2020 21:36:07 +0530 Message-Id: <20201129160612.1908074-11-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, the instances of usb_control_msg() have been replaced with usb_control_msg_send(), and return value checking has also been appropriately enforced. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/isight_firmware.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/usb/misc/isight_firmware.c b/drivers/usb/misc/isight_firmware.c index 4d30095d6ad2..d3fa6fa81e6c 100644 --- a/drivers/usb/misc/isight_firmware.c +++ b/drivers/usb/misc/isight_firmware.c @@ -53,11 +53,11 @@ static int isight_firmware_load(struct usb_interface *intf, ptr = firmware->data; buf[0] = 0x01; - if (usb_control_msg - (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, buf, 1, - 300) != 1) { + ret = usb_control_msg_send(dev, 0, 0xa0, 0x40, 0xe600, + 0, buf, 1, 300, GFP_KERNEL); + if (ret != 0) { printk(KERN_ERR - "Failed to initialise isight firmware loader\n"); + "Failed to initialise isight firmware loader\n"); ret = -ENODEV; goto out; } @@ -86,11 +86,11 @@ static int isight_firmware_load(struct usb_interface *intf, ptr += llen; - if (usb_control_msg - (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, req, 0, - buf, llen, 300) != llen) { + ret = usb_control_msg_send(dev, 0, 0xa0, 0x40, req, 0, + buf, llen, 300, GFP_KERNEL); + if (ret != 0) { printk(KERN_ERR - "Failed to load isight firmware\n"); + "Failed to load isight firmware\n"); ret = -ENODEV; goto out; } @@ -99,9 +99,9 @@ static int isight_firmware_load(struct usb_interface *intf, } buf[0] = 0x00; - if (usb_control_msg - (dev, usb_sndctrlpipe(dev, 0), 0xa0, 0x40, 0xe600, 0, buf, 1, - 300) != 1) { + ret = usb_control_msg_send(dev, 0, 0xa0, 0x40, 0xe600, + 0, buf, 1, 300, GFP_KERNEL); + if (ret != 0) { printk(KERN_ERR "isight firmware loading completion failed\n"); ret = -ENODEV; } From patchwork Sun Nov 29 16:06:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939203 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 8E3B0C83013 for ; Sun, 29 Nov 2020 16:08:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 590382080C for ; Sun, 29 Nov 2020 16:08:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LRMgPa2d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387477AbgK2QIV (ORCPT ); Sun, 29 Nov 2020 11:08:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728236AbgK2QIU (ORCPT ); Sun, 29 Nov 2020 11:08:20 -0500 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AEA3C061A4C; Sun, 29 Nov 2020 08:07:18 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id b23so5088900pls.11; Sun, 29 Nov 2020 08:07:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ulF9m3lqljtgmnGhz+SzghBzSRKlHANlsmi6yEyMAeU=; b=LRMgPa2dW5KmBLDrlMn8DAlzYuuCRsoXCIZVDU/n1JTBvWM5lPI8PUKoSl0GAvVhqf sJo/NOOweogMOpuK4Y7GpetLA0ee064PrQqEkIdCN9fpJNgmnnOhbO2sxxu3yN6pbJL7 VmWDEQTikyWSE0M/zenKQqYCJ9FwEET/FhPShQIBXs6UiTUEl5NHDNz1E5KiCdwbhRNe mFpdIf9PFijkovCghAQB8kU5uSoUxBM/GnQETMAeR6OikXXwDQAWirCTnGKaFcBHxlMx DYckY+ezfq7FC/kSPfUu8SK15SF2c8Ys1Mhh34fMMPFBHbokcRkMBJJ84HJkb/1Y1Eub UrWg== 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:mime-version:content-transfer-encoding; bh=ulF9m3lqljtgmnGhz+SzghBzSRKlHANlsmi6yEyMAeU=; b=FmfjljMLVe/JzW64rVZA54/F0XodVxqZbU+O1+g9EipaTsYORTkn5boCwuHnA27REU k9DPPjgQZmTcHUR8GbHo1RDfGGvWIQnpTXsv5erpedqyq1yF8JrbNSk6GD25W3osqzdO 3aHbYXynoOvXYpPxThwcy0TEuL7/EG8LNCmJsrrUfK+WLvFBRL63jraXsM399ur7Zt+K BST448ZC3s1sCfW5UvlWAPmFvDworhSJqrk3Kd3FUAkWngw7tDHUS/YtiL0pODWEZAjF TWR9Pjt8dDi6Fe7xFTLMLkT+878tb0qWlgkh3nXR4nws4dejbuSFIEBFNGx1YI5iYIQz pRRQ== X-Gm-Message-State: AOAM531N5GECxAblfBm/21JDSjgGuTFsGU8AjX+QKwSoOODY9mvn9Bui jJTi6Bydk+NWeonkGzdeM/w= X-Google-Smtp-Source: ABdhPJyKtNmL5wNGicC6Geed00X/lthoJxMcyxq1jRzaURDjTcMrD+MgRLqJfnkUSchyiGmL2Wzt2A== X-Received: by 2002:a17:902:76c5:b029:d6:a399:8231 with SMTP id j5-20020a17090276c5b02900d6a3998231mr14718033plt.3.1606666037690; Sun, 29 Nov 2020 08:07:17 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:07:16 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Lee Jones , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/15] usb: misc: ldusb: update to use usb_control_msg_send() Date: Sun, 29 Nov 2020 21:36:08 +0530 Message-Id: <20201129160612.1908074-12-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, the instance of usb_control_msg_send() has been replaced with usb_control_msg_send() appropriately. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/ldusb.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 670e4d91e9ca..259ead4edecb 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c @@ -573,15 +573,13 @@ static ssize_t ld_usb_write(struct file *file, const char __user *buffer, } if (dev->interrupt_out_endpoint == NULL) { - /* try HID_REQ_SET_REPORT=9 on control_endpoint instead of interrupt_out_endpoint */ - retval = usb_control_msg(interface_to_usbdev(dev->intf), - usb_sndctrlpipe(interface_to_usbdev(dev->intf), 0), - 9, + retval = usb_control_msg_send(interface_to_usbdev(dev->intf), + 0, 9, USB_TYPE_CLASS | USB_RECIP_INTERFACE | USB_DIR_OUT, 1 << 8, 0, dev->interrupt_out_buffer, bytes_to_write, - USB_CTRL_SET_TIMEOUT); + USB_CTRL_SET_TIMEOUT, GFP_KERNEL); if (retval < 0) dev_err(&dev->intf->dev, "Couldn't submit HID_REQ_SET_REPORT %d\n", From patchwork Sun Nov 29 16:06:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939201 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 4A9C1C83012 for ; Sun, 29 Nov 2020 16:08:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 13B122080C for ; Sun, 29 Nov 2020 16:08:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UsLqSkHn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387542AbgK2QIT (ORCPT ); Sun, 29 Nov 2020 11:08:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387477AbgK2QIQ (ORCPT ); Sun, 29 Nov 2020 11:08:16 -0500 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D96EC061A4F; Sun, 29 Nov 2020 08:07:21 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id u2so5082411pls.10; Sun, 29 Nov 2020 08:07:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YPy8zFLlglB838C7tV9i9EHJFUbRPp+lFfFEzIzekqU=; b=UsLqSkHna5sXWVzuKrVgppWT+IiSxGI8Ye2QkutFSAJMzs4UBFsHtmEsLUskW40osj 7wTdbQ/f6VPMSekNcvpabRAB3uYV9geKhaxac59negrmmqAtUeK6NuXZi2ktx6pUYTm4 G8WenEs1BCN1I5QCXfiBQCE0gdeHe2uNmhLI0KInzZeFpqedkaFVYcNLrvOdOdgKQs9S KEpRceI/r9r7YnSCbYMU/8c8kR6d1b4FGCD+Jf0I9aX6tJpxy0M+IQ4fJvQ8aBIVfK4z rTgxIzkX/8HALXYfZXKZkEUGFP/Xj+yfpc8OlrGX3PGuqexXwW4AntWmEvh6Rl2R/T06 De3w== 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:mime-version:content-transfer-encoding; bh=YPy8zFLlglB838C7tV9i9EHJFUbRPp+lFfFEzIzekqU=; b=Qt4bkVCOiZxxAdwR1NVzNt+pfz02ON1ST5FWMFTp2mCIN9ovpvWsmG6VImmhv2NLSU ZBjYYW+X2K2pUnpWCM0LoI38TwU89tDxZq/D0ViBZIiiv8R2U0d0Ce0ILS2fsJ+h7dNb l1N7u22NDN8G2aNPG6zqTOhghwchU+8hCmdqLV8PTTfy25Ti6P5rSy0x9sclN7+xBh2q qBXAqB2WwqOdJZarmfMkTVtoSOYxCvyXxa0maHeGqZKoPmDGS1VP64aDavvSsuTmkXQX AKjOmUym8pjvbpCeOYYdBKbNmSWy/n4ZxD4QRdhpVTUvimEs5yPUWrBXwJouJpo+uLml nxcw== X-Gm-Message-State: AOAM533FupfdpekP/Oi+nt339gqopzEjtt6tXBELCC0VPAP1ntsFMiYB u72oQMciUObgZ6JZO5M8ODFInIJJgjvSTOmtyWk= X-Google-Smtp-Source: ABdhPJwHf+z5//Kl5e1uIGdUj4cb7W+atRQzYlx0xbfR+lzfORAbIm55rvuAdho3NfuPJ6F/4eUEGA== X-Received: by 2002:a17:902:744b:b029:da:74ca:b5f2 with SMTP id e11-20020a170902744bb02900da74cab5f2mr1682534plt.22.1606666041015; Sun, 29 Nov 2020 08:07:21 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:07:20 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Evgeny Novikov , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/15] usb: misc: lvstest: update to use the usb_control_msg_{send|recv}() API Date: Sun, 29 Nov 2020 21:36:09 +0530 Message-Id: <20201129160612.1908074-13-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, instances of usb_control_msg() have been replaced with usb_control_msg_{recv|send}() and the return value checking conditions have also been modified appropriately. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/lvstest.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c index f8686139d6f3..ab08483258d2 100644 --- a/drivers/usb/misc/lvstest.c +++ b/drivers/usb/misc/lvstest.c @@ -85,17 +85,17 @@ static void destroy_lvs_device(struct usb_device *udev) static int lvs_rh_clear_port_feature(struct usb_device *hdev, int port1, int feature) { - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), + return usb_control_msg_send(hdev, 0, USB_REQ_CLEAR_FEATURE, USB_RT_PORT, feature, port1, - NULL, 0, 1000); + NULL, 0, 1000, GFP_KERNEL); } static int lvs_rh_set_port_feature(struct usb_device *hdev, int port1, int feature) { - return usb_control_msg(hdev, usb_sndctrlpipe(hdev, 0), + return usb_control_msg_send(hdev, 0, USB_REQ_SET_FEATURE, USB_RT_PORT, feature, port1, - NULL, 0, 1000); + NULL, 0, 1000, GFP_KERNEL); } static ssize_t u3_entry_store(struct device *dev, @@ -271,10 +271,10 @@ static ssize_t get_dev_desc_store(struct device *dev, goto free_desc; } - ret = usb_control_msg(udev, (PIPE_CONTROL << 30) | USB_DIR_IN, - USB_REQ_GET_DESCRIPTOR, USB_DIR_IN, USB_DT_DEVICE << 8, - 0, descriptor, sizeof(*descriptor), - USB_CTRL_GET_TIMEOUT); + ret = usb_control_msg_recv(udev, 0, USB_REQ_GET_DESCRIPTOR, + USB_DIR_IN, USB_DT_DEVICE << 8, + 0, descriptor, sizeof(*descriptor), + USB_CTRL_GET_TIMEOUT, GFP_KERNEL); if (ret < 0) dev_err(dev, "can't read device descriptor %d\n", ret); @@ -336,10 +336,10 @@ static void lvs_rh_work(struct work_struct *work) /* Examine each root port */ for (i = 1; i <= descriptor->bNbrPorts; i++) { - ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), + ret = usb_control_msg_recv(hdev, 0, USB_REQ_GET_STATUS, USB_DIR_IN | USB_RT_PORT, 0, i, - port_status, sizeof(*port_status), 1000); - if (ret < 4) + port_status, sizeof(*port_status), 1000, GFP_KERNEL); + if (ret < 0) continue; portchange = le16_to_cpu(port_status->wPortChange); @@ -420,13 +420,13 @@ static int lvs_rh_probe(struct usb_interface *intf, usb_set_intfdata(intf, lvs); /* how many number of ports this root hub has */ - ret = usb_control_msg(hdev, usb_rcvctrlpipe(hdev, 0), + ret = usb_control_msg_recv(hdev, 0, USB_REQ_GET_DESCRIPTOR, USB_DIR_IN | USB_RT_HUB, USB_DT_SS_HUB << 8, 0, &lvs->descriptor, - USB_DT_SS_HUB_SIZE, USB_CTRL_GET_TIMEOUT); - if (ret < (USB_DT_HUB_NONVAR_SIZE + 2)) { + USB_DT_SS_HUB_SIZE, USB_CTRL_GET_TIMEOUT, GFP_KERNEL); + if (ret < 0) { dev_err(&hdev->dev, "wrong root hub descriptor read %d\n", ret); - return ret < 0 ? ret : -EINVAL; + return ret; } /* submit urb to poll interrupt endpoint */ From patchwork Sun Nov 29 16:06:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939199 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 2677EC8300F for ; Sun, 29 Nov 2020 16:08:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E512E20829 for ; Sun, 29 Nov 2020 16:08:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nMsPwpWl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726669AbgK2QIT (ORCPT ); Sun, 29 Nov 2020 11:08:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387527AbgK2QIQ (ORCPT ); Sun, 29 Nov 2020 11:08:16 -0500 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81995C061A51; Sun, 29 Nov 2020 08:07:24 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id b23so5088975pls.11; Sun, 29 Nov 2020 08:07:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dyffzvu2x+IL6U+7i1kbp8EqPJ/1pVi63LQoMYA85l0=; b=nMsPwpWlX30Gdz+D4p5oJnKAalzTiXcWuDf3LvY4/Wu73B9BkGvZb4XjRCS8IpbBwk AlBgYK04qm0F5GbDkzzY/UutaY9u+SK2KzvH/9PvU8P+QCGkUKaoed/VQv6qneu+C2ht tnPDf3C/EG+/nglY4Nm1u9c6mXdC9TrUO8GWfUq0UXpFN2whCvlUMY4e/sRoGkYXSpsK mNIIRPRdxoopDkfSyo+27Xid300gt/NQ5lrOcAAPeYIcIALkh73aK4agLYbE+A1GEnbp 7vUtNMeSXozuYEo5Mie1PbxuhZGT+U4AApAKAFxfS37GnJEIJ+Stowlod00WKDYP05aM jKXg== 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:mime-version:content-transfer-encoding; bh=Dyffzvu2x+IL6U+7i1kbp8EqPJ/1pVi63LQoMYA85l0=; b=jaUZ0O6Xi/9eXypj7EcLu06GfTcrL2meuzICjQQZZLsC7qJZnn3KVfw6WaK6zmMslN TF0H3mA85iaAgtdRJnFoqlPcnUMnXzlVqRK+pL5f1hz21JYPDjMJM4mW3uFai+lYDOR9 s3q/HUxPOcpV98knaupFhGnWZ7BOuVeIdbfzZM6XDOsHL4PCdduB/eh3vGF+nYbUTEki Gt1HoS9NgqwQai7hXfXrVa3JePtuXzrYWFevZhI1Y9/36IClUbA6T05SpJmh9QmjiXz0 Z1QzNrJKQAjN50wRvbbVcRW5q+ZASvxd6N1aMfAnp1j3/B6PMD2m3WTz3EBnnBThmnxY Ee2w== X-Gm-Message-State: AOAM5333Dmx8OfSQ/phKYBPowbKY/IaR20ix06jRZXUis0O+uebN413u hJEOU9MRsr7stvH9mvmPS0TUlcgi8gCv0KYsPiM= X-Google-Smtp-Source: ABdhPJyo3SMxgU0SiNj6hrUlwAvMCQAi4hrhDk3yQETtLUBO9+uDp4nUnHXvo3Dov36OtFQ0WxnOAw== X-Received: by 2002:a17:902:aa8e:b029:da:1c87:e1a7 with SMTP id d14-20020a170902aa8eb02900da1c87e1a7mr15008136plr.40.1606666043964; Sun, 29 Nov 2020 08:07:23 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.07.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:07:23 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/15] usb: misc: trancevibrator: update to use usb_control_msg_send() Date: Sun, 29 Nov 2020 21:36:10 +0530 Message-Id: <20201129160612.1908074-14-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, the instance of usb_control_msg() has been replaced with usb_control_msg_send() and the return value checking condition has also been modified appropriately. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/trancevibrator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index a3dfc77578ea..2c36ee249b4b 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c @@ -59,12 +59,12 @@ static ssize_t speed_store(struct device *dev, struct device_attribute *attr, dev_dbg(&tv->udev->dev, "speed = %d\n", tv->speed); /* Set speed */ - retval = usb_control_msg(tv->udev, usb_sndctrlpipe(tv->udev, 0), + retval = usb_control_msg_send(tv->udev, 0, 0x01, /* vendor request: set speed */ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_OTHER, tv->speed, /* speed value */ - 0, NULL, 0, USB_CTRL_GET_TIMEOUT); - if (retval) { + 0, NULL, 0, USB_CTRL_GET_TIMEOUT, GFP_KERNEL); + if (retval == 0) { tv->speed = old; dev_dbg(&tv->udev->dev, "retval = %d\n", retval); return retval; From patchwork Sun Nov 29 16:06:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939191 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 43596C71156 for ; Sun, 29 Nov 2020 16:08:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 10B712080C for ; Sun, 29 Nov 2020 16:08:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="uTtCl40E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387461AbgK2QIJ (ORCPT ); Sun, 29 Nov 2020 11:08:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387408AbgK2QII (ORCPT ); Sun, 29 Nov 2020 11:08:08 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 891C1C0613D2; Sun, 29 Nov 2020 08:07:27 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id k11so8425270pgq.2; Sun, 29 Nov 2020 08:07:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xJaJ+n9dxBN9XvisaJB9i6SIdnN8VB9cyAZ8b/vmHqM=; b=uTtCl40EyY1q+sS4wPaENTllPz8QahDq5kyaxqJZPeeFZMW8yonUWc3I0ncT8Dfwae e0hAy1KUVOM4Uq+P9TZc9bD47P45KF55hyVmhHNUAodsFpJwW89ciuoyg2o4dq9a9TVj DAxMiPssZFn1GZiWcH/2SqGbhXiep5Z7wW553blUMFcA2bsjdphMfgjFNemM2HYwj4eM CiY3nKbuIwA1Hjfdjp5oZK9lr8XSeyB59H3kfcGWAg02q91AWfKJkf48hgpFl5ybOIAR w0uLsWh++9BaYeewOptPmoDgPzS1WJvRWSOqMbmWR53GB077sRVTo1G7e00A5q/WbYLm GcRg== 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:mime-version:content-transfer-encoding; bh=xJaJ+n9dxBN9XvisaJB9i6SIdnN8VB9cyAZ8b/vmHqM=; b=TnOaI/hNLxgZiBuVpJfEgt10adhi6hME5hQJAYLJQpLkIc41iqLdvqOOBpCjGnhGxx BK6IX8g9blGmXeKuBK0IviUSCdnqAmOgrLTSpHh6XDZrH0Njm104i/weJVbOpQyuL4lo cxhPy/nhA0AuBaIW+/cQBj//bRVwQraKf7Y898zPWSJzv7qqvFDItZexYQxjAl2/TXTT Er7vIrC6NSgMgiY/+ZnXGu56B/nKlQY4f0gkvQzdUFKsB43rmDNO4ivngatToVrENC8T LJ0Lk/PbsvSQRzo5/Yl4B4mexvVZ8280oGmQ+udfKQKUd2EHXBiC/PgCF5mI4jy5RuyZ qA5g== X-Gm-Message-State: AOAM530SK/6CJloFvxSEFTwCs/eyftyCFcDX6H04Ti5wSNShxiY744n8 ejPsZ2nLJ2llUdPDa25rpCo= X-Google-Smtp-Source: ABdhPJyp3LW5aJBiIXX0HT3urNa6kc/g2TQ4lDrB7freuZHcjFOqyQblfvRa7mWUpBdwAQTgYxauHw== X-Received: by 2002:a17:90a:e610:: with SMTP id j16mr3172079pjy.170.1606666047040; Sun, 29 Nov 2020 08:07:27 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.07.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:07:26 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/15] usb: misc: usbsevseg: update to use usb_control_msg_send() Date: Sun, 29 Nov 2020 21:36:11 +0530 Message-Id: <20201129160612.1908074-15-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, instances of usb_control_msg() have been replaced with usb_control_msg_send() appropriately. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/usbsevseg.c | 52 +++++++++++------------------------- 1 file changed, 16 insertions(+), 36 deletions(-) diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c index 551074f5b7ad..f0f6728a8b54 100644 --- a/drivers/usb/misc/usbsevseg.c +++ b/drivers/usb/misc/usbsevseg.c @@ -74,15 +74,10 @@ static void update_display_powered(struct usb_sevsegdev *mydev) if (mydev->shadow_power != 1) return; - rc = usb_control_msg(mydev->udev, - usb_sndctrlpipe(mydev->udev, 0), - 0x12, - 0x48, - (80 * 0x100) + 10, /* (power mode) */ - (0x00 * 0x100) + (mydev->powered ? 1 : 0), - NULL, - 0, - 2000); + rc = usb_control_msg_send(mydev->udev, 0, 0x12, 0x48, + (80 * 0x100) + 10, /* (power mode) */ + (0x00 * 0x100) + (mydev->powered ? 1 : 0), + NULL, 0, 2000, GFP_KERNEL); if (rc < 0) dev_dbg(&mydev->udev->dev, "power retval = %d\n", rc); @@ -99,15 +94,10 @@ static void update_display_mode(struct usb_sevsegdev *mydev) if(mydev->shadow_power != 1) return; - rc = usb_control_msg(mydev->udev, - usb_sndctrlpipe(mydev->udev, 0), - 0x12, - 0x48, - (82 * 0x100) + 10, /* (set mode) */ - (mydev->mode_msb * 0x100) + mydev->mode_lsb, - NULL, - 0, - 2000); + rc = usb_control_msg_send(mydev->udev, 0, 0x12, 0x48, + (82 * 0x100) + 10, /* (set mode) */ + (mydev->mode_msb * 0x100) + mydev->mode_lsb, + NULL, 0, 2000, GFP_KERNEL); if (rc < 0) dev_dbg(&mydev->udev->dev, "mode retval = %d\n", rc); @@ -131,15 +121,10 @@ static void update_display_visual(struct usb_sevsegdev *mydev, gfp_t mf) for (i = 0; i < mydev->textlength; i++) buffer[i] = mydev->text[mydev->textlength-1-i]; - rc = usb_control_msg(mydev->udev, - usb_sndctrlpipe(mydev->udev, 0), - 0x12, - 0x48, - (85 * 0x100) + 10, /* (write text) */ - (0 * 0x100) + mydev->textmode, /* mode */ - buffer, - mydev->textlength, - 2000); + rc = usb_control_msg_send(mydev->udev, 0, 0x12, 0x48, + (85 * 0x100) + 10, /* (write text) */ + (0 * 0x100) + mydev->textmode, /* mode */ + buffer, mydev->textlength, 2000, GFP_KERNEL); if (rc < 0) dev_dbg(&mydev->udev->dev, "write retval = %d\n", rc); @@ -150,15 +135,10 @@ static void update_display_visual(struct usb_sevsegdev *mydev, gfp_t mf) for (i = 0; i < sizeof(mydev->decimals); i++) decimals |= mydev->decimals[i] << i; - rc = usb_control_msg(mydev->udev, - usb_sndctrlpipe(mydev->udev, 0), - 0x12, - 0x48, - (86 * 0x100) + 10, /* (set decimal) */ - (0 * 0x100) + decimals, /* decimals */ - NULL, - 0, - 2000); + rc = usb_control_msg_send(mydev->udev, 0, 0x12, 0x48, + (86 * 0x100) + 10, /* (set decimal) */ + (0 * 0x100) + decimals, /* decimals */ + NULL, 0, 2000, GFP_KERNEL); if (rc < 0) dev_dbg(&mydev->udev->dev, "decimal retval = %d\n", rc); From patchwork Sun Nov 29 16:06:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939193 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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 ED211C3E8C5 for ; Sun, 29 Nov 2020 16:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A6CCC2080C for ; Sun, 29 Nov 2020 16:08:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LiqGJ3Ba" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387484AbgK2QIM (ORCPT ); Sun, 29 Nov 2020 11:08:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387455AbgK2QIJ (ORCPT ); Sun, 29 Nov 2020 11:08:09 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17834C0613D4; Sun, 29 Nov 2020 08:07:32 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id s63so8401581pgc.8; Sun, 29 Nov 2020 08:07:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SXDwYZccsmVjSKXYJgsER+W1djN2DPbdJ+Caqbf/CLM=; b=LiqGJ3Basd+o8GXxdzaegEJjaPUcn2K6UUcgPqMO6Vl2xvPjftQokmLKEW/uAjgBiq A0VDTbVQM3f/adOhjCptRfD4djJdUlbpDUKY2gLdIBZqHwzrszCfoH56cn6BsJZUYuHI 42Lxw81t2ivttnfThvE/zU5aZVVnzBMPfTT0S6arpi7/BbxgfpK5Ewjnxgb4FnS7MQ5/ AAUmiTcwb0u3OI6UYsCf1aasPWOvuibWaVCyCBNvfCGNzQ9uziAOpLDGDL3E6hRb+Kr3 2lVI3dLDytfUpwDWsCRrmV8IL7Xlal6xBcRCT8xgaa55PAcdnHZ5TfujlsJjFy0iJ/UT lZoQ== 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:mime-version:content-transfer-encoding; bh=SXDwYZccsmVjSKXYJgsER+W1djN2DPbdJ+Caqbf/CLM=; b=Nt0Q0lQv1Yk4FjD2px8jIl5aYlJVYU01q0vNCT1ky2EhOHR1mXOCIU8BaI5BHhW7W0 ps9afSplOf5bZyRI5EvhsQvYagAZP6m+1x9Gyl6PYSjvMEPfAn9q3rk7eYKrUEL9rGgA UNdhyGwVlN/ArNdym9+hppMn/yivzV41uQ6bRHI10INBVi4UB+hGof0ljq8Ivezq1W6U VRlFhTAC9ojkrD5ODmoeCdQ8iTNnBt2HyLms1YMHCv+AeSWNdJvQBAvdXtn71uTvjJYl 39uc1sG0gLv9bS1RzB0Jb7e4Jdj8mTfxuAZDSO+tfVOMIdruVVLERA1/NoUIxCkJaeFC PpqA== X-Gm-Message-State: AOAM531Rs8XH6XNjbtirkH7lHy0vkd+8xU3QrYW3XKP+MesbFyUvKecs ZH/TDl3I5TdEqHDRLPQ/Q7w= X-Google-Smtp-Source: ABdhPJw8IiGB+Ahaz7KAq8VBFiFRibfdRL/fPLzsFugA+tGfqMm1FaGF+vZpzqwJDKizPlqC5owhkQ== X-Received: by 2002:a17:90b:3698:: with SMTP id mj24mr1472626pjb.149.1606666051529; Sun, 29 Nov 2020 08:07:31 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id u3sm13496837pfu.47.2020.11.29.08.07.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 08:07:30 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Alan Stern , "Gustavo A. R. Silva" , Zqiang , Bixuan Cui , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/15] usb: misc: usbtest: update to use the usb_control_msg_{send|recv}() API Date: Sun, 29 Nov 2020 21:36:12 +0530 Message-Id: <20201129160612.1908074-16-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> References: <20201129160612.1908074-1-anant.thazhemadam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The newer usb_control_msg_{send|recv}() API are an improvement on the existing usb_control_msg() as it ensures that a short read/write is treated as an error, data can be used off the stack, and raw usb pipes need not be created in the calling functions. For this reason, instances of usb_control_msg() have been replaced with usb_control_msg_{recv|send}() and the return value checking conditions have also been modified appropriately. Signed-off-by: Anant Thazhemadam --- drivers/usb/misc/usbtest.c | 63 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 150090ee4ec1..e44ec5261d82 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -672,10 +672,11 @@ static int get_altsetting(struct usbtest_dev *dev) struct usb_device *udev = interface_to_usbdev(iface); int retval; - retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - USB_REQ_GET_INTERFACE, USB_DIR_IN|USB_RECIP_INTERFACE, - 0, iface->altsetting[0].desc.bInterfaceNumber, - dev->buf, 1, USB_CTRL_GET_TIMEOUT); + retval = usb_control_msg_recv(udev, 0, USB_REQ_GET_INTERFACE, + USB_DIR_IN|USB_RECIP_INTERFACE, + 0, iface->altsetting[0].desc.bInterfaceNumber, + dev->buf, 1, USB_CTRL_GET_TIMEOUT, GFP_KERNEL); + switch (retval) { case 1: return dev->buf[0]; @@ -685,6 +686,11 @@ static int get_altsetting(struct usbtest_dev *dev) default: return retval; } + + if (retval < 0) + return retval; + + return dev->buf[0]; } static int set_altsetting(struct usbtest_dev *dev, int alternate) @@ -872,14 +878,15 @@ static int ch9_postconfig(struct usbtest_dev *dev) * ... although some cheap devices (like one TI Hub I've got) * won't return config descriptors except before set_config. */ - retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - USB_REQ_GET_CONFIGURATION, - USB_DIR_IN | USB_RECIP_DEVICE, - 0, 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT); - if (retval != 1 || dev->buf[0] != expected) { + retval = usb_control_msg_recv(udev, 0, USB_REQ_GET_CONFIGURATION, + USB_DIR_IN | USB_RECIP_DEVICE, 0, + 0, dev->buf, 1, USB_CTRL_GET_TIMEOUT, + GFP_KERNEL); + + if (retval != 0 || dev->buf[0] != expected) { dev_err(&iface->dev, "get config --> %d %d (1 %d)\n", retval, dev->buf[0], expected); - return (retval < 0) ? retval : -EDOM; + return retval; } } @@ -1683,10 +1690,10 @@ static int test_halt(struct usbtest_dev *tdev, int ep, struct urb *urb) return retval; /* set halt (protocol test only), verify it worked */ - retval = usb_control_msg(urb->dev, usb_sndctrlpipe(urb->dev, 0), - USB_REQ_SET_FEATURE, USB_RECIP_ENDPOINT, - USB_ENDPOINT_HALT, ep, - NULL, 0, USB_CTRL_SET_TIMEOUT); + retval = usb_control_msg_send(urb->dev, 0, USB_REQ_SET_FEATURE, + USB_RECIP_ENDPOINT, USB_ENDPOINT_HALT, + ep, NULL, 0, USB_CTRL_SET_TIMEOUT, + GFP_KERNEL); if (retval < 0) { ERROR(tdev, "ep %02x couldn't set halt, %d\n", ep, retval); return retval; @@ -1845,30 +1852,22 @@ static int ctrl_out(struct usbtest_dev *dev, /* write patterned data */ for (j = 0; j < len; j++) buf[j] = (u8)(i + j); - retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - 0x5b, USB_DIR_OUT|USB_TYPE_VENDOR, - 0, 0, buf, len, USB_CTRL_SET_TIMEOUT); - if (retval != len) { + retval = usb_control_msg_send(udev, 0, 0x5b, + USB_DIR_OUT | USB_TYPE_VENDOR, 0, + 0, buf, len, USB_CTRL_SET_TIMEOUT, + GFP_KERNEL); + if (retval < 0) { what = "write"; - if (retval >= 0) { - ERROR(dev, "ctrl_out, wlen %d (expected %d)\n", - retval, len); - retval = -EBADMSG; - } break; } /* read it back -- assuming nothing intervened!! */ - retval = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - 0x5c, USB_DIR_IN|USB_TYPE_VENDOR, - 0, 0, buf, len, USB_CTRL_GET_TIMEOUT); - if (retval != len) { + retval = usb_control_msg_recv(udev, 0, + 0x5c, USB_DIR_IN|USB_TYPE_VENDOR, + 0, 0, buf, len, USB_CTRL_GET_TIMEOUT, + GFP_KERNEL); + if (retval < 0) { what = "read"; - if (retval >= 0) { - ERROR(dev, "ctrl_out, rlen %d (expected %d)\n", - retval, len); - retval = -EBADMSG; - } break; }