From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Philipp Zabel <p.zabel@pengutronix.de>
Cc: linux-arm-kernel@lists.infradead.org,
Masahiro Yamada <yamada.masahiro@socionext.com>,
linux-doc@vger.kernel.org, Stephen Boyd <sboyd@codeaurora.org>,
Jonathan Corbet <corbet@lwn.net>,
linux-kernel@vger.kernel.org,
Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH 1/7] reset: add devm_reset_controller_register API
Date: Sun, 1 May 2016 19:36:57 +0900 [thread overview]
Message-ID: <1462099023-11819-2-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1462099023-11819-1-git-send-email-yamada.masahiro@socionext.com>
Add a device managed API for reset_controller_register().
This helps in reducing code in .remove callbacks and sometimes
dropping .remove callbacks entirely.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
Documentation/driver-model/devres.txt | 4 ++++
drivers/reset/core.c | 37 +++++++++++++++++++++++++++++++++++
include/linux/reset-controller.h | 4 ++++
3 files changed, 45 insertions(+)
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index 108d455..5270435 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -340,6 +340,10 @@ REGULATOR
devm_regulator_put()
devm_regulator_register()
+RESET
+ devm_reset_control_get()
+ devm_reset_controller_register()
+
SLAVE DMA ENGINE
devm_acpi_dma_controller_register()
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index f15f150..181b05d 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -82,6 +82,43 @@ void reset_controller_unregister(struct reset_controller_dev *rcdev)
}
EXPORT_SYMBOL_GPL(reset_controller_unregister);
+static void devm_reset_controller_release(struct device *dev, void *res)
+{
+ reset_controller_unregister(*(struct reset_controller_dev **)res);
+}
+
+/**
+ * devm_reset_controller_register - resource managed reset_controller_register()
+ * @dev: device that is registering this reset controller
+ * @rcdev: a pointer to the initialized reset controller device
+ *
+ * Managed reset_controller_register(). For reset controllers registered by
+ * this function, reset_controller_unregister() is automatically called on
+ * driver detach. See reset_controller_register() for more information.
+ */
+int devm_reset_controller_register(struct device *dev,
+ struct reset_controller_dev *rcdev)
+{
+ struct reset_controller_dev **rcdevp;
+ int ret;
+
+ rcdevp = devres_alloc(devm_reset_controller_release, sizeof(*rcdevp),
+ GFP_KERNEL);
+ if (!rcdevp)
+ return -ENOMEM;
+
+ ret = reset_controller_register(rcdev);
+ if (!ret) {
+ *rcdevp = rcdev;
+ devres_add(dev, rcdevp);
+ } else {
+ devres_free(rcdevp);
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL_GPL(devm_reset_controller_register);
+
/**
* reset_control_reset - reset the controlled device
* @rstc: reset controller
diff --git a/include/linux/reset-controller.h b/include/linux/reset-controller.h
index a3a5bcd..a4eaf1c 100644
--- a/include/linux/reset-controller.h
+++ b/include/linux/reset-controller.h
@@ -51,4 +51,8 @@ struct reset_controller_dev {
int reset_controller_register(struct reset_controller_dev *rcdev);
void reset_controller_unregister(struct reset_controller_dev *rcdev);
+struct device;
+int devm_reset_controller_register(struct device *dev,
+ struct reset_controller_dev *rcdev);
+
#endif
--
1.9.1
next prev parent reply other threads:[~2016-05-01 10:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-01 10:36 [PATCH 0/7] reset: add managned reset_controller_register() Masahiro Yamada
2016-05-01 10:36 ` Masahiro Yamada [this message]
2016-05-03 10:07 ` [PATCH 1/7] reset: add devm_reset_controller_register API Laxman Dewangan
2016-05-03 10:17 ` Philipp Zabel
2016-05-03 10:26 ` Masahiro Yamada
2016-05-03 11:41 ` Masahiro Yamada
2016-05-03 14:20 ` Philipp Zabel
2016-05-01 10:36 ` [PATCH 2/7] reset: ath79: use devm_reset_controller_register() Masahiro Yamada
2016-05-01 10:36 ` [PATCH 3/7] reset: lpc18xx: " Masahiro Yamada
2016-05-01 21:04 ` Joachim Eastwood
2016-05-02 8:26 ` Philipp Zabel
2016-05-02 15:52 ` Masahiro Yamada
2016-05-03 9:05 ` Philipp Zabel
2016-05-03 10:25 ` Masahiro Yamada
2016-05-03 11:08 ` Philipp Zabel
2016-05-03 11:40 ` Masahiro Yamada
2016-05-01 10:37 ` [PATCH 4/7] reset: pistachio: " Masahiro Yamada
2016-05-01 10:37 ` [PATCH 5/7] reset: sunxi: " Masahiro Yamada
2016-05-01 10:37 ` [PATCH 6/7] reset: socfpga: " Masahiro Yamada
2016-05-01 10:37 ` [PATCH 7/7] reset: zynq: " Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1462099023-11819-2-git-send-email-yamada.masahiro@socionext.com \
--to=yamada.masahiro@socionext.com \
--cc=corbet@lwn.net \
--cc=ldewangan@nvidia.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=sboyd@codeaurora.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).