Skip to content

Commit 7bd29bf

Browse files
committed
Merge tag 'hwmon-for-v6.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fixes from Guenter Roeck: - cgbc-hwmon: Add missing NULL check after devm_kzalloc - gpd-fan: Fix error handling - pmbus/isl68137: Fix child node reference leak - pmbus/max34440: Update adpm12160 coefficients to match latest FW - sht3x: Fix error handling * tag 'hwmon-for-v6.18-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: (sht3x) Fix error handling hwmon: (cgbc-hwmon) Add missing NULL check after devm_kzalloc() hwmon: (pmbus/isl68137) Fix child node reference leak on early return hwmon: (gpd-fan) Fix error handling in gpd_fan_probe() hwmon: (gpd-fan) Fix return value when platform_get_resource() fails hwmon: (pmbus/max34440) Update adpm12160 coeff due to latest FW
2 parents 58834e2 + 8dcc66a commit 7bd29bf

5 files changed

Lines changed: 32 additions & 23 deletions

File tree

drivers/hwmon/cgbc-hwmon.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ static int cgbc_hwmon_probe_sensors(struct device *dev, struct cgbc_hwmon_data *
107107
nb_sensors = data[0];
108108

109109
hwmon->sensors = devm_kzalloc(dev, sizeof(*hwmon->sensors) * nb_sensors, GFP_KERNEL);
110+
if (!hwmon->sensors)
111+
return -ENOMEM;
112+
110113
sensor = hwmon->sensors;
111114

112115
for (i = 0; i < nb_sensors; i++) {

drivers/hwmon/gpd-fan.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,14 @@ static int gpd_fan_probe(struct platform_device *pdev)
615615
const struct device *hwdev;
616616

617617
res = platform_get_resource(pdev, IORESOURCE_IO, 0);
618-
if (IS_ERR(res))
619-
return dev_err_probe(dev, PTR_ERR(res),
618+
if (!res)
619+
return dev_err_probe(dev, -EINVAL,
620620
"Failed to get platform resource\n");
621621

622622
region = devm_request_region(dev, res->start,
623623
resource_size(res), DRIVER_NAME);
624-
if (IS_ERR(region))
625-
return dev_err_probe(dev, PTR_ERR(region),
624+
if (!region)
625+
return dev_err_probe(dev, -EBUSY,
626626
"Failed to request region\n");
627627

628628
hwdev = devm_hwmon_device_register_with_info(dev,
@@ -631,7 +631,7 @@ static int gpd_fan_probe(struct platform_device *pdev)
631631
&gpd_fan_chip_info,
632632
NULL);
633633
if (IS_ERR(hwdev))
634-
return dev_err_probe(dev, PTR_ERR(region),
634+
return dev_err_probe(dev, PTR_ERR(hwdev),
635635
"Failed to register hwmon device\n");
636636

637637
return 0;

drivers/hwmon/pmbus/isl68137.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,9 @@ static int isl68137_probe_from_dt(struct device *dev,
336336
struct isl68137_data *data)
337337
{
338338
const struct device_node *np = dev->of_node;
339-
struct device_node *child;
340339
int err;
341340

342-
for_each_child_of_node(np, child) {
341+
for_each_child_of_node_scoped(np, child) {
343342
if (strcmp(child->name, "channel"))
344343
continue;
345344

drivers/hwmon/pmbus/max34440.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,18 +336,18 @@ static struct pmbus_driver_info max34440_info[] = {
336336
.format[PSC_CURRENT_IN] = direct,
337337
.format[PSC_CURRENT_OUT] = direct,
338338
.format[PSC_TEMPERATURE] = direct,
339-
.m[PSC_VOLTAGE_IN] = 1,
339+
.m[PSC_VOLTAGE_IN] = 125,
340340
.b[PSC_VOLTAGE_IN] = 0,
341341
.R[PSC_VOLTAGE_IN] = 0,
342-
.m[PSC_VOLTAGE_OUT] = 1,
342+
.m[PSC_VOLTAGE_OUT] = 125,
343343
.b[PSC_VOLTAGE_OUT] = 0,
344344
.R[PSC_VOLTAGE_OUT] = 0,
345-
.m[PSC_CURRENT_IN] = 1,
345+
.m[PSC_CURRENT_IN] = 250,
346346
.b[PSC_CURRENT_IN] = 0,
347-
.R[PSC_CURRENT_IN] = 2,
348-
.m[PSC_CURRENT_OUT] = 1,
347+
.R[PSC_CURRENT_IN] = -1,
348+
.m[PSC_CURRENT_OUT] = 250,
349349
.b[PSC_CURRENT_OUT] = 0,
350-
.R[PSC_CURRENT_OUT] = 2,
350+
.R[PSC_CURRENT_OUT] = -1,
351351
.m[PSC_TEMPERATURE] = 1,
352352
.b[PSC_TEMPERATURE] = 0,
353353
.R[PSC_TEMPERATURE] = 2,

drivers/hwmon/sht3x.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -291,24 +291,26 @@ static struct sht3x_data *sht3x_update_client(struct device *dev)
291291
return data;
292292
}
293293

294-
static int temp1_input_read(struct device *dev)
294+
static int temp1_input_read(struct device *dev, long *temp)
295295
{
296296
struct sht3x_data *data = sht3x_update_client(dev);
297297

298298
if (IS_ERR(data))
299299
return PTR_ERR(data);
300300

301-
return data->temperature;
301+
*temp = data->temperature;
302+
return 0;
302303
}
303304

304-
static int humidity1_input_read(struct device *dev)
305+
static int humidity1_input_read(struct device *dev, long *humidity)
305306
{
306307
struct sht3x_data *data = sht3x_update_client(dev);
307308

308309
if (IS_ERR(data))
309310
return PTR_ERR(data);
310311

311-
return data->humidity;
312+
*humidity = data->humidity;
313+
return 0;
312314
}
313315

314316
/*
@@ -706,6 +708,7 @@ static int sht3x_read(struct device *dev, enum hwmon_sensor_types type,
706708
u32 attr, int channel, long *val)
707709
{
708710
enum sht3x_limits index;
711+
int ret;
709712

710713
switch (type) {
711714
case hwmon_chip:
@@ -720,10 +723,12 @@ static int sht3x_read(struct device *dev, enum hwmon_sensor_types type,
720723
case hwmon_temp:
721724
switch (attr) {
722725
case hwmon_temp_input:
723-
*val = temp1_input_read(dev);
724-
break;
726+
return temp1_input_read(dev, val);
725727
case hwmon_temp_alarm:
726-
*val = temp1_alarm_read(dev);
728+
ret = temp1_alarm_read(dev);
729+
if (ret < 0)
730+
return ret;
731+
*val = ret;
727732
break;
728733
case hwmon_temp_max:
729734
index = limit_max;
@@ -748,10 +753,12 @@ static int sht3x_read(struct device *dev, enum hwmon_sensor_types type,
748753
case hwmon_humidity:
749754
switch (attr) {
750755
case hwmon_humidity_input:
751-
*val = humidity1_input_read(dev);
752-
break;
756+
return humidity1_input_read(dev, val);
753757
case hwmon_humidity_alarm:
754-
*val = humidity1_alarm_read(dev);
758+
ret = humidity1_alarm_read(dev);
759+
if (ret < 0)
760+
return ret;
761+
*val = ret;
755762
break;
756763
case hwmon_humidity_max:
757764
index = limit_max;

0 commit comments

Comments
 (0)