From patchwork Thu Apr 8 17:02:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: christian pellegrin X-Patchwork-Id: 91311 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o38H5KnE028014 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 8 Apr 2010 17:05:56 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NzvAO-00046W-9C; Thu, 08 Apr 2010 17:05:20 +0000 Received: from sfi-mx-4.v28.ch3.sourceforge.com ([172.29.28.124] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1NzvAN-00046O-6g for spi-devel-general@lists.sourceforge.net; Thu, 08 Apr 2010 17:05:19 +0000 Received-SPF: pass (sfi-mx-4.v28.ch3.sourceforge.com: domain of gmail.com designates 74.125.78.149 as permitted sender) client-ip=74.125.78.149; envelope-from=chripell@gmail.com; helo=ey-out-1920.google.com; Received: from ey-out-1920.google.com ([74.125.78.149]) by sfi-mx-4.v28.ch3.sourceforge.com with esmtp (Exim 4.69) id 1NzvAL-0007eo-Th for spi-devel-general@lists.sourceforge.net; Thu, 08 Apr 2010 17:05:19 +0000 Received: by ey-out-1920.google.com with SMTP id 26so186296eyw.40 for ; Thu, 08 Apr 2010 10:05:11 -0700 (PDT) Received: by 10.213.60.13 with SMTP id n13mr232775ebh.36.1270746311423; Thu, 08 Apr 2010 10:05:11 -0700 (PDT) Received: from localhost (host180-111-dynamic.104-80-r.retail.telecomitalia.it [80.104.111.180]) by mx.google.com with ESMTPS id 16sm175854ewy.3.2010.04.08.10.05.09 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 08 Apr 2010 10:05:10 -0700 (PDT) From: Christian Pellegrin To: akpm@linux-foundation.org, feng.tang@intel.com, grant.likely@secretlab.ca, alan@lxorguk.ukuu.org.uk, linux-serial@vger.kernel.org, spi-devel-general@lists.sourceforge.net Date: Thu, 8 Apr 2010 19:02:32 +0200 Message-Id: <1270746152-25250-1-git-send-email-chripell@fsfe.org> X-Mailer: git-send-email 1.5.6.5 In-Reply-To: References: X-Spam-Score: -1.5 (-) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.0 DKIM_VERIFIED Domain Keys Identified Mail: signature passes verification 0.0 DKIM_SIGNED Domain Keys Identified Mail: message has a signature X-Headers-End: 1NzvAL-0007eo-Th Cc: Christian Pellegrin Subject: [spi-devel-general] [PATCH -mm 1/1] max3100: Fixes for the MAX31x0 console X-BeenThere: spi-devel-general@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: Linux SPI core/device drivers discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: spi-devel-general-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 08 Apr 2010 17:05:56 +0000 (UTC) diff --git a/drivers/serial/max3100.c b/drivers/serial/max3100.c index 6644222..c7def2f 100644 --- a/drivers/serial/max3100.c +++ b/drivers/serial/max3100.c @@ -147,6 +147,8 @@ struct max3100_port { struct work_struct console_work; /* char tx timeout */ int console_tout; + /* lock on receiving chars */ + struct mutex rx_lock; #endif }; @@ -192,6 +194,19 @@ static void max3100_calc_parity(struct max3100_port *s, u16 *c) *c |= max3100_do_parity(s, *c) << 8; } +static void max3100_flip(struct max3100_port *s) +{ + if (s->port.state->port.tty != NULL) { +#ifdef CONFIG_SERIAL_MAX3100_CONSOLE + mutex_lock(&s->rx_lock); +#endif + tty_flip_buffer_push(s->port.state->port.tty); +#ifdef CONFIG_SERIAL_MAX3100_CONSOLE + mutex_unlock(&s->rx_lock); +#endif + } +} + static void max3100_resume_work(struct work_struct *w) { struct max3100_port *s = container_of(w, struct max3100_port, @@ -242,6 +257,10 @@ static int max3100_handlerx(struct max3100_port *s, u16 rx) unsigned int ch, flg, status = 0; int ret = 0, cts; +#ifdef CONFIG_SERIAL_MAX3100_CONSOLE + mutex_lock(&s->rx_lock); +#endif + if (rx & MAX3100_R && s->rx_enabled) { dev_dbg(&s->spi->dev, "%s\n", __func__); ch = rx & (s->parity & MAX3100_7BIT ? 0x7f : 0xff); @@ -274,6 +293,10 @@ static int max3100_handlerx(struct max3100_port *s, u16 rx) uart_handle_cts_change(&s->port, cts ? TIOCM_CTS : 0); } +#ifdef CONFIG_SERIAL_MAX3100_CONSOLE + mutex_unlock(&s->rx_lock); +#endif + return ret; } @@ -329,8 +352,8 @@ static irqreturn_t max3100_ist(int irq, void *dev_id) } } - if (rxchars > 16 && s->port.state->port.tty != NULL) { - tty_flip_buffer_push(s->port.state->port.tty); + if (rxchars > 16) { + max3100_flip(s); rxchars = 0; } if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) @@ -341,8 +364,8 @@ static irqreturn_t max3100_ist(int irq, void *dev_id) (!uart_circ_empty(xmit) && !uart_tx_stopped(&s->port)))); - if (rxchars > 0 && s->port.state->port.tty != NULL) - tty_flip_buffer_push(s->port.state->port.tty); + if (rxchars > 0) + max3100_flip(s); return IRQ_HANDLED; } @@ -699,6 +722,7 @@ static void max3100_console_work(struct work_struct *w) console_work); unsigned long start; u16 tx, rx; + int rxchars = 0; while (s->console_head != s->console_tail && (s->console_flags & MAX3100_SUSPENDING) == 0) { @@ -710,10 +734,19 @@ static void max3100_console_work(struct work_struct *w) !time_after(jiffies, start + s->console_tout)); tx = s->console_buf[s->console_tail]; max3100_calc_parity(s, &tx); - tx |= MAX3100_WD | MAX3100_RTS; + tx |= MAX3100_WD | (s->rts ? MAX3100_RTS : 0); max3100_sr(s, tx, &rx); + if (s->port.state->port.tty != NULL) { + rxchars += max3100_handlerx(s, rx); + if (rxchars > 16) { + max3100_flip(s); + rxchars = 0; + } + } s->console_tail = (s->console_tail + 1) % CONSOLE_BUF_SIZE; } + if (rxchars) + max3100_flip(s); } static void max3100_console_putchar(struct uart_port *port, int ch) @@ -809,6 +842,10 @@ static int max3100_console_setup(struct console *co, char *options) if (parity == 'o') s->parity |= MAX3100_PARITY_ODD; s->console_tout = 1 + (20 * HZ) / baud; /* jiffies to send 20 bits */ + if (flow != 'n') + s->rts = 1; + else + s->rts = 0; tx |= MAX3100_WC; max3100_sr(s, tx, &rx); @@ -912,6 +949,7 @@ static int __devinit max3100_probe(struct spi_device *spi) i, retval); #ifdef CONFIG_SERIAL_MAX3100_CONSOLE + mutex_init(&max3100s[i]->rx_lock); if (pdata->console && !max3100_console_registered) { register_console(&max3100_console); max3100_console_registered = 1;