mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
hwmon: (tmp513) Simplify with dev_err_probe()
[ Upstream commit df989762bc4b71068e6adc0c2b5ef6f76b6acf74 ] Common pattern of handling deferred probe can be simplified with dev_err_probe(). Less code and also it prints the error value. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20231128180654.395692-3-andriy.shevchenko@linux.intel.com [groeck: Fixed excessive line length] Signed-off-by: Guenter Roeck <linux@roeck-us.net> Stable-dep-of: 74d7e038fd07 ("hwmon: (tmp513) Fix interpretation of values of Shunt Voltage and Limit Registers") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d2aa3d5014
commit
7df25973b6
@@ -632,9 +632,9 @@ static int tmp51x_vbus_range_to_reg(struct device *dev,
|
|||||||
} else if (data->vbus_range_uvolt == TMP51X_VBUS_RANGE_16V) {
|
} else if (data->vbus_range_uvolt == TMP51X_VBUS_RANGE_16V) {
|
||||||
data->shunt_config &= ~TMP51X_BUS_VOLTAGE_MASK;
|
data->shunt_config &= ~TMP51X_BUS_VOLTAGE_MASK;
|
||||||
} else {
|
} else {
|
||||||
dev_err(dev, "ti,bus-range-microvolt is invalid: %u\n",
|
return dev_err_probe(dev, -EINVAL,
|
||||||
data->vbus_range_uvolt);
|
"ti,bus-range-microvolt is invalid: %u\n",
|
||||||
return -EINVAL;
|
data->vbus_range_uvolt);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -650,8 +650,8 @@ static int tmp51x_pga_gain_to_reg(struct device *dev, struct tmp51x_data *data)
|
|||||||
} else if (data->pga_gain == 1) {
|
} else if (data->pga_gain == 1) {
|
||||||
data->shunt_config |= CURRENT_SENSE_VOLTAGE_40_MASK;
|
data->shunt_config |= CURRENT_SENSE_VOLTAGE_40_MASK;
|
||||||
} else {
|
} else {
|
||||||
dev_err(dev, "ti,pga-gain is invalid: %u\n", data->pga_gain);
|
return dev_err_probe(dev, -EINVAL,
|
||||||
return -EINVAL;
|
"ti,pga-gain is invalid: %u\n", data->pga_gain);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -684,9 +684,9 @@ static int tmp51x_read_properties(struct device *dev, struct tmp51x_data *data)
|
|||||||
|
|
||||||
// Check if shunt value is compatible with pga-gain
|
// Check if shunt value is compatible with pga-gain
|
||||||
if (data->shunt_uohms > data->pga_gain * 40 * 1000 * 1000) {
|
if (data->shunt_uohms > data->pga_gain * 40 * 1000 * 1000) {
|
||||||
dev_err(dev, "shunt-resistor: %u too big for pga_gain: %u\n",
|
return dev_err_probe(dev, -EINVAL,
|
||||||
data->shunt_uohms, data->pga_gain);
|
"shunt-resistor: %u too big for pga_gain: %u\n",
|
||||||
return -EINVAL;
|
data->shunt_uohms, data->pga_gain);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -730,22 +730,17 @@ static int tmp51x_probe(struct i2c_client *client)
|
|||||||
data->id = i2c_match_id(tmp51x_id, client)->driver_data;
|
data->id = i2c_match_id(tmp51x_id, client)->driver_data;
|
||||||
|
|
||||||
ret = tmp51x_configure(dev, data);
|
ret = tmp51x_configure(dev, data);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
dev_err(dev, "error configuring the device: %d\n", ret);
|
return dev_err_probe(dev, ret, "error configuring the device\n");
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->regmap = devm_regmap_init_i2c(client, &tmp51x_regmap_config);
|
data->regmap = devm_regmap_init_i2c(client, &tmp51x_regmap_config);
|
||||||
if (IS_ERR(data->regmap)) {
|
if (IS_ERR(data->regmap))
|
||||||
dev_err(dev, "failed to allocate register map\n");
|
return dev_err_probe(dev, PTR_ERR(data->regmap),
|
||||||
return PTR_ERR(data->regmap);
|
"failed to allocate register map\n");
|
||||||
}
|
|
||||||
|
|
||||||
ret = tmp51x_init(data);
|
ret = tmp51x_init(data);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
dev_err(dev, "error configuring the device: %d\n", ret);
|
return dev_err_probe(dev, ret, "error configuring the device\n");
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name,
|
hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name,
|
||||||
data,
|
data,
|
||||||
|
|||||||
Reference in New Issue
Block a user