From patchwork Fri May 16 09:00:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chander Kashyap X-Patchwork-Id: 30317 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id F0BD5202E4 for ; Fri, 16 May 2014 09:00:39 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id wo20sf11196590obc.7 for ; Fri, 16 May 2014 02:00:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=YJDmk/vAnkyQe9KB+MqU8MoFcH6NhpL3Kq8gmbVObOc=; b=Ddc0iflUvCQJH44lJ3IdX34e8A5bYRfTpNJJtwcLycMz0FBRL6Aadahvbva82Po0bh OTkE87oUfptZPvetzwaaOeWeEotQgYSTH8jDytjbcQNJ7zyJgEUiUcEhtHnoVjsKetTp 9i84hKZQViqVUfpBI6EutNO2k9DarkptHD24gb1xGWiQeE0u36Lf26Qwx7fNhFsZH04h wSSVLtA5RXPF6Ic3qtNIkKxhg3b5jRVNupwbsoVfCAKeCNUGR8z1zi/t5JMRHwJozwfc SEdtJRG25sa3M6Q0NEvIwQk9Mb3bCQIde/9CSyT559Jzydjeg5ABXkW356nsTG+xfYNX Cl/g== X-Gm-Message-State: ALoCoQkbJ2T3QaTy+/hVafMtR40bWpVKgTdbMc6P53zHUPw62P1soApLy1IRJrMfO5qt+vSVuH+v X-Received: by 10.42.19.73 with SMTP id a9mr2087420icb.31.1400230839370; Fri, 16 May 2014 02:00:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.50.81 with SMTP id r75ls608636qga.71.gmail; Fri, 16 May 2014 02:00:39 -0700 (PDT) X-Received: by 10.52.190.138 with SMTP id gq10mr55758vdc.47.1400230839190; Fri, 16 May 2014 02:00:39 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id fx7si1431235vcb.153.2014.05.16.02.00.39 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 02:00:39 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id hq16so5796572vcb.23 for ; Fri, 16 May 2014 02:00:39 -0700 (PDT) X-Received: by 10.52.125.147 with SMTP id mq19mr10955104vdb.2.1400230839107; Fri, 16 May 2014 02:00:39 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp35150vcb; Fri, 16 May 2014 02:00:38 -0700 (PDT) X-Received: by 10.66.192.225 with SMTP id hj1mr19280071pac.142.1400230838365; Fri, 16 May 2014 02:00:38 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wt1si4121600pbc.75.2014.05.16.02.00.37; Fri, 16 May 2014 02:00:37 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756595AbaEPJA1 (ORCPT + 27 others); Fri, 16 May 2014 05:00:27 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:53982 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754258AbaEPJAY (ORCPT ); Fri, 16 May 2014 05:00:24 -0400 Received: by mail-pa0-f44.google.com with SMTP id ld10so2287010pab.31 for ; Fri, 16 May 2014 02:00:23 -0700 (PDT) X-Received: by 10.68.171.193 with SMTP id aw1mr19010639pbc.117.1400230823472; Fri, 16 May 2014 02:00:23 -0700 (PDT) Received: from localhost.localdomain ([14.140.216.146]) by mx.google.com with ESMTPSA id ek2sm13375254pbd.30.2014.05.16.02.00.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 02:00:22 -0700 (PDT) From: Chander Kashyap To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: nm@ti.com, rjw@rjwysocki.net, pavel@ucw.cz, len.brown@intel.com, gregkh@linuxfoundation.org, viresh.kumar@linaro.org, Chander Kashyap , Inderpal Singh Subject: [PATCH v3] PM / OPP: discard duplicate OPPs Date: Fri, 16 May 2014 14:30:09 +0530 Message-Id: <1400230809-11401-1-git-send-email-chander.kashyap@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: chander.kashyap@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Chander Kashyap This patch detects the duplicate OPP entries and discards them Signed-off-by: Chander Kashyap Signed-off-by: Inderpal Singh Acked-by: Viresh Kumar --- 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; + } + list_add_rcu(&new_opp->node, head); mutex_unlock(&dev_opp_list_lock);