dt-bindings: iio: adc: mcp3911: add support for the whole MCP39xx family
Subsystems (3)
Marcus Folkesson
maintainerPATCH v3 1/2 dt-bindings: iio: adc: mcp3911: add support for the whole MCP39xx family
Microchip does have many similar chips, add those to the compatible string as the driver support is extended.
The new supported chips are:
- microchip,mcp3910
- microchip,mcp3912
- microchip,mcp3913
- microchip,mcp3914
- microchip,mcp3918
- microchip,mcp3919
---
Notes:
v2:
- No changes
v3:
- No changes
.../devicetree/bindings/iio/adc/microchip,mcp3911.yaml | 6 ++++++ 1 file changed, 6 insertions(+)
Documentation/devicetree/bindings/iio/adc/microchip,mcp3911.yaml +6 -0
@@ -18,7 +18,13 @@ description: | properties: compatible: enum: + - microchip,mcp3910 - microchip,mcp3911 + - microchip,mcp3912 + - microchip,mcp3913 + - microchip,mcp3914 + - microchip,mcp3918 + - microchip,mcp3919 reg: maxItems: 1
Signature · 1 line
2.40.1
Marcus Folkesson
maintainerPATCH v3 2/2 iio: adc: mcp3911: add support for the whole MCP39xx family
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
---
Notes:
v2:
- Use callbacks rather than matching against enum for determine chip variants
v3:
- Fix cosmetics
drivers/iio/adc/Kconfig | 5 +- drivers/iio/adc/mcp3911.c | 457 +++++++++++++++++++++++++++++++++----- 2 files changed, 401 insertions(+), 61 deletions(-)
drivers/iio/adc/Kconfig +3 -2
@@ -774,8 +774,9 @@ config MCP3911 select IIO_BUFFER select IIO_TRIGGERED_BUFFER help - Say yes here to build support for Microchip Technology's MCP3911 - analog to digital converter. + Say yes here to build support for Microchip Technology's MCP3910, + MCP3911, MCP3912, MCP3913, MCP3914, MCP3918 and MCP3919 + analog to digital converters. This driver can also be built as a module. If so, the module will be called mcp3911.
drivers/iio/adc/mcp3911.c +398 -59
590 lines not on this page · raw message
Signature · 1 line
2.40.1
Re: [PATCH v3 2/2] iio: adc: mcp3911: add support for the whole MCP39xx family
Quoted 9 lines · Marcus Folkesson
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
...
Quoted 1 line
+#define
MCP3910_STATUSCOM_DRHIZBIT(20)
Is it deliberately using spaces? If so, why?
...
drivers/iio/adc/mcp3911.c static int mcp3911_update(struct mcp3911 *adc, u8 reg, u32 mask, · line 220
Quoted 9 lines
drivers/iio/adc/mcp3911.c +8
-0+static int mcp3910_get_osr (struct mcp3911 *adc,int *val) +{ +int ret, osr; + + ret =mcp3911_read (adc,MCP3910_REG_CONFIG0 , val,3 ); + osr =FIELD_GET (MCP3910_CONFIG0_OSR , *val); + *val =32 << osr; +return ret;
I believe this is wrong order. Or bad code. The rule of thumb is not pollute the output variable if we know the error happened.
Same applies to another function.
Quoted 1 line
+}
...
drivers/iio/adc/mcp3911.c static int mcp3911_probe(struct spi_device *spi) · line 761
Quoted 2 lines
drivers/iio/adc/mcp3911.c +1
-1- ret =mcp3911_config (adc); + ret =device_property_read_u32 (&adc->spi->dev,"microchip,device-addr" , &adc->dev_addr);
Why not spi->dev? Ditto for other uses like this.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Marcus Folkesson
maintainerRe: [PATCH v3 2/2] iio: adc: mcp3911: add support for the whole MCP39xx family
Quoted 11 lines · Andy Shevchenko
Quoted 9 lines · Marcus Folkesson
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
Quoted 5 lines
...
Quoted 1 line
+#define
MCP3910_STATUSCOM_DRHIZBIT(20)Is it deliberately using spaces? If so, why?
No, probably due to my with my new vim setup..
Quoted 18 lines
...
drivers/iio/adc/mcp3911.c static int mcp3911_update(struct mcp3911 *adc, u8 reg, u32 mask, · line 220
Quoted 9 lines
drivers/iio/adc/mcp3911.c +8
-0+static int mcp3910_get_osr (struct mcp3911 *adc,int *val) +{ +int ret, osr; + + ret =mcp3911_read (adc,MCP3910_REG_CONFIG0 , val,3 ); + osr =FIELD_GET (MCP3910_CONFIG0_OSR , *val); + *val =32 << osr; +return ret;I believe this is wrong order. Or bad code. The rule of thumb is not pollute the output variable if we know the error happened.
Same applies to another function.
Quoted 8 lines
Quoted 1 line
+}
...
drivers/iio/adc/mcp3911.c static int mcp3911_probe(struct spi_device *spi) · line 761
Quoted 2 lines
drivers/iio/adc/mcp3911.c +1
-1- ret =mcp3911_config (adc); + ret =device_property_read_u32 (&adc->spi->dev,"microchip,device-addr" , &adc->dev_addr);Why not
spi->dev? Ditto for other uses like this.
After all, I think it is better to stick sith adc->spi-dev to be consistent with the rest of the probe function. Change to spi->dev should probably be a seperate patch.
Do you agree?
Quoted 6 lines
Signature · 3 lines
-- With Best Regards, Andy Shevchenko
Re: [PATCH v3 2/2] iio: adc: mcp3911: add support for the whole MCP39xx family
Quoted 8 lines · Marcus Folkesson
Quoted 7 lines
...
drivers/iio/adc/mcp3911.c static int mcp3911_probe(struct spi_device *spi) · line 761
Quoted 2 lines
drivers/iio/adc/mcp3911.c +1
-1- ret =mcp3911_config (adc); + ret =device_property_read_u32 (&adc->spi->dev,"microchip,device-addr" , &adc->dev_addr);Why not
spi->dev? Ditto for other uses like this.
Quoted 5 lines
After all, I think it is better to stick sith adc->spi-dev to be consistent with the rest of the probe function. Change to
spi->devshould probably be a seperate patch.
Do you agree?
You can first simplify the usages and then add new family support already using spi->dev.
Best regards,
Krzysztof
Re: [PATCH v3 2/2] iio: adc: mcp3911: add support for the whole MCP39xx family
Quoted 1 line · Krzysztof Kozlowski
On 08/08/2023 09:22, Marcus Folkesson wrote:
...
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
drivers/iio/adc/mcp3911.c static int mcp3911_probe(struct spi_device *spi) · line 761
Quoted 1 line
drivers/iio/adc/mcp3911.c +1
-0+ ret =device_property_read_u32 (&adc->spi->dev,"microchip,device-addr" , &adc->dev_addr);Why not
spi->dev? Ditto for other uses like this.
Quoted 8 lines
Quoted 5 lines
After all, I think it is better to stick sith adc->spi-dev to be consistent with the rest of the probe function. Change to
spi->devshould probably be a seperate patch.
Do you agree?You can first simplify the usages and then add new family support already using
spi->dev.
He-he, answered the same :-)
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v3 2/2] iio: adc: mcp3911: add support for the whole MCP39xx family
In reply to Marcus FolkessonQuoted 2 lines · Marcus Folkesson
Quoted 1 line · Andy Shevchenko
On Mon, Aug 07, 2023 at 09:18:31AM +0200, Marcus Folkesson wrote:
...
Quoted 9 lines
Quoted 4 lines
drivers/iio/adc/mcp3911.c static int mcp3911_probe(struct spi_device *spi) · line 761
Quoted 2 lines
drivers/iio/adc/mcp3911.c +1
-1- ret =mcp3911_config (adc); + ret =device_property_read_u32 (&adc->spi->dev,"microchip,device-addr" , &adc->dev_addr);Why not
spi->dev? Ditto for other uses like this.After all, I think it is better to stick sith adc->spi-dev to be consistent with the rest of the probe function. Change to
spi->devshould probably be a seperate patch.
Do you agree?
Make sure you first switch to use shorter form and then add this one. In that case I agree.
Signature · 2 lines
With Best Regards, Andy Shevchenko