regulator: core: Add option to suppress regulator info messages

Each call to regulator_register() results in a line being written
into the kmsg log.  regulator_init_complete() also prints a line for
each unused regulator which is automatically disabled.

Add a function named regulator_suppress_info_printing() which can
be called to disable these print statements.

Change-Id: Ic4c723b7d02a494b4e261858d699d9625da715ea
Signed-off-by: David Collins <collinsd@codeaurora.org>
This commit is contained in:
David Collins
2010-09-27 12:39:39 -07:00
committed by Stephen Boyd
parent 7066219187
commit 3cecc29edd
2 changed files with 31 additions and 4 deletions

View File

@@ -51,6 +51,7 @@ static LIST_HEAD(regulator_list);
static LIST_HEAD(regulator_map_list);
static bool has_full_constraints;
static bool board_wants_dummy_regulator;
static int suppress_info_printing;
static struct dentry *debugfs_root;
@@ -959,7 +960,8 @@ static int set_machine_constraints(struct regulator_dev *rdev,
}
}
print_constraints(rdev);
if (!suppress_info_printing)
print_constraints(rdev);
return 0;
out:
kfree(rdev->constraints);
@@ -981,7 +983,8 @@ static int set_supply(struct regulator_dev *rdev,
{
int err;
rdev_info(rdev, "supplied by %s\n", rdev_get_name(supply_rdev));
if (!suppress_info_printing)
rdev_info(rdev, "supplied by %s\n", rdev_get_name(supply_rdev));
rdev->supply = create_regulator(supply_rdev, &rdev->dev, "SUPPLY");
if (rdev->supply == NULL) {
@@ -3117,6 +3120,22 @@ void regulator_use_dummy_regulator(void)
}
EXPORT_SYMBOL_GPL(regulator_use_dummy_regulator);
/**
* regulator_suppress_info_printing - disable printing of info messages
*
* The regulator framework calls print_constraints() when a regulator is
* registered. It also prints a disable message for each unused regulator in
* regulator_init_complete().
*
* Calling this function ensures that such messages do not end up in the
* log.
*/
void regulator_suppress_info_printing(void)
{
suppress_info_printing = 1;
}
EXPORT_SYMBOL_GPL(regulator_suppress_info_printing);
/**
* rdev_get_drvdata - get rdev regulator driver data
* @rdev: regulator
@@ -3273,7 +3292,8 @@ static int __init regulator_init_complete(void)
if (has_full_constraints) {
/* We log since this may kill the system if it
* goes wrong. */
rdev_info(rdev, "disabling\n");
if (!suppress_info_printing)
rdev_info(rdev, "disabling\n");
ret = ops->disable(rdev);
if (ret != 0) {
rdev_err(rdev, "couldn't disable: %d\n", ret);
@@ -3284,7 +3304,9 @@ static int __init regulator_init_complete(void)
* so warn even if we aren't going to do
* anything here.
*/
rdev_warn(rdev, "incomplete constraints, leaving on\n");
if (!suppress_info_printing)
rdev_warn(rdev, "incomplete constraints, "
"leaving on\n");
}
unlock:

View File

@@ -188,6 +188,7 @@ int regulator_suspend_finish(void);
#ifdef CONFIG_REGULATOR
void regulator_has_full_constraints(void);
void regulator_use_dummy_regulator(void);
void regulator_suppress_info_printing(void);
#else
static inline void regulator_has_full_constraints(void)
{
@@ -196,6 +197,10 @@ static inline void regulator_has_full_constraints(void)
static inline void regulator_use_dummy_regulator(void)
{
}
static inline void regulator_suppress_info_printing(void)
{
}
#endif
#endif