Hi, On 09/25/2012 12:43 AM, Daniel Lezcano wrote: ... > diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c > index 5f809e3..2596422 100644 > --- a/drivers/cpuidle/sysfs.c > +++ b/drivers/cpuidle/sysfs.c > @@ -43,21 +43,46 @@ out: > return i; > } > > +struct cbarg { > + char *buf; > + ssize_t count; > +}; > + > +static int each_driver_cb(int cpu, struct cpuidle_driver *drv, void *data) > +{ > + int ret; > + struct cbarg *cbarg = data; > + > + if ((drv && (strlen(drv->name) + cbarg->count) >= PAGE_SIZE) || > + (!drv && (strlen("none") + cbarg->count) >= PAGE_SIZE)) > + return -EOVERFLOW; > + > +#ifdef CONFIG_CPU_IDLE_MULTIPLE_DRIVERS > + ret = sprintf(cbarg->buf + cbarg->count, "cpu%d: %s\n", > + cpu, drv ? drv->name : "none" ); > +#else > + ret = sprintf(cbarg->buf, "%s\n", drv ? drv->name : "none"); > +#endif > + if (ret < 0) > + return ret; > + > + cbarg->count += ret; > + > + return 0; > +} > + > static ssize_t show_current_driver(struct device *dev, > struct device_attribute *attr, > char *buf) > { > - ssize_t ret; > - struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); > + struct cbarg cbarg = { .buf = buf }; cbarg.count should be initialized to 0. > + int ret; > > - spin_lock(&cpuidle_driver_lock); > - if (cpuidle_driver) > - ret = sprintf(buf, "%s\n", cpuidle_driver->name); > - else > - ret = sprintf(buf, "none\n"); > - spin_unlock(&cpuidle_driver_lock); > + ret = cpuidle_for_each_driver(each_driver_cb, &cbarg); > + if (ret < 0) > + return ret; > > - return ret; > + return cbarg.count; > } -- Francesco -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html