From patchwork Wed Nov 4 06:46:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 318372 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 012DBC2D0A3 for ; Wed, 4 Nov 2020 06:47:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A088222384 for ; Wed, 4 Nov 2020 06:47:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ce47NTPV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727812AbgKDGre (ORCPT ); Wed, 4 Nov 2020 01:47:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725926AbgKDGrd (ORCPT ); Wed, 4 Nov 2020 01:47:33 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AD82C061A4D; Tue, 3 Nov 2020 22:47:33 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id g12so15741226pgm.8; Tue, 03 Nov 2020 22:47: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; bh=IGCdR2zg93PxLfowoIUOGeqadZduI79Y1jQCNcPvnfw=; b=Ce47NTPV8niNPcpAYfYF2OEl7IvkfZ+6P937ZnFxssbhp64mXlNjGNiz95ujP+8EN/ /SzZ6hKE78Ip6regihBDTo/GHyKcgiCX3OjPbPyUvKhjMN4woLcTXPSYymIKhu85RX62 tptBy7wqqkFdBhIo4n6xArDqUpVuyuSwQ7gX1qFdt19ns4M3UDSlFK5g4/5y6Mv4UvY5 IqcOSLDJRN84MNmN5CgBsHPmjV/PSLWJIbGqlkkE4yM6N29bvIVInwYcl/5XyGmb4zmU JiK+Bsi4qWzpPDXhMJJqpXoL/DSDYRyxsAQX9PQnV+4HM65NudqM9Xj/xipmCCpaRYnn kOFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IGCdR2zg93PxLfowoIUOGeqadZduI79Y1jQCNcPvnfw=; b=iQ1qSvjncwL29dZICTr0haOGDxfKpJ6UnPizpyPNZoqykhNoaDdfkE+OePqQmozvrT 2ULaSkVDwXmT9SL5ezP+KLyK4FJjqsTNdCb73AfoavxgX/ZwZYucw3gVuu1GCTHojizG /QsGlxtzafdz3176p4HbE9Oz4uL9TotUH15pIzXyclqTlDvrN0dI6F55RZxJKEdjvwWb Bdlm5Y+2HzDN+ciRMG7L+76cm+DG3lCCLkcdOgyCSIX6vAEeHko6xNUkFqb3Bf8UBekI qRc3jTc9QX7rageFdu6WUsmVudGI37iWW9IB0V5i/VJXXJ5B3uo4OnBLl6Qy7w13UjoE Hrcw== X-Gm-Message-State: AOAM531hts/qU4jDlwTfGvhq0yEHZGWzAZ0qgOe83VxBe/zF5FqnHFkA nN2e+r7cIbUtTJD/Z08qZWM= X-Google-Smtp-Source: ABdhPJwHD78ybryi7ZO7u5PSZtfGLkLqwqQ6nfgHB3CPsSeV4quBSMb/+N7R9bIwgcw9R1hc1N5whQ== X-Received: by 2002:a17:90a:5285:: with SMTP id w5mr3010576pjh.50.1604472452997; Tue, 03 Nov 2020 22:47:32 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.47.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:47:32 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 01/15] usb: serial: ark3116: use usb_control_msg_recv() and usb_control_msg_send() Date: Wed, 4 Nov 2020 12:16:49 +0530 Message-Id: <20201104064703.15123-2-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrappers instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/ark3116.c | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/drivers/usb/serial/ark3116.c b/drivers/usb/serial/ark3116.c index 71a9206ea1e2..51302892c779 100644 --- a/drivers/usb/serial/ark3116.c +++ b/drivers/usb/serial/ark3116.c @@ -77,38 +77,17 @@ struct ark3116_private { static int ark3116_write_reg(struct usb_serial *serial, unsigned reg, __u8 val) { - int result; /* 0xfe 0x40 are magic values taken from original driver */ - result = usb_control_msg(serial->dev, - usb_sndctrlpipe(serial->dev, 0), - 0xfe, 0x40, val, reg, - NULL, 0, ARK_TIMEOUT); - if (result) - return result; - - return 0; + return usb_control_msg_send(serial->dev, 0, 0xfe, 0x40, val, reg, NULL, 0, + ARK_TIMEOUT, GFP_KERNEL); } static int ark3116_read_reg(struct usb_serial *serial, unsigned reg, unsigned char *buf) { - int result; /* 0xfe 0xc0 are magic values taken from original driver */ - result = usb_control_msg(serial->dev, - usb_rcvctrlpipe(serial->dev, 0), - 0xfe, 0xc0, 0, reg, - buf, 1, ARK_TIMEOUT); - if (result < 1) { - dev_err(&serial->interface->dev, - "failed to read register %u: %d\n", - reg, result); - if (result >= 0) - result = -EIO; - - return result; - } - - return 0; + return usb_control_msg_recv(serial->dev, 0, 0xfe, 0xc0, 0, reg, buf, 1, + ARK_TIMEOUT, GFP_KERNEL); } static inline int calc_divisor(int bps) From patchwork Wed Nov 4 06:46:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 315505 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 E64EFC388F9 for ; Wed, 4 Nov 2020 06:47:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8BE9B22277 for ; Wed, 4 Nov 2020 06:47:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="It3dft3O" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728483AbgKDGri (ORCPT ); Wed, 4 Nov 2020 01:47:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728399AbgKDGrh (ORCPT ); Wed, 4 Nov 2020 01:47:37 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95EDCC061A4D; Tue, 3 Nov 2020 22:47:37 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id b3so16522427pfo.2; Tue, 03 Nov 2020 22:47:37 -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; bh=vnMYTYPWpL/m30915j5zLtve0vatdenqyPp6S7vmLgE=; b=It3dft3OWinLT6cIhmfl1Xv4H4P0etg2tdyYAgpuFPVb5m0GvsMP7aDS00s3nNcknq gPPq0cHV/5+JvxAyR5IoozAo8INdiK+/U1PS0GcwX37ZNTZzD9kWbc2/bLlEGj+A0pBf YKDvw7/YoUAq/iisroJq59zIUmq+Gk3FwnTAbRngVlxh+VR0H3UFiR6TG8JlnbAehl4Q 8QGM81Uvs5cdtzaVAuR+3jBxCtCMwIAjVQSSw+DcLwsw5F0UmX20kYTRM3nRkHDsy4Fv D9qXpd5SkiCWtFlcckNq1Yt+Ned9A8E4QMvOjgQ34Y1zl63ROHxvtiNoU7mDH1XjCkCy HJyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vnMYTYPWpL/m30915j5zLtve0vatdenqyPp6S7vmLgE=; b=U1p5omxbypeYqFaekdaM65gj/Jrzui1TMmWtFsXekOzPLinSU+IQeWIQ5ysh5omGFu mHczfMMQxHbOFFUAUOz2W5KBDHQhqqmGO3000VGGpblX25lyQwuad1LyU9wy9oVT7bon avkEi5lS76eSjJkknuFJqMfEa0jo7PdgiQEDnXmfvjyFZm8Md5kvwrBLLJI84H8yaBLA Swt/M9X/st3/+NFehq49CKHKHnh61yHABS4wOl6ZYmqCP+52lESxpDWPGcohhCmzQ6VM ySwaWJVgeltDzy9R9+ddiHBnK5YmgNSqlDxZFukv+kRDLpzP9j++yqd+vkNzmf1pLxUB I1aw== X-Gm-Message-State: AOAM530XB+EXOqEXZbPgCDQ+UFzyqgO+Ao/HuF+Q0kcWQGqlXVXtHBiJ FEn3oPkwxzWihy5SBD57mHM= X-Google-Smtp-Source: ABdhPJwnNQfXO7AjHXWMn/tpTXzV0nUf1dFk+DWr2khbTMJSk39gkNgezJp4Wv7vki3qJV0KgjGvpg== X-Received: by 2002:a62:2e47:0:b029:155:853a:80d5 with SMTP id u68-20020a622e470000b0290155853a80d5mr28804533pfu.29.1604472457118; Tue, 03 Nov 2020 22:47:37 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.47.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:47:36 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 02/15] usb: serial: belkin_sa: use usb_control_msg_send() Date: Wed, 4 Nov 2020 12:16:50 +0530 Message-Id: <20201104064703.15123-3-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrapper instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/belkin_sa.c | 35 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/usb/serial/belkin_sa.c b/drivers/usb/serial/belkin_sa.c index 9bb123ab9bc9..a5ff55f48303 100644 --- a/drivers/usb/serial/belkin_sa.c +++ b/drivers/usb/serial/belkin_sa.c @@ -105,9 +105,10 @@ struct belkin_sa_private { #define WDR_TIMEOUT 5000 /* default urb timeout */ /* assumes that struct usb_serial *serial is available */ -#define BSA_USB_CMD(c, v) usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), \ - (c), BELKIN_SA_SET_REQUEST_TYPE, \ - (v), 0, NULL, 0, WDR_TIMEOUT) +#define BSA_USB_CMD(c, v) usb_control_msg_send(serial->dev, 0, (c), \ + BELKIN_SA_SET_REQUEST_TYPE, \ + (v), 0, NULL, 0, WDR_TIMEOUT, \ + GFP_KERNEL) static int belkin_sa_port_probe(struct usb_serial_port *port) { @@ -309,12 +310,11 @@ static void belkin_sa_set_termios(struct tty_struct *tty, /* reassert DTR and (maybe) RTS on transition from B0 */ if ((old_cflag & CBAUD) == B0) { control_state |= (TIOCM_DTR|TIOCM_RTS); - if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 1)) dev_err(&port->dev, "Set DTR error\n"); /* don't set RTS if using hardware flow control */ if (!(old_cflag & CRTSCTS)) - if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST - , 1) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 1)) dev_err(&port->dev, "Set RTS error\n"); } } @@ -330,18 +330,18 @@ static void belkin_sa_set_termios(struct tty_struct *tty, /* Report the actual baud rate back to the caller */ tty_encode_baud_rate(tty, baud, baud); - if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_BAUDRATE_REQUEST, urb_value)) dev_err(&port->dev, "Set baudrate error\n"); } else { /* Disable flow control */ if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, - BELKIN_SA_FLOW_NONE) < 0) + BELKIN_SA_FLOW_NONE)) dev_err(&port->dev, "Disable flowcontrol error\n"); /* Drop RTS and DTR */ control_state &= ~(TIOCM_DTR | TIOCM_RTS); - if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, 0)) dev_err(&port->dev, "DTR LOW error\n"); - if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, 0)) dev_err(&port->dev, "RTS LOW error\n"); } @@ -352,7 +352,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, : BELKIN_SA_PARITY_EVEN; else urb_value = BELKIN_SA_PARITY_NONE; - if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_PARITY_REQUEST, urb_value)) dev_err(&port->dev, "Set parity error\n"); } @@ -377,7 +377,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, urb_value = BELKIN_SA_DATA_BITS(8); break; } - if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_DATA_BITS_REQUEST, urb_value)) dev_err(&port->dev, "Set data bits error\n"); } @@ -385,8 +385,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, if ((cflag & CSTOPB) != (old_cflag & CSTOPB)) { urb_value = (cflag & CSTOPB) ? BELKIN_SA_STOP_BITS(2) : BELKIN_SA_STOP_BITS(1); - if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, - urb_value) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_STOP_BITS_REQUEST, urb_value)) dev_err(&port->dev, "Set stop bits error\n"); } @@ -407,7 +406,7 @@ static void belkin_sa_set_termios(struct tty_struct *tty, if (bad_flow_control) urb_value &= ~(BELKIN_SA_FLOW_IRTS); - if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_FLOW_CTRL_REQUEST, urb_value)) dev_err(&port->dev, "Set flow control error\n"); } @@ -422,7 +421,7 @@ static void belkin_sa_break_ctl(struct tty_struct *tty, int break_state) struct usb_serial_port *port = tty->driver_data; struct usb_serial *serial = port->serial; - if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0) < 0) + if (BSA_USB_CMD(BELKIN_SA_SET_BREAK_REQUEST, break_state ? 1 : 0)) dev_err(&port->dev, "Set break_ctl %d\n", break_state); } @@ -476,13 +475,13 @@ static int belkin_sa_tiocmset(struct tty_struct *tty, spin_unlock_irqrestore(&priv->lock, flags); retval = BSA_USB_CMD(BELKIN_SA_SET_RTS_REQUEST, rts); - if (retval < 0) { + if (retval) { dev_err(&port->dev, "Set RTS error %d\n", retval); goto exit; } retval = BSA_USB_CMD(BELKIN_SA_SET_DTR_REQUEST, dtr); - if (retval < 0) { + if (retval) { dev_err(&port->dev, "Set DTR error %d\n", retval); goto exit; } From patchwork Wed Nov 4 06:46:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 318371 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 C8C7FC55178 for ; Wed, 4 Nov 2020 06:47:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 714062236F for ; Wed, 4 Nov 2020 06:47:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bdgDAL36" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728399AbgKDGrm (ORCPT ); Wed, 4 Nov 2020 01:47:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725926AbgKDGrl (ORCPT ); Wed, 4 Nov 2020 01:47:41 -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 4F528C061A4D; Tue, 3 Nov 2020 22:47:41 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id e7so16463812pfn.12; Tue, 03 Nov 2020 22:47:41 -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; bh=jIXN4oV96UfWYf6NfkH9p6xOm8rqz64TQybeTquYEoU=; b=bdgDAL36GFSxZ5FJZO8E/+xQp0pgIRfJKgW1vhllCfE0cWJXALFLZGTVA13Io9oEax kLBpBdoxoqrgjlfuKpWU9xamztTgEHWQ/4zyec1bzBTOi42ddb3NxHH3veNbcCCbkv+C lj7FjBxipHKImRwsp9ihQpsbBvb+SR5XVAtFS8g3+Sy5NZfVSWtcPONRHV/XDazRGabG LwoyNMh3bfJMpBDoeuCJSFWlYlPlYt/qbsqR+YoC+4QkiMUXyE1m3jyWCJ1edBEUQV96 vQRdQb8hs4hPxg2NrxnrQURJjQE/8/4HjyfeMPmci58vskAZ2q/OxQMHkKUmJaH8Gko/ 5dSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jIXN4oV96UfWYf6NfkH9p6xOm8rqz64TQybeTquYEoU=; b=t0V0zviXfsAJnII631r9s2Q011wMY9A5J9leJ8A1uVTWIqScKgUtjqvi58LzU9aB+m RDFHez5YWXCzVnG9IsvGfaTD4hGUm+VCzYJu8+fXm7GfC1ABDw60FYXWXszUCnJBG0l4 wruoAEY0bbynOi1OQKBS2tZe2QBASKAx0srrMf+bLoG5kf05Vf+K8WURPf+UMu8WBLOb LRL5glrMtnaKl6J7qFrlTZ6920IsKgm3ODRL2eTj94NGqtgxChXYpZHXJbGnz/2nVuUZ y664TPqUZyeGHobyHtnSKc4C1U0kuy6wxullJYYbDho9p+iMXlx2h+h0elqcQSrYZ2Y3 E7KA== X-Gm-Message-State: AOAM533Ng6JAlvqVBjadRT716iaFxqhuKQSILfOR8r6oFR0PJhXWXfRy PIy5lZP/SLsKI8mUftomA6TprAKVpW8= X-Google-Smtp-Source: ABdhPJwbeR7/672K26Vnqd7j+koUadp3SD8IiepZdPZZlrlpgw5sN/lrTix2osWHCk8nYK4A+rfHtg== X-Received: by 2002:a63:1d12:: with SMTP id d18mr20727693pgd.314.1604472460880; Tue, 03 Nov 2020 22:47:40 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.47.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:47:40 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 03/15] usb: serial: ch314: use usb_control_msg_recv() and usb_control_msg_send() Date: Wed, 4 Nov 2020 12:16:51 +0530 Message-Id: <20201104064703.15123-4-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrappers instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/ch341.c | 45 ++++++++++++-------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c index a2e2f56c88cd..58c5d3ce4f75 100644 --- a/drivers/usb/serial/ch341.c +++ b/drivers/usb/serial/ch341.c @@ -111,10 +111,10 @@ static int ch341_control_out(struct usb_device *dev, u8 request, dev_dbg(&dev->dev, "%s - (%02x,%04x,%04x)\n", __func__, request, value, index); - r = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT, - value, index, NULL, 0, DEFAULT_TIMEOUT); - if (r < 0) + r = usb_control_msg_send(dev, 0, request, USB_TYPE_VENDOR | + USB_RECIP_DEVICE | USB_DIR_OUT, value, index, + NULL, 0, DEFAULT_TIMEOUT, GFP_KERNEL); + if (r) dev_err(&dev->dev, "failed to send control message: %d\n", r); return r; @@ -129,23 +129,14 @@ static int ch341_control_in(struct usb_device *dev, dev_dbg(&dev->dev, "%s - (%02x,%04x,%04x,%u)\n", __func__, request, value, index, bufsize); - r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, - value, index, buf, bufsize, DEFAULT_TIMEOUT); - if (r < (int)bufsize) { - if (r >= 0) { - dev_err(&dev->dev, - "short control message received (%d < %u)\n", - r, bufsize); - r = -EIO; - } - + r = usb_control_msg_recv(dev, 0, request, USB_TYPE_VENDOR | + USB_RECIP_DEVICE | USB_DIR_IN, value, index, + buf, bufsize, DEFAULT_TIMEOUT, GFP_KERNEL); + if (r) dev_err(&dev->dev, "failed to receive control message: %d\n", r); - return r; - } - return 0; + return r; } #define CH341_CLKRATE 48000000 @@ -343,22 +334,18 @@ static int ch341_detect_quirks(struct usb_serial_port *port) struct usb_device *udev = port->serial->dev; const unsigned int size = 2; unsigned long quirks = 0; - char *buffer; + u8 buffer[2]; int r; - buffer = kmalloc(size, GFP_KERNEL); - if (!buffer) - return -ENOMEM; - /* * A subset of CH34x devices does not support all features. The * prescaler is limited and there is no support for sending a RS232 * break condition. A read failure when trying to set up the latter is * used to detect these devices. */ - r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), CH341_REQ_READ_REG, - USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, - CH341_REG_BREAK, 0, buffer, size, DEFAULT_TIMEOUT); + r = usb_control_msg_recv(udev, 0, CH341_REQ_READ_REG, USB_TYPE_VENDOR | + USB_RECIP_DEVICE | USB_DIR_IN, CH341_REG_BREAK, + 0, &buffer, size, DEFAULT_TIMEOUT, GFP_KERNEL); if (r == -EPIPE) { dev_info(&port->dev, "break control not supported, using simulated break\n"); quirks = CH341_QUIRK_LIMITED_PRESCALER | CH341_QUIRK_SIMULATE_BREAK; @@ -366,17 +353,13 @@ static int ch341_detect_quirks(struct usb_serial_port *port) goto out; } - if (r != size) { - if (r >= 0) - r = -EIO; + if (r) { dev_err(&port->dev, "failed to read break control: %d\n", r); goto out; } r = 0; out: - kfree(buffer); - if (quirks) { dev_dbg(&port->dev, "enabling quirk flags: 0x%02lx\n", quirks); priv->quirks |= quirks; From patchwork Wed Nov 4 06:46:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 318365 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 96177C4741F for ; Wed, 4 Nov 2020 06:48:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F4302236F for ; Wed, 4 Nov 2020 06:48:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JOAa2k//" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728667AbgKDGrs (ORCPT ); Wed, 4 Nov 2020 01:47:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbgKDGrq (ORCPT ); Wed, 4 Nov 2020 01:47:46 -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 E0596C061A4D; Tue, 3 Nov 2020 22:47:44 -0800 (PST) Received: by mail-pf1-x444.google.com with SMTP id e7so16463914pfn.12; Tue, 03 Nov 2020 22:47: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; bh=JQfRVw+JvA74WyL79cIHLhMk0a8vhCik+EDNpAkK11o=; b=JOAa2k//H2LnYBr6zCUXT3mo7GQRsBnXapbrGhnCmYWZ2QAeLaOWDCe7zYe2/WDPVe s0zpM8nolDsOeY593GLTZgIDjgPBYh/xA9wXOftzJ2oeMZyMC0acLVWSu59g8HEqwwDj VuU8mUyLGQFTwVwwec+hDOx88Aio5/PvW2DsQIf5w7vdtFxzQU032wIioNqtdX1DxwFq kPqvgq9ni0ZoAOo0VoNRFPrAkPNzI+QzqNSOVQEhD4u6oyliVuxoZuBImAgtW4nhM0vv nYREEePI1FuK20PZWJ8H3kyABTzTAjEu1FCliQZY2sRXeC3DsufEMsMEpbLvXmq9/FK3 c3YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JQfRVw+JvA74WyL79cIHLhMk0a8vhCik+EDNpAkK11o=; b=g3vvtWJnir0f5u9WB7ONZqVU+vUZy88OYLK+6irpnCO+hGzo+Aqi0mlT0jpr5sPpjW 2z0CaVGqNLloIUaDWTyIf2Y0pcC7+Sc24vHG7pjwWGJVocgy3VsW/566SkHvocwcA2Fa yZl7N59nxnChj1erJhtGx+BMecdf2cLUEwC3NGS7dOCq+jCKu2xOvBLVZl32UOulI3iU KaLp+vwwmlb4Crc3mN0zarNac0OUjbhzwOUaS2/Ae2ymxSN7HCt6Uz2IHDVoidviHYg/ b3HVqIQLT2nIM8Vkxbip1gI0bsIby0HNZB5lUBoUyeO5nneyTJZNxI0u+02SJFiCzqIv Sf1w== X-Gm-Message-State: AOAM530dWJf2pX5OEdPb0K9ij8VDCKkr87kfTNlWN2PO+zECZD0c7n2p 8QuLnT0G+Y7ONQleA1NZKoc= X-Google-Smtp-Source: ABdhPJyufrA29PcX5wXFdrhYrNw4mqJ16vQXCCFgpbRsiOI8kfTHHT7jyHUtfZ7BZz3bkgL4+deiFQ== X-Received: by 2002:a63:ec57:: with SMTP id r23mr20660997pgj.257.1604472464508; Tue, 03 Nov 2020 22:47:44 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.47.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:47:43 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 04/15] usb: serial: cp210x: use usb_control_msg_recv() and usb_control_msg_send() Date: Wed, 4 Nov 2020 12:16:52 +0530 Message-Id: <20201104064703.15123-5-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrappers instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/cp210x.c | 148 ++++++++++-------------------------- 1 file changed, 42 insertions(+), 106 deletions(-) diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index d0c05aa8a0d6..29436ab392e8 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -555,31 +555,15 @@ static int cp210x_read_reg_block(struct usb_serial_port *port, u8 req, { struct usb_serial *serial = port->serial; struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); - void *dmabuf; int result; - dmabuf = kmalloc(bufsize, GFP_KERNEL); - if (!dmabuf) { - /* - * FIXME Some callers don't bother to check for error, - * at least give them consistent junk until they are fixed - */ - memset(buf, 0, bufsize); - return -ENOMEM; - } - - result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), - req, REQTYPE_INTERFACE_TO_HOST, 0, - port_priv->bInterfaceNumber, dmabuf, bufsize, - USB_CTRL_SET_TIMEOUT); - if (result == bufsize) { - memcpy(buf, dmabuf, bufsize); - result = 0; - } else { + result = usb_control_msg_recv(serial->dev, 0, req, + REQTYPE_INTERFACE_TO_HOST, 0, + port_priv->bInterfaceNumber, buf, bufsize, + USB_CTRL_SET_TIMEOUT, GFP_KERNEL); + if (result) { dev_err(&port->dev, "failed get req 0x%x size %d status: %d\n", - req, bufsize, result); - if (result >= 0) - result = -EIO; + req, bufsize, result); /* * FIXME Some callers don't bother to check for error, @@ -588,8 +572,6 @@ static int cp210x_read_reg_block(struct usb_serial_port *port, u8 req, memset(buf, 0, bufsize); } - kfree(dmabuf); - return result; } @@ -648,29 +630,16 @@ static int cp210x_read_u8_reg(struct usb_serial_port *port, u8 req, u8 *val) static int cp210x_read_vendor_block(struct usb_serial *serial, u8 type, u16 val, void *buf, int bufsize) { - void *dmabuf; int result; - dmabuf = kmalloc(bufsize, GFP_KERNEL); - if (!dmabuf) - return -ENOMEM; - - result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), - CP210X_VENDOR_SPECIFIC, type, val, - cp210x_interface_num(serial), dmabuf, bufsize, - USB_CTRL_GET_TIMEOUT); - if (result == bufsize) { - memcpy(buf, dmabuf, bufsize); - result = 0; - } else { + result = usb_control_msg_recv(serial->dev, 0, CP210X_VENDOR_SPECIFIC, + type, val, cp210x_interface_num(serial), + buf, bufsize, USB_CTRL_GET_TIMEOUT, + GFP_KERNEL); + if (result) dev_err(&serial->interface->dev, "failed to get vendor val 0x%04x size %d: %d\n", val, bufsize, result); - if (result >= 0) - result = -EIO; - } - - kfree(dmabuf); return result; } @@ -685,14 +654,13 @@ static int cp210x_write_u16_reg(struct usb_serial_port *port, u8 req, u16 val) struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); int result; - result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - req, REQTYPE_HOST_TO_INTERFACE, val, - port_priv->bInterfaceNumber, NULL, 0, - USB_CTRL_SET_TIMEOUT); - if (result < 0) { + result = usb_control_msg_send(serial->dev, 0, req, + REQTYPE_HOST_TO_INTERFACE, val, + port_priv->bInterfaceNumber, NULL, 0, + USB_CTRL_SET_TIMEOUT, GFP_KERNEL); + if (result) dev_err(&port->dev, "failed set request 0x%x status: %d\n", req, result); - } return result; } @@ -706,28 +674,17 @@ static int cp210x_write_reg_block(struct usb_serial_port *port, u8 req, { struct usb_serial *serial = port->serial; struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); - void *dmabuf; int result; - dmabuf = kmemdup(buf, bufsize, GFP_KERNEL); - if (!dmabuf) - return -ENOMEM; + result = usb_control_msg_send(serial->dev, 0, req, + REQTYPE_HOST_TO_INTERFACE, 0, + port_priv->bInterfaceNumber, buf, bufsize, + USB_CTRL_SET_TIMEOUT, GFP_KERNEL); - result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - req, REQTYPE_HOST_TO_INTERFACE, 0, - port_priv->bInterfaceNumber, dmabuf, bufsize, - USB_CTRL_SET_TIMEOUT); - kfree(dmabuf); - - if (result == bufsize) { - result = 0; - } else { + if (result) dev_err(&port->dev, "failed set req 0x%x size %d status: %d\n", req, bufsize, result); - if (result >= 0) - result = -EIO; - } return result; } @@ -752,29 +709,17 @@ static int cp210x_write_u32_reg(struct usb_serial_port *port, u8 req, u32 val) static int cp210x_write_vendor_block(struct usb_serial *serial, u8 type, u16 val, void *buf, int bufsize) { - void *dmabuf; int result; - dmabuf = kmemdup(buf, bufsize, GFP_KERNEL); - if (!dmabuf) - return -ENOMEM; - - result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - CP210X_VENDOR_SPECIFIC, type, val, - cp210x_interface_num(serial), dmabuf, bufsize, - USB_CTRL_SET_TIMEOUT); - - kfree(dmabuf); + result = usb_control_msg_send(serial->dev, 0, CP210X_VENDOR_SPECIFIC, + type, val, cp210x_interface_num(serial), + buf, bufsize, USB_CTRL_SET_TIMEOUT, + GFP_KERNEL); - if (result == bufsize) { - result = 0; - } else { + if (result) dev_err(&serial->interface->dev, "failed to set vendor val 0x%04x size %d: %d\n", val, bufsize, result); - if (result >= 0) - result = -EIO; - } return result; } @@ -995,27 +940,19 @@ static int cp210x_get_tx_queue_byte_count(struct usb_serial_port *port, { struct usb_serial *serial = port->serial; struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); - struct cp210x_comm_status *sts; + struct cp210x_comm_status sts; int result; - sts = kmalloc(sizeof(*sts), GFP_KERNEL); - if (!sts) - return -ENOMEM; - - result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), - CP210X_GET_COMM_STATUS, REQTYPE_INTERFACE_TO_HOST, - 0, port_priv->bInterfaceNumber, sts, sizeof(*sts), - USB_CTRL_GET_TIMEOUT); - if (result == sizeof(*sts)) { - *count = le32_to_cpu(sts->ulAmountInOutQueue); - result = 0; - } else { + result = usb_control_msg_recv(serial->dev, 0, + CP210X_GET_COMM_STATUS, + REQTYPE_INTERFACE_TO_HOST, 0, + port_priv->bInterfaceNumber, &sts, + sizeof(sts), USB_CTRL_GET_TIMEOUT, + GFP_KERNEL); + if (result == 0) + *count = le32_to_cpu(sts.ulAmountInOutQueue); + else dev_err(&port->dev, "failed to get comm status: %d\n", result); - if (result >= 0) - result = -EIO; - } - - kfree(sts); return result; } @@ -1624,13 +1561,12 @@ static void cp210x_gpio_set(struct gpio_chip *gc, unsigned int gpio, int value) } else { u16 wIndex = buf.state << 8 | buf.mask; - result = usb_control_msg(serial->dev, - usb_sndctrlpipe(serial->dev, 0), - CP210X_VENDOR_SPECIFIC, - REQTYPE_HOST_TO_DEVICE, - CP210X_WRITE_LATCH, - wIndex, - NULL, 0, USB_CTRL_SET_TIMEOUT); + result = usb_control_msg_send(serial->dev, 0, + CP210X_VENDOR_SPECIFIC, + REQTYPE_HOST_TO_DEVICE, + CP210X_WRITE_LATCH, + wIndex, NULL, 0, + USB_CTRL_SET_TIMEOUT, GFP_KERNEL); } usb_autopm_put_interface(serial->interface); From patchwork Wed Nov 4 06:46:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 318370 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 494BFC388F9 for ; Wed, 4 Nov 2020 06:47:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDF05223C6 for ; Wed, 4 Nov 2020 06:47:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TRRDSpAY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728778AbgKDGru (ORCPT ); Wed, 4 Nov 2020 01:47:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbgKDGrt (ORCPT ); Wed, 4 Nov 2020 01:47:49 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CCFCC061A4D; Tue, 3 Nov 2020 22:47:48 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id o3so15722215pgr.11; Tue, 03 Nov 2020 22:47:48 -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; bh=TSlwhbTV17TkpJXdKDkhYenknX5pNJ6noEIgEUfNOLo=; b=TRRDSpAYA+9b7oCBslKQ1lWAPU2pWq6ePYfuMk7OWIOmCYO2KISt5kjdyQpzts62fb 8cZOOiZ2ykFmtNemz4KVrHYmB5z6GLxRGFbyxFu+S+u7pRTCB7fI3B00KMK5p1usfE1i gWD+Zs9HSeMqduwUmrepY0nmP9KgocDkjAKIYSejUn3u2SS6F2Q82WH7+1hbIaozMHr/ JDfsWVCSQgojY/XyyC+qQ8nql3/CZ0q3nOa/5CojdFeX33+uhD97CQTGl0HuLjgUTU1v 3UldhNgw7eXu6XjfSwDWdpFy/Lqop1JX7nNkHVwJ7Fh3MbqsMCBrZl6EBrXO0NWIhh18 RQgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TSlwhbTV17TkpJXdKDkhYenknX5pNJ6noEIgEUfNOLo=; b=DzmfmPxbzOOuukG4/jrdhiLOe9AkmEAnzUFzEAK9EI1ErkT+flVo9M0/kOafqM6UuX B0gXcygs0sDdJXf0e2iFZxkWh126UBO1dlpIQx4A08b8sslxqRSwTcLEfpp8wwd0lN58 6QbMOBR0Tbz7bCw0FKr0AH+ytz8GTRL0rKtjk3AU5h44CLnAH0dVbz5TswZglpjeFKj2 M8V4wz9fAH//vlXsfCPY/heBZ0hvI43T8QwtI1CBh7LzXfTGQRNGqIg38PNF89wOmzIw MiPMLbFZmTJ3807z4XOmEVLRymlm6z0oTb19leP8j2uBY3W4Xs0n4aJrmLQsPbJSHRB5 fxZA== X-Gm-Message-State: AOAM532EZ+EHuzvsHSPKnscKBA2vo88YQqYHOAfjOJkudEF2imT11ObZ +wgTeUkF3sgRi2H8zkoeGIo= X-Google-Smtp-Source: ABdhPJy0TMDgkqBlyzvxX29fFTS8osZu0OWFz7ImWJTXyD7yV/BujyK/XeYXPKrUXl/A7NUMSWAb+g== X-Received: by 2002:a17:90a:d3d5:: with SMTP id d21mr2897977pjw.168.1604472468086; Tue, 03 Nov 2020 22:47:48 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.47.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:47:47 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 05/15] usb: serial: cypress_m8: use usb_control_msg_recv() and usb_control_msg_send() Date: Wed, 4 Nov 2020 12:16:53 +0530 Message-Id: <20201104064703.15123-6-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrappers instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/cypress_m8.c | 38 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/drivers/usb/serial/cypress_m8.c b/drivers/usb/serial/cypress_m8.c index cc028601c388..4d66cab8eece 100644 --- a/drivers/usb/serial/cypress_m8.c +++ b/drivers/usb/serial/cypress_m8.c @@ -341,20 +341,21 @@ static int cypress_serial_control(struct tty_struct *tty, feature_buffer[4]); do { - retval = usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - HID_REQ_SET_REPORT, - USB_DIR_OUT | USB_RECIP_INTERFACE | USB_TYPE_CLASS, - 0x0300, 0, feature_buffer, - feature_len, 500); + retval = usb_control_msg_send(port->serial->dev, 0, + HID_REQ_SET_REPORT, + USB_DIR_OUT | + USB_RECIP_INTERFACE | + USB_TYPE_CLASS, 0x0300, + 0, feature_buffer, + feature_len, 500, + GFP_KERNEL); if (tries++ >= 3) break; - } while (retval != feature_len && - retval != -ENODEV); + } while (retval != -ENODEV); - if (retval != feature_len) { + if (retval) { dev_err(dev, "%s - failed sending serial line settings - %d\n", __func__, retval); cypress_set_dead(port); @@ -379,19 +380,20 @@ static int cypress_serial_control(struct tty_struct *tty, } dev_dbg(dev, "%s - retrieving serial line settings\n", __func__); do { - retval = usb_control_msg(port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0), - HID_REQ_GET_REPORT, - USB_DIR_IN | USB_RECIP_INTERFACE | USB_TYPE_CLASS, - 0x0300, 0, feature_buffer, - feature_len, 500); + retval = usb_control_msg_recv(port->serial->dev, 0, + HID_REQ_GET_REPORT, + USB_DIR_IN | + USB_RECIP_INTERFACE | + USB_TYPE_CLASS, 0x0300, + 0, feature_buffer, + feature_len, 500, + GFP_KERNEL); if (tries++ >= 3) break; - } while (retval != feature_len - && retval != -ENODEV); + } while (retval != -ENODEV); - if (retval != feature_len) { + if (retval) { dev_err(dev, "%s - failed to retrieve serial line settings - %d\n", __func__, retval); cypress_set_dead(port); From patchwork Wed Nov 4 06:46:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 315504 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 C4B00C2D0A3 for ; Wed, 4 Nov 2020 06:47:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F3A1223C6 for ; Wed, 4 Nov 2020 06:47:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m+E6aOeg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728906AbgKDGrx (ORCPT ); Wed, 4 Nov 2020 01:47:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbgKDGrw (ORCPT ); Wed, 4 Nov 2020 01:47:52 -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 03C91C040203; Tue, 3 Nov 2020 22:47:52 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id x13so16489698pfa.9; Tue, 03 Nov 2020 22:47:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XBI1Crl/gsGXbbSC9BdECEbU8Eop484Fu7YnX4s2KCI=; b=m+E6aOegAQX7/eaZA7zz/VkVlNlQU1g1l4KUxB/l05xKwUXlPo91NshtD7iV/dNcP8 pUIhatW7I6vplsSlVMkbHyP+Rkw8OqMqkuptDmJK5WgR1tvOrmVH6lehbvz/Z0IJCmeI HvJEBWb7e70+rlWkFwuNT1NrCLkk5p5FoPPKW6x0tCTgmIlLyFoT+FFlbLlcTib1oy1R pn8XwZIFTv6hWjkX++sYVO67pRewBrWKuTci2KPuWF3q5mQZQi68xhRbHQNwN69E9WSn z9exQzlAZglQXOEJbMfgSNmFDj8arz1I/ygfxQa39D/jTd7qYTPwJxpoPckGD+b8rPN7 FYYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XBI1Crl/gsGXbbSC9BdECEbU8Eop484Fu7YnX4s2KCI=; b=eU2TCtyvuKNnVq3D+SmUDdZufGg523Nz6gI5rWXAbuFYhEN8dhtetGQp8z3KNgdJxk A5GE0LXoXEus+hAULyMxy7w9oCuExRbsVqVxJolu2HVQ79FtpQOK+tu50pVKfl6T96dw Tixvwmvt9Krb1zZABiTr63bxKhi9rLnFdCZkLHVmV4ZwJdJV1dk/50dppFSVW7+PsFsi 7ctJqzSPQTkxZoaQGad7o3+PScywDh1Z1BT7TceV5AwguMXoP0xipLINc+gAXpcIAYnp lyZyevJluAKivsHV7mLoCiWxKguxFTVphty3g0370RYP+Or7tp7ibZQlXLB5m13A063q cDjQ== X-Gm-Message-State: AOAM530aIyijQHGkCFZJu8FJ45FMGEAJg4c+ZKSKYxYM0N3tevPXtqHX CF+nTB0ATqfZiOVJJtKLz3Q= X-Google-Smtp-Source: ABdhPJxyahSG3Vg1L10IOgHREuHBbGgfWEMvNNEfg8kcJOgNP3l4vTYkhWXcdi1L8TDTBk4Blnx9nQ== X-Received: by 2002:a63:4825:: with SMTP id v37mr20000208pga.256.1604472471640; Tue, 03 Nov 2020 22:47:51 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.47.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:47:51 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 06/15] usb: serial: f81232: use usb_control_msg_recv() and usb_control_msg_send() Date: Wed, 4 Nov 2020 12:16:54 +0530 Message-Id: <20201104064703.15123-7-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrappers instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/f81232.c | 88 ++++++++----------------------------- 1 file changed, 18 insertions(+), 70 deletions(-) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 0c7eacc630e0..78107feef8a8 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -139,71 +139,36 @@ static int calc_baud_divisor(speed_t baudrate, speed_t clockrate) static int f81232_get_register(struct usb_serial_port *port, u16 reg, u8 *val) { int status; - u8 *tmp; struct usb_device *dev = port->serial->dev; - tmp = kmalloc(sizeof(*val), GFP_KERNEL); - if (!tmp) - return -ENOMEM; - - status = usb_control_msg(dev, - usb_rcvctrlpipe(dev, 0), - F81232_REGISTER_REQUEST, - F81232_GET_REGISTER, - reg, - 0, - tmp, - sizeof(*val), - USB_CTRL_GET_TIMEOUT); - if (status != sizeof(*val)) { + status = usb_control_msg_recv(dev, 0, F81232_REGISTER_REQUEST, + F81232_GET_REGISTER, reg, 0, val, + sizeof(*val), USB_CTRL_GET_TIMEOUT, + GFP_KERNEL); + if (status) { dev_err(&port->dev, "%s failed status: %d\n", __func__, status); - if (status < 0) - status = usb_translate_errors(status); - else - status = -EIO; - } else { - status = 0; - *val = *tmp; + status = usb_translate_errors(status); } - kfree(tmp); return status; } static int f81232_set_register(struct usb_serial_port *port, u16 reg, u8 val) { int status; - u8 *tmp; struct usb_device *dev = port->serial->dev; - tmp = kmalloc(sizeof(val), GFP_KERNEL); - if (!tmp) - return -ENOMEM; - - *tmp = val; - - status = usb_control_msg(dev, - usb_sndctrlpipe(dev, 0), - F81232_REGISTER_REQUEST, - F81232_SET_REGISTER, - reg, - 0, - tmp, - sizeof(val), - USB_CTRL_SET_TIMEOUT); - if (status != sizeof(val)) { + status = usb_control_msg_send(dev, 0, + F81232_REGISTER_REQUEST, + F81232_SET_REGISTER, reg, 0, + &val, sizeof(val), USB_CTRL_SET_TIMEOUT, + GFP_KERNEL); + if (status) { dev_err(&port->dev, "%s failed status: %d\n", __func__, status); - if (status < 0) - status = usb_translate_errors(status); - else - status = -EIO; - } else { - status = 0; + status = usb_translate_errors(status); } - - kfree(tmp); return status; } @@ -866,32 +831,16 @@ static int f81534a_ctrl_set_register(struct usb_interface *intf, u16 reg, struct usb_device *dev = interface_to_usbdev(intf); int retry = F81534A_ACCESS_REG_RETRY; int status; - u8 *tmp; - - tmp = kmemdup(val, size, GFP_KERNEL); - if (!tmp) - return -ENOMEM; while (retry--) { - status = usb_control_msg(dev, - usb_sndctrlpipe(dev, 0), - F81232_REGISTER_REQUEST, - F81232_SET_REGISTER, - reg, - 0, - tmp, - size, - USB_CTRL_SET_TIMEOUT); - if (status < 0) { + status = usb_control_msg_send(dev, 0, F81232_REGISTER_REQUEST, + F81232_SET_REGISTER, reg, 0, val, + size, USB_CTRL_SET_TIMEOUT, GFP_KERNEL); + if (status) { + /* Retry on error or short transfers */ status = usb_translate_errors(status); if (status == -EIO) continue; - } else if (status != size) { - /* Retry on short transfers */ - status = -EIO; - continue; - } else { - status = 0; } break; @@ -902,7 +851,6 @@ static int f81534a_ctrl_set_register(struct usb_interface *intf, u16 reg, reg, status); } - kfree(tmp); return status; } From patchwork Wed Nov 4 06:46:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 315503 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 DA17FC55178 for ; Wed, 4 Nov 2020 06:47:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8E6B22236F for ; Wed, 4 Nov 2020 06:47:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LGMsvBSA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728989AbgKDGr6 (ORCPT ); Wed, 4 Nov 2020 01:47:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728711AbgKDGr5 (ORCPT ); Wed, 4 Nov 2020 01:47:57 -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 364DAC061A4D; Tue, 3 Nov 2020 22:47:56 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id 10so16499474pfp.5; Tue, 03 Nov 2020 22:47:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Gj3vhr1jCB9Dg5NnjmQRggTwPs6mgGI9aVvWxKxd4YM=; b=LGMsvBSA5gQwLgkvnOtNA/ctaxR/E125DO1k+uIzy8+IItaLrI13+92z9tUKubJ9VX GTUh+oetORPbEjpLw6kRJPhQlanj/eFr7ZmgmkZ3if/3vzTeI0D0evPTE2iO7fDnhqTh zmp2sU8c8zTFcnT/qGhh/G5K7qr8DElmk6J7LHoJPbp27iyk+hyC/OflbKdaCpLiDJd5 yhcd2VBlQY1RNmjWfzb6SC0cb4vjh++6YTekI/TODPfwmKF3bm3pp1Ex1Sh7Cbjcbzlu Tls94X0O8/vQhL2pJr5uytezbDhLEWq+CPJfErobLvgKSNWICIu/n9HbhXQB/XFTMrna VjuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Gj3vhr1jCB9Dg5NnjmQRggTwPs6mgGI9aVvWxKxd4YM=; b=beEhgYMoMHE/jbuqBl03WeAJwKZa4u0Xf3i+61XRrHW59HlWG6fK62nfb0RMkd4u7H 7KetS2CV+SS/2YsFJnNyLp5pOrFpyGzeCTiIacqwkzLwHCwCApSa351KVbGNi6hnJuQY /EUaoQl3imPFEVULWe3mlFkWUZ+bcy0UhFkFAP3fmRJ+Q9oWwmFZVa0mN1BlG8vlCQ6E oDdal4MSKGrZq9nNHKgnsekbY6PlhKSR6FvimbH0302z70FjfLCi9RGTHcsMqdvyYkWZ QRp8fLune7HUUQO/CBC+qlndSPTYByPijXcsvE322LATJJ8UuUu588giVFVZ3EZwtIsG 3m/w== X-Gm-Message-State: AOAM532DomMs0Y2g2L7RzFC3mJTlLQukk3Vc/paI9OWR55TKqj/ojuuC IaTENuiV5+mvlXrXKmRqwng= X-Google-Smtp-Source: ABdhPJwpRtZ7gPzaBfsGb4ipy/z5/ycwX0Yqva3is6V9+uWWx9rwD7uszHRbk8NvkHmAbfSr70TXBQ== X-Received: by 2002:a63:381:: with SMTP id 123mr6416620pgd.112.1604472475787; Tue, 03 Nov 2020 22:47:55 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.47.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:47:55 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 07/15] usb: serial: f81534: use usb_control_msg_recv() and usb_control_msg_send() Date: Wed, 4 Nov 2020 12:16:55 +0530 Message-Id: <20201104064703.15123-8-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrappers instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/f81534.c | 63 +++++++++++-------------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/drivers/usb/serial/f81534.c b/drivers/usb/serial/f81534.c index 5661fd03e545..23eb17a2c052 100644 --- a/drivers/usb/serial/f81534.c +++ b/drivers/usb/serial/f81534.c @@ -217,38 +217,26 @@ static int f81534_set_register(struct usb_serial *serial, u16 reg, u8 data) struct usb_device *dev = serial->dev; size_t count = F81534_USB_MAX_RETRY; int status; - u8 *tmp; - - tmp = kmalloc(sizeof(u8), GFP_KERNEL); - if (!tmp) - return -ENOMEM; - - *tmp = data; /* * Our device maybe not reply when heavily loading, We'll retry for * F81534_USB_MAX_RETRY times. */ while (count--) { - status = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - F81534_SET_GET_REGISTER, - USB_TYPE_VENDOR | USB_DIR_OUT, - reg, 0, tmp, sizeof(u8), - F81534_USB_TIMEOUT); - if (status > 0) { - status = 0; - break; - } else if (status == 0) { - status = -EIO; + status = usb_control_msg_send(dev, 0, F81534_SET_GET_REGISTER, + USB_TYPE_VENDOR | USB_DIR_OUT, + reg, 0, &data, sizeof(u8), + F81534_USB_TIMEOUT, GFP_KERNEL); + if (status) { + /* Try again */ + continue; } } - if (status < 0) { + if (status) dev_err(&interface->dev, "%s: reg: %x data: %x failed: %d\n", - __func__, reg, data, status); - } + __func__, reg, data, status); - kfree(tmp); return status; } @@ -258,40 +246,25 @@ static int f81534_get_register(struct usb_serial *serial, u16 reg, u8 *data) struct usb_device *dev = serial->dev; size_t count = F81534_USB_MAX_RETRY; int status; - u8 *tmp; - - tmp = kmalloc(sizeof(u8), GFP_KERNEL); - if (!tmp) - return -ENOMEM; /* * Our device maybe not reply when heavily loading, We'll retry for * F81534_USB_MAX_RETRY times. */ while (count--) { - status = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), - F81534_SET_GET_REGISTER, - USB_TYPE_VENDOR | USB_DIR_IN, - reg, 0, tmp, sizeof(u8), - F81534_USB_TIMEOUT); - if (status > 0) { - status = 0; - break; - } else if (status == 0) { - status = -EIO; + status = usb_control_msg_recv(dev, 0, F81534_SET_GET_REGISTER, + USB_TYPE_VENDOR | USB_DIR_IN, reg, + 0, data, sizeof(u8), + F81534_USB_TIMEOUT, GFP_KERNEL); + if (status) { + /* Try again */ + continue; } } - if (status < 0) { + if (status) dev_err(&interface->dev, "%s: reg: %x failed: %d\n", __func__, - reg, status); - goto end; - } - - *data = *tmp; - -end: - kfree(tmp); + reg, status); return status; } From patchwork Wed Nov 4 06:46:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 318369 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 E978CC388F9 for ; Wed, 4 Nov 2020 06:48:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8954422277 for ; Wed, 4 Nov 2020 06:48:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MYE0aP2s" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729049AbgKDGsB (ORCPT ); Wed, 4 Nov 2020 01:48:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbgKDGsA (ORCPT ); Wed, 4 Nov 2020 01:48:00 -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 618AFC061A4D; Tue, 3 Nov 2020 22:48:00 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id 72so9797243pfv.7; Tue, 03 Nov 2020 22:48:00 -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; bh=dpWiQNpplpqqXHZdrnmhkGJL1ecVpKlvWB6beWz5Buc=; b=MYE0aP2sTJ28zHydRlEZpqrjSq0Ni8YgJJcdXzKs6AtEoJiQPXeJYtidrVhHQFJGgq Et08mk2FJgezufH4+f2VACRRq3eKJD1J1e3RluUuUGYJr+5jGegsig0SXTZpis6CWzX0 YzAkaPdmL21C96QDOFFCJXClajtC36ifWWpSet9CJIFA951Bv7CYpE1zBkXvLk1fhK5b uh5nQHsGzlWW6ToVv/bErPFFDUGRaaJEktup8ID8TVHgQe5L3qdYBjGbeoV57/ckjtu5 2A8658/P3R8kVOgqtPHE9DgJBQATqr1TIHGl4g+EbB3B5+205Aurj17ADH0n31Pz69SU w5XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dpWiQNpplpqqXHZdrnmhkGJL1ecVpKlvWB6beWz5Buc=; b=gpYV3ZSN1ccTi5ahUxoFa/mkOfNYEx1442o266YxZz7dlgI/2wX6p+jrAyBnKavPgZ Rull5Z54LXoyTxGOi5seoRmBrWhbnPb7xOiLMxa+QHo9mSae/8H53cmMZ93yh6h2zYfv h3W8et9ZYunKdSu4rTrlNFyRmBhCOxx7KuvHXIGeuWh9zsRbgIfgiBGMqUiMsNtw8gnm CvtYCoRVEKAE2yC5j7BTn2Zi6BVawkyEYzVN4BCH368EwW4t6Opcgs0JiAFMrYyFAwn/ yNVISCl+rWTtKuC/tpdOYHbahbi+4M8Fdns9k/7IyEZKRwAey2sAbyDSMPIF8j9IklcY kyoQ== X-Gm-Message-State: AOAM532IzE+ljtOT7OJeikahKfvlzh+8hv6bZtRhw/bJoaypHkiUInTe e7BROdksYtDcGmCG2fXh09c= X-Google-Smtp-Source: ABdhPJw0JU8dTd5DFfKgoSD0DK+rO+h/ugVmblHCRx0FgcpjSvB7Yg3dLqGfeFFqMKtKs8IGjzrz3w== X-Received: by 2002:a63:b10:: with SMTP id 16mr1119840pgl.309.1604472479959; Tue, 03 Nov 2020 22:47:59 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:47:59 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 08/15] usb: serial: ftdi_sio: use usb_control_msg_recv() and usb_control_msg_send() Date: Wed, 4 Nov 2020 12:16:56 +0530 Message-Id: <20201104064703.15123-9-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrappers instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/ftdi_sio.c | 182 +++++++++++++++------------------- 1 file changed, 78 insertions(+), 104 deletions(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index e0f4c3d9649c..37e9e75b90d0 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -1245,13 +1245,12 @@ static int update_mctrl(struct usb_serial_port *port, unsigned int set, value |= FTDI_SIO_SET_DTR_HIGH; if (set & TIOCM_RTS) value |= FTDI_SIO_SET_RTS_HIGH; - rv = usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - FTDI_SIO_SET_MODEM_CTRL_REQUEST, - FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, - value, priv->interface, - NULL, 0, WDR_TIMEOUT); - if (rv < 0) { + rv = usb_control_msg_send(port->serial->dev, 0, + FTDI_SIO_SET_MODEM_CTRL_REQUEST, + FTDI_SIO_SET_MODEM_CTRL_REQUEST_TYPE, + value, priv->interface, + NULL, 0, WDR_TIMEOUT, GFP_KERNEL); + if (rv) { dev_dbg(dev, "%s Error from MODEM_CTRL urb: DTR %s, RTS %s\n", __func__, (set & TIOCM_DTR) ? "HIGH" : (clear & TIOCM_DTR) ? "LOW" : "unchanged", @@ -1393,12 +1392,11 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) index = (u16)((index << 8) | priv->interface); } - rv = usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - FTDI_SIO_SET_BAUDRATE_REQUEST, - FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, - value, index, - NULL, 0, WDR_SHORT_TIMEOUT); + rv = usb_control_msg_send(port->serial->dev, 0, + FTDI_SIO_SET_BAUDRATE_REQUEST, + FTDI_SIO_SET_BAUDRATE_REQUEST_TYPE, + value, index, + NULL, 0, WDR_SHORT_TIMEOUT, GFP_KERNEL); return rv; } @@ -1417,13 +1415,12 @@ static int write_latency_timer(struct usb_serial_port *port) dev_dbg(&port->dev, "%s: setting latency timer = %i\n", __func__, l); - rv = usb_control_msg(udev, - usb_sndctrlpipe(udev, 0), - FTDI_SIO_SET_LATENCY_TIMER_REQUEST, - FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, - l, priv->interface, - NULL, 0, WDR_TIMEOUT); - if (rv < 0) + rv = usb_control_msg_send(udev, 0, + FTDI_SIO_SET_LATENCY_TIMER_REQUEST, + FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, + l, priv->interface, + NULL, 0, WDR_TIMEOUT, GFP_KERNEL); + if (rv) dev_err(&port->dev, "Unable to write latency timer: %i\n", rv); return rv; } @@ -1432,27 +1429,16 @@ static int _read_latency_timer(struct usb_serial_port *port) { struct ftdi_private *priv = usb_get_serial_port_data(port); struct usb_device *udev = port->serial->dev; - unsigned char *buf; + u8 buf; int rv; - buf = kmalloc(1, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - rv = usb_control_msg(udev, - usb_rcvctrlpipe(udev, 0), - FTDI_SIO_GET_LATENCY_TIMER_REQUEST, - FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, - 0, priv->interface, - buf, 1, WDR_TIMEOUT); - if (rv < 1) { - if (rv >= 0) - rv = -EIO; - } else { - rv = buf[0]; - } - - kfree(buf); + rv = usb_control_msg_recv(udev, 0, + FTDI_SIO_GET_LATENCY_TIMER_REQUEST, + FTDI_SIO_GET_LATENCY_TIMER_REQUEST_TYPE, + 0, priv->interface, + &buf, 1, WDR_TIMEOUT, GFP_KERNEL); + if (rv == 0) + rv = buf; return rv; } @@ -1731,13 +1717,12 @@ static ssize_t event_char_store(struct device *dev, dev_dbg(&port->dev, "%s: setting event char = 0x%03x\n", __func__, v); - rv = usb_control_msg(udev, - usb_sndctrlpipe(udev, 0), - FTDI_SIO_SET_EVENT_CHAR_REQUEST, - FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, - v, priv->interface, - NULL, 0, WDR_TIMEOUT); - if (rv < 0) { + rv = usb_control_msg_send(udev, 0, + FTDI_SIO_SET_EVENT_CHAR_REQUEST, + FTDI_SIO_SET_EVENT_CHAR_REQUEST_TYPE, + v, priv->interface, + NULL, 0, WDR_TIMEOUT, GFP_KERNEL); + if (rv) { dev_dbg(&port->dev, "Unable to write event character: %i\n", rv); return -EIO; } @@ -1805,12 +1790,12 @@ static int ftdi_set_bitmode(struct usb_serial_port *port, u8 mode) return result; val = (mode << 8) | (priv->gpio_output << 4) | priv->gpio_value; - result = usb_control_msg(serial->dev, - usb_sndctrlpipe(serial->dev, 0), - FTDI_SIO_SET_BITMODE_REQUEST, - FTDI_SIO_SET_BITMODE_REQUEST_TYPE, val, - priv->interface, NULL, 0, WDR_TIMEOUT); - if (result < 0) { + result = usb_control_msg_send(serial->dev, 0, + FTDI_SIO_SET_BITMODE_REQUEST, + FTDI_SIO_SET_BITMODE_REQUEST_TYPE, val, + priv->interface, NULL, 0, WDR_TIMEOUT, + GFP_KERNEL); + if (result) { dev_err(&serial->interface->dev, "bitmode request failed for value 0x%04x: %d\n", val, result); @@ -1866,32 +1851,21 @@ static int ftdi_read_cbus_pins(struct usb_serial_port *port) { struct ftdi_private *priv = usb_get_serial_port_data(port); struct usb_serial *serial = port->serial; - unsigned char *buf; + u8 buf; int result; result = usb_autopm_get_interface(serial->interface); if (result) return result; - buf = kmalloc(1, GFP_KERNEL); - if (!buf) { - usb_autopm_put_interface(serial->interface); - return -ENOMEM; - } - - result = usb_control_msg(serial->dev, - usb_rcvctrlpipe(serial->dev, 0), - FTDI_SIO_READ_PINS_REQUEST, - FTDI_SIO_READ_PINS_REQUEST_TYPE, 0, - priv->interface, buf, 1, WDR_TIMEOUT); - if (result < 1) { - if (result >= 0) - result = -EIO; - } else { - result = buf[0]; - } + result = usb_control_msg_recv(serial->dev, 0, + FTDI_SIO_READ_PINS_REQUEST, + FTDI_SIO_READ_PINS_REQUEST_TYPE, 0, + priv->interface, &buf, 1, WDR_TIMEOUT, + GFP_KERNEL); + if (result == 0) + result = buf; - kfree(buf); usb_autopm_put_interface(serial->interface); return result; @@ -2311,6 +2285,7 @@ static int ftdi_NDI_device_setup(struct usb_serial *serial) { struct usb_device *udev = serial->dev; int latency = ndi_latency_timer; + int ret; if (latency == 0) latency = 1; @@ -2320,12 +2295,12 @@ static int ftdi_NDI_device_setup(struct usb_serial *serial) dev_dbg(&udev->dev, "%s setting NDI device latency to %d\n", __func__, latency); dev_info(&udev->dev, "NDI device with a latency value of %d\n", latency); - /* FIXME: errors are not returned */ - usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - FTDI_SIO_SET_LATENCY_TIMER_REQUEST, - FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, - latency, 0, NULL, 0, WDR_TIMEOUT); - return 0; + ret = usb_control_msg_send(udev, 0, + FTDI_SIO_SET_LATENCY_TIMER_REQUEST, + FTDI_SIO_SET_LATENCY_TIMER_REQUEST_TYPE, + latency, 0, NULL, 0, WDR_TIMEOUT, + GFP_KERNEL); + return ret; } /* @@ -2424,12 +2399,11 @@ static void ftdi_dtr_rts(struct usb_serial_port *port, int on) /* Disable flow control */ if (!on) { - if (usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - FTDI_SIO_SET_FLOW_CTRL_REQUEST, - FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, - 0, priv->interface, NULL, 0, - WDR_TIMEOUT) < 0) { + if (usb_control_msg_send(port->serial->dev, 0, + FTDI_SIO_SET_FLOW_CTRL_REQUEST, + FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, + 0, priv->interface, NULL, 0, + WDR_TIMEOUT, GFP_KERNEL)) { dev_err(&port->dev, "error from flowcontrol urb\n"); } } @@ -2617,12 +2591,11 @@ static void ftdi_break_ctl(struct tty_struct *tty, int break_state) else value = priv->last_set_data_value; - if (usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - FTDI_SIO_SET_DATA_REQUEST, - FTDI_SIO_SET_DATA_REQUEST_TYPE, - value , priv->interface, - NULL, 0, WDR_TIMEOUT) < 0) { + if (usb_control_msg_send(port->serial->dev, 0, + FTDI_SIO_SET_DATA_REQUEST, + FTDI_SIO_SET_DATA_REQUEST_TYPE, + value, priv->interface, + NULL, 0, WDR_TIMEOUT, GFP_KERNEL)) { dev_err(&port->dev, "%s FAILED to enable/disable break state (state was %d)\n", __func__, break_state); } @@ -2754,11 +2727,11 @@ static void ftdi_set_termios(struct tty_struct *tty, - but is or'ed with this value */ priv->last_set_data_value = value; - if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - FTDI_SIO_SET_DATA_REQUEST, - FTDI_SIO_SET_DATA_REQUEST_TYPE, - value , priv->interface, - NULL, 0, WDR_SHORT_TIMEOUT) < 0) { + if (usb_control_msg_send(dev, 0, + FTDI_SIO_SET_DATA_REQUEST, + FTDI_SIO_SET_DATA_REQUEST_TYPE, + value, priv->interface, + NULL, 0, WDR_SHORT_TIMEOUT, GFP_KERNEL)) { dev_err(ddev, "%s FAILED to set databits/stopbits/parity\n", __func__); } @@ -2767,11 +2740,11 @@ static void ftdi_set_termios(struct tty_struct *tty, no_data_parity_stop_changes: if ((cflag & CBAUD) == B0) { /* Disable flow control */ - if (usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - FTDI_SIO_SET_FLOW_CTRL_REQUEST, - FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, - 0, priv->interface, - NULL, 0, WDR_TIMEOUT) < 0) { + if (usb_control_msg_send(dev, 0, + FTDI_SIO_SET_FLOW_CTRL_REQUEST, + FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, + 0, priv->interface, + NULL, 0, WDR_TIMEOUT, GFP_KERNEL)) { dev_err(ddev, "%s error from disable flowcontrol urb\n", __func__); } @@ -2806,11 +2779,12 @@ static void ftdi_set_termios(struct tty_struct *tty, index |= priv->interface; - ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), - FTDI_SIO_SET_FLOW_CTRL_REQUEST, - FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, - value, index, NULL, 0, WDR_TIMEOUT); - if (ret < 0) + ret = usb_control_msg_send(dev, 0, + FTDI_SIO_SET_FLOW_CTRL_REQUEST, + FTDI_SIO_SET_FLOW_CTRL_REQUEST_TYPE, + value, index, NULL, 0, WDR_TIMEOUT, + GFP_KERNEL); + if (ret) dev_err(&port->dev, "failed to set flow control: %d\n", ret); } From patchwork Wed Nov 4 06:46:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 315499 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 1C38BC388F9 for ; Wed, 4 Nov 2020 06:48:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B282D22277 for ; Wed, 4 Nov 2020 06:48:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EPFgct1d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729097AbgKDGsI (ORCPT ); Wed, 4 Nov 2020 01:48:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726225AbgKDGsE (ORCPT ); Wed, 4 Nov 2020 01:48:04 -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 AFF48C061A4D; Tue, 3 Nov 2020 22:48:03 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id t22so9819633plr.9; Tue, 03 Nov 2020 22:48:03 -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; bh=l8NSTxxpQrexkPYVhXT7jvvYAIXTQNPEWoW4LpKJ/RY=; b=EPFgct1dcoqTz7O1M327HwD+IZWgzUe5fzd7bcCEVLeuBTFY+Xh3FiLDgwRbOthgFE Mb8aQA1XYkqVQI6I2LazCjQzy6pJStpC4OKpSeOp7T63ju8SGeHQTIzlsOL2KA7WOs8Y yicCT3K+Tgj/EBEi9y+0knIqkUokXN/kt93MR+40bEbMTcO4RkEAyCmLaKzLRSmB6f2X 1qG3ilfmdt9ER3217RFUm2xWame3Df97ffKO+3Zg6IRZvfcg8zmS+7/+VAvGY9Q55GOJ 1jRESsr4tt8HBjkEVbeLnDZ8zXC934qignZ2vEET2P7QNLaV+/CxG29CjHNDqnZcNYrV g8LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=l8NSTxxpQrexkPYVhXT7jvvYAIXTQNPEWoW4LpKJ/RY=; b=RTmlmAwAOFSYdm8v+K8n6m4sxlIFLuaPpiA180asC+ZyvDWWuAVifMRZ7HXLzK5NBy kxtqIMCxcnOQUZGiXECBABMjbcfBGiw7HNE8brqYBUqgk5CulAay111H0V3OybM5FtTR LUinxDzSwpHzGZ/lbsINYObu4qNe0P9gZtAT5FFLJYFnbVyd0KhfGqtivClVDEdaJ54b SLllG+SRp7jpS5Ff6PeehHOIS4cVtL/X+jrsWRK9I78i8ShVaalRdE1YH+O85Ib9bIK5 2K/gEU3AieBCakJxlhDdd8WuNmkPeVi11f812WwoypHhe3MQTh4ZyJntOQCKt/tLbzPj ZSWA== X-Gm-Message-State: AOAM531upjjK9ekqqG1cezQRMrnPK85pnTp8jEzuQu8MHfREbCYM6EUA wuNI0aL2xZnevW6K7Gq5TsY= X-Google-Smtp-Source: ABdhPJzPQj7n6uicFaevWxSN0ch/aIA432vzngGoXIpK795g7+01js+d+9OiTwm6HL/9MW7/aUTcCw== X-Received: by 2002:a17:902:c20a:b029:d6:b2d6:8006 with SMTP id 10-20020a170902c20ab02900d6b2d68006mr19396172pll.31.1604472483191; Tue, 03 Nov 2020 22:48:03 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.48.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:02 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 09/15] usb: serial: io_edgeport: use usb_control_msg_recv() and usb_control_msg_send() Date: Wed, 4 Nov 2020 12:16:57 +0530 Message-Id: <20201104064703.15123-10-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrappers instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/io_edgeport.c | 73 ++++++++++++-------------------- 1 file changed, 27 insertions(+), 46 deletions(-) diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c index ba5d8df69518..8479d5684af7 100644 --- a/drivers/usb/serial/io_edgeport.c +++ b/drivers/usb/serial/io_edgeport.c @@ -568,34 +568,29 @@ static int get_epic_descriptor(struct edgeport_serial *ep) int result; struct usb_serial *serial = ep->serial; struct edgeport_product_info *product_info = &ep->product_info; - struct edge_compatibility_descriptor *epic; + struct edge_compatibility_descriptor epic; struct edge_compatibility_bits *bits; struct device *dev = &serial->dev->dev; ep->is_epic = 0; - epic = kmalloc(sizeof(*epic), GFP_KERNEL); - if (!epic) - return -ENOMEM; - - result = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), - USB_REQUEST_ION_GET_EPIC_DESC, - 0xC0, 0x00, 0x00, - epic, sizeof(*epic), - 300); - if (result == sizeof(*epic)) { + result = usb_control_msg_recv(serial->dev, 0, + USB_REQUEST_ION_GET_EPIC_DESC, 0xC0, + 0x00, 0x00, &epic, sizeof(epic), 300, + GFP_KERNEL); + if (result) { ep->is_epic = 1; - memcpy(&ep->epic_descriptor, epic, sizeof(*epic)); + memcpy(&ep->epic_descriptor, &epic, sizeof(epic)); memset(product_info, 0, sizeof(struct edgeport_product_info)); - product_info->NumPorts = epic->NumPorts; + product_info->NumPorts = epic.NumPorts; product_info->ProdInfoVer = 0; - product_info->FirmwareMajorVersion = epic->MajorVersion; - product_info->FirmwareMinorVersion = epic->MinorVersion; - product_info->FirmwareBuildNumber = epic->BuildNumber; - product_info->iDownloadFile = epic->iDownloadFile; - product_info->EpicVer = epic->EpicVer; - product_info->Epic = epic->Supports; + product_info->FirmwareMajorVersion = epic.MajorVersion; + product_info->FirmwareMinorVersion = epic.MinorVersion; + product_info->FirmwareBuildNumber = epic.BuildNumber; + product_info->iDownloadFile = epic.iDownloadFile; + product_info->EpicVer = epic.EpicVer; + product_info->Epic = epic.Supports; product_info->ProductId = ION_DEVICE_ID_EDGEPORT_COMPATIBLE; dump_product_info(ep, product_info); @@ -614,16 +609,12 @@ static int get_epic_descriptor(struct edgeport_serial *ep) dev_dbg(dev, " IOSPWriteLCR : %s\n", bits->IOSPWriteLCR ? "TRUE": "FALSE"); dev_dbg(dev, " IOSPSetBaudRate : %s\n", bits->IOSPSetBaudRate ? "TRUE": "FALSE"); dev_dbg(dev, " TrueEdgeport : %s\n", bits->TrueEdgeport ? "TRUE": "FALSE"); - - result = 0; - } else if (result >= 0) { + } else { dev_warn(&serial->interface->dev, "short epic descriptor received: %d\n", result); result = -EIO; } - kfree(epic); - return result; } @@ -2168,11 +2159,6 @@ static int rom_read(struct usb_serial *serial, __u16 extAddr, { int result; __u16 current_length; - unsigned char *transfer_buffer; - - transfer_buffer = kmalloc(64, GFP_KERNEL); - if (!transfer_buffer) - return -ENOMEM; /* need to split these reads up into 64 byte chunks */ result = 0; @@ -2181,25 +2167,18 @@ static int rom_read(struct usb_serial *serial, __u16 extAddr, current_length = 64; else current_length = length; - result = usb_control_msg(serial->dev, - usb_rcvctrlpipe(serial->dev, 0), - USB_REQUEST_ION_READ_ROM, - 0xC0, addr, extAddr, transfer_buffer, - current_length, 300); - if (result < current_length) { - if (result >= 0) - result = -EIO; + result = usb_control_msg_recv(serial->dev, 0, + USB_REQUEST_ION_READ_ROM, 0xC0, + addr, extAddr, data, + current_length, 300, GFP_KERNEL); + if (result) break; - } - memcpy(data, transfer_buffer, current_length); + length -= current_length; addr += current_length; data += current_length; - result = 0; } - - kfree(transfer_buffer); return result; } @@ -2801,10 +2780,12 @@ static void load_application_firmware(struct edgeport_serial *edge_serial) } dev_dbg(dev, "sending exec_dl_code\n"); - response = usb_control_msg (edge_serial->serial->dev, - usb_sndctrlpipe(edge_serial->serial->dev, 0), - USB_REQUEST_ION_EXEC_DL_CODE, - 0x40, 0x4000, 0x0001, NULL, 0, 3000); + response = usb_control_msg_send(edge_serial->serial->dev, 0, + USB_REQUEST_ION_EXEC_DL_CODE, + 0x40, 0x4000, 0x0001, NULL, 0, 3000, + GFP_KERNEL); + if (response) + dev_err(dev, "failed sending exec_dl_decode %d\n", response); release_firmware(fw); } From patchwork Wed Nov 4 06:46:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 315502 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 A8769C2D0A3 for ; Wed, 4 Nov 2020 06:48:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 505EB2236F for ; Wed, 4 Nov 2020 06:48:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rdS5MU5L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729122AbgKDGsI (ORCPT ); Wed, 4 Nov 2020 01:48:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727089AbgKDGsH (ORCPT ); Wed, 4 Nov 2020 01:48:07 -0500 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC00CC061A4D; Tue, 3 Nov 2020 22:48:07 -0800 (PST) Received: by mail-pg1-x541.google.com with SMTP id o3so15722924pgr.11; Tue, 03 Nov 2020 22:48:07 -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; bh=UZc9qlgFs8CbchOrOL+r6fXR+9YC4L2N3YMq7bhJ0+0=; b=rdS5MU5L79qRpQTiXpdQThWirVZOcLRFimad1oO/csh5TOxT5lXTLaOvUbMGHrEa86 ab8w6iGGzfk4onE5Gy482ldjBhqdEgPQ9NKbtnkuzxqHkb2MCRJ4+M9FwuXD+ORRdCGx gbZEP3TAX4uCrjWdpnSMmOxeOMd13gUSgN2DpyPjCzCsnYQqo/5Eyi3nGUp8dvnUIN0O QKdnsTUJnW02HNyreYJw2ZvEtDV/49ayJqMiWt4cRtx7fMuasv5dfMlVRbkhrAZaqBts MDV60SWeUdBGNSg70uw8g08QTs9Z79NjWncRGlMnOcDwtRtxQJcYUt/No1+sou/8kpWb LFrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UZc9qlgFs8CbchOrOL+r6fXR+9YC4L2N3YMq7bhJ0+0=; b=r7IYTsU0e2NZXWBqOcTZvmp+9zLQZd8V8o3xTzU4Bt+h385KJnhtq9ftCePgHWv2Nx 4CNuqEZOPLPatuR5rLUMBneRMZryNc2nwV+IoO0FE4dH9853eQ57B3tDs8LcDZeAro6l XpHUYWpVoz7OgiUa4J+RqlWPtT0iFE4OyvwgSI3gPQh2VvOJcXfpYqhrJe91dkoZi5te TcQ0uZsiFsl5rSII3uboQ9Xt/yZ1g1EOFjtpgzd0RgwGSXLJHc4cM93a4Cx8JNg9tIld oqOVv3a6Bw3tqf63K1fmp1P9nd3NK/mdK2K1BE76+UP6TK7k3cBBwN3gMxNv43cUCGWV YR2w== X-Gm-Message-State: AOAM531H84w6pSnTata6Xrens1rDOQZmkqZjIB16qc586udKQr1HVXnu 52nLW2lMqwchBsoJ6Mh4+RI= X-Google-Smtp-Source: ABdhPJyaj/FbrDzFn4tjPMhDjKG6aLzqGg8DFGOw9jnUBvDEGU4Tt0LkYY74y0xtSktHQrE/aDWn5w== X-Received: by 2002:a17:90a:17ad:: with SMTP id q42mr3087081pja.36.1604472487174; Tue, 03 Nov 2020 22:48:07 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.48.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:06 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 10/15] usb: serial: io_ti: use usb_control_msg_recv() and usb_control_msg_send() Date: Wed, 4 Nov 2020 12:16:58 +0530 Message-Id: <20201104064703.15123-11-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrappers instead of calling usb_control_msg() directly Signed-off-by: Himadri Pandya --- drivers/usb/serial/io_ti.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/drivers/usb/serial/io_ti.c b/drivers/usb/serial/io_ti.c index c327d4cf7928..ab2370b80b3c 100644 --- a/drivers/usb/serial/io_ti.c +++ b/drivers/usb/serial/io_ti.c @@ -260,16 +260,12 @@ static int ti_vread_sync(struct usb_device *dev, __u8 request, { int status; - status = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request, - (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN), - value, index, data, size, 1000); - if (status < 0) + status = usb_control_msg_recv(dev, 0, request, USB_TYPE_VENDOR | + USB_RECIP_DEVICE | USB_DIR_IN, value, + index, data, size, 1000, GFP_KERNEL); + if (status) return status; - if (status != size) { - dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n", - __func__, size, status); - return -ECOMM; - } + return 0; } @@ -278,16 +274,12 @@ static int ti_vsend_sync(struct usb_device *dev, u8 request, u16 value, { int status; - status = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request, - (USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT), - value, index, data, size, timeout); - if (status < 0) + status = usb_control_msg_send(dev, 0, request, USB_TYPE_VENDOR | + USB_RECIP_DEVICE | USB_DIR_OUT, value, + index, data, size, timeout, GFP_KERNEL); + if (status) return status; - if (status != size) { - dev_dbg(&dev->dev, "%s - wanted to write %d, but only wrote %d\n", - __func__, size, status); - return -ECOMM; - } + return 0; } From patchwork Wed Nov 4 06:46:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 318368 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 7911AC2D0A3 for ; Wed, 4 Nov 2020 06:48:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 256182236F for ; Wed, 4 Nov 2020 06:48:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gQFg7+IE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729179AbgKDGsN (ORCPT ); Wed, 4 Nov 2020 01:48:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729172AbgKDGsL (ORCPT ); Wed, 4 Nov 2020 01:48:11 -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 37E3FC061A4D; Tue, 3 Nov 2020 22:48:11 -0800 (PST) Received: by mail-pf1-x442.google.com with SMTP id 10so16499954pfp.5; Tue, 03 Nov 2020 22:48:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vfvrxPrBJGjeJqjA+QKlO7xKcbqowzvBic2gE6WrBIc=; b=gQFg7+IEGHm8KUsDcV9DwYXkLpSQcQqwrfaZqR4PhGzF1/B4B8fDXv0ZR/yGwbCcR9 F7m64I/YV8+35M/mAPTTnVtYE8dh3Xm5YesJCv1yXxLHl8iW/6AwSzcXqVWZMUSfavda tH4nGCnqQOJ0f76yCxY7G2nV++UMFtI4AovOrpWDhfKalQOhZmDHxRJvvV958135e9MT 3e+EhL+9cokTGCxSj00YFCscNPj0vIY38kbqzU+BHVnMmmHakdfSPvLyPhGp/ZWTqJDg 0FCHvE3wYXJyTIypz/6jlclGlTti3+uzOa8//eLBjLWbjPIyD9BP9PwH9/KuF5phLP3J ghFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vfvrxPrBJGjeJqjA+QKlO7xKcbqowzvBic2gE6WrBIc=; b=NubL0AmV4rCh0xvGDaN6cPn0/NI3grA63zU/DG4HrrDIvqCa9V5Qj0dWz+32QQM7Td kkQOv5cLtELNC5RJ1oRi82IaVeqwtuxiQW1Bh9VGGqFjtm5eGScrUHvgllNdRfwvX68V e/7IqCPcgNwcnQx19CHAK55m/lr5AJIEF916P/FZQ8NEnTEa0tfFk+9OMQy/NP878mwf GlEfSjtS5wBtescMlehsdA11pFJDoRUgtLjYrXQBG+/R83FG+LMm+UMWkUE90Av9tMst 1A/ZMGScIXeOiLsPqg4ZtQSXNph8z1kS54b5boN5oI7sWKJkjKK+XkzICQMZTb/Gzn5k 2F7g== X-Gm-Message-State: AOAM533ItZOtA0nNm9iSkk0FmHIS2HmJGEBb+zdR5724mFYLJ065Qizi u90Pq9ZqQALT/i+MLGg5zTSY7dAUf0c= X-Google-Smtp-Source: ABdhPJwlvOvRv2wJs5gb4nk7XbX/MNXQuf3Ps9uRJ5YdGrj5SrKXcXdqV8qanXEDbiLy5h9bT+bpgA== X-Received: by 2002:a65:4bc8:: with SMTP id p8mr16243150pgr.335.1604472490875; Tue, 03 Nov 2020 22:48:10 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:10 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 11/15] usb: serial: ipaq: use usb_control_msg_send() Date: Wed, 4 Nov 2020 12:16:59 +0530 Message-Id: <20201104064703.15123-12-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrapper instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/ipaq.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/usb/serial/ipaq.c b/drivers/usb/serial/ipaq.c index f81746c3c26c..99505a76035d 100644 --- a/drivers/usb/serial/ipaq.c +++ b/drivers/usb/serial/ipaq.c @@ -530,15 +530,14 @@ static int ipaq_open(struct tty_struct *tty, */ while (retries) { retries--; - result = usb_control_msg(serial->dev, - usb_sndctrlpipe(serial->dev, 0), 0x22, 0x21, - 0x1, 0, NULL, 0, 100); - if (!result) + result = usb_control_msg_send(serial->dev, 0, 0x22, 0x21, 0x1, + 0, NULL, 0, 100, GFP_KERNEL); + if (result == 0) break; msleep(1000); } - if (!retries && result) { + if (result) { dev_err(&port->dev, "%s - failed doing control urb, error %d\n", __func__, result); return result; From patchwork Wed Nov 4 06:47:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 315501 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 F0CE0C388F9 for ; Wed, 4 Nov 2020 06:48:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98A3F22384 for ; Wed, 4 Nov 2020 06:48:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GoC8DcFI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729216AbgKDGsT (ORCPT ); Wed, 4 Nov 2020 01:48:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729214AbgKDGsQ (ORCPT ); Wed, 4 Nov 2020 01:48:16 -0500 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C6BEC061A4D; Tue, 3 Nov 2020 22:48:15 -0800 (PST) Received: by mail-pl1-x641.google.com with SMTP id k7so538464plk.3; Tue, 03 Nov 2020 22:48:15 -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; bh=s90dzJNynJlXhu5PFXW3xxoyQNWm3vOkTOAC4HZYz6M=; b=GoC8DcFIeGeve61407Y1kAJsW0emtoExF3ZW1bYgNGvd8lw2rSd/bX2YMnzsHSfLP4 WLxx1vZ9gYbUzyYG7pn5TyQ0O6Cp1nIAtE62V4UMmRL9yoCClSIRAlLqB2igWMJ6+gEO Yfo4nrQZzwM832c+C14C+bWbXgEiX11EczJp77IA4p2SL53F473qZkyJn5tdJSLRvVOe lDY9E9Y9LDz0nNbuBw9liCcQAvLiljJP+prf2mZHyXZZljlyEjVKWrl2+UD2Ll/HKbt7 +Q4yAb2r3mRUlgeFpDRNc6as/L9Lv4RUsXhLc2pkVGl+1/QPfUEtpQ6vgfdT/EsKaD9M t3Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=s90dzJNynJlXhu5PFXW3xxoyQNWm3vOkTOAC4HZYz6M=; b=Ap3G21OeYrVWGZCpM5HJxM2CXbml4i8SQcdXBSRB5Ek8nvgIhVzR9FS8rc/Ps3GhO6 l/WN/Cm3Gy5zU0QmKzBc1Hfl9gaXacal7rLuK2SpZzTGKRyAShl2QJNgKDYUXeQLez+r IoJtfM+ATxUSmKWB+BBQ1xq2zsIxHFuQmsXopXok2h98FGaoHfw7fZuaWsInf39HS4Dt wJ0v6iT51jNv2WL90XjAJ1My8LMUSklmBfGZjlOzDHQCJ+eOwSg64k6XV4yZiwlsYxGT AtztxnopEDJhxYI/gach62qvM5VjWcle7n0Bm9rdQISr0EqML3fp0NJQrSQm6e7robPN KxOw== X-Gm-Message-State: AOAM532JwHXPaxVsjxqigsCSOsPavojIndIgBBlF0fcBe2Xa7lB1cXrY wELmb4VIAPaf4HWwvB1Cb9s= X-Google-Smtp-Source: ABdhPJwozhFZg8sFa6GjYjDZ6TJ0QDReAQ3JswDWFl8ldK9dTIXvTW7GEenCRHqg9sWFdeBDO9IaMg== X-Received: by 2002:a17:902:864b:b029:d3:ce46:2829 with SMTP id y11-20020a170902864bb02900d3ce462829mr29662922plt.16.1604472495216; Tue, 03 Nov 2020 22:48:15 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.48.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:14 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 12/15] usb: serial: ipw: use usb_control_msg_send() Date: Wed, 4 Nov 2020 12:17:00 +0530 Message-Id: <20201104064703.15123-13-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrapper instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/ipw.c | 107 +++++++++++++-------------------------- 1 file changed, 36 insertions(+), 71 deletions(-) diff --git a/drivers/usb/serial/ipw.c b/drivers/usb/serial/ipw.c index d04c7cc5c1c2..3c3895b4dff8 100644 --- a/drivers/usb/serial/ipw.c +++ b/drivers/usb/serial/ipw.c @@ -134,26 +134,16 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) struct usb_device *udev = port->serial->dev; struct device *dev = &port->dev; u8 buf_flow_static[16] = IPW_BYTES_FLOWINIT; - u8 *buf_flow_init; int result; - buf_flow_init = kmemdup(buf_flow_static, 16, GFP_KERNEL); - if (!buf_flow_init) - return -ENOMEM; - /* --1: Tell the modem to initialize (we think) From sniffs this is * always the first thing that gets sent to the modem during * opening of the device */ dev_dbg(dev, "%s: Sending SIO_INIT (we guess)\n", __func__); - result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - IPW_SIO_INIT, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - 0, - 0, /* index */ - NULL, - 0, - 100000); - if (result < 0) + result = usb_control_msg_send(udev, 0, IPW_SIO_INIT, USB_TYPE_VENDOR | + USB_RECIP_INTERFACE | USB_DIR_OUT, 0, + 0, NULL, 0, 100000, GFP_KERNEL); + if (result) dev_err(dev, "Init of modem failed (error = %d)\n", result); /* reset the bulk pipes */ @@ -166,31 +156,22 @@ static int ipw_open(struct tty_struct *tty, struct usb_serial_port *port) /*--3: Tell the modem to open the floodgates on the rx bulk channel */ dev_dbg(dev, "%s:asking modem for RxRead (RXBULK_ON)\n", __func__); - result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - IPW_SIO_RXCTL, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - IPW_RXBULK_ON, - 0, /* index */ - NULL, - 0, - 100000); - if (result < 0) + result = usb_control_msg_send(udev, 0, IPW_SIO_RXCTL, USB_TYPE_VENDOR | + USB_RECIP_INTERFACE | USB_DIR_OUT, + IPW_RXBULK_ON, 0, NULL, 0, 100000, + GFP_KERNEL); + if (result) dev_err(dev, "Enabling bulk RxRead failed (error = %d)\n", result); /*--4: setup the initial flowcontrol */ - dev_dbg(dev, "%s:setting init flowcontrol (%s)\n", __func__, buf_flow_init); - result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - IPW_SIO_HANDFLOW, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - 0, - 0, - buf_flow_init, - 0x10, - 200000); - if (result < 0) + dev_dbg(dev, "%s:setting init flowcontrol (%s)\n", __func__, buf_flow_static); + result = usb_control_msg_send(udev, 0, IPW_SIO_HANDFLOW, + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | + USB_DIR_OUT, 0, 0, &buf_flow_static, 0x10, + 200000, GFP_KERNEL); + if (result) dev_err(dev, "initial flowcontrol failed (error = %d)\n", result); - kfree(buf_flow_init); return 0; } @@ -223,26 +204,20 @@ static void ipw_dtr_rts(struct usb_serial_port *port, int on) dev_dbg(dev, "%s: on = %d\n", __func__, on); - result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - IPW_SIO_SET_PIN, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - on ? IPW_PIN_SETDTR : IPW_PIN_CLRDTR, - 0, - NULL, - 0, - 200000); - if (result < 0) + result = usb_control_msg_send(udev, 0, IPW_SIO_SET_PIN, + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | + USB_DIR_OUT, + on ? IPW_PIN_SETDTR : IPW_PIN_CLRDTR, 0, + NULL, 0, 200000, GFP_KERNEL); + if (result) dev_err(dev, "setting dtr failed (error = %d)\n", result); - result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - IPW_SIO_SET_PIN, USB_TYPE_VENDOR | - USB_RECIP_INTERFACE | USB_DIR_OUT, - on ? IPW_PIN_SETRTS : IPW_PIN_CLRRTS, - 0, - NULL, - 0, - 200000); - if (result < 0) + result = usb_control_msg_send(udev, 0, IPW_SIO_SET_PIN, + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | + USB_DIR_OUT, + on ? IPW_PIN_SETRTS : IPW_PIN_CLRRTS, + 0, NULL, 0, 200000, GFP_KERNEL); + if (result) dev_err(dev, "setting rts failed (error = %d)\n", result); } @@ -254,30 +229,20 @@ static void ipw_close(struct usb_serial_port *port) /*--3: purge */ dev_dbg(dev, "%s:sending purge\n", __func__); - result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - IPW_SIO_PURGE, USB_TYPE_VENDOR | - USB_RECIP_INTERFACE | USB_DIR_OUT, - 0x03, - 0, - NULL, - 0, - 200000); - if (result < 0) + result = usb_control_msg_send(udev, 0, IPW_SIO_PURGE, USB_TYPE_VENDOR | + USB_RECIP_INTERFACE | USB_DIR_OUT, 0x03, + 0, NULL, 0, 200000, GFP_KERNEL); + if (result) dev_err(dev, "purge failed (error = %d)\n", result); /* send RXBULK_off (tell modem to stop transmitting bulk data on rx chan) */ - result = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), - IPW_SIO_RXCTL, - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - IPW_RXBULK_OFF, - 0, /* index */ - NULL, - 0, - 100000); - - if (result < 0) + result = usb_control_msg_send(udev, 0, IPW_SIO_RXCTL, USB_TYPE_VENDOR | + USB_RECIP_INTERFACE | USB_DIR_OUT, + IPW_RXBULK_OFF, 0, NULL, 0, 100000, GFP_KERNEL); + + if (result) dev_err(dev, "Disabling bulk RxRead failed (error = %d)\n", result); usb_wwan_close(port); From patchwork Wed Nov 4 06:47:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 318367 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 DA125C4741F for ; Wed, 4 Nov 2020 06:48:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7D1572236F for ; Wed, 4 Nov 2020 06:48:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iCE670pQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729262AbgKDGsU (ORCPT ); Wed, 4 Nov 2020 01:48:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729172AbgKDGsT (ORCPT ); Wed, 4 Nov 2020 01:48:19 -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 6CF27C061A4D; Tue, 3 Nov 2020 22:48:19 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id u2so3886084pls.10; Tue, 03 Nov 2020 22:48:19 -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; bh=txw7VexweucfLOC8DKUSmw/Pbo6mBmR3atijpGysA14=; b=iCE670pQ4lYbvgpa2WSgZrx62oRISLwyeX3gsg+drYwun6OT/Ax86dlZecFvfEOuNV N0LfEiiuNKLNQlQ55gkerkqxqsKGPM5awSOpMM4FIVz4/XEM0F4WC+TslImeVeb/vBML gIr+G5w8kUpy0/aBLvtEBpXUnzoDZET2SOyQpoUvVUoj1xrzPFh5YzpuyTQDaMgMKQBo sMMr2JEYJAtBLAp2eolhN0zpS6ZpfU/SPSOis8DFrhfwzhlJVrLkvVrZH/h8bZB4qzJT doIl5IOpvb6Y5RryTCtpyf3U6eGB2bCEM/QA23LpGynYLRXwuzJVoyb5hqRMk8iNeRN9 vs1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=txw7VexweucfLOC8DKUSmw/Pbo6mBmR3atijpGysA14=; b=SYMIEMpxt+ieRDwTadNM0uL0QL1TztDHWJBBCg/Qgg6dpURPi0NAxzT7NQ0x+teoya FGaEoQpS1Sm3BFqwh3oT1YSzcXbXNpbz9UYwpixe0Ce7hqjm3wwPwN9jcl6h/8SHmwLi 1VpAe1clPqmnb1G/DfO9+U2TdfWyM3WgW7VqFecsHyLno+ySZZW3M7RIZw0xyaTMK0YZ QhVYZBZLiZtVc9MVqYAu3ahj6PyNlbL3F1PBAFfdNHj4E8iJh2/Cvq4lpJy7/AwudMYz v5mlcvmolGWADMrVdcfT31bHlmSlomRAPS4Ps+2u/JrQtVrj377nUptyBrNY9CFLuyyV Foyw== X-Gm-Message-State: AOAM531c6WzGOySTgs5I+pdP9w5WOyTnvtuLHp0NtqTR3wCn1u1DHF2+ +Vj2jGZm1bm33oOLICXk0+Q= X-Google-Smtp-Source: ABdhPJw3Mli9dEzf7RX1ydq7l+a9Gpmq8nGi25EshURUUZ7k4Dp5tWy8+ySE6k0jE13aXGKJXoLRLA== X-Received: by 2002:a17:902:ab85:b029:d6:b5d2:b6fd with SMTP id f5-20020a170902ab85b02900d6b5d2b6fdmr17595747plr.9.1604472498960; Tue, 03 Nov 2020 22:48:18 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.48.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:18 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 13/15] usb: serial: iuu_phoenix: use usb_control_msg_send() Date: Wed, 4 Nov 2020 12:17:01 +0530 Message-Id: <20201104064703.15123-14-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrapper instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/iuu_phoenix.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index b4ba79123d9d..dfbcdcec94e7 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -968,9 +968,8 @@ static int iuu_open(struct tty_struct *tty, struct usb_serial_port *port) priv->poll = 0; #define SOUP(a, b, c, d) do { \ - result = usb_control_msg(port->serial->dev, \ - usb_sndctrlpipe(port->serial->dev, 0), \ - b, a, c, d, NULL, 0, 1000); \ + result = usb_control_msg_send(port->serial->dev, 0, b, a, c, d, NULL,\ + 0, 1000, GFP_KERNEL); \ dev_dbg(dev, "0x%x:0x%x:0x%x:0x%x %d\n", a, b, c, d, result); } while (0) /* This is not UART related but IUU USB driver related or something */ From patchwork Wed Nov 4 06:47:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 315500 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 89CB8C388F9 for ; Wed, 4 Nov 2020 06:48:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 35DD822470 for ; Wed, 4 Nov 2020 06:48:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iDOmSv+7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729345AbgKDGsY (ORCPT ); Wed, 4 Nov 2020 01:48:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729172AbgKDGsX (ORCPT ); Wed, 4 Nov 2020 01:48:23 -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 7E8F8C061A4D; Tue, 3 Nov 2020 22:48:23 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id w65so16511274pfd.3; Tue, 03 Nov 2020 22:48:23 -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; bh=KB7CZf3CU86Z0He3UNjFkiBM0LUE2H0157Uy00zeVnM=; b=iDOmSv+7rnBajXf+cgmft9pCQRr9KEydAxoL7P7WFn9jTTjy8yotjsRt8yRcI0fP+T nrbtCWwMxIW04SbdFr0mlOVMSI9IasE3xah8/XxIY7efTVIz5IrZt3sphQ56WpfoV6hG FS3vbjAzq4y7Bd0XsUqj8rZS/FvfazwHUccVApgtsqAZPQ56kkfA4FO45aKuvjYAyfU/ 11MZFLdps7sowj0mG+/EJQR+oOOkljGyawOkNqhwyP1McQHsP9pW/3dhN5gvp7AcI0aX MUjuqRcIbKAOxnexRylpMPuQoTYBfWSM3Fpf2sf0rYbL096Fygr9rlkkBHpXBnJIAjdl 8M8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KB7CZf3CU86Z0He3UNjFkiBM0LUE2H0157Uy00zeVnM=; b=te7W1rT+xTNbafeZy7rhUR2+p7vlVKO2lKF3UA1MEu4VL1RiiUQlwvt9naPnvTiZmf FJA1jNSeQPgI5tcDgI0HX4Ji1iUJtVTwfgJanjPno0z2XI/fOrk7/4QZvMw0q5KbiRav 2djjfNmuJSbSrRc6WKvvXMndDMk22DMVgn9CeVDDoXitdxslLYakbHXRVHsNfeMP84kM rKL/lCdKt0pXKomVKegENdynrEa6JiQp+0gMvHnxxrdzwiy0n9FzJlR8l1bjbExw8IfU vTAuSKGU1xP2U8/MFjsxG2lc0A/T5wGzZFmqlDJuCJyokUL0H0hA6mSLqq9wooYt5Epd L+qQ== X-Gm-Message-State: AOAM533NBjMA3gb48+vJTOsn99lhFzNJiWDqJTvhlGhPXi3mxgiwiBwn ytMTNcNu21iOVLpcNzxqFyo= X-Google-Smtp-Source: ABdhPJxs0MkrmUYxezpuHa4boCFPRLOvuB9Nud9oWd6sw5dUNBePOgrl+hKFsnFyKeXvFpEe4oYnbA== X-Received: by 2002:a17:90a:df0d:: with SMTP id gp13mr3045148pjb.92.1604472503048; Tue, 03 Nov 2020 22:48:23 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:22 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 14/15] usb: serial: keyspan_pda: use usb_control_msg_recv() and usb_control_msg_send() Date: Wed, 4 Nov 2020 12:17:02 +0530 Message-Id: <20201104064703.15123-15-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrappers instead of calling usb_control_msg() directly. Signed-off-by: Himadri Pandya --- drivers/usb/serial/keyspan_pda.c | 172 +++++++++++++------------------ 1 file changed, 72 insertions(+), 100 deletions(-) diff --git a/drivers/usb/serial/keyspan_pda.c b/drivers/usb/serial/keyspan_pda.c index c1333919716b..44e1c4490fa9 100644 --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -115,17 +115,17 @@ static void keyspan_pda_request_unthrottle(struct work_struct *work) /* ask the device to tell us when the tx buffer becomes sufficiently empty */ - result = usb_control_msg(serial->dev, - usb_sndctrlpipe(serial->dev, 0), - 7, /* request_unthrottle */ - USB_TYPE_VENDOR | USB_RECIP_INTERFACE - | USB_DIR_OUT, - 16, /* value: threshold */ - 0, /* index */ - NULL, - 0, - 2000); - if (result < 0) + result = usb_control_msg_send(serial->dev, 0, + 7, /* request_unthrottle */ + USB_TYPE_VENDOR | USB_RECIP_INTERFACE + | USB_DIR_OUT, + 16, /* value: threshold */ + 0, /* index */ + NULL, + 0, + 2000, + GFP_KERNEL); + if (result) dev_dbg(&serial->dev->dev, "%s - error %d from usb_control_msg\n", __func__, result); } @@ -269,17 +269,18 @@ static speed_t keyspan_pda_setbaud(struct usb_serial *serial, speed_t baud) /* rather than figure out how to sleep while waiting for this to complete, I just use the "legacy" API. */ - rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - 0, /* set baud */ - USB_TYPE_VENDOR - | USB_RECIP_INTERFACE - | USB_DIR_OUT, /* type */ - bindex, /* value */ - 0, /* index */ - NULL, /* &data */ - 0, /* size */ - 2000); /* timeout */ - if (rc < 0) + rc = usb_control_msg_send(serial->dev, 0, + 0, /* set baud */ + USB_TYPE_VENDOR + | USB_RECIP_INTERFACE + | USB_DIR_OUT, /* type */ + bindex, /* value */ + 0, /* index */ + NULL, /* &data */ + 0, /* size */ + 2000, /* timeout */ + GFP_KERNEL); + if (rc) return 0; return baud; } @@ -296,11 +297,12 @@ static void keyspan_pda_break_ctl(struct tty_struct *tty, int break_state) value = 1; /* start break */ else value = 0; /* clear break */ - result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - 4, /* set break */ - USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_OUT, - value, 0, NULL, 0, 2000); - if (result < 0) + result = usb_control_msg_send(serial->dev, 0, + 4, /* set break */ + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | + USB_DIR_OUT, + value, 0, NULL, 0, 2000, GFP_KERNEL); + if (result) dev_dbg(&port->dev, "%s - error %d from usb_control_msg\n", __func__, result); /* there is something funky about this.. the TCSBRK that 'cu' performs @@ -359,22 +361,11 @@ static int keyspan_pda_get_modem_info(struct usb_serial *serial, unsigned char *value) { int rc; - u8 *data; - - data = kmalloc(1, GFP_KERNEL); - if (!data) - return -ENOMEM; - - rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), - 3, /* get pins */ - USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_IN, - 0, 0, data, 1, 2000); - if (rc == 1) - *value = *data; - else if (rc >= 0) - rc = -EIO; - - kfree(data); + rc = usb_control_msg_recv(serial->dev, 0, + 3, /* get pins */ + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | + USB_DIR_IN, 0, 0, value, 1, 2000, + GFP_KERNEL); return rc; } @@ -383,10 +374,11 @@ static int keyspan_pda_set_modem_info(struct usb_serial *serial, unsigned char value) { int rc; - rc = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - 3, /* set pins */ - USB_TYPE_VENDOR|USB_RECIP_INTERFACE|USB_DIR_OUT, - value, 0, NULL, 0, 2000); + rc = usb_control_msg_send(serial->dev, 0, + 3, /* set pins */ + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | + USB_DIR_OUT, value, 0, NULL, 0, 2000, + GFP_KERNEL); return rc; } @@ -481,36 +473,25 @@ static int keyspan_pda_write(struct tty_struct *tty, device how much room it really has. This is done only on scheduler time, since usb_control_msg() sleeps. */ if (count > priv->tx_room && !in_interrupt()) { - u8 *room; - - room = kmalloc(1, GFP_KERNEL); - if (!room) { - rc = -ENOMEM; - goto exit; + u8 room; + + rc = usb_control_msg_recv(serial->dev, 0, + 6, /* write_room */ + USB_TYPE_VENDOR | USB_RECIP_INTERFACE + | USB_DIR_IN, + 0, /* value: 0 means "remaining room" */ + 0, /* index */ + &room, + 1, + 2000, + GFP_KERNEL); + if (rc == 0) { + dev_dbg(&port->dev, "roomquery says %d\n", room); + priv->tx_room = room; } - rc = usb_control_msg(serial->dev, - usb_rcvctrlpipe(serial->dev, 0), - 6, /* write_room */ - USB_TYPE_VENDOR | USB_RECIP_INTERFACE - | USB_DIR_IN, - 0, /* value: 0 means "remaining room" */ - 0, /* index */ - room, - 1, - 2000); - if (rc > 0) { - dev_dbg(&port->dev, "roomquery says %d\n", *room); - priv->tx_room = *room; - } - kfree(room); - if (rc < 0) { - dev_dbg(&port->dev, "roomquery failed\n"); - goto exit; - } - if (rc == 0) { - dev_dbg(&port->dev, "roomquery returned 0 bytes\n"); - rc = -EIO; /* device didn't return any data */ + if (rc) { + dev_dbg(&port->dev, "roomquery failed %d\n", rc); goto exit; } } @@ -613,36 +594,28 @@ static int keyspan_pda_open(struct tty_struct *tty, struct usb_serial_port *port) { struct usb_serial *serial = port->serial; - u8 *room; + u8 room; int rc = 0; struct keyspan_pda_private *priv; - /* find out how much room is in the Tx ring */ - room = kmalloc(1, GFP_KERNEL); - if (!room) - return -ENOMEM; - - rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), - 6, /* write_room */ - USB_TYPE_VENDOR | USB_RECIP_INTERFACE - | USB_DIR_IN, - 0, /* value */ - 0, /* index */ - room, - 1, - 2000); - if (rc < 0) { - dev_dbg(&port->dev, "%s - roomquery failed\n", __func__); - goto error; - } - if (rc == 0) { - dev_dbg(&port->dev, "%s - roomquery returned 0 bytes\n", __func__); - rc = -EIO; + rc = usb_control_msg_recv(serial->dev, 0, + 6, /* write_room */ + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | + USB_DIR_IN, + 0, /* value */ + 0, /* index */ + &room, + 1, + 2000, + GFP_KERNEL); + if (rc) { + dev_dbg(&port->dev, "%s - roomquery failed %d\n", __func__, rc); goto error; } + priv = usb_get_serial_port_data(port); - priv->tx_room = *room; - priv->tx_throttled = *room ? 0 : 1; + priv->tx_room = room; + priv->tx_throttled = room ? 0 : 1; /*Start reading from the device*/ rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL); @@ -651,7 +624,6 @@ static int keyspan_pda_open(struct tty_struct *tty, goto error; } error: - kfree(room); return rc; } static void keyspan_pda_close(struct usb_serial_port *port) From patchwork Wed Nov 4 06:47:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Himadri Pandya X-Patchwork-Id: 318366 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=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, 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 62389C388F9 for ; Wed, 4 Nov 2020 06:48:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FFFF223BD for ; Wed, 4 Nov 2020 06:48:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YzNxGd//" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729370AbgKDGs2 (ORCPT ); Wed, 4 Nov 2020 01:48:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729172AbgKDGs1 (ORCPT ); Wed, 4 Nov 2020 01:48:27 -0500 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CDA3C061A4D; Tue, 3 Nov 2020 22:48:27 -0800 (PST) Received: by mail-pg1-x542.google.com with SMTP id x13so15731241pgp.7; Tue, 03 Nov 2020 22:48: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; bh=ysHUcVNbp38AUgn7NKxkH5Q5DIwpvOeEqm2kZUXUKmU=; b=YzNxGd//p6RpHxyQKY/zhdc1gm8gz0LIfXvR7h5InWiRax8cOhO7XTjfgvIru0w46l X4w55YlLlkCPHdQ7hCo/wgNXiRwUQwoMCmLOrB7YdM0Y48n/40OymgK1fgJjk6oKvAfv 7uVVyrGgzpO3DjwzTf0pMKZR7HXCHLU9ELAqbDeQjWMGAk/QECCKqV4RXooBd9RDzTz6 rt2B2eYb6efu4pg9hoDN0oc5SJwuch2gDNxkXMhM7SuNI9JPZJKNLZ6YnkBP4dLq7yky lgLbjZy9wNJl65sC7/5OOztv1vKFyROkxORu4j8Oz0KhdlhkPT1JUIlf8ZkgP5xaQWoD 8v0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ysHUcVNbp38AUgn7NKxkH5Q5DIwpvOeEqm2kZUXUKmU=; b=DU06/bxEHeOGD9o+Aj8KbJ68ECb0CsBJQDuZZ56V8DdtOoncVK93pqiKgO7rqiVGXY vnii9PYYQ495N8/xEwJfJRWouIl63Jv6DzwhIt41PV86NPunXKdmuG6+ehepBEO83hgG 5QxAXrXmEhTjhWV2E4DCmts28Cec6TOJhtpcLZENUy1Hh7PemAVJcjBaZYaahY08h+tn /hTFpApHgV5aHzgQ/6dw5Zguv8eudqbbKqwKjzmoLaFDYCIuz8LLnBJIlK5//mFSz474 rRbxsv+w150Y3Eg04nv1hl3avNoGGzpK2qoAWze446UCaAsrOmeBl1Gbt2zY6Syrzqer 1PSw== X-Gm-Message-State: AOAM532GfLQyPtjYnv5lgC3f+RcMQGUQEhpPdTeqISoS6TBQGyeZbd7c sC0L8zpVA3pJIJ3COuog2a4= X-Google-Smtp-Source: ABdhPJzuiIEqTk+1+1eFZRvLotka0QLSy6Ky8iB1wyY+65k+2+Lj+I04P2RisE3gcfbxPM73VqZifA== X-Received: by 2002:a17:90b:34f:: with SMTP id fh15mr3075738pjb.66.1604472507072; Tue, 03 Nov 2020 22:48:27 -0800 (PST) Received: from localhost.localdomain ([2402:3a80:16e6:8166:e462:9fba:da9c:beed]) by smtp.gmail.com with ESMTPSA id s18sm1036873pgh.60.2020.11.03.22.48.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 22:48:26 -0800 (PST) From: Himadri Pandya To: johan@kernel.org, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-kernel-mentees@lists.linuxfoundation.org, Himadri Pandya Subject: [PATCH 15/15] usb: serial: kl5kusb105: use usb_control_msg_recv() and usb_control_msg_send() Date: Wed, 4 Nov 2020 12:17:03 +0530 Message-Id: <20201104064703.15123-16-himadrispandya@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201104064703.15123-1-himadrispandya@gmail.com> References: <20201104064703.15123-1-himadrispandya@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The new usb_control_msg_recv() and usb_control_msg_send() nicely wraps usb_control_msg() with proper error check. Hence use the wrappers instead of calling usb_control_msg() directly Signed-off-by: Himadri Pandya --- drivers/usb/serial/kl5kusb105.c | 94 +++++++++++++++------------------ 1 file changed, 44 insertions(+), 50 deletions(-) diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 5ee48b0650c4..75cfd1c907f3 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -124,16 +124,17 @@ static int klsi_105_chg_port_settings(struct usb_serial_port *port, { int rc; - rc = usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - KL5KUSB105A_SIO_SET_DATA, - USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_INTERFACE, - 0, /* value */ - 0, /* index */ - settings, - sizeof(struct klsi_105_port_settings), - KLSI_TIMEOUT); - if (rc < 0) + rc = usb_control_msg_send(port->serial->dev, 0, + KL5KUSB105A_SIO_SET_DATA, + USB_TYPE_VENDOR | USB_DIR_OUT | + USB_RECIP_INTERFACE, + 0, /* value */ + 0, /* index */ + settings, + sizeof(struct klsi_105_port_settings), + KLSI_TIMEOUT, + GFP_KERNEL); + if (rc) dev_err(&port->dev, "Change port settings failed (error = %d)\n", rc); @@ -167,28 +168,21 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, unsigned long *line_state_p) { int rc; - u8 *status_buf; + u8 status_buf[2]; __u16 status; - status_buf = kmalloc(KLSI_STATUSBUF_LEN, GFP_KERNEL); - if (!status_buf) - return -ENOMEM; - status_buf[0] = 0xff; status_buf[1] = 0xff; - rc = usb_control_msg(port->serial->dev, - usb_rcvctrlpipe(port->serial->dev, 0), - KL5KUSB105A_SIO_POLL, - USB_TYPE_VENDOR | USB_DIR_IN, - 0, /* value */ - 0, /* index */ - status_buf, KLSI_STATUSBUF_LEN, - 10000 - ); - if (rc != KLSI_STATUSBUF_LEN) { + rc = usb_control_msg_recv(port->serial->dev, 0, + KL5KUSB105A_SIO_POLL, + USB_TYPE_VENDOR | USB_DIR_IN, + 0, /* value */ + 0, /* index */ + &status_buf, KLSI_STATUSBUF_LEN, + 10000, + GFP_KERNEL); + if (rc) { dev_err(&port->dev, "reading line status failed: %d\n", rc); - if (rc >= 0) - rc = -EIO; } else { status = get_unaligned_le16(status_buf); @@ -198,7 +192,6 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, *line_state_p = klsi_105_status2linestate(status); } - kfree(status_buf); return rc; } @@ -283,16 +276,17 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) goto err_free_cfg; } - rc = usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - KL5KUSB105A_SIO_CONFIGURE, - USB_TYPE_VENDOR|USB_DIR_OUT|USB_RECIP_INTERFACE, - KL5KUSB105A_SIO_CONFIGURE_READ_ON, - 0, /* index */ - NULL, - 0, - KLSI_TIMEOUT); - if (rc < 0) { + rc = usb_control_msg_send(port->serial->dev, 0, + KL5KUSB105A_SIO_CONFIGURE, + USB_TYPE_VENDOR | USB_DIR_OUT | + USB_RECIP_INTERFACE, + KL5KUSB105A_SIO_CONFIGURE_READ_ON, + 0, /* index */ + NULL, + 0, + KLSI_TIMEOUT, + GFP_KERNEL); + if (rc) { dev_err(&port->dev, "Enabling read failed (error = %d)\n", rc); retval = rc; goto err_generic_close; @@ -314,14 +308,14 @@ static int klsi_105_open(struct tty_struct *tty, struct usb_serial_port *port) return 0; err_disable_read: - usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), + usb_control_msg_send(port->serial->dev, 0, KL5KUSB105A_SIO_CONFIGURE, USB_TYPE_VENDOR | USB_DIR_OUT, KL5KUSB105A_SIO_CONFIGURE_READ_OFF, 0, /* index */ NULL, 0, - KLSI_TIMEOUT); + KLSI_TIMEOUT, + GFP_KERNEL); err_generic_close: usb_serial_generic_close(port); err_free_cfg: @@ -335,15 +329,15 @@ static void klsi_105_close(struct usb_serial_port *port) int rc; /* send READ_OFF */ - rc = usb_control_msg(port->serial->dev, - usb_sndctrlpipe(port->serial->dev, 0), - KL5KUSB105A_SIO_CONFIGURE, - USB_TYPE_VENDOR | USB_DIR_OUT, - KL5KUSB105A_SIO_CONFIGURE_READ_OFF, - 0, /* index */ - NULL, 0, - KLSI_TIMEOUT); - if (rc < 0) + rc = usb_control_msg_send(port->serial->dev, 0, + KL5KUSB105A_SIO_CONFIGURE, + USB_TYPE_VENDOR | USB_DIR_OUT, + KL5KUSB105A_SIO_CONFIGURE_READ_OFF, + 0, /* index */ + NULL, 0, + KLSI_TIMEOUT, + GFP_KERNEL); + if (rc) dev_err(&port->dev, "failed to disable read: %d\n", rc); /* shutdown our bulk reads and writes */