All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] regulator: core: Add stubs for driver API
@ 2021-06-19 12:40 Dmitry Osipenko
  2021-06-21 11:46 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Osipenko @ 2021-06-19 12:40 UTC (permalink / raw)
  To: Thierry Reding, Mark Brown; +Cc: linux-kernel

Add stubs for regulator driver API in order to fix compile-test build
errors of kernel configurations where regulator framework is disabled.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 include/linux/regulator/driver.h | 237 +++++++++++++++++++++++++++++++
 1 file changed, 237 insertions(+)

diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 35e5a611db81..1dbc7fc22090 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -479,6 +479,8 @@ struct regulator_dev {
 	ktime_t last_off;
 };
 
+#if defined(CONFIG_REGULATOR)
+
 struct regulator_dev *
 regulator_register(const struct regulator_desc *regulator_desc,
 		   const struct regulator_config *config);
@@ -551,4 +553,239 @@ int regulator_desc_list_voltage_linear_range(const struct regulator_desc *desc,
 
 int regulator_desc_list_voltage_linear(const struct regulator_desc *desc,
 				       unsigned int selector);
+
+#else
+
+static inline struct regulator_dev *
+regulator_register(const struct regulator_desc *regulator_desc,
+		   const struct regulator_config *config)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline struct regulator_dev *
+devm_regulator_register(struct device *dev,
+			const struct regulator_desc *regulator_desc,
+			const struct regulator_config *config)
+{
+	return ERR_PTR(-ENODEV);
+}
+
+static inline void regulator_unregister(struct regulator_dev *rdev)
+{
+}
+
+static inline void
+devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev)
+{
+}
+
+static inline int regulator_notifier_call_chain(struct regulator_dev *rdev,
+						unsigned long event, void *data)
+{
+	return 0;
+}
+
+static inline void *rdev_get_drvdata(struct regulator_dev *rdev)
+{
+	return NULL;
+}
+
+static inline struct device *rdev_get_dev(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline struct regmap *rdev_get_regmap(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline int rdev_get_id(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline int regulator_mode_to_status(unsigned int mode)
+{
+	return 0;
+}
+
+static inline int regulator_list_voltage_linear(struct regulator_dev *rdev,
+						unsigned int selector)
+{
+	return 0;
+}
+
+static inline int
+regulator_list_voltage_pickable_linear_range(struct regulator_dev *rdev,
+					     unsigned int selector)
+{
+	return 0;
+}
+
+static inline int
+regulator_list_voltage_linear_range(struct regulator_dev *rdev,
+				    unsigned int selector)
+{
+	return 0;
+}
+
+static inline int regulator_list_voltage_table(struct regulator_dev *rdev,
+					       unsigned int selector)
+{
+	return 0;
+}
+
+static inline int regulator_map_voltage_linear(struct regulator_dev *rdev,
+					       int min_uV, int max_uV)
+{
+	return 0;
+}
+
+static inline int
+regulator_map_voltage_pickable_linear_range(struct regulator_dev *rdev,
+					    int min_uV, int max_uV)
+{
+	return 0;
+}
+
+static inline int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
+						     int min_uV, int max_uV)
+{
+	return 0;
+}
+
+static inline int regulator_map_voltage_iterate(struct regulator_dev *rdev,
+						int min_uV, int max_uV)
+{
+	return 0;
+}
+
+static inline int regulator_map_voltage_ascend(struct regulator_dev *rdev,
+					       int min_uV, int max_uV)
+{
+	return 0;
+}
+
+static inline int
+regulator_get_voltage_sel_pickable_regmap(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline int
+regulator_set_voltage_sel_pickable_regmap(struct regulator_dev *rdev,
+					  unsigned int sel)
+{
+	return 0;
+}
+
+static inline int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev,
+						   unsigned sel)
+{
+	return 0;
+}
+
+static inline int regulator_is_enabled_regmap(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline int regulator_enable_regmap(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline int regulator_disable_regmap(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline int
+regulator_set_voltage_time_sel(struct regulator_dev *rdev,
+			       unsigned int old_selector,
+			       unsigned int new_selector)
+{
+	return 0;
+}
+
+static inline int regulator_set_bypass_regmap(struct regulator_dev *rdev,
+					      bool enable)
+{
+	return 0;
+}
+
+static inline int regulator_get_bypass_regmap(struct regulator_dev *rdev,
+					      bool *enable)
+{
+	return 0;
+}
+
+static inline int regulator_set_soft_start_regmap(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline int regulator_set_pull_down_regmap(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline int
+regulator_set_active_discharge_regmap(struct regulator_dev *rdev,
+				      bool enable)
+{
+	return 0;
+}
+
+static inline int
+regulator_set_current_limit_regmap(struct regulator_dev *rdev,
+				   int min_uA, int max_uA)
+{
+	return 0;
+}
+
+static inline int regulator_get_current_limit_regmap(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline void *
+regulator_get_init_drvdata(struct regulator_init_data *reg_init_data)
+{
+	return NULL;
+}
+
+static inline int regulator_set_ramp_delay_regmap(struct regulator_dev *rdev,
+						  int ramp_delay)
+{
+	return 0;
+}
+
+static inline int regulator_sync_voltage_rdev(struct regulator_dev *rdev)
+{
+	return 0;
+}
+
+static inline int
+regulator_desc_list_voltage_linear_range(const struct regulator_desc *desc,
+					 unsigned int selector)
+{
+	return 0;
+}
+
+static inline int
+regulator_desc_list_voltage_linear(const struct regulator_desc *desc,
+				   unsigned int selector)
+{
+	return 0;
+}
+#endif
+
 #endif
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] regulator: core: Add stubs for driver API
  2021-06-19 12:40 [PATCH v1] regulator: core: Add stubs for driver API Dmitry Osipenko
@ 2021-06-21 11:46 ` Mark Brown
  2021-06-21 12:04   ` Dmitry Osipenko
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2021-06-21 11:46 UTC (permalink / raw)
  To: Dmitry Osipenko; +Cc: Thierry Reding, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

On Sat, Jun 19, 2021 at 03:40:52PM +0300, Dmitry Osipenko wrote:

> +static inline struct regulator_dev *
> +regulator_register(const struct regulator_desc *regulator_desc,
> +		   const struct regulator_config *config)

Why would something be registering a regulator device without a
dependency on the regulator API?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] regulator: core: Add stubs for driver API
  2021-06-21 11:46 ` Mark Brown
@ 2021-06-21 12:04   ` Dmitry Osipenko
  2021-06-21 12:34     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Osipenko @ 2021-06-21 12:04 UTC (permalink / raw)
  To: Mark Brown; +Cc: Thierry Reding, linux-kernel

21.06.2021 14:46, Mark Brown пишет:
> On Sat, Jun 19, 2021 at 03:40:52PM +0300, Dmitry Osipenko wrote:
> 
>> +static inline struct regulator_dev *
>> +regulator_register(const struct regulator_desc *regulator_desc,
>> +		   const struct regulator_config *config)
> 
> Why would something be registering a regulator device without a
> dependency on the regulator API?
> 

For example if regulator device registration is optional in the code. We
don't have such cases in the kernel today, but I decided that it will be
cleaner to add stubs for the whole API.

The point of these stubs is to fix the new compile-testing problem of
Tegra regulator coupler drivers. The drivers indeed don't depend on the
regulator-driver API since the regulator-consumer API provides all the
necessary stubs, but now drivers use the regulator-driver API too. The
dependency should reduce the compile-testing scope, IIUC.

If you think that it will be better to add the dependency to the coupler
drivers, then let's do it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] regulator: core: Add stubs for driver API
  2021-06-21 12:04   ` Dmitry Osipenko
@ 2021-06-21 12:34     ` Mark Brown
  2021-06-21 15:33       ` Dmitry Osipenko
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2021-06-21 12:34 UTC (permalink / raw)
  To: Dmitry Osipenko; +Cc: Thierry Reding, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 838 bytes --]

On Mon, Jun 21, 2021 at 03:04:30PM +0300, Dmitry Osipenko wrote:
> 21.06.2021 14:46, Mark Brown пишет:

> > Why would something be registering a regulator device without a
> > dependency on the regulator API?

> For example if regulator device registration is optional in the code. We
> don't have such cases in the kernel today, but I decided that it will be
> cleaner to add stubs for the whole API.

It doesn't strike me as the sort of thing that should be optional TBH.
It seems much more likely that not having the stub will catch silly
errors than that the stubs will make something work that should.

> If you think that it will be better to add the dependency to the coupler
> drivers, then let's do it.

For coupler drivers it's not clear what function they serve without the
regulator API being enabled.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1] regulator: core: Add stubs for driver API
  2021-06-21 12:34     ` Mark Brown
@ 2021-06-21 15:33       ` Dmitry Osipenko
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Osipenko @ 2021-06-21 15:33 UTC (permalink / raw)
  To: Mark Brown; +Cc: Thierry Reding, linux-kernel

21.06.2021 15:34, Mark Brown пишет:
> On Mon, Jun 21, 2021 at 03:04:30PM +0300, Dmitry Osipenko wrote:
>> 21.06.2021 14:46, Mark Brown пишет:
> 
>>> Why would something be registering a regulator device without a
>>> dependency on the regulator API?
> 
>> For example if regulator device registration is optional in the code. We
>> don't have such cases in the kernel today, but I decided that it will be
>> cleaner to add stubs for the whole API.
> 
> It doesn't strike me as the sort of thing that should be optional TBH.
> It seems much more likely that not having the stub will catch silly
> errors than that the stubs will make something work that should.
> 
>> If you think that it will be better to add the dependency to the coupler
>> drivers, then let's do it.
> 
> For coupler drivers it's not clear what function they serve without the
> regulator API being enabled.
> 

I'll prepare patch to fix the Kconfig entry of the coupler drivers,
thank you.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-06-21 15:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-19 12:40 [PATCH v1] regulator: core: Add stubs for driver API Dmitry Osipenko
2021-06-21 11:46 ` Mark Brown
2021-06-21 12:04   ` Dmitry Osipenko
2021-06-21 12:34     ` Mark Brown
2021-06-21 15:33       ` Dmitry Osipenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.