diff mbox

[U-Boot,v3,5/5] sandbox: Find keyboard driver using driver model

Message ID 1466379196-12252-5-git-send-email-sjg@chromium.org
State Accepted
Commit 920c6965d11137fff45feccee7e1108875b196d0
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass June 19, 2016, 11:33 p.m. UTC
The cros-ec keyboard is always a child of the cros-ec node. Rather than
searching the device tree, looking at the children. Remove the compat string
which is now unused.

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

Changes in v3:
- Add new patch to find keyboard driver using driver model

 drivers/misc/cros_ec_sandbox.c | 11 ++++++++++-
 include/fdtdec.h               |  1 -
 lib/fdtdec.c                   |  1 -
 3 files changed, 10 insertions(+), 3 deletions(-)

Comments

Simon Glass July 3, 2016, 11:26 p.m. UTC | #1
On 19 June 2016 at 17:33, Simon Glass <sjg@chromium.org> wrote:
> The cros-ec keyboard is always a child of the cros-ec node. Rather than
> searching the device tree, looking at the children. Remove the compat string
> which is now unused.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v3:
> - Add new patch to find keyboard driver using driver model
>
>  drivers/misc/cros_ec_sandbox.c | 11 ++++++++++-
>  include/fdtdec.h               |  1 -
>  lib/fdtdec.c                   |  1 -
>  3 files changed, 10 insertions(+), 3 deletions(-)

Applied to u-boot-dm/next.
diff mbox

Patch

diff --git a/drivers/misc/cros_ec_sandbox.c b/drivers/misc/cros_ec_sandbox.c
index 98f19a6..c4fbca0 100644
--- a/drivers/misc/cros_ec_sandbox.c
+++ b/drivers/misc/cros_ec_sandbox.c
@@ -517,6 +517,7 @@  int cros_ec_probe(struct udevice *dev)
 	struct ec_state *ec = dev->priv;
 	struct cros_ec_dev *cdev = dev->uclass_priv;
 	const void *blob = gd->fdt_blob;
+	struct udevice *keyb_dev;
 	int node;
 	int err;
 
@@ -525,7 +526,15 @@  int cros_ec_probe(struct udevice *dev)
 	if (err)
 		return err;
 
-	node = fdtdec_next_compatible(blob, 0, COMPAT_GOOGLE_CROS_EC_KEYB);
+	node = -1;
+	for (device_find_first_child(dev, &keyb_dev);
+	     keyb_dev;
+	     device_find_next_child(&keyb_dev)) {
+		if (device_get_uclass_id(keyb_dev) == UCLASS_KEYBOARD) {
+			node = keyb_dev->of_offset;
+			break;
+		}
+	}
 	if (node < 0) {
 		debug("%s: No cros_ec keyboard found\n", __func__);
 	} else if (keyscan_read_fdt_matrix(ec, blob, node)) {
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 8ce98a3..1be87cd 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -137,7 +137,6 @@  enum fdt_compat_id {
 	COMPAT_SAMSUNG_S3C2440_I2C,	/* Exynos I2C Controller */
 	COMPAT_SAMSUNG_EXYNOS5_SOUND,	/* Exynos Sound */
 	COMPAT_WOLFSON_WM8994_CODEC,	/* Wolfson WM8994 Sound Codec */
-	COMPAT_GOOGLE_CROS_EC_KEYB,	/* Google CROS_EC Keyboard */
 	COMPAT_SAMSUNG_EXYNOS_USB_PHY,	/* Exynos phy controller for usb2.0 */
 	COMPAT_SAMSUNG_EXYNOS5_USB3_PHY,/* Exynos phy controller for usb3.0 */
 	COMPAT_SAMSUNG_EXYNOS_TMU,	/* Exynos TMU */
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index b79be59..eb2d508 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -47,7 +47,6 @@  static const char * const compat_names[COMPAT_COUNT] = {
 	COMPAT(SAMSUNG_S3C2440_I2C, "samsung,s3c2440-i2c"),
 	COMPAT(SAMSUNG_EXYNOS5_SOUND, "samsung,exynos-sound"),
 	COMPAT(WOLFSON_WM8994_CODEC, "wolfson,wm8994-codec"),
-	COMPAT(GOOGLE_CROS_EC_KEYB, "google,cros-ec-keyb"),
 	COMPAT(SAMSUNG_EXYNOS_USB_PHY, "samsung,exynos-usb-phy"),
 	COMPAT(SAMSUNG_EXYNOS5_USB3_PHY, "samsung,exynos5250-usb3-phy"),
 	COMPAT(SAMSUNG_EXYNOS_TMU, "samsung,exynos-tmu"),