linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
To: Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: linux-pm@lists.linux-foundation.org, patches@linaro.org,
	linaro-dev@lists.linaro.org, amit.kucheria@linaro.org
Subject: Re: [PATCH][V2] cpuidle : use percpu cpuidle in the core code
Date: Mon, 02 Apr 2012 18:51:48 +0530	[thread overview]
Message-ID: <4F79A7EC.5000003@linux.vnet.ibm.com> (raw)
In-Reply-To: <1333370928-1930-1-git-send-email-daniel.lezcano@linaro.org>

On 04/02/2012 06:18 PM, Daniel Lezcano wrote:

> The usual cpuidle initialization routines are to register the
> driver, then register a cpuidle device per cpu.
> 
> With the device's state count default initialization with the
> driver's state count, the code initialization remains mostly the
> same in the different drivers.
> 
> We can then add a new function 'cpuidle_register' where we register
> the driver and the devices. These devices can be defined in a global
> static variable in cpuidle.c. We will be able to factor out and
> remove a lot of duplicate lines of code.
> 
> As we still have some drivers, with different initialization routines,
> we keep 'cpuidle_register_driver' and 'cpuidle_register_device' as low
> level initialization routines to do some specific operations on the
> cpuidle devices.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

> +/*
> + * cpuidle_register : register cpuidle driver and devices
> + * Note this function must be called after smp_init.
> + * @drv : the cpuidle driver
> + * Returns 0 on success, < 0 otherwise
> + */
> +int cpuidle_register(struct cpuidle_driver *drv)
> +{
> +	int ret, cpu, i;
> +	struct cpuidle_device *dev;
> +
> +	ret = cpuidle_register_driver(drv);
> +	if (ret)
> +		return ret;
> +
> +	for_each_online_cpu(cpu) {
> +		dev = &per_cpu(cpuidle_device, cpu);
> +		dev->cpu = cpu;
> +
> +		ret = cpuidle_register_device(dev);
> +		if (ret)
> +			goto out_unregister;
> +	}
> +
> +out:
> +	return ret;
> +
> +out_unregister:
> +	for_each_online_cpu(i) {
> +		if (i == cpu)
> +			break;
> +		dev = &per_cpu(cpuidle_device, cpu);


					       ^^^
That must have been "i" instead of "cpu"...

> +		cpuidle_unregister_device(dev);
> +	}
> +
> +	cpuidle_unregister_driver(drv);
> +
> +	goto out;
> +}
> +EXPORT_SYMBOL_GPL(cpuidle_register);
> +



Regards,
Srivatsa S. Bhat

  parent reply	other threads:[~2012-04-02 13:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-02 12:48 [PATCH][V2] cpuidle : use percpu cpuidle in the core code Daniel Lezcano
     [not found] ` <1333370928-1930-1-git-send-email-daniel.lezcano-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-04-02 12:59   ` Amit Kucheria
2012-04-02 13:21 ` Srivatsa S. Bhat [this message]
2012-04-02 13:46   ` Daniel Lezcano

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=4F79A7EC.5000003@linux.vnet.ibm.com \
    --to=srivatsa.bhat@linux.vnet.ibm.com \
    --cc=amit.kucheria@linaro.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=patches@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;
as well as URLs for NNTP newsgroup(s).