lkml.org 
[lkml]   [2006]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH, RFC] [1/3] Generic in-kernel AC status
    The included patch adds support for power management methods to register 
    callbacks in order to allow drivers to check if the system is on AC or
    not. Following patches add support to ACPI and APM. Feedback welcome.

    Signed-Off-By: Matthew Garrett <mjg59@srcf.ucam.org>

    diff --git a/include/linux/pm.h b/include/linux/pm.h
    index 5be87ba..59ece0f 100644
    --- a/include/linux/pm.h
    +++ b/include/linux/pm.h
    @@ -129,6 +129,8 @@ struct pm_ops {

    extern void pm_set_ops(struct pm_ops *);
    extern struct pm_ops *pm_ops;
    +extern void pm_set_ac_status(int (*ac_status_function)(void));
    +extern int pm_get_ac_status(void);
    extern int pm_suspend(suspend_state_t state);


    diff --git a/kernel/power/main.c b/kernel/power/main.c
    index 46110d5..a1daafb 100644
    --- a/kernel/power/main.c
    +++ b/kernel/power/main.c
    @@ -25,6 +25,7 @@
    DECLARE_MUTEX(pm_sem);

    struct pm_ops *pm_ops = NULL;
    +int (*get_ac_status)(void);
    suspend_disk_method_t pm_disk_mode = PM_DISK_SHUTDOWN;

    /**
    @@ -39,6 +40,39 @@ void pm_set_ops(struct pm_ops * ops)
    up(&pm_sem);
    }

    +/**
    + * pm_set_ac_status - Set the ac status callback
    + * @ops: Pointer to function
    + */
    +
    +void pm_set_ac_status(int (*ac_status_function)(void))
    +{
    + down(&pm_sem);
    + get_ac_status = ac_status_function;
    + up(&pm_sem);
    +}
    +
    +EXPORT_SYMBOL(pm_set_ac_status);
    +
    +/**
    + * pm_get_ac_status - return true if the system is on AC
    + */
    +
    +int pm_get_ac_status(void)
    +{
    + int status;
    +
    + down (&pm_sem);
    + if (get_ac_status)
    + status = get_ac_status();
    + else
    + status = 0;
    + up (&pm_sem);
    +
    + return status;
    +}
    +
    +EXPORT_SYMBOL(pm_get_ac_status);

    /**
    * suspend_prepare - Do prep work before entering low-power state.
    --
    Matthew Garrett | mjg59@srcf.ucam.org
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/
    \
     
     \ /
      Last update: 2006-02-08 14:00    [W:0.027 / U:0.328 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site