diff mbox series

[v1,2/2] serial: sh-sci: Switch to use dev_err_probe_ptr()

Message ID 20220214143248.502-2-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [v1,1/2] driver core: add a wrapper to device probe log helper to return pointer | expand

Commit Message

Andy Shevchenko Feb. 14, 2022, 2:32 p.m. UTC
Instead of
	return ERR_PTR(dev_err_probe(...));
call
	return dev_err_probe_ptr(...);

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/tty/serial/sh-sci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Andi Shyti June 11, 2023, 9:17 a.m. UTC | #1
Hi Andy,

On Mon, Feb 14, 2022 at 04:32:48PM +0200, Andy Shevchenko wrote:
> Instead of
> 	return ERR_PTR(dev_err_probe(...));
> call
> 	return dev_err_probe_ptr(...);
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/tty/serial/sh-sci.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
> index b610b27893a8..0fce09c13847 100644
> --- a/drivers/tty/serial/sh-sci.c
> +++ b/drivers/tty/serial/sh-sci.c
> @@ -3199,8 +3199,7 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev,
>  
>  	rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
>  	if (IS_ERR(rstc))
> -		return ERR_PTR(dev_err_probe(&pdev->dev, PTR_ERR(rstc),
> -					     "failed to get reset ctrl\n"));
> +		return dev_err_probe_ptr(&pdev->dev, PTR_ERR(rstc), "failed to get reset ctrl\n");

I think this is a great idea. Like Geert, however, I believe that
this could be more effective as a vararg function. Furthermore,
wouldn't it be easier if the PTR_ERR conversion was carried out
directly within dev_err_probe_ptr?

Wouldn't this approach be more compact and convenient?

	return dev_err_probe_ptr(&pdev->dev, rstc,
				 "failed to get reset ctrl\n");


Now, things start to get a bit more complicated as we will have
four different combinations of dev_err_probes. They could either
take a pointer with an error or an error integer, and they could
either return an error or a pointer with an error. All four cases
are utilized.

Please include me in your next batch of patches as I am also
working on something similar in the background.

Thanks,
Andi

>  
>  	ret = reset_control_deassert(rstc);
>  	if (ret) {
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index b610b27893a8..0fce09c13847 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -3199,8 +3199,7 @@  static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev,
 
 	rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL);
 	if (IS_ERR(rstc))
-		return ERR_PTR(dev_err_probe(&pdev->dev, PTR_ERR(rstc),
-					     "failed to get reset ctrl\n"));
+		return dev_err_probe_ptr(&pdev->dev, PTR_ERR(rstc), "failed to get reset ctrl\n");
 
 	ret = reset_control_deassert(rstc);
 	if (ret) {