linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nishanth Menon <nm@ti.com>
To: Chander Kashyap <chander.kashyap@linaro.org>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: rjw@rjwysocki.net, pavel@ucw.cz, len.brown@intel.com,
	gregkh@linuxfoundation.org, viresh.kumar@linaro.org,
	Chander Kashyap <k.chander@samsung.com>,
	Inderpal Singh <inderpal.s@samsung.com>
Subject: Re: [PATCH v3] PM / OPP: discard duplicate OPPs
Date: Mon, 19 May 2014 08:08:23 -0500	[thread overview]
Message-ID: <537A0247.1030503@ti.com> (raw)
In-Reply-To: <1400230809-11401-1-git-send-email-chander.kashyap@linaro.org>

On 05/16/2014 04:00 AM, Chander Kashyap wrote:
> From: Chander Kashyap <k.chander@samsung.com>
> 
> This patch detects the duplicate OPP entries and discards them
> 
> Signed-off-by: Chander Kashyap <k.chander@samsung.com>
> Signed-off-by: Inderpal Singh <inderpal.s@samsung.com>
> ---
>  Changes in v3:
> 	- Modify the commit log
>  Changes in v2:
> 	- Reorder check for duplicate opp
> 
>  drivers/base/power/opp.c |   13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c
> index ca521e1..973da78 100644
> --- a/drivers/base/power/opp.c
> +++ b/drivers/base/power/opp.c
> @@ -443,15 +443,24 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt)
>  	new_opp->u_volt = u_volt;
>  	new_opp->available = true;
>  
> -	/* Insert new OPP in order of increasing frequency */
> +	/*
> +	 * Insert new OPP in order of increasing frequency
> +	 * and discard if already present
> +	 */
>  	head = &dev_opp->opp_list;
>  	list_for_each_entry_rcu(opp, &dev_opp->opp_list, node) {
> -		if (new_opp->rate < opp->rate)
> +		if (new_opp->rate <= opp->rate)
>  			break;
>  		else
>  			head = &opp->node;
>  	}
>  
> +	if (new_opp->rate == opp->rate) {
> +		mutex_unlock(&dev_opp_list_lock);
> +		kfree(new_opp);
> +		return 0;

IF we decide on ensuring that the OPP additions are done one time[1] -
then returning -EEXIST is appropriate here. we want to be able to
catch warnings of sequencing errors, and returning 0 is not the way to
do it.

> +	}
> +
>  	list_add_rcu(&new_opp->node, head);
>  	mutex_unlock(&dev_opp_list_lock);
>  
> 

[1] http://marc.info/?l=linux-pm&m=140034777229205&w=2

-- 
Regards,
Nishanth Menon

  parent reply	other threads:[~2014-05-19 13:08 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-16  9:00 [PATCH v3] PM / OPP: discard duplicate OPPs Chander Kashyap
2014-05-16 10:03 ` Viresh Kumar
2014-05-19 13:08 ` Nishanth Menon [this message]
2014-05-20  4:00   ` Viresh Kumar
2014-05-20 11:24     ` Nishanth Menon
2014-05-20 11:26       ` Viresh Kumar
2014-05-20 12:05         ` Viresh Kumar
2014-05-20 12:32           ` Nishanth Menon
2014-05-20 13:36             ` Viresh Kumar
2014-05-20 12:45           ` Rafael J. Wysocki
2014-05-20 13:29             ` Viresh Kumar
2014-05-20 13:31           ` Viresh Kumar
2014-05-20 13:36             ` Nishanth Menon

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=537A0247.1030503@ti.com \
    --to=nm@ti.com \
    --cc=chander.kashyap@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=inderpal.s@samsung.com \
    --cc=k.chander@samsung.com \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@ucw.cz \
    --cc=rjw@rjwysocki.net \
    --cc=viresh.kumar@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).