Skip to content

Commit afaebbd

Browse files
apmswsre
authored andcommitted
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>
1 parent a7ba749 commit afaebbd

2 files changed

Lines changed: 13 additions & 17 deletions

File tree

‎drivers/power/reset/Kconfig‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ config POWER_RESET_KEYSTONE
120120

121121
config POWER_RESET_SYSCON
122122
bool "Generic SYSCON regmap reset driver"
123-
depends on POWER_RESET && MFD_SYSCON && OF
123+
depends on POWER_RESET && OF
124+
select MFD_SYSCON
124125
help
125126
Reboot support for generic SYSCON mapped register reset.

‎drivers/power/reset/syscon-reboot.c‎

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515
* GNU General Public License for more details.
1616
*/
17+
#include <linux/delay.h>
1718
#include <linux/io.h>
18-
#include <linux/of_device.h>
19-
#include <linux/of_address.h>
20-
#include <linux/platform_device.h>
2119
#include <linux/notifier.h>
2220
#include <linux/mfd/syscon.h>
23-
#include <linux/regmap.h>
21+
#include <linux/of_address.h>
22+
#include <linux/of_device.h>
23+
#include <linux/platform_device.h>
2424
#include <linux/reboot.h>
25+
#include <linux/regmap.h>
2526

2627
struct syscon_reboot_context {
2728
struct regmap *map;
@@ -30,21 +31,17 @@ struct syscon_reboot_context {
3031
struct notifier_block restart_handler;
3132
};
3233

33-
static struct syscon_reboot_context *syscon_reboot_ctx;
34-
3534
static int syscon_restart_handle(struct notifier_block *this,
3635
unsigned long mode, void *cmd)
3736
{
38-
struct syscon_reboot_context *ctx = syscon_reboot_ctx;
39-
unsigned long timeout;
37+
struct syscon_reboot_context *ctx =
38+
container_of(this, struct syscon_reboot_context,
39+
restart_handler);
4040

4141
/* Issue the reboot */
42-
if (ctx->map)
43-
regmap_write(ctx->map, ctx->offset, ctx->mask);
42+
regmap_write(ctx->map, ctx->offset, ctx->mask);
4443

45-
timeout = jiffies + HZ;
46-
while (time_before(jiffies, timeout))
47-
cpu_relax();
44+
mdelay(1000);
4845

4946
pr_emerg("Unable to restart system\n");
5047
return NOTIFY_DONE;
@@ -76,9 +73,7 @@ static int syscon_reboot_probe(struct platform_device *pdev)
7673
if (err)
7774
dev_err(dev, "can't register restart notifier (err=%d)\n", err);
7875

79-
syscon_reboot_ctx = ctx;
80-
81-
return 0;
76+
return err;
8277
}
8378

8479
static struct of_device_id syscon_reboot_of_match[] = {

0 commit comments

Comments
 (0)