Skip to content

Commit 9509376

Browse files
bjdooks-ctbroonie
authored andcommitted
regmap: use less #ifdef for LOG_DEVICE
Move the checking of the LOG_DEVICE into a function to reduce the number of #ifdefs and ensure more of the code gets compiled/checked, and make it easier to change this for internal debugging purposes (such as checking >1 device). Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 5b394b2 commit 9509376

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎drivers/base/regmap/regmap.c‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@
3535
*/
3636
#undef LOG_DEVICE
3737

38+
#ifdef LOG_DEVICE
39+
static inline bool regmap_should_log(struct regmap *map)
40+
{
41+
return (map->dev && strcmp(dev_name(map->dev), LOG_DEVICE) == 0);
42+
}
43+
#else
44+
static inline bool regmap_should_log(struct regmap *map) { return false; }
45+
#endif
46+
47+
3848
static int _regmap_update_bits(struct regmap *map, unsigned int reg,
3949
unsigned int mask, unsigned int val,
4050
bool *change, bool force_write);
@@ -1755,10 +1765,8 @@ int _regmap_write(struct regmap *map, unsigned int reg,
17551765
}
17561766
}
17571767

1758-
#ifdef LOG_DEVICE
1759-
if (map->dev && strcmp(dev_name(map->dev), LOG_DEVICE) == 0)
1768+
if (regmap_should_log(map))
17601769
dev_info(map->dev, "%x <= %x\n", reg, val);
1761-
#endif
17621770

17631771
trace_regmap_reg_write(map, reg, val);
17641772

@@ -2450,10 +2458,8 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
24502458

24512459
ret = map->reg_read(context, reg, val);
24522460
if (ret == 0) {
2453-
#ifdef LOG_DEVICE
2454-
if (map->dev && strcmp(dev_name(map->dev), LOG_DEVICE) == 0)
2461+
if (regmap_should_log(map))
24552462
dev_info(map->dev, "%x => %x\n", reg, *val);
2456-
#endif
24572463

24582464
trace_regmap_reg_read(map, reg, *val);
24592465

0 commit comments

Comments
 (0)