mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH next] drm/sharp-memory: Fix some checks in sharp_memory_probe()
@ 2024-10-23  8:30 Dan Carpenter
  2024-10-23 13:49 ` Alex Lanzano
  2024-10-24 21:08 ` Uwe Kleine-König
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-10-23  8:30 UTC (permalink / raw)
  To: Alex Lanzano
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, Dmitry Baryshkov, Mehdi Djait,
	Uwe Kleine-König, dri-devel, linux-kernel, kernel-janitors

The devm_drm_dev_alloc() function returns error pointers, it never
returns NULL.  Change that check to IS_ERR().

The devm_gpiod_get_optional() function returns a mix of error pointers
if there is an error, or NULL if there is no GPIO assigned.  Add a check
for error pointers.

Fixes: b8f9f21716fe ("drm/tiny: Add driver for Sharp Memory LCD")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/gpu/drm/tiny/sharp-memory.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tiny/sharp-memory.c b/drivers/gpu/drm/tiny/sharp-memory.c
index 2d2315bd6aef..1bcdd79166a4 100644
--- a/drivers/gpu/drm/tiny/sharp-memory.c
+++ b/drivers/gpu/drm/tiny/sharp-memory.c
@@ -543,8 +543,8 @@ static int sharp_memory_probe(struct spi_device *spi)
 
 	smd = devm_drm_dev_alloc(dev, &sharp_memory_drm_driver,
 				 struct sharp_memory_device, drm);
-	if (!smd)
-		return -ENOMEM;
+	if (IS_ERR(smd))
+		return PTR_ERR(smd);
 
 	spi_set_drvdata(spi, smd);
 
@@ -555,6 +555,8 @@ static int sharp_memory_probe(struct spi_device *spi)
 		return dev_err_probe(dev, ret, "Failed to initialize drm config\n");
 
 	smd->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH);
+	if (IS_ERR(smd->enable_gpio))
+		return PTR_ERR(smd->enable_gpio);
 	if (!smd->enable_gpio)
 		dev_warn(dev, "Enable gpio not defined\n");
 
-- 
2.45.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH next] drm/sharp-memory: Fix some checks in sharp_memory_probe()
  2024-10-23  8:30 [PATCH next] drm/sharp-memory: Fix some checks in sharp_memory_probe() Dan Carpenter
@ 2024-10-23 13:49 ` Alex Lanzano
  2024-10-24 21:08 ` Uwe Kleine-König
  1 sibling, 0 replies; 4+ messages in thread
From: Alex Lanzano @ 2024-10-23 13:49 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, Dmitry Baryshkov, Mehdi Djait,
	Uwe Kleine-König, dri-devel, linux-kernel, kernel-janitors

On Wed, Oct 23, 2024 at 11:30:31AM +0300, Dan Carpenter wrote:
> The devm_drm_dev_alloc() function returns error pointers, it never
> returns NULL.  Change that check to IS_ERR().
> 
> The devm_gpiod_get_optional() function returns a mix of error pointers
> if there is an error, or NULL if there is no GPIO assigned.  Add a check
> for error pointers.
> 
> Fixes: b8f9f21716fe ("drm/tiny: Add driver for Sharp Memory LCD")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/gpu/drm/tiny/sharp-memory.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tiny/sharp-memory.c b/drivers/gpu/drm/tiny/sharp-memory.c
> index 2d2315bd6aef..1bcdd79166a4 100644
> --- a/drivers/gpu/drm/tiny/sharp-memory.c
> +++ b/drivers/gpu/drm/tiny/sharp-memory.c
> @@ -543,8 +543,8 @@ static int sharp_memory_probe(struct spi_device *spi)
>  
>  	smd = devm_drm_dev_alloc(dev, &sharp_memory_drm_driver,
>  				 struct sharp_memory_device, drm);
> -	if (!smd)
> -		return -ENOMEM;
> +	if (IS_ERR(smd))
> +		return PTR_ERR(smd);
>  
>  	spi_set_drvdata(spi, smd);
>  
> @@ -555,6 +555,8 @@ static int sharp_memory_probe(struct spi_device *spi)
>  		return dev_err_probe(dev, ret, "Failed to initialize drm config\n");
>  
>  	smd->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH);
> +	if (IS_ERR(smd->enable_gpio))
> +		return PTR_ERR(smd->enable_gpio);
>  	if (!smd->enable_gpio)
>  		dev_warn(dev, "Enable gpio not defined\n");
>  
> -- 
> 2.45.2
> 

Reviewed-by: Alex Lanzano <lanzano.alex@gmail.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH next] drm/sharp-memory: Fix some checks in sharp_memory_probe()
  2024-10-23  8:30 [PATCH next] drm/sharp-memory: Fix some checks in sharp_memory_probe() Dan Carpenter
  2024-10-23 13:49 ` Alex Lanzano
@ 2024-10-24 21:08 ` Uwe Kleine-König
  2024-10-25  7:30   ` Dan Carpenter
  1 sibling, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2024-10-24 21:08 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Alex Lanzano, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Dmitry Baryshkov,
	Mehdi Djait, dri-devel, linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 1603 bytes --]

On Wed, Oct 23, 2024 at 11:30:31AM +0300, Dan Carpenter wrote:
> The devm_drm_dev_alloc() function returns error pointers, it never
> returns NULL.  Change that check to IS_ERR().
> 
> The devm_gpiod_get_optional() function returns a mix of error pointers
> if there is an error, or NULL if there is no GPIO assigned.  Add a check
> for error pointers.
> 
> Fixes: b8f9f21716fe ("drm/tiny: Add driver for Sharp Memory LCD")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/gpu/drm/tiny/sharp-memory.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tiny/sharp-memory.c b/drivers/gpu/drm/tiny/sharp-memory.c
> index 2d2315bd6aef..1bcdd79166a4 100644
> --- a/drivers/gpu/drm/tiny/sharp-memory.c
> +++ b/drivers/gpu/drm/tiny/sharp-memory.c
> @@ -543,8 +543,8 @@ static int sharp_memory_probe(struct spi_device *spi)
>  
>  	smd = devm_drm_dev_alloc(dev, &sharp_memory_drm_driver,
>  				 struct sharp_memory_device, drm);
> -	if (!smd)
> -		return -ENOMEM;
> +	if (IS_ERR(smd))
> +		return PTR_ERR(smd);
>  
>  	spi_set_drvdata(spi, smd);
>  
> @@ -555,6 +555,8 @@ static int sharp_memory_probe(struct spi_device *spi)
>  		return dev_err_probe(dev, ret, "Failed to initialize drm config\n");
>  
>  	smd->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH);
> +	if (IS_ERR(smd->enable_gpio))
> +		return PTR_ERR(smd->enable_gpio);
>  	if (!smd->enable_gpio)
>  		dev_warn(dev, "Enable gpio not defined\n");

Use dev_err_probe() instead of plain returns?

Best regards
Uwe

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH next] drm/sharp-memory: Fix some checks in sharp_memory_probe()
  2024-10-24 21:08 ` Uwe Kleine-König
@ 2024-10-25  7:30   ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2024-10-25  7:30 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Alex Lanzano, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter, Dmitry Baryshkov,
	Mehdi Djait, dri-devel, linux-kernel, kernel-janitors

On Thu, Oct 24, 2024 at 11:08:05PM +0200, Uwe Kleine-König wrote:
> On Wed, Oct 23, 2024 at 11:30:31AM +0300, Dan Carpenter wrote:
> > The devm_drm_dev_alloc() function returns error pointers, it never
> > returns NULL.  Change that check to IS_ERR().
> > 
> > The devm_gpiod_get_optional() function returns a mix of error pointers
> > if there is an error, or NULL if there is no GPIO assigned.  Add a check
> > for error pointers.
> > 
> > Fixes: b8f9f21716fe ("drm/tiny: Add driver for Sharp Memory LCD")
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> >  drivers/gpu/drm/tiny/sharp-memory.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/tiny/sharp-memory.c b/drivers/gpu/drm/tiny/sharp-memory.c
> > index 2d2315bd6aef..1bcdd79166a4 100644
> > --- a/drivers/gpu/drm/tiny/sharp-memory.c
> > +++ b/drivers/gpu/drm/tiny/sharp-memory.c
> > @@ -543,8 +543,8 @@ static int sharp_memory_probe(struct spi_device *spi)
> >  
> >  	smd = devm_drm_dev_alloc(dev, &sharp_memory_drm_driver,
> >  				 struct sharp_memory_device, drm);
> > -	if (!smd)
> > -		return -ENOMEM;
> > +	if (IS_ERR(smd))
> > +		return PTR_ERR(smd);
> >  
> >  	spi_set_drvdata(spi, smd);
> >  
> > @@ -555,6 +555,8 @@ static int sharp_memory_probe(struct spi_device *spi)
> >  		return dev_err_probe(dev, ret, "Failed to initialize drm config\n");
> >  
> >  	smd->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH);
> > +	if (IS_ERR(smd->enable_gpio))
> > +		return PTR_ERR(smd->enable_gpio);
> >  	if (!smd->enable_gpio)
> >  		dev_warn(dev, "Enable gpio not defined\n");
> 
> Use dev_err_probe() instead of plain returns?
> 

Sure.  Let me resend.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-25  7:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-23  8:30 [PATCH next] drm/sharp-memory: Fix some checks in sharp_memory_probe() Dan Carpenter
2024-10-23 13:49 ` Alex Lanzano
2024-10-24 21:08 ` Uwe Kleine-König
2024-10-25  7:30   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®