public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Jonathan Cameron <jic23@kernel.org>,
	Aishwarya Pant <aishpant@gmail.com>,
	Greg KH <gregkh@linuxfoundation.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH 1/5] iio: buffer: use permission specific variants of DEVICE_ATTR
Date: Sat, 06 Jan 2018 07:28:31 -0800	[thread overview]
Message-ID: <1515252511.21222.39.camel@perches.com> (raw)
In-Reply-To: <20180106123521.3bacb64b@archlinux>

(Adding Greg KH who is I think the biggest proponent of these macros)

On Sat, 2018-01-06 at 12:35 +0000, Jonathan Cameron wrote:
> On Thu, 4 Jan 2018 20:07:14 +0530
> Aishwarya Pant <aishpant@gmail.com> wrote
> 
> > This is a clean-up patch which replaces DEVICE_ATTR macro with the file
> > permission specific DEVICE_ATTR_{RO/WO/RW} macros for compaction and
> > readability. Done using coccinelle.
> 
> Hmm. I'll be honest, I personally really dislike these macros.
> They absolutely don't help with readability because they obscure
> the connection between the attributes being created and their callbacks.
> Short is not the same as more readable.
> 
> Dropping off the prefixes from function names suddenly makes them
> appear a lot more generic than they are.  The only advantage is is
> standardizes their naming slightly - but that could be done whilst
> maintaining the more readable version that makes everything obvious.
> 
> I'll think on whether the compactness gains are sufficient to justify their
> use.
> 
> > 
> > Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
> > ---
> >  drivers/iio/industrialio-buffer.c | 25 +++++++++++--------------
> >  1 file changed, 11 insertions(+), 14 deletions(-)
> > 
> > diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> > index d2b465140a6b..ca565fbcff90 100644
> > --- a/drivers/iio/industrialio-buffer.c
> > +++ b/drivers/iio/industrialio-buffer.c
> > @@ -497,7 +497,7 @@ static int iio_buffer_add_channel_sysfs(struct iio_dev *indio_dev,
> >  	return ret;
> >  }
> >  
> > -static ssize_t iio_buffer_read_length(struct device *dev,
> > +static ssize_t length_show(struct device *dev,
> >  				      struct device_attribute *attr,
> >  				      char *buf)
> >  {
> > @@ -507,7 +507,7 @@ static ssize_t iio_buffer_read_length(struct device *dev,
> >  	return sprintf(buf, "%d\n", buffer->length);
> >  }
> >  
> > -static ssize_t iio_buffer_write_length(struct device *dev,
> > +static ssize_t length_store(struct device *dev,
> >  				       struct device_attribute *attr,
> >  				       const char *buf, size_t len)
> >  {
> > @@ -540,7 +540,7 @@ static ssize_t iio_buffer_write_length(struct device *dev,
> >  	return ret ? ret : len;
> >  }
> >  
> > -static ssize_t iio_buffer_show_enable(struct device *dev,
> > +static ssize_t enable_show(struct device *dev,
> >  				      struct device_attribute *attr,
> >  				      char *buf)
> >  {
> > @@ -1117,7 +1117,7 @@ void iio_disable_all_buffers(struct iio_dev *indio_dev)
> >  	iio_buffer_deactivate_all(indio_dev);
> >  }
> >  
> > -static ssize_t iio_buffer_store_enable(struct device *dev,
> > +static ssize_t enable_store(struct device *dev,
> >  				       struct device_attribute *attr,
> >  				       const char *buf,
> >  				       size_t len)
> > @@ -1153,7 +1153,7 @@ static ssize_t iio_buffer_store_enable(struct device *dev,
> >  
> >  static const char * const iio_scan_elements_group_name = "scan_elements";
> >  
> > -static ssize_t iio_buffer_show_watermark(struct device *dev,
> > +static ssize_t watermark_show(struct device *dev,
> >  					 struct device_attribute *attr,
> >  					 char *buf)
> >  {
> > @@ -1163,7 +1163,7 @@ static ssize_t iio_buffer_show_watermark(struct device *dev,
> >  	return sprintf(buf, "%u\n", buffer->watermark);
> >  }
> >  
> > -static ssize_t iio_buffer_store_watermark(struct device *dev,
> > +static ssize_t watermark_store(struct device *dev,
> >  					  struct device_attribute *attr,
> >  					  const char *buf,
> >  					  size_t len)
> > @@ -1198,16 +1198,13 @@ static ssize_t iio_buffer_store_watermark(struct device *dev,
> >  	return ret ? ret : len;
> >  }
> >  
> > -static DEVICE_ATTR(length, S_IRUGO | S_IWUSR, iio_buffer_read_length,
> > -		   iio_buffer_write_length);
> > +static DEVICE_ATTR_RW(length);
> >  static struct device_attribute dev_attr_length_ro = __ATTR(length,
> > -	S_IRUGO, iio_buffer_read_length, NULL);
> > -static DEVICE_ATTR(enable, S_IRUGO | S_IWUSR,
> > -		   iio_buffer_show_enable, iio_buffer_store_enable);
> > -static DEVICE_ATTR(watermark, S_IRUGO | S_IWUSR,
> > -		   iio_buffer_show_watermark, iio_buffer_store_watermark);
> > +	S_IRUGO, length_show, NULL);
> > +static DEVICE_ATTR_RW(enable);
> > +static DEVICE_ATTR_RW(watermark);
> >  static struct device_attribute dev_attr_watermark_ro = __ATTR(watermark,
> > -	S_IRUGO, iio_buffer_show_watermark, NULL);
> > +	S_IRUGO, watermark_show, NULL);
> >  
> >  static struct attribute *iio_buffer_attrs[] = {
> >  	&dev_attr_length.attr,
> 
> 

  parent reply	other threads:[~2018-01-06 15:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-04 14:36 [PATCH 0/5] iio: use permission specific variants of DEVICE_ATTR Aishwarya Pant
2018-01-04 14:37 ` [PATCH 1/5] iio: buffer: " Aishwarya Pant
2018-01-06 12:35   ` Jonathan Cameron
2018-01-06 12:50     ` Lars-Peter Clausen
2018-01-06 13:18       ` Julia Lawall
2018-01-06 14:17         ` Jonathan Cameron
2018-01-06 15:28     ` Joe Perches [this message]
2018-01-04 14:37 ` [PATCH 2/5] iio: core: " Aishwarya Pant
2018-01-04 14:38 ` [PATCH 3/5] iio: trigger: " Aishwarya Pant
2018-01-04 14:38 ` [PATCH 4/5] iio: hrtimer: " Aishwarya Pant
2018-01-04 14:38 ` [PATCH 5/5] iio: trigger: sysfs: use permisssion " Aishwarya Pant
2018-01-04 15:16 ` [PATCH 0/5] iio: use permission " Joe Perches

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=1515252511.21222.39.camel@perches.com \
    --to=joe@perches.com \
    --cc=aishpant@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=julia.lawall@lip6.fr \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmeerw@pmeerw.net \
    /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