lib: utils: Fix shakti uart implementation
PATCH 1/1 lib: utils: Fix shakti uart implementation
Fix uart_putc implementation.
Due to a bug in the IP, this went unnoticed. Use macros instead of magic numbers to make the code more readable.
--- lib/utils/serial/shakti-uart.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
lib/utils/serial/shakti-uart.c +5 -2
@@ -18,18 +18,21 @@#define REG_IQ_CYCLES 0x1C#define REG_RX_THRES 0x20 +#define UART_TX_FULL 0x2 +#define UART_RX_FULL 0x8 +static volatile void *uart_base;void shakti_uart_putc (char ch) { -while ((readw (uart_base +REG_STATUS ) &0x2 ) ==0 ); +while ((readw (uart_base +REG_STATUS ) &UART_TX_FULL ));writeb (ch, uart_base +REG_TX ); }int shakti_uart_getc (void ) {u16 status =readw (uart_base +REG_STATUS ); -if (status &0x8 ) +if (status &UART_RX_FULL )return readb (uart_base +REG_RX );return -1 ; }
Signature · 1 line
2.25.1
PATCH 1/1 lib: utils: Fix shakti uart implementation
Quoted 6 lines · Vijai Kumar K
Fix
uart_putcimplementation.
Due to a bug in the IP, this went unnoticed. Use macros instead of magic numbers to make the code more readable.
Yeah, using macros is good, but this patch isn't doing anything other than adding macros; there's no change of behaviour? Either you've missed something or your commit message needs to be fixed.
Also see below for a style comment.
Jess
Quoted 12 lines
Signed-off-by Vijai Kumar K <[email protected]>---
lib/utils/serial/shakti-uart.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)lib/utils/serial/shakti-uart.c +0
-0@@ -18,18 +18,21 @@#define REG_IQ_CYCLES 0x1C#define REG_RX_THRES 0x20
lib/utils/serial/shakti-uart.c line 28
Quoted 10 lines
lib/utils/serial/shakti-uart.c +4
-1+#define UART_TX_FULL 0x2 +#define UART_RX_FULL 0x8 +static volatile void *uart_base;void shakti_uart_putc (char ch) { -while ((readw (uart_base +REG_STATUS ) &0x2 ) ==0 ); +while ((readw (uart_base +REG_STATUS ) &UART_TX_FULL ));
You should have a space after the while. Also, the existing style is to put the semicolon on a new line so it's not accidentally overlooked.
Quoted 13 lines
lib/utils/serial/shakti-uart.c +1
-1writeb (ch, uart_base +REG_TX ); }int shakti_uart_getc (void ) {u16 status =readw (uart_base +REG_STATUS ); -if (status &0x8 ) +if (status &UART_RX_FULL )return readb (uart_base +REG_RX );return -1 ; }Signature · 1 line
2.25.1
PATCH 1/1 lib: utils: Fix shakti uart implementation
Hi Jessica,
Thank you for reviewing the code. Please see the inline responses.
---- On Mon, 07 Dec 2020 22:44:06 +0530 Jessica Clarke <[email protected]> wrote ----
Quoted 10 lines
Quoted 6 lines · Vijai Kumar K
Fix
uart_putcimplementation.
Due to a bug in the IP, this went unnoticed. Use macros instead of magic numbers to make the code more readable.Yeah, using macros is good, but this patch isn't doing anything other than adding macros; there's no change of behaviour? Either you've missed something or your commit message needs to be fixed.
If you see we are dropping the "==0" comparison. That UART_TX_FULL bit is set when TX is full. So that comparison is wrong and we are dropping it.
Quoted 23 lines
Also see below for a style comment.
Jess
Quoted 18 lines
Signed-off-by Vijai Kumar K <[email protected]>---
lib/utils/serial/shakti-uart.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)lib/utils/serial/shakti-uart.c +3
-0@@ -18,18 +18,21 @@#define REG_IQ_CYCLES 0x1C#define REG_RX_THRES 0x20 +#define UART_TX_FULL 0x2 +#define UART_RX_FULL 0x8 +static volatile void *uart_base;
Quoted 7 lines
lib/utils/serial/shakti-uart.c line 28
Quoted 4 lines
lib/utils/serial/shakti-uart.c +1
-1void shakti_uart_putc (char ch) { -while ((readw (uart_base +REG_STATUS ) &0x2 ) ==0 ); +while ((readw (uart_base +REG_STATUS ) &UART_TX_FULL ));You should have a space after the while. Also, the existing style is to put the semicolon on a new line so it's not accidentally overlooked.
Got it. Will add the space. However, I don't see the style recommendation for putting the semicolon in a new line. Have I overlooked it, or is it just an undocumented practice or a personal taste?
Thanks
Vijai
Quoted 20 lines
Quoted 14 lines
lib/utils/serial/shakti-uart.c +1
-1writeb (ch, uart_base +REG_TX ); }int shakti_uart_getc (void ) {u16 status =readw (uart_base +REG_STATUS ); -if (status &0x8 ) +if (status &UART_RX_FULL )return readb (uart_base +REG_RX );return -1 ; }Signature · 1 line
2.25.1Signature · 3 lines
opensbi mailing list opensbi at lists.infradead.org http://lists.infradead.org/mailman/listinfo/opensbi
PATCH 1/1 lib: utils: Fix shakti uart implementation
Quoted 54 lines · Vijai Kumar K
Hi Jessica,
Thank you for reviewing the code. Please see the inline responses.
---- On Mon, 07 Dec 2020 22:44:06 +0530 Jessica Clarke <[email protected]> wrote ----
Quoted 10 lines
Quoted 6 lines · Vijai Kumar K
Fix
uart_putcimplementation.
Due to a bug in the IP, this went unnoticed. Use macros instead of magic numbers to make the code more readable.Yeah, using macros is good, but this patch isn't doing anything other than adding macros; there's no change of behaviour? Either you've missed something or your commit message needs to be fixed.
If you see we are dropping the "==0" comparison. That
UART_TX_FULLbit is set when TX is full. So that comparison is wrong and we are dropping it.Quoted 23 lines
Also see below for a style comment.
Jess
Quoted 18 lines
Signed-off-by Vijai Kumar K <[email protected]>---
lib/utils/serial/shakti-uart.c| 7 +++++--1 file changed, 5 insertions(+), 2 deletions(-)lib/utils/serial/shakti-uart.c +3
-0@@ -18,18 +18,21 @@#define REG_IQ_CYCLES 0x1C#define REG_RX_THRES 0x20 +#define UART_TX_FULL 0x2 +#define UART_RX_FULL 0x8 +static volatile void *uart_base;Quoted 7 lines
lib/utils/serial/shakti-uart.c line 28
Quoted 4 lines
lib/utils/serial/shakti-uart.c +1
-1void shakti_uart_putc (char ch) { -while ((readw (uart_base +REG_STATUS ) &0x2 ) ==0 ); +while ((readw (uart_base +REG_STATUS ) &UART_TX_FULL ));You should have a space after the while. Also, the existing style is to put the semicolon on a new line so it's not accidentally overlooked.
Quoted 3 lines
Got it. Will add the space. However, I don't see the style recommendation for putting the semicolon in a new line. Have I overlooked it, or is it just an undocumented practice or a personal taste?
Yes, style documentation is not available yet.
We are largely following Linux and U-Boot coding style.
I will wait for your revised patch.
Regards,
Anup
Anup Patel
AppliedPATCH 1/1 lib: utils: Fix shakti uart implementation
In reply to Vijai Kumar KQuoted 52 lines
-----Original Message-----
From: opensbi <[email protected]> On Behalf Of Vijai Kumar K
Sent: 07 December 2020 22:24
To: opensbi at lists.infradead.org
Cc: Vijai Kumar K <[email protected]>
Subject: [PATCH] lib: utils: Fix shakti uart implementationFix
uart_putcimplementation.
Due to a bug in the IP, this went unnoticed.
Use macros instead of magic numbers to make the code more readable.Signed-off-by Vijai Kumar K <[email protected]>--- lib/utils/serial/shakti-uart.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)lib/utils/serial/shakti-uart.c index renamed from lib/utils/serial/shakti-uart.c +0
-0493edcf..b2deb70 100644
lib/utils/serial/shakti-uart.c +5
-3@@ -18,18 +18,21 @@#define REG_IQ_CYCLES 0x1C#define REG_RX_THRES 0x20 +#define UART_TX_FULL 0x2 +#define UART_RX_FULL 0x8 +static volatile void *uart_base;void shakti_uart_putc (char ch) { -while ((readw (uart_base +REG_STATUS ) &0x2 ) ==0 ); +while ((readw (uart_base +REG_STATUS ) &UART_TX_FULL ));writeb (ch, uart_base +REG_TX ); }int shakti_uart_getc (void ) {u16 status =readw (uart_base +REG_STATUS ); -if (status &0x8 ) +if (status &UART_RX_FULL )return readb (uart_base +REG_RX );return -1 ; } --2.25.1
Quoted 4 lines
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
I have taken care of style comment from Jessica at time of applying this patch.
Applied this patch to riscv/opensbi repo.
Thanks,
Anup
PATCH 1/1 lib: utils: Fix shakti uart implementation
---- On Thu, 07 Jan 2021 10:27:17 +0530 Anup Patel <[email protected]> wrote ----
Quoted 59 lines
Quoted 56 lines
-----Original Message-----
From: opensbi <[email protected]> On Behalf Of Vijai Kumar K
Sent: 07 December 2020 22:24
To: opensbi at lists.infradead.org
Cc: Vijai Kumar K <[email protected]>
Subject: [PATCH] lib: utils: Fix shakti uart implementationFix
uart_putcimplementation.
Due to a bug in the IP, this went unnoticed.
Use macros instead of magic numbers to make the code more readable.Signed-off-by Vijai Kumar K <[email protected]>---
lib/utils/serial/shakti-uart.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)lib/utils/serial/shakti-uart.c index renamed from lib/utils/serial/shakti-uart.c +0
-0493edcf..b2deb70 100644
lib/utils/serial/shakti-uart.c +5
-2@@ -18,18 +18,21 @@#define REG_IQ_CYCLES 0x1C#define REG_RX_THRES 0x20 +#define UART_TX_FULL 0x2 +#define UART_RX_FULL 0x8 +static volatile void *uart_base;void shakti_uart_putc (char ch) { -while ((readw (uart_base +REG_STATUS ) &0x2 ) ==0 ); +while ((readw (uart_base +REG_STATUS ) &UART_TX_FULL ));writeb (ch, uart_base +REG_TX ); }int shakti_uart_getc (void ) {u16 status =readw (uart_base +REG_STATUS ); -if (status &0x8 ) +if (status &UART_RX_FULL )return readb (uart_base +REG_RX );return -1 ; }Signature · 8 lines
2.25.1 -- opensbi mailing list opensbi at lists.infradead.org http://lists.infradead.org/mailman/listinfo/opensbiReviewed-by Anup Patel <[email protected]>
Quoted 7 lines
I have taken care of style comment from Jessica at time of applying this patch.
Applied this patch to riscv/opensbi repo.
Thanks,
Anup
Thanks a lot Anup. Sorry for replying late on this. I was on vacation at that time and somehow missed following up on this.
Best,
Vijai
Quoted 6 lines
Signature · 4 lines
-- opensbi mailing list opensbi at lists.infradead.org http://lists.infradead.org/mailman/listinfo/opensbi