Re: [PATCH v4 4/4] iio: adc: mcp3911: add support for the whole MCP39xx family

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

 



> ...
> 
> > +#define MCP3910_OFFCAL(x)		(MCP3910_REG_OFFCAL_CH0 + x * 6)
> 
> Inconsistent macro implementation, i.e. you need to use (x).

Sorry, I do not get you


[...]

> > +static int mcp3910_get_osr(struct mcp3911 *adc, int *val)
> > +{
> > +	int ret, osr;
> 
> Strictly speaking osr can't be negative, otherwise it's a UB below.
> 
> 	u32 osr = FIELD_GET(MCP3910_CONFIG0_OSR, *val);
> 	int ret;
> 
> and why val is int?

I will change val to u32 for *_get_osr(), *_set_osr() and *_set_scale().

[...]

> > +	if (device_property_read_bool(&adc->spi->dev, "microchip,data-ready-hiz"))
> 
> This also becomes shorter.
> 
> One trick to make it even shorter:
> 
> 	if (device_property_present(dev, "microchip,data-ready-hiz"))

Thank you, I wasn't aware of device_property_present().

[...]

> 
> > +	dev_dbg(&spi->dev, "use device address %i\n", adc->dev_addr);
> 
> Is it useful?

Yes, I think so.

> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
> 

Best regards,
Marcus Folkesson

Attachment: signature.asc
Description: PGP signature


[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