RE: [PATCH 15/15] iio: sx9310: use the data of the I2C table
From: Biju Das
Date: Tue Oct 27 2026 - 12:26:12 EST
Hi Greg/Josef,
> -----Original Message-----
> From: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Sent: 27 October 2026 16:19
> Subject: [PATCH 15/15] iio: sx9310: use the data of the I2C table
>
> From: Josef Bacik <josef@xxxxxxxxxxxxxx>
>
> sx9310_check_whoami() takes the chip information from device_get_match_data(), which only looks at the OF
> and ACPI tables, and dereferences it. For a client which was bound through the i2c_device_id table, for
> instance one created with
Not sure we can extend device_get_match_data() to cover this use case?
Cheers,
Biju
>
> echo sx9310 0x28 > /sys/bus/i2c/devices/i2c-1/new_device
>
> it returns NULL, and the kernel oopses as soon as something at that address answers the read of the
> WHOAMI register.
>
> The I2C table has the same pointers. Use i2c_get_match_data(), which falls back to it.
>
> Fixes: 21fd3b1373f6 ("iio: proximity: sx9310: Convert enum->pointer for match data table")
> Cc: stable <stable@xxxxxxxxxx>
> Cc: Jonathan Cameron <jic23@xxxxxxxxxx>
> Cc: David Lechner <dlechner@xxxxxxxxxxxx>
> Cc: "Nuno Sá" <nuno.sa@xxxxxxxxxx>
> Cc: Andy Shevchenko <andy@xxxxxxxxxx>
> Cc: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@xxxxxxxxxxxx>
> Cc: Siratul Islam <email@xxxxxxxx>
> Cc: Matti Vaittinen <mazziesaccount@xxxxxxxxx>
> Cc: Biju Das <biju.das.jz@xxxxxxxxxxxxxx>
> Cc: Stephen Boyd <swboyd@xxxxxxxxxxxx>
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> ---
> drivers/iio/proximity/sx9310.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/proximity/sx9310.c b/drivers/iio/proximity/sx9310.c index
> 79ba46d8a0aa..2585b9c6fb69 100644
> --- a/drivers/iio/proximity/sx9310.c
> +++ b/drivers/iio/proximity/sx9310.c
> @@ -891,7 +891,7 @@ static int sx9310_check_whoami(struct device *dev,
> if (ret)
> return ret;
>
> - ddata = device_get_match_data(dev);
> + ddata = i2c_get_match_data(data->client);
> if (ddata->whoami != whoami)
> return -ENODEV;
>
>
> --
> 2.56.0