mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/6] firmware: raspberrypi: Style cleanups and registration error handling
@ 2026-11-07 16:38 Sander Speetjens
  2026-11-07 16:38 ` [PATCH 1/6] firmware: raspberrypi: Add blank line after declaration in response_callback Sander Speetjens
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Sander Speetjens @ 2026-11-07 16:38 UTC (permalink / raw)
  To: Florian Fainelli, Broadcom internal kernel review list,
	Eric Anholt, Stefan Wahren, Stephen Boyd, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel, sander.speetjens

This series does minor style cleanups in the Raspberry Pi firmware
driver and fixes error handling when registering the hwmon and clock
platform devices.

The first five patches address checkpatch warnings (missing blank lines
after declarations, incorrect indentation, unnecessary braces, and
undocumented memory barriers).

The final patch checks the return value of
platform_device_register_data() so that an error pointer is no longer
stored in the global rpi_hwmon / rpi_clk variables.

---
Sander Speetjens (6):
      firmware: raspberrypi: Add blank line after declaration in response_callback
      firmware: raspberrypi: Fix indentation of return statement
      firmware: raspberrypi: Add blank line after declaration in probe error path
      firmware: raspberrypi: Remove unnecessary braces in transaction helper
      firmware: raspberrypi: Document memory barriers in property list path
      firmware: raspberrypi: Handle device registration errors

 drivers/firmware/raspberrypi.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261107-fix-raspberrypi-firmware-be9c602d6755

Best regards,
-- 
Sander Speetjens <sander.speetjens@gmail.com>


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/6] firmware: raspberrypi: Add blank line after declaration in response_callback
  2026-11-07 16:38 [PATCH 0/6] firmware: raspberrypi: Style cleanups and registration error handling Sander Speetjens
@ 2026-11-07 16:38 ` Sander Speetjens
  2026-11-07 16:38 ` [PATCH 2/6] firmware: raspberrypi: Fix indentation of return statement Sander Speetjens
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sander Speetjens @ 2026-11-07 16:38 UTC (permalink / raw)
  To: Florian Fainelli, Broadcom internal kernel review list,
	Eric Anholt, Stefan Wahren, Stephen Boyd, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel, sander.speetjens

Add a blank line after the local variable declaration.

Signed-off-by: Sander Speetjens <sander.speetjens@gmail.com>
---
 drivers/firmware/raspberrypi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index 443459c8c90f..8f3653c4a669 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -40,6 +40,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);
 }
 

-- 
2.56.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 2/6] firmware: raspberrypi: Fix indentation of return statement
  2026-11-07 16:38 [PATCH 0/6] firmware: raspberrypi: Style cleanups and registration error handling Sander Speetjens
  2026-11-07 16:38 ` [PATCH 1/6] firmware: raspberrypi: Add blank line after declaration in response_callback Sander Speetjens
@ 2026-11-07 16:38 ` Sander Speetjens
  2026-11-07 16:38 ` [PATCH 3/6] firmware: raspberrypi: Add blank line after declaration in probe error path Sander Speetjens
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sander Speetjens @ 2026-11-07 16:38 UTC (permalink / raw)
  To: Florian Fainelli, Broadcom internal kernel review list,
	Eric Anholt, Stefan Wahren, Stephen Boyd, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel, sander.speetjens

The return was over-indented; statements should start on a tab stop.

Signed-off-by: Sander Speetjens <sander.speetjens@gmail.com>
---
 drivers/firmware/raspberrypi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index 8f3653c4a669..e0c91719b4d0 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -267,7 +267,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.56.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 3/6] firmware: raspberrypi: Add blank line after declaration in probe error path
  2026-11-07 16:38 [PATCH 0/6] firmware: raspberrypi: Style cleanups and registration error handling Sander Speetjens
  2026-11-07 16:38 ` [PATCH 1/6] firmware: raspberrypi: Add blank line after declaration in response_callback Sander Speetjens
  2026-11-07 16:38 ` [PATCH 2/6] firmware: raspberrypi: Fix indentation of return statement Sander Speetjens
@ 2026-11-07 16:38 ` Sander Speetjens
  2026-11-07 16:38 ` [PATCH 4/6] firmware: raspberrypi: Remove unnecessary braces in transaction helper Sander Speetjens
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sander Speetjens @ 2026-11-07 16:38 UTC (permalink / raw)
  To: Florian Fainelli, Broadcom internal kernel review list,
	Eric Anholt, Stefan Wahren, Stephen Boyd, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel, sander.speetjens

Add the conventional blank line after the local variable declaration.

Signed-off-by: Sander Speetjens <sander.speetjens@gmail.com>
---
 drivers/firmware/raspberrypi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index e0c91719b4d0..04163c3f385d 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -315,6 +315,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);
+
 		kfree(fw);
 		return dev_err_probe(dev, ret, "Failed to get mbox channel\n");
 	}

-- 
2.56.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 4/6] firmware: raspberrypi: Remove unnecessary braces in transaction helper
  2026-11-07 16:38 [PATCH 0/6] firmware: raspberrypi: Style cleanups and registration error handling Sander Speetjens
                   ` (2 preceding siblings ...)
  2026-11-07 16:38 ` [PATCH 3/6] firmware: raspberrypi: Add blank line after declaration in probe error path Sander Speetjens
@ 2026-11-07 16:38 ` Sander Speetjens
  2026-11-07 16:38 ` [PATCH 5/6] firmware: raspberrypi: Document memory barriers in property list path Sander Speetjens
  2026-11-07 16:38 ` [PATCH 6/6] firmware: raspberrypi: Handle device registration errors Sander Speetjens
  5 siblings, 0 replies; 7+ messages in thread
From: Sander Speetjens @ 2026-11-07 16:38 UTC (permalink / raw)
  To: Florian Fainelli, Broadcom internal kernel review list,
	Eric Anholt, Stefan Wahren, Stephen Boyd, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel, sander.speetjens

Braces are not needed around the single-statement arms of the
wait_for_completion_timeout() check.

Signed-off-by: Sander Speetjens <sander.speetjens@gmail.com>
---
 drivers/firmware/raspberrypi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index 04163c3f385d..d9a569a6dae7 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -60,11 +60,10 @@ rpi_firmware_transaction(struct rpi_firmware *fw, u32 chan, u32 data)
 	reinit_completion(&fw->c);
 	ret = mbox_send_message(fw->chan, &message);
 	if (ret >= 0) {
-		if (wait_for_completion_timeout(&fw->c, HZ)) {
+		if (wait_for_completion_timeout(&fw->c, HZ))
 			ret = 0;
-		} else {
+		else
 			ret = -ETIMEDOUT;
-		}
 	} else {
 		dev_err(fw->cl.dev, "mbox_send_message returned %d\n", ret);
 	}

-- 
2.56.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 5/6] firmware: raspberrypi: Document memory barriers in property list path
  2026-11-07 16:38 [PATCH 0/6] firmware: raspberrypi: Style cleanups and registration error handling Sander Speetjens
                   ` (3 preceding siblings ...)
  2026-11-07 16:38 ` [PATCH 4/6] firmware: raspberrypi: Remove unnecessary braces in transaction helper Sander Speetjens
@ 2026-11-07 16:38 ` Sander Speetjens
  2026-11-07 16:38 ` [PATCH 6/6] firmware: raspberrypi: Handle device registration errors Sander Speetjens
  5 siblings, 0 replies; 7+ messages in thread
From: Sander Speetjens @ 2026-11-07 16:38 UTC (permalink / raw)
  To: Florian Fainelli, Broadcom internal kernel review list,
	Eric Anholt, Stefan Wahren, Stephen Boyd, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel, sander.speetjens

Add comments explaining the wmb() before the firmware transaction and
the rmb() before reading the response, as required by coding style.

Signed-off-by: Sander Speetjens <sander.speetjens@gmail.com>
---
 drivers/firmware/raspberrypi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index d9a569a6dae7..57f21e4e65d6 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -110,10 +110,12 @@ int rpi_firmware_property_list(struct rpi_firmware *fw,
 	buf[1] = RPI_FIRMWARE_STATUS_REQUEST;
 	memcpy(&buf[2], data, tag_size);
 	buf[size / 4 - 1] = RPI_FIRMWARE_PROPERTY_END;
+	/* Make sure the writes to the buffer are visible to the firmware. */
 	wmb();
 
 	ret = rpi_firmware_transaction(fw, MBOX_CHAN_PROPERTY, bus_addr);
 
+	/* Make sure we see the firmware's response before reading it. */
 	rmb();
 	memcpy(data, &buf[2], tag_size);
 	if (ret == 0 && buf[1] != RPI_FIRMWARE_STATUS_SUCCESS) {

-- 
2.56.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 6/6] firmware: raspberrypi: Handle device registration errors
  2026-11-07 16:38 [PATCH 0/6] firmware: raspberrypi: Style cleanups and registration error handling Sander Speetjens
                   ` (4 preceding siblings ...)
  2026-11-07 16:38 ` [PATCH 5/6] firmware: raspberrypi: Document memory barriers in property list path Sander Speetjens
@ 2026-11-07 16:38 ` Sander Speetjens
  5 siblings, 0 replies; 7+ messages in thread
From: Sander Speetjens @ 2026-11-07 16:38 UTC (permalink / raw)
  To: Florian Fainelli, Broadcom internal kernel review list,
	Eric Anholt, Stefan Wahren, Stephen Boyd, Nicolas Saenz Julienne
  Cc: linux-rpi-kernel, linux-arm-kernel, linux-kernel, sander.speetjens

Check the return value of platform_device_register_data() before assigning
it to the global rpi_hwmon / rpi_clk pointers.  Previously an ERR_PTR was
stored on failure, which could be used later without proper checking.

Do not propagate the error to the caller.  The hwmon and clock platform
devices are optional helpers; making the whole rpi_firmware_probe() fail
just because a child platform device could not be created would be worse,
as it would lose the firmware interface that many other drivers need.

Fixes: 70eea1bbb556 ("firmware: raspberrypi: Register hwmon driver")
Fixes: 91f2cf4a6b21 ("firmware: raspberrypi: register clk device")
Signed-off-by: Sander Speetjens <sander.speetjens@gmail.com>
---
 drivers/firmware/raspberrypi.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/raspberrypi.c b/drivers/firmware/raspberrypi.c
index 57f21e4e65d6..48cb8063ddb9 100644
--- a/drivers/firmware/raspberrypi.c
+++ b/drivers/firmware/raspberrypi.c
@@ -203,6 +203,7 @@ rpi_firmware_print_firmware_revision(struct rpi_firmware *fw)
 static void
 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));
@@ -210,13 +211,19 @@ rpi_register_hwmon_driver(struct device *dev, struct rpi_firmware *fw)
 	if (ret)
 		return;
 
-	rpi_hwmon = platform_device_register_data(dev, "raspberrypi-hwmon",
-						  -1, NULL, 0);
+	pdev = platform_device_register_data(dev, "raspberrypi-hwmon",
+					     -1, NULL, 0);
+
+	if (IS_ERR(pdev))
+		return;
+
+	rpi_hwmon = pdev;
 }
 
 static void rpi_register_clk_driver(struct device *dev)
 {
 	struct device_node *firmware;
+	struct platform_device *pdev;
 
 	/*
 	 * Earlier DTs don't have a node for the firmware clocks but
@@ -230,8 +237,13 @@ static void rpi_register_clk_driver(struct device *dev)
 		return;
 	}
 
-	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;
+
+	rpi_clk = pdev;
 }
 
 static void rpi_register_rtc_driver(struct device *dev)

-- 
2.56.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-07 16:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-07 16:38 [PATCH 0/6] firmware: raspberrypi: Style cleanups and registration error handling Sander Speetjens
2026-11-07 16:38 ` [PATCH 1/6] firmware: raspberrypi: Add blank line after declaration in response_callback Sander Speetjens
2026-11-07 16:38 ` [PATCH 2/6] firmware: raspberrypi: Fix indentation of return statement Sander Speetjens
2026-11-07 16:38 ` [PATCH 3/6] firmware: raspberrypi: Add blank line after declaration in probe error path Sander Speetjens
2026-11-07 16:38 ` [PATCH 4/6] firmware: raspberrypi: Remove unnecessary braces in transaction helper Sander Speetjens
2026-11-07 16:38 ` [PATCH 5/6] firmware: raspberrypi: Document memory barriers in property list path Sander Speetjens
2026-11-07 16:38 ` [PATCH 6/6] firmware: raspberrypi: Handle device registration errors Sander Speetjens

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®