2018-11-01 00:52:04

by Nathan Chancellor

[permalink] [raw]
Subject: [PATCH] pinctrl: max77620: Use define directive for max77620_pinconf_param values

Clang warns when one enumerated type is implicitly converted to another:

drivers/pinctrl/pinctrl-max77620.c:56:12: warning: implicit conversion
from enumeration type 'enum max77620_pinconf_param' to different
enumeration type 'enum pin_config_param' [-Wenum-conversion]
.param = MAX77620_ACTIVE_FPS_SOURCE,
^~~~~~~~~~~~~~~~~~~~~~~~~~

It is expected that pinctrl drivers can extend pin_config_param because
of the gap between PIN_CONFIG_END and PIN_CONFIG_MAX so this conversion
isn't an issue. Most drivers that take advantage of this define the
PIN_CONFIG variables as constants, rather than enumerated values. Do the
same thing here so that Clang no longer warns.

Link: https://github.com/ClangBuiltLinux/linux/issues/139
Signed-off-by: Nathan Chancellor <[email protected]>
---
drivers/pinctrl/pinctrl-max77620.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-max77620.c b/drivers/pinctrl/pinctrl-max77620.c
index a7f37063518e..3d05bc1937d4 100644
--- a/drivers/pinctrl/pinctrl-max77620.c
+++ b/drivers/pinctrl/pinctrl-max77620.c
@@ -34,14 +34,12 @@ enum max77620_pin_ppdrv {
MAX77620_PIN_PP_DRV,
};

-enum max77620_pinconf_param {
- MAX77620_ACTIVE_FPS_SOURCE = PIN_CONFIG_END + 1,
- MAX77620_ACTIVE_FPS_POWER_ON_SLOTS,
- MAX77620_ACTIVE_FPS_POWER_DOWN_SLOTS,
- MAX77620_SUSPEND_FPS_SOURCE,
- MAX77620_SUSPEND_FPS_POWER_ON_SLOTS,
- MAX77620_SUSPEND_FPS_POWER_DOWN_SLOTS,
-};
+#define MAX77620_ACTIVE_FPS_SOURCE (PIN_CONFIG_END + 1)
+#define MAX77620_ACTIVE_FPS_POWER_ON_SLOTS (PIN_CONFIG_END + 2)
+#define MAX77620_ACTIVE_FPS_POWER_DOWN_SLOTS (PIN_CONFIG_END + 3)
+#define MAX77620_SUSPEND_FPS_SOURCE (PIN_CONFIG_END + 4)
+#define MAX77620_SUSPEND_FPS_POWER_ON_SLOTS (PIN_CONFIG_END + 5)
+#define MAX77620_SUSPEND_FPS_POWER_DOWN_SLOTS (PIN_CONFIG_END + 6)

struct max77620_pin_function {
const char *name;
--
2.19.1



2018-11-09 09:02:44

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH] pinctrl: max77620: Use define directive for max77620_pinconf_param values

On Thu, Nov 1, 2018 at 1:51 AM Nathan Chancellor
<[email protected]> wrote:

> Clang warns when one enumerated type is implicitly converted to another:
>
> drivers/pinctrl/pinctrl-max77620.c:56:12: warning: implicit conversion
> from enumeration type 'enum max77620_pinconf_param' to different
> enumeration type 'enum pin_config_param' [-Wenum-conversion]
> .param = MAX77620_ACTIVE_FPS_SOURCE,
> ^~~~~~~~~~~~~~~~~~~~~~~~~~
>
> It is expected that pinctrl drivers can extend pin_config_param because
> of the gap between PIN_CONFIG_END and PIN_CONFIG_MAX so this conversion
> isn't an issue. Most drivers that take advantage of this define the
> PIN_CONFIG variables as constants, rather than enumerated values. Do the
> same thing here so that Clang no longer warns.
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/139
> Signed-off-by: Nathan Chancellor <[email protected]>

Patch tentatively applied.

This seems to be the direction we need to be going with a lot
of CLANG business.

Laxman: you weren't CCed, so tell us if you dislike it for some
reason.

Yours,
Linus Walleij

2018-11-09 10:51:01

by Laxman Dewangan

[permalink] [raw]
Subject: Re: [PATCH] pinctrl: max77620: Use define directive for max77620_pinconf_param values



On Friday 09 November 2018 02:31 PM, Linus Walleij wrote:
> On Thu, Nov 1, 2018 at 1:51 AM Nathan Chancellor
> <[email protected]> wrote:
>
>> Clang warns when one enumerated type is implicitly converted to another:
>>
>> drivers/pinctrl/pinctrl-max77620.c:56:12: warning: implicit conversion
>> from enumeration type 'enum max77620_pinconf_param' to different
>> enumeration type 'enum pin_config_param' [-Wenum-conversion]
>> .param = MAX77620_ACTIVE_FPS_SOURCE,
>> ^~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> It is expected that pinctrl drivers can extend pin_config_param because
>> of the gap between PIN_CONFIG_END and PIN_CONFIG_MAX so this conversion
>> isn't an issue. Most drivers that take advantage of this define the
>> PIN_CONFIG variables as constants, rather than enumerated values. Do the
>> same thing here so that Clang no longer warns.
>>
>> Link: https://github.com/ClangBuiltLinux/linux/issues/139
>> Signed-off-by: Nathan Chancellor <[email protected]>
> Patch tentatively applied.
>
> This seems to be the direction we need to be going with a lot
> of CLANG business.
>
> Laxman: you weren't CCed, so tell us if you dislike it for some
> reason.
>
Looked changes and it is great. MISRA-C also happy with macros instead
of enum.

Acked-by: Laxman Dewangan <[email protected]>