iio: dac: ad5593r: add check for i2c functionality
authorNuno Sá <nuno.sa@analog.com>
Tue, 13 Sep 2022 07:34:13 +0000 (09:34 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 21 Sep 2022 17:42:53 +0000 (18:42 +0100)
Make sure that the needed i2c functionality is supported during probe.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Link: https://lore.kernel.org/r/20220913073413.140475-3-nuno.sa@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/dac/ad5593r.c

index 356dc0bab1153d4bd83497c401d81d4538986abc..420981e7c5c3ff9a1b1b7dc94e9e79055258eb06 100644 (file)
@@ -102,6 +102,10 @@ static const struct ad5592r_rw_ops ad5593r_rw_ops = {
 static int ad5593r_i2c_probe(struct i2c_client *i2c,
                const struct i2c_device_id *id)
 {
+       if (!i2c_check_functionality(i2c->adapter,
+                                    I2C_FUNC_SMBUS_BYTE | I2C_FUNC_I2C))
+               return -EOPNOTSUPP;
+
        return ad5592r_probe(&i2c->dev, id->name, &ad5593r_rw_ops);
 }