From: Rajagopal Venkat <rajagopal.venkat@linaro.org>
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 <rajagopal.venkat@linaro.org>
Subject: [PATCH 1/3] PM / devfreq: set min/max freq limit from freq table
Date: Tue, 8 Jan 2013 11:20:37 +0530 [thread overview]
Message-ID: <1357624239-13938-1-git-send-email-rajagopal.venkat@linaro.org> (raw)
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 <rajagopal.venkat@linaro.org>
---
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);
--
1.7.10.4
next reply other threads:[~2013-01-08 5:54 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-08 5:50 Rajagopal Venkat [this message]
[not found] ` <1357624239-13938-1-git-send-email-rajagopal.venkat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-01-08 5:50 ` [PATCH 2/3] PM / devfreq: fix stats start time stamp Rajagopal Venkat
2013-01-14 14:42 ` MyungJoo Ham
2013-01-15 11:40 ` Rajagopal Venkat
2013-01-08 5:50 ` [PATCH 3/3] PM / devfreq: account suspend/resume for stats Rajagopal Venkat
[not found] ` <1357624239-13938-3-git-send-email-rajagopal.venkat-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-01-14 14:48 ` MyungJoo Ham
2013-01-15 11:46 ` Rajagopal Venkat
2013-02-04 8:34 ` Rajagopal Venkat
2013-02-05 6:29 ` MyungJoo Ham
2013-01-14 14:36 ` [PATCH 1/3] PM / devfreq: set min/max freq limit from freq table MyungJoo Ham
[not found] ` <CAJ0PZbTAOdQrUjefOpc2MDam1hHLjSEDLHw3VrP+9=OAbgQ8ug-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-01-15 11:21 ` Rajagopal Venkat
2013-02-04 8:33 ` Rajagopal Venkat
2013-02-05 6:51 ` MyungJoo Ham
2013-02-05 10:42 ` Rajagopal Venkat
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=1357624239-13938-1-git-send-email-rajagopal.venkat@linaro.org \
--to=rajagopal.venkat@linaro.org \
--cc=kyungmin.park@samsung.com \
--cc=linaro-dev@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mturquette@linaro.org \
--cc=myungjoo.ham@samsung.com \
--cc=patches@linaro.org \
--cc=rjw@sisk.pl \
/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).