From: Russell King - ARM Linux <linux@arm.linux.org.uk>
To: Peter Hurley <peter@hurleysoftware.com>
Cc: Andre Przywara <andre.przywara@arm.com>,
Linus Walleij <linus.walleij@linaro.org>,
Andrew.Jackson@arm.com, Timur Tabi <timur@tabi.org>,
linux-serial@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jslaby@suse.com>, Jun Nie <jun.nie@linaro.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 01/12] tty: amba-pl011: add register accessor functions
Date: Thu, 24 Dec 2015 15:14:24 +0000 [thread overview]
Message-ID: <20151224151424.GG8644@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <566333AF.8020507@hurleysoftware.com>
On Sat, Dec 05, 2015 at 01:57:51PM -0500, Peter Hurley wrote:
> On 11/16/2015 12:40 PM, Russell King wrote:
> > Add register accessor functions to amba-pl011. Much of this
> > transformation was done using the sed expression below, with any
> > left-overs fixed up manually afterwards, and code formatted to remain
> > within coding style.
>
> A couple local temporaries are u16; I noted which below.
> Can be fixed with follow-up patch if desired.
>
> > s/readw(\(uap->port.membase\|regs\|port->membase\) +/pl011_read(\1,/g
> > s/writew(\(.*\) +/pl011_write(\1,/g
> >
> > Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
> > ---
> > drivers/tty/serial/amba-pl011.c | 210 +++++++++++++++++++++-------------------
> > 1 file changed, 112 insertions(+), 98 deletions(-)
> >
> > diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
> > index 899a77187bde..bd01e75128dc 100644
> > --- a/drivers/tty/serial/amba-pl011.c
> > +++ b/drivers/tty/serial/amba-pl011.c
> > @@ -184,6 +184,16 @@ struct uart_amba_port {
> > #endif
> > };
> >
> > +static unsigned int pl011_read(void __iomem *base, unsigned int reg)
> > +{
> > + return readw(base + reg);
> > +}
> > +
> > +static void pl011_write(unsigned int val, void __iomem *base, unsigned int reg)
> > +{
> > + writew(val, base + reg);
> > +}
> > +
> > /*
> > * Reads up to 256 characters from the FIFO or until it's empty and
> > * inserts them into the TTY layer. Returns the number of characters
> > @@ -196,12 +206,12 @@ static int pl011_fifo_to_tty(struct uart_amba_port *uap)
> > int fifotaken = 0;
> >
> > while (max_count--) {
> > - status = readw(uap->port.membase + UART01x_FR);
> > + status = pl011_read(uap->port.membase, UART01x_FR);
>
> status is u16.
Not a problem, the register itself is only 16-bit wide.
> > if (status & UART01x_FR_RXFE)
> > break;
> >
> > /* Take chars from the FIFO and update status */
> > - ch = readw(uap->port.membase + UART01x_DR) |
> > + ch = pl011_read(uap->port.membase, UART01x_DR) |
> > UART_DUMMY_DR_RX;
> > flag = TTY_NORMAL;
> > uap->port.icount.rx++;
> > @@ -438,7 +448,7 @@ static void pl011_dma_tx_callback(void *data)
> >
> > dmacr = uap->dmacr;
>
> dmacr is u16.
>
> > uap->dmacr = dmacr & ~UART011_TXDMAE;
> > - writew(uap->dmacr, uap->port.membase + UART011_DMACR);
> > + pl011_write(uap->dmacr, uap->port.membase, UART011_DMACR);
Also not a problem.
> > @@ -658,9 +668,9 @@ static inline bool pl011_dma_tx_start(struct uart_amba_port *uap)
> > */
> > dmacr = uap->dmacr;
>
> dmacr is u16.
Not a problem.
> > @@ -1361,15 +1372,15 @@ static irqreturn_t pl011_int(int irq, void *dev_id)
> > int handled = 0;
> >
> > spin_lock_irqsave(&uap->port.lock, flags);
> > - imsc = readw(uap->port.membase + UART011_IMSC);
> > - status = readw(uap->port.membase + UART011_RIS) & imsc;
> > + imsc = pl011_read(uap->port.membase, UART011_IMSC);
>
> imsc is u16.
Not a problem, IMSC is only 16-bit wide.
None of these are a problem:
* The registers are defined on 32-bit boundaries.
* The registers in question all have less than 16 bits.
* GCC will automatically promote/demote these integers as necessary.
--
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
next prev parent reply other threads:[~2015-12-24 15:14 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-16 17:39 [PATCH 00/12] Prepare amba-pl011 for ZTE UART support Russell King - ARM Linux
2015-11-16 17:40 ` [PATCH 01/12] tty: amba-pl011: add register accessor functions Russell King
2015-12-05 18:57 ` Peter Hurley
2015-12-24 15:14 ` Russell King - ARM Linux [this message]
2015-11-16 17:40 ` [PATCH 02/12] tty: amba-pl011: convert accessor functions to take uart_amba_port Russell King
2015-11-16 17:40 ` [PATCH 03/12] tty: amba-pl011: add helper to detect split LCRH register Russell King
2015-11-16 17:40 ` [PATCH 04/12] tty: amba-pl011: prepare REG_* register indexes Russell King
2015-11-16 17:40 ` [PATCH 05/12] tty: amba-pl011: add register lookup table Russell King
2015-11-19 14:10 ` Dave Martin
2015-12-24 6:54 ` Huang Shijie
2015-12-24 11:01 ` Russell King - ARM Linux
2015-12-24 15:03 ` Timur Tabi
2015-12-24 15:05 ` Russell King - ARM Linux
2015-12-24 15:35 ` Timur Tabi
2015-12-24 15:40 ` Russell King - ARM Linux
2015-12-24 15:50 ` Timur Tabi
2015-12-24 15:54 ` Russell King - ARM Linux
2015-12-24 16:07 ` Russell King - ARM Linux
2015-12-24 16:51 ` Russell King - ARM Linux
2015-11-16 17:40 ` [PATCH 06/12] tty: amba-pl011: add register offset table to vendor data Russell King
2015-11-16 17:40 ` [PATCH 07/12] tty: amba-pl011: add ST register offset table Russell King
2015-11-16 17:40 ` [PATCH 08/12] tty: amba-pl011: clean up LCR register offsets Russell King
2015-11-16 17:40 ` [PATCH 09/12] tty: amba-pl011: remove ST micro registers from standard table Russell King
2015-11-16 17:40 ` [PATCH 10/12] tty: amba-pl011: add support for 32-bit register access Russell King
2015-11-16 17:45 ` Timur Tabi
2015-11-16 17:52 ` Russell King - ARM Linux
2015-11-16 18:25 ` Timur Tabi
2015-11-16 18:30 ` Russell King - ARM Linux
2015-11-16 20:52 ` Timur Tabi
2015-11-16 21:18 ` Peter Hurley
2015-11-16 17:40 ` [PATCH 11/12] tty: amba-pl011: add support for ZTE UART (EXPERIMENTAL) Russell King
2015-11-16 17:41 ` [PATCH 12/12] tty: amba-pl011: switch to using relaxed IO accessors Russell King
2015-12-05 18:49 ` [PATCH 00/12] Prepare amba-pl011 for ZTE UART support Peter Hurley
2015-12-05 19:06 ` Timur Tabi
2015-12-13 6:36 ` Greg Kroah-Hartman
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=20151224151424.GG8644@n2100.arm.linux.org.uk \
--to=linux@arm.linux.org.uk \
--cc=Andrew.Jackson@arm.com \
--cc=andre.przywara@arm.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.com \
--cc=jun.nie@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-serial@vger.kernel.org \
--cc=peter@hurleysoftware.com \
--cc=timur@tabi.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).