• Dmitry Osipenko's avatar
    kernel/reboot: Introduce sys-off handler API · 232edc2f
    Dmitry Osipenko authored
    In order to support power-off chaining we need to get rid of the global
    pm_* variables, replacing them with the new kernel API functions that
    support chaining.
    
    Introduce new generic sys-off handler API that brings the following
    features:
    
    1. Power-off and restart handlers are registered using same API function
       that supports chaining, hence all power-off and restart modes will
       support chaining using this unified function.
    
    2. Prevents notifier priority collisions by disallowing registration of
       multiple handlers at the non-default priority level.
    
    3. Supports passing opaque user argument to callback, which allows us to
       remove global variables from drivers.
    
    This patch adds support of the following sys-off modes:
    
    - SYS_OFF_MODE_POWER_OFF_PREPARE that replaces global pm_power_off_prepare
      variable and provides chaining support for power-off-prepare handlers.
    
    - SYS_OFF_MODE_POWER_OFF that replaces global pm_power_off variable and
      provides chaining support for power-off handlers.
    
    - SYS_OFF_MODE_RESTART that provides a better restart API, removing a need
      from drivers to have a global scratch variable by utilizing the opaque
      callback argument.
    Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    232edc2f
reboot.c 25.9 KB