* [PATCH] hwmon: Mark expected switch fall-throughs
@ 2018-07-02 21:30 Gustavo A. R. Silva
2018-07-03 7:51 ` Jean Delvare
2018-07-03 16:13 ` Guenter Roeck
0 siblings, 2 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-07-02 21:30 UTC (permalink / raw)
To: Jean Delvare, Guenter Roeck
Cc: linux-hwmon, linux-kernel, Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases
where we are expecting to fall through.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/hwmon/emc1403.c | 2 ++
drivers/hwmon/nct6775.c | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
index 1ea7ca5..aaebeb7 100644
--- a/drivers/hwmon/emc1403.c
+++ b/drivers/hwmon/emc1403.c
@@ -443,8 +443,10 @@ static int emc1403_probe(struct i2c_client *client,
switch (id->driver_data) {
case emc1404:
data->groups[2] = &emc1404_group;
+ /* fall through */
case emc1403:
data->groups[1] = &emc1403_group;
+ /* fall through */
case emc1402:
data->groups[0] = &emc1402_group;
}
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
index 3714990..c6bd61e 100644
--- a/drivers/hwmon/nct6775.c
+++ b/drivers/hwmon/nct6775.c
@@ -2541,7 +2541,7 @@ static void pwm_update_registers(struct nct6775_data *data, int nr)
case thermal_cruise:
nct6775_write_value(data, data->REG_TARGET[nr],
data->target_temp[nr]);
- /* intentional */
+ /* fall through */
default:
reg = nct6775_read_value(data, data->REG_FAN_MODE[nr]);
reg = (reg & ~data->tolerance_mask) |
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] hwmon: Mark expected switch fall-throughs
2018-07-02 21:30 [PATCH] hwmon: Mark expected switch fall-throughs Gustavo A. R. Silva
@ 2018-07-03 7:51 ` Jean Delvare
2018-07-03 17:20 ` Gustavo A. R. Silva
2018-07-03 16:13 ` Guenter Roeck
1 sibling, 1 reply; 4+ messages in thread
From: Jean Delvare @ 2018-07-03 7:51 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: Guenter Roeck, linux-hwmon, linux-kernel
Hi Gustavo,
On Mon, 2 Jul 2018 16:30:17 -0500, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
That's a great initiative, thanks for doing that.
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/hwmon/emc1403.c | 2 ++
> drivers/hwmon/nct6775.c | 2 +-
> 2 files changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
> index 1ea7ca5..aaebeb7 100644
> --- a/drivers/hwmon/emc1403.c
> +++ b/drivers/hwmon/emc1403.c
> @@ -443,8 +443,10 @@ static int emc1403_probe(struct i2c_client *client,
> switch (id->driver_data) {
> case emc1404:
> data->groups[2] = &emc1404_group;
> + /* fall through */
> case emc1403:
> data->groups[1] = &emc1403_group;
> + /* fall through */
> case emc1402:
> data->groups[0] = &emc1402_group;
> }
> diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
> index 3714990..c6bd61e 100644
> --- a/drivers/hwmon/nct6775.c
> +++ b/drivers/hwmon/nct6775.c
> @@ -2541,7 +2541,7 @@ static void pwm_update_registers(struct nct6775_data *data, int nr)
> case thermal_cruise:
> nct6775_write_value(data, data->REG_TARGET[nr],
> data->target_temp[nr]);
> - /* intentional */
> + /* fall through */
Do you know which -Wimplicit-fallthrough level we will be using? Level
1 would be happy with the initial comment, no change would be needed.
If level 2-4 then yes the change is needed.
> default:
> reg = nct6775_read_value(data, data->REG_FAN_MODE[nr]);
> reg = (reg & ~data->tolerance_mask) |
Reviewed-by: Jean Delvare <jdelvare@suse.de>
--
Jean Delvare
SUSE L3 Support
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: hwmon: Mark expected switch fall-throughs
2018-07-02 21:30 [PATCH] hwmon: Mark expected switch fall-throughs Gustavo A. R. Silva
2018-07-03 7:51 ` Jean Delvare
@ 2018-07-03 16:13 ` Guenter Roeck
1 sibling, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2018-07-03 16:13 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: Jean Delvare, linux-hwmon, linux-kernel
On Mon, Jul 02, 2018 at 04:30:17PM -0500, Gustavo A. R. Silva wrote:
> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
> where we are expecting to fall through.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> Reviewed-by: Jean Delvare <jdelvare@suse.de>
Applied to hwmon-next.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] hwmon: Mark expected switch fall-throughs
2018-07-03 7:51 ` Jean Delvare
@ 2018-07-03 17:20 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2018-07-03 17:20 UTC (permalink / raw)
To: Jean Delvare; +Cc: Guenter Roeck, linux-hwmon, linux-kernel
Hi Jean,
On 07/03/2018 02:51 AM, Jean Delvare wrote:
> Hi Gustavo,
>
> On Mon, 2 Jul 2018 16:30:17 -0500, Gustavo A. R. Silva wrote:
>> In preparation to enabling -Wimplicit-fallthrough, mark switch cases
>> where we are expecting to fall through.
>
> That's a great initiative, thanks for doing that.
>
Glad to help. :)
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> drivers/hwmon/emc1403.c | 2 ++
>> drivers/hwmon/nct6775.c | 2 +-
>> 2 files changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/hwmon/emc1403.c b/drivers/hwmon/emc1403.c
>> index 1ea7ca5..aaebeb7 100644
>> --- a/drivers/hwmon/emc1403.c
>> +++ b/drivers/hwmon/emc1403.c
>> @@ -443,8 +443,10 @@ static int emc1403_probe(struct i2c_client *client,
>> switch (id->driver_data) {
>> case emc1404:
>> data->groups[2] = &emc1404_group;
>> + /* fall through */
>> case emc1403:
>> data->groups[1] = &emc1403_group;
>> + /* fall through */
>> case emc1402:
>> data->groups[0] = &emc1402_group;
>> }
>> diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
>> index 3714990..c6bd61e 100644
>> --- a/drivers/hwmon/nct6775.c
>> +++ b/drivers/hwmon/nct6775.c
>> @@ -2541,7 +2541,7 @@ static void pwm_update_registers(struct nct6775_data *data, int nr)
>> case thermal_cruise:
>> nct6775_write_value(data, data->REG_TARGET[nr],
>> data->target_temp[nr]);
>> - /* intentional */
>> + /* fall through */
>
> Do you know which -Wimplicit-fallthrough level we will be using? Level
> 1 would be happy with the initial comment, no change would be needed.
> If level 2-4 then yes the change is needed.
>
We are trying level 2, so we can perfectly use annotations like this one (else: fall through):
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=9b10000f4921e9f9f8231f9ceecae4446928844a
>> default:
>> reg = nct6775_read_value(data, data->REG_FAN_MODE[nr]);
>> reg = (reg & ~data->tolerance_mask) |
>
> Reviewed-by: Jean Delvare <jdelvare@suse.de>
>
Thanks
--
Gustavo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-03 17:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-02 21:30 [PATCH] hwmon: Mark expected switch fall-throughs Gustavo A. R. Silva
2018-07-03 7:51 ` Jean Delvare
2018-07-03 17:20 ` Gustavo A. R. Silva
2018-07-03 16:13 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox