Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <nathan@kernel.org>
Link: https://lore.kernel.org/r/20211019004335.193492-1-nathan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Nathan Chancellor and committed by
Mark Brown
061514db ed96f35c

+8 -13
+7 -7
drivers/regulator/lp872x.c
··· 103 103 enum lp872x_id chipid; 104 104 struct lp872x_platform_data *pdata; 105 105 int num_regulators; 106 - enum lp872x_dvs_state dvs_pin; 106 + enum gpiod_flags dvs_pin; 107 107 }; 108 108 109 109 /* LP8720/LP8725 shared voltage table for LDOs */ ··· 251 251 static void lp872x_set_dvs(struct lp872x *lp, enum lp872x_dvs_sel dvs_sel, 252 252 struct gpio_desc *gpio) 253 253 { 254 - enum lp872x_dvs_state state; 254 + enum gpiod_flags state; 255 255 256 - state = dvs_sel == SEL_V1 ? DVS_HIGH : DVS_LOW; 256 + state = dvs_sel == SEL_V1 ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; 257 257 gpiod_set_value(gpio, state); 258 258 lp->dvs_pin = state; 259 259 } ··· 269 269 switch (buck) { 270 270 case LP8720_ID_BUCK: 271 271 if (val & LP8720_EXT_DVS_M) { 272 - addr = (lp->dvs_pin == DVS_HIGH) ? 272 + addr = (lp->dvs_pin == GPIOD_OUT_HIGH) ? 273 273 LP8720_BUCK_VOUT1 : LP8720_BUCK_VOUT2; 274 274 } else { 275 275 if (lp872x_read_byte(lp, LP8720_ENABLE, &val)) ··· 283 283 if (val & LP8725_DVS1_M) 284 284 addr = LP8725_BUCK1_VOUT1; 285 285 else 286 - addr = (lp->dvs_pin == DVS_HIGH) ? 286 + addr = (lp->dvs_pin == GPIOD_OUT_HIGH) ? 287 287 LP8725_BUCK1_VOUT1 : LP8725_BUCK1_VOUT2; 288 288 break; 289 289 case LP8725_ID_BUCK2: ··· 675 675 static int lp872x_init_dvs(struct lp872x *lp) 676 676 { 677 677 struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL; 678 - enum lp872x_dvs_state pinstate; 678 + enum gpiod_flags pinstate; 679 679 u8 mask[] = { LP8720_EXT_DVS_M, LP8725_DVS1_M | LP8725_DVS2_M }; 680 680 u8 default_dvs_mode[] = { LP8720_DEFAULT_DVS, LP8725_DEFAULT_DVS }; 681 681 ··· 841 841 842 842 of_property_read_u8(np, "ti,dvs-vsel", (u8 *)&pdata->dvs->vsel); 843 843 of_property_read_u8(np, "ti,dvs-state", &dvs_state); 844 - pdata->dvs->init_state = dvs_state ? DVS_HIGH : DVS_LOW; 844 + pdata->dvs->init_state = dvs_state ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW; 845 845 846 846 if (of_get_child_count(np) == 0) 847 847 goto out;
+1 -6
include/linux/regulator/lp872x.h
··· 40 40 LP872X_ID_MAX, 41 41 }; 42 42 43 - enum lp872x_dvs_state { 44 - DVS_LOW = GPIOD_OUT_LOW, 45 - DVS_HIGH = GPIOD_OUT_HIGH, 46 - }; 47 - 48 43 enum lp872x_dvs_sel { 49 44 SEL_V1, 50 45 SEL_V2, ··· 54 59 struct lp872x_dvs { 55 60 struct gpio_desc *gpio; 56 61 enum lp872x_dvs_sel vsel; 57 - enum lp872x_dvs_state init_state; 62 + enum gpiod_flags init_state; 58 63 }; 59 64 60 65 /**