From patchwork Tue Sep 21 13:30:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 12507855 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.5 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 EEB72C4332F for ; Tue, 21 Sep 2021 13:31:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D72346115A for ; Tue, 21 Sep 2021 13:31:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233195AbhIUNc6 (ORCPT ); Tue, 21 Sep 2021 09:32:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:52448 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233193AbhIUNcy (ORCPT ); Tue, 21 Sep 2021 09:32:54 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E55BA6115A; Tue, 21 Sep 2021 13:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632231085; bh=prOPIYWELr6nmKB42YtpCDelWSZ0w61BxUEMc2pOTJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vnyb4xBYTqQ2IrnY850MvsQxkxndpcVGwEqfoidzrLyi6bfA8NQXbhsQPs67lNGPT //hxuyYbViPZEoVExLby63fq3qtiOsAAiTCMMfr4HOD4dlZzwx/IzIhB+fPfc9qQap S7QmrfeZyUPDAjThLMkhd50n8IWkkmsLfQY7Ste04FvFE7kykkmQIo8TxPC6NYiqFo 8OBdBshBxU2fG4hDjAk2KV3lxpEQVppA/W3Qz00xea40DyuEl8XS18cYmoiTLW46VD J0L7zpiWE4/6POcIi9XX2CDiUv7kFKebCyD31Zk6qfvwdP2TjwiB93bivITU86r/8V H5bHRwT27xKDw== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1mSfrp-0003bP-D3; Tue, 21 Sep 2021 15:31:25 +0200 From: Johan Hovold To: Johan Hovold Cc: Himadri Pandya , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] USB: serial: kl5kusb105: simplify line-status handling Date: Tue, 21 Sep 2021 15:30:08 +0200 Message-Id: <20210921133009.13739-3-johan@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210921133009.13739-1-johan@kernel.org> References: <20210921133009.13739-1-johan@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Now that the driver is using usb_control_msg_recv(), the line status handling can be simplified further by reading directly into the status variable and doing the endian conversion in place. Signed-off-by: Johan Hovold --- drivers/usb/serial/kl5kusb105.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/usb/serial/kl5kusb105.c b/drivers/usb/serial/kl5kusb105.c index 7681671ddb79..99dffbdd3142 100644 --- a/drivers/usb/serial/kl5kusb105.c +++ b/drivers/usb/serial/kl5kusb105.c @@ -163,21 +163,18 @@ static unsigned long klsi_105_status2linestate(const __u16 status) * Read line control via vendor command and return result through * *line_state_p */ -/* It seems that the status buffer has always only 2 bytes length */ -#define KLSI_STATUSBUF_LEN 2 static int klsi_105_get_line_state(struct usb_serial_port *port, unsigned long *line_state_p) { + u16 status; int rc; - u8 status_buf[KLSI_STATUSBUF_LEN]; - __u16 status; 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, + &status, sizeof(status), 10000, GFP_KERNEL); if (rc) { @@ -185,10 +182,9 @@ static int klsi_105_get_line_state(struct usb_serial_port *port, return rc; } - status = get_unaligned_le16(status_buf); + le16_to_cpus(&status); - dev_dbg(&port->dev, "read status %02x %02x\n", - status_buf[0], status_buf[1]); + dev_dbg(&port->dev, "read status %04x\n", status); *line_state_p = klsi_105_status2linestate(status);