From 61d1a82e00491a5d7ee28895aacfca26972d2b32 Mon Sep 17 00:00:00 2001 From: zhuwg1 Date: Fri, 21 Jan 2022 17:00:44 +0800 Subject: [PATCH] Use of_ API to parse gpio pin number TP: Use of_ API to parse gpio pin number. Change-Id: I82fb037012135c430c0de5610638f99bfa58b844 Signed-off-by: zhuwg1 Reviewed-on: https://gerrit.mot.com/2176491 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: litong Reviewed-by: Jianqi Yang Submit-Approved: Jira Key --- .../parade_tma5xx_mmi/cyttsp5_devtree.c | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_devtree.c b/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_devtree.c index b1bb1381e0c7..279e62ef584f 100644 --- a/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_devtree.c +++ b/drivers/input/touchscreen/parade_tma5xx_mmi/cyttsp5_devtree.c @@ -30,6 +30,7 @@ #include #include #include +#include /* cyttsp */ #include "cyttsp5_regs.h" @@ -554,10 +555,13 @@ static struct cyttsp5_core_platform_data *create_and_get_core_pdata( } /* Required fields */ - rc = of_property_read_u32(core_node, "cy,irq_gpio", &value); - if (rc) + rc = of_get_named_gpio(core_node, "cy,irq_gpio", 0); + if (!gpio_is_valid(rc)) { + pdata->irq_gpio = -EINVAL; + pr_err("%s, invalid irq-gpio in dt: %d", __func__, rc); goto fail_free; - pdata->irq_gpio = value; + } + pdata->irq_gpio = rc; rc = of_property_read_u32(core_node, "cy,hid_desc_register", &value); if (rc) @@ -568,9 +572,13 @@ static struct cyttsp5_core_platform_data *create_and_get_core_pdata( /* rst_gpio is optional since a platform may use * power cycling instead of using the XRES pin */ - rc = of_property_read_u32(core_node, "cy,rst_gpio", &value); - if (!rc) - pdata->rst_gpio = value; + rc = of_get_named_gpio(core_node, "cy,rst_gpio", 0); + if (!gpio_is_valid(rc)) { + pdata->rst_gpio = -EINVAL; + pr_err("%s, invalid rst-gpio in dt: %d", __func__, rc); + goto fail_free; + } + pdata->rst_gpio = rc; rc = of_property_read_u32(core_node, "cy,level_irq_udelay", &value); if (!rc)