diff mbox series

[V2] serial: tegra: Only print FIFO error message when an error occurs

Message ID 20210630125643.264264-1-jonathanh@nvidia.com
State Superseded
Headers show
Series [V2] serial: tegra: Only print FIFO error message when an error occurs | expand

Commit Message

Jon Hunter June 30, 2021, 12:56 p.m. UTC
The Tegra serial driver always prints an error message when enabling the
FIFO for devices that have support for checking the FIFO enable status.
Fix this by displaying the error message, only when an error occurs.

Finally, update the error message to make it clear that enabling the
FIFO failed and display the error code.

Fixes: 222dcdff3405 ("serial: tegra: check for FIFO mode enabled status")
Cc: <stable@vger.kernel.org>
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
---
Changes since V1:
- Updated the error message to make it more meaningful.

drivers/tty/serial/serial-tegra.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Thierry Reding June 30, 2021, 5:25 p.m. UTC | #1
On Wed, Jun 30, 2021 at 01:56:43PM +0100, Jon Hunter wrote:
> The Tegra serial driver always prints an error message when enabling the
> FIFO for devices that have support for checking the FIFO enable status.
> Fix this by displaying the error message, only when an error occurs.
> 
> Finally, update the error message to make it clear that enabling the
> FIFO failed and display the error code.
> 
> Fixes: 222dcdff3405 ("serial: tegra: check for FIFO mode enabled status")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
> ---
> Changes since V1:
> - Updated the error message to make it more meaningful.
> 
> drivers/tty/serial/serial-tegra.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Looks good:

Acked-by: Thierry Reding <treding@nvidia.com>
Michał Mirosław July 8, 2021, 10:25 p.m. UTC | #2
On Wed, Jun 30, 2021 at 01:56:43PM +0100, Jon Hunter wrote:
> The Tegra serial driver always prints an error message when enabling the
> FIFO for devices that have support for checking the FIFO enable status.
> Fix this by displaying the error message, only when an error occurs.
> 
> Finally, update the error message to make it clear that enabling the
> FIFO failed and display the error code.
[...]
> @@ -1045,9 +1045,11 @@ static int tegra_uart_hw_init(struct tegra_uart_port *tup)
>  
>  	if (tup->cdata->fifo_mode_enable_status) {
>  		ret = tegra_uart_wait_fifo_mode_enabled(tup);
> -		dev_err(tup->uport.dev, "FIFO mode not enabled\n");
> -		if (ret < 0)
> +		if (ret < 0) {
> +			dev_err(tup->uport.dev,
> +				"Failed to enable FIFO mode: %d\n", ret);

Could you change this to use %pe and ERR_PTR(ret)?

Best Regards
Michał Mirosław
Michał Mirosław July 9, 2021, 5:55 p.m. UTC | #3
On Fri, Jul 09, 2021 at 12:38:07PM +0100, Jon Hunter wrote:
> 

> On 09/07/2021 09:34, Jon Hunter wrote:

> > 

> > 

> > On 08/07/2021 23:25, Michał Mirosław wrote:

> >> On Wed, Jun 30, 2021 at 01:56:43PM +0100, Jon Hunter wrote:

> >>> The Tegra serial driver always prints an error message when enabling the

> >>> FIFO for devices that have support for checking the FIFO enable status.

> >>> Fix this by displaying the error message, only when an error occurs.

> >>>

> >>> Finally, update the error message to make it clear that enabling the

> >>> FIFO failed and display the error code.

> >> [...]

> >>> @@ -1045,9 +1045,11 @@ static int tegra_uart_hw_init(struct tegra_uart_port *tup)

> >>>  

> >>>  	if (tup->cdata->fifo_mode_enable_status) {

> >>>  		ret = tegra_uart_wait_fifo_mode_enabled(tup);

> >>> -		dev_err(tup->uport.dev, "FIFO mode not enabled\n");

> >>> -		if (ret < 0)

> >>> +		if (ret < 0) {

> >>> +			dev_err(tup->uport.dev,

> >>> +				"Failed to enable FIFO mode: %d\n", ret);

> >>

> >> Could you change this to use %pe and ERR_PTR(ret)?

> > 

> > Sorry, but it is not clear to me why this would be necessary in this case.

> 

> I see so '%pe' prints the symbolic name of the error code. While that is

> nice, it also looks a bit odd. Given that we simply print the error code

> values in this driver, from looking at other prints, I prefer to keep it

> as is for consistency.


It is a quite new facility of printk(), so I woudn't expect it to be
present in older code. It saves a bit of time when you occasionally
hit an error, so even incremental conversion seems beneficial for me.

Best Regards
Michał Mirosław
diff mbox series

Patch

diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c
index 222032792d6c..eba5b9ecba34 100644
--- a/drivers/tty/serial/serial-tegra.c
+++ b/drivers/tty/serial/serial-tegra.c
@@ -1045,9 +1045,11 @@  static int tegra_uart_hw_init(struct tegra_uart_port *tup)
 
 	if (tup->cdata->fifo_mode_enable_status) {
 		ret = tegra_uart_wait_fifo_mode_enabled(tup);
-		dev_err(tup->uport.dev, "FIFO mode not enabled\n");
-		if (ret < 0)
+		if (ret < 0) {
+			dev_err(tup->uport.dev,
+				"Failed to enable FIFO mode: %d\n", ret);
 			return ret;
+		}
 	} else {
 		/*
 		 * For all tegra devices (up to t210), there is a hardware