From: Vladimir Murzin <vladimir.murzin@arm.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
"Russell King" <linux@arm.linux.org.uk>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Daniel Lezcano" <daniel.lezcano@linaro.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Mark Rutland" <mark.rutland@arm.com>,
"Pawel Moll" <pawel.moll@arm.com>,
ijc+devicetree <ijc+devicetree@hellion.org.uk>,
"Kumar Gala" <galak@codeaurora.org>,
"Jiri Slaby" <jslaby@suse.cz>, "Rob Herring" <robh+dt@kernel.org>,
devicetree <devicetree@vger.kernel.org>,
"linux-serial@vger.kernel.org" <linux-serial@vger.kernel.org>,
"linux-api@vger.kernel.org" <linux-api@vger.kernel.org>,
"linux-arm Mailing List" <linux-arm-kernel@lists.infradead.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 04/10] serial: mps2-uart: add MPS2 UART driver
Date: Tue, 16 Feb 2016 14:25:47 +0000 [thread overview]
Message-ID: <56C3316B.10205@arm.com> (raw)
In-Reply-To: <CAHp75Vcx_xAY2A4XNgQ1ea_U5mUnD1+6=2FxCM3KzsRSpxgRuw@mail.gmail.com>
On 16/02/16 10:48, Andy Shevchenko wrote:
> On Tue, Feb 16, 2016 at 12:08 PM, Vladimir Murzin
> <vladimir.murzin@arm.com> wrote:
>> This driver adds support to the UART controller found on ARM MPS2
>> platform.
>
>
>> +static irqreturn_t mps2_uart_oerrirq(int irq, void *data)
>> +{
>> + irqreturn_t handled = IRQ_NONE;
>> + struct uart_port *port = data;
>> + u8 irqflag = mps2_uart_read8(port, UARTn_INT);
>> +
>> + spin_lock(&port->lock);
>> +
>> + if (irqflag & UARTn_INT_RX_OVERRUN) {
>> + struct tty_port *tport = &port->state->port;
>> +
>> + mps2_uart_write8(port, UARTn_INT_RX_OVERRUN, UARTn_INT);
>> + tty_insert_flip_char(tport, 0, TTY_OVERRUN);
>> + port->icount.overrun++;
>> + handled = IRQ_HANDLED;
>> + }
>> +
>> + /*
>> + * It's never been seen in practice and it never *should* happen since
>> + * we check if there is enough room in TX buffer before sending data.
>> + * So we keep this check in case something suspicious has happened.
>> + */
>> + if (irqflag & UARTn_INT_TX_OVERRUN) {
>> + mps2_uart_write8(port, UARTn_INT_TX_OVERRUN, UARTn_INT);
>
>> + dev_warn(port->dev, "unexpected overrun interrupt\n");
>
> I'm not sure there is no dead lock if this happens on the same port
> which is used as console.
Right, doesn't look like a good idea...
>
>> + handled = IRQ_HANDLED;
>> + }
>> +
>> + spin_unlock(&port->lock);
>> +
>> + return handled;
>> +}
>> +
>> +static int mps2_uart_startup(struct uart_port *port)
>> +{
>> + struct mps2_uart_port *mps_port = to_mps2_port(port);
>> + u8 control = mps2_uart_read8(port, UARTn_CTRL);
>> + int ret;
>> +
>> + control &= ~(UARTn_CTRL_RX_GRP | UARTn_CTRL_TX_GRP);
>> +
>> + mps2_uart_write8(port, control, UARTn_CTRL);
>> +
>> + ret = request_irq(mps_port->rx_irq, mps2_uart_rxirq, 0,
>> + MAKE_NAME(-rx), mps_port);
>> + if (ret) {
>> + dev_err(port->dev, "failed to register rxirq (%d)\n", ret);
>> + goto err_no_rxirq;
>
> It should be below, here just a plain return.
>
>> + }
>> +
>> + ret = request_irq(mps_port->tx_irq, mps2_uart_txirq, 0,
>> + MAKE_NAME(-tx), mps_port);
>> + if (ret) {
>> + dev_err(port->dev, "failed to register txirq (%d)\n", ret);
>> + goto err_no_txirq;
>
> goto err_free_rxirq;
>
>> + }
>> +
>> + ret = request_irq(port->irq, mps2_uart_oerrirq, IRQF_SHARED,
>> + MAKE_NAME(-overrun), mps_port);
>> +
>> + if (ret) {
>> + dev_err(port->dev, "failed to register oerrirq (%d)\n", ret);
>
> Why not goto pattern here as well?
>
> goto err_free_txirq;
>
>> + } else {
>
> …and remove this else.
>
>> + control |= UARTn_CTRL_RX_GRP | UARTn_CTRL_TX_GRP;
>> +
>> + mps2_uart_write8(port, control, UARTn_CTRL);
>> +
>> + return 0;
>> + }
>> +
>> + free_irq(mps_port->tx_irq, mps_port);
>> +err_no_txirq:
>> + free_irq(mps_port->rx_irq, mps_port);
>> +err_no_rxirq:
>> + return ret;
>> +}
>
Ok. Will rework that.
>
>> +static struct mps2_uart_port mps2_uart_ports[MPS2_MAX_PORTS];
>> +
>> +#ifdef CONFIG_SERIAL_MPS2_UART_CONSOLE
>> +static void mps2_uart_console_putchar(struct uart_port *port, int ch)
>> +{
>> + while (mps2_uart_read8(port, UARTn_STATE) & UARTn_STATE_TX_FULL)
>> + cpu_relax();
>
> Infinite?
>
The same as for [5/10].
>> +
>> + mps2_uart_write8(port, ch, UARTn_DATA);
>> +}
>
>> +static int mps2_init_port(struct mps2_uart_port *mps_port,
>> + struct platform_device *pdev)
>> +{
>> + int ret;
>> + struct resource *res;
>
> Maybe:
> struct resource *res;
> int ret;
> ?
>
Matter of taste :) Will change it since I need to update the patch anyway.
Thanks
Vladimir
WARNING: multiple messages have this Message-ID (diff)
From: vladimir.murzin@arm.com (Vladimir Murzin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v3 04/10] serial: mps2-uart: add MPS2 UART driver
Date: Tue, 16 Feb 2016 14:25:47 +0000 [thread overview]
Message-ID: <56C3316B.10205@arm.com> (raw)
In-Reply-To: <CAHp75Vcx_xAY2A4XNgQ1ea_U5mUnD1+6=2FxCM3KzsRSpxgRuw@mail.gmail.com>
On 16/02/16 10:48, Andy Shevchenko wrote:
> On Tue, Feb 16, 2016 at 12:08 PM, Vladimir Murzin
> <vladimir.murzin@arm.com> wrote:
>> This driver adds support to the UART controller found on ARM MPS2
>> platform.
>
>
>> +static irqreturn_t mps2_uart_oerrirq(int irq, void *data)
>> +{
>> + irqreturn_t handled = IRQ_NONE;
>> + struct uart_port *port = data;
>> + u8 irqflag = mps2_uart_read8(port, UARTn_INT);
>> +
>> + spin_lock(&port->lock);
>> +
>> + if (irqflag & UARTn_INT_RX_OVERRUN) {
>> + struct tty_port *tport = &port->state->port;
>> +
>> + mps2_uart_write8(port, UARTn_INT_RX_OVERRUN, UARTn_INT);
>> + tty_insert_flip_char(tport, 0, TTY_OVERRUN);
>> + port->icount.overrun++;
>> + handled = IRQ_HANDLED;
>> + }
>> +
>> + /*
>> + * It's never been seen in practice and it never *should* happen since
>> + * we check if there is enough room in TX buffer before sending data.
>> + * So we keep this check in case something suspicious has happened.
>> + */
>> + if (irqflag & UARTn_INT_TX_OVERRUN) {
>> + mps2_uart_write8(port, UARTn_INT_TX_OVERRUN, UARTn_INT);
>
>> + dev_warn(port->dev, "unexpected overrun interrupt\n");
>
> I'm not sure there is no dead lock if this happens on the same port
> which is used as console.
Right, doesn't look like a good idea...
>
>> + handled = IRQ_HANDLED;
>> + }
>> +
>> + spin_unlock(&port->lock);
>> +
>> + return handled;
>> +}
>> +
>> +static int mps2_uart_startup(struct uart_port *port)
>> +{
>> + struct mps2_uart_port *mps_port = to_mps2_port(port);
>> + u8 control = mps2_uart_read8(port, UARTn_CTRL);
>> + int ret;
>> +
>> + control &= ~(UARTn_CTRL_RX_GRP | UARTn_CTRL_TX_GRP);
>> +
>> + mps2_uart_write8(port, control, UARTn_CTRL);
>> +
>> + ret = request_irq(mps_port->rx_irq, mps2_uart_rxirq, 0,
>> + MAKE_NAME(-rx), mps_port);
>> + if (ret) {
>> + dev_err(port->dev, "failed to register rxirq (%d)\n", ret);
>> + goto err_no_rxirq;
>
> It should be below, here just a plain return.
>
>> + }
>> +
>> + ret = request_irq(mps_port->tx_irq, mps2_uart_txirq, 0,
>> + MAKE_NAME(-tx), mps_port);
>> + if (ret) {
>> + dev_err(port->dev, "failed to register txirq (%d)\n", ret);
>> + goto err_no_txirq;
>
> goto err_free_rxirq;
>
>> + }
>> +
>> + ret = request_irq(port->irq, mps2_uart_oerrirq, IRQF_SHARED,
>> + MAKE_NAME(-overrun), mps_port);
>> +
>> + if (ret) {
>> + dev_err(port->dev, "failed to register oerrirq (%d)\n", ret);
>
> Why not goto pattern here as well?
>
> goto err_free_txirq;
>
>> + } else {
>
> ?and remove this else.
>
>> + control |= UARTn_CTRL_RX_GRP | UARTn_CTRL_TX_GRP;
>> +
>> + mps2_uart_write8(port, control, UARTn_CTRL);
>> +
>> + return 0;
>> + }
>> +
>> + free_irq(mps_port->tx_irq, mps_port);
>> +err_no_txirq:
>> + free_irq(mps_port->rx_irq, mps_port);
>> +err_no_rxirq:
>> + return ret;
>> +}
>
Ok. Will rework that.
>
>> +static struct mps2_uart_port mps2_uart_ports[MPS2_MAX_PORTS];
>> +
>> +#ifdef CONFIG_SERIAL_MPS2_UART_CONSOLE
>> +static void mps2_uart_console_putchar(struct uart_port *port, int ch)
>> +{
>> + while (mps2_uart_read8(port, UARTn_STATE) & UARTn_STATE_TX_FULL)
>> + cpu_relax();
>
> Infinite?
>
The same as for [5/10].
>> +
>> + mps2_uart_write8(port, ch, UARTn_DATA);
>> +}
>
>> +static int mps2_init_port(struct mps2_uart_port *mps_port,
>> + struct platform_device *pdev)
>> +{
>> + int ret;
>> + struct resource *res;
>
> Maybe:
> struct resource *res;
> int ret;
> ?
>
Matter of taste :) Will change it since I need to update the patch anyway.
Thanks
Vladimir
next prev parent reply other threads:[~2016-02-16 14:25 UTC|newest]
Thread overview: 113+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-16 10:08 [PATCH v3 00/10] Support for Cortex-M Prototyping System Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 10:08 ` [PATCH v3 01/10] dt-bindings: document the MPS2 timer bindings Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 10:08 ` [PATCH v3 02/10] clockevents/drivers: add MPS2 Timer driver Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 10:08 ` [PATCH v3 03/10] dt-bindings: document the MPS2 UART bindings Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 10:08 ` [PATCH v3 04/10] serial: mps2-uart: add MPS2 UART driver Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
[not found] ` <1455617295-23736-5-git-send-email-vladimir.murzin-5wv7dgnIgG8@public.gmane.org>
2016-02-16 10:48 ` Andy Shevchenko
2016-02-16 10:48 ` Andy Shevchenko
2016-02-16 10:48 ` Andy Shevchenko
2016-02-16 14:25 ` Vladimir Murzin [this message]
2016-02-16 14:25 ` Vladimir Murzin
2016-02-16 11:02 ` One Thousand Gnomes
2016-02-16 11:02 ` One Thousand Gnomes
2016-02-16 15:09 ` Vladimir Murzin
2016-02-16 15:09 ` Vladimir Murzin
2016-02-16 10:08 ` [PATCH v3 05/10] serial: mps2-uart: add support for early console Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 10:36 ` Andy Shevchenko
2016-02-16 10:36 ` Andy Shevchenko
2016-02-16 13:09 ` Vladimir Murzin
2016-02-16 13:09 ` Vladimir Murzin
2016-02-16 13:13 ` Andy Shevchenko
2016-02-16 13:13 ` Andy Shevchenko
[not found] ` <CAHp75Vf_4MgdWunQy5hBMH5GGei+OkktFPYY-ZprY0qOEnD=wA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-16 13:38 ` Vladimir Murzin
2016-02-16 13:38 ` Vladimir Murzin
2016-02-16 13:38 ` Vladimir Murzin
[not found] ` <56C32641.4020201-5wv7dgnIgG8@public.gmane.org>
2016-02-16 14:00 ` Andy Shevchenko
2016-02-16 14:00 ` Andy Shevchenko
2016-02-16 14:00 ` Andy Shevchenko
2016-02-16 16:12 ` One Thousand Gnomes
2016-02-16 16:12 ` One Thousand Gnomes
[not found] ` <56C31F9F.10000-5wv7dgnIgG8@public.gmane.org>
2016-02-19 9:45 ` Vladimir Murzin
2016-02-19 9:45 ` Vladimir Murzin
2016-02-19 9:45 ` Vladimir Murzin
[not found] ` <56C6E42E.5070601-5wv7dgnIgG8@public.gmane.org>
2016-02-19 9:57 ` Andy Shevchenko
2016-02-19 9:57 ` Andy Shevchenko
2016-02-19 9:57 ` Andy Shevchenko
[not found] ` <CAHp75VcosaVcz_aYbpfL-nUH0kBf72SshXU5k95s48Z3wnA5nQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2016-02-19 15:46 ` Peter Hurley
2016-02-19 15:46 ` Peter Hurley
2016-02-19 15:46 ` Peter Hurley
[not found] ` <56C738F1.2070307-WaGBZJeGNqdsbIuE7sb01tBPR1lH4CV8@public.gmane.org>
2016-02-19 16:27 ` Vladimir Murzin
2016-02-19 16:27 ` Vladimir Murzin
2016-02-19 16:27 ` Vladimir Murzin
2016-02-16 10:08 ` [PATCH v3 06/10] ARM: mps2: introduce MPS2 platform Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
[not found] ` <1455617295-23736-7-git-send-email-vladimir.murzin-5wv7dgnIgG8@public.gmane.org>
2016-02-16 10:56 ` Arnd Bergmann
2016-02-16 10:56 ` Arnd Bergmann
2016-02-16 10:56 ` Arnd Bergmann
2016-02-16 14:35 ` Vladimir Murzin
2016-02-16 14:35 ` Vladimir Murzin
2016-02-16 14:35 ` Vladimir Murzin
[not found] ` <56C333BF.1020108-5wv7dgnIgG8@public.gmane.org>
2016-02-16 14:39 ` Arnd Bergmann
2016-02-16 14:39 ` Arnd Bergmann
2016-02-16 14:39 ` Arnd Bergmann
2016-02-16 10:08 ` [PATCH v3 07/10] ARM: mps2: add low-level debug support Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 10:08 ` [PATCH v3 08/10] ARM: configs: add MPS2 defconfig Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 10:58 ` Arnd Bergmann
2016-02-16 10:58 ` Arnd Bergmann
2016-02-16 14:51 ` Vladimir Murzin
2016-02-16 14:51 ` Vladimir Murzin
[not found] ` <56C3378F.2010008-5wv7dgnIgG8@public.gmane.org>
2016-02-16 15:08 ` Arnd Bergmann
2016-02-16 15:08 ` Arnd Bergmann
2016-02-16 15:08 ` Arnd Bergmann
2016-02-16 15:14 ` Vladimir Murzin
2016-02-16 15:14 ` Vladimir Murzin
2016-02-16 10:08 ` [PATCH v3 09/10] ARM: dts: introduce MPS2 AN385/AN386 Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
[not found] ` <1455617295-23736-10-git-send-email-vladimir.murzin-5wv7dgnIgG8@public.gmane.org>
2016-02-16 11:01 ` Arnd Bergmann
2016-02-16 11:01 ` Arnd Bergmann
2016-02-16 11:01 ` Arnd Bergmann
2016-02-16 16:10 ` Vladimir Murzin
2016-02-16 16:10 ` Vladimir Murzin
2016-02-17 16:48 ` Vladimir Murzin
2016-02-17 16:48 ` Vladimir Murzin
[not found] ` <56C4A46C.50506-5wv7dgnIgG8@public.gmane.org>
2016-02-17 16:58 ` Arnd Bergmann
2016-02-17 16:58 ` Arnd Bergmann
2016-02-17 16:58 ` Arnd Bergmann
2016-02-18 10:11 ` Vladimir Murzin
2016-02-18 10:11 ` Vladimir Murzin
2016-02-18 10:11 ` Vladimir Murzin
2016-02-18 10:45 ` Arnd Bergmann
2016-02-18 10:45 ` Arnd Bergmann
2016-02-18 11:13 ` Vladimir Murzin
2016-02-18 11:13 ` Vladimir Murzin
[not found] ` <56C5A742.8010304-5wv7dgnIgG8@public.gmane.org>
2016-02-18 12:16 ` Arnd Bergmann
2016-02-18 12:16 ` Arnd Bergmann
2016-02-18 12:16 ` Arnd Bergmann
2016-02-18 12:47 ` Vladimir Murzin
2016-02-18 12:47 ` Vladimir Murzin
2016-02-18 12:47 ` Vladimir Murzin
2016-02-16 15:17 ` Linus Walleij
2016-02-16 15:17 ` Linus Walleij
2016-02-16 15:17 ` Linus Walleij
2016-02-16 15:37 ` Vladimir Murzin
2016-02-16 15:37 ` Vladimir Murzin
2016-02-16 15:37 ` Vladimir Murzin
2016-02-16 10:08 ` [PATCH v3 10/10] ARM: dts: introduce MPS2 AN399/AN400 Vladimir Murzin
2016-02-16 10:08 ` Vladimir Murzin
2016-02-16 11:05 ` [PATCH v3 00/10] Support for Cortex-M Prototyping System Arnd Bergmann
2016-02-16 11:05 ` Arnd Bergmann
2016-02-16 16:14 ` Vladimir Murzin
2016-02-16 16:14 ` Vladimir Murzin
2016-02-16 16:14 ` Vladimir Murzin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56C3316B.10205@arm.com \
--to=vladimir.murzin@arm.com \
--cc=andy.shevchenko@gmail.com \
--cc=arnd@arndb.de \
--cc=daniel.lezcano@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=gregkh@linuxfoundation.org \
--cc=ijc+devicetree@hellion.org.uk \
--cc=jslaby@suse.cz \
--cc=linux-api@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=mark.rutland@arm.com \
--cc=pawel.moll@arm.com \
--cc=robh+dt@kernel.org \
--cc=tglx@linutronix.de \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.