Re: [PATCH v1 2/2] iio: adc: Add TI ADS131M0x ADC driver
From: Marc Kleine-Budde
Date: Wed Nov 05 2025 - 09:51:52 EST
On 05.11.2025 15:38:14, Oleksij Rempel wrote:
> +static int ads131m_probe(struct spi_device *spi)
> +{
> + const struct ads131m_configuration *config;
> + struct iio_dev *indio_dev;
> + struct ads131m_priv *priv;
> + int ret;
> +
> + spi->mode = SPI_MODE_1;
> + spi->bits_per_word = 8;
> +
> + if (!spi->max_speed_hz || spi->max_speed_hz > ADS131M_MAX_SCLK_HZ)
> + spi->max_speed_hz = ADS131M_MAX_SCLK_HZ;
> +
> + ret = spi_setup(spi);
> + if (ret < 0) {
> + dev_err(&spi->dev, "Error in spi setup\n");
> + return ret;
> + }
> +
> + indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*priv));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + priv = iio_priv(indio_dev);
> + priv->spi = spi;
> +
> + indio_dev->name = spi_get_device_id(spi)->name;
> + indio_dev->modes = INDIO_DIRECT_MODE;
> + indio_dev->info = &ads131m_info;
> +
> + config = device_get_match_data(&spi->dev);
> + if (!config) {
> + const struct spi_device_id *id;
> +
> + id = spi_get_device_id(spi);
> + if (!id)
> + return -ENODEV;
> +
> + config = (const void *)id->driver_data;
> + }
> + priv->config = config;
> +
> + indio_dev->channels = config->channels;
> + indio_dev->num_channels = config->num_channels;
> + priv->num_channels = config->num_channels;
> +
> + /* Get the external clock source connected to the CLKIN pin */
> + priv->clk = devm_clk_get(&spi->dev, NULL);
Can you use devm_clk_get_prepared() here? This simplifies the
ads131m_hw_init() function.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
Attachment:
signature.asc
Description: PGP signature