* [PATCH v2 0/6] mailbox: core cleanup patches
@ 2025-02-24 8:27 Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 1/6] mailbox: use error ret code of of_parse_phandle_with_args() Tudor Ambarus
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Tudor Ambarus @ 2025-02-24 8:27 UTC (permalink / raw)
To: Jassi Brar
Cc: linux-kernel, andre.draszik, peter.griffin, willmcvicker,
kernel-team, Tudor Ambarus
Here are few small cleanup patches that I made when working on the
exynos mailbox controller driver. It touches error codes, what the mutex
in the core protects and what header files are included.
Cheers,
ta
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
Tudor Ambarus (6):
mailbox: use error ret code of of_parse_phandle_with_args()
mailbox: don't protect of_parse_phandle_with_args with con_mutex
mailbox: sort headers alphabetically
mailbox: explicitly include <linux/bits.h>
mailbox: remove unused header files
MAINTAINERS: add mailbox API's tree type and location
MAINTAINERS | 1 +
drivers/mailbox/mailbox.c | 23 ++++++++++-------------
drivers/mailbox/mailbox.h | 2 ++
include/linux/mailbox_client.h | 2 +-
include/linux/mailbox_controller.h | 6 +++---
5 files changed, 17 insertions(+), 17 deletions(-)
---
base-commit: 4783ce32b0806911287f35cc65b799876d6f9547
change-id: 20241221-mbox-mutex-ced37c16f509
Best regards,
--
Tudor Ambarus <tudor.ambarus@linaro.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/6] mailbox: use error ret code of of_parse_phandle_with_args()
2025-02-24 8:27 [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
@ 2025-02-24 8:27 ` Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 2/6] mailbox: don't protect of_parse_phandle_with_args with con_mutex Tudor Ambarus
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2025-02-24 8:27 UTC (permalink / raw)
To: Jassi Brar
Cc: linux-kernel, andre.draszik, peter.griffin, willmcvicker,
kernel-team, Tudor Ambarus
In case of error, of_parse_phandle_with_args() returns -EINVAL when the
passed index is negative, or -ENOENT when the index is for an empty
phandle. The mailbox core overwrote the error return code with a less
precise -ENODEV. Use the error returned code from
of_parse_phandle_with_args().
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
drivers/mailbox/mailbox.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index d3d26a2c9895..cb174e788a96 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -415,11 +415,12 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index)
mutex_lock(&con_mutex);
- if (of_parse_phandle_with_args(dev->of_node, "mboxes",
- "#mbox-cells", index, &spec)) {
+ ret = of_parse_phandle_with_args(dev->of_node, "mboxes", "#mbox-cells",
+ index, &spec);
+ if (ret) {
dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__);
mutex_unlock(&con_mutex);
- return ERR_PTR(-ENODEV);
+ return ERR_PTR(ret);
}
chan = ERR_PTR(-EPROBE_DEFER);
--
2.48.1.601.g30ceb7b040-goog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/6] mailbox: don't protect of_parse_phandle_with_args with con_mutex
2025-02-24 8:27 [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 1/6] mailbox: use error ret code of of_parse_phandle_with_args() Tudor Ambarus
@ 2025-02-24 8:27 ` Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 3/6] mailbox: sort headers alphabetically Tudor Ambarus
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2025-02-24 8:27 UTC (permalink / raw)
To: Jassi Brar
Cc: linux-kernel, andre.draszik, peter.griffin, willmcvicker,
kernel-team, Tudor Ambarus
There are no concurrency problems if multiple consumers parse the
phandle, don't gratuiously protect the parsing with the mutex used
for the controllers list.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
drivers/mailbox/mailbox.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index cb174e788a96..784b56859a06 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -413,16 +413,15 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index)
return ERR_PTR(-ENODEV);
}
- mutex_lock(&con_mutex);
-
ret = of_parse_phandle_with_args(dev->of_node, "mboxes", "#mbox-cells",
index, &spec);
if (ret) {
dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__);
- mutex_unlock(&con_mutex);
return ERR_PTR(ret);
}
+ mutex_lock(&con_mutex);
+
chan = ERR_PTR(-EPROBE_DEFER);
list_for_each_entry(mbox, &mbox_cons, node)
if (mbox->dev->of_node == spec.np) {
--
2.48.1.601.g30ceb7b040-goog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 3/6] mailbox: sort headers alphabetically
2025-02-24 8:27 [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 1/6] mailbox: use error ret code of of_parse_phandle_with_args() Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 2/6] mailbox: don't protect of_parse_phandle_with_args with con_mutex Tudor Ambarus
@ 2025-02-24 8:27 ` Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 4/6] mailbox: explicitly include <linux/bits.h> Tudor Ambarus
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2025-02-24 8:27 UTC (permalink / raw)
To: Jassi Brar
Cc: linux-kernel, andre.draszik, peter.griffin, willmcvicker,
kernel-team, Tudor Ambarus
Sorting headers alphabetically helps locating duplicates,
and makes it easier to figure out where to insert new headers.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
drivers/mailbox/mailbox.c | 14 +++++++-------
include/linux/mailbox_client.h | 2 +-
include/linux/mailbox_controller.h | 6 +++---
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 784b56859a06..fa3dcec63940 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -6,18 +6,18 @@
* Author: Jassi Brar <jassisinghbrar@gmail.com>
*/
-#include <linux/interrupt.h>
-#include <linux/spinlock.h>
-#include <linux/mutex.h>
+#include <linux/bitops.h>
#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/err.h>
-#include <linux/module.h>
#include <linux/device.h>
-#include <linux/bitops.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
#include <linux/mailbox_client.h>
#include <linux/mailbox_controller.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/of.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
#include "mailbox.h"
diff --git a/include/linux/mailbox_client.h b/include/linux/mailbox_client.h
index 734694912ef7..c6eea9afb943 100644
--- a/include/linux/mailbox_client.h
+++ b/include/linux/mailbox_client.h
@@ -7,8 +7,8 @@
#ifndef __MAILBOX_CLIENT_H
#define __MAILBOX_CLIENT_H
-#include <linux/of.h>
#include <linux/device.h>
+#include <linux/of.h>
struct mbox_chan;
diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h
index 6fee33cb52f5..5fb0b65f45a2 100644
--- a/include/linux/mailbox_controller.h
+++ b/include/linux/mailbox_controller.h
@@ -3,11 +3,11 @@
#ifndef __MAILBOX_CONTROLLER_H
#define __MAILBOX_CONTROLLER_H
+#include <linux/completion.h>
+#include <linux/device.h>
+#include <linux/hrtimer.h>
#include <linux/of.h>
#include <linux/types.h>
-#include <linux/hrtimer.h>
-#include <linux/device.h>
-#include <linux/completion.h>
struct mbox_chan;
--
2.48.1.601.g30ceb7b040-goog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 4/6] mailbox: explicitly include <linux/bits.h>
2025-02-24 8:27 [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
` (2 preceding siblings ...)
2025-02-24 8:27 ` [PATCH v2 3/6] mailbox: sort headers alphabetically Tudor Ambarus
@ 2025-02-24 8:27 ` Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 5/6] mailbox: remove unused header files Tudor Ambarus
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2025-02-24 8:27 UTC (permalink / raw)
To: Jassi Brar
Cc: linux-kernel, andre.draszik, peter.griffin, willmcvicker,
kernel-team, Tudor Ambarus
Don't rely on those including the header file to already include the
needed <linux/bits.h>. Include it in the header file.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
drivers/mailbox/mailbox.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/mailbox/mailbox.h b/drivers/mailbox/mailbox.h
index 046d6d258b32..e1ec4efab693 100644
--- a/drivers/mailbox/mailbox.h
+++ b/drivers/mailbox/mailbox.h
@@ -3,6 +3,8 @@
#ifndef __MAILBOX_H
#define __MAILBOX_H
+#include <linux/bits.h>
+
#define TXDONE_BY_IRQ BIT(0) /* controller has remote RTR irq */
#define TXDONE_BY_POLL BIT(1) /* controller can read status of last TX */
#define TXDONE_BY_ACK BIT(2) /* S/W ACK received by Client ticks the TX */
--
2.48.1.601.g30ceb7b040-goog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 5/6] mailbox: remove unused header files
2025-02-24 8:27 [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
` (3 preceding siblings ...)
2025-02-24 8:27 ` [PATCH v2 4/6] mailbox: explicitly include <linux/bits.h> Tudor Ambarus
@ 2025-02-24 8:27 ` Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 6/6] MAINTAINERS: add mailbox API's tree type and location Tudor Ambarus
2025-02-24 8:28 ` [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
6 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2025-02-24 8:27 UTC (permalink / raw)
To: Jassi Brar
Cc: linux-kernel, andre.draszik, peter.griffin, willmcvicker,
kernel-team, Tudor Ambarus
There's nothing used from these header files, remove their inclusion.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
drivers/mailbox/mailbox.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index fa3dcec63940..5e3a1d0315f9 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -6,17 +6,14 @@
* Author: Jassi Brar <jassisinghbrar@gmail.com>
*/
-#include <linux/bitops.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/err.h>
-#include <linux/interrupt.h>
#include <linux/mailbox_client.h>
#include <linux/mailbox_controller.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
-#include <linux/slab.h>
#include <linux/spinlock.h>
#include "mailbox.h"
--
2.48.1.601.g30ceb7b040-goog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 6/6] MAINTAINERS: add mailbox API's tree type and location
2025-02-24 8:27 [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
` (4 preceding siblings ...)
2025-02-24 8:27 ` [PATCH v2 5/6] mailbox: remove unused header files Tudor Ambarus
@ 2025-02-24 8:27 ` Tudor Ambarus
2025-02-24 8:28 ` [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
6 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2025-02-24 8:27 UTC (permalink / raw)
To: Jassi Brar
Cc: linux-kernel, andre.draszik, peter.griffin, willmcvicker,
kernel-team, Tudor Ambarus
Add mailbox API tree type and location. It helps contributors know
what's currently queued.
Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
MAINTAINERS | 1 +
1 file changed, 1 insertion(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 20163d8a8d90..94f8f59c71e9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -13735,6 +13735,7 @@ MAILBOX API
M: Jassi Brar <jassisinghbrar@gmail.com>
L: linux-kernel@vger.kernel.org
S: Maintained
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/jassibrar/mailbox.git for-next
F: Documentation/devicetree/bindings/mailbox/
F: drivers/mailbox/
F: include/dt-bindings/mailbox/
--
2.48.1.601.g30ceb7b040-goog
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 0/6] mailbox: core cleanup patches
2025-02-24 8:27 [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
` (5 preceding siblings ...)
2025-02-24 8:27 ` [PATCH v2 6/6] MAINTAINERS: add mailbox API's tree type and location Tudor Ambarus
@ 2025-02-24 8:28 ` Tudor Ambarus
6 siblings, 0 replies; 8+ messages in thread
From: Tudor Ambarus @ 2025-02-24 8:28 UTC (permalink / raw)
To: Jassi Brar
Cc: linux-kernel, andre.draszik, peter.griffin, willmcvicker, kernel-team
seems that I mangled b4 prep --resend somehow. v2 is just a resend of v1.
Thanks,
ta
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-02-24 8:29 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-24 8:27 [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 1/6] mailbox: use error ret code of of_parse_phandle_with_args() Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 2/6] mailbox: don't protect of_parse_phandle_with_args with con_mutex Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 3/6] mailbox: sort headers alphabetically Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 4/6] mailbox: explicitly include <linux/bits.h> Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 5/6] mailbox: remove unused header files Tudor Ambarus
2025-02-24 8:27 ` [PATCH v2 6/6] MAINTAINERS: add mailbox API's tree type and location Tudor Ambarus
2025-02-24 8:28 ` [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
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®