summaryrefslogtreecommitdiffstats
path: root/drivers/power/reset
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/power/reset')
-rw-r--r--drivers/power/reset/keystone-reset.c2
-rw-r--r--drivers/power/reset/reboot-mode.c59
-rw-r--r--drivers/power/reset/reboot-mode.h4
-rw-r--r--drivers/power/reset/st-poweroff.c41
-rw-r--r--drivers/power/reset/syscon-reboot-mode.c12
-rw-r--r--drivers/power/reset/xgene-reboot.c4
-rw-r--r--drivers/power/reset/zx-reboot.c5
7 files changed, 72 insertions, 55 deletions
diff --git a/drivers/power/reset/keystone-reset.c b/drivers/power/reset/keystone-reset.c
index c70f1bffe038..09380857a1c5 100644
--- a/drivers/power/reset/keystone-reset.c
+++ b/drivers/power/reset/keystone-reset.c
@@ -139,7 +139,7 @@ static int rsctrl_probe(struct platform_device *pdev)
}
if (val >= WDT_MUX_NUMBER) {
- dev_err(dev, "ti,wdt-list property can contain"
+ dev_err(dev, "ti,wdt-list property can contain "
"only numbers < 4\n");
return -EINVAL;
}
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
diff --git a/drivers/power/reset/st-poweroff.c b/drivers/power/reset/st-poweroff.c
index a488877a3538..2046b31232f7 100644
--- a/drivers/power/reset/st-poweroff.c
+++ b/drivers/power/reset/st-poweroff.c
@@ -28,28 +28,6 @@ struct reset_syscfg {
unsigned int mask_rst_msk;
};
-/* STiH415 */
-#define STIH415_SYSCFG_11 0x2c
-#define STIH415_SYSCFG_15 0x3c
-
-static struct reset_syscfg stih415_reset = {
- .offset_rst = STIH415_SYSCFG_11,
- .mask_rst = BIT(0),
- .offset_rst_msk = STIH415_SYSCFG_15,
- .mask_rst_msk = BIT(0)
-};
-
-/* STiH416 */
-#define STIH416_SYSCFG_500 0x7d0
-#define STIH416_SYSCFG_504 0x7e0
-
-static struct reset_syscfg stih416_reset = {
- .offset_rst = STIH416_SYSCFG_500,
- .mask_rst = BIT(0),
- .offset_rst_msk = STIH416_SYSCFG_504,
- .mask_rst_msk = BIT(0)
-};
-
/* STiH407 */
#define STIH407_SYSCFG_4000 0x0
#define STIH407_SYSCFG_4008 0x20
@@ -61,16 +39,6 @@ static struct reset_syscfg stih407_reset = {
.mask_rst_msk = BIT(0)
};
-/* STiD127 */
-#define STID127_SYSCFG_700 0x0
-#define STID127_SYSCFG_773 0x124
-
-static struct reset_syscfg stid127_reset = {
- .offset_rst = STID127_SYSCFG_773,
- .mask_rst = BIT(0),
- .offset_rst_msk = STID127_SYSCFG_700,
- .mask_rst_msk = BIT(8)
-};
static struct reset_syscfg *st_restart_syscfg;
@@ -99,17 +67,8 @@ static struct notifier_block st_restart_nb = {
static const struct of_device_id st_reset_of_match[] = {
{
- .compatible = "st,stih415-restart",
- .data = (void *)&stih415_reset,
- }, {
- .compatible = "st,stih416-restart",
- .data = (void *)&stih416_reset,
- }, {
.compatible = "st,stih407-restart",
.data = (void *)&stih407_reset,
- }, {
- .compatible = "st,stid127-restart",
- .data = (void *)&stid127_reset,
},
{}
};
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,
diff --git a/drivers/power/reset/xgene-reboot.c b/drivers/power/reset/xgene-reboot.c
index f07e93c97ba3..73c3d93e5318 100644
--- a/drivers/power/reset/xgene-reboot.c
+++ b/drivers/power/reset/xgene-reboot.c
@@ -81,8 +81,10 @@ static int xgene_reboot_probe(struct platform_device *pdev)
ctx->restart_handler.notifier_call = xgene_restart_handler;
ctx->restart_handler.priority = 128;
err = register_restart_handler(&ctx->restart_handler);
- if (err)
+ if (err) {
+ iounmap(ctx->csr);
dev_err(dev, "cannot register restart handler (err=%d)\n", err);
+ }
return err;
}
diff --git a/drivers/power/reset/zx-reboot.c b/drivers/power/reset/zx-reboot.c
index a5b009673d0e..b0b1eb3a78c2 100644
--- a/drivers/power/reset/zx-reboot.c
+++ b/drivers/power/reset/zx-reboot.c
@@ -58,9 +58,12 @@ static int zx_reboot_probe(struct platform_device *pdev)
}
err = register_restart_handler(&zx_restart_nb);
- if (err)
+ if (err) {
+ iounmap(base);
+ iounmap(pcu_base);
dev_err(&pdev->dev, "Register restart handler failed(err=%d)\n",
err);
+ }
return err;
}
OpenPOWER on IntegriCloud