diff mbox series

clk: bcm: rpi: Fix error handling of raspberrypi_fw_get_rate

Message ID 20220625083643.4012-1-stefan.wahren@i2se.com (mailing list archive)
State Accepted, archived
Headers show
Series clk: bcm: rpi: Fix error handling of raspberrypi_fw_get_rate | expand

Commit Message

Stefan Wahren June 25, 2022, 8:36 a.m. UTC
The function raspberrypi_fw_get_rate (e.g. used for the recalc_rate
hook) can fail to get the clock rate from the firmware. In this case
we cannot return a signed error value, which would be casted to
unsigned long. Fix this by returning 0 instead.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
 drivers/clk/bcm/clk-raspberrypi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Florian Fainelli June 27, 2022, 4:24 p.m. UTC | #1
On 6/25/22 01:36, Stefan Wahren wrote:
> The function raspberrypi_fw_get_rate (e.g. used for the recalc_rate
> hook) can fail to get the clock rate from the firmware. In this case
> we cannot return a signed error value, which would be casted to
> unsigned long. Fix this by returning 0 instead.
> 
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>

Fixes: 4e85e535e6cc ("clk: bcm283x: add driver interfacing with 
Raspberry Pi's firmware")

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Stefan Wahren Aug. 5, 2022, 8:32 a.m. UTC | #2
Am 27.06.22 um 18:24 schrieb Florian Fainelli:
> On 6/25/22 01:36, Stefan Wahren wrote:
>> The function raspberrypi_fw_get_rate (e.g. used for the recalc_rate
>> hook) can fail to get the clock rate from the firmware. In this case
>> we cannot return a signed error value, which would be casted to
>> unsigned long. Fix this by returning 0 instead.
>>
>> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
>
> Fixes: 4e85e535e6cc ("clk: bcm283x: add driver interfacing with 
> Raspberry Pi's firmware")
>
> Acked-by: Florian Fainelli <f.fainelli@gmail.com>

gentle ping
Stephen Boyd Aug. 23, 2022, 2:17 a.m. UTC | #3
Quoting Stefan Wahren (2022-06-25 01:36:43)
> The function raspberrypi_fw_get_rate (e.g. used for the recalc_rate
> hook) can fail to get the clock rate from the firmware. In this case
> we cannot return a signed error value, which would be casted to
> unsigned long. Fix this by returning 0 instead.
> 
> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
> ---

Applied to clk-fixes
diff mbox series

Patch

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index 73518009a0f2..39d63c983d62 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -203,7 +203,7 @@  static unsigned long raspberrypi_fw_get_rate(struct clk_hw *hw,
 	ret = raspberrypi_clock_property(rpi->firmware, data,
 					 RPI_FIRMWARE_GET_CLOCK_RATE, &val);
 	if (ret)
-		return ret;
+		return 0;
 
 	return val;
 }