regulator: rt6160: Remove vsel_active_low from struct rt6160_priv
Use a local variable instead is enough, this simplifies the code. Signed-off-by: Axel Lin <axel.lin@ingics.com> Link: https://lore.kernel.org/r/20210615103947.3387994-1-axel.lin@ingics.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Родитель
00430f71b2
Коммит
f3f4f37d53
|
@ -42,7 +42,6 @@ struct rt6160_priv {
|
||||||
struct regulator_desc desc;
|
struct regulator_desc desc;
|
||||||
struct gpio_desc *enable_gpio;
|
struct gpio_desc *enable_gpio;
|
||||||
struct regmap *regmap;
|
struct regmap *regmap;
|
||||||
bool vsel_active_low;
|
|
||||||
bool enable_state;
|
bool enable_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -128,19 +127,15 @@ static unsigned int rt6160_get_mode(struct regulator_dev *rdev)
|
||||||
|
|
||||||
static int rt6160_set_suspend_voltage(struct regulator_dev *rdev, int uV)
|
static int rt6160_set_suspend_voltage(struct regulator_dev *rdev, int uV)
|
||||||
{
|
{
|
||||||
struct rt6160_priv *priv = rdev_get_drvdata(rdev);
|
|
||||||
struct regmap *regmap = rdev_get_regmap(rdev);
|
struct regmap *regmap = rdev_get_regmap(rdev);
|
||||||
unsigned int reg = RT6160_REG_VSELH;
|
|
||||||
int vsel;
|
int vsel;
|
||||||
|
|
||||||
vsel = regulator_map_voltage_linear(rdev, uV, uV);
|
vsel = regulator_map_voltage_linear(rdev, uV, uV);
|
||||||
if (vsel < 0)
|
if (vsel < 0)
|
||||||
return vsel;
|
return vsel;
|
||||||
|
|
||||||
if (priv->vsel_active_low)
|
return regmap_update_bits(regmap, rdev->desc->vsel_reg,
|
||||||
reg = RT6160_REG_VSELL;
|
RT6160_VSEL_MASK, vsel);
|
||||||
|
|
||||||
return regmap_update_bits(regmap, reg, RT6160_VSEL_MASK, vsel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rt6160_get_error_flags(struct regulator_dev *rdev, unsigned int *flags)
|
static int rt6160_get_error_flags(struct regulator_dev *rdev, unsigned int *flags)
|
||||||
|
@ -228,6 +223,7 @@ static int rt6160_probe(struct i2c_client *i2c)
|
||||||
struct rt6160_priv *priv;
|
struct rt6160_priv *priv;
|
||||||
struct regulator_config regulator_cfg = {};
|
struct regulator_config regulator_cfg = {};
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
|
bool vsel_active_low;
|
||||||
unsigned int devid;
|
unsigned int devid;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -235,7 +231,8 @@ static int rt6160_probe(struct i2c_client *i2c)
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
priv->vsel_active_low = device_property_present(&i2c->dev, "richtek,vsel-active-low");
|
vsel_active_low =
|
||||||
|
device_property_present(&i2c->dev, "richtek,vsel-active-low");
|
||||||
|
|
||||||
priv->enable_gpio = devm_gpiod_get_optional(&i2c->dev, "enable", GPIOD_OUT_HIGH);
|
priv->enable_gpio = devm_gpiod_get_optional(&i2c->dev, "enable", GPIOD_OUT_HIGH);
|
||||||
if (IS_ERR(priv->enable_gpio)) {
|
if (IS_ERR(priv->enable_gpio)) {
|
||||||
|
@ -267,7 +264,10 @@ static int rt6160_probe(struct i2c_client *i2c)
|
||||||
priv->desc.owner = THIS_MODULE;
|
priv->desc.owner = THIS_MODULE;
|
||||||
priv->desc.min_uV = RT6160_VOUT_MINUV;
|
priv->desc.min_uV = RT6160_VOUT_MINUV;
|
||||||
priv->desc.uV_step = RT6160_VOUT_STPUV;
|
priv->desc.uV_step = RT6160_VOUT_STPUV;
|
||||||
priv->desc.vsel_reg = RT6160_REG_VSELH;
|
if (vsel_active_low)
|
||||||
|
priv->desc.vsel_reg = RT6160_REG_VSELL;
|
||||||
|
else
|
||||||
|
priv->desc.vsel_reg = RT6160_REG_VSELH;
|
||||||
priv->desc.vsel_mask = RT6160_VSEL_MASK;
|
priv->desc.vsel_mask = RT6160_VSEL_MASK;
|
||||||
priv->desc.n_voltages = RT6160_N_VOUTS;
|
priv->desc.n_voltages = RT6160_N_VOUTS;
|
||||||
priv->desc.ramp_reg = RT6160_REG_CNTL;
|
priv->desc.ramp_reg = RT6160_REG_CNTL;
|
||||||
|
@ -276,8 +276,6 @@ static int rt6160_probe(struct i2c_client *i2c)
|
||||||
priv->desc.n_ramp_values = ARRAY_SIZE(rt6160_ramp_tables);
|
priv->desc.n_ramp_values = ARRAY_SIZE(rt6160_ramp_tables);
|
||||||
priv->desc.of_map_mode = rt6160_of_map_mode;
|
priv->desc.of_map_mode = rt6160_of_map_mode;
|
||||||
priv->desc.ops = &rt6160_regulator_ops;
|
priv->desc.ops = &rt6160_regulator_ops;
|
||||||
if (priv->vsel_active_low)
|
|
||||||
priv->desc.vsel_reg = RT6160_REG_VSELL;
|
|
||||||
|
|
||||||
regulator_cfg.dev = &i2c->dev;
|
regulator_cfg.dev = &i2c->dev;
|
||||||
regulator_cfg.of_node = i2c->dev.of_node;
|
regulator_cfg.of_node = i2c->dev.of_node;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче