]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pinctrl: qcom: Fix resolving register base address from device node
authorSneh Mankad <sneh.mankad@oss.qualcomm.com>
Fri, 29 May 2026 12:55:45 +0000 (18:25 +0530)
committerLinus Walleij <linusw@kernel.org>
Mon, 8 Jun 2026 19:30:53 +0000 (21:30 +0200)
Commit 56ffb63749f4 ("pinctrl: qcom: add multi TLMM region option parameter")
added reg-names property based register reading. However multiple platforms
are not using the reg-names as they have only single TLMM register region.

Commit tried to handle this using the default_region module parameter,
however this condition is unreachable as the error return precedes it by
just checking if reg-names property exists or not, making it impossible
to use tlmm-test for the SoCs (x1e80100) which don't have reg-names
property in TLMM device.

Fix this by moving the default_region check at the start of the
tlmm_reg_base().

Fixes: 56ffb63749f4 ("pinctrl: qcom: add multi TLMM region option parameter")
Signed-off-by: Sneh Mankad <sneh.mankad@oss.qualcomm.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Linus Walleij <linusw@kernel.org>
drivers/pinctrl/qcom/tlmm-test.c

index b655de5b4c5f08e7b138f0da24546274bc5fa93b..007d6539ceced294e81cfbe93a00c75a98c858de 100644 (file)
@@ -581,6 +581,9 @@ static int tlmm_reg_base(struct device_node *tlmm, struct resource *res)
        int ret;
        int i;
 
+       if (!strcmp(tlmm_reg_name, "default_region"))
+               return of_address_to_resource(tlmm, 0, res);
+
        count = of_property_count_strings(tlmm, "reg-names");
        if (count <= 0) {
                pr_err("failed to find tlmm reg name\n");
@@ -597,18 +600,14 @@ static int tlmm_reg_base(struct device_node *tlmm, struct resource *res)
                return -EINVAL;
        }
 
-       if (!strcmp(tlmm_reg_name, "default_region")) {
-               ret = of_address_to_resource(tlmm, 0, res);
-       } else {
-               for (i = 0; i < count; i++) {
-                       if (!strcmp(reg_names[i], tlmm_reg_name)) {
-                               ret = of_address_to_resource(tlmm, i, res);
-                               break;
-                       }
+       for (i = 0; i < count; i++) {
+               if (!strcmp(reg_names[i], tlmm_reg_name)) {
+                       ret = of_address_to_resource(tlmm, i, res);
+                       break;
                }
-               if (i == count)
-                       ret = -EINVAL;
        }
+       if (i == count)
+               ret = -EINVAL;
 
        kfree(reg_names);