[U-Boot,09/25] sandbox: cros_ec: exynos: Drop use of cros_ec_get_error()

Message ID 20181106222142.94537-10-sjg@chromium.org
State New
Delegated to: Simon Glass
Headers show
Series
  • sandbox: Changes and improvements to support verified boot
Related show

Commit Message

Simon Glass Nov. 6, 2018, 10:21 p.m.
This function is really just a call to uclass_get_device() and there is no
reason why the caller cannot do it. Update sandbox and snow accordingly.

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

 board/samsung/common/board.c | 10 ++++++----
 board/sandbox/sandbox.c      |  9 ++++++---
 common/cros_ec.c             | 12 ------------
 3 files changed, 12 insertions(+), 19 deletions(-)

Comments

Minkyu Kang Nov. 7, 2018, 2:27 a.m. | #1
On 07/11/18 07:21, Simon Glass wrote:
> This function is really just a call to uclass_get_device() and there is no
> reason why the caller cannot do it. Update sandbox and snow accordingly.
> 
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
> 
>  board/samsung/common/board.c | 10 ++++++----
>  board/sandbox/sandbox.c      |  9 ++++++---
>  common/cros_ec.c             | 12 ------------
>  3 files changed, 12 insertions(+), 19 deletions(-)
> 

Acked-by: Minkyu Kang <mk7.kang@samsung.com>

Thanks,
Minkyu Kang.

Patch

diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
index c4b6baedf04..fc2a219e384 100644
--- a/board/samsung/common/board.c
+++ b/board/samsung/common/board.c
@@ -306,14 +306,16 @@  int checkboard(void)
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
-	stdio_print_current_devices();
+	struct udevice *dev;
+	int ret;
 
-	if (cros_ec_get_error()) {
+	stdio_print_current_devices();
+	ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
+	if (ret) {
 		/* Force console on */
 		gd->flags &= ~GD_FLG_SILENT;
 
-		printf("cros-ec communications failure %d\n",
-		       cros_ec_get_error());
+		printf("cros-ec communications failure %d\n", ret);
 		puts("\nPlease reset with Power+Refresh\n\n");
 		panic("Cannot init cros-ec device");
 		return -1;
diff --git a/board/sandbox/sandbox.c b/board/sandbox/sandbox.c
index 0e87674826a..56b1005e374 100644
--- a/board/sandbox/sandbox.c
+++ b/board/sandbox/sandbox.c
@@ -59,12 +59,15 @@  int board_init(void)
 #ifdef CONFIG_BOARD_LATE_INIT
 int board_late_init(void)
 {
-	if (cros_ec_get_error()) {
+	struct udevice *dev;
+	int ret;
+
+	ret = uclass_first_device_err(UCLASS_CROS_EC, &dev);
+	if (ret) {
 		/* Force console on */
 		gd->flags &= ~GD_FLG_SILENT;
 
-		printf("cros-ec communications failure %d\n",
-		       cros_ec_get_error());
+		printf("cros-ec communications failure %d\n", ret);
 		puts("\nPlease reset with Power+Refresh\n\n");
 		panic("Cannot init cros-ec device");
 		return -1;
diff --git a/common/cros_ec.c b/common/cros_ec.c
index 4ca15e19d5f..e66471ebd1b 100644
--- a/common/cros_ec.c
+++ b/common/cros_ec.c
@@ -25,15 +25,3 @@  struct udevice *board_get_cros_ec_dev(void)
 	}
 	return dev;
 }
-
-int cros_ec_get_error(void)
-{
-	struct udevice *dev;
-	int ret;
-
-	ret = uclass_get_device(UCLASS_CROS_EC, 0, &dev);
-	if (ret && ret != -ENODEV)
-		return ret;
-
-	return 0;
-}