From patchwork Mon Jul 5 08:20:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 470378 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=-20.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 412BEC07E9C for ; Mon, 5 Jul 2021 08:20:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A4D2613D1 for ; Mon, 5 Jul 2021 08:20:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230389AbhGEIX1 (ORCPT ); Mon, 5 Jul 2021 04:23:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:40908 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230324AbhGEIXR (ORCPT ); Mon, 5 Jul 2021 04:23:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DB84C613FB; Mon, 5 Jul 2021 08:20:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625473240; bh=gU2KIV1UToXi8NzfHed8Zsat9LVm5rq/ChFXgWWM3KY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VWCo7i5Kdcp82XIMMYSQQNWHO/Icju/46v9HxOEtMOcaBnxwQorD+JocvT0ORdSaL PAm39MkBP1VtmJHthoBp6t24GOHUQ90zLXsR6mgrTLjSZnZNHq3edNhCwhaAUYD57S 30K7+vW82sBiLO3VebayG9nKTxd02sbMH5/UmkmEjsfL1olMt9vwQxqsh9GbA0Knlu QMRvk9XQh+ccF1uScsyubeyEfqMf8AwcddDDYlPwDb2FMQnt8qMjEQDnALWUBfHhW0 ZLXvUwS2QEAdGJ3APCqSzo9hJzyALzZ6kL7+lzuSTqVkV1f3DSE1jd14FmvQzW5XD2 FLeBLxpJ2tKcg== Received: from johan by xi with local (Exim 4.94.2) (envelope-from ) id 1m0JqF-0004lx-Cj; Mon, 05 Jul 2021 10:20:35 +0200 From: Johan Hovold To: Johan Hovold Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] USB: serial: cp210x: clean up set-chars request Date: Mon, 5 Jul 2021 10:20:13 +0200 Message-Id: <20210705082015.18286-5-johan@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210705082015.18286-1-johan@kernel.org> References: <20210705082015.18286-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use the generic control request helper to implement the SET_CHARS request. Signed-off-by: Johan Hovold --- drivers/usb/serial/cp210x.c | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index e560608afb1e..6e027e2a02ad 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c @@ -1144,31 +1144,6 @@ static void cp210x_disable_event_mode(struct usb_serial_port *port) port_priv->event_mode = false; } -static int cp210x_set_chars(struct usb_serial_port *port, - struct cp210x_special_chars *chars) -{ - struct cp210x_port_private *port_priv = usb_get_serial_port_data(port); - struct usb_serial *serial = port->serial; - void *dmabuf; - int result; - - dmabuf = kmemdup(chars, sizeof(*chars), GFP_KERNEL); - if (!dmabuf) - return -ENOMEM; - - result = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), - CP210X_SET_CHARS, REQTYPE_HOST_TO_INTERFACE, 0, - port_priv->bInterfaceNumber, - dmabuf, sizeof(*chars), USB_CTRL_SET_TIMEOUT); - - kfree(dmabuf); - - if (result < 0) - return result; - - return 0; -} - static bool cp210x_termios_change(const struct ktermios *a, const struct ktermios *b) { bool iflag_change, cc_change; @@ -1216,7 +1191,8 @@ static void cp210x_set_flow_control(struct tty_struct *tty, chars.bXonChar = START_CHAR(tty); chars.bXoffChar = STOP_CHAR(tty); - ret = cp210x_set_chars(port, &chars); + ret = cp210x_write_reg_block(port, CP210X_SET_CHARS, &chars, + sizeof(chars)); if (ret) { dev_err(&port->dev, "failed to set special chars: %d\n", ret);