X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fthermal%2Fthermal.c;h=7f79bbf652d7483c1a11f1b793973f0eddf345f4;hb=f5c90e85dc77669a55fecfb593bb8e7f47374ee2;hp=3273e348fd14584d1173001b12688eb2ce3c1e14;hpb=f0f1b3364ae7f48084bdf2837fb979ff59622523;p=linux-2.6 diff --git a/drivers/thermal/thermal.c b/drivers/thermal/thermal.c index 3273e348fd..7f79bbf652 100644 --- a/drivers/thermal/thermal.c +++ b/drivers/thermal/thermal.c @@ -196,6 +196,10 @@ static struct device_attribute trip_point_attrs[] = { __ATTR(trip_point_8_temp, 0444, trip_point_temp_show, NULL), __ATTR(trip_point_9_type, 0444, trip_point_type_show, NULL), __ATTR(trip_point_9_temp, 0444, trip_point_temp_show, NULL), + __ATTR(trip_point_10_type, 0444, trip_point_type_show, NULL), + __ATTR(trip_point_10_temp, 0444, trip_point_temp_show, NULL), + __ATTR(trip_point_11_type, 0444, trip_point_type_show, NULL), + __ATTR(trip_point_11_temp, 0444, trip_point_temp_show, NULL), }; #define TRIP_POINT_ATTR_ADD(_dev, _index, result) \ @@ -267,7 +271,7 @@ thermal_cooling_device_cur_state_store(struct device *dev, } static struct device_attribute dev_attr_cdev_type = - __ATTR(type, 0444, thermal_cooling_device_type_show, NULL); +__ATTR(type, 0444, thermal_cooling_device_type_show, NULL); static DEVICE_ATTR(max_state, 0444, thermal_cooling_device_max_state_show, NULL); static DEVICE_ATTR(cur_state, 0644, @@ -276,7 +280,7 @@ static DEVICE_ATTR(cur_state, 0644, static ssize_t thermal_cooling_device_trip_point_show(struct device *dev, - struct device_attribute *attr, char *buf) + struct device_attribute *attr, char *buf) { struct thermal_cooling_device_instance *instance; @@ -293,11 +297,12 @@ thermal_cooling_device_trip_point_show(struct device *dev, /** * thermal_zone_bind_cooling_device - bind a cooling device to a thermal zone - * this function is usually called in the thermal zone device .bind callback. * @tz: thermal zone device * @trip: indicates which trip point the cooling devices is * associated with in this thermal zone. * @cdev: thermal cooling device + * + * This function is usually called in the thermal zone device .bind callback. */ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, int trip, @@ -305,13 +310,23 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, { struct thermal_cooling_device_instance *dev; struct thermal_cooling_device_instance *pos; + struct thermal_zone_device *pos1; + struct thermal_cooling_device *pos2; int result; - if (trip >= tz->trips || - (trip < 0 && trip != THERMAL_TRIPS_NONE)) + if (trip >= tz->trips || (trip < 0 && trip != THERMAL_TRIPS_NONE)) return -EINVAL; - if (!tz || !cdev) + list_for_each_entry(pos1, &thermal_tz_list, node) { + if (pos1 == tz) + break; + } + list_for_each_entry(pos2, &thermal_cdev_list, node) { + if (pos2 == cdev) + break; + } + + if (tz != pos1 || cdev != pos2) return -EINVAL; dev = @@ -361,15 +376,17 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, kfree(dev); return result; } + EXPORT_SYMBOL(thermal_zone_bind_cooling_device); /** * thermal_zone_unbind_cooling_device - unbind a cooling device from a thermal zone - * this function is usually called in the thermal zone device .unbind callback. * @tz: thermal zone device * @trip: indicates which trip point the cooling devices is * associated with in this thermal zone. * @cdev: thermal cooling device + * + * This function is usually called in the thermal zone device .unbind callback. */ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, int trip, @@ -379,8 +396,7 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, mutex_lock(&tz->lock); list_for_each_entry_safe(pos, next, &tz->cooling_devices, node) { - if (pos->tz == tz && pos->trip == trip - && pos->cdev == cdev) { + if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) { list_del(&pos->node); mutex_unlock(&tz->lock); goto unbind; @@ -397,6 +413,7 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, kfree(pos); return 0; } + EXPORT_SYMBOL(thermal_zone_unbind_cooling_device); static void thermal_release(struct device *dev) @@ -425,27 +442,30 @@ static struct class thermal_class = { * @ops: standard thermal cooling devices callbacks. */ struct thermal_cooling_device *thermal_cooling_device_register(char *type, - void *devdata, struct thermal_cooling_device_ops *ops) + void *devdata, + struct + thermal_cooling_device_ops + *ops) { struct thermal_cooling_device *cdev; struct thermal_zone_device *pos; 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; + !ops->set_cur_state) + 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); @@ -457,13 +477,12 @@ 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 */ if (type) { - result = device_create_file(&cdev->device, - &dev_attr_cdev_type); + result = device_create_file(&cdev->device, &dev_attr_cdev_type); if (result) goto unregister; } @@ -494,13 +513,13 @@ 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); /** * thermal_cooling_device_unregister - removes the registered thermal cooling device - * * @cdev: the thermal cooling device to remove. * * thermal_cooling_device_unregister() must be called when the device is no @@ -533,8 +552,7 @@ void thermal_cooling_device_unregister(struct } mutex_unlock(&thermal_list_lock); if (cdev->type[0]) - device_remove_file(&cdev->device, - &dev_attr_cdev_type); + device_remove_file(&cdev->device, &dev_attr_cdev_type); device_remove_file(&cdev->device, &dev_attr_max_state); device_remove_file(&cdev->device, &dev_attr_cur_state); @@ -542,6 +560,7 @@ void thermal_cooling_device_unregister(struct device_unregister(&cdev->device); return; } + EXPORT_SYMBOL(thermal_cooling_device_unregister); /** @@ -555,8 +574,10 @@ EXPORT_SYMBOL(thermal_cooling_device_unregister); * longer needed. */ struct thermal_zone_device *thermal_zone_device_register(char *type, - int trips, void *devdata, - struct thermal_zone_device_ops *ops) + int trips, + void *devdata, struct + thermal_zone_device_ops + *ops) { struct thermal_zone_device *tz; struct thermal_cooling_device *pos; @@ -564,17 +585,17 @@ 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); @@ -582,7 +603,7 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, 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); @@ -595,7 +616,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 */ @@ -625,9 +646,9 @@ struct thermal_zone_device *thermal_zone_device_register(char *type, list_add_tail(&tz->node, &thermal_tz_list); if (ops->bind) list_for_each_entry(pos, &thermal_cdev_list, node) { - result = ops->bind(tz, pos); - if (result) - break; + result = ops->bind(tz, pos); + if (result) + break; } mutex_unlock(&thermal_list_lock); @@ -637,13 +658,13 @@ 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); /** * thermal_device_unregister - removes the registered thermal zone device - * * @tz: the thermal zone device to remove */ void thermal_zone_device_unregister(struct thermal_zone_device *tz) @@ -685,6 +706,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) device_unregister(&tz->device); return; } + EXPORT_SYMBOL(thermal_zone_device_unregister); static int __init thermal_init(void)