From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] nios2: convert altera_jtag_uart to driver model
Date: Sun, 13 Sep 2015 15:42:43 +0200 [thread overview]
Message-ID: <201509131542.43478.marex@denx.de> (raw)
In-Reply-To: <1442133130-11174-2-git-send-email-thomas@wytron.com.tw>
On Sunday, September 13, 2015 at 10:32:10 AM, Thomas Chou wrote:
> Convert altera_jtag_uart to driver model.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
[...]
> -static int altera_jtag_serial_init(void)
> +static int altera_jtaguart_putc(struct udevice *dev, const char c)
> {
> - return 0;
> -}
> + struct altera_jtaguart_platdata *plat = dev->platdata;
> + struct altera_jtaguart_regs *const regs = plat->reg;
>
> -static void altera_jtag_serial_putc(char c)
> -{
> while (1) {
> - unsigned st = readl(&jtag->control);
> + unsigned st = readl(®s->control);
> if (NIOS_JTAG_WSPACE(st))
> break;
> #ifdef CONFIG_ALTERA_JTAG_UART_BYPASS
> if (!(st & NIOS_JTAG_AC)) /* no connection */
> - return;
> + return 0;
> #endif
> - WATCHDOG_RESET();
Please keep those WATCHDOG_RESET() calls, they're needed in case you
do have a WDT on your board.
> }
> - writel ((unsigned char)c, &jtag->data);
> + writel((unsigned char)c, ®s->data);
> +
> + return 0;
> }
[...]
> -static int altera_jtag_serial_getc(void)
> +static int altera_jtaguart_getc(struct udevice *dev)
> {
> - int c;
> + struct altera_jtaguart_platdata *plat = dev->platdata;
> + struct altera_jtaguart_regs *const regs = plat->reg;
> unsigned val;
>
> - while (1) {
> - WATCHDOG_RESET ();
> - val = readl (&jtag->data);
> - if (val & NIOS_JTAG_RVALID)
> - break;
> - }
> - c = val & 0x0ff;
> - return (c);
> + while (!((val = readl(®s->data)) & NIOS_JTAG_RVALID))
Ewww, this is ugly. Please expand it into something like the following,
for the sake of readability.
while (1) {
val = readl()
if (val & cond)
break;
}
> + ;
> +
> + return (val & 0xff);
> }
Looks good otherwise, thanks ! :)
[...]
next prev parent reply other threads:[~2015-09-13 13:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-13 8:32 [U-Boot] [PATCH 1/2] nios2: remap and translate reg address in device tree Thomas Chou
2015-09-13 8:32 ` [U-Boot] [PATCH 2/2] nios2: convert altera_jtag_uart to driver model Thomas Chou
2015-09-13 13:42 ` Marek Vasut [this message]
2015-09-13 13:39 ` [U-Boot] [PATCH 1/2] nios2: remap and translate reg address in device tree Marek Vasut
2015-09-14 12:39 ` Simon Glass
2015-09-15 4:48 ` Thomas Chou
2015-09-13 13:40 ` [U-Boot] [PATCH v2 0/3] nios2: convert altera_jtag_uart to driver model Thomas Chou
2015-09-13 13:40 ` [U-Boot] [PATCH v2 1/3] nios2: map physical address to uncached virtual address Thomas Chou
2015-09-13 13:46 ` Marek Vasut
2015-10-01 22:49 ` Simon Glass
2015-10-02 0:16 ` Thomas Chou
2015-10-02 11:21 ` Simon Glass
2015-09-13 13:40 ` [U-Boot] [PATCH v2 2/3] nios2: remove bridges in device tree Thomas Chou
2015-09-13 13:40 ` [U-Boot] [PATCH v2 3/3] nios2: convert altera_jtag_uart to driver model Thomas Chou
2015-09-14 5:39 ` [U-Boot] [PATCH 1/2] nios2: remap and translate reg address in device tree Stefan Roese
2015-09-15 0:50 ` Thomas Chou
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=201509131542.43478.marex@denx.de \
--to=marex@denx.de \
--cc=u-boot@lists.denx.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.