All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Joe Perches <joe@perches.com>
Cc: linux-fbdev@vger.kernel.org, David Airlie <airlied@linux.ie>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	alsa-devel@alsa-project.org, dri-devel@lists.freedesktop.org,
	Jaroslav Kysela <perex@perex.cz>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	linux-s390@vger.kernel.org, linux-omap@vger.kernel.org,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	linux-scsi@vger.kernel.org, Takashi Iwai <tiwai@suse.com>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>,
	James Smart <james.smart@broadcom.com>,
	Cezary Jackiewicz <cezary.jackiewicz@gmail.com>,
	linux-serial@vger.kernel.org, Jiri Slaby <jslaby@suse.com>,
	Darren Hart <dvhart@infradead.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Dick Kennedy <dick.kennedy@broadcom.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Peter Oberparleiter <oberpar@linux.vnet.ibm.com>,
	intel-gfx@lists.freedesktop
Subject: Re: [-next PATCH 2/4] treewide: Use DEVICE_ATTR_RW
Date: Wed, 20 Dec 2017 10:59:26 +0100	[thread overview]
Message-ID: <20171220095926.GA24285@kroah.com> (raw)
In-Reply-To: <1513763681.1234.101.camel@perches.com>

On Wed, Dec 20, 2017 at 01:54:41AM -0800, Joe Perches wrote:
> On Wed, 2017-12-20 at 10:32 +0100, Greg Kroah-Hartman wrote:
> > On Wed, Dec 20, 2017 at 01:24:44AM -0800, Joe Perches wrote:
> > > On Wed, 2017-12-20 at 10:34 +0200, Jarkko Nikula wrote:
> > > > On Tue, Dec 19, 2017 at 10:15:07AM -0800, Joe Perches wrote:
> > > > > Convert DEVICE_ATTR uses to DEVICE_ATTR_RW where possible.
> > > 
> > > [] 
> > > > > diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
> > > 
> > > []
> > > > > @@ -854,7 +854,7 @@ static ssize_t dma_op_mode_store(struct device *dev,
> > > > >  	return size;
> > > > >  }
> > > > >  
> > > > > -static DEVICE_ATTR(dma_op_mode, 0644, dma_op_mode_show, dma_op_mode_store);
> > > > > +static DEVICE_ATTR_RW(dma_op_mode);
> > > > >  
> > > > 
> > > > While I can ack this part here if it helps generic cleanup effort I
> > > > don't understart would it improve code readability in general? Mode 644
> > > > is clear and don't need any grepping but for DEVICE_ATTR_RW() I had to go
> > > > through all of these files in order to see what does it mean:
> > 
> > Yeah, 644 is "clear", but _RW() is even more clear.  Ideally I want to
> > get rid of all of the "non-standard" users that set random modes of
> > sysfs files, as we get it wrong too many times.  Using the "defaults" is
> > much better.
> > 
> > > Are you suggesting that device.h (as that is where
> > > DEVICE_ATTR and the other DEVICE_ATTR_<FOO> variants
> > > are #defined) should have better comments for the
> > > _<FOO> variants?
> > > 
> > > > DEVICE_ATTR_RW: include/linux/device.h
> > > > __ATTR_RW: include/linux/sysfs.h
> > > > S_IWUSR: include/uapi/linux/stat.h
> > > > S_IRUGO: include/linux/stat.h
> > > 
> > > btw: patch 1/4 of the series does remove the uses of
> > > S_<PERMS> from these macros in sysfs.h and converts
> > > them to simple octal instead.
> > 
> > Why you didn't send that patch to the sysfs maintainer is a bit odd...  :)
> 
> So here's an opportunity for you:
> 
> The sysfs maintainer hasn't added include/linux/sysfs.h to
> the list of maintained files...
> 
> DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS
> M:	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> T:	git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
> S:	Supported
> F:	Documentation/kobject.txt
> F:	drivers/base/
> F:	fs/debugfs/
> F:	fs/sysfs/
> F:	include/linux/debugfs.h
> F:	include/linux/kobj*
> F:	lib/kobj*

Heh, good point, but using get_maintainer.pl does put me at the top of
the list that you should be cc:ing:

$ ./scripts/get_maintainer.pl --file include/linux/sysfs.h
Greg Kroah-Hartman <gregkh@linuxfoundation.org> (commit_signer:3/3=100%,authored:2/3=67%,added_lines:7/8=88%)
Kate Stewart <kstewart@linuxfoundation.org> (commit_signer:1/3=33%)
Thomas Gleixner <tglx@linutronix.de> (commit_signer:1/3=33%)
Philippe Ombredanne <pombredanne@nexb.com> (commit_signer:1/3=33%)
Nick Desaulniers <nick.desaulniers@gmail.com> (commit_signer:1/3=33%,authored:1/3=33%,added_lines:1/8=12%,removed_lines:1/1=100%)
linux-kernel@vger.kernel.org (open list)

Anyway, I'll go add sysfs.h to the list, thanks for pointing it out.

> > I should be taking this whole series through my tree.  Joe, thanks for
> > doing this in an automated way, I've been wanting to see this done for a
> > long time.
> 
> btw: there are many uses of a reversed declaration style of DEVICE_ATTR
> 
> Here's another thing that could be done for more DEVICE_ATTR_<FOO> uses.
> 
> ===
> 
> Some DEVICE_ATTR definitions use a reversed static function form from
> the typical.  Convert them to use the more common macro form so it is
> easier to grep for the style.
> 
> i.e.:
>         static ssize_t show_<foo>(...)
> and
>         static ssize_t store_<foo>(...)
> 
> where the static function names in the DEVICE_ATTR_RW macro are reversed
> 
>         static ssize_t <foo>_show(...)
> and
>         static ssize_t <foo>_store(...)
> 
> Done with perl script
> 
> $ cat dev_attr_rw_backwards.perl
> local $/;
> while (<>) {
>     my $file = $_;
>     while ($file =~ m/\bDEVICE_ATTR\s*\(\s*(\w+)\s*,/g) {
>         my $var = $1;
>         if ($file =~ s/\bDEVICE_ATTR\s*\(\s*${var}\s*,\s*\(?(\s*S_IRUGO\s*\|\s*S
>             $file =~ s/\bshow_${var}\b/${var}_show/g;
>             $file =~ s/\bstore_${var}\b/${var}_store/g;
>         }
>     }
>     print $file;
> }
> 
> $ git grep --name-only -w DEVICE_ATTR | \
>   xargs perl -i dev_attr_rw_backwards.perl
> 

Ah, nice, I love perl :)

greg k-h
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Joe Perches <joe@perches.com>
Cc: linux-fbdev@vger.kernel.org, David Airlie <airlied@linux.ie>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	alsa-devel@alsa-project.org, dri-devel@lists.freedesktop.org,
	Jaroslav Kysela <perex@perex.cz>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	linux-s390@vger.kernel.org, linux-omap@vger.kernel.org,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	linux-scsi@vger.kernel.org, Takashi Iwai <tiwai@suse.com>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>,
	James Smart <james.smart@broadcom.com>,
	Cezary Jackiewicz <cezary.jackiewicz@gmail.com>,
	linux-serial@vger.kernel.org, Jiri Slaby <jslaby@suse.com>,
	Darren Hart <dvhart@infradead.org>,
	Zhang Rui <rui.zhang@intel.com>,
	Dick Kennedy <dick.kennedy@broadcom.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Peter Oberparleiter <oberpar@linux.vnet.ibm.com>,
	intel-gfx@lists.freedesktop
Subject: Re: [-next PATCH 2/4] treewide: Use DEVICE_ATTR_RW
Date: Wed, 20 Dec 2017 09:59:26 +0000	[thread overview]
Message-ID: <20171220095926.GA24285@kroah.com> (raw)
In-Reply-To: <1513763681.1234.101.camel@perches.com>

On Wed, Dec 20, 2017 at 01:54:41AM -0800, Joe Perches wrote:
> On Wed, 2017-12-20 at 10:32 +0100, Greg Kroah-Hartman wrote:
> > On Wed, Dec 20, 2017 at 01:24:44AM -0800, Joe Perches wrote:
> > > On Wed, 2017-12-20 at 10:34 +0200, Jarkko Nikula wrote:
> > > > On Tue, Dec 19, 2017 at 10:15:07AM -0800, Joe Perches wrote:
> > > > > Convert DEVICE_ATTR uses to DEVICE_ATTR_RW where possible.
> > > 
> > > [] 
> > > > > diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
> > > 
> > > []
> > > > > @@ -854,7 +854,7 @@ static ssize_t dma_op_mode_store(struct device *dev,
> > > > >  	return size;
> > > > >  }
> > > > >  
> > > > > -static DEVICE_ATTR(dma_op_mode, 0644, dma_op_mode_show, dma_op_mode_store);
> > > > > +static DEVICE_ATTR_RW(dma_op_mode);
> > > > >  
> > > > 
> > > > While I can ack this part here if it helps generic cleanup effort I
> > > > don't understart would it improve code readability in general? Mode 644
> > > > is clear and don't need any grepping but for DEVICE_ATTR_RW() I had to go
> > > > through all of these files in order to see what does it mean:
> > 
> > Yeah, 644 is "clear", but _RW() is even more clear.  Ideally I want to
> > get rid of all of the "non-standard" users that set random modes of
> > sysfs files, as we get it wrong too many times.  Using the "defaults" is
> > much better.
> > 
> > > Are you suggesting that device.h (as that is where
> > > DEVICE_ATTR and the other DEVICE_ATTR_<FOO> variants
> > > are #defined) should have better comments for the
> > > _<FOO> variants?
> > > 
> > > > DEVICE_ATTR_RW: include/linux/device.h
> > > > __ATTR_RW: include/linux/sysfs.h
> > > > S_IWUSR: include/uapi/linux/stat.h
> > > > S_IRUGO: include/linux/stat.h
> > > 
> > > btw: patch 1/4 of the series does remove the uses of
> > > S_<PERMS> from these macros in sysfs.h and converts
> > > them to simple octal instead.
> > 
> > Why you didn't send that patch to the sysfs maintainer is a bit odd...  :)
> 
> So here's an opportunity for you:
> 
> The sysfs maintainer hasn't added include/linux/sysfs.h to
> the list of maintained files...
> 
> DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS
> M:	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> T:	git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
> S:	Supported
> F:	Documentation/kobject.txt
> F:	drivers/base/
> F:	fs/debugfs/
> F:	fs/sysfs/
> F:	include/linux/debugfs.h
> F:	include/linux/kobj*
> F:	lib/kobj*

Heh, good point, but using get_maintainer.pl does put me at the top of
the list that you should be cc:ing:

$ ./scripts/get_maintainer.pl --file include/linux/sysfs.h
Greg Kroah-Hartman <gregkh@linuxfoundation.org> (commit_signer:3/3\x100%,authored:2/3g%,added_lines:7/8ˆ%)
Kate Stewart <kstewart@linuxfoundation.org> (commit_signer:1/33%)
Thomas Gleixner <tglx@linutronix.de> (commit_signer:1/33%)
Philippe Ombredanne <pombredanne@nexb.com> (commit_signer:1/33%)
Nick Desaulniers <nick.desaulniers@gmail.com> (commit_signer:1/33%,authored:1/33%,added_lines:1/8\x12%,removed_lines:1/1\x100%)
linux-kernel@vger.kernel.org (open list)

Anyway, I'll go add sysfs.h to the list, thanks for pointing it out.

> > I should be taking this whole series through my tree.  Joe, thanks for
> > doing this in an automated way, I've been wanting to see this done for a
> > long time.
> 
> btw: there are many uses of a reversed declaration style of DEVICE_ATTR
> 
> Here's another thing that could be done for more DEVICE_ATTR_<FOO> uses.
> 
> => 
> Some DEVICE_ATTR definitions use a reversed static function form from
> the typical.  Convert them to use the more common macro form so it is
> easier to grep for the style.
> 
> i.e.:
>         static ssize_t show_<foo>(...)
> and
>         static ssize_t store_<foo>(...)
> 
> where the static function names in the DEVICE_ATTR_RW macro are reversed
> 
>         static ssize_t <foo>_show(...)
> and
>         static ssize_t <foo>_store(...)
> 
> Done with perl script
> 
> $ cat dev_attr_rw_backwards.perl
> local $/;
> while (<>) {
>     my $file = $_;
>     while ($file =~ m/\bDEVICE_ATTR\s*\(\s*(\w+)\s*,/g) {
>         my $var = $1;
>         if ($file =~ s/\bDEVICE_ATTR\s*\(\s*${var}\s*,\s*\(?(\s*S_IRUGO\s*\|\s*S
>             $file =~ s/\bshow_${var}\b/${var}_show/g;
>             $file =~ s/\bstore_${var}\b/${var}_store/g;
>         }
>     }
>     print $file;
> }
> 
> $ git grep --name-only -w DEVICE_ATTR | \
>   xargs perl -i dev_attr_rw_backwards.perl
> 

Ah, nice, I love perl :)

greg k-h

WARNING: multiple messages have this Message-ID (diff)
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Joe Perches <joe@perches.com>
Cc: Jarkko Nikula <jarkko.nikula@bitmer.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Cezary Jackiewicz <cezary.jackiewicz@gmail.com>,
	Darren Hart <dvhart@infradead.org>,
	Andy Shevchenko <andy@infradead.org>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>,
	Peter Oberparleiter <oberpar@linux.vnet.ibm.com>,
	James Smart <james.smart@broadcom.com>,
	Dick Kennedy <dick.kennedy@broadcom.com>,
	Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Felipe Balbi <balbi@kernel.org>,
	"Luis R. Rodriguez" <mcgrof@kernel.org>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	David Airlie <airlied@linux.ie>,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Jiri Slaby <jslaby@suse.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	platform-driver-x86@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org,
	alsa-devel@alsa-project.org, linux-omap@vger.kernel.org
Subject: [-next,2/4] treewide: Use DEVICE_ATTR_RW
Date: Wed, 20 Dec 2017 10:59:26 +0100	[thread overview]
Message-ID: <20171220095926.GA24285@kroah.com> (raw)

On Wed, Dec 20, 2017 at 01:54:41AM -0800, Joe Perches wrote:
> On Wed, 2017-12-20 at 10:32 +0100, Greg Kroah-Hartman wrote:
> > On Wed, Dec 20, 2017 at 01:24:44AM -0800, Joe Perches wrote:
> > > On Wed, 2017-12-20 at 10:34 +0200, Jarkko Nikula wrote:
> > > > On Tue, Dec 19, 2017 at 10:15:07AM -0800, Joe Perches wrote:
> > > > > Convert DEVICE_ATTR uses to DEVICE_ATTR_RW where possible.
> > > 
> > > [] 
> > > > > diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
> > > 
> > > []
> > > > > @@ -854,7 +854,7 @@ static ssize_t dma_op_mode_store(struct device *dev,
> > > > >  	return size;
> > > > >  }
> > > > >  
> > > > > -static DEVICE_ATTR(dma_op_mode, 0644, dma_op_mode_show, dma_op_mode_store);
> > > > > +static DEVICE_ATTR_RW(dma_op_mode);
> > > > >  
> > > > 
> > > > While I can ack this part here if it helps generic cleanup effort I
> > > > don't understart would it improve code readability in general? Mode 644
> > > > is clear and don't need any grepping but for DEVICE_ATTR_RW() I had to go
> > > > through all of these files in order to see what does it mean:
> > 
> > Yeah, 644 is "clear", but _RW() is even more clear.  Ideally I want to
> > get rid of all of the "non-standard" users that set random modes of
> > sysfs files, as we get it wrong too many times.  Using the "defaults" is
> > much better.
> > 
> > > Are you suggesting that device.h (as that is where
> > > DEVICE_ATTR and the other DEVICE_ATTR_<FOO> variants
> > > are #defined) should have better comments for the
> > > _<FOO> variants?
> > > 
> > > > DEVICE_ATTR_RW: include/linux/device.h
> > > > __ATTR_RW: include/linux/sysfs.h
> > > > S_IWUSR: include/uapi/linux/stat.h
> > > > S_IRUGO: include/linux/stat.h
> > > 
> > > btw: patch 1/4 of the series does remove the uses of
> > > S_<PERMS> from these macros in sysfs.h and converts
> > > them to simple octal instead.
> > 
> > Why you didn't send that patch to the sysfs maintainer is a bit odd...  :)
> 
> So here's an opportunity for you:
> 
> The sysfs maintainer hasn't added include/linux/sysfs.h to
> the list of maintained files...
> 
> DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS
> M:	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> T:	git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
> S:	Supported
> F:	Documentation/kobject.txt
> F:	drivers/base/
> F:	fs/debugfs/
> F:	fs/sysfs/
> F:	include/linux/debugfs.h
> F:	include/linux/kobj*
> F:	lib/kobj*

Heh, good point, but using get_maintainer.pl does put me at the top of
the list that you should be cc:ing:

$ ./scripts/get_maintainer.pl --file include/linux/sysfs.h
Greg Kroah-Hartman <gregkh@linuxfoundation.org> (commit_signer:3/3=100%,authored:2/3=67%,added_lines:7/8=88%)
Kate Stewart <kstewart@linuxfoundation.org> (commit_signer:1/3=33%)
Thomas Gleixner <tglx@linutronix.de> (commit_signer:1/3=33%)
Philippe Ombredanne <pombredanne@nexb.com> (commit_signer:1/3=33%)
Nick Desaulniers <nick.desaulniers@gmail.com> (commit_signer:1/3=33%,authored:1/3=33%,added_lines:1/8=12%,removed_lines:1/1=100%)
linux-kernel@vger.kernel.org (open list)

Anyway, I'll go add sysfs.h to the list, thanks for pointing it out.

> > I should be taking this whole series through my tree.  Joe, thanks for
> > doing this in an automated way, I've been wanting to see this done for a
> > long time.
> 
> btw: there are many uses of a reversed declaration style of DEVICE_ATTR
> 
> Here's another thing that could be done for more DEVICE_ATTR_<FOO> uses.
> 
> ===
> 
> Some DEVICE_ATTR definitions use a reversed static function form from
> the typical.  Convert them to use the more common macro form so it is
> easier to grep for the style.
> 
> i.e.:
>         static ssize_t show_<foo>(...)
> and
>         static ssize_t store_<foo>(...)
> 
> where the static function names in the DEVICE_ATTR_RW macro are reversed
> 
>         static ssize_t <foo>_show(...)
> and
>         static ssize_t <foo>_store(...)
> 
> Done with perl script
> 
> $ cat dev_attr_rw_backwards.perl
> local $/;
> while (<>) {
>     my $file = $_;
>     while ($file =~ m/\bDEVICE_ATTR\s*\(\s*(\w+)\s*,/g) {
>         my $var = $1;
>         if ($file =~ s/\bDEVICE_ATTR\s*\(\s*${var}\s*,\s*\(?(\s*S_IRUGO\s*\|\s*S
>             $file =~ s/\bshow_${var}\b/${var}_show/g;
>             $file =~ s/\bstore_${var}\b/${var}_store/g;
>         }
>     }
>     print $file;
> }
> 
> $ git grep --name-only -w DEVICE_ATTR | \
>   xargs perl -i dev_attr_rw_backwards.perl
> 

Ah, nice, I love perl :)

greg k-h
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Joe Perches <joe@perches.com>
Cc: Jarkko Nikula <jarkko.nikula@bitmer.com>,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Cezary Jackiewicz <cezary.jackiewicz@gmail.com>,
	Darren Hart <dvhart@infradead.org>,
	Andy Shevchenko <andy@infradead.org>,
	Sebastian Ott <sebott@linux.vnet.ibm.com>,
	Peter Oberparleiter <oberpar@linux.vnet.ibm.com>,
	James Smart <james.smart@broadcom.com>,
	Dick Kennedy <dick.kennedy@broadcom.com>,
	Zhang Rui <rui.zhang@intel.com>,
	Eduardo Valentin <edubezval@gmail.com>,
	Mathias Nyman <mathias.nyman@intel.com>,
	Felipe Balbi <balbi@kernel.org>,
	"Luis R. Rodriguez" <mcgrof@kernel.org>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>,
	Heiko Carstens <heiko.carstens@de.ibm.com>,
	David Airlie <airlied@linux.ie>,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Jiri Slaby <jslaby@suse.com>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	platform-driver-x86@vger.kernel.org, linux-scsi@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-serial@vger.kernel.org,
	linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org,
	alsa-devel@alsa-project.org, linux-omap@vger.kernel.org
Subject: Re: [-next PATCH 2/4] treewide: Use DEVICE_ATTR_RW
Date: Wed, 20 Dec 2017 10:59:26 +0100	[thread overview]
Message-ID: <20171220095926.GA24285@kroah.com> (raw)
In-Reply-To: <1513763681.1234.101.camel@perches.com>

On Wed, Dec 20, 2017 at 01:54:41AM -0800, Joe Perches wrote:
> On Wed, 2017-12-20 at 10:32 +0100, Greg Kroah-Hartman wrote:
> > On Wed, Dec 20, 2017 at 01:24:44AM -0800, Joe Perches wrote:
> > > On Wed, 2017-12-20 at 10:34 +0200, Jarkko Nikula wrote:
> > > > On Tue, Dec 19, 2017 at 10:15:07AM -0800, Joe Perches wrote:
> > > > > Convert DEVICE_ATTR uses to DEVICE_ATTR_RW where possible.
> > > 
> > > [] 
> > > > > diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
> > > 
> > > []
> > > > > @@ -854,7 +854,7 @@ static ssize_t dma_op_mode_store(struct device *dev,
> > > > >  	return size;
> > > > >  }
> > > > >  
> > > > > -static DEVICE_ATTR(dma_op_mode, 0644, dma_op_mode_show, dma_op_mode_store);
> > > > > +static DEVICE_ATTR_RW(dma_op_mode);
> > > > >  
> > > > 
> > > > While I can ack this part here if it helps generic cleanup effort I
> > > > don't understart would it improve code readability in general? Mode 644
> > > > is clear and don't need any grepping but for DEVICE_ATTR_RW() I had to go
> > > > through all of these files in order to see what does it mean:
> > 
> > Yeah, 644 is "clear", but _RW() is even more clear.  Ideally I want to
> > get rid of all of the "non-standard" users that set random modes of
> > sysfs files, as we get it wrong too many times.  Using the "defaults" is
> > much better.
> > 
> > > Are you suggesting that device.h (as that is where
> > > DEVICE_ATTR and the other DEVICE_ATTR_<FOO> variants
> > > are #defined) should have better comments for the
> > > _<FOO> variants?
> > > 
> > > > DEVICE_ATTR_RW: include/linux/device.h
> > > > __ATTR_RW: include/linux/sysfs.h
> > > > S_IWUSR: include/uapi/linux/stat.h
> > > > S_IRUGO: include/linux/stat.h
> > > 
> > > btw: patch 1/4 of the series does remove the uses of
> > > S_<PERMS> from these macros in sysfs.h and converts
> > > them to simple octal instead.
> > 
> > Why you didn't send that patch to the sysfs maintainer is a bit odd...  :)
> 
> So here's an opportunity for you:
> 
> The sysfs maintainer hasn't added include/linux/sysfs.h to
> the list of maintained files...
> 
> DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS
> M:	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> T:	git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
> S:	Supported
> F:	Documentation/kobject.txt
> F:	drivers/base/
> F:	fs/debugfs/
> F:	fs/sysfs/
> F:	include/linux/debugfs.h
> F:	include/linux/kobj*
> F:	lib/kobj*

Heh, good point, but using get_maintainer.pl does put me at the top of
the list that you should be cc:ing:

$ ./scripts/get_maintainer.pl --file include/linux/sysfs.h
Greg Kroah-Hartman <gregkh@linuxfoundation.org> (commit_signer:3/3=100%,authored:2/3=67%,added_lines:7/8=88%)
Kate Stewart <kstewart@linuxfoundation.org> (commit_signer:1/3=33%)
Thomas Gleixner <tglx@linutronix.de> (commit_signer:1/3=33%)
Philippe Ombredanne <pombredanne@nexb.com> (commit_signer:1/3=33%)
Nick Desaulniers <nick.desaulniers@gmail.com> (commit_signer:1/3=33%,authored:1/3=33%,added_lines:1/8=12%,removed_lines:1/1=100%)
linux-kernel@vger.kernel.org (open list)

Anyway, I'll go add sysfs.h to the list, thanks for pointing it out.

> > I should be taking this whole series through my tree.  Joe, thanks for
> > doing this in an automated way, I've been wanting to see this done for a
> > long time.
> 
> btw: there are many uses of a reversed declaration style of DEVICE_ATTR
> 
> Here's another thing that could be done for more DEVICE_ATTR_<FOO> uses.
> 
> ===
> 
> Some DEVICE_ATTR definitions use a reversed static function form from
> the typical.  Convert them to use the more common macro form so it is
> easier to grep for the style.
> 
> i.e.:
>         static ssize_t show_<foo>(...)
> and
>         static ssize_t store_<foo>(...)
> 
> where the static function names in the DEVICE_ATTR_RW macro are reversed
> 
>         static ssize_t <foo>_show(...)
> and
>         static ssize_t <foo>_store(...)
> 
> Done with perl script
> 
> $ cat dev_attr_rw_backwards.perl
> local $/;
> while (<>) {
>     my $file = $_;
>     while ($file =~ m/\bDEVICE_ATTR\s*\(\s*(\w+)\s*,/g) {
>         my $var = $1;
>         if ($file =~ s/\bDEVICE_ATTR\s*\(\s*${var}\s*,\s*\(?(\s*S_IRUGO\s*\|\s*S
>             $file =~ s/\bshow_${var}\b/${var}_show/g;
>             $file =~ s/\bstore_${var}\b/${var}_store/g;
>         }
>     }
>     print $file;
> }
> 
> $ git grep --name-only -w DEVICE_ATTR | \
>   xargs perl -i dev_attr_rw_backwards.perl
> 

Ah, nice, I love perl :)

greg k-h

  reply	other threads:[~2017-12-20  9:59 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-19 18:15 [-next PATCH 0/4] sysfs and DEVICE_ATTR_<foo> Joe Perches
2017-12-19 18:15 ` Joe Perches
2017-12-19 18:15 ` Joe Perches
2017-12-19 18:15 ` Joe Perches
2017-12-19 18:15 ` Joe Perches
2017-12-19 18:15 ` [-next PATCH 1/4] sysfs.h: Use octal permissions Joe Perches
2017-12-19 18:15 ` [-next PATCH 2/4] treewide: Use DEVICE_ATTR_RW Joe Perches
2017-12-19 18:15   ` Joe Perches
2017-12-19 18:15   ` [-next,2/4] " Joe Perches
2017-12-19 18:15   ` [-next PATCH 2/4] " Joe Perches
2017-12-19 18:41   ` Andy Shevchenko
2017-12-19 18:41     ` Andy Shevchenko
2017-12-19 18:41     ` [-next,2/4] " Andy Shevchenko
2017-12-19 18:41     ` [-next PATCH 2/4] " Andy Shevchenko
2017-12-20  7:19     ` [alsa-devel] " Jidong Zhang
2017-12-20  8:34   ` Jarkko Nikula
2017-12-20  8:34     ` Jarkko Nikula
2017-12-20  8:34     ` [-next,2/4] " Jarkko Nikula
2017-12-20  8:34     ` [-next PATCH 2/4] " Jarkko Nikula
2017-12-20  9:24     ` Joe Perches
2017-12-20  9:24       ` Joe Perches
2017-12-20  9:24       ` [-next,2/4] " Joe Perches
2017-12-20  9:24       ` [-next PATCH 2/4] " Joe Perches
2017-12-20  9:32       ` Greg Kroah-Hartman
2017-12-20  9:32         ` Greg Kroah-Hartman
2017-12-20  9:32         ` [-next,2/4] " Greg Kroah-Hartman
2017-12-20  9:32         ` [-next PATCH 2/4] " Greg Kroah-Hartman
2017-12-20  9:54         ` Joe Perches
2017-12-20  9:54           ` Joe Perches
2017-12-20  9:54           ` [-next,2/4] " Joe Perches
2017-12-20  9:54           ` [-next PATCH 2/4] " Joe Perches
2017-12-20  9:59           ` Greg Kroah-Hartman [this message]
2017-12-20  9:59             ` Greg Kroah-Hartman
2017-12-20  9:59             ` [-next,2/4] " Greg Kroah-Hartman
2017-12-20  9:59             ` [-next PATCH 2/4] " Greg Kroah-Hartman
2017-12-20 10:55             ` Joe Perches
2017-12-20 10:55               ` Joe Perches
2017-12-20 10:55               ` [-next,2/4] " Joe Perches
2017-12-20 10:55               ` [-next PATCH 2/4] " Joe Perches
2017-12-20 13:26               ` Julia Lawall
2017-12-20 13:26                 ` Julia Lawall
2017-12-20 13:26                 ` [-next,2/4] " Julia Lawall
2017-12-20 13:26                 ` [-next PATCH 2/4] " Julia Lawall
2017-12-20 10:54         ` Jarkko Nikula
2017-12-20 10:54           ` Jarkko Nikula
2017-12-20 10:54           ` [-next,2/4] " Jarkko Nikula
2017-12-20 10:54           ` [-next PATCH 2/4] " Jarkko Nikula
2018-01-10 14:43           ` Peter Ujfalusi
2018-01-10 14:43             ` Peter Ujfalusi
2018-01-10 14:43             ` [-next,2/4] " Peter Ujfalusi
2018-01-10 14:43             ` [-next PATCH 2/4] " Peter Ujfalusi
2017-12-21  0:47   ` Zhang Rui
2017-12-21  0:47     ` Zhang Rui
2017-12-21  0:47     ` [-next,2/4] " Zhang, Rui
2017-12-21  0:47     ` [-next PATCH 2/4] " Zhang Rui
2018-01-03 15:16   ` Bartlomiej Zolnierkiewicz
2018-01-03 15:16     ` Bartlomiej Zolnierkiewicz
2018-01-03 15:16     ` [-next,2/4] " Bartlomiej Zolnierkiewicz
2018-01-03 15:16     ` [-next PATCH 2/4] " Bartlomiej Zolnierkiewicz
2017-12-19 18:15 ` [-next PATCH 3/4] treewide: Use DEVICE_ATTR_RO Joe Perches
2017-12-19 18:15   ` Joe Perches
2017-12-19 18:15   ` Joe Perches
2017-12-20 19:00   ` Rafael J. Wysocki
2017-12-20 20:26     ` Sagi Grimberg
2017-12-20 21:38     ` Robert Jarzmik
2017-12-21  0:48   ` Zhang Rui
2017-12-21  0:48     ` Zhang Rui
2017-12-21  0:48     ` Zhang Rui
2017-12-21  7:55   ` Harald Freudenberger
2017-12-21  9:34   ` Sakari Ailus
2018-01-09 15:34     ` Greg Kroah-Hartman
2018-01-09 15:34       ` Greg Kroah-Hartman
2017-12-19 18:15 ` [-next PATCH 4/4] treewide: Use DEVICE_ATTR_WO Joe Perches
2017-12-19 18:44   ` Borislav Petkov
2017-12-19 18:44     ` Borislav Petkov
2017-12-19 18:51     ` Joe Perches
2017-12-19 18:51       ` Joe Perches
2017-12-19 18:54       ` Borislav Petkov
2017-12-19 18:54         ` Borislav Petkov
2017-12-21  0:50   ` Zhang Rui
2017-12-19 18:54 ` [-next PATCH 0/4] sysfs and DEVICE_ATTR_<foo> Jani Nikula
2017-12-19 18:54   ` Jani Nikula
2017-12-19 18:54   ` Jani Nikula
2017-12-19 18:54   ` Jani Nikula
2017-12-19 19:26 ` Corey Minyard
2017-12-19 19:26   ` Corey Minyard
2017-12-19 19:26   ` Corey Minyard
2017-12-19 19:26   ` Corey Minyard
2017-12-19 19:26   ` Corey Minyard
2017-12-20  9:46 ` Felipe Balbi
2017-12-20  9:46   ` Felipe Balbi
2017-12-20  9:46   ` Felipe Balbi
2017-12-20  9:46   ` Felipe Balbi
2017-12-20  9:46   ` Felipe Balbi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171220095926.GA24285@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=airlied@linux.ie \
    --cc=alsa-devel@alsa-project.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=cezary.jackiewicz@gmail.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dvhart@infradead.org \
    --cc=heiko.carstens@de.ibm.com \
    --cc=intel-gfx@lists.freedesktop \
    --cc=james.smart@broadcom.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=joe@perches.com \
    --cc=jslaby@suse.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=oberpar@linux.vnet.ibm.com \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@ti.com \
    --cc=rui.zhang@intel.com \
    --cc=sebott@linux.vnet.ibm.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.