Received: by 10.223.176.46 with SMTP id f43csp2610137wra; Mon, 22 Jan 2018 00:00:56 -0800 (PST) X-Google-Smtp-Source: AH8x224/xRZNEMnJFcXX+MzjPJDgCOuHyh23mu4dbhURBRS9Bh8ojDmbIkbz77Yq6rsKTkT32O9j X-Received: by 10.101.80.6 with SMTP id f6mr6612598pgo.272.1516608055922; Mon, 22 Jan 2018 00:00:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516608055; cv=none; d=google.com; s=arc-20160816; b=TFO/f9M5NgvAazgX2vkWIX7PxERN7ihGsINC50sD9BBT9qkXIewgxDZuFRS1xKx9FH 761gWrMC2brGInhUUl7ecXmq+9ZRyOSmbMRMjkFveYlFb4jz1KDE5WQoZjLLsK46zlTq D66ozqY3NakDXTEa09w6b7xp3MaJRpLiqD+q3NLuslH4MyPenBbMbQk69P2yanS5qrFk wGHz2xGTFvmXhcoqlf3hlNr6WZ9Fn+6nrPMl/cxibNRVS0TfgF9NKbwhMteZJSEgIJUN szE8tWQHaymYoFdkqosxm6ck6Jbeb4qRxPLznVlNmFDJ7AbOFielUC2Ww77VY2LhUqHV u/XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=xroenPQVy6VzbO2PaitV40OimOqyLugpS2uz94DhGuA=; b=H80oTk8HJ4XRXrhuNJ95exhqxbXV0KdFPBndiyAqUxFDsAfYBc12cRqx5xh7ejvari PYjoDZyAZx2YJw5vCOpTVnkZABh9R0GciK/IWtyjtEFETRmDt0TXdf4yAeqiwH8S96bH yKejB2L5GAkEtpVo8olaNYxUSbdiNP4MWJxp7PgQrlr4plG/bilueW98EqjqU78vN81b fDMj6K69PVECi5AoxBgR5trDuX7z12seaVt9gfBueFDyXPpem17CukSQ4Ynh2F2nhf/a +65KB+WhlhWdlqL2OfH4+RRdOCVfL6lbOsQddGtobYIwt4LQL5AWfxoOiRyrmnxeh9+q Bbjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nlJbtZQF; 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=NONE 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 z15si13173698pgv.91.2018.01.22.00.00.41; Mon, 22 Jan 2018 00:00:55 -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=nlJbtZQF; 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=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751093AbeAVH6w (ORCPT + 99 others); Mon, 22 Jan 2018 02:58:52 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:35662 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981AbeAVH6v (ORCPT ); Mon, 22 Jan 2018 02:58:51 -0500 Received: by mail-pf0-f195.google.com with SMTP id t12so6476510pfg.2; Sun, 21 Jan 2018 23:58: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; bh=xroenPQVy6VzbO2PaitV40OimOqyLugpS2uz94DhGuA=; b=nlJbtZQFattwrT8aCsCUFB0nlmaH6tVJLqLs85BF45u0Kw6WFnj8vU4oTllUl6GbO0 G1OWw5WAhOrh3YdiactCjve5lE5NerwKG5HviS8zpv5Na+KmxyvIIdWttD0lUjA9wRec v7HpqGZMxIOI4JKc8xTLe/GgPllguC0hS1aHks4avIu7RgwN2eFgwjxtrM4Vlk08WNuM d6C+76CQRDOyB/JS8zAU7mENC3KNgfbQRnnLWAZwZw5CLr83Qo0b4Y9jM/YlEwRpMRj8 LnWTJuIgA8sV2xcrrssDouYUPHQFOa+3yc4u2mwjTGHnuoXSJzGRtYIIrONZK9Eoco2W lF+w== 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; bh=xroenPQVy6VzbO2PaitV40OimOqyLugpS2uz94DhGuA=; b=Bg3DwYtpbELenwVjNQZzGJaLyrnQRYKrh5D718AbEkV/tW65hypVATTUI9Her/lFFw tXc+7NXxKm10uH9XRERY6RfYP1gNqIxYrzRHw69T13W95UzRnRcFArKOuCMql97zGg35 9Je9H62gFcwWUdyINOJTFQBdgDisdrcau/WfouZi0ypv58i0CXiEtvumCR3zfw42JGwd fBxANgFqiUgmFaz99JOQ1UpqjOsIUbCEQoNF/ZRMGMzHscaYqjK2UQF+OiOl3vPvngaL Eo0Y7CBE7VbATFYtlwmzpjgHrmoRRyR+/kB+/6k2hSleV4POCzlY/BM3ICG6NS3XeO/L V0wA== X-Gm-Message-State: AKwxyteFfVlaZwhaqzIR2ouk0zWK7ChC5tu9N9pwav1xSKq8gyax9q5k KZ7XEq+hWIkH74hPIhPsTq8HBaqm X-Received: by 10.99.117.74 with SMTP id f10mr6441907pgn.385.1516607930771; Sun, 21 Jan 2018 23:58:50 -0800 (PST) Received: from localhost (59-120-186-245.HINET-IP.hinet.net. [59.120.186.245]) by smtp.gmail.com with ESMTPSA id c76sm5658135pga.16.2018.01.21.23.58.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Jan 2018 23:58:50 -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 1/5] USB: serial: f81232: clear overrun flag Date: Mon, 22 Jan 2018 15:58:43 +0800 Message-Id: <1516607927-8887-1-git-send-email-hpeter+linux_kernel@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The F81232 will report data and LSR with bulk like following format: bulk-in data: [LSR(1Byte)+DATA(1Byte)][LSR(1Byte)+DATA(1Byte)]... LSR will auto clear frame/parity/break error flag when reading by H/W, but overrrun will only cleared when reading LSR. So this patch add a worker to read LSR when OE. Signed-off-by: Ji-Ze Hong (Peter Hong) --- drivers/usb/serial/f81232.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/usb/serial/f81232.c b/drivers/usb/serial/f81232.c index 96036f87b1de..46836041c50e 100644 --- a/drivers/usb/serial/f81232.c +++ b/drivers/usb/serial/f81232.c @@ -41,12 +41,14 @@ MODULE_DEVICE_TABLE(usb, id_table); #define FIFO_CONTROL_REGISTER (0x02 + SERIAL_BASE_ADDRESS) #define LINE_CONTROL_REGISTER (0x03 + SERIAL_BASE_ADDRESS) #define MODEM_CONTROL_REGISTER (0x04 + SERIAL_BASE_ADDRESS) +#define LINE_STATUS_REGISTER (0x05 + SERIAL_BASE_ADDRESS) #define MODEM_STATUS_REGISTER (0x06 + SERIAL_BASE_ADDRESS) struct f81232_private { struct mutex lock; u8 modem_control; u8 modem_status; + struct work_struct lsr_work; struct work_struct interrupt_work; struct usb_serial_port *port; }; @@ -282,6 +284,7 @@ static void f81232_read_int_callback(struct urb *urb) static void f81232_process_read_urb(struct urb *urb) { struct usb_serial_port *port = urb->context; + struct f81232_private *priv = usb_get_serial_port_data(port); unsigned char *data = urb->transfer_buffer; char tty_flag; unsigned int i; @@ -315,6 +318,7 @@ static void f81232_process_read_urb(struct urb *urb) if (lsr & UART_LSR_OE) { port->icount.overrun++; + schedule_work(&priv->lsr_work); tty_insert_flip_char(&port->port, 0, TTY_OVERRUN); } @@ -623,6 +627,21 @@ static void f81232_interrupt_work(struct work_struct *work) f81232_read_msr(priv->port); } +static void f81232_lsr_worker(struct work_struct *work) +{ + struct f81232_private *priv; + struct usb_serial_port *port; + int status; + u8 tmp; + + priv = container_of(work, struct f81232_private, lsr_work); + port = priv->port; + + status = f81232_get_register(port, LINE_STATUS_REGISTER, &tmp); + if (status) + dev_warn(&port->dev, "read LSR failed: %d\n", status); +} + static int f81232_port_probe(struct usb_serial_port *port) { struct f81232_private *priv; @@ -633,6 +652,7 @@ static int f81232_port_probe(struct usb_serial_port *port) mutex_init(&priv->lock); INIT_WORK(&priv->interrupt_work, f81232_interrupt_work); + INIT_WORK(&priv->lsr_work, f81232_lsr_worker); usb_set_serial_port_data(port, priv); -- 2.7.4