devfreq: Suspend all devices on system shutdown 81/199781/2
authorMarek Szyprowski <m.szyprowski@samsung.com>
Fri, 25 Jan 2019 13:49:53 +0000 (14:49 +0100)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 18 Feb 2019 04:54:22 +0000 (04:54 +0000)
This way devfreq core ensures that all its devices will be set to safe
operation points before reboot operation. There are board on which some
aggressive power saving operation points are behind the capabilities of
the bootloader to properly reset the hardware and boot the board. This
way one can avoid board crash early after reboot.

Similar pattern is used in CPUfreq subsystem.

Reported-by: Markus Reichl <m.reichl@fivetechno.de>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: I45467c8e02f7fedf90d1dfd5080e6143a8cb69f7

drivers/devfreq/devfreq.c

index 5db7249..2a08edc 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/devfreq.h>
 #include <linux/workqueue.h>
 #include <linux/platform_device.h>
+#include <linux/syscore_ops.h>
 #include <linux/list.h>
 #include <linux/printk.h>
 #include <linux/hrtimer.h>
@@ -1421,6 +1422,10 @@ static struct attribute *devfreq_attrs[] = {
 };
 ATTRIBUTE_GROUPS(devfreq);
 
+static struct syscore_ops devfreq_syscore_ops = {
+       .shutdown = devfreq_suspend,
+};
+
 static int __init devfreq_init(void)
 {
        devfreq_class = class_create(THIS_MODULE, "devfreq");
@@ -1437,6 +1442,8 @@ static int __init devfreq_init(void)
        }
        devfreq_class->dev_groups = devfreq_groups;
 
+       register_syscore_ops(&devfreq_syscore_ops);
+
        return 0;
 }
 subsys_initcall(devfreq_init);