Re: [PATCH v2 2/2] iio: adc: ltc2309: add support for ltc2305
From: Andy Shevchenko
Date: Sat Dec 27 2025 - 09:55:38 EST
On Wed, Dec 24, 2025 at 01:37:15PM +0800, Kyle Hsieh wrote:
> Add support for the 2-channel LTC2305 ADC in the existing LTC2309 driver.
> The LTC2305 and LTC2309 share similar features: both are 12-bit,
> low-noise, low-power SAR ADCs with an I2C interface.
> The main difference is the number of channels: LTC2305 has 2 channels,
> while LTC2309 has 8 channels.
> /* Order matches expected channel address, See datasheet Table 1. */
> +enum ltc2305_channels {
> + LTC2305_CH0_CH1 = 0,
> + LTC2305_CH1_CH0,
> + LTC2305_CH0,
> + LTC2305_CH1,
When it's hardware defined, assign all of them explicitly. Otherwise drop the
unneeded 0 which is guaranteed by the C standard.
> +};
...
> + chip_info = i2c_get_match_data(client);
> + if (!chip_info)
> + return -EINVAL;
I consider this check redundant. There is shouldn't be a production code that
works nicely when there is a clear mistake in it (absence of the mandatory
static initialiser). The author of the change should have been testing this
and hence it will Oops the kernel, which means that the initial code is b0rken.
So, drop the dead check.
--
With Best Regards,
Andy Shevchenko