summaryrefslogtreecommitdiff
path: root/drivers/power/reset/syscon-reboot.c
diff options
context:
space:
mode:
authorFeng Kan <fkan@apm.com>2014-10-02 22:24:15 +0400
committerSebastian Reichel <sre@kernel.org>2014-10-03 06:32:08 +0400
commitafaebbdbd48ada5ead707d6a90ce4b604e1d77d4 (patch)
treefc11ce4144991227bac55c4c100061f109f60df2 /drivers/power/reset/syscon-reboot.c
parenta7ba749e01461a3802d22157fc0e6c4ecbe0dd32 (diff)
downloadlinux-afaebbdbd48ada5ead707d6a90ce4b604e1d77d4.tar.xz
power: reset: corrections for simple syscon reboot driver
This patch is to fix some bugs in reboot driver. Which includes auto selection of the MFD_SYSCON for the driver, use of container to locate restart handler, correction of the count down failure timer and ordering of the header file. Signed-off-by: Feng Kan <fkan@apm.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> [ sre: return err instead of 0 in syscon_reboot_probe() ] Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/reset/syscon-reboot.c')
-rw-r--r--drivers/power/reset/syscon-reboot.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c
index 948e0ee32a4d..815b901822cf 100644
--- a/drivers/power/reset/syscon-reboot.c
+++ b/drivers/power/reset/syscon-reboot.c
@@ -14,14 +14,15 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
+#include <linux/delay.h>
#include <linux/io.h>
-#include <linux/of_device.h>
-#include <linux/of_address.h>
-#include <linux/platform_device.h>
#include <linux/notifier.h>
#include <linux/mfd/syscon.h>
-#include <linux/regmap.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
#include <linux/reboot.h>
+#include <linux/regmap.h>
struct syscon_reboot_context {
struct regmap *map;
@@ -30,21 +31,17 @@ struct syscon_reboot_context {
struct notifier_block restart_handler;
};
-static struct syscon_reboot_context *syscon_reboot_ctx;
-
static int syscon_restart_handle(struct notifier_block *this,
unsigned long mode, void *cmd)
{
- struct syscon_reboot_context *ctx = syscon_reboot_ctx;
- unsigned long timeout;
+ struct syscon_reboot_context *ctx =
+ container_of(this, struct syscon_reboot_context,
+ restart_handler);
/* Issue the reboot */
- if (ctx->map)
- regmap_write(ctx->map, ctx->offset, ctx->mask);
+ regmap_write(ctx->map, ctx->offset, ctx->mask);
- timeout = jiffies + HZ;
- while (time_before(jiffies, timeout))
- cpu_relax();
+ mdelay(1000);
pr_emerg("Unable to restart system\n");
return NOTIFY_DONE;
@@ -76,9 +73,7 @@ static int syscon_reboot_probe(struct platform_device *pdev)
if (err)
dev_err(dev, "can't register restart notifier (err=%d)\n", err);
- syscon_reboot_ctx = ctx;
-
- return 0;
+ return err;
}
static struct of_device_id syscon_reboot_of_match[] = {