From: Nishanth Menon <nm@ti.com>
To: MyungJoo Ham <myungjoo.ham@gmail.com>
Cc: myungjoo.ham@samsung.com, LKML <linux-kernel@vger.kernel.org>,
"Kevin Hilman" <khilman@ti.com>,
linux-pm <linux-pm@vger.kernel.org>,
"Rajagopal Venkat" <rajagopal.venkat@linaro.org>,
박경민 <kyungmin.park@samsung.com>,
"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: Re: [linux-next PATCH 6/7] PM / devfreq: allow sysfs governor node to switch governor
Date: Tue, 6 Nov 2012 15:28:25 -0600 [thread overview]
Message-ID: <20121106212825.GA21925@kahuna> (raw)
In-Reply-To: <CAJ0PZbSe7Orhww-amHNRkbvUvJr6x9CtisHw2hoLpcJdyBSKCA@mail.gmail.com>
On 18:18-20121106, MyungJoo Ham wrote:
> 2012. 11. 6. 오후 6:02에 "MyungJoo Ham" <myungjoo.ham@samsung.com>님이 작성:
> >
> > > --- a/drivers/devfreq/devfreq.c
> > > +++ b/drivers/devfreq/devfreq.c
> > > @@ -629,6 +629,44 @@ static ssize_t show_governor(struct device *dev,
> > > return sprintf(buf, "%s\n", to_devfreq(dev)->governor->name);
> > > }
> > >
> > > +static ssize_t store_governor(struct device *dev, struct
> device_attribute *attr,
> > > + const char *buf, size_t count)
> > > +{
> > > + struct devfreq *df = to_devfreq(dev);
> > > + int ret = 0;
> > > + struct devfreq_governor *governor;
> > > +
> > > + mutex_lock(&devfreq_list_lock);
> >
> > Please remove the trailing \n from buf here.
> > When user enters "userspace", buf gets "userspace\n".
> >
> > With some printks in find_devfreq_governor (printing the buf and governor
> names):
> >
> > # echo userspace > /sys/class/devfreq/exynos4210-busfreq.0/governor
> > [ 65.975000] [userspace
> > [ 65.975000] ].[userspace]
> > [ 65.980000] [userspace
> > [ 65.980000] ].[powersave]
> > [ 65.985000] [userspace
> > [ 65.985000] ].[performance]
> > [ 65.990000] [userspace
> > [ 65.990000] ].[simple_ondemand]
> > [ 65.995000] err no = -19
> > #
> >
>
> Anyway this seems quite wierd. I will look more into this one in my target
> system.
Thanks for catching this.
:( I missed the \n (been using echo -n toooo often now grr..)
What do you think of the following change to the patch?
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 586b6fd..9a4e898 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -614,11 +614,16 @@ static ssize_t store_governor(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct devfreq *df = to_devfreq(dev);
- int ret = 0;
+ int ret;
+ char str_governor[DEVFREQ_NAME_LEN + 1];
struct devfreq_governor *governor;
+ ret = sscanf(buf, "%" __stringify(DEVFREQ_NAME_LEN) "s", str_governor);
+ if (ret != 1)
+ return -EINVAL;
+
mutex_lock(&devfreq_list_lock);
- governor = find_devfreq_governor(buf);
+ governor = find_devfreq_governor(str_governor);
if (IS_ERR(governor)) {
ret = PTR_ERR(governor);
goto out;
--
Regards,
Nishanth Menon
output:
/sys/devices/platform/iva.0/devfreq/iva.0 # cat governor
simple_ondemand
/sys/devices/platform/iva.0/devfreq/iva.0 # echo -n "userspace">governor
/sys/devices/platform/iva.0/devfreq/iva.0 # echo -n "simple_ondeman">governor
sh: write error: No such device
/sys/devices/platform/iva.0/devfreq/iva.0 # cat governor
userspace
/sys/devices/platform/iva.0/devfreq/iva.0 # echo -n "simple_ondemand">governor
/sys/devices/platform/iva.0/devfreq/iva.0 # cat governor
simple_ondemand
/sys/devices/platform/iva.0/devfreq/iva.0 # echo "userspace">governor
/sys/devices/platform/iva.0/devfreq/iva.0 # cat governor
userspace
/sys/devices/platform/iva.0/devfreq/iva.0 # echo "simple_ondemand">governor
/sys/devices/platform/iva.0/devfreq/iva.0 # echo "userspace123123213123213123212
3123123131231">governor
sh: write error: No such device
/sys/devices/platform/iva.0/devfreq/iva.0 # cat governor
simple_ondemand
next prev parent reply other threads:[~2012-11-06 21:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-06 9:02 [linux-next PATCH 6/7] PM / devfreq: allow sysfs governor node to switch governor MyungJoo Ham
2012-11-06 9:02 ` MyungJoo Ham
[not found] ` <CAJ0PZbSe7Orhww-amHNRkbvUvJr6x9CtisHw2hoLpcJdyBSKCA@mail.gmail.com>
2012-11-06 21:28 ` Nishanth Menon [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-10-29 20:01 [linux-next PATCH 0/7] PM / devfreq: allow governors to be modules and switch dynamically Nishanth Menon
2012-10-29 20:01 ` [linux-next PATCH 6/7] PM / devfreq: allow sysfs governor node to switch governor Nishanth Menon
2012-10-29 20:01 ` Nishanth Menon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121106212825.GA21925@kahuna \
--to=nm@ti.com \
--cc=khilman@ti.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=myungjoo.ham@gmail.com \
--cc=myungjoo.ham@samsung.com \
--cc=rajagopal.venkat@linaro.org \
--cc=rjw@sisk.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.