diff options
author | Eduardo Valentin <eduardo.valentin@ti.com> | 2013-05-29 15:07:43 +0000 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2013-06-13 10:14:00 +0800 |
commit | 0c12b5ac82fbae6903237997677c228089569ace (patch) | |
tree | 8e5b4f2d22f90cdc8959d98796cc0110963d5a95 /drivers/thermal/ti-soc-thermal/ti-thermal-common.c | |
parent | ba0049eacc59831f4018060dc30fb7c818421a75 (diff) |
thermal: ti-soc-thermal: remove usage of IS_ERR_OR_NULL
This patch changes the driver to avoid the usage of IS_ERR_OR_NULL()
macro. This macro can lead to dangerous results, like returning
success (0) during a failure scenario (NULL pointer handling).
For this reason this patch is changing the driver after
revisiting the code. These are the cases:
i. For cases in which IS_ERR_OR_NULL() is used for checking
return values of functions that returns either PTR_ERR()
or a valid pointer, it has been translated to IS_ERR() check only.
ii. For cases that a NULL check is still needed, it has been
translated to if (!ptr || IS_ERR(ptr)).
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal/ti-soc-thermal/ti-thermal-common.c')
-rw-r--r-- | drivers/thermal/ti-soc-thermal/ti-thermal-common.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c index 8e67ebf98404..4c5f55c37349 100644 --- a/drivers/thermal/ti-soc-thermal/ti-thermal-common.c +++ b/drivers/thermal/ti-soc-thermal/ti-thermal-common.c @@ -101,7 +101,7 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal, pcb_tz = data->pcb_tz; /* In case pcb zone is available, use the extrapolation rule with it */ - if (!IS_ERR_OR_NULL(pcb_tz)) { + if (!IS_ERR(pcb_tz)) { ret = thermal_zone_get_temp(pcb_tz, &pcb_temp); if (!ret) { tmp -= pcb_temp; /* got a valid PCB temp */ @@ -124,7 +124,7 @@ static int ti_thermal_bind(struct thermal_zone_device *thermal, struct ti_thermal_data *data = thermal->devdata; int id; - if (IS_ERR_OR_NULL(data)) + if (!data || IS_ERR(data)) return -ENODEV; /* check if this is the cooling device we registered */ @@ -146,7 +146,7 @@ static int ti_thermal_unbind(struct thermal_zone_device *thermal, { struct ti_thermal_data *data = thermal->devdata; - if (IS_ERR_OR_NULL(data)) + if (!data || IS_ERR(data)) return -ENODEV; /* check if this is the cooling device we registered */ @@ -282,6 +282,7 @@ static struct ti_thermal_data data->sensor_id = id; data->bgp = bgp; data->mode = THERMAL_DEVICE_ENABLED; + /* pcb_tz will be either valid or PTR_ERR() */ data->pcb_tz = thermal_zone_get_zone_by_name("pcb"); INIT_WORK(&data->thermal_wq, ti_thermal_work); @@ -295,7 +296,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id, data = ti_bandgap_get_sensor_data(bgp, id); - if (IS_ERR_OR_NULL(data)) + if (!data || IS_ERR(data)) data = ti_thermal_build_data(bgp, id); if (!data) @@ -306,7 +307,7 @@ int ti_thermal_expose_sensor(struct ti_bandgap *bgp, int id, OMAP_TRIP_NUMBER, 0, data, &ti_thermal_ops, NULL, FAST_TEMP_MONITORING_RATE, FAST_TEMP_MONITORING_RATE); - if (IS_ERR_OR_NULL(data->ti_thermal)) { + if (IS_ERR(data->ti_thermal)) { dev_err(bgp->dev, "thermal zone device is NULL\n"); return PTR_ERR(data->ti_thermal); } @@ -343,7 +344,7 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id) struct ti_thermal_data *data; data = ti_bandgap_get_sensor_data(bgp, id); - if (IS_ERR_OR_NULL(data)) + if (!data || IS_ERR(data)) data = ti_thermal_build_data(bgp, id); if (!data) @@ -356,7 +357,7 @@ int ti_thermal_register_cpu_cooling(struct ti_bandgap *bgp, int id) /* Register cooling device */ data->cool_dev = cpufreq_cooling_register(cpu_present_mask); - if (IS_ERR_OR_NULL(data->cool_dev)) { + if (IS_ERR(data->cool_dev)) { dev_err(bgp->dev, "Failed to register cpufreq cooling device\n"); return PTR_ERR(data->cool_dev); |