From: Andrew Davis <afd@ti.com>
To: Jassi Brar <jassisinghbrar@gmail.com>,
Hari Nagalla <hnagalla@ti.com>, Nick Saulnier <nsaulnier@ti.com>,
Bjorn Andersson <andersson@kernel.org>,
Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: <linux-remoteproc@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, Andrew Davis <afd@ti.com>
Subject: [PATCH v2 10/13] mailbox: omap: Use mbox_controller channel list directly
Date: Wed, 10 Apr 2024 08:59:39 -0500 [thread overview]
Message-ID: <20240410135942.61667-11-afd@ti.com> (raw)
In-Reply-To: <20240410135942.61667-1-afd@ti.com>
The driver stores a list of omap_mbox structs so it can later use it to
lookup the mailbox names in of_xlate. This same information is already
available in the mbox_controller passed into of_xlate. Simply use that
data and remove the extra allocation and storage of the omap_mbox list.
Signed-off-by: Andrew Davis <afd@ti.com>
---
drivers/mailbox/omap-mailbox.c | 42 +++++++++-------------------------
1 file changed, 11 insertions(+), 31 deletions(-)
diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c
index 97f59d9f9f319..8e42266cb31a5 100644
--- a/drivers/mailbox/omap-mailbox.c
+++ b/drivers/mailbox/omap-mailbox.c
@@ -85,7 +85,6 @@ struct omap_mbox_device {
u32 num_users;
u32 num_fifos;
u32 intr_type;
- struct omap_mbox **mboxes;
};
struct omap_mbox {
@@ -356,25 +355,6 @@ static void omap_mbox_fini(struct omap_mbox *mbox)
mbox_queue_free(mbox->rxq);
}
-static struct omap_mbox *omap_mbox_device_find(struct omap_mbox_device *mdev,
- const char *mbox_name)
-{
- struct omap_mbox *_mbox, *mbox = NULL;
- struct omap_mbox **mboxes = mdev->mboxes;
- int i;
-
- if (!mboxes)
- return NULL;
-
- for (i = 0; (_mbox = mboxes[i]); i++) {
- if (!strcmp(_mbox->name, mbox_name)) {
- mbox = _mbox;
- break;
- }
- }
- return mbox;
-}
-
static int omap_mbox_chan_startup(struct mbox_chan *chan)
{
struct omap_mbox *mbox = mbox_chan_to_omap_mbox(chan);
@@ -539,6 +519,7 @@ static struct mbox_chan *omap_mbox_of_xlate(struct mbox_controller *controller,
struct device_node *node;
struct omap_mbox_device *mdev;
struct omap_mbox *mbox;
+ int i;
mdev = dev_get_drvdata(controller->dev);
if (WARN_ON(!mdev))
@@ -551,16 +532,23 @@ static struct mbox_chan *omap_mbox_of_xlate(struct mbox_controller *controller,
return ERR_PTR(-ENODEV);
}
- mbox = omap_mbox_device_find(mdev, node->name);
+ for (i = 0; i < controller->num_chans; i++) {
+ mbox = controller->chans[i].con_priv;
+ if (!strcmp(mbox->name, node->name)) {
+ of_node_put(node);
+ return &controller->chans[i];
+ }
+ }
+
of_node_put(node);
- return mbox ? mbox->chan : ERR_PTR(-ENOENT);
+ return ERR_PTR(-ENOENT);
}
static int omap_mbox_probe(struct platform_device *pdev)
{
int ret;
struct mbox_chan *chnls;
- struct omap_mbox **list, *mbox;
+ struct omap_mbox *mbox;
struct omap_mbox_device *mdev;
struct omap_mbox_fifo *fifo;
struct device_node *node = pdev->dev.of_node;
@@ -608,12 +596,6 @@ static int omap_mbox_probe(struct platform_device *pdev)
if (!mdev->irq_ctx)
return -ENOMEM;
- /* allocate one extra for marking end of list */
- list = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*list),
- GFP_KERNEL);
- if (!list)
- return -ENOMEM;
-
chnls = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*chnls),
GFP_KERNEL);
if (!chnls)
@@ -675,7 +657,6 @@ static int omap_mbox_probe(struct platform_device *pdev)
return mbox->irq;
mbox->chan = &chnls[i];
chnls[i].con_priv = mbox;
- list[i] = mbox++;
}
mutex_init(&mdev->cfg_lock);
@@ -683,7 +664,6 @@ static int omap_mbox_probe(struct platform_device *pdev)
mdev->num_users = num_users;
mdev->num_fifos = num_fifos;
mdev->intr_type = intr_type;
- mdev->mboxes = list;
controller = devm_kzalloc(&pdev->dev, sizeof(*controller), GFP_KERNEL);
if (!controller)
--
2.39.2
next prev parent reply other threads:[~2024-04-10 13:59 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-10 13:59 [PATCH v2 00/13] OMAP mailbox FIFO removal Andrew Davis
2024-04-10 13:59 ` [PATCH v2 01/13] mailbox: omap: Remove unused omap_mbox_{enable,disable}_irq() functions Andrew Davis
2024-04-10 13:59 ` [PATCH v2 02/13] mailbox: omap: Remove unused omap_mbox_request_channel() function Andrew Davis
2024-04-10 13:59 ` [PATCH v2 03/13] mailbox: omap: Move omap_mbox_irq_t into driver Andrew Davis
2024-04-10 13:59 ` [PATCH v2 04/13] mailbox: omap: Move fifo size check to point of use Andrew Davis
2024-04-10 13:59 ` [PATCH v2 05/13] mailbox: omap: Remove unneeded header omap-mailbox.h Andrew Davis
2024-04-10 13:59 ` [PATCH v2 06/13] mailbox: omap: Remove device class Andrew Davis
2024-04-10 13:59 ` [PATCH v2 07/13] mailbox: omap: Use devm_pm_runtime_enable() helper Andrew Davis
2024-04-10 13:59 ` [PATCH v2 08/13] mailbox: omap: Merge mailbox child node setup loops Andrew Davis
2024-04-10 13:59 ` [PATCH v2 09/13] mailbox: omap: Use function local struct mbox_controller Andrew Davis
2024-04-10 13:59 ` Andrew Davis [this message]
2024-04-10 13:59 ` [PATCH v2 11/13] mailbox: omap: Remove mbox_chan_to_omap_mbox() Andrew Davis
2024-04-10 13:59 ` [PATCH v2 12/13] mailbox: omap: Reverse FIFO busy check logic Andrew Davis
2024-04-10 13:59 ` [PATCH v2 13/13] mailbox: omap: Remove kernel FIFO message queuing Andrew Davis
2024-06-13 7:58 ` [PATCH v2 00/13] OMAP mailbox FIFO removal Dominic Rath
2024-06-13 12:22 ` Andrew Davis
2024-06-14 6:12 ` Dominic Rath
2024-06-26 14:39 ` Dominic Rath
2024-06-26 15:30 ` Andrew Davis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240410135942.61667-11-afd@ti.com \
--to=afd@ti.com \
--cc=andersson@kernel.org \
--cc=hnagalla@ti.com \
--cc=jassisinghbrar@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=nsaulnier@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox