Skip to content

Commit

Permalink
thermal: use ERR_PTR for returning error
Browse files Browse the repository at this point in the history
Need to return using ERR_PTR instead of NULL
in case of errors.

Signed-off-by: Thomas Sujith <sujith.thomas@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Thomas Sujith authored and Len Brown committed Feb 15, 2008
1 parent c751670 commit 3e6fda5
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions drivers/thermal/thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,20 +448,20 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type,
int result;

if (strlen(type) >= THERMAL_NAME_LENGTH)
return NULL;
return ERR_PTR(-EINVAL);

if (!ops || !ops->get_max_state || !ops->get_cur_state ||
!ops->set_cur_state)
return NULL;
return ERR_PTR(-EINVAL);

cdev = kzalloc(sizeof(struct thermal_cooling_device), GFP_KERNEL);
if (!cdev)
return NULL;
return ERR_PTR(-ENOMEM);

result = get_idr(&thermal_cdev_idr, &thermal_idr_lock, &cdev->id);
if (result) {
kfree(cdev);
return NULL;
return ERR_PTR(result);
}

strcpy(cdev->type, type);
Expand All @@ -473,7 +473,7 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type,
if (result) {
release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id);
kfree(cdev);
return NULL;
return ERR_PTR(result);
}

/* sys I/F */
Expand Down Expand Up @@ -509,7 +509,7 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type,
unregister:
release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id);
device_unregister(&cdev->device);
return NULL;
return ERR_PTR(result);
}

EXPORT_SYMBOL(thermal_cooling_device_register);
Expand Down Expand Up @@ -581,25 +581,25 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,
int count;

if (strlen(type) >= THERMAL_NAME_LENGTH)
return NULL;
return ERR_PTR(-EINVAL);

if (trips > THERMAL_MAX_TRIPS || trips < 0)
return NULL;
return ERR_PTR(-EINVAL);

if (!ops || !ops->get_temp)
return NULL;
return ERR_PTR(-EINVAL);

tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL);
if (!tz)
return NULL;
return ERR_PTR(-ENOMEM);

INIT_LIST_HEAD(&tz->cooling_devices);
idr_init(&tz->idr);
mutex_init(&tz->lock);
result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id);
if (result) {
kfree(tz);
return NULL;
return ERR_PTR(result);
}

strcpy(tz->type, type);
Expand All @@ -612,7 +612,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,
if (result) {
release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
kfree(tz);
return NULL;
return ERR_PTR(result);
}

/* sys I/F */
Expand Down Expand Up @@ -654,7 +654,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,
unregister:
release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
device_unregister(&tz->device);
return NULL;
return ERR_PTR(result);
}

EXPORT_SYMBOL(thermal_zone_device_register);
Expand Down

0 comments on commit 3e6fda5

Please sign in to comment.