* [PATCH 1/2] power: reset: reboot-mode: Add managed resource API
@ 2016-08-04 5:04 Bjorn Andersson
2016-08-04 5:04 ` [PATCH 2/2] power: reset: syscon-reboot-mode: Use " Bjorn Andersson
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Bjorn Andersson @ 2016-08-04 5:04 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse,
John Stultz
Cc: linux-doc, linux-kernel, linux-pm
Provide managed resource version of reboot_mode_register() and
reboot_mode_unregister() to simplify implementations.
Cc: John Stultz <john.stultz@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
John, here's a "pointer" to what I meant with my comment on your
sram-reboot-mode patch. Only compile tested though.
Documentation/driver-model/devres.txt | 4 +++
drivers/power/reset/reboot-mode.c | 59 +++++++++++++++++++++++++++++++++++
drivers/power/reset/reboot-mode.h | 4 +++
3 files changed, 67 insertions(+)
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt
index f5e522342ee5..fbb9fde1aad3 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -342,6 +342,10 @@ PINCTRL
devm_pinctrl_register()
devm_pinctrl_unregister()
+POWER
+ devm_reboot_mode_register()
+ devm_reboot_mode_unregister()
+
PWM
devm_pwm_get()
devm_pwm_put()
diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index 2dfbbce0f817..fb512183ace3 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -135,6 +135,65 @@ int reboot_mode_unregister(struct reboot_mode_driver *reboot)
}
EXPORT_SYMBOL_GPL(reboot_mode_unregister);
+static void devm_reboot_mode_release(struct device *dev, void *res)
+{
+ reboot_mode_unregister(*(struct reboot_mode_driver **)res);
+}
+
+/**
+ * devm_reboot_mode_register() - resource managed reboot_mode_register()
+ * @dev: device to associate this resource with
+ * @reboot: reboot mode driver
+ *
+ * Returns: 0 on success or a negative error code on failure.
+ */
+int devm_reboot_mode_register(struct device *dev,
+ struct reboot_mode_driver *reboot)
+{
+ struct reboot_mode_driver **dr;
+ int rc;
+
+ dr = devres_alloc(devm_reboot_mode_release, sizeof(*dr), GFP_KERNEL);
+ if (!dr)
+ return -ENOMEM;
+
+ rc = reboot_mode_register(reboot);
+ if (rc) {
+ devres_free(dr);
+ return rc;
+ }
+
+ *dr = reboot;
+ devres_add(dev, dr);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(devm_reboot_mode_register);
+
+static int devm_reboot_mode_match(struct device *dev, void *res, void *data)
+{
+ struct reboot_mode_driver **p = res;
+
+ if (WARN_ON(!p || !*p))
+ return 0;
+
+ return *p == data;
+}
+
+/**
+ * devm_reboot_mode_unregister() - resource managed reboot_mode_unregister()
+ * @dev: device to associate this resource with
+ * @reboot: reboot mode driver
+ */
+void devm_reboot_mode_unregister(struct device *dev,
+ struct reboot_mode_driver *reboot)
+{
+ WARN_ON(devres_release(dev,
+ devm_reboot_mode_release,
+ devm_reboot_mode_match, reboot));
+}
+EXPORT_SYMBOL_GPL(devm_reboot_mode_unregister);
+
MODULE_AUTHOR("Andy Yan <andy.yan@rock-chips.com");
MODULE_DESCRIPTION("System reboot mode core library");
MODULE_LICENSE("GPL v2");
diff --git a/drivers/power/reset/reboot-mode.h b/drivers/power/reset/reboot-mode.h
index 2491bb71f591..75f7fe5c881f 100644
--- a/drivers/power/reset/reboot-mode.h
+++ b/drivers/power/reset/reboot-mode.h
@@ -10,5 +10,9 @@ struct reboot_mode_driver {
int reboot_mode_register(struct reboot_mode_driver *reboot);
int reboot_mode_unregister(struct reboot_mode_driver *reboot);
+int devm_reboot_mode_register(struct device *dev,
+ struct reboot_mode_driver *reboot);
+void devm_reboot_mode_unregister(struct device *dev,
+ struct reboot_mode_driver *reboot);
#endif
--
2.5.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] power: reset: syscon-reboot-mode: Use managed resource API
2016-08-04 5:04 [PATCH 1/2] power: reset: reboot-mode: Add managed resource API Bjorn Andersson
@ 2016-08-04 5:04 ` Bjorn Andersson
2016-08-04 21:14 ` John Stultz
2016-08-15 22:34 ` Sebastian Reichel
2016-08-04 21:14 ` [PATCH 1/2] power: reset: reboot-mode: Add " John Stultz
2016-08-15 22:32 ` Sebastian Reichel
2 siblings, 2 replies; 6+ messages in thread
From: Bjorn Andersson @ 2016-08-04 5:04 UTC (permalink / raw)
To: Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse,
John Stultz
Cc: linux-doc, linux-kernel, linux-pm
Use the managed resource version of reboot_mode_register().
Cc: John Stultz <john.stultz@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---
John, here's a "pointer" to what I meant with my comment on your
sram-reboot-mode patch. Only compile tested though.
drivers/power/reset/syscon-reboot-mode.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
diff --git a/drivers/power/reset/syscon-reboot-mode.c b/drivers/power/reset/syscon-reboot-mode.c
index 9e1cba5dd58e..1ecb51d67149 100644
--- a/drivers/power/reset/syscon-reboot-mode.c
+++ b/drivers/power/reset/syscon-reboot-mode.c
@@ -53,8 +53,6 @@ static int syscon_reboot_mode_probe(struct platform_device *pdev)
syscon_rbm->reboot.write = syscon_reboot_mode_write;
syscon_rbm->mask = 0xffffffff;
- dev_set_drvdata(&pdev->dev, syscon_rbm);
-
syscon_rbm->map = syscon_node_to_regmap(pdev->dev.parent->of_node);
if (IS_ERR(syscon_rbm->map))
return PTR_ERR(syscon_rbm->map);
@@ -65,20 +63,13 @@ static int syscon_reboot_mode_probe(struct platform_device *pdev)
of_property_read_u32(pdev->dev.of_node, "mask", &syscon_rbm->mask);
- ret = reboot_mode_register(&syscon_rbm->reboot);
+ ret = devm_reboot_mode_register(&pdev->dev, &syscon_rbm->reboot);
if (ret)
dev_err(&pdev->dev, "can't register reboot mode\n");
return ret;
}
-static int syscon_reboot_mode_remove(struct platform_device *pdev)
-{
- struct syscon_reboot_mode *syscon_rbm = dev_get_drvdata(&pdev->dev);
-
- return reboot_mode_unregister(&syscon_rbm->reboot);
-}
-
static const struct of_device_id syscon_reboot_mode_of_match[] = {
{ .compatible = "syscon-reboot-mode" },
{}
@@ -86,7 +77,6 @@ static const struct of_device_id syscon_reboot_mode_of_match[] = {
static struct platform_driver syscon_reboot_mode_driver = {
.probe = syscon_reboot_mode_probe,
- .remove = syscon_reboot_mode_remove,
.driver = {
.name = "syscon-reboot-mode",
.of_match_table = syscon_reboot_mode_of_match,
--
2.5.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] power: reset: reboot-mode: Add managed resource API
2016-08-04 5:04 [PATCH 1/2] power: reset: reboot-mode: Add managed resource API Bjorn Andersson
2016-08-04 5:04 ` [PATCH 2/2] power: reset: syscon-reboot-mode: Use " Bjorn Andersson
@ 2016-08-04 21:14 ` John Stultz
2016-08-15 22:32 ` Sebastian Reichel
2 siblings, 0 replies; 6+ messages in thread
From: John Stultz @ 2016-08-04 21:14 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse,
linux-doc, lkml, Linux PM list
On Wed, Aug 3, 2016 at 10:04 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> Provide managed resource version of reboot_mode_register() and
> reboot_mode_unregister() to simplify implementations.
>
> Cc: John Stultz <john.stultz@linaro.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>
> John, here's a "pointer" to what I meant with my comment on your
> sram-reboot-mode patch. Only compile tested though.
Heh. Awesome. The seem to be working fine for me.
Tested-by: John Stultz <john.stultz@linaro.org>
thanks
-john
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] power: reset: syscon-reboot-mode: Use managed resource API
2016-08-04 5:04 ` [PATCH 2/2] power: reset: syscon-reboot-mode: Use " Bjorn Andersson
@ 2016-08-04 21:14 ` John Stultz
2016-08-15 22:34 ` Sebastian Reichel
1 sibling, 0 replies; 6+ messages in thread
From: John Stultz @ 2016-08-04 21:14 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Sebastian Reichel, Dmitry Eremin-Solenikov, David Woodhouse,
linux-doc, lkml, Linux PM list
On Wed, Aug 3, 2016 at 10:04 PM, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
> Use the managed resource version of reboot_mode_register().
>
> Cc: John Stultz <john.stultz@linaro.org>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
> ---
>
> John, here's a "pointer" to what I meant with my comment on your
> sram-reboot-mode patch. Only compile tested though.
Tested-by: John Stultz <john.stultz@linaro.org>
thanks
-john
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] power: reset: reboot-mode: Add managed resource API
2016-08-04 5:04 [PATCH 1/2] power: reset: reboot-mode: Add managed resource API Bjorn Andersson
2016-08-04 5:04 ` [PATCH 2/2] power: reset: syscon-reboot-mode: Use " Bjorn Andersson
2016-08-04 21:14 ` [PATCH 1/2] power: reset: reboot-mode: Add " John Stultz
@ 2016-08-15 22:32 ` Sebastian Reichel
2 siblings, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2016-08-15 22:32 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Dmitry Eremin-Solenikov, David Woodhouse, John Stultz, linux-doc,
linux-kernel, linux-pm
[-- Attachment #1: Type: text/plain, Size: 222 bytes --]
Hi,
On Wed, Aug 03, 2016 at 10:04:05PM -0700, Bjorn Andersson wrote:
> Provide managed resource version of reboot_mode_register() and
> reboot_mode_unregister() to simplify implementations.
Thanks, queued.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] power: reset: syscon-reboot-mode: Use managed resource API
2016-08-04 5:04 ` [PATCH 2/2] power: reset: syscon-reboot-mode: Use " Bjorn Andersson
2016-08-04 21:14 ` John Stultz
@ 2016-08-15 22:34 ` Sebastian Reichel
1 sibling, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2016-08-15 22:34 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Dmitry Eremin-Solenikov, David Woodhouse, John Stultz, linux-doc,
linux-kernel, linux-pm
[-- Attachment #1: Type: text/plain, Size: 302 bytes --]
Hi,
On Wed, Aug 03, 2016 at 10:04:06PM -0700, Bjorn Andersson wrote:
> Use the managed resource version of reboot_mode_register().
>
> [...]
>
> drivers/power/reset/syscon-reboot-mode.c | 12 +-----------
> 1 file changed, 1 insertion(+), 11 deletions(-)
Thanks, queued.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-08-15 22:34 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-04 5:04 [PATCH 1/2] power: reset: reboot-mode: Add managed resource API Bjorn Andersson
2016-08-04 5:04 ` [PATCH 2/2] power: reset: syscon-reboot-mode: Use " Bjorn Andersson
2016-08-04 21:14 ` John Stultz
2016-08-15 22:34 ` Sebastian Reichel
2016-08-04 21:14 ` [PATCH 1/2] power: reset: reboot-mode: Add " John Stultz
2016-08-15 22:32 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox