regulator: core: Add stubs for driver API
PATCH 1/1 regulator: core: Add stubs for driver API
Add stubs for regulator driver API in order to fix compile-test build errors of kernel configurations where regulator framework is disabled.
--- include/linux/regulator/driver.h | 237 +++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+)
include/linux/regulator/driver.h +237 -0
@@ -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
Signature · 1 line
2.30.2
Mark Brown
maintainerinclude/linux/regulator/driver.h int regulator_desc_list_voltage_linear_range(const struct regulator_desc *desc, · line 561
Quoted 3 lines · Dmitry Osipenko
include/linux/regulator/driver.h +3
-0+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?
21.06.2021 14:46, Mark Brown пишет:
Quoted 9 lines · Dmitry Osipenko
include/linux/regulator/driver.h int regulator_desc_list_voltage_linear_range(const struct regulator_desc *desc, · line 561
Quoted 4 lines
include/linux/regulator/driver.h +3
-0+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.
Mark Brown
maintainerQuoted 8 lines · Dmitry Osipenko
21.06.2021 14:46, Mark Brown пишет:
Quoted 2 lines
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.
Quoted 2 lines
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.
21.06.2021 15:34, Mark Brown пишет:
Quoted 14 lines · Dmitry Osipenko
Quoted 8 lines
21.06.2021 14:46, Mark Brown пишет:
Quoted 2 lines
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.
Quoted 6 lines
Quoted 2 lines
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.