[PATCH 06/15] serial: sc16is7xx: use dev_err_probe() instead of dev_err()

Hugo Villeneuve posted 15 patches 2 months, 3 weeks ago
There is a newer version of this series
[PATCH 06/15] serial: sc16is7xx: use dev_err_probe() instead of dev_err()
Posted by Hugo Villeneuve 2 months, 3 weeks ago
From: Hugo Villeneuve <hvilleneuve@dimonoff.com>

This simplifies code and standardizes the error output.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
---
 drivers/tty/serial/sc16is7xx.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
index 7af09535a1563..4384804a4e228 100644
--- a/drivers/tty/serial/sc16is7xx.c
+++ b/drivers/tty/serial/sc16is7xx.c
@@ -1528,10 +1528,9 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype,
 
 	/* Alloc port structure */
 	s = devm_kzalloc(dev, struct_size(s, p, devtype->nr_uart), GFP_KERNEL);
-	if (!s) {
-		dev_err(dev, "Error allocating port structure\n");
-		return -ENOMEM;
-	}
+	if (!s)
+		return dev_err_probe(dev, -ENOMEM,
+				     "Error allocating port structure\n");
 
 	/* Always ask for fixed clock rate from a property. */
 	device_property_read_u32(dev, "clock-frequency", &uartclk);
-- 
2.39.5
Re: [PATCH 06/15] serial: sc16is7xx: use dev_err_probe() instead of dev_err()
Posted by Jiri Slaby 2 months, 2 weeks ago
On 24. 09. 25, 17:37, Hugo Villeneuve wrote:
> From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> 
> This simplifies code and standardizes the error output.
> 
> Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> ---
>   drivers/tty/serial/sc16is7xx.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
> index 7af09535a1563..4384804a4e228 100644
> --- a/drivers/tty/serial/sc16is7xx.c
> +++ b/drivers/tty/serial/sc16is7xx.c
> @@ -1528,10 +1528,9 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype,
>   
>   	/* Alloc port structure */
>   	s = devm_kzalloc(dev, struct_size(s, p, devtype->nr_uart), GFP_KERNEL);
> -	if (!s) {
> -		dev_err(dev, "Error allocating port structure\n");
> -		return -ENOMEM;
> -	}
> +	if (!s)
> +		return dev_err_probe(dev, -ENOMEM,
> +				     "Error allocating port structure\n");

This does not work as you'd expect:
         case -ENOMEM:
                 /* Don't print anything on -ENOMEM, there's already 
enough output */
                 break;

thanks,
-- 
js
suse labs
Re: [PATCH 06/15] serial: sc16is7xx: use dev_err_probe() instead of dev_err()
Posted by Hugo Villeneuve 2 months, 2 weeks ago
Hi Jiri,

On Mon, 29 Sep 2025 08:10:17 +0200
Jiri Slaby <jirislaby@kernel.org> wrote:

> On 24. 09. 25, 17:37, Hugo Villeneuve wrote:
> > From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> > 
> > This simplifies code and standardizes the error output.
> > 
> > Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> > ---
> >   drivers/tty/serial/sc16is7xx.c | 7 +++----
> >   1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/sc16is7xx.c b/drivers/tty/serial/sc16is7xx.c
> > index 7af09535a1563..4384804a4e228 100644
> > --- a/drivers/tty/serial/sc16is7xx.c
> > +++ b/drivers/tty/serial/sc16is7xx.c
> > @@ -1528,10 +1528,9 @@ int sc16is7xx_probe(struct device *dev, const struct sc16is7xx_devtype *devtype,
> >   
> >   	/* Alloc port structure */
> >   	s = devm_kzalloc(dev, struct_size(s, p, devtype->nr_uart), GFP_KERNEL);
> > -	if (!s) {
> > -		dev_err(dev, "Error allocating port structure\n");
> > -		return -ENOMEM;
> > -	}
> > +	if (!s)
> > +		return dev_err_probe(dev, -ENOMEM,
> > +				     "Error allocating port structure\n");
> 
> This does not work as you'd expect:
>          case -ENOMEM:
>                  /* Don't print anything on -ENOMEM, there's already 
> enough output */
>                  break;

Ok, I will simply remove the original dev_err() call.

Hugo.