diff mbox series

[1/2] board: gateworks: venice: fix gsc_get_dev

Message ID 20210308215236.27722-1-tharvey@gateworks.com
State Accepted
Commit bb32c2a617673ff14970399e5519de0400614baf
Delegated to: Stefano Babic
Headers show
Series [1/2] board: gateworks: venice: fix gsc_get_dev | expand

Commit Message

Tim Harvey March 8, 2021, 9:52 p.m. UTC
use dm_i2c_probe instead of i2c_get_chip which appears to be more
reliable.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
 board/gateworks/venice/gsc.c | 23 ++++++-----------------
 1 file changed, 6 insertions(+), 17 deletions(-)

Comments

Fabio Estevam March 9, 2021, 12:04 p.m. UTC | #1
Hi Tim,

On Mon, Mar 8, 2021 at 6:52 PM Tim Harvey <tharvey@gateworks.com> wrote:
>
> use dm_i2c_probe instead of i2c_get_chip which appears to be more
> reliable.
>
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>

Reviewed-by: Fabio Estevam <festevam@gmail.com>
Stefano Babic April 8, 2021, 8:58 p.m. UTC | #2
> use dm_i2c_probe instead of i2c_get_chip which appears to be more
> reliable.
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
> Reviewed-by: Fabio Estevam <festevam@gmail.com>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/board/gateworks/venice/gsc.c b/board/gateworks/venice/gsc.c
index ad3f8d95d9..d2490e6063 100644
--- a/board/gateworks/venice/gsc.c
+++ b/board/gateworks/venice/gsc.c
@@ -125,29 +125,18 @@  enum {
 
 static struct udevice *gsc_get_dev(int busno, int slave)
 {
-	struct udevice *dev;
+	static const char * const i2c[] = { "i2c@30a20000", "i2c@30a30000" };
+	struct udevice *dev, *bus;
 	int ret;
 
-#if (IS_ENABLED(CONFIG_SPL_BUILD))
-	ret = i2c_get_chip_for_busnum(busno + 1, slave, 1, &dev);
-	if (ret)
-		return NULL;
-#else
-	struct udevice *bus;
-
-	busno--;
-
-	ret = uclass_get_device_by_seq(UCLASS_I2C, busno, &bus);
+	ret = uclass_get_device_by_name(UCLASS_I2C, i2c[busno - 1], &bus);
 	if (ret) {
-		printf("i2c%d: no bus %d\n", busno + 1, ret);
+		printf("GSC     : failed I2C%d probe: %d\n", busno, ret);
 		return NULL;
 	}
-	ret = i2c_get_chip(bus, slave, 1, &dev);
-	if (ret) {
-		printf("i2c%d@0x%02x: no chip %d\n", busno + 1, slave, ret);
+	ret = dm_i2c_probe(bus, slave, 0, &dev);
+	if (ret)
 		return NULL;
-	}
-#endif
 
 	return dev;
 }