diff mbox series

[v2,04/17] tegra: i2c: Change driver to use helper function

Message ID 20200204001945.234347-5-sjg@chromium.org
State Superseded
Headers show
Series x86: coral: Add support for Cr50 | expand

Commit Message

Simon Glass Feb. 4, 2020, 12:19 a.m. UTC
Now that we have uclass_first_device_drvdata(), use it from the I2C driver
to reduce code duplication.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v2:
- Add new patch to change tegra driver to use helper function

 drivers/i2c/tegra_i2c.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

Comments

Heiko Schocher Feb. 4, 2020, 5:17 a.m. UTC | #1
Hello Simon,

Am 04.02.2020 um 01:19 schrieb Simon Glass:
> Now that we have uclass_first_device_drvdata(), use it from the I2C driver
> to reduce code duplication.
> 
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
> 
> Changes in v2:
> - Add new patch to change tegra driver to use helper function
> 
>   drivers/i2c/tegra_i2c.c | 13 +------------
>   1 file changed, 1 insertion(+), 12 deletions(-)

Reviewed-by: Heiko Schocher <hs at denx.de>

bye,
Heiko
Bin Meng Feb. 4, 2020, 7:32 a.m. UTC | #2
On Tue, Feb 4, 2020 at 8:20 AM Simon Glass <sjg at chromium.org> wrote:
>
> Now that we have uclass_first_device_drvdata(), use it from the I2C driver
> to reduce code duplication.
>
> Signed-off-by: Simon Glass <sjg at chromium.org>
> ---
>
> Changes in v2:
> - Add new patch to change tegra driver to use helper function
>
>  drivers/i2c/tegra_i2c.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>
diff mbox series

Patch

diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 4be41ddbf0..142463ef44 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -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 = {