diff options
author | Axel Lin <axel.lin@ingics.com> | 2013-08-09 03:29:27 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-08-09 06:45:02 -0400 |
commit | d295f7670127eb241d81e96e003b380c77c2b254 (patch) | |
tree | 84f185451441d18e1f3e676bdb1edbc4b96cdc98 | |
parent | c4a54b8d54218a75b94ab9947449e688869df00d (diff) |
regulator: core: Move list_voltage_{linear,linear_range,table} to helpers.c
Move regulator_list_voltage_{linear,linear_range,table} helper functions to
helpers.c.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/regulator/core.c | 86 | ||||
-rw-r--r-- | drivers/regulator/helpers.c | 86 |
2 files changed, 86 insertions, 86 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 01d9675b0e83..c111a2c19119 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1989,92 +1989,6 @@ int regulator_count_voltages(struct regulator *regulator) | |||
1989 | EXPORT_SYMBOL_GPL(regulator_count_voltages); | 1989 | EXPORT_SYMBOL_GPL(regulator_count_voltages); |
1990 | 1990 | ||
1991 | /** | 1991 | /** |
1992 | * regulator_list_voltage_linear - List voltages with simple calculation | ||
1993 | * | ||
1994 | * @rdev: Regulator device | ||
1995 | * @selector: Selector to convert into a voltage | ||
1996 | * | ||
1997 | * Regulators with a simple linear mapping between voltages and | ||
1998 | * selectors can set min_uV and uV_step in the regulator descriptor | ||
1999 | * and then use this function as their list_voltage() operation, | ||
2000 | */ | ||
2001 | int regulator_list_voltage_linear(struct regulator_dev *rdev, | ||
2002 | unsigned int selector) | ||
2003 | { | ||
2004 | if (selector >= rdev->desc->n_voltages) | ||
2005 | return -EINVAL; | ||
2006 | if (selector < rdev->desc->linear_min_sel) | ||
2007 | return 0; | ||
2008 | |||
2009 | selector -= rdev->desc->linear_min_sel; | ||
2010 | |||
2011 | return rdev->desc->min_uV + (rdev->desc->uV_step * selector); | ||
2012 | } | ||
2013 | EXPORT_SYMBOL_GPL(regulator_list_voltage_linear); | ||
2014 | |||
2015 | /** | ||
2016 | * regulator_list_voltage_linear_range - List voltages for linear ranges | ||
2017 | * | ||
2018 | * @rdev: Regulator device | ||
2019 | * @selector: Selector to convert into a voltage | ||
2020 | * | ||
2021 | * Regulators with a series of simple linear mappings between voltages | ||
2022 | * and selectors can set linear_ranges in the regulator descriptor and | ||
2023 | * then use this function as their list_voltage() operation, | ||
2024 | */ | ||
2025 | int regulator_list_voltage_linear_range(struct regulator_dev *rdev, | ||
2026 | unsigned int selector) | ||
2027 | { | ||
2028 | const struct regulator_linear_range *range; | ||
2029 | int i; | ||
2030 | |||
2031 | if (!rdev->desc->n_linear_ranges) { | ||
2032 | BUG_ON(!rdev->desc->n_linear_ranges); | ||
2033 | return -EINVAL; | ||
2034 | } | ||
2035 | |||
2036 | for (i = 0; i < rdev->desc->n_linear_ranges; i++) { | ||
2037 | range = &rdev->desc->linear_ranges[i]; | ||
2038 | |||
2039 | if (!(selector >= range->min_sel && | ||
2040 | selector <= range->max_sel)) | ||
2041 | continue; | ||
2042 | |||
2043 | selector -= range->min_sel; | ||
2044 | |||
2045 | return range->min_uV + (range->uV_step * selector); | ||
2046 | } | ||
2047 | |||
2048 | return -EINVAL; | ||
2049 | } | ||
2050 | EXPORT_SYMBOL_GPL(regulator_list_voltage_linear_range); | ||
2051 | |||
2052 | /** | ||
2053 | * regulator_list_voltage_table - List voltages with table based mapping | ||
2054 | * | ||
2055 | * @rdev: Regulator device | ||
2056 | * @selector: Selector to convert into a voltage | ||
2057 | * | ||
2058 | * Regulators with table based mapping between voltages and | ||
2059 | * selectors can set volt_table in the regulator descriptor | ||
2060 | * and then use this function as their list_voltage() operation. | ||
2061 | */ | ||
2062 | int regulator_list_voltage_table(struct regulator_dev *rdev, | ||
2063 | unsigned int selector) | ||
2064 | { | ||
2065 | if (!rdev->desc->volt_table) { | ||
2066 | BUG_ON(!rdev->desc->volt_table); | ||
2067 | return -EINVAL; | ||
2068 | } | ||
2069 | |||
2070 | if (selector >= rdev->desc->n_voltages) | ||
2071 | return -EINVAL; | ||
2072 | |||
2073 | return rdev->desc->volt_table[selector]; | ||
2074 | } | ||
2075 | EXPORT_SYMBOL_GPL(regulator_list_voltage_table); | ||
2076 | |||
2077 | /** | ||
2078 | * regulator_list_voltage - enumerate supported voltages | 1992 | * regulator_list_voltage - enumerate supported voltages |
2079 | * @regulator: regulator source | 1993 | * @regulator: regulator source |
2080 | * @selector: identify voltage to list | 1994 | * @selector: identify voltage to list |
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c index d13cf8f7fb90..6e30df14714b 100644 --- a/drivers/regulator/helpers.c +++ b/drivers/regulator/helpers.c | |||
@@ -320,6 +320,92 @@ int regulator_map_voltage_linear_range(struct regulator_dev *rdev, | |||
320 | EXPORT_SYMBOL_GPL(regulator_map_voltage_linear_range); | 320 | EXPORT_SYMBOL_GPL(regulator_map_voltage_linear_range); |
321 | 321 | ||
322 | /** | 322 | /** |
323 | * regulator_list_voltage_linear - List voltages with simple calculation | ||
324 | * | ||
325 | * @rdev: Regulator device | ||
326 | * @selector: Selector to convert into a voltage | ||
327 | * | ||
328 | * Regulators with a simple linear mapping between voltages and | ||
329 | * selectors can set min_uV and uV_step in the regulator descriptor | ||
330 | * and then use this function as their list_voltage() operation, | ||
331 | */ | ||
332 | int regulator_list_voltage_linear(struct regulator_dev *rdev, | ||
333 | unsigned int selector) | ||
334 | { | ||
335 | if (selector >= rdev->desc->n_voltages) | ||
336 | return -EINVAL; | ||
337 | if (selector < rdev->desc->linear_min_sel) | ||
338 | return 0; | ||
339 | |||
340 | selector -= rdev->desc->linear_min_sel; | ||
341 | |||
342 | return rdev->desc->min_uV + (rdev->desc->uV_step * selector); | ||
343 | } | ||
344 | EXPORT_SYMBOL_GPL(regulator_list_voltage_linear); | ||
345 | |||
346 | /** | ||
347 | * regulator_list_voltage_linear_range - List voltages for linear ranges | ||
348 | * | ||
349 | * @rdev: Regulator device | ||
350 | * @selector: Selector to convert into a voltage | ||
351 | * | ||
352 | * Regulators with a series of simple linear mappings between voltages | ||
353 | * and selectors can set linear_ranges in the regulator descriptor and | ||
354 | * then use this function as their list_voltage() operation, | ||
355 | */ | ||
356 | int regulator_list_voltage_linear_range(struct regulator_dev *rdev, | ||
357 | unsigned int selector) | ||
358 | { | ||
359 | const struct regulator_linear_range *range; | ||
360 | int i; | ||
361 | |||
362 | if (!rdev->desc->n_linear_ranges) { | ||
363 | BUG_ON(!rdev->desc->n_linear_ranges); | ||
364 | return -EINVAL; | ||
365 | } | ||
366 | |||
367 | for (i = 0; i < rdev->desc->n_linear_ranges; i++) { | ||
368 | range = &rdev->desc->linear_ranges[i]; | ||
369 | |||
370 | if (!(selector >= range->min_sel && | ||
371 | selector <= range->max_sel)) | ||
372 | continue; | ||
373 | |||
374 | selector -= range->min_sel; | ||
375 | |||
376 | return range->min_uV + (range->uV_step * selector); | ||
377 | } | ||
378 | |||
379 | return -EINVAL; | ||
380 | } | ||
381 | EXPORT_SYMBOL_GPL(regulator_list_voltage_linear_range); | ||
382 | |||
383 | /** | ||
384 | * regulator_list_voltage_table - List voltages with table based mapping | ||
385 | * | ||
386 | * @rdev: Regulator device | ||
387 | * @selector: Selector to convert into a voltage | ||
388 | * | ||
389 | * Regulators with table based mapping between voltages and | ||
390 | * selectors can set volt_table in the regulator descriptor | ||
391 | * and then use this function as their list_voltage() operation. | ||
392 | */ | ||
393 | int regulator_list_voltage_table(struct regulator_dev *rdev, | ||
394 | unsigned int selector) | ||
395 | { | ||
396 | if (!rdev->desc->volt_table) { | ||
397 | BUG_ON(!rdev->desc->volt_table); | ||
398 | return -EINVAL; | ||
399 | } | ||
400 | |||
401 | if (selector >= rdev->desc->n_voltages) | ||
402 | return -EINVAL; | ||
403 | |||
404 | return rdev->desc->volt_table[selector]; | ||
405 | } | ||
406 | EXPORT_SYMBOL_GPL(regulator_list_voltage_table); | ||
407 | |||
408 | /** | ||
323 | * regulator_set_bypass_regmap - Default set_bypass() using regmap | 409 | * regulator_set_bypass_regmap - Default set_bypass() using regmap |
324 | * | 410 | * |
325 | * @rdev: device to operate on. | 411 | * @rdev: device to operate on. |