From: Nishanth Menon <nm@ti.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: linux-pm <linux-pm@vger.kernel.org>,
Rajagopal Venkat <rajagopal.venkat@linaro.org>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Kevin Hilman <khilman@ti.com>,
linux-kernel@vger.kernel.org
Subject: Re: [for-next PATCH] PM / devfreq: Add sysfs node to expose available frequencies
Date: Thu, 25 Oct 2012 19:03:21 -0500 [thread overview]
Message-ID: <20121026000321.GA4190@kahuna> (raw)
In-Reply-To: <1639482.oGax1ZB8vZ@vostro.rjw.lan>
On 01:56-20121026, Rafael J. Wysocki wrote:
> On Thursday, October 25, 2012 06:32:43 PM Nishanth Menon wrote:
[..]
> > +static ssize_t show_available_freqs(struct device *d,
> > + struct device_attribute *attr,
> > + char *buf)
> > +{
> > + struct devfreq *df = to_devfreq(d);
> > + struct device *dev = df->dev.parent;
> > + struct opp *opp;
> > + ssize_t count = 0;
> > + unsigned long freq = 0;
> > +
> > + rcu_read_lock();
> > + do {
> > + opp = opp_find_freq_ceil(dev, &freq);
> > + if (IS_ERR(opp))
> > + break;
> > +
> > + count += sprintf(&buf[count], "%lu ", freq);
> > + freq++;
> > + } while (1);
> > + rcu_read_unlock();
> > + count += sprintf(&buf[count], "\n");
>
> Care to avoid printing the tailing space?
count -= count ? 1 : 0;
count += sprintf(&buf[count], "\n");
should take care of empty list and the trailing space. Sounds reasonable?
--
Regards,
Nishanth Menon
WARNING: multiple messages have this Message-ID (diff)
From: Nishanth Menon <nm@ti.com>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: linux-pm <linux-pm@vger.kernel.org>,
Rajagopal Venkat <rajagopal.venkat@linaro.org>,
MyungJoo Ham <myungjoo.ham@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Kevin Hilman <khilman@ti.com>, <linux-kernel@vger.kernel.org>
Subject: Re: [for-next PATCH] PM / devfreq: Add sysfs node to expose available frequencies
Date: Thu, 25 Oct 2012 19:03:21 -0500 [thread overview]
Message-ID: <20121026000321.GA4190@kahuna> (raw)
In-Reply-To: <1639482.oGax1ZB8vZ@vostro.rjw.lan>
On 01:56-20121026, Rafael J. Wysocki wrote:
> On Thursday, October 25, 2012 06:32:43 PM Nishanth Menon wrote:
[..]
> > +static ssize_t show_available_freqs(struct device *d,
> > + struct device_attribute *attr,
> > + char *buf)
> > +{
> > + struct devfreq *df = to_devfreq(d);
> > + struct device *dev = df->dev.parent;
> > + struct opp *opp;
> > + ssize_t count = 0;
> > + unsigned long freq = 0;
> > +
> > + rcu_read_lock();
> > + do {
> > + opp = opp_find_freq_ceil(dev, &freq);
> > + if (IS_ERR(opp))
> > + break;
> > +
> > + count += sprintf(&buf[count], "%lu ", freq);
> > + freq++;
> > + } while (1);
> > + rcu_read_unlock();
> > + count += sprintf(&buf[count], "\n");
>
> Care to avoid printing the tailing space?
count -= count ? 1 : 0;
count += sprintf(&buf[count], "\n");
should take care of empty list and the trailing space. Sounds reasonable?
--
Regards,
Nishanth Menon
next prev parent reply other threads:[~2012-10-26 0:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-25 23:32 [for-next PATCH] PM / devfreq: Add sysfs node to expose available frequencies Nishanth Menon
2012-10-25 23:32 ` Nishanth Menon
2012-10-25 23:56 ` Rafael J. Wysocki
2012-10-26 0:03 ` Nishanth Menon [this message]
2012-10-26 0:03 ` Nishanth Menon
2012-10-26 0:22 ` Rafael J. Wysocki
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=20121026000321.GA4190@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@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.