From patchwork Tue Jan 8 05:50:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rajagopal.venkat@linaro.org X-Patchwork-Id: 13899 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0D88C23E2A for ; Tue, 8 Jan 2013 05:54:36 +0000 (UTC) Received: from mail-vb0-f44.google.com (mail-vb0-f44.google.com [209.85.212.44]) by fiordland.canonical.com (Postfix) with ESMTP id B2A20A18D3B for ; Tue, 8 Jan 2013 05:54:35 +0000 (UTC) Received: by mail-vb0-f44.google.com with SMTP id fc26so31379vbb.3 for ; Mon, 07 Jan 2013 21:54:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=uKSyf+9QmdWu7pFlsJTmW7MV/qv/pXCjiU/17f5/UT0=; b=lnKsq0MBTf2+YTO8kCXihAOA6B5gQmg2eB5pJxhrmoGeglzO9/mzWzj9EpIavXg34S jbzV4hxzjWii9Xzo/s+JQeQ600HA2UpYjkiai/sr6FDb64Yl10eC5o88Grv2+lLCWgQ+ JL+N+tMkHQZ+MN+uaToGpGOHsba4ZtmKLP8b+6Y5S4i0R4xTRPfBXz0cUdwlriK9f3cg HWExCaAXa4cP6R75bF5waARwfzzgRv8Or7CISYrmjt02DVEkvvsGYLWMHXWZixaD+WZd DnUxh8JfvJQdhERGQbF3fwTp6E6ojhFDw4y9DUV5Y8wdqETH4KXR2yaNdlRc4tV69dUJ CmOg== X-Received: by 10.221.0.79 with SMTP id nl15mr85786215vcb.41.1357624475006; Mon, 07 Jan 2013 21:54:35 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp95415veb; Mon, 7 Jan 2013 21:54:34 -0800 (PST) X-Received: by 10.68.222.196 with SMTP id qo4mr194004486pbc.140.1357624473541; Mon, 07 Jan 2013 21:54:33 -0800 (PST) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id p7si61935716pav.50.2013.01.07.21.54.32 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 07 Jan 2013 21:54:33 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.220.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) smtp.mail=rajagopal.venkat@linaro.org Received: by mail-pa0-f50.google.com with SMTP id hz10so113945pad.37 for ; Mon, 07 Jan 2013 21:54:32 -0800 (PST) X-Received: by 10.68.211.42 with SMTP id mz10mr196136662pbc.100.1357624472862; Mon, 07 Jan 2013 21:54:32 -0800 (PST) Received: from localhost.localdomain ([115.242.216.217]) by mx.google.com with ESMTPS id ty4sm38989248pbc.57.2013.01.07.21.54.27 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 07 Jan 2013 21:54:32 -0800 (PST) From: Rajagopal Venkat To: myungjoo.ham@samsung.com, kyungmin.park@samsung.com, mturquette@linaro.org, rjw@sisk.pl Cc: patches@linaro.org, linaro-dev@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Rajagopal Venkat Subject: [PATCH 1/3] PM / devfreq: set min/max freq limit from freq table Date: Tue, 8 Jan 2013 11:20:37 +0530 Message-Id: <1357624239-13938-1-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQlb+kQ24B93tJK78oZW4QYDY5+zXM/uUMogTICLmW8IiEqQymz9HirJWQIU7CSBMIDAgUpf Set devfreq device min and max frequency limits when device is added to devfreq, provided frequency table is supplied. This helps governors to suggest target frequency with in limits. Signed-off-by: Rajagopal Venkat --- drivers/devfreq/devfreq.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index a8f0173..5782c9b 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -69,6 +69,29 @@ static struct devfreq *find_device_devfreq(struct device *dev) } /** + * devfreq_set_freq_limits() - Set min and max frequency from freq_table + * @devfreq: the devfreq instance + */ +static void devfreq_set_freq_limits(struct devfreq *devfreq) +{ + int idx; + unsigned long min = ~0, max = 0; + + if (!devfreq->profile->freq_table) + return; + + for (idx = 0; idx < devfreq->profile->max_state; idx++) { + if (min > devfreq->profile->freq_table[idx]) + min = devfreq->profile->freq_table[idx]; + if (max < devfreq->profile->freq_table[idx]) + max = devfreq->profile->freq_table[idx]; + } + + devfreq->min_freq = min; + devfreq->max_freq = max; +} + +/** * devfreq_get_freq_level() - Lookup freq_table for the frequency * @devfreq: the devfreq instance * @freq: the target frequency @@ -476,6 +499,7 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->profile->max_state, GFP_KERNEL); devfreq->last_stat_updated = jiffies; + devfreq_set_freq_limits(devfreq); dev_set_name(&devfreq->dev, dev_name(dev)); err = device_register(&devfreq->dev);