diff options
author | Sebastian Reichel <sre@kernel.org> | 2018-08-16 22:19:22 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2018-08-16 22:19:22 +0200 |
commit | 5198a48381455969aa1053a0ca2e4ce409be2fc2 (patch) | |
tree | 881914c4a5349e45285d686b1a513c678fcd6894 /drivers/power/reset/vexpress-poweroff.c | |
parent | 3d779180c69261f5c713832e46763e38589c18d3 (diff) | |
parent | cc44ba91166beb78f9cb29d5e3d41c0a2d0a7329 (diff) | |
download | linux-5198a48381455969aa1053a0ca2e4ce409be2fc2.tar.bz2 |
Merge branch 'psy-fixes' into psy-next
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/reset/vexpress-poweroff.c')
-rw-r--r-- | drivers/power/reset/vexpress-poweroff.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c index 102f95a09460..e9e749f87517 100644 --- a/drivers/power/reset/vexpress-poweroff.c +++ b/drivers/power/reset/vexpress-poweroff.c @@ -35,6 +35,7 @@ static void vexpress_reset_do(struct device *dev, const char *what) } static struct device *vexpress_power_off_device; +static atomic_t vexpress_restart_nb_refcnt = ATOMIC_INIT(0); static void vexpress_power_off(void) { @@ -99,10 +100,13 @@ static int _vexpress_register_restart_handler(struct device *dev) int err; vexpress_restart_device = dev; - err = register_restart_handler(&vexpress_restart_nb); - if (err) { - dev_err(dev, "cannot register restart handler (err=%d)\n", err); - return err; + if (atomic_inc_return(&vexpress_restart_nb_refcnt) == 1) { + err = register_restart_handler(&vexpress_restart_nb); + if (err) { + dev_err(dev, "cannot register restart handler (err=%d)\n", err); + atomic_dec(&vexpress_restart_nb_refcnt); + return err; + } } device_create_file(dev, &dev_attr_active); |