From 72bf80cf09c4693780ad93a31b48fa5a4e17a946 Mon Sep 17 00:00:00 2001 From: Maíra Canal Date: Fri, 15 Oct 2021 12:14:35 -0300 Subject: regulator: lp872x: replacing legacy gpio interface for gpiod Removing all linux/gpio.h and linux/of_gpio.h dependencies and replacing them with the gpiod interface Signed-off-by: Maíra Canal Message-Id: Signed-off-by: Mark Brown --- include/linux/regulator/lp872x.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/linux/regulator/lp872x.h b/include/linux/regulator/lp872x.h index d780dbb8b423..8e7e0343c6e1 100644 --- a/include/linux/regulator/lp872x.h +++ b/include/linux/regulator/lp872x.h @@ -10,7 +10,7 @@ #include #include -#include +#include #define LP872X_MAX_REGULATORS 9 @@ -41,8 +41,8 @@ enum lp872x_regulator_id { }; enum lp872x_dvs_state { - DVS_LOW = GPIOF_OUT_INIT_LOW, - DVS_HIGH = GPIOF_OUT_INIT_HIGH, + DVS_LOW = GPIOD_OUT_LOW, + DVS_HIGH = GPIOD_OUT_HIGH, }; enum lp872x_dvs_sel { @@ -52,12 +52,12 @@ enum lp872x_dvs_sel { /** * lp872x_dvs - * @gpio : gpio pin number for dvs control + * @gpio : gpio descriptor for dvs control * @vsel : dvs selector for buck v1 or buck v2 register * @init_state : initial dvs pin state */ struct lp872x_dvs { - int gpio; + struct gpio_desc *gpio; enum lp872x_dvs_sel vsel; enum lp872x_dvs_state init_state; }; @@ -78,14 +78,14 @@ struct lp872x_regulator_data { * @update_config : if LP872X_GENERAL_CFG register is updated, set true * @regulator_data : platform regulator id and init data * @dvs : dvs data for buck voltage control - * @enable_gpio : gpio pin number for enable control + * @enable_gpio : gpio descriptor for enable control */ struct lp872x_platform_data { u8 general_config; bool update_config; struct lp872x_regulator_data regulator_data[LP872X_MAX_REGULATORS]; struct lp872x_dvs *dvs; - int enable_gpio; + struct gpio_desc *enable_gpio; }; #endif -- cgit v1.2.3 From 061514dbfb79910ef60eb40dd9fc528be3f45d62 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Mon, 18 Oct 2021 17:43:35 -0700 Subject: regulator: lp872x: Remove lp872x_dvs_state After this driver was converted to gpiod, clang started warning: vers/regulator/lp872x.c:689:57: error: implicit conversion from enumeration type 'enum lp872x_dvs_state' to different enumeration type 'enum gpiod_flags' [-Werror,-Wenum-conversion] dvs->gpio = devm_gpiod_get_optional(lp->dev, "ti,dvs", pinstate); ~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~ 1 error generated. lp872x_dvs_state was updated to have values from gpiod_flags but this is not enough to avoid an implicit conversion warning from either GCC or clang (although GCC enables this warning under -Wextra instead of -Wall like clang so it is not seen under normal builds). Eliminate lp872x_dvs_state in favor of using gpiod_flags everywhere so that there is no more warning about an implicit conversion. Fixes: 72bf80cf09c4 ("regulator: lp872x: replacing legacy gpio interface for gpiod") Link: https://github.com/ClangBuiltLinux/linux/issues/1481 Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20211019004335.193492-1-nathan@kernel.org Signed-off-by: Mark Brown --- drivers/regulator/lp872x.c | 14 +++++++------- include/linux/regulator/lp872x.h | 7 +------ 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index 1dba5dbcd461..35d826fe9def 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c @@ -103,7 +103,7 @@ struct lp872x { enum lp872x_id chipid; struct lp872x_platform_data *pdata; int num_regulators; - enum lp872x_dvs_state dvs_pin; + enum gpiod_flags dvs_pin; }; /* LP8720/LP8725 shared voltage table for LDOs */ @@ -251,9 +251,9 @@ static int lp872x_regulator_enable_time(struct regulator_dev *rdev) static void lp872x_set_dvs(struct lp872x *lp, enum lp872x_dvs_sel dvs_sel, struct gpio_desc *gpio) { - enum lp872x_dvs_state state; + enum gpiod_flags state; - state = dvs_sel == SEL_V1 ? DVS_HIGH : DVS_LOW; + state = dvs_sel == SEL_V1 ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; gpiod_set_value(gpio, state); lp->dvs_pin = state; } @@ -269,7 +269,7 @@ static u8 lp872x_select_buck_vout_addr(struct lp872x *lp, switch (buck) { case LP8720_ID_BUCK: if (val & LP8720_EXT_DVS_M) { - addr = (lp->dvs_pin == DVS_HIGH) ? + addr = (lp->dvs_pin == GPIOD_OUT_HIGH) ? LP8720_BUCK_VOUT1 : LP8720_BUCK_VOUT2; } else { if (lp872x_read_byte(lp, LP8720_ENABLE, &val)) @@ -283,7 +283,7 @@ static u8 lp872x_select_buck_vout_addr(struct lp872x *lp, if (val & LP8725_DVS1_M) addr = LP8725_BUCK1_VOUT1; else - addr = (lp->dvs_pin == DVS_HIGH) ? + addr = (lp->dvs_pin == GPIOD_OUT_HIGH) ? LP8725_BUCK1_VOUT1 : LP8725_BUCK1_VOUT2; break; case LP8725_ID_BUCK2: @@ -675,7 +675,7 @@ static const struct regulator_desc lp8725_regulator_desc[] = { static int lp872x_init_dvs(struct lp872x *lp) { struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL; - enum lp872x_dvs_state pinstate; + enum gpiod_flags pinstate; u8 mask[] = { LP8720_EXT_DVS_M, LP8725_DVS1_M | LP8725_DVS2_M }; u8 default_dvs_mode[] = { LP8720_DEFAULT_DVS, LP8725_DEFAULT_DVS }; @@ -841,7 +841,7 @@ static struct lp872x_platform_data of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel); of_property_read_u8(np, "ti,dvs-state", &dvs_state); - pdata->dvs->init_state = dvs_state ? DVS_HIGH : DVS_LOW; + pdata->dvs->init_state = dvs_state ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; if (of_get_child_count(np) == 0) goto out; diff --git a/include/linux/regulator/lp872x.h b/include/linux/regulator/lp872x.h index 8e7e0343c6e1..b62e45aa1dd3 100644 --- a/include/linux/regulator/lp872x.h +++ b/include/linux/regulator/lp872x.h @@ -40,11 +40,6 @@ enum lp872x_regulator_id { LP872X_ID_MAX, }; -enum lp872x_dvs_state { - DVS_LOW = GPIOD_OUT_LOW, - DVS_HIGH = GPIOD_OUT_HIGH, -}; - enum lp872x_dvs_sel { SEL_V1, SEL_V2, @@ -59,7 +54,7 @@ enum lp872x_dvs_sel { struct lp872x_dvs { struct gpio_desc *gpio; enum lp872x_dvs_sel vsel; - enum lp872x_dvs_state init_state; + enum gpiod_flags init_state; }; /** -- cgit v1.2.3 From 6a8b5bb0f1350fc4cf398435a1119db12b0bd50e Mon Sep 17 00:00:00 2001 From: Maíra Canal Date: Sun, 17 Oct 2021 15:06:39 -0300 Subject: regulator: tps62360: replacing legacy gpio interface for gpiod Removing all linux/gpio.h and linux/of_gpio.h dependencies and replacing them with the gpiod interface. Signed-off-by: Maíra Canal Link: https://lore.kernel.org/r/YWxmL2baF5AdzyHv@fedora Signed-off-by: Mark Brown --- drivers/regulator/tps62360-regulator.c | 59 +++++++++++++++------------------- include/linux/regulator/tps62360.h | 6 ---- 2 files changed, 26 insertions(+), 39 deletions(-) (limited to 'include') diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index 315cd5daf480..574958690ace 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c @@ -28,13 +28,12 @@ #include #include #include -#include #include #include #include #include #include -#include +#include #include #include #include @@ -65,8 +64,8 @@ struct tps62360_chip { struct regulator_desc desc; struct regulator_dev *rdev; struct regmap *regmap; - int vsel0_gpio; - int vsel1_gpio; + struct gpio_desc *vsel0_gpio; + struct gpio_desc *vsel1_gpio; u8 voltage_reg_mask; bool en_internal_pulldn; bool en_discharge; @@ -165,8 +164,8 @@ static int tps62360_dcdc_set_voltage_sel(struct regulator_dev *dev, /* Select proper VSET register vio gpios */ if (tps->valid_gpios) { - gpio_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); - gpio_set_value_cansleep(tps->vsel1_gpio, + gpiod_set_value_cansleep(tps->vsel0_gpio, new_vset_id & 0x1); + gpiod_set_value_cansleep(tps->vsel1_gpio, (new_vset_id >> 1) & 0x1); } return 0; @@ -310,9 +309,6 @@ static struct tps62360_regulator_platform_data * return NULL; } - pdata->vsel0_gpio = of_get_named_gpio(np, "vsel0-gpio", 0); - pdata->vsel1_gpio = of_get_named_gpio(np, "vsel1-gpio", 0); - if (of_find_property(np, "ti,vsel0-state-high", NULL)) pdata->vsel0_def_state = 1; @@ -349,6 +345,7 @@ static int tps62360_probe(struct i2c_client *client, int ret; int i; int chip_id; + int gpio_flags; pdata = dev_get_platdata(&client->dev); @@ -390,8 +387,6 @@ static int tps62360_probe(struct i2c_client *client, tps->en_discharge = pdata->en_discharge; tps->en_internal_pulldn = pdata->en_internal_pulldn; - tps->vsel0_gpio = pdata->vsel0_gpio; - tps->vsel1_gpio = pdata->vsel1_gpio; tps->dev = &client->dev; switch (chip_id) { @@ -426,29 +421,27 @@ static int tps62360_probe(struct i2c_client *client, tps->lru_index[0] = tps->curr_vset_id; tps->valid_gpios = false; - if (gpio_is_valid(tps->vsel0_gpio) && gpio_is_valid(tps->vsel1_gpio)) { - int gpio_flags; - gpio_flags = (pdata->vsel0_def_state) ? - GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; - ret = devm_gpio_request_one(&client->dev, tps->vsel0_gpio, - gpio_flags, "tps62360-vsel0"); - if (ret) { - dev_err(&client->dev, - "%s(): Could not obtain vsel0 GPIO %d: %d\n", - __func__, tps->vsel0_gpio, ret); - return ret; - } + gpio_flags = (pdata->vsel0_def_state) ? + GPIOD_OUT_HIGH : GPIOD_OUT_LOW; + tps->vsel0_gpio = devm_gpiod_get_optional(&client->dev, "vsel0", gpio_flags); + if (IS_ERR(tps->vsel0_gpio)) { + dev_err(&client->dev, + "%s(): Could not obtain vsel0 GPIO: %ld\n", + __func__, PTR_ERR(tps->vsel0_gpio)); + return PTR_ERR(tps->vsel0_gpio); + } - gpio_flags = (pdata->vsel1_def_state) ? - GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; - ret = devm_gpio_request_one(&client->dev, tps->vsel1_gpio, - gpio_flags, "tps62360-vsel1"); - if (ret) { - dev_err(&client->dev, - "%s(): Could not obtain vsel1 GPIO %d: %d\n", - __func__, tps->vsel1_gpio, ret); - return ret; - } + gpio_flags = (pdata->vsel1_def_state) ? + GPIOD_OUT_HIGH : GPIOD_OUT_LOW; + tps->vsel1_gpio = devm_gpiod_get_optional(&client->dev, "vsel1", gpio_flags); + if (IS_ERR(tps->vsel1_gpio)) { + dev_err(&client->dev, + "%s(): Could not obtain vsel1 GPIO: %ld\n", + __func__, PTR_ERR(tps->vsel1_gpio)); + return PTR_ERR(tps->vsel1_gpio); + } + + if (tps->vsel0_gpio != NULL && tps->vsel1_gpio != NULL) { tps->valid_gpios = true; /* diff --git a/include/linux/regulator/tps62360.h b/include/linux/regulator/tps62360.h index 94a90c06f1e5..398e74a1d941 100644 --- a/include/linux/regulator/tps62360.h +++ b/include/linux/regulator/tps62360.h @@ -19,10 +19,6 @@ * @en_discharge: Enable discharge the output capacitor via internal * register. * @en_internal_pulldn: internal pull down enable or not. - * @vsel0_gpio: Gpio number for vsel0. It should be -1 if this is tied with - * fixed logic. - * @vsel1_gpio: Gpio number for vsel1. It should be -1 if this is tied with - * fixed logic. * @vsel0_def_state: Default state of vsel0. 1 if it is high else 0. * @vsel1_def_state: Default state of vsel1. 1 if it is high else 0. */ @@ -30,8 +26,6 @@ struct tps62360_regulator_platform_data { struct regulator_init_data *reg_init_data; bool en_discharge; bool en_internal_pulldn; - int vsel0_gpio; - int vsel1_gpio; int vsel0_def_state; int vsel1_def_state; }; -- cgit v1.2.3