* [PATCH] regulator: lp872x: fix enum conversion warning
@ 2021-10-19 15:38 Arnd Bergmann
2021-10-19 17:40 ` Nathan Chancellor
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2021-10-19 15:38 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Nathan Chancellor, Nick Desaulniers,
Maíra Canal
Cc: Arnd Bergmann, Colin Ian King, linux-kernel, llvm
From: Arnd Bergmann <arnd@arndb.de>
clang warns that the argument to devm_gpiod_get_optional()
is the wrong type:
drivers/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);
~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~
The enum value is specifcally chosen to be the same here, but
the compiler only sees the mismatched types. This could be
worked around using another ?: expression, but it seems easiest
to replace the assignment with a macro.
Fixes: 72bf80cf09c4 ("regulator: lp872x: replacing legacy gpio interface for gpiod")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/regulator/lp872x.c | 6 +++---
include/linux/regulator/lp872x.h | 8 +++-----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index 1dba5dbcd461..61412ebc8d8d 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,7 +251,7 @@ 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;
gpiod_set_value(gpio, state);
@@ -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 };
diff --git a/include/linux/regulator/lp872x.h b/include/linux/regulator/lp872x.h
index 8e7e0343c6e1..5b94fe38fc78 100644
--- a/include/linux/regulator/lp872x.h
+++ b/include/linux/regulator/lp872x.h
@@ -40,10 +40,8 @@ enum lp872x_regulator_id {
LP872X_ID_MAX,
};
-enum lp872x_dvs_state {
- DVS_LOW = GPIOD_OUT_LOW,
- DVS_HIGH = GPIOD_OUT_HIGH,
-};
+#define DVS_LOW GPIOD_OUT_LOW
+#define DVS_HIGH GPIOD_OUT_HIGH
enum lp872x_dvs_sel {
SEL_V1,
@@ -59,7 +57,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;
};
/**
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: lp872x: fix enum conversion warning
2021-10-19 15:38 [PATCH] regulator: lp872x: fix enum conversion warning Arnd Bergmann
@ 2021-10-19 17:40 ` Nathan Chancellor
0 siblings, 0 replies; 2+ messages in thread
From: Nathan Chancellor @ 2021-10-19 17:40 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Liam Girdwood, Mark Brown, Nick Desaulniers, Maíra Canal,
Arnd Bergmann, Colin Ian King, linux-kernel, llvm
On Tue, Oct 19, 2021 at 05:38:43PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang warns that the argument to devm_gpiod_get_optional()
> is the wrong type:
>
> drivers/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);
> ~~~~~~~~~~~~~~~~~~~~~~~ ^~~~~~~~
>
> The enum value is specifcally chosen to be the same here, but
> the compiler only sees the mismatched types. This could be
> worked around using another ?: expression, but it seems easiest
> to replace the assignment with a macro.
>
> Fixes: 72bf80cf09c4 ("regulator: lp872x: replacing legacy gpio interface for gpiod")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
I sent basically the same patch but I also eliminated DSV_{LOW,HIGH}
in favor of the GPIOD flags outright:
https://lore.kernel.org/r/20211019004335.193492-1-nathan@kernel.org/
Either one works so I do not really care which one gets merged.
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> ---
> drivers/regulator/lp872x.c | 6 +++---
> include/linux/regulator/lp872x.h | 8 +++-----
> 2 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
> index 1dba5dbcd461..61412ebc8d8d 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,7 +251,7 @@ 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;
> gpiod_set_value(gpio, state);
> @@ -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 };
>
> diff --git a/include/linux/regulator/lp872x.h b/include/linux/regulator/lp872x.h
> index 8e7e0343c6e1..5b94fe38fc78 100644
> --- a/include/linux/regulator/lp872x.h
> +++ b/include/linux/regulator/lp872x.h
> @@ -40,10 +40,8 @@ enum lp872x_regulator_id {
> LP872X_ID_MAX,
> };
>
> -enum lp872x_dvs_state {
> - DVS_LOW = GPIOD_OUT_LOW,
> - DVS_HIGH = GPIOD_OUT_HIGH,
> -};
> +#define DVS_LOW GPIOD_OUT_LOW
> +#define DVS_HIGH GPIOD_OUT_HIGH
>
> enum lp872x_dvs_sel {
> SEL_V1,
> @@ -59,7 +57,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;
> };
>
> /**
> --
> 2.29.2
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-19 17:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 15:38 [PATCH] regulator: lp872x: fix enum conversion warning Arnd Bergmann
2021-10-19 17:40 ` Nathan Chancellor
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.