Re: [PATCH 1/3] i3c: master: enable driver_override for I3C
From: Jonathan Cameron
Date: Sat Sep 12 2026 - 20:24:37 EST
On Fri, 11 Sep 2026 14:09:33 -0700
Meagan Lloyd <meaganlloyd@xxxxxxxxxxxxxxxxxxx> wrote:
> Opt-in to driver_override sysfs functionality for I3C subsystem.
>
> Update some I3C drivers that are assuming that if their .probe is
> invoked that the bus match function already checked the ID table. Go
> ahead and verify in .probe that i3c_device_match_id() returns a valid
> match before using the i3c_device_id pointer.
>
> Signed-off-by: Meagan Lloyd <meaganlloyd@xxxxxxxxxxxxxxxxxxx>
> Assisted-by: Claude:claude-opus-4.8 copilot
Along with splitting these up as this is the sort of change that
will sometimes need backporting in individual drivers because we are
layering something on top, I'd look at adding some helpers to skip
the id as that isn't much used and get the specific fields people
want.
> diff --git a/drivers/hwmon/tmp108.c b/drivers/hwmon/tmp108.c
> index 1c4a58855e2d..98076ae8dce8 100644
> --- a/drivers/hwmon/tmp108.c
> +++ b/drivers/hwmon/tmp108.c
> @@ -581,6 +581,8 @@ static int p3t1085_i3c_probe(struct i3c_device *i3cdev)
> "Failed to register i3c regmap\n");
>
> id = i3c_device_match_id(i3cdev, p3t1085_i3c_ids);
> + if (!id)
> + return -ENODEV;
>
> return tmp108_common_probe(dev, regmap, "p3t1085_i3c", id->data);
Similar to below, jumping directly to an i3c_device_match_data() helper
in this series would avoid getting and id that these drivers don't
need access to.
> }
> diff --git a/drivers/iio/adc/ad4062.c b/drivers/iio/adc/ad4062.c
> index 8e5984055b15..f28b503d16eb 100644
> --- a/drivers/iio/adc/ad4062.c
> +++ b/drivers/iio/adc/ad4062.c
> @@ -1482,14 +1482,20 @@ MODULE_DEVICE_TABLE(i3c, ad4062_id_table);
>
> static int ad4062_probe(struct i3c_device *i3cdev)
> {
> - const struct i3c_device_id *id = i3c_device_match_id(i3cdev, ad4062_id_table);
> - const struct ad4062_chip_info *chip = id->data;
> + const struct i3c_device_id *id;
> + const struct ad4062_chip_info *chip;
> struct device *dev = &i3cdev->dev;
> struct iio_dev *indio_dev;
> struct ad4062_state *st;
> bool ref_sel;
> int ret;
>
> + id = i3c_device_match_id(i3cdev, ad4062_id_table);
> + if (!id)
> + return -ENODEV;
> +
> + chip = id->data;
This might be a good opportunity to introduce
i3c_device_match_data() as in many drivers we don't actually care about
access to the id itself.
> +
> indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
> if (!indio_dev)
> return -ENOMEM;
> diff --git a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> index cb5c5d7e1f3d..153a03e06801 100644
> --- a/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> +++ b/drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_i3c.c
> @@ -32,6 +32,9 @@ static int st_lsm6dsx_i3c_probe(struct i3c_device *i3cdev)
> struct device *dev = i3cdev_to_dev(i3cdev);
> struct regmap *regmap;
>
Please bring the assignment down to above the check so
id = i3c_device_match_id(i3cdev,st_lsm6dsx_i3c_ids);
Which is what you did in the previous driver...
> + if (!id)
> + return -ENODEV;
> +
> regmap = devm_regmap_init_i3c(i3cdev, &st_lsm6dsx_i3c_regmap_config);
> if (IS_ERR(regmap)) {
> dev_err(dev, "Failed to register i3c regmap %ld\n", PTR_ERR(regmap));