Skip to content

Commit

Permalink
Preliminary power management support for BMI bus..
Browse files Browse the repository at this point in the history
Signed-off-by: Matt Isaacs <izzy@buglabs.net>
  • Loading branch information
Matt Isaacs committed Sep 17, 2010
1 parent c101ccd commit f88577f
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 8 deletions.
31 changes: 23 additions & 8 deletions drivers/bmi/core/core.c
Expand Up @@ -255,26 +255,40 @@ static void bmi_device_shutdown(struct device * dev)

static int bmi_device_suspend (struct device * dev, pm_message_t state)
{
return -1;
struct bmi_device *bdev = to_bmi_device(dev);
struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
int ret;

printk(KERN_INFO "BMI: Bus suspend..\n");

if (pm->suspend) {
int error;

error = pm->suspend(dev);
suspend_report_result(pm->suspend, error);
if (error)
return error;
}

return 0;
}

static int bmi_device_suspend_late (struct device * dev, pm_message_t state)
{
return -1;
return 0;
}

static int bmi_device_resume_early (struct device * dev)
{
return -1;
return 0;
}

static int bmi_device_resume (struct device * dev)
{
return -1;
printk(KERN_INFO "BMI: Bus resume..\n");
return 0;
}



struct bus_type bmi_bus_type = {
.name = "bmi",
.match = bmi_device_match,
Expand All @@ -284,9 +298,10 @@ struct bus_type bmi_bus_type = {
.shutdown = bmi_device_shutdown,
.suspend = bmi_device_suspend,
.dev_attrs = bmi_dev_attrs,
// .suspend_late = bmi_device_suspend_late,
// .resume_early = bmi_device_resume_early,
//.suspend_late = bmi_device_suspend_late,
//.resume_early = bmi_device_resume_early,
.resume = bmi_device_resume,
.pm = &bmi_dev_pm_ops,
};

static int __init bmi_init(void)
Expand Down
70 changes: 70 additions & 0 deletions drivers/bmi/core/pm.c
@@ -0,0 +1,70 @@
#include <linux/bmi.h>
#include <linux/pm.h>

static int bmi_pm_prepare(struct device *dev)
{
struct device_driver *drv = dev->driver;
int error = 0;

printk(KERN_INFO "BMI: Bus prepare..\n");
if (drv && drv->pm && drv->pm->prepare)
error = drv->pm->prepare(dev);

return error;
}

static void bmi_pm_complete(struct device *dev)
{
struct device_driver *drv = dev->driver;

printk(KERN_INFO "BMI: Bus complete..\n");
if (drv && drv->pm && drv->pm->complete)
drv->pm->complete(dev);
}

static int bmi_pm_suspend (struct device * dev)
{
struct bmi_device *bdev = to_bmi_device(dev);
struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
int ret;

printk(KERN_INFO "BMI: Bus suspend..\n");
if (!pm)
return 0;
if (pm->suspend) {
int error;

error = pm->suspend(dev);
suspend_report_result(pm->suspend, error);
if (error)
return error;
}

return 0;
}

static int bmi_pm_resume (struct device * dev)
{
printk(KERN_INFO "BMI: Bus resume..\n");
return 0;
}

struct dev_pm_ops bmi_dev_pm_ops = {
.prepare = bmi_pm_prepare,
.complete = bmi_pm_complete,
.suspend = bmi_pm_suspend,
.resume = bmi_pm_resume,
/*
.freeze = bmi_pm_freeze,
.thaw = bmi_pm_thaw,
.poweroff = bmi_pm_poweroff,
.restore = bmi_pm_restore,
.suspend_noirq = bmi_pm_suspend_noirq,
.resume_noirq = bmi_pm_resume_noirq,
.freeze_noirq = bmi_pm_freeze_noirq,
.thaw_noirq = bmi_pm_thaw_noirq,
.poweroff_noirq = bmi_pm_poweroff_noirq,
.restore_noirq = bmi_pm_restore_noirq,
*/
};

0 comments on commit f88577f

Please sign in to comment.