Skip to contentSkip to conversation

mailbox: sun6i: modernize probe and convert to fully managed

PATCH Superseded Rosen Penev 4 participants 6 messages Jul 27 – Aug 14

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mailbox: sun6i: modernize probe and convert to fully managed

Replace irq_of_parse_and_map() with platform_get_irq() and move both IRQ and MMIO resource acquisition to the top of probe, before any allocations, for early error exit.

Switch from devm_clk_get() + clk_prepare_enable() to devm_clk_get_enabled(), which combines both operations and registers devres callbacks for automatic disable/unprepare on unbind. This eliminates the manual err_disable_unprepare error path and the remove callback entirely.

Use devm_mbox_controller_register() for devres-managed controller registration, and drop the remove callback and platform_set_drvdata() which are no longer needed.

Assisted-by Opencode:Big-Pickle
---
 drivers/mailbox/sun6i-msgbox.c | 62 ++++++++++------------------------
 1 file changed, 18 insertions(+), 44 deletions(-)
drivers/mailbox/sun6i-msgbox.c +18 -44
index 6ba6920f4645..28d8636afad2 100644
@@ -198,7 +198,17 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
 	struct mbox_chan *chans;
 	struct reset_control *reset;
 	struct sun6i_msgbox *mbox;
+	void __iomem *regs;
 	int i, ret;
+	int irq;
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		return irq;
+
+	regs = devm_platform_ioremap_resource(pdev, 0);
+	if (IS_ERR(regs))
+		return PTR_ERR(regs);
 
 	mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL);
 	if (!mbox)
@@ -211,24 +221,18 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
 	for (i = 0; i < NUM_CHANS; ++i)
 		chans[i].con_priv = mbox;
 
-	mbox->clk = devm_clk_get(dev, NULL);
+	mbox->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(mbox->clk)) {
 		ret = PTR_ERR(mbox->clk);
 		dev_err(dev, "Failed to get clock: %d\n", ret);
 		return ret;
 	}
 
-	ret = clk_prepare_enable(mbox->clk);
-	if (ret) {
-		dev_err(dev, "Failed to enable clock: %d\n", ret);
-		return ret;
-	}
-
 	reset = devm_reset_control_get_exclusive(dev, NULL);
 	if (IS_ERR(reset)) {
 		ret = PTR_ERR(reset);
 		dev_err(dev, "Failed to get reset control: %d\n", ret);
-		goto err_disable_unprepare;
+		return ret;
 	}
 
 	/*
@@ -242,25 +246,17 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
 	ret = reset_control_deassert(reset);
 	if (ret) {
 		dev_err(dev, "Failed to deassert reset: %d\n", ret);
-		goto err_disable_unprepare;
+		return ret;
 	}
 
-	mbox->regs = devm_platform_ioremap_resource(pdev, 0);
-	if (IS_ERR(mbox->regs)) {
-		ret = PTR_ERR(mbox->regs);
-		dev_err(dev, "Failed to map MMIO resource: %d\n", ret);
-		goto err_disable_unprepare;
-	}
+	mbox->regs = regs;
 
 	/* Disable all IRQs for this end of the msgbox. */
 	writel(0, mbox->regs + LOCAL_IRQ_EN_REG);
 
-	ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
-			       sun6i_msgbox_irq, 0, dev_name(dev), mbox);
-	if (ret) {
-		dev_err(dev, "Failed to register IRQ handler: %d\n", ret);
-		goto err_disable_unprepare;
-	}
+	ret = devm_request_irq(dev, irq, sun6i_msgbox_irq, 0, dev_name(dev), mbox);
+	if (ret)
+		return ret;
 
 	mbox->controller.dev           = dev;
 	mbox->controller.ops           = &sun6i_msgbox_chan_ops;
@@ -271,29 +267,8 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
 	mbox->controller.txpoll_period = 5;
 
 	spin_lock_init(&mbox->lock);
-	platform_set_drvdata(pdev, mbox);
-
-	ret = mbox_controller_register(&mbox->controller);
-	if (ret) {
-		dev_err(dev, "Failed to register controller: %d\n", ret);
-		goto err_disable_unprepare;
-	}
-
-	return 0;
-
-err_disable_unprepare:
-	clk_disable_unprepare(mbox->clk);
-
-	return ret;
-}
-
-static void sun6i_msgbox_remove(struct platform_device *pdev)
-{
-	struct sun6i_msgbox *mbox = platform_get_drvdata(pdev);
 
-	mbox_controller_unregister(&mbox->controller);
-	/* See the comment in sun6i_msgbox_probe about the reset line. */
-	clk_disable_unprepare(mbox->clk);
+	return devm_mbox_controller_register(&mbox->controller);
 }
 
 static const struct of_device_id sun6i_msgbox_of_match[] = {
@@ -308,7 +283,6 @@ static struct platform_driver sun6i_msgbox_driver = {
 		.of_match_table = sun6i_msgbox_of_match,
 	},
 	.probe = sun6i_msgbox_probe,
-	.remove = sun6i_msgbox_remove,
 };
 module_platform_driver(sun6i_msgbox_driver);
 
Signature · 1 line
2.55.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] The function `devm_mbox_controller_register()` is called with one argument, but it requires two…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The function devm_mbox_controller_register() is called with one argument, but it requires two, causing a build failure. --

--- Patch [1]: [PATCH] mailbox: sun6i: modernize probe and convert to fully managed --- commit 6febca9f53cbed2f1affb7635d88de86beffdca8
Author: Rosen Penev <[email protected]>

mailbox: sun6i: modernize probe and convert to fully managed

This patch replaces manual resource cleanup with devres-managed variants in the sun6i mailbox driver. It converts IRQ, MMIO, clock, and mailbox controller registration to use their devm_* equivalents and removes the manual error paths and remove callback.

Quoted 4 lines
drivers/mailbox/sun6i-msgbox.c +0 -0
index 6ba6920f4645e..28d8636afad26 100644

[ ... ]

Quoted 18 lines
drivers/mailbox/sun6i-msgbox.c +0 -14
@@ -271,29 +267,8 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
 	mbox->controller.txpoll_period = 5;
 
 	spin_lock_init(&mbox->lock);
-	platform_set_drvdata(pdev, mbox);
-
-	ret = mbox_controller_register(&mbox->controller);
-	if (ret) {
-		dev_err(dev, "Failed to register controller: %d\n", ret);
-		goto err_disable_unprepare;
-	}
-
-	return 0;
-
-err_disable_unprepare:
-	clk_disable_unprepare(mbox->clk);
-
-	return ret;

drivers/mailbox/sun6i-msgbox.c static int sun6i_msgbox_probe(struct platform_device *pdev) · line 271

Quoted 10 lines
drivers/mailbox/sun6i-msgbox.c +1 -8
-}
-
-static void sun6i_msgbox_remove(struct platform_device *pdev)
-{
-	struct sun6i_msgbox *mbox = platform_get_drvdata(pdev);
 
-	mbox_controller_unregister(&mbox->controller);
-	/* See the comment in sun6i_msgbox_probe about the reset line. */
-	clk_disable_unprepare(mbox->clk);
+	return devm_mbox_controller_register(&mbox->controller);

[Severity: Low]
Will this compile successfully?

Looking at the function signature in drivers/mailbox/mailbox.c, devm_mbox_controller_register() requires two arguments:

int devm_mbox_controller_register(struct device *dev,
struct mbox_controller *mbox)

The call here only provides the mbox_controller pointer and is missing the struct device pointer as the first argument, which is likely to result in a build failure.

Quoted 3 lines
drivers/mailbox/sun6i-msgbox.c +0 -0
 }
 
 static const struct of_device_id sun6i_msgbox_of_match[] = {
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
In reply to Rosen Penev
Quoted 4 lines · Rosen Penev

Replace irq_of_parse_and_map() with platform_get_irq() and move both IRQ and MMIO resource acquisition to the top of probe, before any allocations, for early error exit.

There's no real reason for the code movement. It's going to fail once or maybe twice at the most. And the ones you moved are the least likely to fail.

Now I could see replacing irq_of_parse_and_map() with the more standard platform_get_irq(), but you haven't given a reasonable reason. And it should be a separate patch since it has nothing to do with streamlining the error handling and dropping the remove function.

Quoted 9 lines

Switch from devm_clk_get() + clk_prepare_enable() to devm_clk_get_enabled(), which combines both operations and registers devres callbacks for automatic disable/unprepare on unbind. This eliminates the manual err_disable_unprepare error path and the remove callback entirely.

Use devm_mbox_controller_register() for devres-managed controller registration, and drop the remove callback and platform_set_drvdata() which are no longer needed.

These two are what are important.

Quoted 104 lines
Assisted-by Opencode:Big-Pickle
---
 drivers/mailbox/sun6i-msgbox.c | 62 ++++++++++------------------------
 1 file changed, 18 insertions(+), 44 deletions(-)
drivers/mailbox/sun6i-msgbox.c +17 -35
index 6ba6920f4645..28d8636afad2 100644
@@ -198,7 +198,17 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
        struct mbox_chan *chans;
        struct reset_control *reset;
        struct sun6i_msgbox *mbox;
+       void __iomem *regs;
        int i, ret;
+       int irq;
+
+       irq = platform_get_irq(pdev, 0);
+       if (irq < 0)
+               return irq;
+
+       regs = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(regs))
+               return PTR_ERR(regs);
 
        mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL);
        if (!mbox)
@@ -211,24 +221,18 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
        for (i = 0; i < NUM_CHANS; ++i)
                chans[i].con_priv = mbox;
 
-       mbox->clk = devm_clk_get(dev, NULL);
+       mbox->clk = devm_clk_get_enabled(dev, NULL);
        if (IS_ERR(mbox->clk)) {
                ret = PTR_ERR(mbox->clk);
                dev_err(dev, "Failed to get clock: %d\n", ret);
                return ret;
        }
 
-       ret = clk_prepare_enable(mbox->clk);
-       if (ret) {
-               dev_err(dev, "Failed to enable clock: %d\n", ret);
-               return ret;
-       }
-
        reset = devm_reset_control_get_exclusive(dev, NULL);
        if (IS_ERR(reset)) {
                ret = PTR_ERR(reset);
                dev_err(dev, "Failed to get reset control: %d\n", ret);
-               goto err_disable_unprepare;
+               return ret;
        }
 
        /*
@@ -242,25 +246,17 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
        ret = reset_control_deassert(reset);
        if (ret) {
                dev_err(dev, "Failed to deassert reset: %d\n", ret);
-               goto err_disable_unprepare;
+               return ret;
        }
 
-       mbox->regs = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(mbox->regs)) {
-               ret = PTR_ERR(mbox->regs);
-               dev_err(dev, "Failed to map MMIO resource: %d\n", ret);
-               goto err_disable_unprepare;
-       }
+       mbox->regs = regs;
 
        /* Disable all IRQs for this end of the msgbox. */
        writel(0, mbox->regs + LOCAL_IRQ_EN_REG);
 
-       ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
-                              sun6i_msgbox_irq, 0, dev_name(dev), mbox);
-       if (ret) {
-               dev_err(dev, "Failed to register IRQ handler: %d\n", ret);
-               goto err_disable_unprepare;
-       }
+       ret = devm_request_irq(dev, irq, sun6i_msgbox_irq, 0, dev_name(dev), mbox);
+       if (ret)
+               return ret;
 
        mbox->controller.dev           = dev;
        mbox->controller.ops           = &sun6i_msgbox_chan_ops;
@@ -271,29 +267,8 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
        mbox->controller.txpoll_period = 5;
 
        spin_lock_init(&mbox->lock);
-       platform_set_drvdata(pdev, mbox);
-
-       ret = mbox_controller_register(&mbox->controller);
-       if (ret) {
-               dev_err(dev, "Failed to register controller: %d\n", ret);
-               goto err_disable_unprepare;
-       }
-
-       return 0;
-
-err_disable_unprepare:
-       clk_disable_unprepare(mbox->clk);
-
-       return ret;

drivers/mailbox/sun6i-msgbox.c static int sun6i_msgbox_probe(struct platform_device *pdev) · line 271

Quoted 10 lines
drivers/mailbox/sun6i-msgbox.c +1 -8
-}
-
-static void sun6i_msgbox_remove(struct platform_device *pdev)
-{
-       struct sun6i_msgbox *mbox = platform_get_drvdata(pdev);
 
-       mbox_controller_unregister(&mbox->controller);
-       /* See the comment in sun6i_msgbox_probe about the reset line. */
-       clk_disable_unprepare(mbox->clk);
+       return devm_mbox_controller_register(&mbox->controller);

Like Sashiko said, this doesn't compile. All devm_*() functions require a |struct device *| parameter.

Build testing your patch before sending it is a must.

ChenYu

Quoted 14 lines
drivers/mailbox/sun6i-msgbox.c +0 -2
 }
 
 static const struct of_device_id sun6i_msgbox_of_match[] = {
@@ -308,7 +283,6 @@ static struct platform_driver sun6i_msgbox_driver = {
                .of_match_table = sun6i_msgbox_of_match,
        },
        .probe = sun6i_msgbox_probe,
-       .remove = sun6i_msgbox_remove,
 };
 module_platform_driver(sun6i_msgbox_driver);
 
--

2.55.0

#3 lore raw
Quoted 10 lines · Chen-Yu Tsai
Quoted 4 lines · Rosen Penev

Replace irq_of_parse_and_map() with platform_get_irq() and move both IRQ and MMIO resource acquisition to the top of probe, before any allocations, for early error exit.

There's no real reason for the code movement. It's going to fail once or maybe twice at the most. And the ones you moved are the least likely to fail.

Not my experience. They can and do return -EPROBE_DEFER with some drivers. No idea about this one in particular.

Quoted 156 lines

Now I could see replacing irq_of_parse_and_map() with the more standard platform_get_irq(), but you haven't given a reasonable reason. And it should be a separate patch since it has nothing to do with streamlining the error handling and dropping the remove function.

Quoted 9 lines

Switch from devm_clk_get() + clk_prepare_enable() to devm_clk_get_enabled(), which combines both operations and registers devres callbacks for automatic disable/unprepare on unbind. This eliminates the manual err_disable_unprepare error path and the remove callback entirely.

Use devm_mbox_controller_register() for devres-managed controller registration, and drop the remove callback and platform_set_drvdata() which are no longer needed.

These two are what are important.

Quoted 104 lines
Assisted-by Opencode:Big-Pickle
---
 drivers/mailbox/sun6i-msgbox.c | 62 ++++++++++------------------------
 1 file changed, 18 insertions(+), 44 deletions(-)
drivers/mailbox/sun6i-msgbox.c +17 -35
index 6ba6920f4645..28d8636afad2 100644
@@ -198,7 +198,17 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
        struct mbox_chan *chans;
        struct reset_control *reset;
        struct sun6i_msgbox *mbox;
+       void __iomem *regs;
        int i, ret;
+       int irq;
+
+       irq = platform_get_irq(pdev, 0);
+       if (irq < 0)
+               return irq;
+
+       regs = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(regs))
+               return PTR_ERR(regs);
 
        mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL);
        if (!mbox)
@@ -211,24 +221,18 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
        for (i = 0; i < NUM_CHANS; ++i)
                chans[i].con_priv = mbox;
 
-       mbox->clk = devm_clk_get(dev, NULL);
+       mbox->clk = devm_clk_get_enabled(dev, NULL);
        if (IS_ERR(mbox->clk)) {
                ret = PTR_ERR(mbox->clk);
                dev_err(dev, "Failed to get clock: %d\n", ret);
                return ret;
        }
 
-       ret = clk_prepare_enable(mbox->clk);
-       if (ret) {
-               dev_err(dev, "Failed to enable clock: %d\n", ret);
-               return ret;
-       }
-
        reset = devm_reset_control_get_exclusive(dev, NULL);
        if (IS_ERR(reset)) {
                ret = PTR_ERR(reset);
                dev_err(dev, "Failed to get reset control: %d\n", ret);
-               goto err_disable_unprepare;
+               return ret;
        }
 
        /*
@@ -242,25 +246,17 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
        ret = reset_control_deassert(reset);
        if (ret) {
                dev_err(dev, "Failed to deassert reset: %d\n", ret);
-               goto err_disable_unprepare;
+               return ret;
        }
 
-       mbox->regs = devm_platform_ioremap_resource(pdev, 0);
-       if (IS_ERR(mbox->regs)) {
-               ret = PTR_ERR(mbox->regs);
-               dev_err(dev, "Failed to map MMIO resource: %d\n", ret);
-               goto err_disable_unprepare;
-       }
+       mbox->regs = regs;
 
        /* Disable all IRQs for this end of the msgbox. */
        writel(0, mbox->regs + LOCAL_IRQ_EN_REG);
 
-       ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0),
-                              sun6i_msgbox_irq, 0, dev_name(dev), mbox);
-       if (ret) {
-               dev_err(dev, "Failed to register IRQ handler: %d\n", ret);
-               goto err_disable_unprepare;
-       }
+       ret = devm_request_irq(dev, irq, sun6i_msgbox_irq, 0, dev_name(dev), mbox);
+       if (ret)
+               return ret;
 
        mbox->controller.dev           = dev;
        mbox->controller.ops           = &sun6i_msgbox_chan_ops;
@@ -271,29 +267,8 @@ static int sun6i_msgbox_probe(struct platform_device *pdev)
        mbox->controller.txpoll_period = 5;
 
        spin_lock_init(&mbox->lock);
-       platform_set_drvdata(pdev, mbox);
-
-       ret = mbox_controller_register(&mbox->controller);
-       if (ret) {
-               dev_err(dev, "Failed to register controller: %d\n", ret);
-               goto err_disable_unprepare;
-       }
-
-       return 0;
-
-err_disable_unprepare:
-       clk_disable_unprepare(mbox->clk);
-
-       return ret;

drivers/mailbox/sun6i-msgbox.c static int sun6i_msgbox_probe(struct platform_device *pdev) · line 271

Quoted 10 lines
drivers/mailbox/sun6i-msgbox.c +1 -8
-}
-
-static void sun6i_msgbox_remove(struct platform_device *pdev)
-{
-       struct sun6i_msgbox *mbox = platform_get_drvdata(pdev);
 
-       mbox_controller_unregister(&mbox->controller);
-       /* See the comment in sun6i_msgbox_probe about the reset line. */
-       clk_disable_unprepare(mbox->clk);
+       return devm_mbox_controller_register(&mbox->controller);

Like Sashiko said, this doesn't compile. All devm_*() functions require a |struct device *| parameter.

Build testing your patch before sending it is a must.

ChenYu

Quoted 14 lines
drivers/mailbox/sun6i-msgbox.c +0 -2
 }
 
 static const struct of_device_id sun6i_msgbox_of_match[] = {
@@ -308,7 +283,6 @@ static struct platform_driver sun6i_msgbox_driver = {
                .of_match_table = sun6i_msgbox_of_match,
        },
        .probe = sun6i_msgbox_probe,
-       .remove = sun6i_msgbox_remove,
 };
 module_platform_driver(sun6i_msgbox_driver);
 
--

2.55.0

#4 lore raw
In reply to Rosen Penev
kernel test robot noticed the following build errors:

Hi Rosen,

kernel test robot noticed the following build errors:

[auto build test ERROR on sunxi/sunxi/for-next]
[also build test ERROR on linus/master v7.2-rc6 next-20260806] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/mailbox-sun6i-modernize-probe-and-convert-to-fully-managed/20260807-054041
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux.git sunxi/for-next
patch link:    https://lore.kernel.org/r/20260727194208.10082-1-rosenp%40gmail.com
patch subject: [PATCH] mailbox: sun6i: modernize probe and convert to fully managed
config: alpha-allmodconfig (https://download.01.org/0day-ci/archive/20260807/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 16.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260807/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/mailbox/sun6i-msgbox.c: In function 'sun6i_msgbox_probe':

>> drivers/mailbox/sun6i-msgbox.c:271:46: error: passing argument 1 of 'devm_mbox_controller_register' from incompatible pointer type [-Wincompatible-pointer-types]
     271 |         return devm_mbox_controller_register(&mbox->controller);
         |                                              ^~~~~~~~~~~~~~~~~
         |                                              |
         |                                              struct mbox_controller *
   In file included from drivers/mailbox/sun6i-msgbox.c:12:
   include/linux/mailbox_controller.h:149:50: note: expected 'struct device *' but argument is of type 'struct mbox_controller *'
     149 | int devm_mbox_controller_register(struct device *dev,
         |                                   ~~~~~~~~~~~~~~~^~~
>> drivers/mailbox/sun6i-msgbox.c:271:16: error: too few arguments to function 'devm_mbox_controller_register'; expected 2, have 1
     271 |         return devm_mbox_controller_register(&mbox->controller);
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

include/linux/mailbox_controller.h:149:5: note: declared here
149 | int devm_mbox_controller_register(struct device *dev,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/devm_mbox_controller_register +271 drivers/mailbox/sun6i-msgbox.c

194
195 static int sun6i_msgbox_probe(struct platform_device *pdev)
196 {
197 struct device *dev = &pdev->dev;
198 struct mbox_chan *chans;
199 struct reset_control *reset;
200 struct sun6i_msgbox *mbox;
201 void __iomem *regs;
202 int i, ret;
203 int irq;
204
205 irq = platform_get_irq(pdev, 0);
206 if (irq < 0)
207 return irq;
208
209 regs = devm_platform_ioremap_resource(pdev, 0);
210 if (IS_ERR(regs))
211 return PTR_ERR(regs);
212
213 mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL);
214 if (!mbox)
215 return -ENOMEM;
216
217 chans = devm_kcalloc(dev, NUM_CHANS, sizeof(*chans), GFP_KERNEL);
218 if (!chans)
219 return -ENOMEM;
220
221 for (i = 0; i < NUM_CHANS; ++i)
222 chans[i].con_priv = mbox;
223
224 mbox->clk = devm_clk_get_enabled(dev, NULL);
225 if (IS_ERR(mbox->clk)) {
226 ret = PTR_ERR(mbox->clk);
227 dev_err(dev, "Failed to get clock: %d\n", ret);
228 return ret;
229 }
230
231 reset = devm_reset_control_get_exclusive(dev, NULL);
232 if (IS_ERR(reset)) {
233 ret = PTR_ERR(reset);
234 dev_err(dev, "Failed to get reset control: %d\n", ret);
235 return ret;
236 }
237
238 /*
239 * NOTE: We rely on platform firmware to preconfigure the channel
240 * directions, and we share this hardware block with other firmware
241 * that runs concurrently with Linux (e.g. a trusted monitor).
242 *
243 * Therefore, we do *not* assert the reset line if probing fails or
244 * when removing the device.
245 */
246 ret = reset_control_deassert(reset);
247 if (ret) {
248 dev_err(dev, "Failed to deassert reset: %d\n", ret);
249 return ret;
250 }
251
252 mbox->regs = regs;
253
254 /* Disable all IRQs for this end of the msgbox. */
255 writel(0, mbox->regs + LOCAL_IRQ_EN_REG);
256
257 ret = devm_request_irq(dev, irq, sun6i_msgbox_irq, 0, dev_name(dev), mbox);
258 if (ret)
259 return ret;
260

   261		mbox->controller.dev           = dev;
   262		mbox->controller.ops           = &sun6i_msgbox_chan_ops;
   263		mbox->controller.chans         = chans;
   264		mbox->controller.num_chans     = NUM_CHANS;
   265		mbox->controller.txdone_irq    = false;
   266		mbox->controller.txdone_poll   = true;
   267		mbox->controller.txpoll_period = 5;
   268	
   269		spin_lock_init(&mbox->lock);
   270	
 > 271		return devm_mbox_controller_register(&mbox->controller);

272 }
273

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

#5 lore raw
In reply to Rosen Penev
kernel test robot noticed the following build errors:

Hi Rosen,

kernel test robot noticed the following build errors:

[auto build test ERROR on sunxi/sunxi/for-next]
[also build test ERROR on linus/master v7.2-rc6 next-20260806] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Rosen-Penev/mailbox-sun6i-modernize-probe-and-convert-to-fully-managed/20260807-054041
base:   https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux.git sunxi/for-next
patch link:    https://lore.kernel.org/r/20260727194208.10082-1-rosenp%40gmail.com
patch subject: [PATCH] mailbox: sun6i: modernize probe and convert to fully managed
config: arm64-randconfig-001-20260807 (https://download.01.org/0day-ci/archive/20260808/[email protected]/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 12df34b8469b8095359de8c249cb1b2753fadeea)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260808/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> drivers/mailbox/sun6i-msgbox.c:271:56: error: too few arguments to function call, expected 2, have 1
     271 |         return devm_mbox_controller_register(&mbox->controller);
         |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                  ^
   include/linux/mailbox_controller.h:149:5: note: 'devm_mbox_controller_register' declared here
     149 | int devm_mbox_controller_register(struct device *dev,
         |     ^                             ~~~~~~~~~~~~~~~~~~~
     150 |                                   struct mbox_controller *mbox);
         |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

1 error generated.

vim +271 drivers/mailbox/sun6i-msgbox.c

194
195 static int sun6i_msgbox_probe(struct platform_device *pdev)
196 {
197 struct device *dev = &pdev->dev;
198 struct mbox_chan *chans;
199 struct reset_control *reset;
200 struct sun6i_msgbox *mbox;
201 void __iomem *regs;
202 int i, ret;
203 int irq;
204
205 irq = platform_get_irq(pdev, 0);
206 if (irq < 0)
207 return irq;
208
209 regs = devm_platform_ioremap_resource(pdev, 0);
210 if (IS_ERR(regs))
211 return PTR_ERR(regs);
212
213 mbox = devm_kzalloc(dev, sizeof(*mbox), GFP_KERNEL);
214 if (!mbox)
215 return -ENOMEM;
216
217 chans = devm_kcalloc(dev, NUM_CHANS, sizeof(*chans), GFP_KERNEL);
218 if (!chans)
219 return -ENOMEM;
220
221 for (i = 0; i < NUM_CHANS; ++i)
222 chans[i].con_priv = mbox;
223
224 mbox->clk = devm_clk_get_enabled(dev, NULL);
225 if (IS_ERR(mbox->clk)) {
226 ret = PTR_ERR(mbox->clk);
227 dev_err(dev, "Failed to get clock: %d\n", ret);
228 return ret;
229 }
230
231 reset = devm_reset_control_get_exclusive(dev, NULL);
232 if (IS_ERR(reset)) {
233 ret = PTR_ERR(reset);
234 dev_err(dev, "Failed to get reset control: %d\n", ret);
235 return ret;
236 }
237
238 /*
239 * NOTE: We rely on platform firmware to preconfigure the channel
240 * directions, and we share this hardware block with other firmware
241 * that runs concurrently with Linux (e.g. a trusted monitor).
242 *
243 * Therefore, we do *not* assert the reset line if probing fails or
244 * when removing the device.
245 */
246 ret = reset_control_deassert(reset);
247 if (ret) {
248 dev_err(dev, "Failed to deassert reset: %d\n", ret);
249 return ret;
250 }
251
252 mbox->regs = regs;
253
254 /* Disable all IRQs for this end of the msgbox. */
255 writel(0, mbox->regs + LOCAL_IRQ_EN_REG);
256
257 ret = devm_request_irq(dev, irq, sun6i_msgbox_irq, 0, dev_name(dev), mbox);
258 if (ret)
259 return ret;
260

   261		mbox->controller.dev           = dev;
   262		mbox->controller.ops           = &sun6i_msgbox_chan_ops;
   263		mbox->controller.chans         = chans;
   264		mbox->controller.num_chans     = NUM_CHANS;
   265		mbox->controller.txdone_irq    = false;
   266		mbox->controller.txdone_poll   = true;
   267		mbox->controller.txpoll_period = 5;
   268	
   269		spin_lock_init(&mbox->lock);
   270	
 > 271		return devm_mbox_controller_register(&mbox->controller);

272 }
273

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki