serial: pl01x: Add error value checking
PATCH 1/1 serial: pl01x: Add error value checking
There also a need to check return values to make sure that clocks were enabled and setup properly.
---
drivers/serial/serial_pl01x.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/serial/serial_pl01x.c +11 -1
@@ -362,8 +362,18 @@ int pl01x_serial_ofdata_to_platdata(struct udevice *dev) plat->clock =dev_read_u32_default (dev,"clock" ,CONFIG_PL011_CLOCK ); ret =clk_get_by_index (dev,0 , &clk);if (!ret) { -clk_enable (&clk); + ret =clk_enable (&clk); +if (ret && ret != -ENOSYS ) { +dev_err (dev,"failed to enable clock\n" ); +return ret; + } + plat->clock =clk_get_rate (&clk); +if (IS_ERR_VALUE (plat->clock)) { +dev_err (dev,"failed to get rate\n" ); +return plat->clock; + } +debug ("%s: CLK %d\n" , __func__, plat->clock); } plat->type =dev_get_driver_data (dev); plat->skip_init =dev_read_bool (dev,"skip-init" );
Signature · 1 line
2.28.0
PATCH 1/1 serial: pl01x: Add error value checking
Quoted 9 lines · Michal Simek
There also a need to check return values to make sure that clocks were enabled and setup properly.
Signed-off-by Michal Simek <[email protected]>---
drivers/serial/serial_pl01x.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
PATCH 1/1 serial: pl01x: Add error value checking
In reply to Michal SimekOn 14/10/2020 09:42, Michal Simek wrote:
Hi,
Quoted 2 lines
There also a need to check return values to make sure that clocks were enabled and setup properly.
is that just clean-up or is there a particular problem that's fixed?
I am asking because I am not sure how useful debug output in a console driver is.
Also in some cases the UART is actually already configured, so failure to get the clock (due to a sloppy/too complicated DTB) is not really fatal at the moment.
I am not against this patch, just wanted to make sure we don't break anything.
Cheers,
Andre
Quoted 32 lines
Signed-off-by Michal Simek <[email protected]>---
drivers/serial/serial_pl01x.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)drivers/serial/serial_pl01x.c +11
-1@@ -362,8 +362,18 @@ int pl01x_serial_ofdata_to_platdata(struct udevice *dev) plat->clock =dev_read_u32_default (dev,"clock" ,CONFIG_PL011_CLOCK ); ret =clk_get_by_index (dev,0 , &clk);if (!ret) { -clk_enable (&clk); + ret =clk_enable (&clk); +if (ret && ret != -ENOSYS ) { +dev_err (dev,"failed to enable clock\n" ); +return ret; + } + plat->clock =clk_get_rate (&clk); +if (IS_ERR_VALUE (plat->clock)) { +dev_err (dev,"failed to get rate\n" ); +return plat->clock; + } +debug ("%s: CLK %d\n" , __func__, plat->clock); } plat->type =dev_get_driver_data (dev); plat->skip_init =dev_read_bool (dev,"skip-init" );
PATCH 1/1 serial: pl01x: Add error value checking
Hi,
Quoted 9 lines · Andr? Przywara
On 14/10/2020 09:42, Michal Simek wrote:
Hi,
Quoted 2 lines
There also a need to check return values to make sure that clocks were enabled and setup properly.
is that just clean-up or is there a particular problem that's fixed?
Quoted 8 lines
I am asking because I am not sure how useful debug output in a console driver is.
Also in some cases the UART is actually already configured, so failure to get the clock (due to a sloppy/too complicated DTB) is not really fatal at the moment.I am not against this patch, just wanted to make sure we don't break anything.
We have created the patch long time ago and it was also sent to mailing list in October 2018.
More or less the most of the part of it where already added by different people. The only missing part was checking error values. There are 2 reasons behind this patch.
1. it is good practice to check all return values - and coverity also reports it.
2. at this time clock driver is up and running and if not you will get errors. In our case we are asking firmware for doing that action/returning value which needs to be catch.
And early console can be configured properly when DEBUG console is used that's why debug message will be shown over this interface and it makes sense to show message about it. And if you don't failed you can break regular console by configuring by incorrect values.
Thanks,
Michal