mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Nishanth Menon <nm@ti.com>
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: Fri, 26 Oct 2012 02:22:51 +0200	[thread overview]
Message-ID: <1775844.L5g0QF5oVv@vostro.rjw.lan> (raw)
In-Reply-To: <20121026000321.GA4190@kahuna>

On Thursday, October 25, 2012 07:03:21 PM Nishanth Menon wrote:
> 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;

What about

if (count)
  count--;

instead?

> count += sprintf(&buf[count], "\n");
> should take care of empty list and the trailing space. Sounds reasonable?

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

      reply	other threads:[~2012-10-26  0:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-25 23:32 Nishanth Menon
2012-10-25 23:56 ` Rafael J. Wysocki
2012-10-26  0:03   ` Nishanth Menon
2012-10-26  0:22     ` Rafael J. Wysocki [this message]

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=1775844.L5g0QF5oVv@vostro.rjw.lan \
    --to=rjw@sisk.pl \
    --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=nm@ti.com \
    --cc=rajagopal.venkat@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®