Re: [PATCH v2 2/2] iio: adc: ti-ads1119: Add driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Jonathan,

Thanks for the review!

> > +
> > +static int ads1119_validate_gain(struct ads1119_state *st, int scale, int uscale)
> > +{
> > +	int gain = 1000000 / ((scale * 1000000) + uscale);
> > +
> > +	switch (gain) {
> > +	case 1:
> > +	case 4:
> > +		return gain;
> Odd to calculate it if we don't need it
> 		return MICRO / (scale * MICRO + uscale);
> use constants as it's easy to drop a 0 in these without anyone noticing.
>
> > +	default:
> > +		return -EINVAL;
> > +	}
> > +}
> > +

Just a minor. I do use the calculated value on write_raw() by storing it as the
new channel gain and would still need to validate it as scale/uscale comes from
userspace. Maybe I can just remove the validate_gain function and do the check
directly on write_raw(). What do you think?

Regards,
João Paulo Gonçalves




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux