Skip to content

Commit 157d223

Browse files
M-Vaittinenbroonie
authored andcommitted
regulator: move rdev_print helpers to internal.h
The rdev print helpers are a nice way to print messages related to a specific regulator device. Move them from core.c to internal.h As the rdev print helpers use rdev_get_name() export it from core.c. Also move the declaration from coupler.h to driver.h because the rdev name is not just a coupled regulator property. I guess the main audience for rdev_get_name() will be the regulator core and drivers. Signed-off-by: Matti Vaittinen <[email protected]> Link: https://lore.kernel.org/r/dc7fd70dc31de4d0e820b7646bb78eeb04f80735.1622628333.git.matti.vaittinen@fi.rohmeurope.com Signed-off-by: Mark Brown <[email protected]>
1 parent e6c3092 commit 157d223

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

drivers/regulator/core.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@
3333
#include "dummy.h"
3434
#include "internal.h"
3535

36-
#define rdev_crit(rdev, fmt, ...) \
37-
pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
38-
#define rdev_err(rdev, fmt, ...) \
39-
pr_err("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
40-
#define rdev_warn(rdev, fmt, ...) \
41-
pr_warn("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
42-
#define rdev_info(rdev, fmt, ...) \
43-
pr_info("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
44-
#define rdev_dbg(rdev, fmt, ...) \
45-
pr_debug("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
46-
4736
static DEFINE_WW_CLASS(regulator_ww_class);
4837
static DEFINE_MUTEX(regulator_nesting_mutex);
4938
static DEFINE_MUTEX(regulator_list_mutex);
@@ -117,6 +106,7 @@ const char *rdev_get_name(struct regulator_dev *rdev)
117106
else
118107
return "";
119108
}
109+
EXPORT_SYMBOL_GPL(rdev_get_name);
120110

121111
static bool have_full_constraints(void)
122112
{

drivers/regulator/internal.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515

1616
#define REGULATOR_STATES_NUM (PM_SUSPEND_MAX + 1)
1717

18+
#define rdev_crit(rdev, fmt, ...) \
19+
pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
20+
#define rdev_err(rdev, fmt, ...) \
21+
pr_err("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
22+
#define rdev_warn(rdev, fmt, ...) \
23+
pr_warn("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
24+
#define rdev_info(rdev, fmt, ...) \
25+
pr_info("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
26+
#define rdev_dbg(rdev, fmt, ...) \
27+
pr_debug("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
28+
1829
struct regulator_voltage {
1930
int min_uV;
2031
int max_uV;

include/linux/regulator/coupler.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ struct regulator_coupler {
5252

5353
#ifdef CONFIG_REGULATOR
5454
int regulator_coupler_register(struct regulator_coupler *coupler);
55-
const char *rdev_get_name(struct regulator_dev *rdev);
5655
int regulator_check_consumers(struct regulator_dev *rdev,
5756
int *min_uV, int *max_uV,
5857
suspend_state_t state);
@@ -69,10 +68,6 @@ static inline int regulator_coupler_register(struct regulator_coupler *coupler)
6968
{
7069
return 0;
7170
}
72-
static inline const char *rdev_get_name(struct regulator_dev *rdev)
73-
{
74-
return NULL;
75-
}
7671
static inline int regulator_check_consumers(struct regulator_dev *rdev,
7772
int *min_uV, int *max_uV,
7873
suspend_state_t state)

include/linux/regulator/driver.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,4 +550,14 @@ int regulator_desc_list_voltage_linear_range(const struct regulator_desc *desc,
550550

551551
int regulator_desc_list_voltage_linear(const struct regulator_desc *desc,
552552
unsigned int selector);
553+
554+
#ifdef CONFIG_REGULATOR
555+
const char *rdev_get_name(struct regulator_dev *rdev);
556+
#else
557+
static inline const char *rdev_get_name(struct regulator_dev *rdev)
558+
{
559+
return NULL;
560+
}
561+
#endif
562+
553563
#endif

0 commit comments

Comments
 (0)