]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tegra: i2c: Change driver to use helper function
authorSimon Glass <sjg@chromium.org>
Thu, 6 Feb 2020 16:54:52 +0000 (09:54 -0700)
committerBin Meng <bmeng.cn@gmail.com>
Fri, 7 Feb 2020 14:41:24 +0000 (22:41 +0800)
Now that we have uclass_first_device_drvdata(), use it from the I2C driver
to reduce code duplication.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/i2c/tegra_i2c.c

index 4be41ddbf057ce41335a61ff992f11320921c004..142463ef4405feb922f71dcb761c0e8e7c548ced 100644 (file)
@@ -499,18 +499,7 @@ static int tegra_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
 
 int tegra_i2c_get_dvc_bus(struct udevice **busp)
 {
-       struct udevice *bus;
-
-       for (uclass_first_device(UCLASS_I2C, &bus);
-            bus;
-            uclass_next_device(&bus)) {
-               if (dev_get_driver_data(bus) == TYPE_DVC) {
-                       *busp = bus;
-                       return 0;
-               }
-       }
-
-       return -ENODEV;
+       return uclass_first_device_drvdata(UCLASS_I2C, TYPE_DVC, busp);
 }
 
 static const struct dm_i2c_ops tegra_i2c_ops = {