Skip to content

Commit

Permalink
macintosh: windfarm: Use unsigned type for 1-bit bitfields
Browse files Browse the repository at this point in the history
[ Upstream commit 748ea32 ]

Clang warns:

  drivers/macintosh/windfarm_lm75_sensor.c:63:14: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                  lm->inited = 1;
                             ^ ~

  drivers/macintosh/windfarm_smu_sensors.c:356:19: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                  pow->fake_volts = 1;
                                  ^ ~
  drivers/macintosh/windfarm_smu_sensors.c:368:18: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion]
                  pow->quadratic = 1;
                                 ^ ~

There is no bug here since no code checks the actual value of these
fields, just whether or not they are zero (boolean context), but this
can be easily fixed by switching to an unsigned type.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230215-windfarm-wsingle-bit-bitfield-constant-conversion-v1-1-26415072e855@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
nathanchance authored and gregkh committed Mar 17, 2023
1 parent 3415ad5 commit e78f5ba
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions drivers/macintosh/windfarm_lm75_sensor.c
Expand Up @@ -33,8 +33,8 @@
#endif

struct wf_lm75_sensor {
int ds1775 : 1;
int inited : 1;
unsigned int ds1775 : 1;
unsigned int inited : 1;
struct i2c_client *i2c;
struct wf_sensor sens;
};
Expand Down
4 changes: 2 additions & 2 deletions drivers/macintosh/windfarm_smu_sensors.c
Expand Up @@ -274,8 +274,8 @@ struct smu_cpu_power_sensor {
struct list_head link;
struct wf_sensor *volts;
struct wf_sensor *amps;
int fake_volts : 1;
int quadratic : 1;
unsigned int fake_volts : 1;
unsigned int quadratic : 1;
struct wf_sensor sens;
};
#define to_smu_cpu_power(c) container_of(c, struct smu_cpu_power_sensor, sens)
Expand Down

0 comments on commit e78f5ba

Please sign in to comment.