Re: [PATCH 7/7] iio: amplifiers: ad8366: add device tree support
From: Krzysztof Kozlowski
Date: Mon Jan 19 2026 - 09:47:51 EST
On 19/01/2026 15:37, Rodrigo Alencar via B4 Relay wrote:
> + st->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> + if (IS_ERR(st->reset_gpio))
> + return dev_err_probe(dev, PTR_ERR(st->reset_gpio),
> + "Failed to get reset GPIO\n");
>
> - st->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH);
> - if (IS_ERR(st->enable_gpio))
> - return dev_err_probe(dev, PTR_ERR(st->enable_gpio),
> - "Failed to get enable GPIO\n");
> + st->enable_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_HIGH);
No, you are changing the same line *third* time. you need to organize
your patchset in logical way but also in a readable. You do not add
incorrect code just to change it later.
I do not see the reason behind removal of switch case. It's really
independent change of OF support which must come with its own
justification of affecting other platforms.
> + if (IS_ERR(st->enable_gpio))
> + return dev_err_probe(dev, PTR_ERR(st->enable_gpio),
> + "Failed to get enable GPIO\n");
>
> - indio_dev->channels = ada4961_channels;
> - indio_dev->num_channels = ARRAY_SIZE(ada4961_channels);
> - break;
> - default:
> - return dev_err_probe(dev, -EINVAL, "Invalid device ID\n");
> - }
> -
> - st->info = &ad8366_infos[st->type];
> indio_dev->name = spi_get_device_id(spi)->name;
> indio_dev->info = &ad8366_info;
> + indio_dev->channels = ad8366_channels;
> + indio_dev->num_channels = st->info->num_channels;
> indio_dev->modes = INDIO_DIRECT_MODE;
>
> - ret = ad8366_write(indio_dev, 0, 0);
> + ret = ad8366_write_code(st);
> if (ret < 0)
> return dev_err_probe(dev, ret, "failed to write initial gain\n");
>
> @@ -384,24 +322,41 @@ static int ad8366_probe(struct spi_device *spi)
> }
Best regards,
Krzysztof