Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 154212
b: refs/heads/master
c: b31d0fd
h: refs/heads/master
v: v3
  • Loading branch information
Corentin Chary authored and Len Brown committed Jun 24, 2009
1 parent 76ab427 commit 849e97d
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 2 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: b7b700d4a473d56103e87e341ad555e8a7cce06d
refs/heads/master: b31d0fde89c905673ceed0404d5ae24f2261d7c7
77 changes: 76 additions & 1 deletion trunk/drivers/platform/x86/eeepc-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,88 @@ static ssize_t show_sys_acpi(int cm, char *buf)
EEEPC_CREATE_DEVICE_ATTR(camera, CM_ASL_CAMERA);
EEEPC_CREATE_DEVICE_ATTR(cardr, CM_ASL_CARDREADER);
EEEPC_CREATE_DEVICE_ATTR(disp, CM_ASL_DISPLAYSWITCH);
EEEPC_CREATE_DEVICE_ATTR(cpufv, CM_ASL_CPUFV);

struct eeepc_cpufv {
int num;
int cur;
};

static int get_cpufv(struct eeepc_cpufv *c)
{
c->cur = get_acpi(CM_ASL_CPUFV);
c->num = (c->cur >> 8) & 0xff;
c->cur &= 0xff;
if (c->cur < 0 || c->num <= 0 || c->num > 12)
return -ENODEV;
return 0;
}

static ssize_t show_available_cpufv(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct eeepc_cpufv c;
int i;
ssize_t len = 0;

if (get_cpufv(&c))
return -ENODEV;
for (i = 0; i < c.num; i++)
len += sprintf(buf + len, "%d ", i);
len += sprintf(buf + len, "\n");
return len;
}

static ssize_t show_cpufv(struct device *dev,
struct device_attribute *attr,
char *buf)
{
struct eeepc_cpufv c;

if (get_cpufv(&c))
return -ENODEV;
return sprintf(buf, "%#x\n", (c.num << 8) | c.cur);
}

static ssize_t store_cpufv(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct eeepc_cpufv c;
int rv, value;

if (get_cpufv(&c))
return -ENODEV;
rv = parse_arg(buf, count, &value);
if (rv < 0)
return rv;
if (!rv || value < 0 || value >= c.num)
return -EINVAL;
set_acpi(CM_ASL_CPUFV, value);
return rv;
}

static struct device_attribute dev_attr_cpufv = {
.attr = {
.name = "cpufv",
.mode = 0644 },
.show = show_cpufv,
.store = store_cpufv
};

static struct device_attribute dev_attr_available_cpufv = {
.attr = {
.name = "available_cpufv",
.mode = 0444 },
.show = show_available_cpufv
};

static struct attribute *platform_attributes[] = {
&dev_attr_camera.attr,
&dev_attr_cardr.attr,
&dev_attr_disp.attr,
&dev_attr_cpufv.attr,
&dev_attr_available_cpufv.attr,
NULL
};

Expand Down

0 comments on commit 849e97d

Please sign in to comment.