Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 62564
b: refs/heads/master
c: f432255
h: refs/heads/master
v: v3
  • Loading branch information
Henrique de Moraes Holschuh authored and Len Brown committed Jul 22, 2007
1 parent cc48843 commit 4ceb851
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 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: c78d5c96bb65b71a54b7551b404fbaf4763ed6e4
refs/heads/master: f432255e936a892a6896e5032e2b4897423076f2
35 changes: 28 additions & 7 deletions trunk/drivers/misc/thinkpad_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3000,12 +3000,16 @@ static struct backlight_ops ibm_backlight_data = {
.update_status = brightness_update_status,
};

static struct mutex brightness_mutex;

static int __init brightness_init(struct ibm_init_struct *iibm)
{
int b;

vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n");

mutex_init(&brightness_mutex);

if (!brightness_mode) {
if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO)
brightness_mode = 2;
Expand Down Expand Up @@ -3092,27 +3096,44 @@ static int brightness_get(struct backlight_device *bd)

static int brightness_set(int value)
{
int cmos_cmd, inc, i;
int current_value = brightness_get(NULL);
int cmos_cmd, inc, i, res;
int current_value;

if (value > 7)
return -EINVAL;

res = mutex_lock_interruptible(&brightness_mutex);
if (res < 0)
return res;

current_value = brightness_get(NULL);
if (current_value < 0) {
res = current_value;
goto errout;
}

cmos_cmd = value > current_value ?
TP_CMOS_BRIGHTNESS_UP :
TP_CMOS_BRIGHTNESS_DOWN;
inc = value > current_value ? 1 : -1;

res = 0;
for (i = current_value; i != value; i += inc) {
if ((brightness_mode & 2) &&
issue_thinkpad_cmos_command(cmos_cmd))
return -EIO;
issue_thinkpad_cmos_command(cmos_cmd)) {
res = -EIO;
goto errout;
}
if ((brightness_mode & 1) &&
!acpi_ec_write(brightness_offset, i + inc))
return -EIO;
!acpi_ec_write(brightness_offset, i + inc)) {
res = -EIO;
goto errout;;
}
}

return 0;
errout:
mutex_unlock(&brightness_mutex);
return res;
}

static int brightness_read(char *p)
Expand Down

0 comments on commit 4ceb851

Please sign in to comment.