From: "Uwe Kleine-König" <ukleinek@kernel.org>
To: Jassi Brar <jassisinghbrar@gmail.com>, Heiko Stuebner <heiko@sntech.de>
Cc: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-rockchip@lists.infradead.org
Subject: [PATCH v1 2/3] mailbox: rockchip: Simplify device variant handling
Date: Tue, 25 Aug 2026 16:19:25 +0200 [thread overview]
Message-ID: <cf355152c7392686380034efa99dd0f21530179e.1787667315.git.ukleinek@kernel.org> (raw)
In-Reply-To: <cover.1787667315.git.ukleinek@kernel.org>
From: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
There is only a single device variant. Let's not use multi-device
abstraction for that but hardcode the information relevant for that
single device type.
Bloat-o-meter reports the following size reduction for an ARCH=arm64
build:
add/remove: 0/1 grow/shrink: 0/1 up/down: 0/-492 (-492)
Function old new delta
rk3368_drv_data 4 - -4
rockchip_mbox_probe 2084 1596 -488
Total: Before=7185, After=6693, chg -6.85%
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
---
drivers/mailbox/rockchip-mailbox.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/drivers/mailbox/rockchip-mailbox.c b/drivers/mailbox/rockchip-mailbox.c
index 7ebe5f0d0233..ada2bd419880 100644
--- a/drivers/mailbox/rockchip-mailbox.c
+++ b/drivers/mailbox/rockchip-mailbox.c
@@ -22,15 +22,13 @@
#define ROCKCHIP_MAILBOX_B2A_CMD(x) (0x30 + (x) * 8)
#define ROCKCHIP_MAILBOX_B2A_DAT(x) (0x34 + (x) * 8)
+#define ROCKCHIP_MAILBOX_NUM_CHANS 4
+
struct rockchip_mbox_msg {
u32 cmd;
int rx_size;
};
-struct rockchip_mbox_data {
- int num_chans;
-};
-
struct rockchip_mbox_chan {
int idx;
int irq;
@@ -151,20 +149,15 @@ static irqreturn_t rockchip_mbox_isr(int irq, void *dev_id)
return IRQ_HANDLED;
}
-static const struct rockchip_mbox_data rk3368_drv_data = {
- .num_chans = 4,
-};
-
static const struct of_device_id rockchip_mbox_of_match[] = {
- { .compatible = "rockchip,rk3368-mailbox", .data = &rk3368_drv_data},
- { },
+ { .compatible = "rockchip,rk3368-mailbox" },
+ { }
};
MODULE_DEVICE_TABLE(of, rockchip_mbox_of_match);
static int rockchip_mbox_probe(struct platform_device *pdev)
{
struct rockchip_mbox *mb;
- const struct rockchip_mbox_data *drv_data;
struct resource *res;
struct clk *pclk;
int ret, irq, i;
@@ -172,13 +165,13 @@ static int rockchip_mbox_probe(struct platform_device *pdev)
if (!pdev->dev.of_node)
return -ENODEV;
- drv_data = (const struct rockchip_mbox_data *) device_get_match_data(&pdev->dev);
-
- mb = devm_kzalloc(&pdev->dev, struct_size(mb, chans, drv_data->num_chans), GFP_KERNEL);
+ mb = devm_kzalloc(&pdev->dev,
+ struct_size(mb, chans, ROCKCHIP_MAILBOX_NUM_CHANS),
+ GFP_KERNEL);
if (!mb)
return -ENOMEM;
- mb->mbox.chans = devm_kcalloc(&pdev->dev, drv_data->num_chans,
+ mb->mbox.chans = devm_kcalloc(&pdev->dev, ROCKCHIP_MAILBOX_NUM_CHANS,
sizeof(*mb->mbox.chans), GFP_KERNEL);
if (!mb->mbox.chans)
return -ENOMEM;
@@ -186,7 +179,7 @@ static int rockchip_mbox_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, mb);
mb->mbox.dev = &pdev->dev;
- mb->mbox.num_chans = drv_data->num_chans;
+ mb->mbox.num_chans = ROCKCHIP_MAILBOX_NUM_CHANS;
mb->mbox.ops = &rockchip_mbox_chan_ops;
mb->mbox.txdone_irq = true;
@@ -195,7 +188,7 @@ static int rockchip_mbox_probe(struct platform_device *pdev)
return PTR_ERR(mb->mbox_base);
/* Each channel has two buffers for A2B and B2A */
- mb->buf_size = (size_t)resource_size(res) / (drv_data->num_chans * 2);
+ mb->buf_size = (size_t)resource_size(res) / (ROCKCHIP_MAILBOX_NUM_CHANS * 2);
pclk = devm_clk_get_enabled(&pdev->dev, "pclk_mailbox");
if (IS_ERR(pclk))
--
2.55.0.11.g153666a7d9bb
next prev parent reply other threads:[~2026-08-25 14:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 14:19 [PATCH v1 0/3] mailbox: rockchip: Some cleanups Uwe Kleine-König
2026-08-25 14:19 ` [PATCH v1 1/3] mailbox: rockchip: Add a prefix for register defines Uwe Kleine-König
2026-08-25 14:19 ` Uwe Kleine-König [this message]
2026-08-25 14:19 ` [PATCH v1 3/3] mailbox: rockchip: Convert to use dev_err_probe() Uwe Kleine-König
2026-10-12 1:31 ` [PATCH v1 0/3] mailbox: rockchip: Some cleanups Jassi Brar
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=cf355152c7392686380034efa99dd0f21530179e.1787667315.git.ukleinek@kernel.org \
--to=ukleinek@kernel.org \
--cc=heiko@sntech.de \
--cc=jassisinghbrar@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=u.kleine-koenig@baylibre.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
all inboxes | Powered by JetHome®