[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1775844.L5g0QF5oVv@vostro.rjw.lan>
Date: Fri, 26 Oct 2012 02:22:51 +0200
From: "Rafael J. Wysocki" <rjw@...k.pl>
To: Nishanth Menon <nm@...com>
Cc: linux-pm <linux-pm@...r.kernel.org>,
Rajagopal Venkat <rajagopal.venkat@...aro.org>,
MyungJoo Ham <myungjoo.ham@...sung.com>,
Kyungmin Park <kyungmin.park@...sung.com>,
Kevin Hilman <khilman@...com>, linux-kernel@...r.kernel.org
Subject: Re: [for-next PATCH] PM / devfreq: Add sysfs node to expose available frequencies
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists