Linux IIO development
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Joe Perches <joe@perches.com>
Cc: Lars-Peter Clausen <lars@metafoo.de>, linux-iio@vger.kernel.org
Subject: Re: [PATCH 4/4] iio: dac: Convert powerdown read callbacks to sysfs_emit()
Date: Mon, 29 Mar 2021 11:13:46 +0100	[thread overview]
Message-ID: <20210329111346.64af72ab@jic23-huawei> (raw)
In-Reply-To: <5fda4359734f5b008040090d1bad96e36473e307.camel@perches.com>

On Sat, 20 Mar 2021 08:13:55 -0700
Joe Perches <joe@perches.com> wrote:

> On Sat, 2021-03-20 at 13:52 +0100, Lars-Peter Clausen wrote:
> > On 3/20/21 12:01 PM, Joe Perches wrote:  
> > > On Sat, 2021-03-20 at 08:14 +0100, Lars-Peter Clausen wrote:  
> > > > Update DAC drivers powerdown attribute show callback to use the new
> > > > sysfs_emit() function.
> > > > 
> > > > sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it
> > > > knows about the sysfs buffer specifics and has some built-in sanity checks.  
> > > Thanks.
> > > 
> > > unrelated trivia:
> > >   
> > > > diff --git a/drivers/iio/dac/ad5360.c b/drivers/iio/dac/ad5360.c  
> > > []  
> > > > @@ -255,7 +255,7 @@ static ssize_t ad5360_read_dac_powerdown(struct device *dev,
> > > >   	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> > > >   	struct ad5360_state *st = iio_priv(indio_dev);
> > > >   
> > > > 
> > > > -	return sprintf(buf, "%d\n", (bool)(st->ctrl & AD5360_SF_CTRL_PWR_DOWN));
> > > > +	return sysfs_emit(buf, "%d\n", (bool)(st->ctrl & AD5360_SF_CTRL_PWR_DOWN));  
> > > rather than cast to bool, perhaps standardize to use !!(val & test)  
> > I very much prefer the cast to bool since it semantically stronger. You 
> > don't have to know that the !! idiom is used to cast an int to bool.  
> 
> Using !! does not cast to bool, it's an int.
> 
> casting to bool and using %d in a printf equivalent ends up with an
> integer promotion/implicit type conversion from bool to int.
> 
> Anyway, it's not my code so it's author's choice, but similar
> code using different styles is, at a minimum, inconsistent.
> 
I'm certainly not against cleaning this up at somepoint, but it's not strictly
part of what this particular patch set is doing, so I'd rather do
it separately anyway.

Applied to the togreg branch of iio.git and pushed out as testing
for all the normal reasons.

Thanks,

Jonathan


  reply	other threads:[~2021-03-29 10:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-20  7:14 [PATCH 0/4] iio: Start conversion to sysfs_emit() Lars-Peter Clausen
2021-03-20  7:14 ` [PATCH 1/4] iio: core: Use sysfs_emit() (trivial bits) Lars-Peter Clausen
2021-03-20  7:14 ` [PATCH 2/4] iio: iio_enum_available_read(): Convert to sysfs_emit_at() Lars-Peter Clausen
2021-03-20  7:14 ` [PATCH 3/4] iio: __iio_format_value(): " Lars-Peter Clausen
2021-03-20  7:14 ` [PATCH 4/4] iio: dac: Convert powerdown read callbacks to sysfs_emit() Lars-Peter Clausen
2021-03-20 11:01   ` Joe Perches
2021-03-20 12:52     ` Lars-Peter Clausen
2021-03-20 15:13       ` Joe Perches
2021-03-29 10:13         ` Jonathan Cameron [this message]
2021-03-29 11:21       ` Andy Shevchenko
2021-03-29 11:22         ` Andy Shevchenko
2021-03-29 11:27   ` Andy Shevchenko
2021-03-20 18:34 ` [PATCH 0/4] iio: Start conversion " Jonathan Cameron

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=20210329111346.64af72ab@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=joe@perches.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    /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