On Wed, Aug 26, 2026 at 07:54:08PM +0200, Jorijn van der Graaf wrote:
> Introduce a chip_info structure carrying the device name and channel
> specification, attach it to every i2c, OF and ACPI table entry, and
> let probe take it from the match data, failing when there is none.
> Every firmware bind path carries match data, and with the id names in
> lower case a client instantiated through the sysfs new_device
> interface under a compatible-derived name receives it through the id
> table. The shared channel definitions move into macros.
> 
> The ACPI table entries change to named initializers, matching the
> other id tables.
> 
> This is a preparatory change for a variant that provides more channels
> than the existing parts. No functional change for firmware-described
> devices; a sysfs client under a name that binds without matching any
> id entry (the full compatible string) now fails probe with an error
> instead of probing as an stk3310.

...

> +/**
> + * struct stk3310_chip_info - chip-specific data
> + * @name: device name reported to the IIO core
> + * @channels: channel specification
> + * @num_channels: number of channels
> + */
> +struct stk3310_chip_info {
> +     const char                      *name;
> +     const struct iio_chan_spec      *channels 
> __counted_by_ptr(num_channels);
> +     unsigned int                    num_channels;

I don't think we need tab-based indentation of the field names.

> +};

...

>  static int stk3310_probe(struct i2c_client *client)
>  {
> +     const struct stk3310_chip_info *chip_info;

        struct device *dev = &client->dev;

>       int ret;
>       struct iio_dev *indio_dev;
>       struct stk3310_data *data;
>  
> +     chip_info = i2c_get_match_data(client);
> +     if (!chip_info)
> +             return dev_err_probe(&client->dev, -ENODEV,
> +                                  "missing driver data\n");

Use -ENODATA

                return dev_err_probe(dev, -ENODATA, "missing driver data\n");

>       indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
>       if (!indio_dev)
>               return -ENOMEM;

-- 
With Best Regards,
Andy Shevchenko



Reply via email to