Skip to content

Commit b059b7e

Browse files
Marek Vasutbroonie
authored andcommitted
regulator: core: Add regulator_is_equal() helper
Add regulator_is_equal() helper to compare whether two regulators are the same. This is useful for checking whether two separate regulators in a driver are actually the same supply. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Fabio Estevam <festevam@gmail.com> Cc: Igor Opaniuk <igor.opaniuk@toradex.com> Cc: Liam Girdwood <lgirdwood@gmail.com> Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com> Cc: Mark Brown <broonie@kernel.org> Cc: Oleksandr Suvorov <oleksandr.suvorov@toradex.com> Link: https://lore.kernel.org/r/20191220164450.1395038-1-marex@denx.de Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent e42617b commit b059b7e

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

‎drivers/regulator/helpers.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include <linux/regulator/driver.h>
1414
#include <linux/module.h>
1515

16+
#include "internal.h"
17+
1618
/**
1719
* regulator_is_enabled_regmap - standard is_enabled() for regmap users
1820
*
@@ -881,3 +883,15 @@ void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
881883
consumers[i].supply = supply_names[i];
882884
}
883885
EXPORT_SYMBOL_GPL(regulator_bulk_set_supply_names);
886+
887+
/**
888+
* regulator_is_equal - test whether two regulators are the same
889+
*
890+
* @reg1: first regulator to operate on
891+
* @reg2: second regulator to operate on
892+
*/
893+
bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2)
894+
{
895+
return reg1->rdev == reg2->rdev;
896+
}
897+
EXPORT_SYMBOL_GPL(regulator_is_equal);

‎include/linux/regulator/consumer.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ void regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
287287
const char *const *supply_names,
288288
unsigned int num_supplies);
289289

290+
bool regulator_is_equal(struct regulator *reg1, struct regulator *reg2);
291+
290292
#else
291293

292294
/*
@@ -593,6 +595,11 @@ regulator_bulk_set_supply_names(struct regulator_bulk_data *consumers,
593595
{
594596
}
595597

598+
static inline bool
599+
regulator_is_equal(struct regulator *reg1, struct regulator *reg2);
600+
{
601+
return false;
602+
}
596603
#endif
597604

598605
static inline int regulator_set_voltage_triplet(struct regulator *regulator,

0 commit comments

Comments
 (0)