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

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

 



On Sun, Aug 20, 2023 at 12:26:10PM +0200, Marcus Folkesson wrote:
> Microchip does have many similar chips, add support for those.
> 
> The new supported chips are:
>   - microchip,mcp3910
>   - microchip,mcp3912
>   - microchip,mcp3913
>   - microchip,mcp3914
>   - microchip,mcp3918
>   - microchip,mcp3919

A few really minor things, after addressing them
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>

Thank you for this journey!

...

> +static int mcp3910_enable_offset(struct mcp3911 *adc, bool enable)
> +{
> +	unsigned int mask = MCP3910_CONFIG0_EN_OFFCAL;

	unsigned int value = enable ? mask : 0;

> +
> +	if (enable)
> +		return mcp3911_update(adc, MCP3910_REG_CONFIG0, mask, mask, 3);
> +	else
> +		return mcp3911_update(adc, MCP3910_REG_CONFIG0, mask, 0, 3);

	return mcp3911_update(adc, MCP3910_REG_CONFIG0, mask, value, 3);

> +}

...

> +static int mcp3911_enable_offset(struct mcp3911 *adc, bool enable)
> +{
> +	unsigned int mask = MCP3911_STATUSCOM_EN_OFFCAL;
> +
> +	if (enable)
> +		return mcp3911_update(adc, MCP3911_REG_STATUSCOM, mask, mask, 2);
> +	else
> +		return mcp3911_update(adc, MCP3911_REG_STATUSCOM, mask, 0, 2);
> +}

Ditto.

...

> +static int mcp3910_get_osr(struct mcp3911 *adc, u32 *val)
> +{
> +	int ret, osr;

	unsigned int osr;

> +
> +	ret = mcp3911_read(adc, MCP3910_REG_CONFIG0, val, 3);
> +	if (ret)
> +		return ret;
> +
> +	osr = FIELD_GET(MCP3910_CONFIG0_OSR, *val);
> +	*val = 32 << osr;
> +	return 0;
> +}

...

> +static int mcp3910_set_osr(struct mcp3911 *adc, u32 val)
> +{
> +	int osr = FIELD_PREP(MCP3910_CONFIG0_OSR, val);

Ditto.

> +	unsigned int mask = MCP3910_CONFIG0_OSR;
> +
> +	return mcp3911_update(adc, MCP3910_REG_CONFIG0, mask, osr, 3);
> +}

...

> +static int mcp3911_set_osr(struct mcp3911 *adc, u32 val)
> +{
> +	int osr = FIELD_PREP(MCP3911_CONFIG_OSR, val);

Ditto.

> +	unsigned int mask = MCP3911_CONFIG_OSR;
> +
> +	return mcp3911_update(adc, MCP3911_REG_CONFIG, mask, osr, 2);
> +}
> +
> +static int mcp3911_get_osr(struct mcp3911 *adc, u32 *val)
> +{
> +	int ret, osr;
> +
> +	ret = mcp3911_read(adc, MCP3911_REG_CONFIG, val, 2);
> +	if (ret)
> +		return ret;
> +
> +	osr = FIELD_GET(MCP3911_CONFIG_OSR, *val);
> +	*val = 32 << osr;
> +	return ret;
> +}

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux