* [PATCH 0/2] firmware: raspberrypi: Handle device registration errors @ 2026-09-19 3:48 Triet Hoang 2026-09-19 3:48 ` [PATCH 1/2] " Triet Hoang 2026-09-19 3:48 ` [PATCH 2/2] firmware: raspberrypi: Clean up local formatting Triet Hoang 0 siblings, 2 replies; 9+ messages in thread From: Triet Hoang @ 2026-09-19 3:48 UTC (permalink / raw) To: Florian Fainelli Cc: Broadcom internal kernel review list, linux-rpi-kernel, linux-arm-kernel, linux-kernel, Stefan Wahren, Triet Hoang Hi, This series improves error handling when registering the Raspberry Pi firmware hwmon and clock platform devices. The first patch checks errors returned by platform_device_register_data() and unwinds previously allocated resources when registration fails. It preserves the existing behavior of skipping hwmon registration when the RPI_FIRMWARE_GET_THROTTLED request fails. The second patch fixes formatting issues reported by checkpatch. Triet Hoang (2): firmware: raspberrypi: Handle device registration errors firmware: raspberrypi: Clean up local formatting drivers/firmware/raspberrypi.c | 60 ++++++++++++++++++++++++++-------- 1 file changed, 46 insertions(+), 14 deletions(-) -- 2.53.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] firmware: raspberrypi: Handle device registration errors 2026-09-19 3:48 [PATCH 0/2] firmware: raspberrypi: Handle device registration errors Triet Hoang @ 2026-09-19 3:48 ` Triet Hoang 2026-09-19 16:05 ` Stefan Wahren 2026-09-19 3:48 ` [PATCH 2/2] firmware: raspberrypi: Clean up local formatting Triet Hoang 1 sibling, 1 reply; 9+ messages in thread From: Triet Hoang @ 2026-09-19 3:48 UTC (permalink / raw) To: Florian Fainelli Cc: Broadcom internal kernel review list, linux-rpi-kernel, linux-arm-kernel, linux-kernel, Stefan Wahren, Triet Hoang Check the return value of platform_device_register_data() when registering the hwmon and clock devices. Propagate registration failures to the firmware probe instead of silently ignoring them. Use local platform device pointers so the global pointers are only updated after successful registration. If clock registration fails, unregister the previously registered hwmon device before releasing the firmware instance. Keep the existing behavior of skipping hwmon registration when the RPI_FIRMWARE_GET_THROTTLED request fails. Fixes: 70eea1bbb556 ("firmware: raspberrypi: Register hwmon driver") Fixes: 91f2cf4a6b21 ("firmware: raspberrypi: register clk device") Signed-off-by: Triet Hoang <triet.hoang.dev@gmail.com> --- drivers/firmware/raspberrypi.c | 57 ++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 0aa322e9a2e7..88c3de9ce67a 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -197,22 +197,31 @@ rpi_firmware_print_firmware_revision(struct rpi_firmware *fw) dev_info(fw->cl.dev, "Attached to firmware from %ptT\n", &date_and_time); } -static void +static int rpi_register_hwmon_driver(struct device *dev, struct rpi_firmware *fw) { + struct platform_device *pdev; u32 packet; - int ret = rpi_firmware_property(fw, RPI_FIRMWARE_GET_THROTTLED, - &packet, sizeof(packet)); + int ret; + ret = rpi_firmware_property(fw, RPI_FIRMWARE_GET_THROTTLED, + &packet, sizeof(packet)); if (ret) - return; + return 0; + + pdev = platform_device_register_data(dev, "raspberrypi-hwmon", + -1, NULL, 0); + if (IS_ERR(pdev)) + return PTR_ERR(pdev); - rpi_hwmon = platform_device_register_data(dev, "raspberrypi-hwmon", - -1, NULL, 0); + rpi_hwmon = pdev; + + return 0; } -static void rpi_register_clk_driver(struct device *dev) +static int rpi_register_clk_driver(struct device *dev) { + struct platform_device *pdev; struct device_node *firmware; /* @@ -224,11 +233,17 @@ static void rpi_register_clk_driver(struct device *dev) "raspberrypi,firmware-clocks"); if (firmware) { of_node_put(firmware); - return; + return 0; } - rpi_clk = platform_device_register_data(dev, "raspberrypi-clk", - -1, NULL, 0); + pdev = platform_device_register_data(dev, "raspberrypi-clk", + -1, NULL, 0); + if (IS_ERR(pdev)) + return PTR_ERR(pdev); + + rpi_clk = pdev; + + return 0; } unsigned int rpi_firmware_clk_get_max_rate(struct rpi_firmware *fw, unsigned int id) @@ -277,6 +292,7 @@ static int rpi_firmware_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct rpi_firmware *fw; + int ret; /* * Memory will be freed by rpi_firmware_delete() once all users have @@ -292,7 +308,7 @@ static int rpi_firmware_probe(struct platform_device *pdev) fw->chan = mbox_request_channel(&fw->cl, 0); if (IS_ERR(fw->chan)) { - int ret = PTR_ERR(fw->chan); + ret = PTR_ERR(fw->chan); kfree(fw); return dev_err_probe(dev, ret, "Failed to get mbox channel\n"); } @@ -303,10 +319,25 @@ static int rpi_firmware_probe(struct platform_device *pdev) platform_set_drvdata(pdev, fw); rpi_firmware_print_firmware_revision(fw); - rpi_register_hwmon_driver(dev, fw); - rpi_register_clk_driver(dev); + + ret = rpi_register_hwmon_driver(dev, fw); + if (ret) + goto err_put_fw; + + ret = rpi_register_clk_driver(dev); + if (ret) + goto err_unregister_hwmon; return 0; + +err_unregister_hwmon: + platform_device_unregister(rpi_hwmon); + rpi_hwmon = NULL; +err_put_fw: + platform_set_drvdata(pdev, NULL); + rpi_firmware_put(fw); + + return ret; } static void rpi_firmware_shutdown(struct platform_device *pdev) -- 2.53.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] firmware: raspberrypi: Handle device registration errors 2026-09-19 3:48 ` [PATCH 1/2] " Triet Hoang @ 2026-09-19 16:05 ` Stefan Wahren 0 siblings, 0 replies; 9+ messages in thread From: Stefan Wahren @ 2026-09-19 16:05 UTC (permalink / raw) To: Triet Hoang, Florian Fainelli Cc: Broadcom internal kernel review list, linux-rpi-kernel, linux-arm-kernel, linux-kernel Am 19.09.26 um 05:48 schrieb Triet Hoang: > Check the return value of platform_device_register_data() when > registering the hwmon and clock devices. Propagate registration failures > to the firmware probe instead of silently ignoring them. > > Use local platform device pointers so the global pointers are only > updated after successful registration. If clock registration fails, > unregister the previously registered hwmon device before releasing the > firmware instance. > > Keep the existing behavior of skipping hwmon registration when the > RPI_FIRMWARE_GET_THROTTLED request fails. > > Fixes: 70eea1bbb556 ("firmware: raspberrypi: Register hwmon driver") > Fixes: 91f2cf4a6b21 ("firmware: raspberrypi: register clk device") > Signed-off-by: Triet Hoang <triet.hoang.dev@gmail.com> Reviewed-by: Stefan Wahren <wahrenst@gmx.net> ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] firmware: raspberrypi: Clean up local formatting 2026-09-19 3:48 [PATCH 0/2] firmware: raspberrypi: Handle device registration errors Triet Hoang 2026-09-19 3:48 ` [PATCH 1/2] " Triet Hoang @ 2026-09-19 3:48 ` Triet Hoang 2026-09-19 16:06 ` Stefan Wahren 2026-09-22 14:22 ` Markus Elfring 1 sibling, 2 replies; 9+ messages in thread From: Triet Hoang @ 2026-09-19 3:48 UTC (permalink / raw) To: Florian Fainelli Cc: Broadcom internal kernel review list, linux-rpi-kernel, linux-arm-kernel, linux-kernel, Stefan Wahren, Triet Hoang Add a blank line after the local variable declaration in response_callback() and fix the indentation of the UINT_MAX return in rpi_firmware_clk_get_max_rate(). No functional change intended. Signed-off-by: Triet Hoang <triet.hoang.dev@gmail.com> --- drivers/firmware/raspberrypi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c index 88c3de9ce67a..1e98fc1457d1 100644 --- a/drivers/firmware/raspberrypi.c +++ b/drivers/firmware/raspberrypi.c @@ -39,6 +39,7 @@ static DEFINE_MUTEX(transaction_lock); static void response_callback(struct mbox_client *cl, void *msg) { struct rpi_firmware *fw = container_of(cl, struct rpi_firmware, cl); + complete(&fw->c); } @@ -260,7 +261,7 @@ unsigned int rpi_firmware_clk_get_max_rate(struct rpi_firmware *fw, unsigned int * assume the maximum clock rate is absolute maximum we can * store over our type. */ - return UINT_MAX; + return UINT_MAX; return le32_to_cpu(msg.rate); } -- 2.53.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] firmware: raspberrypi: Clean up local formatting 2026-09-19 3:48 ` [PATCH 2/2] firmware: raspberrypi: Clean up local formatting Triet Hoang @ 2026-09-19 16:06 ` Stefan Wahren 2026-09-22 14:22 ` Markus Elfring 1 sibling, 0 replies; 9+ messages in thread From: Stefan Wahren @ 2026-09-19 16:06 UTC (permalink / raw) To: Triet Hoang, Florian Fainelli Cc: Broadcom internal kernel review list, linux-rpi-kernel, linux-arm-kernel, linux-kernel Am 19.09.26 um 05:48 schrieb Triet Hoang: > Add a blank line after the local variable declaration in > response_callback() and fix the indentation of the UINT_MAX return in > rpi_firmware_clk_get_max_rate(). > > No functional change intended. > > Signed-off-by: Triet Hoang <triet.hoang.dev@gmail.com> Reviewed-by: Stefan Wahren <wahrenst@gmx.net> ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] firmware: raspberrypi: Clean up local formatting 2026-09-19 3:48 ` [PATCH 2/2] firmware: raspberrypi: Clean up local formatting Triet Hoang 2026-09-19 16:06 ` Stefan Wahren @ 2026-09-22 14:22 ` Markus Elfring 2026-10-02 15:13 ` Stefan Wahren 1 sibling, 1 reply; 9+ messages in thread From: Markus Elfring @ 2026-09-22 14:22 UTC (permalink / raw) To: Triet Hoang, linux-rpi-kernel, linux-arm-kernel, bcm-kernel-feedback-list, Florian Fainelli, Stefan Wahren Cc: LKML > Add a blank line after the local variable declaration in > response_callback() and fix the indentation of the UINT_MAX return in > rpi_firmware_clk_get_max_rate(). … See also: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.3-rc4#n88 Regards, Markus ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] firmware: raspberrypi: Clean up local formatting 2026-09-22 14:22 ` Markus Elfring @ 2026-10-02 15:13 ` Stefan Wahren 2026-10-03 11:17 ` [2/2] " Markus Elfring 0 siblings, 1 reply; 9+ messages in thread From: Stefan Wahren @ 2026-10-02 15:13 UTC (permalink / raw) To: Markus Elfring, Triet Hoang, linux-rpi-kernel, linux-arm-kernel, bcm-kernel-feedback-list, Florian Fainelli Cc: LKML Hi Markus, Am 22.09.26 um 16:22 schrieb Markus Elfring: >> Add a blank line after the local variable declaration in >> response_callback() and fix the indentation of the UINT_MAX return in >> rpi_firmware_clk_get_max_rate(). > … > > See also: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.3-rc4#n88 sorry but I didn't get. What's the problem about the commit message? > > Regards, > Markus ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [2/2] firmware: raspberrypi: Clean up local formatting 2026-10-02 15:13 ` Stefan Wahren @ 2026-10-03 11:17 ` Markus Elfring 2026-10-03 13:34 ` Stefan Wahren 0 siblings, 1 reply; 9+ messages in thread From: Markus Elfring @ 2026-10-03 11:17 UTC (permalink / raw) To: Stefan Wahren, Triet Hoang, linux-rpi-kernel, linux-arm-kernel, bcm-kernel-feedback-list, Florian Fainelli Cc: LKML >>> Add a blank line after the local variable declaration in >>> response_callback() and fix the indentation of the UINT_MAX return in >>> rpi_firmware_clk_get_max_rate(). >> … >> >> See also: >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.3-rc4#n88 > sorry but I didn't get. What's the problem about the commit message? “… and fix …” I imagine that another known advice can eventually be taken better into account. “… Solve only one problem per patch. …” Regards, Markus ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [2/2] firmware: raspberrypi: Clean up local formatting 2026-10-03 11:17 ` [2/2] " Markus Elfring @ 2026-10-03 13:34 ` Stefan Wahren 0 siblings, 0 replies; 9+ messages in thread From: Stefan Wahren @ 2026-10-03 13:34 UTC (permalink / raw) To: Markus Elfring, Triet Hoang, linux-rpi-kernel, linux-arm-kernel, bcm-kernel-feedback-list, Florian Fainelli Cc: LKML Hi Markus, Am 03.10.26 um 13:17 schrieb Markus Elfring: >>>> Add a blank line after the local variable declaration in >>>> response_callback() and fix the indentation of the UINT_MAX return in >>>> rpi_firmware_clk_get_max_rate(). >>> … >>> >>> See also: >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.3-rc4#n88 >> sorry but I didn't get. What's the problem about the commit message? > “… and fix …” > > > I imagine that another known advice can eventually be taken better into account. > > “… Solve only one problem per patch. …” thanks for clarifying. The link pointed to a different line. Best regards > > Regards, > Markus ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-10-03 13:35 UTC | newest] Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2026-09-19 3:48 [PATCH 0/2] firmware: raspberrypi: Handle device registration errors Triet Hoang 2026-09-19 3:48 ` [PATCH 1/2] " Triet Hoang 2026-09-19 16:05 ` Stefan Wahren 2026-09-19 3:48 ` [PATCH 2/2] firmware: raspberrypi: Clean up local formatting Triet Hoang 2026-09-19 16:06 ` Stefan Wahren 2026-09-22 14:22 ` Markus Elfring 2026-10-02 15:13 ` Stefan Wahren 2026-10-03 11:17 ` [2/2] " Markus Elfring 2026-10-03 13:34 ` Stefan Wahren
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®