Skip to contentSkip to conversation

hwmon: (ibmaem) Fix error paths

PATCH In review Jean Delvare 3 participants 3 messages Aug 20, 2011 – Aug 23, 2011 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/3 hwmon: (ibmaem) Fix error paths

From: Jean Delvare <[email protected]>
Subject: hwmon: (ibmaem) Fix error paths

I am under the impression that error paths in functions aem_init_aem1_inst() and aem_init_aem2_inst() are incorrect. In several cases, the function returns 0 on error, which I suspect is not intended. Fix this by properly tracking error codes.

Cc Darrick J. Wong <[email protected]>
Cc Guenter Roeck <[email protected]>

---
No change since v1.

 drivers/hwmon/ibmaem.c |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/hwmon/ibmaem.c +12 -8
@@ -602,24 +602,26 @@ static int aem_init_aem1_inst(struct aem
 	platform_set_drvdata(data->pdev, data);
 
 	/* Set up IPMI interface */
-	if (aem_init_ipmi_data(&data->ipmi, probe->interface,
-			       probe->bmc_device))
+	res = aem_init_ipmi_data(&data->ipmi, probe->interface,
+				 probe->bmc_device);
+	if (res)
 		goto ipmi_err;
 
 	/* Register with hwmon */
 	data->hwmon_dev = hwmon_device_register(&data->pdev->dev);
-
 	if (IS_ERR(data->hwmon_dev)) {
 		dev_err(&data->pdev->dev, "Unable to register hwmon "
 			"device for IPMI interface %d\n",
 			probe->interface);
+		res = PTR_ERR(data->hwmon_dev);
 		goto hwmon_reg_err;
 	}
 
 	data->update = update_aem1_sensors;
 
 	/* Find sensors */
-	if (aem1_find_sensors(data))
+	res = aem1_find_sensors(data);
+	if (res)
 		goto sensor_err;
 
 	/* Add to our list of AEM devices */
@@ -735,24 +737,26 @@ static int aem_init_aem2_inst(struct aem
 	platform_set_drvdata(data->pdev, data);
 
 	/* Set up IPMI interface */
-	if (aem_init_ipmi_data(&data->ipmi, probe->interface,
-			       probe->bmc_device))
+	res = aem_init_ipmi_data(&data->ipmi, probe->interface,
+				 probe->bmc_device);
+	if (res)
 		goto ipmi_err;
 
 	/* Register with hwmon */
 	data->hwmon_dev = hwmon_device_register(&data->pdev->dev);
-
 	if (IS_ERR(data->hwmon_dev)) {
 		dev_err(&data->pdev->dev, "Unable to register hwmon "
 			"device for IPMI interface %d\n",
 			probe->interface);
+		res = PTR_ERR(data->hwmon_dev);
 		goto hwmon_reg_err;
 	}
 
 	data->update = update_aem2_sensors;
 
 	/* Find sensors */
-	if (aem2_find_sensors(data))
+	res = aem2_find_sensors(data);
+	if (res)
 		goto sensor_err;
 
 	/* Add to our list of AEM devices */
Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Acked-by on v2 1/3
#1 lore raw
Quoted 11 lines · Jean Delvare

From: Jean Delvare <[email protected]>
Subject: hwmon: (ibmaem) Fix error paths

I am under the impression that error paths in functions aem_init_aem1_inst() and aem_init_aem2_inst() are incorrect. In several cases, the function returns 0 on error, which I suspect is not intended. Fix this by properly tracking error codes.

Cc Darrick J. Wong <[email protected]>
Cc Guenter Roeck <[email protected]>

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

Acked-by on v2 1/3
#2 lore raw
In reply to Jean Delvare
Quoted 9 lines · Guenter Roeck
Quoted 8 lines · Jean Delvare

From: Jean Delvare <[email protected]>
Subject: hwmon: (ibmaem) Fix error paths

I am under the impression that error paths in functions aem_init_aem1_inst() and aem_init_aem2_inst() are incorrect. In several cases, the function returns 0 on error, which I suspect is not intended. Fix this by properly tracking error codes.

Quoted 5 lines
Quoted 3 lines
Cc Darrick J. Wong <[email protected]>
Cc Guenter Roeck <[email protected]>

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors