From patchwork Thu Feb 6 16:54:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 236022 List-Id: U-Boot discussion From: sjg at chromium.org (Simon Glass) Date: Thu, 6 Feb 2020 09:54:52 -0700 Subject: [PATCH v4 04/17] tegra: i2c: Change driver to use helper function In-Reply-To: <20200206165505.113435-1-sjg@chromium.org> References: <20200206165505.113435-1-sjg@chromium.org> Message-ID: <20200206165505.113435-5-sjg@chromium.org> Now that we have uclass_first_device_drvdata(), use it from the I2C driver to reduce code duplication. Signed-off-by: Simon Glass Reviewed-by: Heiko Schocher Reviewed-by: Bin Meng --- Changes in v4: None Changes in v3: None 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(-) 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 = {