Re: [PATCH v1 2/2] iio: adc: add ADC driver for the TI LMP92064 controller

From: Marcus Folkesson
Date: Tue Oct 04 2022 - 10:57:24 EST


Hi,

Overall, a lot of comments does not have the right formatting.
Please run scripts/checkpatch.pl.

On Tue, Oct 04, 2022 at 03:42:38PM +0200, Leonard Göhrs wrote:
> The TI LMP92064 is a dual 12 Bit ADC connected via SPI.
> The two channels are intended for simultaneous measurements of the voltage
> across- and current through a load to allow accurate instantaneous power
> measurements.
> The driver does not yet take advantage of this feature, as buffering is not yet
> implemented.
>
> Signed-off-by: Leonard Göhrs <l.goehrs@xxxxxxxxxxxxxx>
> ---
> +static const struct iio_chan_spec lmp92064_adc_channels[] = {
> + {
> + .type = IIO_CURRENT,
> + .address = TI_LMP92064_CHAN_INC,
> + .info_mask_separate =
> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> + .datasheet_name = "INC",
> + },
> + {
> + .type = IIO_VOLTAGE,
> + .address = TI_LMP92064_CHAN_INV,
> + .info_mask_separate =
> + BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> + .datasheet_name = "INV",
> + },
> +};
> +

[...]

> +static int lmp92064_write_reg(struct lmp92064_adc_priv *priv, u16 reg, u8 val)
> +static int lmp92064_read_reg(struct lmp92064_adc_priv *priv, u16 reg, u8 *val)

Does not regmap work for this?

[...]

> +static int lmp92064_adc_probe(struct spi_device *spi)
> +{
> + struct device *dev = &spi->dev;
> + struct lmp92064_adc_priv *priv;
> + struct iio_dev *indio_dev;
> + struct gpio_desc *gpio_reset;
> + int ret;
> + u32 shunt_resistor;
> +
> + spi->bits_per_word = 8;
> + spi->mode &= ~SPI_MODE_X_MASK;
> + spi->mode |= SPI_MODE_0;
> + ret = spi_setup(spi);
> + if (ret < 0)
> + return dev_err_probe(dev, ret, "Error in SPI setup\n");
> +
> + indio_dev = devm_iio_device_alloc(dev, sizeof(*priv));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + priv = iio_priv(indio_dev);
> +
> + priv->spi = spi;
> +
> + ret = of_property_read_u32(dev->of_node, "shunt-resistor",
> + &shunt_resistor);

device_property_read_u32() ?


> + if (ret < 0)
> + return dev_err_probe(dev, ret,

Attachment: signature.asc
Description: PGP signature