All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] omapdrm: no need to check return value of debugfs_create functions
@ 2019-06-13 11:57 Greg Kroah-Hartman
  2019-08-08 12:50 ` Laurent Pinchart
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-06-13 11:57 UTC (permalink / raw)
  To: Tomi Valkeinen, David Airlie, Daniel Vetter, Laurent Pinchart,
	Sebastian Reichel, Jyri Sarha, Tony Lindgren, zhong jiang
  Cc: dri-devel

When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
Cc: Jyri Sarha <jsarha@ti.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: zhong jiang <zhongjiang@huawei.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/gpu/drm/omapdrm/dss/dss.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
index 55e68863ef15..83b973813394 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss.c
@@ -934,7 +934,6 @@ dss_debugfs_create_file(struct dss_device *dss, const char *name,
 			void *data)
 {
 	struct dss_debugfs_entry *entry;
-	struct dentry *d;
 
 	entry = kzalloc(sizeof(*entry), GFP_KERNEL);
 	if (!entry)
@@ -942,15 +941,9 @@ dss_debugfs_create_file(struct dss_device *dss, const char *name,
 
 	entry->show_fn = show_fn;
 	entry->data = data;
+	entry->dentry = debugfs_create_file(name, 0444, dss->debugfs.root,
+					    entry, &dss_debug_fops);
 
-	d = debugfs_create_file(name, 0444, dss->debugfs.root, entry,
-				&dss_debug_fops);
-	if (IS_ERR(d)) {
-		kfree(entry);
-		return ERR_CAST(d);
-	}
-
-	entry->dentry = d;
 	return entry;
 }
 
-- 
2.22.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] omapdrm: no need to check return value of debugfs_create functions
  2019-06-13 11:57 [PATCH] omapdrm: no need to check return value of debugfs_create functions Greg Kroah-Hartman
@ 2019-08-08 12:50 ` Laurent Pinchart
  2019-08-09  6:59   ` Tomi Valkeinen
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Pinchart @ 2019-08-08 12:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: David Airlie, Sebastian Reichel, Jyri Sarha, Tony Lindgren,
	Tomi Valkeinen, dri-devel, zhong jiang

Hi Greg,

Thank you for the patch.

On Thu, Jun 13, 2019 at 01:57:49PM +0200, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.
> 
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Cc: David Airlie <airlied@linux.ie>
> Cc: Daniel Vetter <daniel@ffwll.ch>
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
> Cc: Jyri Sarha <jsarha@ti.com>
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: zhong jiang <zhongjiang@huawei.com>
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

This makes sense.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Tomi, will you take this patch in your tree ?

> ---
>  drivers/gpu/drm/omapdrm/dss/dss.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss.c b/drivers/gpu/drm/omapdrm/dss/dss.c
> index 55e68863ef15..83b973813394 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss.c
> @@ -934,7 +934,6 @@ dss_debugfs_create_file(struct dss_device *dss, const char *name,
>  			void *data)
>  {
>  	struct dss_debugfs_entry *entry;
> -	struct dentry *d;
>  
>  	entry = kzalloc(sizeof(*entry), GFP_KERNEL);
>  	if (!entry)
> @@ -942,15 +941,9 @@ dss_debugfs_create_file(struct dss_device *dss, const char *name,
>  
>  	entry->show_fn = show_fn;
>  	entry->data = data;
> +	entry->dentry = debugfs_create_file(name, 0444, dss->debugfs.root,
> +					    entry, &dss_debug_fops);
>  
> -	d = debugfs_create_file(name, 0444, dss->debugfs.root, entry,
> -				&dss_debug_fops);
> -	if (IS_ERR(d)) {
> -		kfree(entry);
> -		return ERR_CAST(d);
> -	}
> -
> -	entry->dentry = d;
>  	return entry;
>  }
>  

-- 
Regards,

Laurent Pinchart
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] omapdrm: no need to check return value of debugfs_create functions
  2019-08-08 12:50 ` Laurent Pinchart
@ 2019-08-09  6:59   ` Tomi Valkeinen
  2019-08-09  7:47     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Tomi Valkeinen @ 2019-08-09  6:59 UTC (permalink / raw)
  To: Laurent Pinchart, Greg Kroah-Hartman
  Cc: David Airlie, Sebastian Reichel, Jyri Sarha, Tony Lindgren,
	dri-devel, zhong jiang

Hi,

On 08/08/2019 15:50, Laurent Pinchart wrote:
> Hi Greg,
> 
> Thank you for the patch.
> 
> On Thu, Jun 13, 2019 at 01:57:49PM +0200, Greg Kroah-Hartman wrote:
>> When calling debugfs functions, there is no need to ever check the
>> return value.  The function can work or not, but the code logic should
>> never do something different based on this.
>>
>> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
>> Cc: David Airlie <airlied@linux.ie>
>> Cc: Daniel Vetter <daniel@ffwll.ch>
>> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>> Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
>> Cc: Jyri Sarha <jsarha@ti.com>
>> Cc: Tony Lindgren <tony@atomide.com>
>> Cc: zhong jiang <zhongjiang@huawei.com>
>> Cc: dri-devel@lists.freedesktop.org
>> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> This makes sense.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> 
> Tomi, will you take this patch in your tree ?

Yes, I'll pick this up. I presume debugfs_create_file() will give a 
warning print if it fails to create the file, instead of being silent.

  Tomi

-- 
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] omapdrm: no need to check return value of debugfs_create functions
  2019-08-09  6:59   ` Tomi Valkeinen
@ 2019-08-09  7:47     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-08-09  7:47 UTC (permalink / raw)
  To: Tomi Valkeinen
  Cc: David Airlie, dri-devel, Sebastian Reichel, Jyri Sarha,
	Tony Lindgren, Laurent Pinchart, zhong jiang

On Fri, Aug 09, 2019 at 09:59:56AM +0300, Tomi Valkeinen wrote:
> Hi,
> 
> On 08/08/2019 15:50, Laurent Pinchart wrote:
> > Hi Greg,
> > 
> > Thank you for the patch.
> > 
> > On Thu, Jun 13, 2019 at 01:57:49PM +0200, Greg Kroah-Hartman wrote:
> > > When calling debugfs functions, there is no need to ever check the
> > > return value.  The function can work or not, but the code logic should
> > > never do something different based on this.
> > > 
> > > Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> > > Cc: David Airlie <airlied@linux.ie>
> > > Cc: Daniel Vetter <daniel@ffwll.ch>
> > > Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
> > > Cc: Jyri Sarha <jsarha@ti.com>
> > > Cc: Tony Lindgren <tony@atomide.com>
> > > Cc: zhong jiang <zhongjiang@huawei.com>
> > > Cc: dri-devel@lists.freedesktop.org
> > > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > 
> > This makes sense.
> > 
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > 
> > Tomi, will you take this patch in your tree ?
> 
> Yes, I'll pick this up. I presume debugfs_create_file() will give a warning
> print if it fails to create the file, instead of being silent.

Yes it does, please see 43e23b6c0b01 ("debugfs: log errors when
something goes wrong") and c33d442328f5 ("debugfs: make error message a
bit more verbose") for the details if you are curious.

Those warnings have already found at least one user of debugfs that was
doing things wrong and no one had noticed before.

thanks,

greg k-h
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2019-08-09  9:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-13 11:57 [PATCH] omapdrm: no need to check return value of debugfs_create functions Greg Kroah-Hartman
2019-08-08 12:50 ` Laurent Pinchart
2019-08-09  6:59   ` Tomi Valkeinen
2019-08-09  7:47     ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.