X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fcpuidle%2Fsysfs.c;h=e949618b9be0ee3d0e95b48bbac4fd5f93ad21f2;hb=e76328e4a8260707fbc29c99773fb5ba4627096c;hp=0f3515e77d4b5e9a0632ecbb95369962697eae6a;hpb=43cd73658d8077ee6899b0b5029aad0cba1e9f92;p=linux-2.6-omap-h63xx.git diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 0f3515e77d4..e949618b9be 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -218,16 +218,29 @@ static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ return sprintf(buf, "%u\n", state->_name);\ } -static ssize_t show_state_name(struct cpuidle_state *state, char *buf) -{ - return sprintf(buf, "%s\n", state->name); +#define define_show_state_ull_function(_name) \ +static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ +{ \ + return sprintf(buf, "%llu\n", state->_name);\ +} + +#define define_show_state_str_function(_name) \ +static ssize_t show_state_##_name(struct cpuidle_state *state, char *buf) \ +{ \ + if (state->_name[0] == '\0')\ + return sprintf(buf, "\n");\ + return sprintf(buf, "%s\n", state->_name);\ } define_show_state_function(exit_latency) define_show_state_function(power_usage) -define_show_state_function(usage) -define_show_state_function(time) +define_show_state_ull_function(usage) +define_show_state_ull_function(time) +define_show_state_str_function(name) +define_show_state_str_function(desc) + define_one_state_ro(name, show_state_name); +define_one_state_ro(desc, show_state_desc); define_one_state_ro(latency, show_state_exit_latency); define_one_state_ro(power, show_state_power_usage); define_one_state_ro(usage, show_state_usage); @@ -235,6 +248,7 @@ define_one_state_ro(time, show_state_time); static struct attribute *cpuidle_state_default_attrs[] = { &attr_name.attr, + &attr_desc.attr, &attr_latency.attr, &attr_power.attr, &attr_usage.attr, @@ -277,7 +291,7 @@ static struct kobj_type ktype_state_cpuidle = { static void inline cpuidle_free_state_kobj(struct cpuidle_device *device, int i) { - kobject_unregister(&device->kobjs[i]->kobj); + kobject_put(&device->kobjs[i]->kobj); wait_for_completion(&device->kobjs[i]->kobj_unregister); kfree(device->kobjs[i]); device->kobjs[i] = NULL; @@ -300,14 +314,13 @@ int cpuidle_add_state_sysfs(struct cpuidle_device *device) kobj->state = &device->states[i]; init_completion(&kobj->kobj_unregister); - kobj->kobj.parent = &device->kobj; - kobj->kobj.ktype = &ktype_state_cpuidle; - kobject_set_name(&kobj->kobj, "state%d", i); - ret = kobject_register(&kobj->kobj); + ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle, &device->kobj, + "state%d", i); if (ret) { kfree(kobj); goto error_state; } + kobject_uevent(&kobj->kobj, KOBJ_ADD); device->kobjs[i] = kobj; } @@ -339,12 +352,14 @@ int cpuidle_add_sysfs(struct sys_device *sysdev) { int cpu = sysdev->id; struct cpuidle_device *dev; + int error; dev = per_cpu(cpuidle_devices, cpu); - dev->kobj.parent = &sysdev->kobj; - dev->kobj.ktype = &ktype_cpuidle; - kobject_set_name(&dev->kobj, "%s", "cpuidle"); - return kobject_register(&dev->kobj); + error = kobject_init_and_add(&dev->kobj, &ktype_cpuidle, &sysdev->kobj, + "cpuidle"); + if (!error) + kobject_uevent(&dev->kobj, KOBJ_ADD); + return error; } /** @@ -357,5 +372,5 @@ void cpuidle_remove_sysfs(struct sys_device *sysdev) struct cpuidle_device *dev; dev = per_cpu(cpuidle_devices, cpu); - kobject_unregister(&dev->kobj); + kobject_put(&dev->kobj); }