diff mbox series

[V2,1/2] board: samsung: covert to driver model about power_key_pressed

Message ID 20210222222823.15627-2-jh80.chung@samsung.com
State Accepted
Commit 579d819971b9e33a8fdc5e509e864ba58458a11c
Delegated to: Minkyu Kang
Headers show
Series power: remove non-DM max8997/8 files | expand

Commit Message

Jaehoon Chung Feb. 22, 2021, 10:28 p.m. UTC
Convert to driver model about power_key_pressed.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 board/samsung/common/misc.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/board/samsung/common/misc.c b/board/samsung/common/misc.c
index d48ba7eaf0b0..b3b1bbcc820a 100644
--- a/board/samsung/common/misc.c
+++ b/board/samsung/common/misc.c
@@ -117,32 +117,33 @@  void set_board_info(void)
 #ifdef CONFIG_LCD_MENU
 static int power_key_pressed(u32 reg)
 {
-#if !CONFIG_IS_ENABLED(DM_I2C) /* TODO(maintainer): Convert to driver model */
-	struct pmic *pmic;
+	struct udevice *dev;
+	int ret;
 	u32 status;
 	u32 mask;
 
-	pmic = pmic_get(KEY_PWR_PMIC_NAME);
-	if (!pmic) {
-		printf("%s: Not found\n", KEY_PWR_PMIC_NAME);
+	if (IS_ENABLED(CONFIG_TARGET_TRATS))
+		ret = pmic_get("max8997-pmic", &dev);
+	else if (IS_ENABLED(CONFIG_TARGET_TRATS2))
+		ret = pmic_get("max77686-pmic", &dev);
+	else if (IS_ENABLED(CONFIG_TARGET_S5PC210_UNIVERSAL))
+		ret = pmic_get("max8998-pmic", &dev);
+	else
 		return 0;
-	}
 
-	if (pmic_probe(pmic))
-		return 0;
+	if (ret)
+		return ret;
 
 	if (reg == KEY_PWR_STATUS_REG)
 		mask = KEY_PWR_STATUS_MASK;
 	else
 		mask = KEY_PWR_INTERRUPT_MASK;
 
-	if (pmic_reg_read(pmic, reg, &status))
-		return 0;
+	status = pmic_reg_read(dev, reg);
+	if (status < 0)
+		return status;
 
 	return !!(status & mask);
-#else
-	return 0;
-#endif
 }
 
 static int key_pressed(int key)