Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 164544
b: refs/heads/master
c: a976f15
h: refs/heads/master
v: v3
  • Loading branch information
Henrik Rydberg authored and Linus Torvalds committed Sep 22, 2009
1 parent 63174e4 commit 974539f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 560a64a2b501add585b494b2b9cd9f68c0636b50
refs/heads/master: a976f150a6953da5ccbd40fa6dba3bd7d56f9f67
38 changes: 26 additions & 12 deletions trunk/drivers/hwmon/applesmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ static const int debug;
static struct platform_device *pdev;
static s16 rest_x;
static s16 rest_y;
static u8 backlight_state[2];

static struct device *hwmon_dev;
static struct input_polled_dev *applesmc_idev;

Expand Down Expand Up @@ -497,17 +499,36 @@ static int applesmc_probe(struct platform_device *dev)
return 0;
}

static int applesmc_resume(struct platform_device *dev)
/* Synchronize device with memorized backlight state */
static int applesmc_pm_resume(struct device *dev)
{
return applesmc_device_init();
mutex_lock(&applesmc_lock);
if (applesmc_light)
applesmc_write_key(BACKLIGHT_KEY, backlight_state, 2);
mutex_unlock(&applesmc_lock);
return 0;
}

/* Reinitialize device on resume from hibernation */
static int applesmc_pm_restore(struct device *dev)
{
int ret = applesmc_device_init();
if (ret)
return ret;
return applesmc_pm_resume(dev);
}

static struct dev_pm_ops applesmc_pm_ops = {
.resume = applesmc_pm_resume,
.restore = applesmc_pm_restore,
};

static struct platform_driver applesmc_driver = {
.probe = applesmc_probe,
.resume = applesmc_resume,
.driver = {
.name = "applesmc",
.owner = THIS_MODULE,
.pm = &applesmc_pm_ops,
},
};

Expand Down Expand Up @@ -804,17 +825,10 @@ static ssize_t applesmc_calibrate_store(struct device *dev,
return count;
}

/* Store the next backlight value to be written by the work */
static unsigned int backlight_value;

static void applesmc_backlight_set(struct work_struct *work)
{
u8 buffer[2];

mutex_lock(&applesmc_lock);
buffer[0] = backlight_value;
buffer[1] = 0x00;
applesmc_write_key(BACKLIGHT_KEY, buffer, 2);
applesmc_write_key(BACKLIGHT_KEY, backlight_state, 2);
mutex_unlock(&applesmc_lock);
}
static DECLARE_WORK(backlight_work, &applesmc_backlight_set);
Expand All @@ -824,7 +838,7 @@ static void applesmc_brightness_set(struct led_classdev *led_cdev,
{
int ret;

backlight_value = value;
backlight_state[0] = value;
ret = queue_work(applesmc_led_wq, &backlight_work);

if (debug && (!ret))
Expand Down

0 comments on commit 974539f

Please sign in to comment.