Linux Documentation
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Orson Zhai <orsonzhai@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>,
	Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	Joe Perches <joe@perches.com>, Denis Efremov <efremov@linux.com>,
	"David S. Miller" <davem@davemloft.net>,
	Christian Brauner <christian.brauner@ubuntu.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Sourabh Jain <sourabhjain@linux.ibm.com>,
	Orson Zhai <orson.zhai@unisoc.com>,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] include: sysfs: Add macro to assign show for RO attributes
Date: Wed, 27 Jan 2021 08:50:28 +0100	[thread overview]
Message-ID: <YBEbRDOQhczI5/yC@kroah.com> (raw)
In-Reply-To: <1611721162-29982-1-git-send-email-orsonzhai@gmail.com>

On Wed, Jan 27, 2021 at 12:19:22PM +0800, Orson Zhai wrote:
> In some circumstances, multiple __ATTR_RO attributes need to be assigned
> with a single show function.
> 
> Add this macro to make life easier with simple code.
> 
> Signed-off-by: Orson Zhai <orsonzhai@gmail.com>
> ---
>  Documentation/filesystems/sysfs.rst | 2 ++
>  include/linux/sysfs.h               | 5 +++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/Documentation/filesystems/sysfs.rst b/Documentation/filesystems/sysfs.rst
> index 004d490..0e2274a 100644
> --- a/Documentation/filesystems/sysfs.rst
> +++ b/Documentation/filesystems/sysfs.rst
> @@ -141,6 +141,8 @@ __ATTR_RO_MODE(name, mode):
>  	         fore more restrictive RO access currently
>                   only use case is the EFI System Resource Table
>                   (see drivers/firmware/efi/esrt.c)
> +__ATTR_RO_SHOW(name, show):
> +		 assumes default mode 0444 with specified show.
>  __ATTR_RW(name):
>  	         assumes default name_show, name_store and setting
>                   mode to 0644.
> diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
> index 2caa34c..c851592 100644
> --- a/include/linux/sysfs.h
> +++ b/include/linux/sysfs.h
> @@ -117,6 +117,11 @@ struct attribute_group {
>  	.show	= _name##_show,						\
>  }
>  
> +#define __ATTR_RO_SHOW(_name, _show) {					\
> +	.attr	= { .name = __stringify(_name), .mode = 0444 },		\
> +	.show	= _show,						\
> +}

Do you have a real user for this?  Using "raw" kobject attributes is
rare and should not be used often, so who needs this?

thanks,

greg k-h

  reply	other threads:[~2021-01-27  7:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27  4:19 [PATCH] include: sysfs: Add macro to assign show for RO attributes Orson Zhai
2021-01-27  7:50 ` Greg Kroah-Hartman [this message]
2021-01-27 12:51   ` Orson Zhai
2021-01-27 13:30     ` Greg Kroah-Hartman

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=YBEbRDOQhczI5/yC@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=corbet@lwn.net \
    --cc=dan.j.williams@intel.com \
    --cc=davem@davemloft.net \
    --cc=efremov@linux.com \
    --cc=joe@perches.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=orson.zhai@unisoc.com \
    --cc=orsonzhai@gmail.com \
    --cc=sourabhjain@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox