From patchwork Tue Jan 27 08:36:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 43823 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1F9512409D for ; Tue, 27 Jan 2015 08:37:26 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf6836179lab.3 for ; Tue, 27 Jan 2015 00:37:25 -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=TA80WFtpndrYXRLu7/V/j1jmJ38bza9KkmFcKtZyTjk=; b=Kd3er5jN0rOxyTDeeW/U5UPFufoessjH6+/mVTdxmb5newsqRbY0ZUzxsmrfUel5V9 2ZUEHbSYDbEKjOMUHoThy4u4g8qWexqDmL2kivAn7XV4cTWheXTvT4E3wUtknAZQiKgF mDLqjd0D1f3BdfZAPPRXB5nH1M7JIMT6oWYFhH++ien2FT0BdwhtjSjxvmnz1QW1R1eA WlJt3hM7zv7HYMcTtOFst3p0T2JKjZHynNkhyB9fuIq8k26+T8lzaTeCufTMfG0QQgSI FzRHZ7dAsL0euhvw+EAeChnxNjSkgwA7+V4RKscceQh7BG8qhojrV9doYaU9X76hkmnz assw== X-Gm-Message-State: ALoCoQml88htsOFe4c1qhX2GEweKGHJsxlEC7VwETpB0wmHuq4SwtjCNdrSjjW7xjDA9v2L6R8ck X-Received: by 10.152.37.130 with SMTP id y2mr34707laj.8.1422347845029; Tue, 27 Jan 2015 00:37:25 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.2 with SMTP id ku2ls2516lac.64.gmail; Tue, 27 Jan 2015 00:37:24 -0800 (PST) X-Received: by 10.112.30.135 with SMTP id s7mr53580lbh.63.1422347844752; Tue, 27 Jan 2015 00:37:24 -0800 (PST) Received: from mail-la0-f53.google.com (mail-la0-f53.google.com. [209.85.215.53]) by mx.google.com with ESMTPS id sk7si515408lbb.101.2015.01.27.00.37.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 00:37:24 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.53 as permitted sender) client-ip=209.85.215.53; Received: by mail-la0-f53.google.com with SMTP id gq15so11998533lab.12 for ; Tue, 27 Jan 2015 00:37:24 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr93354lal.29.1422347844663; Tue, 27 Jan 2015 00:37:24 -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 h5csp1025527lbj; Tue, 27 Jan 2015 00:37:23 -0800 (PST) X-Received: by 10.68.225.100 with SMTP id rj4mr218368pbc.80.1422347842787; Tue, 27 Jan 2015 00:37:22 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dj3si597279pbc.204.2015.01.27.00.37.21; Tue, 27 Jan 2015 00:37:22 -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 S1757901AbbA0IhQ (ORCPT + 11 others); Tue, 27 Jan 2015 03:37:16 -0500 Received: from mail-pa0-f52.google.com ([209.85.220.52]:38309 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757884AbbA0IhM (ORCPT ); Tue, 27 Jan 2015 03:37:12 -0500 Received: by mail-pa0-f52.google.com with SMTP id kx10so17140910pab.11 for ; Tue, 27 Jan 2015 00:37:11 -0800 (PST) X-Received: by 10.66.63.68 with SMTP id e4mr41720470pas.69.1422347831215; Tue, 27 Jan 2015 00:37:11 -0800 (PST) Received: from localhost ([122.178.198.250]) by mx.google.com with ESMTPSA id ws4sm809213pbc.53.2015.01.27.00.37.10 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 27 Jan 2015 00:37:10 -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 08/18] cpufreq: Add doc style comment about cpufreq_cpu_{get|put}() Date: Tue, 27 Jan 2015 14:06:14 +0530 Message-Id: <7b7de04921e8e2e57fbe2c8e75898c9d9284a269.1422346933.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.215.53 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 d9528046f651..21c8ef6073d7 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -167,6 +167,23 @@ struct cpufreq_policy *cpufreq_cpu_get_raw(unsigned int cpu) return NULL; } +/** + * 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; @@ -193,6 +210,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);