hwmon: (adt7475) Use enum chips when loading attenuator settings
Make use of enum chips and use a switch statement in load_attenuators() so that the compiler can tell us if we've failed to cater for a supported chip. Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Link: https://lore.kernel.org/r/20220323034056.260455-4-chris.packham@alliedtelesis.co.nz Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
7b8664f126
commit
d45cd80428
@ -1569,12 +1569,12 @@ static int set_property_bit(const struct i2c_client *client, char *property,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int load_attenuators(const struct i2c_client *client, int chip,
|
static int load_attenuators(const struct i2c_client *client, enum chips chip,
|
||||||
struct adt7475_data *data)
|
struct adt7475_data *data)
|
||||||
{
|
{
|
||||||
int ret;
|
switch (chip) {
|
||||||
|
case adt7476:
|
||||||
if (chip == adt7476 || chip == adt7490) {
|
case adt7490:
|
||||||
set_property_bit(client, "adi,bypass-attenuator-in0",
|
set_property_bit(client, "adi,bypass-attenuator-in0",
|
||||||
&data->config4, 4);
|
&data->config4, 4);
|
||||||
set_property_bit(client, "adi,bypass-attenuator-in1",
|
set_property_bit(client, "adi,bypass-attenuator-in1",
|
||||||
@ -1584,18 +1584,15 @@ static int load_attenuators(const struct i2c_client *client, int chip,
|
|||||||
set_property_bit(client, "adi,bypass-attenuator-in4",
|
set_property_bit(client, "adi,bypass-attenuator-in4",
|
||||||
&data->config4, 7);
|
&data->config4, 7);
|
||||||
|
|
||||||
ret = i2c_smbus_write_byte_data(client, REG_CONFIG4,
|
return i2c_smbus_write_byte_data(client, REG_CONFIG4,
|
||||||
data->config4);
|
data->config4);
|
||||||
if (ret < 0)
|
case adt7473:
|
||||||
return ret;
|
case adt7475:
|
||||||
} else if (chip == adt7473 || chip == adt7475) {
|
|
||||||
set_property_bit(client, "adi,bypass-attenuator-in1",
|
set_property_bit(client, "adi,bypass-attenuator-in1",
|
||||||
&data->config2, 5);
|
&data->config2, 5);
|
||||||
|
|
||||||
ret = i2c_smbus_write_byte_data(client, REG_CONFIG2,
|
return i2c_smbus_write_byte_data(client, REG_CONFIG2,
|
||||||
data->config2);
|
data->config2);
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user