]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
power: reset: corrections for simple syscon reboot driver
authorFeng Kan <fkan@apm.com>
Thu, 2 Oct 2014 18:24:15 +0000 (11:24 -0700)
committerSebastian Reichel <sre@kernel.org>
Fri, 3 Oct 2014 02:32:08 +0000 (04:32 +0200)
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>
drivers/power/reset/Kconfig
drivers/power/reset/syscon-reboot.c

index addb26afae5aa29381f9e3a6aed200c42589f590..3b451e162a983ff2a251acdaef2f451ebf8c4703 100644 (file)
@@ -120,6 +120,7 @@ config POWER_RESET_KEYSTONE
 
 config POWER_RESET_SYSCON
        bool "Generic SYSCON regmap reset driver"
-       depends on POWER_RESET && MFD_SYSCON && OF
+       depends on POWER_RESET && OF
+       select MFD_SYSCON
        help
          Reboot support for generic SYSCON mapped register reset.
index 948e0ee32a4d3ca3b5410a91df0c4a3b60800660..815b901822cf9299b6210982e370e2aaa3a503a7 100644 (file)
  * 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[] = {