* [PATCH] ACPI:Fix goto flows in thermal-sys
@ 2011-03-02 23:00 Durgadoss R
2011-03-23 5:54 ` Len Brown
0 siblings, 1 reply; 2+ messages in thread
From: Durgadoss R @ 2011-03-02 23:00 UTC (permalink / raw)
To: lenb, rui.zhang; +Cc: linux-acpi, Durgadoss R
This patch fixes two minor bugs in thermal_sys:
(a) The flow of goto's in thermal_hwmon_add_sysfs.
(b) Remove the temp*_crit only if there is a get_crit_temp defined, in
thermal_remove_hwmon_sysfs.
Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
---
drivers/thermal/thermal_sys.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 13c72c6..b826dfb 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -495,7 +495,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
dev_set_drvdata(hwmon->device, hwmon);
result = device_create_file(hwmon->device, &dev_attr_name);
if (result)
- goto unregister_hwmon_device;
+ goto free_mem;
register_sys_interface:
tz->hwmon = hwmon;
@@ -509,7 +509,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
sysfs_attr_init(&tz->temp_input.attr.attr);
result = device_create_file(hwmon->device, &tz->temp_input.attr);
if (result)
- goto unregister_hwmon_device;
+ goto unregister_name;
if (tz->ops->get_crit_temp) {
unsigned long temperature;
@@ -523,7 +523,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
result = device_create_file(hwmon->device,
&tz->temp_crit.attr);
if (result)
- goto unregister_hwmon_device;
+ goto unregister_input;
}
}
@@ -535,9 +535,9 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
return 0;
- unregister_hwmon_device:
- device_remove_file(hwmon->device, &tz->temp_crit.attr);
+ unregister_input:
device_remove_file(hwmon->device, &tz->temp_input.attr);
+ unregister_name:
if (new_hwmon_device) {
device_remove_file(hwmon->device, &dev_attr_name);
hwmon_device_unregister(hwmon->device);
@@ -556,7 +556,8 @@ thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
tz->hwmon = NULL;
device_remove_file(hwmon->device, &tz->temp_input.attr);
- device_remove_file(hwmon->device, &tz->temp_crit.attr);
+ if (tz->ops->get_crit_temp)
+ device_remove_file(hwmon->device, &tz->temp_crit.attr);
mutex_lock(&thermal_list_lock);
list_del(&tz->hwmon_node);
--
1.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ACPI:Fix goto flows in thermal-sys
2011-03-02 23:00 [PATCH] ACPI:Fix goto flows in thermal-sys Durgadoss R
@ 2011-03-23 5:54 ` Len Brown
0 siblings, 0 replies; 2+ messages in thread
From: Len Brown @ 2011-03-23 5:54 UTC (permalink / raw)
To: Durgadoss R; +Cc: rui.zhang, linux-acpi
On Thu, 3 Mar 2011, Durgadoss R wrote:
> This patch fixes two minor bugs in thermal_sys:
> (a) The flow of goto's in thermal_hwmon_add_sysfs.
> (b) Remove the temp*_crit only if there is a get_crit_temp defined, in
> thermal_remove_hwmon_sysfs.
2 patches for two logical changes, please.
> Signed-off-by: Durgadoss R <durgadoss.r@intel.com>
> ---
> drivers/thermal/thermal_sys.c | 13 +++++++------
> 1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
> index 13c72c6..b826dfb 100644
> --- a/drivers/thermal/thermal_sys.c
> +++ b/drivers/thermal/thermal_sys.c
> @@ -495,7 +495,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
> dev_set_drvdata(hwmon->device, hwmon);
> result = device_create_file(hwmon->device, &dev_attr_name);
> if (result)
> - goto unregister_hwmon_device;
> + goto free_mem;
hwmon_device_register() succeeded if we got here,
so why don't we need to hwmon_device_unregister() in the error path?
thanks,
-Len Brown, Intel Open Source Technology Center
> register_sys_interface:
> tz->hwmon = hwmon;
> @@ -509,7 +509,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
> sysfs_attr_init(&tz->temp_input.attr.attr);
> result = device_create_file(hwmon->device, &tz->temp_input.attr);
> if (result)
> - goto unregister_hwmon_device;
> + goto unregister_name;
>
> if (tz->ops->get_crit_temp) {
> unsigned long temperature;
> @@ -523,7 +523,7 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
> result = device_create_file(hwmon->device,
> &tz->temp_crit.attr);
> if (result)
> - goto unregister_hwmon_device;
> + goto unregister_input;
> }
> }
>
> @@ -535,9 +535,9 @@ thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
>
> return 0;
>
> - unregister_hwmon_device:
> - device_remove_file(hwmon->device, &tz->temp_crit.attr);
> + unregister_input:
> device_remove_file(hwmon->device, &tz->temp_input.attr);
> + unregister_name:
> if (new_hwmon_device) {
> device_remove_file(hwmon->device, &dev_attr_name);
> hwmon_device_unregister(hwmon->device);
> @@ -556,7 +556,8 @@ thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
>
> tz->hwmon = NULL;
> device_remove_file(hwmon->device, &tz->temp_input.attr);
> - device_remove_file(hwmon->device, &tz->temp_crit.attr);
> + if (tz->ops->get_crit_temp)
> + device_remove_file(hwmon->device, &tz->temp_crit.attr);
>
> mutex_lock(&thermal_list_lock);
> list_del(&tz->hwmon_node);
> --
> 1.7.4
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-23 5:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-02 23:00 [PATCH] ACPI:Fix goto flows in thermal-sys Durgadoss R
2011-03-23 5:54 ` Len Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox