Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f517b3a4 authored by Rajagopal Venkat's avatar Rajagopal Venkat Committed by Rohit Gupta
Browse files

FROMLIST: PM / devfreq: set min/max freq limit from freq table



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.

Change-Id: Iab24aef59bfeffcfb3c3118c12ba58e25cd9d479
Signed-off-by: default avatarRajagopal Venkat <rajagopal.venkat@linaro.org>
Patch-mainline: linux-pm @ 01/08/13, 05:50
Signed-off-by: default avatarVladimir Razgulin <vrazguli@codeaurora.org>
parent 0a4d1ddb
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -69,6 +69,29 @@ static struct devfreq *find_device_devfreq(struct device *dev)
	return ERR_PTR(-ENODEV);
}

/**
 * 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
@@ -569,6 +592,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
		devfreq_set_freq_table(devfreq);
		mutex_lock(&devfreq->lock);
	}
	devfreq_set_freq_limits(devfreq);

	dev_set_name(&devfreq->dev, "%s", dev_name(dev));
	err = device_register(&devfreq->dev);