All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eva Rachel Retuya <eraretuya@gmail.com>
To: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael.Hennerich@analog.com, jic23@kernel.org, knaack.h@gmx.de,
	pmeerw@pmeerw.net, gregkh@linuxfoundation.org,
	outreachy-kernel@googlegroups.com
Subject: Re: [PATCH] staging: iio: ad7192: implement IIO_CHAN_INFO_SAMP_FREQ
Date: Sat, 1 Oct 2016 15:52:40 +0800	[thread overview]
Message-ID: <20161001075239.GA3233@Socrates-DK> (raw)
In-Reply-To: <21ebde28-4670-bfa5-a171-d7547bb84b26@metafoo.de>

On Fri, Sep 30, 2016 at 02:45:31PM +0200, Lars-Peter Clausen wrote:
> On 09/30/2016 12:28 PM, Eva Rachel Retuya wrote:
> > Use IIO_CHAN_INFO_SAMP_FREQ to implement the sampling_frequency attribute
> > instead of using IIO_DEV_ATTR_SAMP_FREQ() macro.
> > 
> > Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
> 
> Hi,
> 
> Thanks for the patch. There is one tiny bug in the patch, see in the inline
> review.
> 
> The commit message can also be slightly improved. A commit message should
> typically contain why, what and how. For trivial cases some of these might
> be omitted but it is always a good idea to include them regardless. In this
> case the commit message only includes the what. The how is trivial, so that
> is OK. But the why is missing and not necessarily obvious to everybody, e.g.
> consider somebody reading the log 5 years from now.
> 
> For the why part the commit message could contain that this driver
> originally predates the availability of the IIO_CHAN_INFO_SAMP_FREQ
> attribute which is why it was not using it and using it has some advantages
> like it can be access by in-kernel consumers. And it also reduces the code size.
> 

Thank you for the comment. I sent the v2 with all your concerns
addressed.

Eva

> [...]
> > @@ -548,7 +499,7 @@ static int ad7192_write_raw(struct iio_dev *indio_dev,
> >  			    long mask)
> >  {
> >  	struct ad7192_state *st = iio_priv(indio_dev);
> > -	int ret, i;
> > +	int ret, i, div;
> >  	unsigned int tmp;
> >  
> >  	ret = iio_device_claim_direct_mode(indio_dev);
> > @@ -572,10 +523,25 @@ static int ad7192_write_raw(struct iio_dev *indio_dev,
> >  				break;
> >  			}
> >  		break;
> > +	case IIO_CHAN_INFO_SAMP_FREQ:
> > +		if (!val)
> > +			return -EINVAL;
> 
> The direct return here bypasses the iio_device_release_direct_mode() and
> will keep the direct mode locked. This sould instead be
> 
> if (!val) {
> 	ret = -EINVAL;
> 	break;
> }
> 
> > +
> > +		div = st->mclk / (val * st->f_order * 1024);
> > +		if (div < 1 || div > 1023) {
> > +			ret = -EINVAL;
> > +			goto out;
> 
> Since this is in a switch statement and we want to jump to the end of the
> switch I'd just use break, instead of introducing a new label.
> 
> > +		}
> > +
> > +		st->mode &= ~AD7192_MODE_RATE(-1);
> > +		st->mode |= AD7192_MODE_RATE(div);
> > +		ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode);
> > +		break;
> >  	default:
> >  		ret = -EINVAL;
> >  	}
> >  
> > +out:
> >  	iio_device_release_direct_mode(indio_dev);
> >  
> >  	return ret;


      reply	other threads:[~2016-10-01  7:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-30 10:28 [PATCH] staging: iio: ad7192: implement IIO_CHAN_INFO_SAMP_FREQ Eva Rachel Retuya
2016-09-30 12:45 ` Lars-Peter Clausen
2016-10-01  7:52   ` Eva Rachel Retuya [this message]

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=20161001075239.GA3233@Socrates-DK \
    --to=eraretuya@gmail.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=outreachy-kernel@googlegroups.com \
    --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 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.