Skip to content

Commit 9a61442

Browse files
committed
Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux
Pull clk fixes from Stephen Boyd: "Here's a collection of primarily clk driver fixes, with a couple fixes to the core framework. We had to revert out a commit that affected boot on some devices that have the CLK_OPS_PARENT_ENABLE flag set. It isn't critical to have that fix so we'll try again next time. Driver side fixes include: - Plug an OF-node refcount bug in the TI clk driver - Fix the error handling in the raspberry pi firmware get_rate so that errors don't look like valid frequencies - Avoid going out of bounds in the raspberry pi driver too if the video firmware returns something we're not expecting" * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux: Revert "clk: core: Honor CLK_OPS_PARENT_ENABLE for clk gate ops" clk: bcm: rpi: Show clock id limit in error case clk: bcm: rpi: Add missing newline clk: bcm: rpi: Prevent out-of-bounds access clk: bcm: rpi: Fix error handling of raspberrypi_fw_get_rate clk: core: Fix runtime PM sequence in clk_core_unprepare() clk: core: Honor CLK_OPS_PARENT_ENABLE for clk gate ops clk: ti: Fix missing of_node_get() ti_find_clock_provider()
2 parents 7774642 + abb5f3f commit 9a61442

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

drivers/clk/bcm/clk-raspberrypi.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static unsigned long raspberrypi_fw_get_rate(struct clk_hw *hw,
203203
ret = raspberrypi_clock_property(rpi->firmware, data,
204204
RPI_FIRMWARE_GET_CLOCK_RATE, &val);
205205
if (ret)
206-
return ret;
206+
return 0;
207207

208208
return val;
209209
}
@@ -220,7 +220,7 @@ static int raspberrypi_fw_set_rate(struct clk_hw *hw, unsigned long rate,
220220
ret = raspberrypi_clock_property(rpi->firmware, data,
221221
RPI_FIRMWARE_SET_CLOCK_RATE, &_rate);
222222
if (ret)
223-
dev_err_ratelimited(rpi->dev, "Failed to change %s frequency: %d",
223+
dev_err_ratelimited(rpi->dev, "Failed to change %s frequency: %d\n",
224224
clk_hw_get_name(hw), ret);
225225

226226
return ret;
@@ -288,7 +288,7 @@ static struct clk_hw *raspberrypi_clk_register(struct raspberrypi_clk *rpi,
288288
RPI_FIRMWARE_GET_MIN_CLOCK_RATE,
289289
&min_rate);
290290
if (ret) {
291-
dev_err(rpi->dev, "Failed to get clock %d min freq: %d",
291+
dev_err(rpi->dev, "Failed to get clock %d min freq: %d\n",
292292
id, ret);
293293
return ERR_PTR(ret);
294294
}
@@ -344,8 +344,13 @@ static int raspberrypi_discover_clocks(struct raspberrypi_clk *rpi,
344344
struct rpi_firmware_get_clocks_response *clks;
345345
int ret;
346346

347+
/*
348+
* The firmware doesn't guarantee that the last element of
349+
* RPI_FIRMWARE_GET_CLOCKS is zeroed. So allocate an additional
350+
* zero element as sentinel.
351+
*/
347352
clks = devm_kcalloc(rpi->dev,
348-
RPI_FIRMWARE_NUM_CLK_ID, sizeof(*clks),
353+
RPI_FIRMWARE_NUM_CLK_ID + 1, sizeof(*clks),
349354
GFP_KERNEL);
350355
if (!clks)
351356
return -ENOMEM;
@@ -360,7 +365,8 @@ static int raspberrypi_discover_clocks(struct raspberrypi_clk *rpi,
360365
struct raspberrypi_clk_variant *variant;
361366

362367
if (clks->id > RPI_FIRMWARE_NUM_CLK_ID) {
363-
dev_err(rpi->dev, "Unknown clock id: %u", clks->id);
368+
dev_err(rpi->dev, "Unknown clock id: %u (max: %u)\n",
369+
clks->id, RPI_FIRMWARE_NUM_CLK_ID);
364370
return -EINVAL;
365371
}
366372

drivers/clk/clk.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,10 +840,9 @@ static void clk_core_unprepare(struct clk_core *core)
840840
if (core->ops->unprepare)
841841
core->ops->unprepare(core->hw);
842842

843-
clk_pm_runtime_put(core);
844-
845843
trace_clk_unprepare_complete(core);
846844
clk_core_unprepare(core->parent);
845+
clk_pm_runtime_put(core);
847846
}
848847

849848
static void clk_core_unprepare_lock(struct clk_core *core)

drivers/clk/ti/clk.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ static struct device_node *ti_find_clock_provider(struct device_node *from,
135135
continue;
136136

137137
if (!strncmp(n, tmp, strlen(tmp))) {
138+
of_node_get(np);
138139
found = true;
139140
break;
140141
}

0 commit comments

Comments
 (0)