All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/19] mailbox: Device-managed registration
@ 2018-12-17 15:01 Thierry Reding
  2018-12-17 15:01 ` [PATCH v2 01/19] mailbox: Add device-managed registration functions Thierry Reding
                   ` (18 more replies)
  0 siblings, 19 replies; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:01 UTC (permalink / raw)
  To: Jassi Brar
  Cc: linux-kernel, Andy Gospodarek, Anup Patel, Bjorn Andersson,
	Caesar Wang, CK Hu, Dong Aisheng, Duc Dang, Eric Anholt,
	Fabien Dessenne, Feng Kan, Florian Fainelli, Georgi Djakov,
	Houlong Wei, HS Liao, Jon Mason, Kaihua Zhong, Kevin Wangtao,
	Lee Jones, Leo Yan, Ley Foon Tan, Ludovic Barre, Neil Armstrong,
	Nishanth Menon, Oleksij Rempel, Ray Jui, Rob Rice, Ruyi Wang,
	Scott Branden, Sibi Sankar, Stefan Wahren, Steve Lin,
	Sudeep Holla, Suman Anna, Tony Lindgren, Vikram Prakash,
	Vladimir Zapolskiy

From: Thierry Reding <treding@nvidia.com>

Hi,

This series of patches adds device-managed registration functions for
mailbox controllers. A number of drivers can be simplified by making use
of this new API both in the error cleanup paths in their probe functions
and in the driver remove implementation.

In addition to adding the new API this series converts all drivers to
use it. There is also an additional cleanup patch for the mtk-cmdq
driver that removes some calls to devm_kfree() that are not needed.

Thierry

Thierry Reding (19):
  mailbox: Add device-managed registration functions
  mailbox: arm-mhu: Use device-managed registration API
  mailbox: bcm2835: Use device-managed registration API
  mailbox: bcm-flexrm: Use device-managed registration API
  mailbox: bcm-pdc: Use device-managed registration API
  mailbox: hi3660: Use device-managed registration API
  mailbox: hi6220: Use device-managed registration API
  mailbox: imx: Use device-managed registration API
  mailbox: altera: Use device-managed registration API
  mailbox: sti: Use device-managed registration API
  mailbox: xgene-slimpro: Use device-managed registration API
  mailbox: mtk-cmdq: Use device-managed registration API
  mailbox: mtk-cmdq: Remove needless devm_kfree() calls
  mailbox: omap: Use device-managed registration API
  mailbox: platform-mhu: Use device-managed registration API
  mailbox: qcom-apcs: Use device-managed registration API
  mailbox: rockchip: Use device-managed registration API
  mailbox: stm32-ipcc: Use device-managed registration API
  mailbox: ti-msgmgr: Use device-managed registration API

 drivers/mailbox/arm_mhu.c               | 12 +----
 drivers/mailbox/bcm-flexrm-mailbox.c    |  4 +-
 drivers/mailbox/bcm-pdc-mailbox.c       |  4 +-
 drivers/mailbox/bcm2835-mailbox.c       | 10 +---
 drivers/mailbox/hi3660-mailbox.c        | 11 +---
 drivers/mailbox/hi6220-mailbox.c        | 11 +---
 drivers/mailbox/imx-mailbox.c           |  3 +-
 drivers/mailbox/mailbox-altera.c        | 15 +-----
 drivers/mailbox/mailbox-sti.c           | 13 +----
 drivers/mailbox/mailbox-xgene-slimpro.c | 11 +---
 drivers/mailbox/mailbox.c               | 70 +++++++++++++++++++++++++
 drivers/mailbox/mtk-cmdq-mailbox.c      | 11 +---
 drivers/mailbox/omap-mailbox.c          |  4 +-
 drivers/mailbox/platform_mhu.c          | 12 +----
 drivers/mailbox/qcom-apcs-ipc-mailbox.c |  3 +-
 drivers/mailbox/rockchip-mailbox.c      | 15 +-----
 drivers/mailbox/stm32-ipcc.c            |  4 +-
 drivers/mailbox/ti-msgmgr.c             | 13 +----
 include/linux/mailbox_controller.h      |  5 ++
 19 files changed, 92 insertions(+), 139 deletions(-)

-- 
2.19.1


^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH v2 01/19] mailbox: Add device-managed registration functions
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
@ 2018-12-17 15:01 ` Thierry Reding
  2018-12-17 18:15   ` Bjorn Andersson
  2018-12-18 16:04   ` Sudeep Holla
  2018-12-17 15:02 ` [PATCH v2 02/19] mailbox: arm-mhu: Use device-managed registration API Thierry Reding
                   ` (17 subsequent siblings)
  18 siblings, 2 replies; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:01 UTC (permalink / raw)
  To: Jassi Brar
  Cc: linux-kernel, Andy Gospodarek, Anup Patel, Bjorn Andersson,
	Caesar Wang, CK Hu, Dong Aisheng, Duc Dang, Eric Anholt,
	Fabien Dessenne, Feng Kan, Florian Fainelli, Georgi Djakov,
	Houlong Wei, HS Liao, Jon Mason, Kaihua Zhong, Kevin Wangtao,
	Lee Jones, Leo Yan, Ley Foon Tan, Ludovic Barre, Neil Armstrong,
	Nishanth Menon, Oleksij Rempel, Ray Jui, Rob Rice, Ruyi Wang,
	Scott Branden, Sibi Sankar, Stefan Wahren, Steve Lin,
	Sudeep Holla, Suman Anna, Tony Lindgren, Vikram Prakash,
	Vladimir Zapolskiy

From: Thierry Reding <treding@nvidia.com>

Add device-managed equivalents of the mbox_controller_register() and
mbox_controller_unregister() functions that can be used to have the
devres infrastructure automatically unregister mailbox controllers on
driver probe failure or driver removal. This can help remove a lot of
boiler plate code from drivers.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/mailbox.c          | 70 ++++++++++++++++++++++++++++++
 include/linux/mailbox_controller.h |  5 +++
 2 files changed, 75 insertions(+)

diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 674b35f402f5..eb781e2b19cb 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -515,3 +515,73 @@ void mbox_controller_unregister(struct mbox_controller *mbox)
 	mutex_unlock(&con_mutex);
 }
 EXPORT_SYMBOL_GPL(mbox_controller_unregister);
+
+static void __devm_mbox_controller_unregister(struct device *dev, void *res)
+{
+	struct mbox_controller *mbox = res;
+
+	mbox_controller_unregister(mbox);
+}
+
+static int devm_mbox_controller_match(struct device *dev, void *res, void *data)
+{
+	struct mbox_controller **mbox = res;
+
+	if (WARN_ON(!mbox || !*mbox))
+		return 0;
+
+	return *mbox == data;
+}
+
+/**
+ * devm_mbox_controller_register() - managed mbox_controller_register()
+ * @dev: device owning the mailbox controller being registered
+ * @mbox: mailbox controller being registered
+ *
+ * This function adds a device-managed resource that will make sure that the
+ * mailbox controller, which is registered using mbox_controller_register()
+ * as part of this function, will be unregistered along with the rest of
+ * device-managed resources upon driver probe failure or driver removal.
+ *
+ * Returns 0 on success or a negative error code on failure.
+ */
+int devm_mbox_controller_register(struct device *dev,
+				  struct mbox_controller *mbox)
+{
+	struct mbox_controller **ptr;
+	int err;
+
+	ptr = devres_alloc(__devm_mbox_controller_unregister, sizeof(*ptr),
+			   GFP_KERNEL);
+	if (!ptr)
+		return -ENOMEM;
+
+	err = mbox_controller_register(mbox);
+	if (err < 0) {
+		devres_free(ptr);
+		return err;
+	}
+
+	devres_add(dev, ptr);
+	*ptr = mbox;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(devm_mbox_controller_register);
+
+/**
+ * devm_mbox_controller_unregister() - managed mbox_controller_unregister()
+ * @dev: device owning the mailbox controller being unregistered
+ * @mbox: mailbox controller being unregistered
+ *
+ * This function unregisters the mailbox controller and removes the device-
+ * managed resource that was set up to automatically unregister the mailbox
+ * controller on driver probe failure or driver removal. It's typically not
+ * necessary to call this function.
+ */
+void devm_mbox_controller_unregister(struct device *dev, struct mbox_controller *mbox)
+{
+	WARN_ON(devres_release(dev, __devm_mbox_controller_unregister,
+			       devm_mbox_controller_match, mbox));
+}
+EXPORT_SYMBOL_GPL(devm_mbox_controller_unregister);
diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h
index 74deadb42d76..9b0b21207345 100644
--- a/include/linux/mailbox_controller.h
+++ b/include/linux/mailbox_controller.h
@@ -131,4 +131,9 @@ void mbox_controller_unregister(struct mbox_controller *mbox); /* can sleep */
 void mbox_chan_received_data(struct mbox_chan *chan, void *data); /* atomic */
 void mbox_chan_txdone(struct mbox_chan *chan, int r); /* atomic */
 
+int devm_mbox_controller_register(struct device *dev,
+				  struct mbox_controller *mbox);
+void devm_mbox_controller_unregister(struct device *dev,
+				     struct mbox_controller *mbox);
+
 #endif /* __MAILBOX_CONTROLLER_H */
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 02/19] mailbox: arm-mhu: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
  2018-12-17 15:01 ` [PATCH v2 01/19] mailbox: Add device-managed registration functions Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-18 16:07   ` Sudeep Holla
  2018-12-17 15:02 ` [PATCH v2 03/19] mailbox: bcm2835: " Thierry Reding
                   ` (16 subsequent siblings)
  18 siblings, 1 reply; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Sudeep Holla

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/arm_mhu.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/mailbox/arm_mhu.c b/drivers/mailbox/arm_mhu.c
index 99befa76e37c..64d85c6a2bdf 100644
--- a/drivers/mailbox/arm_mhu.c
+++ b/drivers/mailbox/arm_mhu.c
@@ -152,7 +152,7 @@ static int mhu_probe(struct amba_device *adev, const struct amba_id *id)
 
 	amba_set_drvdata(adev, mhu);
 
-	err = mbox_controller_register(&mhu->mbox);
+	err = devm_mbox_controller_register(dev, &mhu->mbox);
 	if (err) {
 		dev_err(dev, "Failed to register mailboxes %d\n", err);
 		return err;
@@ -162,15 +162,6 @@ static int mhu_probe(struct amba_device *adev, const struct amba_id *id)
 	return 0;
 }
 
-static int mhu_remove(struct amba_device *adev)
-{
-	struct arm_mhu *mhu = amba_get_drvdata(adev);
-
-	mbox_controller_unregister(&mhu->mbox);
-
-	return 0;
-}
-
 static struct amba_id mhu_ids[] = {
 	{
 		.id	= 0x1bb098,
@@ -186,7 +177,6 @@ static struct amba_driver arm_mhu_driver = {
 	},
 	.id_table	= mhu_ids,
 	.probe		= mhu_probe,
-	.remove		= mhu_remove,
 };
 module_amba_driver(arm_mhu_driver);
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 03/19] mailbox: bcm2835: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
  2018-12-17 15:01 ` [PATCH v2 01/19] mailbox: Add device-managed registration functions Thierry Reding
  2018-12-17 15:02 ` [PATCH v2 02/19] mailbox: arm-mhu: Use device-managed registration API Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-18 19:24   ` Eric Anholt
  2018-12-17 15:02 ` [PATCH v2 04/19] mailbox: bcm-flexrm: " Thierry Reding
                   ` (15 subsequent siblings)
  18 siblings, 1 reply; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Eric Anholt, Stefan Wahren

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Eric Anholt <eric@anholt.net>
Cc: Stefan Wahren <stefan.wahren@i2se.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/bcm2835-mailbox.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/mailbox/bcm2835-mailbox.c b/drivers/mailbox/bcm2835-mailbox.c
index bb3ee728169d..39761d190545 100644
--- a/drivers/mailbox/bcm2835-mailbox.c
+++ b/drivers/mailbox/bcm2835-mailbox.c
@@ -172,7 +172,7 @@ static int bcm2835_mbox_probe(struct platform_device *pdev)
 	if (!mbox->controller.chans)
 		return -ENOMEM;
 
-	ret = mbox_controller_register(&mbox->controller);
+	ret = devm_mbox_controller_register(dev, &mbox->controller);
 	if (ret)
 		return ret;
 
@@ -182,13 +182,6 @@ static int bcm2835_mbox_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int bcm2835_mbox_remove(struct platform_device *pdev)
-{
-	struct bcm2835_mbox *mbox = platform_get_drvdata(pdev);
-	mbox_controller_unregister(&mbox->controller);
-	return 0;
-}
-
 static const struct of_device_id bcm2835_mbox_of_match[] = {
 	{ .compatible = "brcm,bcm2835-mbox", },
 	{},
@@ -201,7 +194,6 @@ static struct platform_driver bcm2835_mbox_driver = {
 		.of_match_table = bcm2835_mbox_of_match,
 	},
 	.probe		= bcm2835_mbox_probe,
-	.remove		= bcm2835_mbox_remove,
 };
 module_platform_driver(bcm2835_mbox_driver);
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 04/19] mailbox: bcm-flexrm: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (2 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 03/19] mailbox: bcm2835: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-17 15:02 ` [PATCH v2 05/19] mailbox: bcm-pdc: " Thierry Reding
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar
  Cc: linux-kernel, Vikram Prakash, Scott Branden, Florian Fainelli,
	Anup Patel, Ray Jui

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Vikram Prakash <vikram.prakash@broadcom.com>
Cc: Scott Branden <scott.branden@broadcom.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Anup Patel <anup.patel@broadcom.com>
Cc: Ray Jui <ray.jui@broadcom.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/bcm-flexrm-mailbox.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mailbox/bcm-flexrm-mailbox.c b/drivers/mailbox/bcm-flexrm-mailbox.c
index d7a8ed7d8097..d713271ebf7c 100644
--- a/drivers/mailbox/bcm-flexrm-mailbox.c
+++ b/drivers/mailbox/bcm-flexrm-mailbox.c
@@ -1665,7 +1665,7 @@ static int flexrm_mbox_probe(struct platform_device *pdev)
 		mbox->controller.chans[index].con_priv = &mbox->rings[index];
 
 	/* Register mailbox controller */
-	ret = mbox_controller_register(&mbox->controller);
+	ret = devm_mbox_controller_register(dev, &mbox->controller);
 	if (ret)
 		goto fail_free_debugfs_root;
 
@@ -1691,8 +1691,6 @@ static int flexrm_mbox_remove(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 	struct flexrm_mbox *mbox = platform_get_drvdata(pdev);
 
-	mbox_controller_unregister(&mbox->controller);
-
 	debugfs_remove_recursive(mbox->root);
 
 	platform_msi_domain_free_irqs(dev);
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 05/19] mailbox: bcm-pdc: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (3 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 04/19] mailbox: bcm-flexrm: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-17 15:02 ` [PATCH v2 06/19] mailbox: hi3660: " Thierry Reding
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar
  Cc: linux-kernel, Florian Fainelli, Steve Lin, Jon Mason, Rob Rice,
	Andy Gospodarek

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Steve Lin <steven.lin1@broadcom.com>
Cc: Jon Mason <jon.mason@broadcom.com>
Cc: Rob Rice <rob.rice@broadcom.com>
Cc: Andy Gospodarek <gospo@broadcom.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/bcm-pdc-mailbox.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mailbox/bcm-pdc-mailbox.c b/drivers/mailbox/bcm-pdc-mailbox.c
index 4fe7be0bdd11..ccf3d62af7e7 100644
--- a/drivers/mailbox/bcm-pdc-mailbox.c
+++ b/drivers/mailbox/bcm-pdc-mailbox.c
@@ -1471,7 +1471,7 @@ static int pdc_mb_init(struct pdc_state *pdcs)
 		mbc->chans[chan_index].con_priv = pdcs;
 
 	/* Register mailbox controller */
-	err = mbox_controller_register(mbc);
+	err = devm_mbox_controller_register(dev, mbc);
 	if (err) {
 		dev_crit(dev,
 			 "Failed to register PDC mailbox controller. Error %d.",
@@ -1641,8 +1641,6 @@ static int pdc_remove(struct platform_device *pdev)
 
 	pdc_hw_disable(pdcs);
 
-	mbox_controller_unregister(&pdcs->mbc);
-
 	dma_pool_destroy(pdcs->rx_buf_pool);
 	dma_pool_destroy(pdcs->ring_pool);
 	return 0;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 06/19] mailbox: hi3660: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (4 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 05/19] mailbox: bcm-pdc: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-18  9:16   ` leo.yan
  2018-12-17 15:02 ` [PATCH v2 07/19] mailbox: hi6220: " Thierry Reding
                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Kevin Wangtao, Kaihua Zhong, Ruyi Wang, Leo Yan

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Kevin Wangtao <kevin.wangtao@hisilicon.com>
Cc: Kaihua Zhong <zhongkaihua@huawei.com>
Cc: Ruyi Wang <wangruyi@huawei.com>
Cc: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/hi3660-mailbox.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/mailbox/hi3660-mailbox.c b/drivers/mailbox/hi3660-mailbox.c
index f9aed5d8f9f1..53f4bc2488c5 100644
--- a/drivers/mailbox/hi3660-mailbox.c
+++ b/drivers/mailbox/hi3660-mailbox.c
@@ -265,7 +265,7 @@ static int hi3660_mbox_probe(struct platform_device *pdev)
 	for (ch = 0; ch < MBOX_CHAN_MAX; ch++)
 		chan[ch].con_priv = (void *)ch;
 
-	err = mbox_controller_register(&mbox->controller);
+	err = devm_mbox_controller_register(dev, &mbox->controller);
 	if (err) {
 		dev_err(dev, "Failed to register mailbox %d\n", err);
 		return err;
@@ -276,17 +276,8 @@ static int hi3660_mbox_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int hi3660_mbox_remove(struct platform_device *pdev)
-{
-	struct hi3660_mbox *mbox = platform_get_drvdata(pdev);
-
-	mbox_controller_unregister(&mbox->controller);
-	return 0;
-}
-
 static struct platform_driver hi3660_mbox_driver = {
 	.probe  = hi3660_mbox_probe,
-	.remove = hi3660_mbox_remove,
 	.driver = {
 		.name = "hi3660-mbox",
 		.of_match_table = hi3660_mbox_of_match,
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 07/19] mailbox: hi6220: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (5 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 06/19] mailbox: hi3660: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-18  9:17   ` leo.yan
  2018-12-17 15:02 ` [PATCH v2 08/19] mailbox: imx: " Thierry Reding
                   ` (11 subsequent siblings)
  18 siblings, 1 reply; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Leo Yan

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Leo Yan <leo.yan@linaro.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/hi6220-mailbox.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/mailbox/hi6220-mailbox.c b/drivers/mailbox/hi6220-mailbox.c
index 4fa9803cd204..c32cbfaf223a 100644
--- a/drivers/mailbox/hi6220-mailbox.c
+++ b/drivers/mailbox/hi6220-mailbox.c
@@ -349,7 +349,7 @@ static int hi6220_mbox_probe(struct platform_device *pdev)
 		mbox->controller.txpoll_period = 5;
 	}
 
-	err = mbox_controller_register(&mbox->controller);
+	err = devm_mbox_controller_register(dev, &mbox->controller);
 	if (err) {
 		dev_err(dev, "Failed to register mailbox %d\n", err);
 		return err;
@@ -360,14 +360,6 @@ static int hi6220_mbox_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int hi6220_mbox_remove(struct platform_device *pdev)
-{
-	struct hi6220_mbox *mbox = platform_get_drvdata(pdev);
-
-	mbox_controller_unregister(&mbox->controller);
-	return 0;
-}
-
 static struct platform_driver hi6220_mbox_driver = {
 	.driver = {
 		.name = "hi6220-mbox",
@@ -375,7 +367,6 @@ static struct platform_driver hi6220_mbox_driver = {
 		.of_match_table = hi6220_mbox_of_match,
 	},
 	.probe	= hi6220_mbox_probe,
-	.remove	= hi6220_mbox_remove,
 };
 
 static int __init hi6220_mbox_init(void)
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 08/19] mailbox: imx: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (6 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 07/19] mailbox: hi6220: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-17 15:31   ` Oleksij Rempel
  2018-12-17 15:02 ` [PATCH v2 09/19] mailbox: altera: " Thierry Reding
                   ` (10 subsequent siblings)
  18 siblings, 1 reply; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Oleksij Rempel, Dong Aisheng, Vladimir Zapolskiy

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Dong Aisheng <aisheng.dong@nxp.com>
Cc: Vladimir Zapolskiy <vz@mleia.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/imx-mailbox.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c
index 363d35d5e49d..774362a05159 100644
--- a/drivers/mailbox/imx-mailbox.c
+++ b/drivers/mailbox/imx-mailbox.c
@@ -324,14 +324,13 @@ static int imx_mu_probe(struct platform_device *pdev)
 
 	imx_mu_init_generic(priv);
 
-	return mbox_controller_register(&priv->mbox);
+	return devm_mbox_controller_register(dev, &priv->mbox);
 }
 
 static int imx_mu_remove(struct platform_device *pdev)
 {
 	struct imx_mu_priv *priv = platform_get_drvdata(pdev);
 
-	mbox_controller_unregister(&priv->mbox);
 	clk_disable_unprepare(priv->clk);
 
 	return 0;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 09/19] mailbox: altera: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (7 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 08/19] mailbox: imx: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-17 15:02 ` [PATCH v2 10/19] mailbox: sti: " Thierry Reding
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Ley Foon Tan

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Ley Foon Tan <lftan@altera.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/mailbox-altera.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/mailbox/mailbox-altera.c b/drivers/mailbox/mailbox-altera.c
index bcb29df9549e..397e25ddae29 100644
--- a/drivers/mailbox/mailbox-altera.c
+++ b/drivers/mailbox/mailbox-altera.c
@@ -341,7 +341,7 @@ static int altera_mbox_probe(struct platform_device *pdev)
 		}
 	}
 
-	ret = mbox_controller_register(&mbox->controller);
+	ret = devm_mbox_controller_register(&pdev->dev, &mbox->controller);
 	if (ret) {
 		dev_err(&pdev->dev, "Register mailbox failed\n");
 		goto err;
@@ -352,18 +352,6 @@ static int altera_mbox_probe(struct platform_device *pdev)
 	return ret;
 }
 
-static int altera_mbox_remove(struct platform_device *pdev)
-{
-	struct altera_mbox *mbox = platform_get_drvdata(pdev);
-
-	if (!mbox)
-		return -EINVAL;
-
-	mbox_controller_unregister(&mbox->controller);
-
-	return 0;
-}
-
 static const struct of_device_id altera_mbox_match[] = {
 	{ .compatible = "altr,mailbox-1.0" },
 	{ /* Sentinel */ }
@@ -373,7 +361,6 @@ MODULE_DEVICE_TABLE(of, altera_mbox_match);
 
 static struct platform_driver altera_mbox_driver = {
 	.probe	= altera_mbox_probe,
-	.remove	= altera_mbox_remove,
 	.driver	= {
 		.name	= DRIVER_NAME,
 		.of_match_table	= altera_mbox_match,
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 10/19] mailbox: sti: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (8 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 09/19] mailbox: altera: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-18  8:27   ` Lee Jones
  2018-12-17 15:02 ` [PATCH v2 11/19] mailbox: xgene-slimpro: " Thierry Reding
                   ` (8 subsequent siblings)
  18 siblings, 1 reply; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Lee Jones

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/mailbox-sti.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/mailbox/mailbox-sti.c b/drivers/mailbox/mailbox-sti.c
index 779d41262ef0..adf82b85dbb2 100644
--- a/drivers/mailbox/mailbox-sti.c
+++ b/drivers/mailbox/mailbox-sti.c
@@ -462,7 +462,7 @@ static int sti_mbox_probe(struct platform_device *pdev)
 	mbox->chans		= chans;
 	mbox->num_chans		= STI_MBOX_CHAN_MAX;
 
-	ret = mbox_controller_register(mbox);
+	ret = devm_mbox_controller_register(&pdev->dev, mbox);
 	if (ret)
 		return ret;
 
@@ -480,7 +480,6 @@ static int sti_mbox_probe(struct platform_device *pdev)
 					IRQF_ONESHOT, mdev->name, mdev);
 	if (ret) {
 		dev_err(&pdev->dev, "Can't claim IRQ %d\n", irq);
-		mbox_controller_unregister(mbox);
 		return -EINVAL;
 	}
 
@@ -489,18 +488,8 @@ static int sti_mbox_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int sti_mbox_remove(struct platform_device *pdev)
-{
-	struct sti_mbox_device *mdev = platform_get_drvdata(pdev);
-
-	mbox_controller_unregister(mdev->mbox);
-
-	return 0;
-}
-
 static struct platform_driver sti_mbox_driver = {
 	.probe = sti_mbox_probe,
-	.remove = sti_mbox_remove,
 	.driver = {
 		.name = "sti-mailbox",
 		.of_match_table = sti_mailbox_match,
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 11/19] mailbox: xgene-slimpro: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (9 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 10/19] mailbox: sti: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-17 15:02 ` [PATCH v2 12/19] mailbox: mtk-cmdq: " Thierry Reding
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Duc Dang, Feng Kan

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Duc Dang <dhdang@apm.com>
Cc: Feng Kan <fkan@apm.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/mailbox-xgene-slimpro.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/mailbox/mailbox-xgene-slimpro.c b/drivers/mailbox/mailbox-xgene-slimpro.c
index b8b2b3533f46..8f397da1150b 100644
--- a/drivers/mailbox/mailbox-xgene-slimpro.c
+++ b/drivers/mailbox/mailbox-xgene-slimpro.c
@@ -224,7 +224,7 @@ static int slimpro_mbox_probe(struct platform_device *pdev)
 	ctx->mb_ctrl.ops = &slimpro_mbox_ops;
 	ctx->mb_ctrl.num_chans = i;
 
-	rc = mbox_controller_register(&ctx->mb_ctrl);
+	rc = devm_mbox_controller_register(&pdev->dev, &ctx->mb_ctrl);
 	if (rc) {
 		dev_err(&pdev->dev,
 			"APM X-Gene SLIMpro MailBox register failed:%d\n", rc);
@@ -235,14 +235,6 @@ static int slimpro_mbox_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int slimpro_mbox_remove(struct platform_device *pdev)
-{
-	struct slimpro_mbox *smb = platform_get_drvdata(pdev);
-
-	mbox_controller_unregister(&smb->mb_ctrl);
-	return 0;
-}
-
 static const struct of_device_id slimpro_of_match[] = {
 	{.compatible = "apm,xgene-slimpro-mbox" },
 	{ },
@@ -259,7 +251,6 @@ MODULE_DEVICE_TABLE(acpi, slimpro_acpi_ids);
 
 static struct platform_driver slimpro_mbox_driver = {
 	.probe	= slimpro_mbox_probe,
-	.remove = slimpro_mbox_remove,
 	.driver	= {
 		.name = "xgene-slimpro-mbox",
 		.of_match_table = of_match_ptr(slimpro_of_match),
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 12/19] mailbox: mtk-cmdq: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (10 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 11/19] mailbox: xgene-slimpro: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-17 15:02 ` [PATCH v2 13/19] mailbox: mtk-cmdq: Remove needless devm_kfree() calls Thierry Reding
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Houlong Wei, HS Liao, CK Hu

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Houlong Wei <houlong.wei@mediatek.com>
Cc: HS Liao <hs.liao@mediatek.com>
Cc: CK Hu <ck.hu@mediatek.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index f7cc29c00302..d9c3ec3667a8 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -337,7 +337,6 @@ static int cmdq_remove(struct platform_device *pdev)
 {
 	struct cmdq *cmdq = platform_get_drvdata(pdev);
 
-	mbox_controller_unregister(&cmdq->mbox);
 	clk_unprepare(cmdq->clock);
 
 	if (cmdq->mbox.chans)
@@ -524,7 +523,7 @@ static int cmdq_probe(struct platform_device *pdev)
 		cmdq->mbox.chans[i].con_priv = (void *)&cmdq->thread[i];
 	}
 
-	err = mbox_controller_register(&cmdq->mbox);
+	err = devm_mbox_controller_register(dev, &cmdq->mbox);
 	if (err < 0) {
 		dev_err(dev, "failed to register mailbox: %d\n", err);
 		return err;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 13/19] mailbox: mtk-cmdq: Remove needless devm_kfree() calls
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (11 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 12/19] mailbox: mtk-cmdq: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-17 15:02 ` [PATCH v2 14/19] mailbox: omap: Use device-managed registration API Thierry Reding
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Houlong Wei, HS Liao, CK Hu

From: Thierry Reding <treding@nvidia.com>

Memory allocated through device-managed functions doesn't need to be
explicitly freed, so these calls can be removed.

Cc: Houlong Wei <houlong.wei@mediatek.com>
Cc: HS Liao <hs.liao@mediatek.com>
Cc: CK Hu <ck.hu@mediatek.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/mtk-cmdq-mailbox.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c b/drivers/mailbox/mtk-cmdq-mailbox.c
index d9c3ec3667a8..22811784dc7d 100644
--- a/drivers/mailbox/mtk-cmdq-mailbox.c
+++ b/drivers/mailbox/mtk-cmdq-mailbox.c
@@ -339,14 +339,6 @@ static int cmdq_remove(struct platform_device *pdev)
 
 	clk_unprepare(cmdq->clock);
 
-	if (cmdq->mbox.chans)
-		devm_kfree(&pdev->dev, cmdq->mbox.chans);
-
-	if (cmdq->thread)
-		devm_kfree(&pdev->dev, cmdq->thread);
-
-	devm_kfree(&pdev->dev, cmdq);
-
 	return 0;
 }
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 14/19] mailbox: omap: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (12 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 13/19] mailbox: mtk-cmdq: Remove needless devm_kfree() calls Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-18  0:10   ` kbuild test robot
  2018-12-17 15:02 ` [PATCH v2 15/19] mailbox: platform-mhu: " Thierry Reding
                   ` (4 subsequent siblings)
  18 siblings, 1 reply; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Tony Lindgren, Suman Anna

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Tony Lindgren <tony@atomide.com>
Cc: Suman Anna <s-anna@ti.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/omap-mailbox.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c
index db66e952a871..7e54ebb7defe 100644
--- a/drivers/mailbox/omap-mailbox.c
+++ b/drivers/mailbox/omap-mailbox.c
@@ -486,7 +486,7 @@ static int omap_mbox_register(struct omap_mbox_device *mdev)
 	list_add(&mdev->elem, &omap_mbox_devices);
 	mutex_unlock(&omap_mbox_devices_lock);
 
-	ret = mbox_controller_register(&mdev->controller);
+	ret = devm_mbox_controller_register(&mdev->controller);
 
 err_out:
 	if (ret) {
@@ -508,8 +508,6 @@ static int omap_mbox_unregister(struct omap_mbox_device *mdev)
 	list_del(&mdev->elem);
 	mutex_unlock(&omap_mbox_devices_lock);
 
-	mbox_controller_unregister(&mdev->controller);
-
 	mboxes = mdev->mboxes;
 	for (i = 0; mboxes[i]; i++)
 		device_unregister(mboxes[i]->dev);
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 15/19] mailbox: platform-mhu: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (13 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 14/19] mailbox: omap: Use device-managed registration API Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-17 15:04   ` Neil Armstrong
  2018-12-17 15:02 ` [PATCH v2 16/19] mailbox: qcom-apcs: " Thierry Reding
                   ` (3 subsequent siblings)
  18 siblings, 1 reply; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Neil Armstrong

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/platform_mhu.c | 12 +-----------
 1 file changed, 1 insertion(+), 11 deletions(-)

diff --git a/drivers/mailbox/platform_mhu.c b/drivers/mailbox/platform_mhu.c
index e13201a5cec6..d2502c5be130 100644
--- a/drivers/mailbox/platform_mhu.c
+++ b/drivers/mailbox/platform_mhu.c
@@ -163,7 +163,7 @@ static int platform_mhu_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, mhu);
 
-	err = mbox_controller_register(&mhu->mbox);
+	err = devm_mbox_controller_register(dev, &mhu->mbox);
 	if (err) {
 		dev_err(dev, "Failed to register mailboxes %d\n", err);
 		return err;
@@ -173,15 +173,6 @@ static int platform_mhu_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int platform_mhu_remove(struct platform_device *pdev)
-{
-	struct platform_mhu *mhu = platform_get_drvdata(pdev);
-
-	mbox_controller_unregister(&mhu->mbox);
-
-	return 0;
-}
-
 static const struct of_device_id platform_mhu_dt_ids[] = {
 	{ .compatible = "amlogic,meson-gxbb-mhu", },
 	{ /* sentinel */ },
@@ -190,7 +181,6 @@ MODULE_DEVICE_TABLE(of, platform_mhu_dt_ids);
 
 static struct platform_driver platform_mhu_driver = {
 	.probe	= platform_mhu_probe,
-	.remove	= platform_mhu_remove,
 	.driver = {
 		.name = "platform-mhu",
 		.of_match_table	= platform_mhu_dt_ids,
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 16/19] mailbox: qcom-apcs: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (14 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 15/19] mailbox: platform-mhu: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-17 18:16   ` Bjorn Andersson
  2018-12-17 15:02 ` [PATCH v2 17/19] mailbox: rockchip: " Thierry Reding
                   ` (2 subsequent siblings)
  18 siblings, 1 reply; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Bjorn Andersson, Georgi Djakov, Sibi Sankar

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Georgi Djakov <georgi.djakov@linaro.org>
Cc: Sibi Sankar <sibis@codeaurora.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/qcom-apcs-ipc-mailbox.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mailbox/qcom-apcs-ipc-mailbox.c b/drivers/mailbox/qcom-apcs-ipc-mailbox.c
index aed23ac9550d..3cf2937be149 100644
--- a/drivers/mailbox/qcom-apcs-ipc-mailbox.c
+++ b/drivers/mailbox/qcom-apcs-ipc-mailbox.c
@@ -91,7 +91,7 @@ static int qcom_apcs_ipc_probe(struct platform_device *pdev)
 	apcs->mbox.chans = apcs->mbox_chans;
 	apcs->mbox.num_chans = ARRAY_SIZE(apcs->mbox_chans);
 
-	ret = mbox_controller_register(&apcs->mbox);
+	ret = devm_mbox_controller_register(&pdev->dev, &apcs->mbox);
 	if (ret) {
 		dev_err(&pdev->dev, "failed to register APCS IPC controller\n");
 		return ret;
@@ -115,7 +115,6 @@ static int qcom_apcs_ipc_remove(struct platform_device *pdev)
 	struct qcom_apcs_ipc *apcs = platform_get_drvdata(pdev);
 	struct platform_device *clk = apcs->clk;
 
-	mbox_controller_unregister(&apcs->mbox);
 	platform_device_unregister(clk);
 
 	return 0;
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 17/19] mailbox: rockchip: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (15 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 16/19] mailbox: qcom-apcs: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-18  0:36   ` Caesar Wang
  2018-12-17 15:02 ` [PATCH v2 18/19] mailbox: stm32-ipcc: " Thierry Reding
  2018-12-17 15:02 ` [PATCH v2 19/19] mailbox: ti-msgmgr: " Thierry Reding
  18 siblings, 1 reply; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Caesar Wang

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Caesar Wang <wxt@rock-chips.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/rockchip-mailbox.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/mailbox/rockchip-mailbox.c b/drivers/mailbox/rockchip-mailbox.c
index d702a204f5c1..f24a77b1a0ff 100644
--- a/drivers/mailbox/rockchip-mailbox.c
+++ b/drivers/mailbox/rockchip-mailbox.c
@@ -247,28 +247,15 @@ static int rockchip_mbox_probe(struct platform_device *pdev)
 		mb->chans[i].msg = NULL;
 	}
 
-	ret = mbox_controller_register(&mb->mbox);
+	ret = devm_mbox_controller_register(&pdev->dev, &mb->mbox);
 	if (ret < 0)
 		dev_err(&pdev->dev, "Failed to register mailbox: %d\n", ret);
 
 	return ret;
 }
 
-static int rockchip_mbox_remove(struct platform_device *pdev)
-{
-	struct rockchip_mbox *mb = platform_get_drvdata(pdev);
-
-	if (!mb)
-		return -EINVAL;
-
-	mbox_controller_unregister(&mb->mbox);
-
-	return 0;
-}
-
 static struct platform_driver rockchip_mbox_driver = {
 	.probe	= rockchip_mbox_probe,
-	.remove	= rockchip_mbox_remove,
 	.driver = {
 		.name = "rockchip-mailbox",
 		.of_match_table = of_match_ptr(rockchip_mbox_of_match),
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 18/19] mailbox: stm32-ipcc: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (16 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 17/19] mailbox: rockchip: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  2018-12-18  8:26   ` Ludovic BARRE
  2018-12-17 15:02 ` [PATCH v2 19/19] mailbox: ti-msgmgr: " Thierry Reding
  18 siblings, 1 reply; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Fabien Dessenne, Ludovic Barre

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Fabien Dessenne <fabien.dessenne@st.com>
Cc: Ludovic Barre <ludovic.barre@st.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/stm32-ipcc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/mailbox/stm32-ipcc.c b/drivers/mailbox/stm32-ipcc.c
index 533b0da5235d..a338bd4cd7db 100644
--- a/drivers/mailbox/stm32-ipcc.c
+++ b/drivers/mailbox/stm32-ipcc.c
@@ -299,7 +299,7 @@ static int stm32_ipcc_probe(struct platform_device *pdev)
 	for (i = 0; i < ipcc->controller.num_chans; i++)
 		ipcc->controller.chans[i].con_priv = (void *)i;
 
-	ret = mbox_controller_register(&ipcc->controller);
+	ret = devm_mbox_controller_register(dev, &ipcc->controller);
 	if (ret)
 		goto err_irq_wkp;
 
@@ -329,8 +329,6 @@ static int stm32_ipcc_remove(struct platform_device *pdev)
 {
 	struct stm32_ipcc *ipcc = platform_get_drvdata(pdev);
 
-	mbox_controller_unregister(&ipcc->controller);
-
 	if (ipcc->wkp)
 		dev_pm_clear_wake_irq(&pdev->dev);
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH v2 19/19] mailbox: ti-msgmgr: Use device-managed registration API
  2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
                   ` (17 preceding siblings ...)
  2018-12-17 15:02 ` [PATCH v2 18/19] mailbox: stm32-ipcc: " Thierry Reding
@ 2018-12-17 15:02 ` Thierry Reding
  18 siblings, 0 replies; 33+ messages in thread
From: Thierry Reding @ 2018-12-17 15:02 UTC (permalink / raw)
  To: Jassi Brar; +Cc: linux-kernel, Nishanth Menon

From: Thierry Reding <treding@nvidia.com>

Get rid of some boilerplate driver removal code by using the newly added
device-managed registration API.

Cc: Nishanth Menon <nm@ti.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/mailbox/ti-msgmgr.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/mailbox/ti-msgmgr.c b/drivers/mailbox/ti-msgmgr.c
index 6f6addd51d14..88047d835211 100644
--- a/drivers/mailbox/ti-msgmgr.c
+++ b/drivers/mailbox/ti-msgmgr.c
@@ -817,26 +817,15 @@ static int ti_msgmgr_probe(struct platform_device *pdev)
 	mbox->of_xlate = ti_msgmgr_of_xlate;
 
 	platform_set_drvdata(pdev, inst);
-	ret = mbox_controller_register(mbox);
+	ret = devm_mbox_controller_register(dev, mbox);
 	if (ret)
 		dev_err(dev, "Failed to register mbox_controller(%d)\n", ret);
 
 	return ret;
 }
 
-static int ti_msgmgr_remove(struct platform_device *pdev)
-{
-	struct ti_msgmgr_inst *inst;
-
-	inst = platform_get_drvdata(pdev);
-	mbox_controller_unregister(&inst->mbox);
-
-	return 0;
-}
-
 static struct platform_driver ti_msgmgr_driver = {
 	.probe = ti_msgmgr_probe,
-	.remove = ti_msgmgr_remove,
 	.driver = {
 		   .name = "ti-msgmgr",
 		   .of_match_table = of_match_ptr(ti_msgmgr_of_match),
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 15/19] mailbox: platform-mhu: Use device-managed registration API
  2018-12-17 15:02 ` [PATCH v2 15/19] mailbox: platform-mhu: " Thierry Reding
@ 2018-12-17 15:04   ` Neil Armstrong
  0 siblings, 0 replies; 33+ messages in thread
From: Neil Armstrong @ 2018-12-17 15:04 UTC (permalink / raw)
  To: Thierry Reding, Jassi Brar; +Cc: linux-kernel

On 17/12/2018 16:02, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Get rid of some boilerplate driver removal code by using the newly added
> device-managed registration API.
> 
> Cc: Neil Armstrong <narmstrong@baylibre.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/mailbox/platform_mhu.c | 12 +-----------
>  1 file changed, 1 insertion(+), 11 deletions(-)
> 
> diff --git a/drivers/mailbox/platform_mhu.c b/drivers/mailbox/platform_mhu.c
> index e13201a5cec6..d2502c5be130 100644
> --- a/drivers/mailbox/platform_mhu.c
> +++ b/drivers/mailbox/platform_mhu.c
> @@ -163,7 +163,7 @@ static int platform_mhu_probe(struct platform_device *pdev)
>  
>  	platform_set_drvdata(pdev, mhu);
>  
> -	err = mbox_controller_register(&mhu->mbox);
> +	err = devm_mbox_controller_register(dev, &mhu->mbox);
>  	if (err) {
>  		dev_err(dev, "Failed to register mailboxes %d\n", err);
>  		return err;
> @@ -173,15 +173,6 @@ static int platform_mhu_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -static int platform_mhu_remove(struct platform_device *pdev)
> -{
> -	struct platform_mhu *mhu = platform_get_drvdata(pdev);
> -
> -	mbox_controller_unregister(&mhu->mbox);
> -
> -	return 0;
> -}
> -
>  static const struct of_device_id platform_mhu_dt_ids[] = {
>  	{ .compatible = "amlogic,meson-gxbb-mhu", },
>  	{ /* sentinel */ },
> @@ -190,7 +181,6 @@ MODULE_DEVICE_TABLE(of, platform_mhu_dt_ids);
>  
>  static struct platform_driver platform_mhu_driver = {
>  	.probe	= platform_mhu_probe,
> -	.remove	= platform_mhu_remove,
>  	.driver = {
>  		.name = "platform-mhu",
>  		.of_match_table	= platform_mhu_dt_ids,
> 

Acked-by: Neil Armstrong <narmstrong@baylibre.com>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 08/19] mailbox: imx: Use device-managed registration API
  2018-12-17 15:02 ` [PATCH v2 08/19] mailbox: imx: " Thierry Reding
@ 2018-12-17 15:31   ` Oleksij Rempel
  0 siblings, 0 replies; 33+ messages in thread
From: Oleksij Rempel @ 2018-12-17 15:31 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Jassi Brar, linux-kernel, Dong Aisheng, Vladimir Zapolskiy

[-- Attachment #1: Type: text/plain, Size: 1593 bytes --]

On Mon, Dec 17, 2018 at 04:02:06PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Get rid of some boilerplate driver removal code by using the newly added
> device-managed registration API.
> 
> Cc: Oleksij Rempel <o.rempel@pengutronix.de>
> Cc: Dong Aisheng <aisheng.dong@nxp.com>
> Cc: Vladimir Zapolskiy <vz@mleia.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>

Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>

> ---
>  drivers/mailbox/imx-mailbox.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/mailbox/imx-mailbox.c b/drivers/mailbox/imx-mailbox.c
> index 363d35d5e49d..774362a05159 100644
> --- a/drivers/mailbox/imx-mailbox.c
> +++ b/drivers/mailbox/imx-mailbox.c
> @@ -324,14 +324,13 @@ static int imx_mu_probe(struct platform_device *pdev)
>  
>  	imx_mu_init_generic(priv);
>  
> -	return mbox_controller_register(&priv->mbox);
> +	return devm_mbox_controller_register(dev, &priv->mbox);
>  }
>  
>  static int imx_mu_remove(struct platform_device *pdev)
>  {
>  	struct imx_mu_priv *priv = platform_get_drvdata(pdev);
>  
> -	mbox_controller_unregister(&priv->mbox);
>  	clk_disable_unprepare(priv->clk);
>  
>  	return 0;
> -- 
> 2.19.1
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 01/19] mailbox: Add device-managed registration functions
  2018-12-17 15:01 ` [PATCH v2 01/19] mailbox: Add device-managed registration functions Thierry Reding
@ 2018-12-17 18:15   ` Bjorn Andersson
  2018-12-18 16:04   ` Sudeep Holla
  1 sibling, 0 replies; 33+ messages in thread
From: Bjorn Andersson @ 2018-12-17 18:15 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Jassi Brar, linux-kernel, Andy Gospodarek, Anup Patel,
	Caesar Wang, CK Hu, Dong Aisheng, Duc Dang, Eric Anholt,
	Fabien Dessenne, Feng Kan, Florian Fainelli, Georgi Djakov,
	Houlong Wei, HS Liao, Jon Mason, Kaihua Zhong, Kevin Wangtao,
	Lee Jones, Leo Yan, Ley Foon Tan, Ludovic Barre, Neil Armstrong,
	Nishanth Menon, Oleksij Rempel, Ray Jui, Rob Rice, Ruyi Wang,
	Scott Branden, Sibi Sankar, Stefan Wahren, Steve Lin,
	Sudeep Holla, Suman Anna, Tony Lindgren, Vikram Prakash,
	Vladimir Zapolskiy

On Mon 17 Dec 07:01 PST 2018, Thierry Reding wrote:

> From: Thierry Reding <treding@nvidia.com>
> 
> Add device-managed equivalents of the mbox_controller_register() and
> mbox_controller_unregister() functions that can be used to have the
> devres infrastructure automatically unregister mailbox controllers on
> driver probe failure or driver removal. This can help remove a lot of
> boiler plate code from drivers.
> 

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/mailbox/mailbox.c          | 70 ++++++++++++++++++++++++++++++
>  include/linux/mailbox_controller.h |  5 +++
>  2 files changed, 75 insertions(+)
> 
> diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
> index 674b35f402f5..eb781e2b19cb 100644
> --- a/drivers/mailbox/mailbox.c
> +++ b/drivers/mailbox/mailbox.c
> @@ -515,3 +515,73 @@ void mbox_controller_unregister(struct mbox_controller *mbox)
>  	mutex_unlock(&con_mutex);
>  }
>  EXPORT_SYMBOL_GPL(mbox_controller_unregister);
> +
> +static void __devm_mbox_controller_unregister(struct device *dev, void *res)
> +{
> +	struct mbox_controller *mbox = res;
> +
> +	mbox_controller_unregister(mbox);
> +}
> +
> +static int devm_mbox_controller_match(struct device *dev, void *res, void *data)
> +{
> +	struct mbox_controller **mbox = res;
> +
> +	if (WARN_ON(!mbox || !*mbox))
> +		return 0;
> +
> +	return *mbox == data;
> +}
> +
> +/**
> + * devm_mbox_controller_register() - managed mbox_controller_register()
> + * @dev: device owning the mailbox controller being registered
> + * @mbox: mailbox controller being registered
> + *
> + * This function adds a device-managed resource that will make sure that the
> + * mailbox controller, which is registered using mbox_controller_register()
> + * as part of this function, will be unregistered along with the rest of
> + * device-managed resources upon driver probe failure or driver removal.
> + *
> + * Returns 0 on success or a negative error code on failure.
> + */
> +int devm_mbox_controller_register(struct device *dev,
> +				  struct mbox_controller *mbox)
> +{
> +	struct mbox_controller **ptr;
> +	int err;
> +
> +	ptr = devres_alloc(__devm_mbox_controller_unregister, sizeof(*ptr),
> +			   GFP_KERNEL);
> +	if (!ptr)
> +		return -ENOMEM;
> +
> +	err = mbox_controller_register(mbox);
> +	if (err < 0) {
> +		devres_free(ptr);
> +		return err;
> +	}
> +
> +	devres_add(dev, ptr);
> +	*ptr = mbox;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL_GPL(devm_mbox_controller_register);
> +
> +/**
> + * devm_mbox_controller_unregister() - managed mbox_controller_unregister()
> + * @dev: device owning the mailbox controller being unregistered
> + * @mbox: mailbox controller being unregistered
> + *
> + * This function unregisters the mailbox controller and removes the device-
> + * managed resource that was set up to automatically unregister the mailbox
> + * controller on driver probe failure or driver removal. It's typically not
> + * necessary to call this function.
> + */
> +void devm_mbox_controller_unregister(struct device *dev, struct mbox_controller *mbox)
> +{
> +	WARN_ON(devres_release(dev, __devm_mbox_controller_unregister,
> +			       devm_mbox_controller_match, mbox));
> +}
> +EXPORT_SYMBOL_GPL(devm_mbox_controller_unregister);
> diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h
> index 74deadb42d76..9b0b21207345 100644
> --- a/include/linux/mailbox_controller.h
> +++ b/include/linux/mailbox_controller.h
> @@ -131,4 +131,9 @@ void mbox_controller_unregister(struct mbox_controller *mbox); /* can sleep */
>  void mbox_chan_received_data(struct mbox_chan *chan, void *data); /* atomic */
>  void mbox_chan_txdone(struct mbox_chan *chan, int r); /* atomic */
>  
> +int devm_mbox_controller_register(struct device *dev,
> +				  struct mbox_controller *mbox);
> +void devm_mbox_controller_unregister(struct device *dev,
> +				     struct mbox_controller *mbox);
> +
>  #endif /* __MAILBOX_CONTROLLER_H */
> -- 
> 2.19.1
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 16/19] mailbox: qcom-apcs: Use device-managed registration API
  2018-12-17 15:02 ` [PATCH v2 16/19] mailbox: qcom-apcs: " Thierry Reding
@ 2018-12-17 18:16   ` Bjorn Andersson
  0 siblings, 0 replies; 33+ messages in thread
From: Bjorn Andersson @ 2018-12-17 18:16 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Jassi Brar, linux-kernel, Georgi Djakov, Sibi Sankar

On Mon 17 Dec 07:02 PST 2018, Thierry Reding wrote:

> From: Thierry Reding <treding@nvidia.com>
> 
> Get rid of some boilerplate driver removal code by using the newly added
> device-managed registration API.
> 
> Cc: Bjorn Andersson <bjorn.andersson@linaro.org>

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

Regards,
Bjorn

> Cc: Georgi Djakov <georgi.djakov@linaro.org>
> Cc: Sibi Sankar <sibis@codeaurora.org>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/mailbox/qcom-apcs-ipc-mailbox.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/mailbox/qcom-apcs-ipc-mailbox.c b/drivers/mailbox/qcom-apcs-ipc-mailbox.c
> index aed23ac9550d..3cf2937be149 100644
> --- a/drivers/mailbox/qcom-apcs-ipc-mailbox.c
> +++ b/drivers/mailbox/qcom-apcs-ipc-mailbox.c
> @@ -91,7 +91,7 @@ static int qcom_apcs_ipc_probe(struct platform_device *pdev)
>  	apcs->mbox.chans = apcs->mbox_chans;
>  	apcs->mbox.num_chans = ARRAY_SIZE(apcs->mbox_chans);
>  
> -	ret = mbox_controller_register(&apcs->mbox);
> +	ret = devm_mbox_controller_register(&pdev->dev, &apcs->mbox);
>  	if (ret) {
>  		dev_err(&pdev->dev, "failed to register APCS IPC controller\n");
>  		return ret;
> @@ -115,7 +115,6 @@ static int qcom_apcs_ipc_remove(struct platform_device *pdev)
>  	struct qcom_apcs_ipc *apcs = platform_get_drvdata(pdev);
>  	struct platform_device *clk = apcs->clk;
>  
> -	mbox_controller_unregister(&apcs->mbox);
>  	platform_device_unregister(clk);
>  
>  	return 0;
> -- 
> 2.19.1
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 14/19] mailbox: omap: Use device-managed registration API
  2018-12-17 15:02 ` [PATCH v2 14/19] mailbox: omap: Use device-managed registration API Thierry Reding
@ 2018-12-18  0:10   ` kbuild test robot
  0 siblings, 0 replies; 33+ messages in thread
From: kbuild test robot @ 2018-12-18  0:10 UTC (permalink / raw)
  To: Thierry Reding
  Cc: kbuild-all, Jassi Brar, linux-kernel, Tony Lindgren, Suman Anna

[-- Attachment #1: Type: text/plain, Size: 3066 bytes --]

Hi Thierry,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v4.20-rc7 next-20181217]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Thierry-Reding/mailbox-Device-managed-registration/20181218-033546
config: arm-omap2plus_defconfig (attached as .config)
compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=arm 

All errors (new ones prefixed by >>):

   drivers/mailbox/omap-mailbox.c: In function 'omap_mbox_register':
>> drivers/mailbox/omap-mailbox.c:489:38: error: passing argument 1 of 'devm_mbox_controller_register' from incompatible pointer type [-Werror=incompatible-pointer-types]
     ret = devm_mbox_controller_register(&mdev->controller);
                                         ^
   In file included from drivers/mailbox/omap-mailbox.c:23:0:
   include/linux/mailbox_controller.h:134:5: note: expected 'struct device *' but argument is of type 'struct mbox_controller *'
    int devm_mbox_controller_register(struct device *dev,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/mailbox/omap-mailbox.c:489:8: error: too few arguments to function 'devm_mbox_controller_register'
     ret = devm_mbox_controller_register(&mdev->controller);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   In file included from drivers/mailbox/omap-mailbox.c:23:0:
   include/linux/mailbox_controller.h:134:5: note: declared here
    int devm_mbox_controller_register(struct device *dev,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/devm_mbox_controller_register +489 drivers/mailbox/omap-mailbox.c

   463	
   464	static int omap_mbox_register(struct omap_mbox_device *mdev)
   465	{
   466		int ret;
   467		int i;
   468		struct omap_mbox **mboxes;
   469	
   470		if (!mdev || !mdev->mboxes)
   471			return -EINVAL;
   472	
   473		mboxes = mdev->mboxes;
   474		for (i = 0; mboxes[i]; i++) {
   475			struct omap_mbox *mbox = mboxes[i];
   476	
   477			mbox->dev = device_create(&omap_mbox_class, mdev->dev,
   478						0, mbox, "%s", mbox->name);
   479			if (IS_ERR(mbox->dev)) {
   480				ret = PTR_ERR(mbox->dev);
   481				goto err_out;
   482			}
   483		}
   484	
   485		mutex_lock(&omap_mbox_devices_lock);
   486		list_add(&mdev->elem, &omap_mbox_devices);
   487		mutex_unlock(&omap_mbox_devices_lock);
   488	
 > 489		ret = devm_mbox_controller_register(&mdev->controller);
   490	
   491	err_out:
   492		if (ret) {
   493			while (i--)
   494				device_unregister(mboxes[i]->dev);
   495		}
   496		return ret;
   497	}
   498	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 34486 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 17/19] mailbox: rockchip: Use device-managed registration API
  2018-12-17 15:02 ` [PATCH v2 17/19] mailbox: rockchip: " Thierry Reding
@ 2018-12-18  0:36   ` Caesar Wang
  0 siblings, 0 replies; 33+ messages in thread
From: Caesar Wang @ 2018-12-18  0:36 UTC (permalink / raw)
  To: Thierry Reding, Jassi Brar; +Cc: linux-kernel

On 2018/12/17 下午11:02, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Get rid of some boilerplate driver removal code by using the newly added
> device-managed registration API.

Reviewed-by: Caesar Wang <wxt@rock-chips.com>

Thanks,
Caesar
>
> Cc: Caesar Wang <wxt@rock-chips.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>   drivers/mailbox/rockchip-mailbox.c | 15 +--------------
>   1 file changed, 1 insertion(+), 14 deletions(-)
>
> diff --git a/drivers/mailbox/rockchip-mailbox.c b/drivers/mailbox/rockchip-mailbox.c
> index d702a204f5c1..f24a77b1a0ff 100644
> --- a/drivers/mailbox/rockchip-mailbox.c
> +++ b/drivers/mailbox/rockchip-mailbox.c
> @@ -247,28 +247,15 @@ static int rockchip_mbox_probe(struct platform_device *pdev)
>   		mb->chans[i].msg = NULL;
>   	}
>   
> -	ret = mbox_controller_register(&mb->mbox);
> +	ret = devm_mbox_controller_register(&pdev->dev, &mb->mbox);
>   	if (ret < 0)
>   		dev_err(&pdev->dev, "Failed to register mailbox: %d\n", ret);
>   
>   	return ret;
>   }
>   
> -static int rockchip_mbox_remove(struct platform_device *pdev)
> -{
> -	struct rockchip_mbox *mb = platform_get_drvdata(pdev);
> -
> -	if (!mb)
> -		return -EINVAL;
> -
> -	mbox_controller_unregister(&mb->mbox);
> -
> -	return 0;
> -}
> -
>   static struct platform_driver rockchip_mbox_driver = {
>   	.probe	= rockchip_mbox_probe,
> -	.remove	= rockchip_mbox_remove,
>   	.driver = {
>   		.name = "rockchip-mailbox",
>   		.of_match_table = of_match_ptr(rockchip_mbox_of_match),

-- 
王晓腾 | 系统产品三部 | 软件工程师
Caesar Wang |  Product R&D Dept.III | Software engineer
**************************************************
福州瑞芯微电子股份有限公司
Fuzhou Rockchip Electronics Co.Ltd
地址:福建省福州市铜盘路软件大道89号软件园A区20号楼 (福州总部)
Addr: No.20 Building, A District, Fuzhou Software Park.Gulou District,Fuzhou,Fujian,China(Fuzhou Headquarters)
Tel:+86-0591-83991906-8221
Mobile: +86 15059456742
E-mail: wxt@rock-chips.com
*************************************************
****************************************************************************
保密提示:本邮件及其附件含有机密信息,仅发送给本邮件所指特定收件人。若非该特定收件人,请勿复制、
使用或披露本邮件的任何内容。若误收本邮件,请从系统中永久性删除本邮件及所有附件,并以回复邮件或其他方式即刻告知发件人。
福州瑞芯微电子有限公司拥有本邮件信息的著作权及解释权,禁止任何未经授权许可的侵权行为。
IMPORTANT NOTICE: This email is from Fuzhou Rockchip Electronics Co., Ltd .The contents of this
email and any attachments may contain information that is privileged, confidential and/or exempt from disclosure under applicable law and relevant NDA.
If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information is STRICTLY PROHIBITED.
Please immediately contact the sender as soon as possible and destroy the material in its entirety in any format. Thank you.



^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 18/19] mailbox: stm32-ipcc: Use device-managed registration API
  2018-12-17 15:02 ` [PATCH v2 18/19] mailbox: stm32-ipcc: " Thierry Reding
@ 2018-12-18  8:26   ` Ludovic BARRE
  0 siblings, 0 replies; 33+ messages in thread
From: Ludovic BARRE @ 2018-12-18  8:26 UTC (permalink / raw)
  To: Thierry Reding, Jassi Brar; +Cc: linux-kernel, Fabien Dessenne



On 12/17/18 4:02 PM, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Get rid of some boilerplate driver removal code by using the newly added
> device-managed registration API.
> 
> Cc: Fabien Dessenne <fabien.dessenne@st.com>
> Cc: Ludovic Barre <ludovic.barre@st.com>

Reviewed-by: Ludovic Barre <ludovic.barre@st.com>

Regards,
Ludo

> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>   drivers/mailbox/stm32-ipcc.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/mailbox/stm32-ipcc.c b/drivers/mailbox/stm32-ipcc.c
> index 533b0da5235d..a338bd4cd7db 100644
> --- a/drivers/mailbox/stm32-ipcc.c
> +++ b/drivers/mailbox/stm32-ipcc.c
> @@ -299,7 +299,7 @@ static int stm32_ipcc_probe(struct platform_device *pdev)
>   	for (i = 0; i < ipcc->controller.num_chans; i++)
>   		ipcc->controller.chans[i].con_priv = (void *)i;
>   
> -	ret = mbox_controller_register(&ipcc->controller);
> +	ret = devm_mbox_controller_register(dev, &ipcc->controller);
>   	if (ret)
>   		goto err_irq_wkp;
>   
> @@ -329,8 +329,6 @@ static int stm32_ipcc_remove(struct platform_device *pdev)
>   {
>   	struct stm32_ipcc *ipcc = platform_get_drvdata(pdev);
>   
> -	mbox_controller_unregister(&ipcc->controller);
> -
>   	if (ipcc->wkp)
>   		dev_pm_clear_wake_irq(&pdev->dev);
>   
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 10/19] mailbox: sti: Use device-managed registration API
  2018-12-17 15:02 ` [PATCH v2 10/19] mailbox: sti: " Thierry Reding
@ 2018-12-18  8:27   ` Lee Jones
  0 siblings, 0 replies; 33+ messages in thread
From: Lee Jones @ 2018-12-18  8:27 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Jassi Brar, linux-kernel

On Mon, 17 Dec 2018, Thierry Reding wrote:

> From: Thierry Reding <treding@nvidia.com>
> 
> Get rid of some boilerplate driver removal code by using the newly added
> device-managed registration API.
> 
> Cc: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/mailbox/mailbox-sti.c | 13 +------------
>  1 file changed, 1 insertion(+), 12 deletions(-)

Acked-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 06/19] mailbox: hi3660: Use device-managed registration API
  2018-12-17 15:02 ` [PATCH v2 06/19] mailbox: hi3660: " Thierry Reding
@ 2018-12-18  9:16   ` leo.yan
  0 siblings, 0 replies; 33+ messages in thread
From: leo.yan @ 2018-12-18  9:16 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Jassi Brar, linux-kernel, Kevin Wangtao, Kaihua Zhong, Ruyi Wang

On Mon, Dec 17, 2018 at 04:02:04PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Get rid of some boilerplate driver removal code by using the newly added
> device-managed registration API.

Tested-by: Leo Yan <leo.yan@linaro.org>

> Cc: Kevin Wangtao <kevin.wangtao@hisilicon.com>
> Cc: Kaihua Zhong <zhongkaihua@huawei.com>
> Cc: Ruyi Wang <wangruyi@huawei.com>
> Cc: Leo Yan <leo.yan@linaro.org>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/mailbox/hi3660-mailbox.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/mailbox/hi3660-mailbox.c b/drivers/mailbox/hi3660-mailbox.c
> index f9aed5d8f9f1..53f4bc2488c5 100644
> --- a/drivers/mailbox/hi3660-mailbox.c
> +++ b/drivers/mailbox/hi3660-mailbox.c
> @@ -265,7 +265,7 @@ static int hi3660_mbox_probe(struct platform_device *pdev)
>  	for (ch = 0; ch < MBOX_CHAN_MAX; ch++)
>  		chan[ch].con_priv = (void *)ch;
>  
> -	err = mbox_controller_register(&mbox->controller);
> +	err = devm_mbox_controller_register(dev, &mbox->controller);
>  	if (err) {
>  		dev_err(dev, "Failed to register mailbox %d\n", err);
>  		return err;
> @@ -276,17 +276,8 @@ static int hi3660_mbox_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -static int hi3660_mbox_remove(struct platform_device *pdev)
> -{
> -	struct hi3660_mbox *mbox = platform_get_drvdata(pdev);
> -
> -	mbox_controller_unregister(&mbox->controller);
> -	return 0;
> -}
> -
>  static struct platform_driver hi3660_mbox_driver = {
>  	.probe  = hi3660_mbox_probe,
> -	.remove = hi3660_mbox_remove,
>  	.driver = {
>  		.name = "hi3660-mbox",
>  		.of_match_table = hi3660_mbox_of_match,
> -- 
> 2.19.1
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 07/19] mailbox: hi6220: Use device-managed registration API
  2018-12-17 15:02 ` [PATCH v2 07/19] mailbox: hi6220: " Thierry Reding
@ 2018-12-18  9:17   ` leo.yan
  0 siblings, 0 replies; 33+ messages in thread
From: leo.yan @ 2018-12-18  9:17 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Jassi Brar, linux-kernel

On Mon, Dec 17, 2018 at 04:02:05PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Get rid of some boilerplate driver removal code by using the newly added
> device-managed registration API.

Reviewed-by: Leo Yan <leo.yan@linaro.org>

> Cc: Leo Yan <leo.yan@linaro.org>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/mailbox/hi6220-mailbox.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
> 
> diff --git a/drivers/mailbox/hi6220-mailbox.c b/drivers/mailbox/hi6220-mailbox.c
> index 4fa9803cd204..c32cbfaf223a 100644
> --- a/drivers/mailbox/hi6220-mailbox.c
> +++ b/drivers/mailbox/hi6220-mailbox.c
> @@ -349,7 +349,7 @@ static int hi6220_mbox_probe(struct platform_device *pdev)
>  		mbox->controller.txpoll_period = 5;
>  	}
>  
> -	err = mbox_controller_register(&mbox->controller);
> +	err = devm_mbox_controller_register(dev, &mbox->controller);
>  	if (err) {
>  		dev_err(dev, "Failed to register mailbox %d\n", err);
>  		return err;
> @@ -360,14 +360,6 @@ static int hi6220_mbox_probe(struct platform_device *pdev)
>  	return 0;
>  }
>  
> -static int hi6220_mbox_remove(struct platform_device *pdev)
> -{
> -	struct hi6220_mbox *mbox = platform_get_drvdata(pdev);
> -
> -	mbox_controller_unregister(&mbox->controller);
> -	return 0;
> -}
> -
>  static struct platform_driver hi6220_mbox_driver = {
>  	.driver = {
>  		.name = "hi6220-mbox",
> @@ -375,7 +367,6 @@ static struct platform_driver hi6220_mbox_driver = {
>  		.of_match_table = hi6220_mbox_of_match,
>  	},
>  	.probe	= hi6220_mbox_probe,
> -	.remove	= hi6220_mbox_remove,
>  };
>  
>  static int __init hi6220_mbox_init(void)
> -- 
> 2.19.1
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 01/19] mailbox: Add device-managed registration functions
  2018-12-17 15:01 ` [PATCH v2 01/19] mailbox: Add device-managed registration functions Thierry Reding
  2018-12-17 18:15   ` Bjorn Andersson
@ 2018-12-18 16:04   ` Sudeep Holla
  1 sibling, 0 replies; 33+ messages in thread
From: Sudeep Holla @ 2018-12-18 16:04 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Jassi Brar, linux-kernel, Andy Gospodarek, Anup Patel,
	Bjorn Andersson, Caesar Wang, CK Hu, Dong Aisheng, Duc Dang,
	Eric Anholt, Fabien Dessenne, Feng Kan, Florian Fainelli,
	Georgi Djakov, Houlong Wei, HS Liao, Jon Mason, Kaihua Zhong,
	Kevin Wangtao, Lee Jones, Leo Yan, Ley Foon Tan, Ludovic Barre,
	Neil Armstrong, Nishanth Menon, Oleksij Rempel, Ray Jui,
	Rob Rice, Ruyi Wang, Scott Branden, Sibi Sankar, Stefan Wahren,
	Steve Lin, Suman Anna, Tony Lindgren, Vikram Prakash,
	Vladimir Zapolskiy, Sudeep Holla

On Mon, Dec 17, 2018 at 04:01:59PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
> 
> Add device-managed equivalents of the mbox_controller_register() and
> mbox_controller_unregister() functions that can be used to have the
> devres infrastructure automatically unregister mailbox controllers on
> driver probe failure or driver removal. This can help remove a lot of
> boiler plate code from drivers.
> 
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
>  drivers/mailbox/mailbox.c          | 70 ++++++++++++++++++++++++++++++
>  include/linux/mailbox_controller.h |  5 +++
>  2 files changed, 75 insertions(+)
> 
> diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
> index 674b35f402f5..eb781e2b19cb 100644
> --- a/drivers/mailbox/mailbox.c
> +++ b/drivers/mailbox/mailbox.c
> @@ -515,3 +515,73 @@ void mbox_controller_unregister(struct mbox_controller *mbox)
>  	mutex_unlock(&con_mutex);
>  }
>  EXPORT_SYMBOL_GPL(mbox_controller_unregister);
> +
> +static void __devm_mbox_controller_unregister(struct device *dev, void *res)
> +{
> +	struct mbox_controller *mbox = res;
> +
> +	mbox_controller_unregister(mbox);

This looks wrong to me. See below for details.

[...]

> +int devm_mbox_controller_register(struct device *dev,
> +				  struct mbox_controller *mbox)
> +{
> +	struct mbox_controller **ptr;
> +	int err;
> +
> +	ptr = devres_alloc(__devm_mbox_controller_unregister, sizeof(*ptr),
> +			   GFP_KERNEL);

devres_alloc returns devres->data as ptr above

> +	if (!ptr)
> +		return -ENOMEM;
> +
> +	err = mbox_controller_register(mbox);
> +	if (err < 0) {
> +		devres_free(ptr);
> +		return err;
> +	}
> +
> +	devres_add(dev, ptr);
> +	*ptr = mbox;

And ...release is called with devres->data so we need *ptr
in devm_mbox_controller_unregister and not ptr itself something like:

	struct mbox_controller **mbox = res;
	mbox_controller_unregister(*mbox);

With above fixed:

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>

--
Regards,
Sudeep


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 02/19] mailbox: arm-mhu: Use device-managed registration API
  2018-12-17 15:02 ` [PATCH v2 02/19] mailbox: arm-mhu: Use device-managed registration API Thierry Reding
@ 2018-12-18 16:07   ` Sudeep Holla
  0 siblings, 0 replies; 33+ messages in thread
From: Sudeep Holla @ 2018-12-18 16:07 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Jassi Brar, linux-kernel, Sudeep Holla

On Mon, Dec 17, 2018 at 04:02:00PM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Get rid of some boilerplate driver removal code by using the newly added
> device-managed registration API.
>

Since the platform I have uses MHU differently and the mainline driver
doesn't work as is, I can't test the change easily.

But the changes looks fine to me. Feel free to all:

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>

--
Regards,
Sudeep

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH v2 03/19] mailbox: bcm2835: Use device-managed registration API
  2018-12-17 15:02 ` [PATCH v2 03/19] mailbox: bcm2835: " Thierry Reding
@ 2018-12-18 19:24   ` Eric Anholt
  0 siblings, 0 replies; 33+ messages in thread
From: Eric Anholt @ 2018-12-18 19:24 UTC (permalink / raw)
  To: Thierry Reding, Jassi Brar; +Cc: linux-kernel, Stefan Wahren

[-- Attachment #1: Type: text/plain, Size: 289 bytes --]

Thierry Reding <thierry.reding@gmail.com> writes:

> From: Thierry Reding <treding@nvidia.com>
>
> Get rid of some boilerplate driver removal code by using the newly added
> device-managed registration API.
>
> Cc: Eric Anholt <eric@anholt.net>

Reviewed-by: Eric Anholt <eric@anholt.net>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2018-12-18 19:24 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17 15:01 [PATCH v2 00/19] mailbox: Device-managed registration Thierry Reding
2018-12-17 15:01 ` [PATCH v2 01/19] mailbox: Add device-managed registration functions Thierry Reding
2018-12-17 18:15   ` Bjorn Andersson
2018-12-18 16:04   ` Sudeep Holla
2018-12-17 15:02 ` [PATCH v2 02/19] mailbox: arm-mhu: Use device-managed registration API Thierry Reding
2018-12-18 16:07   ` Sudeep Holla
2018-12-17 15:02 ` [PATCH v2 03/19] mailbox: bcm2835: " Thierry Reding
2018-12-18 19:24   ` Eric Anholt
2018-12-17 15:02 ` [PATCH v2 04/19] mailbox: bcm-flexrm: " Thierry Reding
2018-12-17 15:02 ` [PATCH v2 05/19] mailbox: bcm-pdc: " Thierry Reding
2018-12-17 15:02 ` [PATCH v2 06/19] mailbox: hi3660: " Thierry Reding
2018-12-18  9:16   ` leo.yan
2018-12-17 15:02 ` [PATCH v2 07/19] mailbox: hi6220: " Thierry Reding
2018-12-18  9:17   ` leo.yan
2018-12-17 15:02 ` [PATCH v2 08/19] mailbox: imx: " Thierry Reding
2018-12-17 15:31   ` Oleksij Rempel
2018-12-17 15:02 ` [PATCH v2 09/19] mailbox: altera: " Thierry Reding
2018-12-17 15:02 ` [PATCH v2 10/19] mailbox: sti: " Thierry Reding
2018-12-18  8:27   ` Lee Jones
2018-12-17 15:02 ` [PATCH v2 11/19] mailbox: xgene-slimpro: " Thierry Reding
2018-12-17 15:02 ` [PATCH v2 12/19] mailbox: mtk-cmdq: " Thierry Reding
2018-12-17 15:02 ` [PATCH v2 13/19] mailbox: mtk-cmdq: Remove needless devm_kfree() calls Thierry Reding
2018-12-17 15:02 ` [PATCH v2 14/19] mailbox: omap: Use device-managed registration API Thierry Reding
2018-12-18  0:10   ` kbuild test robot
2018-12-17 15:02 ` [PATCH v2 15/19] mailbox: platform-mhu: " Thierry Reding
2018-12-17 15:04   ` Neil Armstrong
2018-12-17 15:02 ` [PATCH v2 16/19] mailbox: qcom-apcs: " Thierry Reding
2018-12-17 18:16   ` Bjorn Andersson
2018-12-17 15:02 ` [PATCH v2 17/19] mailbox: rockchip: " Thierry Reding
2018-12-18  0:36   ` Caesar Wang
2018-12-17 15:02 ` [PATCH v2 18/19] mailbox: stm32-ipcc: " Thierry Reding
2018-12-18  8:26   ` Ludovic BARRE
2018-12-17 15:02 ` [PATCH v2 19/19] mailbox: ti-msgmgr: " Thierry Reding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.