Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1379096ybl; Wed, 29 Jan 2020 21:49:23 -0800 (PST) X-Google-Smtp-Source: APXvYqz2f6oupl8xxK+117PMLDQ5rCA8xOJHq4usbRBpGsBV00QHeT/YwqgUbe1RHrh7WORXWOXm X-Received: by 2002:aca:b286:: with SMTP id b128mr1874054oif.147.1580363362988; Wed, 29 Jan 2020 21:49:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580363362; cv=none; d=google.com; s=arc-20160816; b=EgJblayM0ohkPU7ydsYi+fO4w/xyIFGIb75uaFKkielXm0nkF5jo9k8M6mdWTOKJiE 66mHOq4qaZUUYdUVZ6I1nZpOhztpD/73egEqPxuQyn6iAENwVvkWjT3ESyGSSPIeMpSp Oa5Xf/ElPtCkg48wGBTtdQAWcgyjQYrss9DUIhQxxXJ+ggaDD10jIFQAS9/8tQHqK59o UfxrU91UC5hMhTuX04u8+g8ywclBokWX0JBTbrpsVegdZwQ6EyvCDoECbFp0/UwfliP1 9rjoz3Pfs0uyKXwPlKoU3kWixLzCr+lPxm2dzNYbnhehZABIZwvgGjh9JvjoUMIOoNfn lecQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=d2SIm3bhYZ5Yw954kj7k/SsJk8xges7EqsF+eWSvkxA=; b=KW3B5hTJLfEdaUYm7TCNfC2Q/73hbY2o1m6SgY+WJMjRd7jDXpcwT0eOxQadY2RuxE 61BsFYXyM3+GZJXOFrP0pW8kLMEWvlM5BqO/RTC9/VTTiHxJbRkuRF1A/PtcC9H91Lpn mrK7Ifhz4kH+g4AlXm0QkzS6GKbxx/Sdn/E16ssBprfX9FUOAdauWVSKlTWYFW7iXsEp TSJ28ZfOo4fb1UNUnAeC0y4K2S6s9vBwfYSJWWftaiWnY1HE8/0YgqObn+JLZJc1iEN9 4KFFBewpcHOtUqO2kG7oHGYXx98UJz/EW9UVkhymZPE91EBh9x5MAY4qEO/q72shYLQ1 1T9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bdiiNJKS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y6si2100697oih.217.2020.01.29.21.49.04; Wed, 29 Jan 2020 21:49:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bdiiNJKS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727197AbgA3FsD (ORCPT + 99 others); Thu, 30 Jan 2020 00:48:03 -0500 Received: from mail-pj1-f66.google.com ([209.85.216.66]:39165 "EHLO mail-pj1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727139AbgA3FsB (ORCPT ); Thu, 30 Jan 2020 00:48:01 -0500 Received: by mail-pj1-f66.google.com with SMTP id e9so857081pjr.4; Wed, 29 Jan 2020 21:48:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=d2SIm3bhYZ5Yw954kj7k/SsJk8xges7EqsF+eWSvkxA=; b=bdiiNJKSxMT0YkQNhlu41/94uAHaM9o8M8stTDHu/07g3sUzklnZGkpx00Wgk4iLsC 6poUW/b/eXdXX4mveA93Wb3CT7b67sYk5FOv9b5ATpo1s1DHdZd4nPkp0QgWMDobObQc lVel2g5GUG0BM0LdcMQB4KqlTfteCvo539UjPcuUJrotnej1YjkuoFye7G/l8ZUJ7VHr s6wtvqLKmj3TmqupQutezgpj5m+cF8bqCVqAMXzTL3fYoNJyNo0HaySng1NCnB6SIguu 23YxN0WWe9ETbGMGnUrNTfWJQvQ8q+uAiDH41dBuse6jMz6Z4GqJuJ9tkjPsv+i0lW10 PZow== 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=d2SIm3bhYZ5Yw954kj7k/SsJk8xges7EqsF+eWSvkxA=; b=NarLXFjIw1fBXNMjsDUiTkAfa83fmeUjRWI+Ents59e3l2iu5kkKrPdlkt91PgYIwH fxuQGSYWjYXGH/jFI42XGhW21hweZr07VJX2GND2Rj/1RCe2qSvIoRQXqhaMTQsDEyVV +fYQZoVqE9GNAYVrX/U0ywweVY2I781z4bq/X5IbMjsyYJg8OhTz7oJYiptah3wV8mCY bDSJDZvRRN1L3ezfVwlzs77xpEZnvvK3Pz3Cjza/SstqBn+v/OdKSd3W7E77Y7D1jRAw K1qtLMcGf2zo4L66HqjyyKbDVB3uR93qDQcvYuRb8kN+NGZcpy4Zc7+JLpi8Qam9ALcv RkfA== X-Gm-Message-State: APjAAAVR1vSxaePmgU6Yz8ZWHDaUGSAVnwObJxIS8zxUvJO8e+xd/XCC lqUrPwWxKz210uPMkAfSNgM= X-Received: by 2002:a17:902:e789:: with SMTP id cp9mr3125780plb.85.1580363280762; Wed, 29 Jan 2020 21:48:00 -0800 (PST) Received: from localhost (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id o184sm4621315pgo.62.2020.01.29.21.47.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Jan 2020 21:48:00 -0800 (PST) From: "Ji-Ze Hong (Peter Hong)" X-Google-Original-From: "Ji-Ze Hong (Peter Hong)" To: johan@kernel.org Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, peter_hong@fintek.com.tw, "Ji-Ze Hong (Peter Hong)" Subject: [PATCH V3 2/6] USB: serial: f81232: Add tx_empty function Date: Thu, 30 Jan 2020 13:47:48 +0800 Message-Id: <20200130054752.9368-3-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200130054752.9368-1-hpeter+linux_kernel@gmail.com> References: <20200130054752.9368-1-hpeter+linux_kernel@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add tx_empty() function for F81232. Without this, console redirection will get garbage data. Signed-off-by: Ji-Ze Hong (Peter Hong) --- Changelog: v3: 1. Modify return true when accessing device with error. v2: 1: Change check tx empty from UART_LSR_TEMT | UART_LSR_THRE to UART_LSR_TEMT only. drivers/usb/serial/f81232.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index c07d376c743d..793d0b30e347 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -685,6 +685,20 @@ static void f81232_dtr_rts(struct usb_serial_port *port, int on) f81232_set_mctrl(port, 0, TIOCM_DTR | TIOCM_RTS); } +static bool f81232_tx_empty(struct usb_serial_port *port) +{ + int status; + u8 tmp; + + status = f81232_get_register(port, LINE_STATUS_REGISTER, &tmp); + if (!status) { + if ((tmp & UART_LSR_TEMT) != UART_LSR_TEMT) + return false; + } + + return true; +} + static int f81232_carrier_raised(struct usb_serial_port *port) { u8 msr; @@ -820,6 +834,7 @@ static struct usb_serial_driver f81232_device = { .tiocmget = f81232_tiocmget, .tiocmset = f81232_tiocmset, .tiocmiwait = usb_serial_generic_tiocmiwait, + .tx_empty = f81232_tx_empty, .process_read_urb = f81232_process_read_urb, .read_int_callback = f81232_read_int_callback, .port_probe = f81232_port_probe, -- 2.17.1