mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 21:59:12 -04:00
regulator: core: add support to log enabled regulators during suspend
Add support to print a list of enabled regulators in the kernel log. This is useful when debugging low power modes during suspend. Change-Id: I78acb1285caeaeccd30efc16bb5bc001f66bdf33 Signed-off-by: David Collins <collinsd@codeaurora.org>
This commit is contained in:
parent
491c9e1721
commit
43d8c68cf4
2 changed files with 80 additions and 0 deletions
|
|
@ -54,6 +54,7 @@ static LIST_HEAD(regulator_ena_gpio_list);
|
|||
static LIST_HEAD(regulator_supply_alias_list);
|
||||
static LIST_HEAD(regulator_coupler_list);
|
||||
static bool has_full_constraints;
|
||||
static bool debug_suspend;
|
||||
|
||||
static struct dentry *debugfs_root;
|
||||
|
||||
|
|
@ -6024,6 +6025,74 @@ static int regulator_summary_show(struct seq_file *s, void *data)
|
|||
DEFINE_SHOW_ATTRIBUTE(regulator_summary);
|
||||
#endif /* CONFIG_DEBUG_FS */
|
||||
|
||||
#ifdef CONFIG_REGULATOR_QTI_DEBUG
|
||||
static int _regulator_debug_print_enabled(struct device *dev, void *data)
|
||||
{
|
||||
struct regulator_dev *rdev = dev_to_rdev(dev);
|
||||
struct regulator *reg;
|
||||
const char *supply_name;
|
||||
int mode = -EPERM;
|
||||
int uV = -EPERM;
|
||||
|
||||
if (_regulator_is_enabled(rdev) <= 0)
|
||||
return 0;
|
||||
|
||||
uV = regulator_get_voltage_rdev(rdev);
|
||||
|
||||
if (rdev->desc->ops->get_mode)
|
||||
mode = rdev->desc->ops->get_mode(rdev);
|
||||
|
||||
if (uV != -EPERM && mode != -EPERM)
|
||||
pr_info("%s[%u] %d uV, mode=%d\n",
|
||||
rdev_get_name(rdev), rdev->use_count, uV, mode);
|
||||
else if (uV != -EPERM)
|
||||
pr_info("%s[%u] %d uV\n",
|
||||
rdev_get_name(rdev), rdev->use_count, uV);
|
||||
else if (mode != -EPERM)
|
||||
pr_info("%s[%u], mode=%d\n",
|
||||
rdev_get_name(rdev), rdev->use_count, mode);
|
||||
else
|
||||
pr_info("%s[%u]\n", rdev_get_name(rdev), rdev->use_count);
|
||||
|
||||
/* Print a header if there are consumers. */
|
||||
if (rdev->open_count)
|
||||
pr_info(" %-32s EN Min_uV Max_uV load_uA\n",
|
||||
"Device-Supply");
|
||||
|
||||
list_for_each_entry(reg, &rdev->consumer_list, list) {
|
||||
if (reg->supply_name)
|
||||
supply_name = reg->supply_name;
|
||||
else
|
||||
supply_name = "(null)-(null)";
|
||||
|
||||
pr_info(" %-32s %d %8d %8d %8d\n", supply_name,
|
||||
reg->enable_count,
|
||||
reg->voltage[PM_SUSPEND_ON].min_uV,
|
||||
reg->voltage[PM_SUSPEND_ON].max_uV,
|
||||
reg->uA_load);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* regulator_debug_print_enabled - log enabled regulators
|
||||
*
|
||||
* Print the names of all enabled regulators and their consumers to the kernel
|
||||
* log if debug_suspend is set from debugfs.
|
||||
*/
|
||||
void regulator_debug_print_enabled(void)
|
||||
{
|
||||
if (likely(!debug_suspend))
|
||||
return;
|
||||
|
||||
pr_info("Enabled regulators:\n");
|
||||
class_for_each_device(®ulator_class, NULL, NULL,
|
||||
_regulator_debug_print_enabled);
|
||||
}
|
||||
EXPORT_SYMBOL(regulator_debug_print_enabled);
|
||||
#endif /* CONFIG_REGULATOR_QTI_DEBUG */
|
||||
|
||||
static int __init regulator_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
|
@ -6040,6 +6109,9 @@ static int __init regulator_init(void)
|
|||
|
||||
debugfs_create_file("regulator_summary", 0444, debugfs_root,
|
||||
NULL, ®ulator_summary_fops);
|
||||
|
||||
debugfs_create_bool("debug_suspend", 0644, debugfs_root,
|
||||
&debug_suspend);
|
||||
#endif
|
||||
regulator_dummy_init();
|
||||
|
||||
|
|
|
|||
|
|
@ -253,6 +253,14 @@ static inline void regulator_has_full_constraints(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_REGULATOR_QTI_DEBUG
|
||||
void regulator_debug_print_enabled(void);
|
||||
#else
|
||||
static inline void regulator_debug_print_enabled(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int regulator_suspend_prepare(suspend_state_t state)
|
||||
{
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue