[U-Boot] [PATCH 05/28] cros_ec: Use udevice instead of cros_ec_dev for keyboard functions

Simon Glass sjg at chromium.org
Wed Sep 9 06:32:28 CEST 2015


In preparation for converting the cros_ec keyboard driver to driver model,
adjust the cros_ec functions it will use to use a normal struct udevice.

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

 drivers/input/cros_ec_keyb.c |  4 ++--
 drivers/misc/cros_ec.c       | 14 +++++++++-----
 include/cros_ec.h            |  4 ++--
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/input/cros_ec_keyb.c b/drivers/input/cros_ec_keyb.c
index eaab86f..88397b0 100644
--- a/drivers/input/cros_ec_keyb.c
+++ b/drivers/input/cros_ec_keyb.c
@@ -54,7 +54,7 @@ static int check_for_keys(struct keyb *config,
 	unsigned int row, col, bit, data;
 	int num_keys;
 
-	if (cros_ec_scan_keyboard(config->dev, &scan)) {
+	if (cros_ec_scan_keyboard(config->dev->dev, &scan)) {
 		debug("%s: keyboard scan failed\n", __func__);
 		return -EIO;
 	}
@@ -139,7 +139,7 @@ int cros_ec_kbc_check(struct input_config *input)
 	 * may return 0 before all keys have been read from the EC.
 	 */
 	do {
-		irq_pending = cros_ec_interrupt_pending(config.dev);
+		irq_pending = cros_ec_interrupt_pending(config.dev->dev);
 		if (irq_pending) {
 			num_keys = check_for_keys(&config, keys, KBC_MAX_KEYS,
 						  &same);
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c
index ba36795..e3229ef 100644
--- a/drivers/misc/cros_ec.c
+++ b/drivers/misc/cros_ec.c
@@ -358,9 +358,11 @@ static int ec_command(struct cros_ec_dev *dev, uint8_t cmd, int cmd_version,
 	return len;
 }
 
-int cros_ec_scan_keyboard(struct cros_ec_dev *dev, struct mbkp_keyscan *scan)
+int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan)
 {
-	if (ec_command(dev, EC_CMD_MKBP_STATE, 0, NULL, 0, scan,
+	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
+
+	if (ec_command(cdev, EC_CMD_MKBP_STATE, 0, NULL, 0, scan,
 		       sizeof(scan->data)) != sizeof(scan->data))
 		return -1;
 
@@ -549,13 +551,15 @@ int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,
 	return 0;
 }
 
-int cros_ec_interrupt_pending(struct cros_ec_dev *dev)
+int cros_ec_interrupt_pending(struct udevice *dev)
 {
+	struct cros_ec_dev *cdev = dev_get_uclass_priv(dev);
+
 	/* no interrupt support : always poll */
-	if (!dm_gpio_is_valid(&dev->ec_int))
+	if (!dm_gpio_is_valid(&cdev->ec_int))
 		return -ENOENT;
 
-	return dm_gpio_get_value(&dev->ec_int);
+	return dm_gpio_get_value(&cdev->ec_int);
 }
 
 int cros_ec_info(struct cros_ec_dev *dev, struct ec_response_mkbp_info *info)
diff --git a/include/cros_ec.h b/include/cros_ec.h
index b926934..5fa5f6f 100644
--- a/include/cros_ec.h
+++ b/include/cros_ec.h
@@ -81,7 +81,7 @@ int cros_ec_read_id(struct cros_ec_dev *dev, char *id, int maxlen);
  * @param scan		Place to put the scan results
  * @return 0 if ok, -1 on error
  */
-int cros_ec_scan_keyboard(struct cros_ec_dev *dev, struct mbkp_keyscan *scan);
+int cros_ec_scan_keyboard(struct udevice *dev, struct mbkp_keyscan *scan);
 
 /**
  * Read which image is currently running on the CROS-EC device.
@@ -125,7 +125,7 @@ int cros_ec_reboot(struct cros_ec_dev *dev, enum ec_reboot_cmd cmd,
  * @param dev		CROS-EC device
  * @return 0 if no interrupt is pending
  */
-int cros_ec_interrupt_pending(struct cros_ec_dev *dev);
+int cros_ec_interrupt_pending(struct udevice *dev);
 
 enum {
 	CROS_EC_OK,
-- 
2.6.0.rc0.131.gf624c3d



More information about the U-Boot mailing list