From c2f05ed6b5be99d81487ce40d18aea1fe5e2b297 Mon Sep 17 00:00:00 2001 From: Jishnu Prakash Date: Wed, 8 Apr 2020 16:54:59 +0530 Subject: [PATCH] regulators: rpm-smd: Remove unused exported functions Remove all exported functions as clients need to use only functions exported from core regulator framework. Change rpm-smd config to tristate to ensure it can be loaded as a module. Change-Id: I3f72a19b23fb2b97e0a13fd93fad5eade15ff535 Signed-off-by: Jishnu Prakash --- drivers/regulator/Kconfig | 2 +- drivers/regulator/rpm-smd-regulator.c | 299 +------------------- include/linux/regulator/rpm-smd-regulator.h | 43 +-- 3 files changed, 3 insertions(+), 341 deletions(-) diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index d7739c58326e..209365663d10 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -1182,7 +1182,7 @@ config REGULATOR_RPMH processors within the SoC. config REGULATOR_RPM_SMD - bool "RPM SMD regulator driver" + tristate "RPM SMD regulator driver" depends on OF depends on MSM_RPM_SMD help diff --git a/drivers/regulator/rpm-smd-regulator.c b/drivers/regulator/rpm-smd-regulator.c index 044a4d6e2e3e..5fa65556eebf 100644 --- a/drivers/regulator/rpm-smd-regulator.c +++ b/drivers/regulator/rpm-smd-regulator.c @@ -149,20 +149,6 @@ static struct rpm_regulator_param params[RPM_REGULATOR_PARAM_MAX] = { PARAM(PIN_CTRL_VOLTAGE3, 0, 0, 0, 0, 1, "pcv3", 0, 0x7FFFFFF, "qcom,init-pin-ctrl-voltage3"), }; -struct rpm_regulator_mode_map { - int ldo_mode; - int smps_mode; -}; - -static struct rpm_regulator_mode_map mode_mapping[] = { - [RPM_REGULATOR_MODE_AUTO] - = {-1, RPM_REGULATOR_SMPS_MODE_AUTO}, - [RPM_REGULATOR_MODE_IPEAK] - = {RPM_REGULATOR_LDO_MODE_IPEAK, RPM_REGULATOR_SMPS_MODE_IPEAK}, - [RPM_REGULATOR_MODE_HPM] - = {RPM_REGULATOR_LDO_MODE_HPM, RPM_REGULATOR_SMPS_MODE_PWM}, -}; - /* Indices for use with pin control enable via enable/disable feature. */ #define RPM_VREG_PIN_CTRL_STATE_DISABLE 0 #define RPM_VREG_PIN_CTRL_STATE_ENABLE 1 @@ -1177,288 +1163,6 @@ static int rpm_vreg_configure_pin_control_enable(struct rpm_regulator *reg, return 0; } -/** - * rpm_regulator_get() - lookup and obtain a handle to an RPM regulator - * @dev: device for regulator consumer - * @supply: supply name - * - * Returns a struct rpm_regulator corresponding to the regulator producer, - * or ERR_PTR() containing errno. - * - * This function may only be called from nonatomic context. - */ -struct rpm_regulator *rpm_regulator_get(struct device *dev, const char *supply) -{ - struct rpm_regulator *framework_reg; - struct rpm_regulator *priv_reg = NULL; - struct regulator *regulator; - struct rpm_vreg *rpm_vreg; - - regulator = regulator_get(dev, supply); - if (IS_ERR(regulator)) { - pr_err("could not find regulator for: dev=%s, supply=%s, rc=%ld\n", - (dev ? dev_name(dev) : ""), (supply ? supply : ""), - PTR_ERR(regulator)); - return ERR_CAST(regulator); - } - - framework_reg = regulator_get_drvdata(regulator); - if (framework_reg == NULL) { - pr_err("regulator structure not found\n"); - regulator_put(regulator); - return ERR_PTR(-ENODEV); - } - regulator_put(regulator); - - rpm_vreg = framework_reg->rpm_vreg; - - priv_reg = kzalloc(sizeof(*priv_reg), GFP_KERNEL); - if (priv_reg == NULL) - return ERR_PTR(-ENOMEM); - - /* - * Allocate a regulator_dev struct so that framework callback functions - * can be called from the private API functions. - */ - priv_reg->rdev = kzalloc(sizeof(struct regulator_dev), GFP_KERNEL); - if (priv_reg->rdev == NULL) { - kfree(priv_reg); - return ERR_PTR(-ENOMEM); - } - priv_reg->rdev->reg_data = priv_reg; - priv_reg->rpm_vreg = rpm_vreg; - priv_reg->rdesc.name = framework_reg->rdesc.name; - priv_reg->rdesc.ops = framework_reg->rdesc.ops; - priv_reg->set_active = framework_reg->set_active; - priv_reg->set_sleep = framework_reg->set_sleep; - priv_reg->min_uV = framework_reg->min_uV; - priv_reg->max_uV = framework_reg->max_uV; - priv_reg->system_load = framework_reg->system_load; - - might_sleep_if(!rpm_vreg->allow_atomic); - rpm_vreg_lock(rpm_vreg); - list_add(&priv_reg->list, &rpm_vreg->reg_list); - rpm_vreg_unlock(rpm_vreg); - - return priv_reg; -} -EXPORT_SYMBOL(rpm_regulator_get); - -static int rpm_regulator_check_input(struct rpm_regulator *regulator) -{ - if (IS_ERR_OR_NULL(regulator) || regulator->rpm_vreg == NULL) { - pr_err("invalid rpm_regulator pointer\n"); - return -EINVAL; - } - - might_sleep_if(!regulator->rpm_vreg->allow_atomic); - - return 0; -} - -/** - * rpm_regulator_put() - free the RPM regulator handle - * @regulator: RPM regulator handle - * - * Parameter reaggregation does not take place when rpm_regulator_put is called. - * Therefore, regulator enable state and voltage must be configured - * appropriately before calling rpm_regulator_put. - * - * This function may be called from either atomic or nonatomic context. If this - * function is called from atomic context, then the regulator being operated on - * must be configured via device tree with qcom,allow-atomic == 1. - */ -void rpm_regulator_put(struct rpm_regulator *regulator) -{ - struct rpm_vreg *rpm_vreg; - int rc = rpm_regulator_check_input(regulator); - - if (rc) - return; - - rpm_vreg = regulator->rpm_vreg; - - might_sleep_if(!rpm_vreg->allow_atomic); - rpm_vreg_lock(rpm_vreg); - list_del(®ulator->list); - rpm_vreg_unlock(rpm_vreg); - - kfree(regulator->rdev); - kfree(regulator); -} -EXPORT_SYMBOL(rpm_regulator_put); - -/** - * rpm_regulator_enable() - enable regulator output - * @regulator: RPM regulator handle - * - * Returns 0 on success or errno on failure. - * - * This function may be called from either atomic or nonatomic context. If this - * function is called from atomic context, then the regulator being operated on - * must be configured via device tree with qcom,allow-atomic == 1. - */ -int rpm_regulator_enable(struct rpm_regulator *regulator) -{ - int rc = rpm_regulator_check_input(regulator); - - if (rc) - return rc; - - return rpm_vreg_enable(regulator->rdev); -} -EXPORT_SYMBOL(rpm_regulator_enable); - -/** - * rpm_regulator_disable() - disable regulator output - * @regulator: RPM regulator handle - * - * Returns 0 on success or errno on failure. - * - * The enable state of the regulator is determined by aggregating the requests - * of all consumers. Therefore, it is possible that the regulator will remain - * enabled even after rpm_regulator_disable is called. - * - * This function may be called from either atomic or nonatomic context. If this - * function is called from atomic context, then the regulator being operated on - * must be configured via device tree with qcom,allow-atomic == 1. - */ -int rpm_regulator_disable(struct rpm_regulator *regulator) -{ - int rc = rpm_regulator_check_input(regulator); - - if (rc) - return rc; - - return rpm_vreg_disable(regulator->rdev); -} -EXPORT_SYMBOL(rpm_regulator_disable); - -/** - * rpm_regulator_set_voltage() - set regulator output voltage - * @regulator: RPM regulator handle - * @min_uV: minimum required voltage in uV - * @max_uV: maximum acceptable voltage in uV - * - * Sets a voltage regulator to the desired output voltage. This can be set - * while the regulator is disabled or enabled. If the regulator is enabled then - * the voltage will change to the new value immediately; otherwise, if the - * regulator is disabled, then the regulator will output at the new voltage when - * enabled. - * - * The min_uV to max_uV voltage range requested must intersect with the - * voltage constraint range configured for the regulator. - * - * Returns 0 on success or errno on failure. - * - * The final voltage value that is sent to the RPM is aggregated based upon the - * values requested by all consumers of the regulator. This corresponds to the - * maximum min_uV value. - * - * This function may be called from either atomic or nonatomic context. If this - * function is called from atomic context, then the regulator being operated on - * must be configured via device tree with qcom,allow-atomic == 1. - */ -int rpm_regulator_set_voltage(struct rpm_regulator *regulator, int min_uV, - int max_uV) -{ - int rc = rpm_regulator_check_input(regulator); - int uV = min_uV; - - if (rc) - return rc; - - if (regulator->rpm_vreg->regulator_type == RPM_REGULATOR_TYPE_VS) { - vreg_err(regulator, "unsupported regulator type: %d\n", - regulator->rpm_vreg->regulator_type); - return -EINVAL; - } - - if (min_uV > max_uV) { - vreg_err(regulator, "min_uV=%d must be less than max_uV=%d\n", - min_uV, max_uV); - return -EINVAL; - } - - if (uV < regulator->min_uV && max_uV >= regulator->min_uV) - uV = regulator->min_uV; - - if (uV < regulator->min_uV || uV > regulator->max_uV) { - vreg_err(regulator, - "request v=[%d, %d] is outside allowed v=[%d, %d]\n", - min_uV, max_uV, regulator->min_uV, regulator->max_uV); - return -EINVAL; - } - - return regulator->rdesc.ops->set_voltage(regulator->rdev, uV, uV, NULL); -} -EXPORT_SYMBOL(rpm_regulator_set_voltage); - -/** - * rpm_regulator_set_mode() - set regulator operating mode - * @regulator: RPM regulator handle - * @mode: operating mode requested for the regulator - * - * Requests that the mode of the regulator be set to the mode specified. This - * parameter is aggregated using a max function such that AUTO < IPEAK < HPM. - * - * Returns 0 on success or errno on failure. - */ -int rpm_regulator_set_mode(struct rpm_regulator *regulator, - enum rpm_regulator_mode mode) -{ - int index = 0; - u32 new_mode, prev_mode; - int rc; - - rc = rpm_regulator_check_input(regulator); - if (rc) - return rc; - - if (mode < 0 || mode >= ARRAY_SIZE(mode_mapping)) { - vreg_err(regulator, "invalid mode requested: %d\n", mode); - return -EINVAL; - } - - switch (regulator->rpm_vreg->regulator_type) { - case RPM_REGULATOR_TYPE_SMPS: - index = RPM_REGULATOR_PARAM_MODE_SMPS; - new_mode = mode_mapping[mode].smps_mode; - break; - case RPM_REGULATOR_TYPE_LDO: - index = RPM_REGULATOR_PARAM_MODE_LDO; - new_mode = mode_mapping[mode].ldo_mode; - break; - default: - vreg_err(regulator, "unsupported regulator type: %d\n", - regulator->rpm_vreg->regulator_type); - return -EINVAL; - } - - if (new_mode < params[index].min || new_mode > params[index].max) { - vreg_err(regulator, "invalid mode requested: %d for type: %d\n", - mode, regulator->rpm_vreg->regulator_type); - return -EINVAL; - } - - rpm_vreg_lock(regulator->rpm_vreg); - - prev_mode = regulator->req.param[index]; - regulator->req.param[index] = new_mode; - regulator->req.modified |= BIT(index); - - rc = rpm_vreg_aggregate_requests(regulator); - if (rc) { - vreg_err(regulator, "set mode failed, rc=%d", rc); - regulator->req.param[index] = prev_mode; - } - - rpm_vreg_unlock(regulator->rpm_vreg); - - return rc; -} -EXPORT_SYMBOL(rpm_regulator_set_mode); - static struct regulator_ops ldo_ops = { .enable = rpm_vreg_enable, .disable = rpm_vreg_disable, @@ -2049,7 +1753,7 @@ static struct platform_driver rpm_vreg_resource_driver = { * * Returns 0 on success or errno on failure. */ -int __init rpm_smd_regulator_driver_init(void) +static int __init rpm_smd_regulator_driver_init(void) { static bool initialized; int i, rc; @@ -2069,7 +1773,6 @@ int __init rpm_smd_regulator_driver_init(void) return platform_driver_register(&rpm_vreg_resource_driver); } -EXPORT_SYMBOL(rpm_smd_regulator_driver_init); static void __exit rpm_vreg_exit(void) { diff --git a/include/linux/regulator/rpm-smd-regulator.h b/include/linux/regulator/rpm-smd-regulator.h index db1c0639f7d5..33cb0896fa54 100644 --- a/include/linux/regulator/rpm-smd-regulator.h +++ b/include/linux/regulator/rpm-smd-regulator.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2012-2013, 2015, 2017, 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2012-2013, 2015, 2017, 2019-2020, The Linux Foundation. All rights reserved. */ #ifndef _LINUX_REGULATOR_RPM_SMD_H @@ -82,47 +82,6 @@ enum rpm_regulator_mode { RPM_REGULATOR_MODE_HPM, }; -#ifdef CONFIG_REGULATOR_RPM_SMD - -struct rpm_regulator *rpm_regulator_get(struct device *dev, const char *supply); - -void rpm_regulator_put(struct rpm_regulator *regulator); - -int rpm_regulator_enable(struct rpm_regulator *regulator); - -int rpm_regulator_disable(struct rpm_regulator *regulator); - -int rpm_regulator_set_voltage(struct rpm_regulator *regulator, int min_uV, - int max_uV); - -int rpm_regulator_set_mode(struct rpm_regulator *regulator, - enum rpm_regulator_mode mode); - -int __init rpm_smd_regulator_driver_init(void); - -#else - -static inline struct rpm_regulator *rpm_regulator_get(struct device *dev, - const char *supply) { return NULL; } - -static inline void rpm_regulator_put(struct rpm_regulator *regulator) { } - -static inline int rpm_regulator_enable(struct rpm_regulator *regulator) - { return 0; } - -static inline int rpm_regulator_disable(struct rpm_regulator *regulator) - { return 0; } - -static inline int rpm_regulator_set_voltage(struct rpm_regulator *regulator, - int min_uV, int max_uV) { return 0; } - -static inline int rpm_regulator_set_mode(struct rpm_regulator *regulator, - enum rpm_regulator_mode mode) { return 0; } - -static inline int __init rpm_smd_regulator_driver_init(void) { return 0; } - -#endif /* CONFIG_REGULATOR_RPM_SMD */ - #ifdef CONFIG_DEBUG_FS static void rpm_vreg_create_debugfs(struct rpm_regulator *reg);