diff options
author | Thomas Sujith <sujith.thomas@intel.com> | 2008-02-15 00:59:50 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2008-02-15 18:21:30 -0500 |
commit | 3e6fda5c1159823fc02463eceb564c8bfc0e7a0e (patch) | |
tree | 38af580a57b553a902db25ec1401d8005885981d | |
parent | c751670902c3dd9abbed279170a832e6a1e6cf94 (diff) |
thermal: use ERR_PTR for returning error
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>
-rw-r--r-- | drivers/thermal/thermal.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/thermal/thermal.c b/drivers/thermal/thermal.c index 5f1d318f0574..8b86e53ccf7a 100644 --- a/drivers/thermal/thermal.c +++ b/drivers/thermal/thermal.c | |||
@@ -448,20 +448,20 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type, | |||
448 | int result; | 448 | int result; |
449 | 449 | ||
450 | if (strlen(type) >= THERMAL_NAME_LENGTH) | 450 | if (strlen(type) >= THERMAL_NAME_LENGTH) |
451 | return NULL; | 451 | return ERR_PTR(-EINVAL); |
452 | 452 | ||
453 | if (!ops || !ops->get_max_state || !ops->get_cur_state || | 453 | if (!ops || !ops->get_max_state || !ops->get_cur_state || |
454 | !ops->set_cur_state) | 454 | !ops->set_cur_state) |
455 | return NULL; | 455 | return ERR_PTR(-EINVAL); |
456 | 456 | ||
457 | cdev = kzalloc(sizeof(struct thermal_cooling_device), GFP_KERNEL); | 457 | cdev = kzalloc(sizeof(struct thermal_cooling_device), GFP_KERNEL); |
458 | if (!cdev) | 458 | if (!cdev) |
459 | return NULL; | 459 | return ERR_PTR(-ENOMEM); |
460 | 460 | ||
461 | result = get_idr(&thermal_cdev_idr, &thermal_idr_lock, &cdev->id); | 461 | result = get_idr(&thermal_cdev_idr, &thermal_idr_lock, &cdev->id); |
462 | if (result) { | 462 | if (result) { |
463 | kfree(cdev); | 463 | kfree(cdev); |
464 | return NULL; | 464 | return ERR_PTR(result); |
465 | } | 465 | } |
466 | 466 | ||
467 | strcpy(cdev->type, type); | 467 | strcpy(cdev->type, type); |
@@ -473,7 +473,7 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type, | |||
473 | if (result) { | 473 | if (result) { |
474 | release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); | 474 | release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); |
475 | kfree(cdev); | 475 | kfree(cdev); |
476 | return NULL; | 476 | return ERR_PTR(result); |
477 | } | 477 | } |
478 | 478 | ||
479 | /* sys I/F */ | 479 | /* sys I/F */ |
@@ -509,7 +509,7 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *type, | |||
509 | unregister: | 509 | unregister: |
510 | release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); | 510 | release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id); |
511 | device_unregister(&cdev->device); | 511 | device_unregister(&cdev->device); |
512 | return NULL; | 512 | return ERR_PTR(result); |
513 | } | 513 | } |
514 | 514 | ||
515 | EXPORT_SYMBOL(thermal_cooling_device_register); | 515 | EXPORT_SYMBOL(thermal_cooling_device_register); |
@@ -581,17 +581,17 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, | |||
581 | int count; | 581 | int count; |
582 | 582 | ||
583 | if (strlen(type) >= THERMAL_NAME_LENGTH) | 583 | if (strlen(type) >= THERMAL_NAME_LENGTH) |
584 | return NULL; | 584 | return ERR_PTR(-EINVAL); |
585 | 585 | ||
586 | if (trips > THERMAL_MAX_TRIPS || trips < 0) | 586 | if (trips > THERMAL_MAX_TRIPS || trips < 0) |
587 | return NULL; | 587 | return ERR_PTR(-EINVAL); |
588 | 588 | ||
589 | if (!ops || !ops->get_temp) | 589 | if (!ops || !ops->get_temp) |
590 | return NULL; | 590 | return ERR_PTR(-EINVAL); |
591 | 591 | ||
592 | tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL); | 592 | tz = kzalloc(sizeof(struct thermal_zone_device), GFP_KERNEL); |
593 | if (!tz) | 593 | if (!tz) |
594 | return NULL; | 594 | return ERR_PTR(-ENOMEM); |
595 | 595 | ||
596 | INIT_LIST_HEAD(&tz->cooling_devices); | 596 | INIT_LIST_HEAD(&tz->cooling_devices); |
597 | idr_init(&tz->idr); | 597 | idr_init(&tz->idr); |
@@ -599,7 +599,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, | |||
599 | result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id); | 599 | result = get_idr(&thermal_tz_idr, &thermal_idr_lock, &tz->id); |
600 | if (result) { | 600 | if (result) { |
601 | kfree(tz); | 601 | kfree(tz); |
602 | return NULL; | 602 | return ERR_PTR(result); |
603 | } | 603 | } |
604 | 604 | ||
605 | strcpy(tz->type, type); | 605 | strcpy(tz->type, type); |
@@ -612,7 +612,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, | |||
612 | if (result) { | 612 | if (result) { |
613 | release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); | 613 | release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); |
614 | kfree(tz); | 614 | kfree(tz); |
615 | return NULL; | 615 | return ERR_PTR(result); |
616 | } | 616 | } |
617 | 617 | ||
618 | /* sys I/F */ | 618 | /* sys I/F */ |
@@ -654,7 +654,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, | |||
654 | unregister: | 654 | unregister: |
655 | release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); | 655 | release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); |
656 | device_unregister(&tz->device); | 656 | device_unregister(&tz->device); |
657 | return NULL; | 657 | return ERR_PTR(result); |
658 | } | 658 | } |
659 | 659 | ||
660 | EXPORT_SYMBOL(thermal_zone_device_register); | 660 | EXPORT_SYMBOL(thermal_zone_device_register); |