From patchwork Mon Nov 30 01:23:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939453 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 1071BC71155 for ; Mon, 30 Nov 2020 01:24:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFA9A2076A for ; Mon, 30 Nov 2020 01:24:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sOIIrb2g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727158AbgK3BYP (ORCPT ); Sun, 29 Nov 2020 20:24:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbgK3BYO (ORCPT ); Sun, 29 Nov 2020 20:24:14 -0500 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA3BAC0613D3; Sun, 29 Nov 2020 17:23:34 -0800 (PST) Received: by mail-pj1-x1042.google.com with SMTP id t21so311723pjw.2; Sun, 29 Nov 2020 17:23:34 -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=sOIIrb2ge9ByKCOwVRraxrZb42+0eKIIh9/KwI88AapVeOifgOAUSh+SV72ZD7OJiO O7PSp3o5W6g3tU3atxT3nH2r8T+2+/GDb0acoGFnMOEU7/7NgH4rXEvU54V02jRDH8Sg 4XU/XRulSzAUse66AHvXeQYZEgnSOAaaKgrjcmIRS/mwIjRAlYpxDCi/I3BfaMpQ6vYQ TThHuWrIT6NiQuk3VKGw07BWJoAJoB0mZBvoY4J/1CL+QLMjh8nrA0MpytYCnYGKAixc HaY6yjYw1WZ0vnc8UDvvBobyH7Rb7fry7ydyzz7V74bb3SVpQ9w1Mo4m5oiYnKmY5sqI jQ5Q== 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=VkoG/bBZRD+N6kKOk8Hi4zs2xefSAHSW9vD2W8aEJraY3+RRs1qJAHzv3yrePzfvAn ekUMN6KjXTPwaXIu7UNwdTfnRPpJnY0ra9G9TP+CTkH7hpdwF5M3whbsa85HMCG9LXnM sKXGENexEtVxp1Sa21/rzaPvlyuray3svHH/pnTesWcAUcu/PPIbpH662s0joVSqzjTb NF8uDNG7TUxi3ztBo3KRJI20mpwZyHA7COmJlSiR62Jb4mUBjI1NkXo68NY9Q515Sy6D R4AvB5cxLjaN6Ckvsn9NplFcuiU37vOKhcc7dkGC7YXaQJ41GmEQUQF3sAoAL9lBn2xi cJhg== X-Gm-Message-State: AOAM530kcw3YaDsSQCozyxL56ILOgjsMdBcHjtYrocLVpHfbqRgmSBJl y4gpgKui9DsvzJOxmS4NQ6C90wh6LdDzSM7DoO4= X-Google-Smtp-Source: ABdhPJxOEBBAQJP/L/NnOm+nJUbdgvpayTNcNXn28TnZyKKTqgS8CdmZNpNps4+CuhELzP0g9zW+pg== X-Received: by 2002:a17:902:b70d:b029:da:5196:1181 with SMTP id d13-20020a170902b70db02900da51961181mr11610150pls.81.1606699414111; Sun, 29 Nov 2020 17:23:34 -0800 (PST) Received: from localhost.localdomain ([49.207.196.188]) by smtp.gmail.com with ESMTPSA id ds24sm4373196pjb.30.2020.11.29.17.23.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:23:33 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Liu Shixin , Anant Thazhemadam , Xu Wang , "Gustavo A. R. Silva" Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 01/15] usb: misc: appledisplay: update to use the usb_control_msg_{send|recv}() API Date: Mon, 30 Nov 2020 06:53:13 +0530 Message-Id: <20201130012313.2577352-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 Mon Nov 30 01:26: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: 11939457 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 B22B3C64E8A for ; Mon, 30 Nov 2020 01:27:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 558892076A for ; Mon, 30 Nov 2020 01:27:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LWir8t8g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726660AbgK3B1A (ORCPT ); Sun, 29 Nov 2020 20:27:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbgK3B1A (ORCPT ); Sun, 29 Nov 2020 20:27:00 -0500 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 196E2C0613CF; Sun, 29 Nov 2020 17:26:14 -0800 (PST) Received: by mail-pj1-x1043.google.com with SMTP id t21so315393pjw.2; Sun, 29 Nov 2020 17:26: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=OR9wVz2vxGr4uGs0aRUSPWq5Qs/Y5o7RNeRWhP0NrZ0=; b=LWir8t8g7RbKCr3a0p/eiWmOWB/9H4twl/9idxXuEBCLV0BsfN+g3TZgKefOjXjJ7O SOhdtZUMZjLignp5n2FE88mg1ItdFovUEuI5UHlgrNlSixLmPlJ3J0PvVPpMoFmZ9TMj xs0tG4OSPbMQ9IWZ/fhq/i0I6beTeBoPvO5B+u8x40YSvZTMJ1nmOAymvCGKsF/IBJNj Yd9r9SwOFvESCR+OpH8e4Fl5imiDF1l8HsnoG3Sj34GJAc3LWG4Na8rc6Q9M0vUEcdkC QVRuDdmmvZpv1mOHXMFy08m0L7k31eZN2jlnEJJ0Cwi4U9X3tAehQxs6l/TsUfy6PkG4 Y3lQ== 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=OR9wVz2vxGr4uGs0aRUSPWq5Qs/Y5o7RNeRWhP0NrZ0=; b=TJxOHD7k2R5Rw7yMiivqqF/g+ugeINUTSo860xR7D7S7RCmFi9fq2OXZDE6XqCHlWA mV5NW/Fhy1r024y/ZI0mo9CQ/cM1T5c0uafpbN3622KiWPAY1z+4NMROSWUBgUS7e5bn aNq4Z5ior3284Du5vrNzDKd3dYyEZ0WRhwaaYS+vOBNZ0NOd4/GphQiQgIbQPDd6A/4J V21/LRCPm8mh5XnPHpPltbUdjDQbGeaZjshwrorpBincT50AqTXyqhVKqzZxucHaBzHh gnLTGrwHbkFicgVUDeT/RL0HJ48FPNXPNz03TkWEcrP8tDKlhhqg6kaKIIYz6wphRvdN YtlA== X-Gm-Message-State: AOAM533MJRaU7yv83xsoDjmedcF2oRFOeG3gwz1K3644O/OAiMb8jQy8 84BeR9oWYUzZQz5JfeGRjqM= X-Google-Smtp-Source: ABdhPJwWr925SmFwvuhB6QF3+8PzGho6RhqVW0tUlxCEZdRgnljdSJbl9rm3MHBUpsA6KLkKlES3JA== X-Received: by 2002:a17:90b:3594:: with SMTP id mm20mr12032130pjb.121.1606699573510; Sun, 29 Nov 2020 17:26:13 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id a81sm14637227pfd.178.2020.11.29.17.26.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:26:12 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 02/15] usb: misc: cypress_cy7c63: update to use usb_control_msg_recv() Date: Mon, 30 Nov 2020 06:56:05 +0530 Message-Id: <20201130012605.2578511-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c index 14faec51d7a5..76a320ef17a7 100644 --- a/drivers/usb/misc/cypress_cy7c63.c +++ b/drivers/usb/misc/cypress_cy7c63.c @@ -70,24 +70,15 @@ 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*/ - iobuf = kzalloc(CYPRESS_MAX_REQSIZE, GFP_KERNEL); - if (!iobuf) { - retval = -ENOMEM; - goto error; - } + u8 iobuf[CYPRESS_MAX_REQSIZE] = {0}; 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) { @@ -107,8 +98,6 @@ static int vendor_command(struct cypress *dev, unsigned char request, break; } - kfree(iobuf); -error: return retval; } From patchwork Mon Nov 30 01:27:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939459 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 8C2FDC64E8A for ; Mon, 30 Nov 2020 01:28:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2316020757 for ; Mon, 30 Nov 2020 01:28:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jHyddAFS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727185AbgK3B2A (ORCPT ); Sun, 29 Nov 2020 20:28:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726510AbgK3B2A (ORCPT ); Sun, 29 Nov 2020 20:28:00 -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 1893BC0613CF; Sun, 29 Nov 2020 17:27:14 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id bj5so5568840plb.4; Sun, 29 Nov 2020 17:27: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=6xBjojemrIICF/vl8V5tDr3Zp6uDLBqRICYfScnuO8M=; b=jHyddAFSy3yEXVajRASCAZvkgE5J8XfJt3PuzkiIj0wgnWYdQwBSMkQkNTUK1V6FyP Ni1QrhiDfjtExCvtRoQP3tnvY71Md468LX/5R4t139aURisGpid+EkTaRCYv56hZNWYt vsvydHoSxZgU5D5uLfGGD4SnmqWP/DBd6i+5E25MyC2qwRpxFtZowtrLiXExUCpa69wS vAaIlrMZqiC0g5IqblkCDsJ5QSeWoIauUPe8QGLmrJup+ZTxqIK5dt7mo1PZqZR3RBf6 6vdN5cd1vkKZGQplyh2Tp701+hAI4kG5hgAXtPRAzydPxiZAhzV0CqvlKoIjXbh5qAYQ F9yQ== 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=6xBjojemrIICF/vl8V5tDr3Zp6uDLBqRICYfScnuO8M=; b=PTbDg8edImEahpUGG+EHv4bAoHNYzgmZAmWR/e9uIVBoM5H7SpI9q7GAeMzDYvCqPm xFk67JP7+dlTvOwDf7kR2yR4sm/krEUb0Pz4el/cSJH/KhLgBnaQgPHS4+RRaflWj1VS M+v+ewpEZUCrN9BFtrCgRa9DCrO7QWVQ668KQyCG4IQ5jnGbmHKARP2SCVJJirt9LUDS SvcF6vWJVBnHjrUqt1j+2xchuark+UXj96QVAHZHABaKyWeUksFqHsz14djXP+ajnovD DosqRMeFOj/ydE9+9w5fQFSAYpYTG9mIHLZwf56frSZnY938nxC58ig2O+m8VjAep2Tb oxKw== X-Gm-Message-State: AOAM533bbMQ2sSqhcVBnzYudm6hVK8FzRMrhJE5ZY+gMtshT3EFk0xlJ hNb2DRJUcmpPxzYmdBZiPaqX3rKTYGdaI5TeVWw= X-Google-Smtp-Source: ABdhPJymmucrxNeI8pFidRH1l5xI9arCyKp9HE18/dslVeW9nUIsjsxsqhOKs6ifbdlUWoDsAhxcTQ== X-Received: by 2002:a17:902:b691:b029:d8:ebc8:385e with SMTP id c17-20020a170902b691b02900d8ebc8385emr16781522pls.48.1606699633563; Sun, 29 Nov 2020 17:27:13 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id q200sm14341308pfq.95.2020.11.29.17.27.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:27:12 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 03/15] usb: misc: cytherm: update to use usb_control_msg_recv() Date: Mon, 30 Nov 2020 06:57:07 +0530 Message-Id: <20201130012707.2578797-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 | 128 +++++++++++++------------------------ 1 file changed, 43 insertions(+), 85 deletions(-) diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 3e3802aaefa3..2ca36ea5b76a 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); } @@ -78,33 +78,27 @@ static ssize_t brightness_store(struct device *dev, struct device_attribute *att struct usb_interface *intf = to_usb_interface(dev); struct usb_cytherm *cytherm = usb_get_intfdata(intf); - unsigned char *buffer; + unsigned char buffer[8]; int retval; - - buffer = kmalloc(8, GFP_KERNEL); - if (!buffer) - return 0; cytherm->brightness = simple_strtoul(buf, NULL, 10); - + if (cytherm->brightness > 0xFF) cytherm->brightness = 0xFF; else if (cytherm->brightness < 0) cytherm->brightness = 0; - + /* 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); + cytherm->brightness, &buffer, 8); + 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); - - kfree(buffer); - + 0x01, &buffer, 8); + if (!retval) + dev_dbg(&cytherm->udev->dev, "µC informed of change in brightness setting\n"); + return count; } static DEVICE_ATTR_RW(brightness); @@ -120,28 +114,22 @@ static ssize_t temp_show(struct device *dev, struct device_attribute *attr, char struct usb_cytherm *cytherm = usb_get_intfdata(intf); int retval; - unsigned char *buffer; + unsigned char buffer[8]; int temp, sign; - buffer = kmalloc(8, GFP_KERNEL); - if (!buffer) - return 0; - /* read temperature */ - retval = vendor_command(cytherm->udev, READ_RAM, TEMP, 0, buffer, 8); - if (retval) - dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); + retval = vendor_command(cytherm->udev, READ_RAM, TEMP, 0, &buffer, 8); + 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); + retval = vendor_command(cytherm->udev, READ_RAM, SIGN, 0, &buffer, 8); + if (!retval) + dev_dbg(&cytherm->udev->dev, "read sign successfully\n"); sign = buffer[1]; - kfree(buffer); - return sprintf(buf, "%c%i.%i", sign ? '-' : '+', temp >> 1, 5*(temp - ((temp >> 1) << 1))); } @@ -157,21 +145,15 @@ static ssize_t button_show(struct device *dev, struct device_attribute *attr, ch struct usb_cytherm *cytherm = usb_get_intfdata(intf); int retval; - unsigned char *buffer; - - buffer = kmalloc(8, GFP_KERNEL); - if (!buffer) - return 0; + unsigned char buffer[8]; /* check button */ - retval = vendor_command(cytherm->udev, READ_RAM, BUTTON, 0, buffer, 8); - if (retval) - dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); + retval = vendor_command(cytherm->udev, READ_RAM, BUTTON, 0, &buffer, 8); + if (!retval) + dev_dbg(&cytherm->udev->dev, "checked button successfully\n"); retval = buffer[1]; - kfree(buffer); - if (retval) return sprintf(buf, "1"); else @@ -186,20 +168,14 @@ static ssize_t port0_show(struct device *dev, struct device_attribute *attr, cha struct usb_cytherm *cytherm = usb_get_intfdata(intf); int retval; - unsigned char *buffer; - - buffer = kmalloc(8, GFP_KERNEL); - if (!buffer) - return 0; + unsigned char buffer[8]; - retval = vendor_command(cytherm->udev, READ_PORT, 0, 0, buffer, 8); - if (retval) + retval = vendor_command(cytherm->udev, READ_PORT, 0, 0, &buffer, 8); + if (!retval) dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); retval = buffer[1]; - kfree(buffer); - return sprintf(buf, "%d", retval); } @@ -209,28 +185,22 @@ static ssize_t port0_store(struct device *dev, struct device_attribute *attr, co struct usb_interface *intf = to_usb_interface(dev); struct usb_cytherm *cytherm = usb_get_intfdata(intf); - unsigned char *buffer; + unsigned char buffer[8]; int retval; int tmp; - - buffer = kmalloc(8, GFP_KERNEL); - if (!buffer) - return 0; tmp = simple_strtoul(buf, NULL, 10); - + if (tmp > 0xFF) tmp = 0xFF; else if (tmp < 0) tmp = 0; - + retval = vendor_command(cytherm->udev, WRITE_PORT, 0, - tmp, buffer, 8); - if (retval) + tmp, &buffer, 8); + if (!retval) dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); - kfree(buffer); - return count; } static DEVICE_ATTR_RW(port0); @@ -241,19 +211,13 @@ static ssize_t port1_show(struct device *dev, struct device_attribute *attr, cha struct usb_cytherm *cytherm = usb_get_intfdata(intf); int retval; - unsigned char *buffer; + unsigned char buffer[8]; - buffer = kmalloc(8, GFP_KERNEL); - if (!buffer) - return 0; - - retval = vendor_command(cytherm->udev, READ_PORT, 1, 0, buffer, 8); - if (retval) + retval = vendor_command(cytherm->udev, READ_PORT, 1, 0, &buffer, 8); + if (!retval) dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); - - retval = buffer[1]; - kfree(buffer); + retval = buffer[1]; return sprintf(buf, "%d", retval); } @@ -264,13 +228,9 @@ static ssize_t port1_store(struct device *dev, struct device_attribute *attr, co struct usb_interface *intf = to_usb_interface(dev); struct usb_cytherm *cytherm = usb_get_intfdata(intf); - unsigned char *buffer; + unsigned char buffer[8]; int retval; int tmp; - - buffer = kmalloc(8, GFP_KERNEL); - if (!buffer) - return 0; tmp = simple_strtoul(buf, NULL, 10); @@ -278,14 +238,12 @@ static ssize_t port1_store(struct device *dev, struct device_attribute *attr, co tmp = 0xFF; else if (tmp < 0) tmp = 0; - + retval = vendor_command(cytherm->udev, WRITE_PORT, 1, - tmp, buffer, 8); - if (retval) + tmp, &buffer, 8); + if (!retval) dev_dbg(&cytherm->udev->dev, "retval = %d\n", retval); - kfree(buffer); - return count; } static DEVICE_ATTR_RW(port1); From patchwork Mon Nov 30 01:28:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939461 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 F2C85C64E8A for ; Mon, 30 Nov 2020 01:29:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AFF320757 for ; Mon, 30 Nov 2020 01:29:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hI0q5Tyf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727812AbgK3B3O (ORCPT ); Sun, 29 Nov 2020 20:29:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726370AbgK3B3N (ORCPT ); Sun, 29 Nov 2020 20:29:13 -0500 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77831C0613CF; Sun, 29 Nov 2020 17:28:27 -0800 (PST) Received: by mail-pj1-x1041.google.com with SMTP id b12so317985pjl.0; Sun, 29 Nov 2020 17:28: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=adCoA0FX32LVJH0CmgSfN0z9RiJT+SmZNYMtTn4BLVs=; b=hI0q5TyfQpDDb7ywq5cTMebgEanaCmzQpCHbbntM40pxvr0ZObjqBZ7x8cIOi8EsSD JsLvW0zLjlxBFdiOZ4VAakfTJ+dcsHczZLxXv2pUGjifVnIoyA4Dyj7eUGOMTzl+atY9 ndj3tfwh4EyZ3mlySE5nnPYHcw72PAnLmxM1kSooypYLa/2myh0DhlstBwzHdDVV1ha/ /PpH7StVUAEcWLDG8ppV/jmedk9SbjjxPzR04RrGnnPCH6E39vyJ6R7e7JAi53DcxWRe jUXRk3/GqhzHlD2jCF+R3EkBFDTEKt3bzZ8bc1ov/LYSJbuL9MLPxHrXM1kvrupbVxAR djsQ== 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=adCoA0FX32LVJH0CmgSfN0z9RiJT+SmZNYMtTn4BLVs=; b=ta+Gbn0aQn7LZZXwHGuOKqT4BVosgKgDQ3ThqYntmKCUlpC42fcrI83RNjrq+DS0sU 8ExK4wrEnsI3S7pvNsEZ/DLmcAFRZLxAwnraEzL9U2QJ5ywEIL+arbr5Og6dCSGFSxk7 FebZgkajWODaGzWU+aomSXEXNN4WbONagep4E6EwTA5ZkFhABmgDrl/TyI5+pjEhJu2I PAELZVeVCwJZBej9ZJ1TVl+sE1SQii/1dkxtgBceEdmEQoQ4Dw6G28lYRkZ4x0a9W73h y2JsvZwA+2kUKAlQQVwABibIOx9SlqocURAzXZ8f6WMIXkt8iVGe33aaLSktAEcOOAtu 32Qw== X-Gm-Message-State: AOAM5323ReUsOQ30xOaM3vB9gpYEn3MrHmYzBwzolPuYw0CVDvYVIRWl LmbHpmfu+zeuLCEbrtzL8+w= X-Google-Smtp-Source: ABdhPJyIvXXYzDDaT6Me1FDNqZuoQ2wuvK5w8bjSKQkkrHFXKoFsbgzgMqj48mBN1vHci9xnuwEaGA== X-Received: by 2002:a17:902:7d8e:b029:da:274:c75b with SMTP id a14-20020a1709027d8eb02900da0274c75bmr16149204plm.61.1606699706939; Sun, 29 Nov 2020 17:28:26 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id m9sm20825079pjf.20.2020.11.29.17.28.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:28:26 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Matthias Brugger , Bin Liu , Anant Thazhemadam , Minas Harutyunyan , Chunfeng Yun Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH v2 04/15] usb: misc: ehset: update to use the usb_control_msg_{send|recv}() API Date: Mon, 30 Nov 2020 06:58:16 +0530 Message-Id: <20201130012816.2579140-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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/ehset.c | 76 +++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 44 deletions(-) diff --git a/drivers/usb/misc/ehset.c b/drivers/usb/misc/ehset.c index 2752e1f4f4d0..f87890f9cd26 100644 --- a/drivers/usb/misc/ehset.c +++ b/drivers/usb/misc/ehset.c @@ -24,68 +24,57 @@ static int ehset_probe(struct usb_interface *intf, int ret = -EINVAL; struct usb_device *dev = interface_to_usbdev(intf); struct usb_device *hub_udev = dev->parent; - struct usb_device_descriptor *buf; + struct usb_device_descriptor buf; u8 portnum = dev->portnum; u16 test_pid = le16_to_cpu(dev->descriptor.idProduct); 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 */ msleep(15 * 1000); - buf = kmalloc(USB_DT_DEVICE_SIZE, GFP_KERNEL); - 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); - kfree(buf); + 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); break; case TEST_SINGLE_STEP_SET_FEATURE: /* @@ -100,11 +89,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 +100,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 Mon Nov 30 01:28:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939463 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 01D3EC64E8A for ; Mon, 30 Nov 2020 01:30:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B03932076A for ; Mon, 30 Nov 2020 01:29:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k30vK/uV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727733AbgK3B3l (ORCPT ); Sun, 29 Nov 2020 20:29:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgK3B3l (ORCPT ); Sun, 29 Nov 2020 20:29:41 -0500 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3998C0613D2; Sun, 29 Nov 2020 17:28:55 -0800 (PST) Received: by mail-pj1-x1044.google.com with SMTP id e5so287651pjt.0; Sun, 29 Nov 2020 17:28:55 -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=odz+kb1KpmjaBlSIsSkY7pj1XNUUsPWvStEjf4gxHdU=; b=k30vK/uVBS2ysUeIkpG/T9aRQUWMbgTX2kJ3obZ7BuPcx6jgJX+k9zQ2/plmrF+P+q uSMc7zlVOVx6gRjHHBQ87dEe2O6/9No6FeStiwfzQj8tcQCbog+mMF42ma1dPAmADb8Y Pg//cWEapNPrWUWgHN9MYaX8EFZHHnecSiG6LJ25sb3H+WZYQJTVBTTH4PhUSx9qtQHi CkDzVByFtcVSG1w4e1ZCLyWqUJwTJZW/yPrtbtyxGo6D5RhYZrzi1JI56Jx+njla70PJ maN6I3rti4/pmscav+oKAG/Ytly5wNuQdxaUCTX51eMjwaq33cmSRKBLGwwVzPrZEZKG 7s1g== 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=odz+kb1KpmjaBlSIsSkY7pj1XNUUsPWvStEjf4gxHdU=; b=N8Lxf0URa0RPLzDDDsy+afGg4prPKDt/JTc5LUJyWrlZoWKMtQG0YYE8hCq9xJqRQN NFakIrVryt7Fdg2JaPWhTH/dGa31OWP3XxZmCk0J80F9NkU3br9eZe4ggCXIcECmjrMg kM8dR5LE0WmqcnHgfsJSVnPg0uokqrlv94FBIqWLmNoJXp9PJR+sqGBfuj7294d6Bqkz dzmkAYtRklFzQjIaMh+m2ES8lsHZOOg56T2T2kHt/JZGxxCYQzeu77WzzAhf2C/+Y7ix Kbffk94DghlzzUFjio0/2rM5Zq8nLMdXcXBtMkv9dXnft7jcBvERUgCt7Y5OALQfpbZ4 ODng== X-Gm-Message-State: AOAM5306sj+5E+/uxPSvmW0S47jkRiHgQ98tCHeiV7FLVndU8QESM+UC qDJb3txdCPxuTcb7zfu5Ub2O+219cxrrVLi0TzY= X-Google-Smtp-Source: ABdhPJz5OT92OWKkSRuxaohuF6Hwaatl+3XGDi4LGFv61H2jpVNcA1DprkT9mbRb9Ke6riy26rcs6A== X-Received: by 2002:a17:90b:1886:: with SMTP id mn6mr14823892pjb.31.1606699735236; Sun, 29 Nov 2020 17:28:55 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id l7sm3214644pgi.44.2020.11.29.17.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:28:54 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 05/15] usb: misc: emi26: update to use usb_control_msg_send() Date: Mon, 30 Nov 2020 06:58:47 +0530 Message-Id: <20201130012847.2579463-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 Reported-by: kernel test robot --- drivers/usb/misc/emi26.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/usb/misc/emi26.c b/drivers/usb/misc/emi26.c index 24d841850e05..1dd024507f40 100644 --- a/drivers/usb/misc/emi26.c +++ b/drivers/usb/misc/emi26.c @@ -27,7 +27,7 @@ #define INTERNAL_RAM(address) (address <= MAX_INTERNAL_ADDRESS) static int emi26_writememory( struct usb_device *dev, int address, - const unsigned char *data, int length, + const void *data, int length, __u8 bRequest); static int emi26_set_reset(struct usb_device *dev, unsigned char reset_bit); static int emi26_load_firmware (struct usb_device *dev); @@ -35,22 +35,12 @@ static int emi26_probe(struct usb_interface *intf, const struct usb_device_id *i static void emi26_disconnect(struct usb_interface *intf); /* thanks to drivers/usb/serial/keyspan_pda.c code */ -static int emi26_writememory (struct usb_device *dev, int address, - const unsigned char *data, int length, +static int emi26_writememory(struct usb_device *dev, int address, + const void *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 */ @@ -77,11 +67,7 @@ static int emi26_load_firmware (struct usb_device *dev) int err = -ENOMEM; int i; __u32 addr; /* Address to write */ - __u8 *buf; - - buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); - if (!buf) - goto wraperr; + __u8 buf[FW_LOAD_SIZE]; err = request_ihex_firmware(&loader_fw, "emi26/loader.fw", &dev->dev); if (err) @@ -133,11 +119,11 @@ static int emi26_load_firmware (struct usb_device *dev) /* intel hex records are terminated with type 0 element */ while (rec && (i + be16_to_cpu(rec->len) < FW_LOAD_SIZE)) { - memcpy(buf + i, rec->data, be16_to_cpu(rec->len)); + memcpy(&buf[i], rec->data, be16_to_cpu(rec->len)); i += be16_to_cpu(rec->len); rec = ihex_next_binrec(rec); } - err = emi26_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA); + err = emi26_writememory(dev, addr, &buf, i, ANCHOR_LOAD_FPGA); if (err < 0) goto wraperr; } while (rec); @@ -211,7 +197,6 @@ static int emi26_load_firmware (struct usb_device *dev) release_firmware(bitstream_fw); release_firmware(firmware_fw); - kfree(buf); return err; } From patchwork Mon Nov 30 01:29:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939465 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 21D18C64E7B for ; Mon, 30 Nov 2020 01:30:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C60BE20757 for ; Mon, 30 Nov 2020 01:30:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cecYIi5F" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728015AbgK3BaN (ORCPT ); Sun, 29 Nov 2020 20:30:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbgK3BaN (ORCPT ); Sun, 29 Nov 2020 20:30:13 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6960CC0613CF; Sun, 29 Nov 2020 17:29:33 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id 131so9368616pfb.9; Sun, 29 Nov 2020 17:29:33 -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=6ib7I1SBzR+I2y31YawRWflg5fgYPXjDvqt2aJ7OH+U=; b=cecYIi5FdVJnecc8OYQz5g8ZzZj9yof8HUpow1OIVGK4S3ezZcRt27keh5z1crNFJY BgTzGwtYe6GjXN5Le7w5oGJvAAe+QvsG2N+grDBksFbWIE9vjEwxcVQj4AYIMaazyYoC fVUm2oCW9NVeoMvwnR+nwQXcnXtiEXfryPdBjoZIApNy0I/6vyAXemYKkWUFbKY02gL2 KnU4hq/qsnmEGPzbdQnrd0f/R7xaRxDh7uKoAxYwCJ65fGbDZB7Mnj21/e+TsiXqIsyA cqMOMUNEi4oHeRN0iCCMg/VT/E6FrwzdOrEcAdQQ1Q9IvXOsB0NDZCoOTTvxbCgpYTO+ 4+Pw== 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=6ib7I1SBzR+I2y31YawRWflg5fgYPXjDvqt2aJ7OH+U=; b=Y4H6LqABKhMz5MoBr6+DAH9H62roSM11/LmINcpLidqJbda+qxyxS82xwY/GU7UmZN 4wkz3Dfqp4BSAZG9MgqR9G3HuLjlXbsILOCwI2a2iKIEhkkjps127b7L+69IKsPVX0N2 5TMxrvweo9+yKmdwFtj7mkxtQJmKmPTUBVIbAODmR5YFI7YgzPjMk4teYTeSYK5b8d0b qndU6exfvcoQQg431+QzbB9+BcB0O0kxjthv4BfsVUY8s8Qk2IWoFsg1OTmJMmpl8fQ8 m/JtpQcxFMOp/Sm9ZmoCF8lC974fcp2RMHWe5Gy6X0X/pXM9rvHBaD22AaJeHkdfsHRh q1+Q== X-Gm-Message-State: AOAM530Uk71OCYiDQ4uYO9JtpOd1CfH9WsQr+ndBggcvJQOvsiiUJGA6 Lda15PEul7xyTtccPEhRsx8= X-Google-Smtp-Source: ABdhPJyquQazRocFDtBMZM5qU7dDWxxxNHNwIB0txUPxRL9WQqQfpF0YT3pGUCaSbpIHAmNGBjHAPw== X-Received: by 2002:a62:84d2:0:b029:18a:f574:fded with SMTP id k201-20020a6284d20000b029018af574fdedmr16612845pfd.31.1606699772878; Sun, 29 Nov 2020 17:29:32 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id y15sm3256550pju.13.2020.11.29.17.29.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:29:32 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 06/15] usb: misc: emi62: update to use usb_control_msg_send() Date: Mon, 30 Nov 2020 06:59:25 +0530 Message-Id: <20201130012925.2579632-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 Reported-by: kernel test robot --- drivers/usb/misc/emi62.c | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/drivers/usb/misc/emi62.c b/drivers/usb/misc/emi62.c index 3eea60437f56..6ac4e72d53e0 100644 --- a/drivers/usb/misc/emi62.c +++ b/drivers/usb/misc/emi62.c @@ -36,7 +36,7 @@ #define INTERNAL_RAM(address) (address <= MAX_INTERNAL_ADDRESS) static int emi62_writememory(struct usb_device *dev, int address, - const unsigned char *data, int length, + const void *data, int length, __u8 bRequest); static int emi62_set_reset(struct usb_device *dev, unsigned char reset_bit); static int emi62_load_firmware (struct usb_device *dev); @@ -45,21 +45,11 @@ static void emi62_disconnect(struct usb_interface *intf); /* thanks to drivers/usb/serial/keyspan_pda.c code */ static int emi62_writememory(struct usb_device *dev, int address, - const unsigned char *data, int length, + const void *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 */ @@ -85,12 +75,9 @@ static int emi62_load_firmware (struct usb_device *dev) int err = -ENOMEM; int i; __u32 addr; /* Address to write */ - __u8 *buf; + __u8 buf[FW_LOAD_SIZE]; dev_dbg(&dev->dev, "load_firmware\n"); - buf = kmalloc(FW_LOAD_SIZE, GFP_KERNEL); - if (!buf) - goto wraperr; err = request_ihex_firmware(&loader_fw, "emi62/loader.fw", &dev->dev); if (err) @@ -140,11 +127,11 @@ static int emi62_load_firmware (struct usb_device *dev) /* intel hex records are terminated with type 0 element */ while (rec && (i + be16_to_cpu(rec->len) < FW_LOAD_SIZE)) { - memcpy(buf + i, rec->data, be16_to_cpu(rec->len)); + memcpy(&buf[i], rec->data, be16_to_cpu(rec->len)); i += be16_to_cpu(rec->len); rec = ihex_next_binrec(rec); } - err = emi62_writememory(dev, addr, buf, i, ANCHOR_LOAD_FPGA); + err = emi62_writememory(dev, addr, &buf, i, ANCHOR_LOAD_FPGA); if (err < 0) goto wraperr; } while (rec); @@ -209,8 +196,6 @@ static int emi62_load_firmware (struct usb_device *dev) release_firmware(bitstream_fw); release_firmware(firmware_fw); - kfree(buf); - /* return 1 to fail the driver inialization * and give real driver change to load */ return 1; @@ -223,7 +208,6 @@ static int emi62_load_firmware (struct usb_device *dev) release_firmware(bitstream_fw); release_firmware(firmware_fw); - kfree(buf); dev_err(&dev->dev, "Error\n"); return err; } From patchwork Mon Nov 30 01:29:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939467 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 7E753C64E7B for ; Mon, 30 Nov 2020 01:31:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3557D20757 for ; Mon, 30 Nov 2020 01:31:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JzrdzN27" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728182AbgK3Bam (ORCPT ); Sun, 29 Nov 2020 20:30:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgK3Bal (ORCPT ); Sun, 29 Nov 2020 20:30:41 -0500 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FE4AC0613D2; Sun, 29 Nov 2020 17:30:01 -0800 (PST) Received: by mail-pj1-x1042.google.com with SMTP id r20so288875pjp.1; Sun, 29 Nov 2020 17:30:01 -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=JzrdzN27W7cLCCdg2aMntMtj//R/354K+/dW4g6ZP/qiMxzVMJCK0crSVzz4mfEJhp UTdriCCD+3CKFQPaSdImgxWkq0KCvCN0F989zwlXJaTdXJOioJg4I+ZMimHW52PRWCvl QaXUzcHoqdXh6jZcGt2xpJEhCw1wxVaHNStTx1r5D/1RwDpNOfGlpEZwQYdxgCe2P2Z9 sI2tEDnQ3H1niW5JzF/F4f2ZO2uxLJ7acZEzoz1/57v5LpcDgXM8Xu4N+5ol2N2CK0/3 JnCjqaaY+SH+IEuBtyV4BNUr/tGUG2yYneirpls4I/aBIzfyUApbXm6Y8wlqJEgWkOvC 6Rjg== 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=rV0thk9vb/ozvuAuCZcRrT+qqPOnW0XyPIFVTxH6b8gek9TwH6dy26sT6TwboFRgA5 l7k7eQPIMFZwTTi2+Bckyg6HSnXNVc/lHOeDU9+WeCSeURJjMInz/IMufI/eFYpYTP7m sZB8vO5I/dG3bZIpsoxoTpIJYFDyFY4z1TAIXV41IeGs4TPvpJTZDrKhvAAT9N27/xWD 0s0Z1A7JtdNpL1yhyHi4sZJCfg66tpJgA0C+T/ymwS9q28qWjudG6oKx8gn62Fb8ZZ7t WZMxSqNUo7EUjswqR7kjdLYh+bg7KGJcEOQrpsPjZos0w7Pz4OukD+PLirFueYGGG8jb ESsQ== X-Gm-Message-State: AOAM533motlzxqLo/3IuZFJ01Gm29rdiZqBz1iLjBAp2mAkVX8tBoHqy 5w0/TvQWA9fuDlP0SqFFddA= X-Google-Smtp-Source: ABdhPJzYbrUiYyUPRkjeKRyyqoRSKMvqVC9Sst+yJ1xi3++Xe5VbaZ3jjO89zlocflcbdOmU5APoiA== X-Received: by 2002:a17:902:eb53:b029:d9:e57a:e402 with SMTP id i19-20020a170902eb53b02900d9e57ae402mr16620061pli.85.1606699801085; Sun, 29 Nov 2020 17:30:01 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id u1sm19863599pjn.40.2020.11.29.17.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:30: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 v2 07/15] usb: misc: ezusb: update to use usb_control_msg_send() Date: Mon, 30 Nov 2020 06:59:53 +0530 Message-Id: <20201130012953.2579811-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 Mon Nov 30 01:30:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939471 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 BF94DC64E8A for ; Mon, 30 Nov 2020 01:31:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CBF620757 for ; Mon, 30 Nov 2020 01:31:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GRMO7gea" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbgK3Bbj (ORCPT ); Sun, 29 Nov 2020 20:31:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbgK3Bbj (ORCPT ); Sun, 29 Nov 2020 20:31:39 -0500 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32D59C0613CF; Sun, 29 Nov 2020 17:30:53 -0800 (PST) Received: by mail-pj1-x1044.google.com with SMTP id r9so290299pjl.5; Sun, 29 Nov 2020 17:30:53 -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=GRMO7geaH7OIC3CKw4jkUk882KiGCKpXeYYxwK8nqNyEZpKh1nKhxQynS76lMSxBAu epu4fqCwvyeoxDRs3bpQqQztQhryoB7ve/sdf6BTaj0+bfRUGML42xZ/bzQkHWGUpe+s tUhQ1W7YBHuChFyRE8UuVA7nZN44dXDVl39TMpNDByQpK7kEAEy7H0wLlB7iZLtTsdOO rfRebXJx7ha0RMQ9c33ymAwVMbJV33r48MHfXk+OXoVjDPMWDJ8zAo+8shAdpReIULzx RZTgk/cb1VtSBty9c5SQ2sF3kO4EgPED5g/FzBYMnl2EDhhrazjSNMgyxAQny4PxYdyk C6Cw== 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=UleiSXk3Zvbrxt0Z1B4MdNnthbTR+rhMLt/yUJuxPRVjvmdt7Ag5AcYPoqc1g0UmwQ dvzQB5Ypt/gcsjOQpcdfXHdmhdTFgxL3MCZXRRaI+fvfr9VTGpfEnnqOjpv3qllrCQkG KlloS1qa612brWxNUad5z6+GyDLf+M6f9i01s7blEoKeWinV58LO1vJfKLb/03PgW5At DJtVKET0rcCYkDDkJgJhXHObfcwUGkwMfwADbQuv5NOg3PEM1C9C21yTcWKKppMoD83W +H5xqcKI0Ga7oHFy1YLDEUZS3JbfflbMZ+LBJ2cRhs1J9TLBBUEKXXcVITTDW7u/CeI1 d6FQ== X-Gm-Message-State: AOAM531xg8bEaj6Ko4aCjSJ/k2jMp5Rkd02t/TQIpJr7XTCJEUH36qmw CHbGrVHOJVCPaMchX57YWyw= X-Google-Smtp-Source: ABdhPJwOqYJKKyq4DzeiIKNVhiim6y247J1ugLfLyWq4kjGuEzuxguenIXn8MCnrtKQtIi+wegz2vg== X-Received: by 2002:a17:90b:33d1:: with SMTP id lk17mr23709423pjb.174.1606699852617; Sun, 29 Nov 2020 17:30:52 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id a3sm14565211pfo.46.2020.11.29.17.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:30:51 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam , Johan Hovold Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 08/15] usb: misc: idmouse: update to use usb_control_msg_send() Date: Mon, 30 Nov 2020 07:00:31 +0530 Message-Id: <20201130013031.2580265-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 Mon Nov 30 01:31: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: 11939473 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 755F9C64E7B for ; Mon, 30 Nov 2020 01:32:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 22A9320757 for ; Mon, 30 Nov 2020 01:32:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vGXHs16X" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728508AbgK3Bby (ORCPT ); Sun, 29 Nov 2020 20:31:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbgK3Bbx (ORCPT ); Sun, 29 Nov 2020 20:31:53 -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 AC191C0613D2; Sun, 29 Nov 2020 17:31:13 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id w202so9372295pff.10; Sun, 29 Nov 2020 17:31:13 -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=vGXHs16X2MF2DjnkBqRJw/m30w6G7WZqBnHtoCcR92+2a4886nq/4jhrToqCpyfTDK S+EST94Xac05QbbqfkjatTJtoPnZZ8yJ4oib/7O8SGfhqxFlMsmeCgmkG8N2BhplP+48 PL4p9ktfWGOlnPNP52X6Dm+02ALrA1Xip3Hedvr0oVljnEDIBHZOLjYJLVlGq8BZRKqg jr50UOxUasRw48NGE5WQ8Z4kKXHt/myl4c4ykPTq1IYBNXxWyYx9hvOBaaUIr38yz1rK Y909hN59xQgwWwgFo60EtArO5TRddN45BLhKIO4y70Ez5oz1CZSSafAX/gXx6st6Cwv1 2vJw== 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=NSi8eQx74QA8M3agnufJqbHfaj1o9F17HyCAyjMKX+rtPSGW91X8EmOW6U8aHY4WEv esg9Mx7djn6eLRFz4CD45g0Bi4TAwySrJ4Z/+q2JlHVCWzADBrLC2+QLSkW8huApMG1I 4vaTSqbJpo7nppQSRACE3UfBcnQSk8nB5LQJ7jniVd0UAYa/EGC0xHVHj1k7vS8BqMW9 TJ1L9xJw7WGlPLTcHdXPDwW0bB/8sK69+XqTiUp/oMXv6Av1ssOF95vmAr58xo2Z3zys SUyU0IrTGcBd+icVV25JrdgVjgZM6+DV/aDsojqyUTsRu+tCIxbzzIKefkp0nn9pF9B6 at5w== X-Gm-Message-State: AOAM532K/g8lZalXUnevmW0VM8pL5oiga33kP50rSUOng9I2hvGqOqsA 9VrgjDybfhg7UXHbE/lK95k= X-Google-Smtp-Source: ABdhPJwush27084ownRR7LQvdQzXAJeIAPcwg6gV5PwbWkR1xYbqSBWHbj4N+JNCLZT9ExU87KGfvg== X-Received: by 2002:a62:78d3:0:b029:198:ad8:7d05 with SMTP id t202-20020a6278d30000b02901980ad87d05mr16538003pfc.18.1606699873090; Sun, 29 Nov 2020 17:31:13 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id l23sm13747168pgn.40.2020.11.29.17.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:31:12 -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 v2 09/15] usb: misc: iowarrior: update to use the usb_control_msg_{send|recv}() API Date: Mon, 30 Nov 2020 07:01:03 +0530 Message-Id: <20201130013103.2580467-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 Mon Nov 30 01:31:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939475 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 5D3BAC64E8A for ; Mon, 30 Nov 2020 01:33:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0F3AB20757 for ; Mon, 30 Nov 2020 01:33:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K4/211RP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727233AbgK3Bcf (ORCPT ); Sun, 29 Nov 2020 20:32:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726332AbgK3Bcf (ORCPT ); Sun, 29 Nov 2020 20:32:35 -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 EB48BC0613CF; Sun, 29 Nov 2020 17:31:54 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id y7so9364073pfq.11; Sun, 29 Nov 2020 17:31:54 -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=04c9BxYa1Ymi07bLwZCgG59VbrDPFBxGmQMOZz4mzls=; b=K4/211RPyH8AC68ON0DQNEbKbkXoSOGzSBPdICQr7PmW5l1mASVK+NtY/l9bx0jVct HsMeh8tqjINe/UZIj41aZCIeoAxXWJ+3vWE3h03Acb2JUy8ZGtvCJAiasw4oe+v8GUAz 4bcddyq/QMmUQYduArGCAeMS6nZhaIy3JCWod9uTlStJAJYJGn6tCOzxTaIbWq8MTJaU ts6J9IVHJS/xqwCfOSFh9MozfYHp5xdeF/xtZ3UAYIld/Tec3PmdQVXOWBKaxchIOG10 es0CUMVrwZbiDnZ3LVQzflO5OCjNdYESn6tRBsm7TUUgkCVynN977iysXuSQYkzzqOo/ uUjg== 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=04c9BxYa1Ymi07bLwZCgG59VbrDPFBxGmQMOZz4mzls=; b=KLijA0/5S+YsxomxrUzPQvKYu2JOSF9J8JxgFUxDjP+CLR3WY2mMDvUD2J9dTkRBv0 v8kpPluEcYejbDFzqjGmzS8jo3QQaIdSmwd4kbi1T+s+tYxKtHKRjQUdMvO2OiF+cY37 bcZNVV/bR8jran1RJcjH7vws0CLMuGazIhjmGdZKPOIb/BwQjqb9GFBIo1pDXmxCzwu8 RtjJMVwowbdEnxO9CRAlRtRdfPk+MkjMCjoNJd/yAuPlKUOt9Zo0AlZTQKhtk6S6AccC 8QrzwXWsal96bey8nes5456mXY00VzJCig43Z//yHbN2ADHzg/HlNFov/Go2Q0t8U3V3 KRTw== X-Gm-Message-State: AOAM531V844RB1NYgmPZxAgA9nTesozmi6z0YZK0m7sHErY4jAoWVmA6 7IxPIUPmQo4yLa+2CXYtC/U= X-Google-Smtp-Source: ABdhPJxM7H+CT4jARvaYn0bcnsLdxdmO6/Z5uIdDPaOCOchLBN7hcQTv+G4anBoZdpOzLNbq40c4iA== X-Received: by 2002:a63:344a:: with SMTP id b71mr15476454pga.146.1606699914442; Sun, 29 Nov 2020 17:31:54 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id m73sm14641550pfd.106.2020.11.29.17.31.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:31:53 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 10/15] usb: misc: isight_firmware: update to use usb_control_msg_send() Date: Mon, 30 Nov 2020 07:01:44 +0530 Message-Id: <20201130013144.2580664-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/usb/misc/isight_firmware.c b/drivers/usb/misc/isight_firmware.c index 4d30095d6ad2..1bd14a431f6c 100644 --- a/drivers/usb/misc/isight_firmware.c +++ b/drivers/usb/misc/isight_firmware.c @@ -37,13 +37,10 @@ static int isight_firmware_load(struct usb_interface *intf, struct usb_device *dev = interface_to_usbdev(intf); int llen, len, req, ret = 0; const struct firmware *firmware; - unsigned char *buf = kmalloc(50, GFP_KERNEL); + unsigned char buf[50]; unsigned char data[4]; const u8 *ptr; - if (!buf) - return -ENOMEM; - if (request_firmware(&firmware, "isight.fw", &dev->dev) != 0) { printk(KERN_ERR "Unable to load isight firmware\n"); ret = -ENODEV; @@ -53,11 +50,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; } @@ -82,15 +79,15 @@ static int isight_firmware_load(struct usb_interface *intf, ret = -ENODEV; goto out; } - memcpy(buf, ptr, llen); + memcpy(&buf, ptr, llen); 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,15 +96,14 @@ 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; } out: - kfree(buf); release_firmware(firmware); return ret; } From patchwork Mon Nov 30 01:32: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: 11939477 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 73966C64E7B for ; Mon, 30 Nov 2020 01:33:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 312D02076A for ; Mon, 30 Nov 2020 01:33:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DeTr/M+8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727828AbgK3BdD (ORCPT ); Sun, 29 Nov 2020 20:33:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726332AbgK3BdC (ORCPT ); Sun, 29 Nov 2020 20:33:02 -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 77D72C0613D2; Sun, 29 Nov 2020 17:32:22 -0800 (PST) Received: by mail-pl1-x643.google.com with SMTP id s2so5555833plr.9; Sun, 29 Nov 2020 17:32:22 -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=DeTr/M+8eCuCLV/F6kqkKuqqLF9ULokzQhootagixYA/9rbHXyeUybli+7p/Knxj8B KUgKBsBmbWVzmrgWeuZn8u4zuRRH0RWDN3iK8HQcA2pGP35G8kMfOQB8GZ/jWr9+wavN LkdzM2Ng7LQp4wVkV7EodCRByF7T+1sNQTLVuV19kmcPPxmIxNBPldBpd9/wOdmRlaTG YZKXKyCX43reYmPvNojxus1V2FnRYKX+a9p8Unnuc1HyJ8ljpu9RCx6EY+MJhy6F6+VJ eSLNEreJjMAQw8eEsyoZBCmowiYL3OqnEurpt2CezkfzDFjbURS4P4bZc+ILwXaki595 pbRA== 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=lHal0tS0caLdPLv+2d274FxVFBHbPW3AlEFV6Hb2LuNhoPaK3iqGsw12qqzHecxO97 7V7Jr358J1s1Wz4DMkEgnJ2nebPCkKeCr3Pvi66YQGbdefen8w9xSumnaXl3uZUDIwFO rNutHeWYyY80bFRlCpuZ0qmImXQHzJbRwyrwiNlgvw3aceOOsc1wiQVkFxS/AO/REsfM 7DQjb9KJonmyvkaFfE42/FWJ8X2Yl0lrkq/QTF2yAhF4+uefEozI9V2bnNCpquXZqNVq 685rgh+tWDnxECgl/rxW1PZdLeAAI/uWoKBCZhypIHy3EA7PHwA+0E8CVw7yRMBiLZg+ eeIg== X-Gm-Message-State: AOAM531bwrAKH6bob0uG24jrCBycXK1uvNWYkjluGTYIo6MbG5ASFYmi kXGVHaS0ovLvalgFL7I+EjU= X-Google-Smtp-Source: ABdhPJyr5kZGQeFS9YcNm+UDvhuSK0Hr48efv9+8FP6y+RsUNzBnbVXZUi1IfgtN049l1oTPx8TNeQ== X-Received: by 2002:a17:90a:fa93:: with SMTP id cu19mr23818221pjb.117.1606699941992; Sun, 29 Nov 2020 17:32:21 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id i4sm13622895pgg.67.2020.11.29.17.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:32:21 -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 v2 11/15] usb: misc: ldusb: update to use usb_control_msg_send() Date: Mon, 30 Nov 2020 07:02:07 +0530 Message-Id: <20201130013207.2580849-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 Mon Nov 30 01:32:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939479 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 2F213C64E8A for ; Mon, 30 Nov 2020 01:33:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E3E4720757 for ; Mon, 30 Nov 2020 01:33:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lBWEIheP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727190AbgK3BdY (ORCPT ); Sun, 29 Nov 2020 20:33:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726510AbgK3BdY (ORCPT ); Sun, 29 Nov 2020 20:33:24 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DB89C0613CF; Sun, 29 Nov 2020 17:32:44 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id t8so9383142pfg.8; Sun, 29 Nov 2020 17:32: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=oc1Y4NMhbCVXiBqEN7io2NrC3w9YKQLRDFoQx1B3ae0=; b=lBWEIheP4d1nXN5YP20R5Oj4Pe/fqJezrOm2IUICE1iQLxmBckKmVCQUWbwiXi3iod zI4RZEZB5SK9cuIuflQ07AG7IYXF+6R74d8RQIeHcUr+FRgkD633fbErhLIYw7O1jHYN ImqAZsfBqCThNZDRz4iVpgk260K0cWPS/wRi2tbcasl5U3Jm4EzfEn0TFahY/fng5giW 5fKak+BOiYqbWi4R58Yl6hSrDL+88BOZiMLIV19z1BveL8YtK2lvAzt4EQuQidx95B1x 9lDVf1MN1rlxELxA+V3IT6uzf8umLLmaNebI1XmKmJtjrc4F3EuHk+ShABG2l/exYg0K w5WQ== 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=oc1Y4NMhbCVXiBqEN7io2NrC3w9YKQLRDFoQx1B3ae0=; b=eusCXUBoY819DTFLTX0+og4QnauDLlUM9xsk/gMmE4jyakmUraS3NV6yUVjVU7orFP msaLwdkLAE+ubHDBdueZzewV4ICWtOYwcFodJE+fRzX69djxuwj6oL/jyuGswUcqntmC G2EOUqe6qs0NGAnFJr5GUX9jubm5Xn1ag4s6b3XEpHQgSaMIDRS8pGqTdZQ2b3kR7dsZ lLfyatFYLfsmJkdT84AHQb3inA1tbZRsemiKgZYxtdxSo0JeKLqkbeLKIn1FYDKsG5hp Hy058Fa8uJH3wbIikIF/VnP6DrkuDqb3RvhWKeDPAadQXU4B51xGvaB6awbM/ELxUATY HovQ== X-Gm-Message-State: AOAM533+YUSO0ZmzU4GohVYHT+QkSg+7D+p4dcQw1bzA538gJi2sKniA awwGgQWdlpLnaM7nAppjVfU= X-Google-Smtp-Source: ABdhPJwUlt6J5+lTz3AvhQQHBbxtYuv38EmVGIgU4CBbeADY7C6cZpdtgFyQY7KopPEe8JuaT1ddHg== X-Received: by 2002:aa7:9087:0:b029:197:daff:a9a8 with SMTP id i7-20020aa790870000b0290197daffa9a8mr16402971pfa.26.1606699963656; Sun, 29 Nov 2020 17:32:43 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id h32sm14348410pgl.36.2020.11.29.17.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:32:42 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam , Evgeny Novikov Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 12/15] usb: misc: lvstest: update to use the usb_control_msg_{send|recv}() API Date: Mon, 30 Nov 2020 07:02:32 +0530 Message-Id: <20201130013232.2581070-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c index f8686139d6f3..daa1b2c9139f 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, @@ -257,13 +257,9 @@ static ssize_t get_dev_desc_store(struct device *dev, { struct usb_interface *intf = to_usb_interface(dev); struct usb_device *udev; - struct usb_device_descriptor *descriptor; + struct usb_device_descriptor descriptor; int ret; - descriptor = kmalloc(sizeof(*descriptor), GFP_KERNEL); - if (!descriptor) - return -ENOMEM; - udev = create_lvs_device(intf); if (!udev) { dev_err(dev, "failed to create lvs device\n"); @@ -271,18 +267,16 @@ 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); destroy_lvs_device(udev); free_desc: - kfree(descriptor); - if (ret < 0) return ret; @@ -336,10 +330,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 +414,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 Mon Nov 30 01:33: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: 11939481 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 DDEADC64E7B for ; Mon, 30 Nov 2020 01:34:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99D0B20757 for ; Mon, 30 Nov 2020 01:34:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YcmE0ZRc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728700AbgK3Bdu (ORCPT ); Sun, 29 Nov 2020 20:33:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727294AbgK3Bdt (ORCPT ); Sun, 29 Nov 2020 20:33:49 -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 89E72C0613D2; Sun, 29 Nov 2020 17:33:09 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id b23so5564262pls.11; Sun, 29 Nov 2020 17:33:09 -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=oMoEajyDR9iy/8AmtoE+xZAQV9/TdmV8a3AZX9/gsow=; b=YcmE0ZRcv9ZdFuMrDXDVIiiYSheIGN3T2L13gXLZf7thOK9mdeH6w95wlnKreceqf/ +sPtTnI7ucwXOsaLf7osxdMGoh81GpGsEWK33GBLECx2rk86KyiMIisFZwngHwudBn7+ pOcDtZlrKGhEKAA74Stm8ELEfdyi1IDGmwYEtigAj3lHLyMnBfPF2frz13ES81yZWAua E6kP/I+a7EcMzjt7ejIw98YfBovx4SugpVtiBfgyE2cwrDLbxXc5zE1FOeqmw9YyE9G6 W1PhjYBGlpPcHy34KlFF9baBwIsTKGj1bHM20rxz6yx808Ys6EHZgbXRrBiTLmP8Um/D 6HLg== 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=oMoEajyDR9iy/8AmtoE+xZAQV9/TdmV8a3AZX9/gsow=; b=IVhe8+BG58guONKCRAqWFtqFge6LcOzut9l62ndmERn/0JuaZraF0+YI0+m9EK+5HA 2ktHr9C0doHcS8IgyH7UleJLkhCCU0a6/eEwcQ8fxDe46qks2OLJoxxK+VPQRpIeOpo3 z03yInBCMR0GD/PX38limsLUAKjBFbQCJpl63O4O6AH63Xkqx9Y8tu+i6qvjpZh6YDce hhzR8PCmnsS0hbQCgGJbF5dTXIBmKwLwgTrf03Nf3m+6ldVisulVrpEaZmRJs+jVaMsk jLAuYpCGueRuoboPtNVwXKQ2zkf/FPzF2cnmEaKRd4HQ/OX4WUPFFuG5sBEfMrH6/hvq AjDg== X-Gm-Message-State: AOAM532U0we4PD1vzaZlFdtobr0vwStOUmqMWfdzCkpqACr5b28tH/MV TrO+/JOk6RrbgeClQ2O5hpY= X-Google-Smtp-Source: ABdhPJxTaUh6PgwHoSpw9N670578+JxdXCsZa06WsHSiz60yFAz7Mm3thgEJYCH42tyo1yClRJc/Iw== X-Received: by 2002:a17:90a:4601:: with SMTP id w1mr23468441pjg.109.1606699988738; Sun, 29 Nov 2020 17:33:08 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id r15sm20579565pjp.51.2020.11.29.17.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:33:08 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 13/15] usb: misc: trancevibrator: update to use usb_control_msg_send() Date: Mon, 30 Nov 2020 07:03:02 +0530 Message-Id: <20201130013302.2581300-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index a3dfc77578ea..c50807b4f4ef 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c @@ -59,11 +59,11 @@ 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); + 0, NULL, 0, USB_CTRL_GET_TIMEOUT, GFP_KERNEL); if (retval) { tv->speed = old; dev_dbg(&tv->udev->dev, "retval = %d\n", retval); From patchwork Mon Nov 30 01:33: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: 11939483 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 1264BC64E8A for ; Mon, 30 Nov 2020 01:35:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD3A82076A for ; Mon, 30 Nov 2020 01:35:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LSQtjKIL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728199AbgK3Beu (ORCPT ); Sun, 29 Nov 2020 20:34:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726702AbgK3Bet (ORCPT ); Sun, 29 Nov 2020 20:34:49 -0500 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 166BBC0613CF; Sun, 29 Nov 2020 17:34:09 -0800 (PST) Received: by mail-pj1-x1044.google.com with SMTP id t12so326481pjq.5; Sun, 29 Nov 2020 17:34:09 -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=idqo+EX1CIZxF2ePxyjSJLOfFZLABQRqNBSPoIAo4yo=; b=LSQtjKIL9N+y42WJmEkfId0H0TuLAQBIKgpzcKrj7BWehMRwb6c5LHIzQWjDw/SaDs pjf4BANMBsuP07I5wkJ5lgO2f1FL4iYfFICwdDZmUGgeQ9yCxQbcJ1mHz/3l1Csh13gV cCYQqP+IgfeyL4Y/mwkZoAacTXBCb2NJLMxZhBNaRyhe1QhwZPNRlO3X1AIwaBUKfryJ xOENVfrSC6myp5lxPZBF5hmmyf1VEuWX3jk1BKY6oZ6ho55fXhHxj64ytKk3OqLdtmgN eiMnhd3+OeOMSKc6r11LBt+ijQXEoFA8UWbap6tzms8n4b5HJr2mIhaFhlfsZOlnWS3L Sx/Q== 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=idqo+EX1CIZxF2ePxyjSJLOfFZLABQRqNBSPoIAo4yo=; b=CwaHRWYJCkzifHr3Ey83Zj95dclTwtkDdP/9WABBbcKYXE7ZltzHkRaZLUUSIC1iXI aZjwn0qsl7rGcU95VyZ2NYXnqGvFqggKO1zOlmv36wuIoflRiZmcELC1becbHQViAShn +GrD/vIbJEZ9hMdHSuuV7B9LVyvbJHkQmeYZIJ4Y0Jm+DNCEsJsuIkQ/vED6UMDntdU6 FzrtUbqdOsedwHBvbTO1H1w1o0QZjoTsKFe4GdVGK4f0uE0F6fQgxFWX5iFARll0gtPX 1s2DnlcKOQ9kUJxcL9ELJRpwaN12UyoB2k3iRTi6cpfdGv6yHHpCNFxgFI+QVfIJVTus ec+Q== X-Gm-Message-State: AOAM533PlmQOK1R2MlD0+1QpaIfgKcDuES8Eaz5hn28u6MLkGnCpL4sQ YnrebyNgFlLWCRsQ4ve9M68= X-Google-Smtp-Source: ABdhPJyLnQKJcGFYvO7G03Zk5SDRh6FQd/SBrNNmUiLivQYLaPkY/T85NZryYuH2MT3eX2X1H0xbYg== X-Received: by 2002:a17:90b:614:: with SMTP id gb20mr10130027pjb.34.1606700048506; Sun, 29 Nov 2020 17:34:08 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id v6sm14916071pgk.2.2020.11.29.17.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:34:07 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Anant Thazhemadam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 14/15] usb: misc: usbsevseg: update to use usb_control_msg_send() Date: Mon, 30 Nov 2020 07:03:58 +0530 Message-Id: <20201130013358.2581796-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 | 60 ++++++++++-------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c index 551074f5b7ad..ade4bc58d5f2 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); @@ -117,48 +107,32 @@ static void update_display_visual(struct usb_sevsegdev *mydev, gfp_t mf) { int rc; int i; - unsigned char *buffer; + unsigned char buffer[MAXLEN] = {0}; u8 decimals = 0; if(mydev->shadow_power != 1) return; - buffer = kzalloc(MAXLEN, mf); - if (!buffer) - return; - /* The device is right to left, where as you write left to right */ 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, mf); if (rc < 0) dev_dbg(&mydev->udev->dev, "write retval = %d\n", rc); - kfree(buffer); - /* The device is right to left, where as you write left to right */ 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, mf); if (rc < 0) dev_dbg(&mydev->udev->dev, "decimal retval = %d\n", rc); From patchwork Mon Nov 30 01:34:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anant Thazhemadam X-Patchwork-Id: 11939485 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 406D1C64E8A for ; Mon, 30 Nov 2020 01:35:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC3472076C for ; Mon, 30 Nov 2020 01:35:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G1ZxR9Tk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728496AbgK3BfN (ORCPT ); Sun, 29 Nov 2020 20:35:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727028AbgK3BfM (ORCPT ); Sun, 29 Nov 2020 20:35:12 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9ABBC0613D2; Sun, 29 Nov 2020 17:34:32 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id n137so9398883pfd.3; Sun, 29 Nov 2020 17:34: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=MRf4ZKc/l/eC7hFvdoC+Q4DO+7qNVyq14MdwpxFRyF4=; b=G1ZxR9TkgoW8diPH06BgSmIXKYidGd9LgBebSIwX0TWLjOX0xJmKKv67iCR5getn7r F7TKZVzfPzxw08bbKFbMm9Imcx1CvSk5EsFakblE6/MTcZBjM1tq0x3mImWeb5JhPsLr ezr0XTJ7gKr5J/xbzjsNRDXFWKmYABaKmtJissHCKRnvydqPvDwTT5gDWkCuy7O6dkxx 1f1BM1i5tu3rK5UCdxKOQLaJg2rBSYRzs2Fr004b0BrABdWZVXSuVc6cAHJlqbMYdczv g3xQwwvfROsl2MjrJZ7WoduuL0d0a/OswWVLv34SbCYzp5WQUk5AzznGv3cvz9AUoW1s UXbg== 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=MRf4ZKc/l/eC7hFvdoC+Q4DO+7qNVyq14MdwpxFRyF4=; b=CIe3ehLSetllqNOIznPj+d0+sDjMFNYM52by6Hp3WylMlmNj5w4it25oVBiNV0Sesu TIA2KyYxMOF3nUtqbFZJLnfkuGq7jKYLOD3ypkfrNaecV6OaaMk0SwShAW0ekG5rny/6 E2my0K7JCu+OjGP9R8/BqhciihYR2CrqWPXo7swIYnuRvXNZzJdsYv8RfGcqxByfAqjA 4qvPzmxd3sCKdxycIavqWeECIIfcceSUXdafpzTdvegrhiR12yFhdtT1plllllJCcSJM xw9Iy2n4THO3O2Fpnpac1XZqyT9s8q1VrCb6R2woQvlgKOAsoilt2JUSeYDeU7hnjyiG Joww== X-Gm-Message-State: AOAM530240RVveszRGqExeOAKGJxvKlWyw9pgiGlmYlfRROpnQ7J4sE+ BW5bB242F+KFOOOFeZ1lnSs= X-Google-Smtp-Source: ABdhPJyHO7I4zPVmvwQF5AEJDODFMWaZarJmtHMBk2qu5luFRYuyFq+VBvj/Vf+wFjH0DgDAvSPmIw== X-Received: by 2002:a63:e54b:: with SMTP id z11mr3477173pgj.158.1606700072181; Sun, 29 Nov 2020 17:34:32 -0800 (PST) Received: from localhost.localdomain ([49.207.197.72]) by smtp.gmail.com with ESMTPSA id k1sm13933508pgm.21.2020.11.29.17.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2020 17:34:31 -0800 (PST) From: Anant Thazhemadam To: Greg Kroah-Hartman , Alan Stern , Bixuan Cui , Anant Thazhemadam , Zqiang , "Gustavo A. R. Silva" Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 15/15] usb: misc: usbtest: update to use the usb_control_msg_{send|recv}() API Date: Mon, 30 Nov 2020 07:04:23 +0530 Message-Id: <20201130013423.2582099-1-anant.thazhemadam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201130011819.2576481-1-anant.thazhemadam@gmail.com> References: <20201130011819.2576481-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 | 69 ++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 40 deletions(-) diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index 150090ee4ec1..4337eff2a749 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c @@ -672,19 +672,15 @@ 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); - switch (retval) { - case 1: - return dev->buf[0]; - case 0: - retval = -ERANGE; - fallthrough; - default: + 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); + + if (retval < 0) return retval; - } + + return dev->buf[0]; } static int set_altsetting(struct usbtest_dev *dev, int alternate) @@ -872,14 +868,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 +1680,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 +1842,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; }