Re: [PATCH v6 4/4] iio: light: veml6031x00: add support for events and trigger

"Javier Carrasco" <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
>  static int veml6031x00_probe(struct i2c_client *i2c)
>  {
...
> +	ret = devm_add_action_or_reset(dev, veml6031x00_disable_event_action, data);
> +	if (ret) {
> +		dev_err_probe(dev, ret, "Failed to add event cleanup action\n");
> +		goto err_pm_put;
> +	}
> +

I just realized that this action is added without taking into account if
an interrupt is registered or not. It passes because the function checks
if the events are enabled, but it is unnecessary if there is no
interrupt in the first place. I will move it right after
veml6031x00_setup_irq(), and when at it, I will take the whole IIO
device initialization to a dedicated function to make it more readable.

>  	ret = veml6031x00_validate_part_id(data);
>  	if (ret)
>  		goto err_pm_put;
> @@ -693,6 +1212,20 @@ static int veml6031x00_probe(struct i2c_client *i2c)
>  	if (ret)
>  		goto err_pm_put;
>
> +	if (i2c->irq) {
> +		iio->channels = veml6031x00_channels_irq;
> +		iio->num_channels = ARRAY_SIZE(veml6031x00_channels_irq);
> +		ret = veml6031x00_setup_irq(i2c, iio);
> +		if (ret)
> +			goto err_pm_put;
> +
> +		iio->info = &veml6031x00_info;
> +	} else {
> +		iio->channels = veml6031x00_channels;
> +		iio->num_channels = ARRAY_SIZE(veml6031x00_channels);
> +		iio->info = &veml6031x00_info_no_irq;
> +	}
> +
>  	pm_runtime_put_autosuspend(dev);
>
>  	ret = devm_iio_triggered_buffer_setup(dev, iio,

Best regards,
Javier
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.