From patchwork Thu Feb 19 11:32:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 44816 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E930C21554 for ; Thu, 19 Feb 2015 11:33:34 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id b15sf5113274eek.0 for ; Thu, 19 Feb 2015 03:33:34 -0800 (PST) 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:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=pfU/HVhLsxHGGxeIKLPAmCE2TPPoHeVnDcchx49yqes=; b=O2cP8b+nB1lNDL/7LK/FsHum9c5cGqz4CI0oCykpdXTevSge5x+dm/iWgTR4LPbf3m bvMk0VUrFQA9GJdNGZkst4Zyu8YkzqOiC28/OWbL3dzNxiLhP9DIClI/QAbI1bnMfAXY GreOFqtlvvnwuctHcV2rHjKEeDbNFIOEAjnVdPvVVt1JPkNFe6zIKHI5q7p8QZHnTyg3 vWyQQUAeChC1Jm2Z78PFSgan9mbqYo+PzL7eLoyJOaHEb1Xd1HCI5gXKGdR3SYqTFP91 tkxToXfqJ1EQaBYSnjk2h+keXP8vLZSij2nFb14qMdIQz8nN7pT5e1bXqbdP4HiFVe3i YcoQ== X-Gm-Message-State: ALoCoQlydJxXcdo5WAVls1hbi+JStVwsJSvSOurOHB1kSfXDNA330xq3a9SR+JyBnd/YufUKPHXn X-Received: by 10.152.1.5 with SMTP id 5mr518328lai.4.1424345614097; Thu, 19 Feb 2015 03:33:34 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.42 with SMTP id v10ls131561laj.56.gmail; Thu, 19 Feb 2015 03:33:33 -0800 (PST) X-Received: by 10.112.62.135 with SMTP id y7mr3624675lbr.50.1424345613900; Thu, 19 Feb 2015 03:33:33 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id jr8si3106613lab.63.2015.02.19.03.33.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Feb 2015 03:33:33 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbvn10 with SMTP id n10so6866581lbv.4 for ; Thu, 19 Feb 2015 03:33:33 -0800 (PST) X-Received: by 10.112.26.110 with SMTP id k14mr3456990lbg.29.1424345613739; Thu, 19 Feb 2015 03:33:33 -0800 (PST) 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.112.35.133 with SMTP id h5csp431459lbj; Thu, 19 Feb 2015 03:33:32 -0800 (PST) X-Received: by 10.66.251.105 with SMTP id zj9mr7350226pac.4.1424345611751; Thu, 19 Feb 2015 03:33:31 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5si9194519pdq.28.2015.02.19.03.33.30; Thu, 19 Feb 2015 03:33:31 -0800 (PST) Received-SPF: none (google.com: linux-pm-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 S1753355AbbBSLd1 (ORCPT + 11 others); Thu, 19 Feb 2015 06:33:27 -0500 Received: from mail-pd0-f176.google.com ([209.85.192.176]:33353 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753354AbbBSLdZ (ORCPT ); Thu, 19 Feb 2015 06:33:25 -0500 Received: by pdjz10 with SMTP id z10so8319913pdj.0 for ; Thu, 19 Feb 2015 03:33:25 -0800 (PST) X-Received: by 10.66.156.229 with SMTP id wh5mr6669583pab.119.1424345604922; Thu, 19 Feb 2015 03:33:24 -0800 (PST) Received: from localhost ([122.172.249.58]) by mx.google.com with ESMTPSA id rj7sm23408319pbc.58.2015.02.19.03.33.23 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 19 Feb 2015 03:33:24 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, sboyd@codeaurora.org, prarit@redhat.com, skannan@codeaurora.org, Viresh Kumar Subject: [PATCH V2 01/20] cpufreq: Add doc style comment about cpufreq_cpu_{get|put}() Date: Thu, 19 Feb 2015 17:02:03 +0530 Message-Id: <3e39c8ea46c06a2933e8bae2117396ed220d548b.1424345053.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.3.0.rc0.44.ga94655d In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@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.217.174 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: , This clearly states what the code inside these routines is doing and how these must be used. Signed-off-by: Viresh Kumar --- drivers/cpufreq/cpufreq.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 28e59a48b35f..fc51b8fbb0b0 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -207,6 +207,23 @@ struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu) return per_cpu(cpufreq_cpu_data, cpu); } +/** + * cpufreq_cpu_get: returns policy for a cpu and marks it busy. + * + * @cpu: cpu to find policy for. + * + * This returns policy for 'cpu', returns NULL if it doesn't exist. + * It also increments the kobject reference count to mark it busy and so would + * require a corresponding call to cpufreq_cpu_put() to decrement it back. + * If corresponding call cpufreq_cpu_put() isn't made, the policy wouldn't be + * freed as that depends on the kobj count. + * + * It also takes a read-lock of 'cpufreq_rwsem' and doesn't put it back if a + * valid policy is found. This is done to make sure the driver doesn't get + * unregistered while the policy is being used. + * + * Return: A valid policy on success, otherwise NULL on failure. + */ struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) { struct cpufreq_policy *policy = NULL; @@ -237,6 +254,16 @@ struct cpufreq_policy *cpufreq_cpu_get(unsigned int cpu) } EXPORT_SYMBOL_GPL(cpufreq_cpu_get); +/** + * cpufreq_cpu_put: Decrements the usage count of a policy + * + * @policy: policy earlier returned by cpufreq_cpu_get(). + * + * This decrements the kobject reference count incremented earlier by calling + * cpufreq_cpu_get(). + * + * It also drops the read-lock of 'cpufreq_rwsem' taken at cpufreq_cpu_get(). + */ void cpufreq_cpu_put(struct cpufreq_policy *policy) { kobject_put(&policy->kobj);