]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
bus: ti-sysc: Fix getting optional clocks in clock_roles
authorTony Lindgren <tony@atomide.com>
Thu, 15 Nov 2018 22:46:52 +0000 (14:46 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Dec 2019 07:51:23 +0000 (08:51 +0100)
[ Upstream commit 7b4f8ac2f1acdff3c0cce23d8c3b86434a6e768a ]

We can have holes in clock_roles with interface clock missing for
example. Currently getting an optional clock will fail if there are
only a functional clock and an optional clock.

Fixes: 09dfe5810762 ("bus: ti-sysc: Add handling for clkctrl opt clocks")
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/bus/ti-sysc.c

index 5b31131d0cba20c211566ed7f7af510646929aff..b6f63e7620214a7baf02fc491ea7fe118204958f 100644 (file)
@@ -217,8 +217,13 @@ static int sysc_get_clocks(struct sysc *ddata)
        if (!ddata->clocks)
                return -ENOMEM;
 
-       for (i = 0; i < ddata->nr_clocks; i++) {
-               error = sysc_get_one_clock(ddata, ddata->clock_roles[i]);
+       for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
+               const char *name = ddata->clock_roles[i];
+
+               if (!name)
+                       continue;
+
+               error = sysc_get_one_clock(ddata, name);
                if (error && error != -ENOENT)
                        return error;
        }