Message ID | 20190613132850.GC4863@kroah.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | armada: no need to check return value of debugfs_create functions | expand |
On Thu, Jun 13, 2019 at 03:28:50PM +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. Please don't merge this patch - I have a change that conflicts with this which switches us over to using drm_debugfs_create_files(), thereby eliminating this code. > > Cc: Russell King <linux@armlinux.org.uk> > Cc: David Airlie <airlied@linux.ie> > Cc: Daniel Vetter <daniel@ffwll.ch> > Cc: dri-devel@lists.freedesktop.org > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > --- > drivers/gpu/drm/armada/armada_debugfs.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/armada/armada_debugfs.c b/drivers/gpu/drm/armada/armada_debugfs.c > index 6758c3a83de2..aec1e7372371 100644 > --- a/drivers/gpu/drm/armada/armada_debugfs.c > +++ b/drivers/gpu/drm/armada/armada_debugfs.c > @@ -109,7 +109,6 @@ static struct drm_info_list armada_debugfs_list[] = { > > int armada_drm_debugfs_init(struct drm_minor *minor) > { > - struct dentry *de; > int ret; > > ret = drm_debugfs_create_files(armada_debugfs_list, > @@ -118,15 +117,10 @@ int armada_drm_debugfs_init(struct drm_minor *minor) > if (ret) > return ret; > > - de = debugfs_create_file("reg", S_IFREG | S_IRUSR, > - minor->debugfs_root, minor->dev, &fops_reg_r); > - if (!de) > - return -ENOMEM; > - > - de = debugfs_create_file("reg_wr", S_IFREG | S_IWUSR, > - minor->debugfs_root, minor->dev, &fops_reg_w); > - if (!de) > - return -ENOMEM; > + debugfs_create_file("reg", S_IFREG | S_IRUSR, minor->debugfs_root, > + minor->dev, &fops_reg_r); > + debugfs_create_file("reg_wr", S_IFREG | S_IWUSR, minor->debugfs_root, > + minor->dev, &fops_reg_w); > > return 0; > } > -- > 2.22.0 > >
On Thu, Jun 13, 2019 at 03:36:00PM +0100, Russell King - ARM Linux admin wrote: > On Thu, Jun 13, 2019 at 03:28:50PM +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. > > Please don't merge this patch - I have a change that conflicts with this > which switches us over to using drm_debugfs_create_files(), thereby > eliminating this code. Isn't it "first received, first applied?" That's how it is for my subsystems... Anyway, I have a much larger patch for all users of drm_debugfs_create_files coming, but I'll wait for all of these tiny ones to land before sending that out :) thanks, greg k-h
On Thu, Jun 13, 2019 at 06:01:14PM +0200, Greg Kroah-Hartman wrote: > On Thu, Jun 13, 2019 at 03:36:00PM +0100, Russell King - ARM Linux admin wrote: > > On Thu, Jun 13, 2019 at 03:28:50PM +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. > > > > Please don't merge this patch - I have a change that conflicts with this > > which switches us over to using drm_debugfs_create_files(), thereby > > eliminating this code. > > Isn't it "first received, first applied?" That's how it is for my > subsystems... When I started working on the kernel in the 1990s, it was "the most technically correct approach of competing approaches". If we've now switched to "first received, first applied" that can only be harmful and demotivating to those who wish to do a good job. If someone has a better approach ready to go, why should the inferior approach be applied and then the better approach have to be rebased on top of the inferior approach? This makes no sense.
On Thu, Jun 13, 2019 at 05:15:59PM +0100, Russell King - ARM Linux admin wrote: > On Thu, Jun 13, 2019 at 06:01:14PM +0200, Greg Kroah-Hartman wrote: > > On Thu, Jun 13, 2019 at 03:36:00PM +0100, Russell King - ARM Linux admin wrote: > > > On Thu, Jun 13, 2019 at 03:28:50PM +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. > > > > > > Please don't merge this patch - I have a change that conflicts with this > > > which switches us over to using drm_debugfs_create_files(), thereby > > > eliminating this code. > > > > Isn't it "first received, first applied?" That's how it is for my > > subsystems... > > When I started working on the kernel in the 1990s, it was "the most > technically correct approach of competing approaches". If we've > now switched to "first received, first applied" that can only be > harmful and demotivating to those who wish to do a good job. > > If someone has a better approach ready to go, why should the > inferior approach be applied and then the better approach have to > be rebased on top of the inferior approach? This makes no sense. If you have a better approach ready to go, please post it and I will be glad to rebase my patch on top of yours. greg k-h
diff --git a/drivers/gpu/drm/armada/armada_debugfs.c b/drivers/gpu/drm/armada/armada_debugfs.c index 6758c3a83de2..aec1e7372371 100644 --- a/drivers/gpu/drm/armada/armada_debugfs.c +++ b/drivers/gpu/drm/armada/armada_debugfs.c @@ -109,7 +109,6 @@ static struct drm_info_list armada_debugfs_list[] = { int armada_drm_debugfs_init(struct drm_minor *minor) { - struct dentry *de; int ret; ret = drm_debugfs_create_files(armada_debugfs_list, @@ -118,15 +117,10 @@ int armada_drm_debugfs_init(struct drm_minor *minor) if (ret) return ret; - de = debugfs_create_file("reg", S_IFREG | S_IRUSR, - minor->debugfs_root, minor->dev, &fops_reg_r); - if (!de) - return -ENOMEM; - - de = debugfs_create_file("reg_wr", S_IFREG | S_IWUSR, - minor->debugfs_root, minor->dev, &fops_reg_w); - if (!de) - return -ENOMEM; + debugfs_create_file("reg", S_IFREG | S_IRUSR, minor->debugfs_root, + minor->dev, &fops_reg_r); + debugfs_create_file("reg_wr", S_IFREG | S_IWUSR, minor->debugfs_root, + minor->dev, &fops_reg_w); return 0; }
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: Russell King <linux@armlinux.org.uk> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: dri-devel@lists.freedesktop.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/gpu/drm/armada/armada_debugfs.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)