mailbox: core cleanup patches
v2 cover mailbox: core cleanup patches
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
---
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,
Signature · 1 line
Tudor Ambarus <[email protected]>
PATCH v2 1/6 mailbox: use error ret code of of_parse_phandle_with_args()
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().
--- drivers/mailbox/mailbox.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/mailbox/mailbox.c +4 -3
@@ -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 );
Signature · 1 line
2.48.1.601.g30ceb7b040-goog
PATCH v2 2/6 mailbox: don't protect of_parse_phandle_with_args with con_mutex
In reply to Tudor AmbarusThere are no concurrency problems if multiple consumers parse the phandle, don't gratuiously protect the parsing with the mutex used for the controllers list.
--- drivers/mailbox/mailbox.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mailbox/mailbox.c +2 -3
@@ -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) {
Signature · 1 line
2.48.1.601.g30ceb7b040-goog
PATCH v2 3/6 mailbox: sort headers alphabetically
In reply to Tudor AmbarusSorting headers alphabetically helps locating duplicates, and makes it easier to figure out where to insert new headers.
--- drivers/mailbox/mailbox.c | 14 +++++++------- include/linux/mailbox_client.h | 2 +- include/linux/mailbox_controller.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-)
drivers/mailbox/mailbox.c +7 -7
@@ -6,18 +6,18 @@* Author: Jassi Brar <[email protected]> */ -#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"
include/linux/mailbox_client.h +1 -1
@@ -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 ;
include/linux/mailbox_controller.h +3 -3
@@ -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 ;
Signature · 1 line
2.48.1.601.g30ceb7b040-goog
PATCH v2 4/6 mailbox: explicitly include <linux/bits.h>
In reply to Tudor AmbarusDon't rely on those including the header file to already include the needed <linux/bits.h>. Include it in the header file.
--- drivers/mailbox/mailbox.h | 2 ++ 1 file changed, 2 insertions(+)
drivers/mailbox/mailbox.h +2 -0
@@ -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 */
Signature · 1 line
2.48.1.601.g30ceb7b040-goog
PATCH v2 5/6 mailbox: remove unused header files
In reply to Tudor AmbarusThere's nothing used from these header files, remove their inclusion.
--- drivers/mailbox/mailbox.c | 3 --- 1 file changed, 3 deletions(-)
drivers/mailbox/mailbox.c +0 -3
@@ -6,17 +6,14 @@* Author: Jassi Brar <[email protected]> */ -#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"
Signature · 1 line
2.48.1.601.g30ceb7b040-goog
PATCH v2 6/6 MAINTAINERS: add mailbox API's tree type and location
In reply to Tudor AmbarusAdd mailbox API tree type and location. It helps contributors know what's currently queued.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -13735,6 +13735,7 @@ MAILBOX API M: Jassi Brar <[email protected]> L: [email protected] 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/
Signature · 1 line
2.48.1.601.g30ceb7b040-goog
seems that I mangled b4 prep --resend somehow. v2 is just a resend of v1.
Thanks,
ta