linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Paul Mackerras <paulus@ozlabs.org>
To: Oliver O'Halloran <oohall@gmail.com>
Cc: "Gautham R. Shenoy" <ego@linux.vnet.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	Michael Neuling <mikey@neuling.org>,
	Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>,
	"Shreyas B. Prabhu" <shreyasbp@gmail.com>,
	Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>,
	Stewart Smith <stewart@linux.vnet.ibm.com>,
	Balbir Singh <bsingharora@gmail.com>,
	skiboot list <skiboot@lists.ozlabs.org>,
	linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org
Subject: Re: [PATCH v2 2/3] cpuidle:powernv: Add helper function to populate powernv idle states.
Date: Wed, 2 Nov 2016 08:03:01 +1100	[thread overview]
Message-ID: <20161101210301.GA15949@fergus.ozlabs.ibm.com> (raw)
In-Reply-To: <CAOSf1CHZ0_1B28bX9TsaE6vcOaWUwhanQWAN=LKSLoNHK+Jh0A@mail.gmail.com>

On Tue, Nov 01, 2016 at 07:32:58PM +1100, Oliver O'Halloran wrote:
> On Thu, Oct 27, 2016 at 7:35 PM, Gautham R. Shenoy
> <ego@linux.vnet.ibm.com> wrote:
> > From: "Gautham R. Shenoy" <ego@linux.vnet.ibm.com>
> >
> > In the current code for powernv_add_idle_states, there is a lot of code
> > duplication while initializing an idle state in powernv_states table.
> >
> > Add an inline helper function to populate the powernv_states[] table for
> > a given idle state. Invoke this for populating the "Nap", "Fastsleep"
> > and the stop states in powernv_add_idle_states.
> >
> > Signed-off-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
> > ---
> >  drivers/cpuidle/cpuidle-powernv.c | 82 +++++++++++++++++++++++----------------
> >  include/linux/cpuidle.h           |  1 +
> >  2 files changed, 49 insertions(+), 34 deletions(-)
> >
> > diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
> > index 7fe442c..11b22b9 100644
> > --- a/drivers/cpuidle/cpuidle-powernv.c
> > +++ b/drivers/cpuidle/cpuidle-powernv.c
> > @@ -167,6 +167,28 @@ static int powernv_cpuidle_driver_init(void)
> >         return 0;
> >  }
> >
> > +static inline void add_powernv_state(int index, const char *name,
> > +                                    unsigned int flags,
> > +                                    int (*idle_fn)(struct cpuidle_device *,
> > +                                                   struct cpuidle_driver *,
> > +                                                   int),
> > +                                    unsigned int target_residency,
> > +                                    unsigned int exit_latency,
> > +                                    u64 psscr_val)
> > +{
> > +       strncpy(powernv_states[index].name, name, CPUIDLE_NAME_LEN);
> > +       strncpy(powernv_states[index].desc, name, CPUIDLE_NAME_LEN);
> 
> If the supplied name is equal to CPUIDLE_NAME_LEN then strncpy() won't
> terminate the string. The least annoying fix is to memset() the whole
> structure to zero and set n to CPUIDLE_NAME_LEN - 1.

Or he could use strlcpy() instead of strncpy().

Paul.

  reply	other threads:[~2016-11-01 21:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-27  8:35 [PATCH v2 0/3] powernv:stop: Use psscr_val,mask provided by firmware Gautham R. Shenoy
2016-10-27  8:35 ` [PATCH v2 1/3] powernv:idle: Add IDLE_STATE_ENTER_SEQ_NORET macro Gautham R. Shenoy
2016-10-27  8:35 ` [PATCH v2 2/3] cpuidle:powernv: Add helper function to populate powernv idle states Gautham R. Shenoy
2016-11-01  8:32   ` Oliver O'Halloran
2016-11-01 21:03     ` Paul Mackerras [this message]
2016-11-02  8:42     ` Gautham R Shenoy
2016-10-27  8:35 ` [PATCH v2 3/3] powernv: Pass PSSCR value and mask to power9_idle_stop Gautham R. Shenoy
2016-11-01  4:21 ` [PATCH v2 0/3] powernv:stop: Use psscr_val, mask provided by firmware 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=20161101210301.GA15949@fergus.ozlabs.ibm.com \
    --to=paulus@ozlabs.org \
    --cc=benh@kernel.crashing.org \
    --cc=bsingharora@gmail.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=ego@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=mpe@ellerman.id.au \
    --cc=oohall@gmail.com \
    --cc=rjw@rjwysocki.net \
    --cc=shilpa.bhat@linux.vnet.ibm.com \
    --cc=shreyasbp@gmail.com \
    --cc=skiboot@lists.ozlabs.org \
    --cc=stewart@linux.vnet.ibm.com \
    --cc=svaidy@linux.vnet.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).