~ubuntu-branches/ubuntu/precise/cpufreqd/precise

« back to all changes in this revision

Viewing changes to src/cpufreqd_acpi_temperature.c

  • Committer: Bazaar Package Importer
  • Author(s): Mattia Dongili
  • Date: 2010-04-18 23:08:30 UTC
  • mfrom: (1.2.1 upstream) (6.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100418230830-2whwcjxddq9mxcxo
Tags: 2.4.2-1
New upstream release: fixes configuration with libsensors4
(Closes: #577822).

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "cpufreqd_acpi.h"
27
27
#include "cpufreqd_acpi_temperature.h"
28
28
 
29
 
#define THERMAL "thermal"
30
 
#define THERMAL_TYPE "ACPI thermal zone"
31
 
#define THERMAL_TEMP "temp"
 
29
#define THERMAL                 "thermal"
 
30
#define THERMAL_TYPE            "acpitz"
 
31
/* the below is for kernels <= 2.6.25 */
 
32
#define THERMAL_TYPE_ALT        "ACPI thermal zone"
 
33
#define THERMAL_TEMP            "temp"
32
34
 
33
35
struct thermal_zone {
34
36
        int temperature;
49
51
{
50
52
        int i;
51
53
        struct thermal_zone *ret = NULL;
52
 
        
 
54
 
53
55
        for (i = 0; i < atz_dir_num; i++) {
54
56
                if (strncmp(atz_list[i].cdev->name, name, 32) == 0) {
55
57
                        ret = &atz_list[i];
74
76
 
75
77
/*  static int acpi_temperature_init(void)
76
78
 *
77
 
 *  test if ATZ dirs are present and read their 
 
79
 *  test if ATZ dirs are present and read their
78
80
 *  path for usage when parsing rules
79
81
 */
80
 
int acpi_temperature_init(void)
 
82
short int acpi_temperature_init(void)
81
83
{
82
84
        find_class_device(THERMAL, THERMAL_TYPE, atz_callback);
 
85
        /* try with the old type name */
 
86
        if (atz_dir_num <= 0)
 
87
                find_class_device(THERMAL, THERMAL_TYPE_ALT, atz_callback);
83
88
        if (atz_dir_num <= 0) {
84
89
                clog(LOG_INFO, "No thermal zones found\n");
85
90
                return -1;
89
94
        return 0;
90
95
}
91
96
 
92
 
int acpi_temperature_exit(void) 
 
97
short int acpi_temperature_exit(void)
93
98
{
94
99
        while (--atz_dir_num >= 0) {
95
100
                put_attribute(atz_list[atz_dir_num].temp);
112
117
        clog(LOG_DEBUG, "called with: %s\n", ev);
113
118
 
114
119
        /* try to parse the %[a-zA-Z0-9]:%d-%d format first */
115
 
        if (sscanf(ev, "%32[a-zA-Z0-9]:%d-%d", atz_name, &(ret->min), &(ret->max)) == 3) {
 
120
        if (sscanf(ev, "%32[a-zA-Z0-9_]:%d-%d", atz_name, &(ret->min), &(ret->max)) == 3) {
116
121
                /* validate zone name and assign pointer to struct thermal_zone */
117
122
                if ((ret->tz = get_thermal_zone(atz_name)) == NULL) {
118
123
                        clog(LOG_ERR, "non existent thermal zone %s!\n", atz_name);
122
127
                clog(LOG_INFO, "parsed %s %d-%d\n",
123
128
                                ret->tz->cdev->name, ret->min, ret->max);
124
129
 
125
 
        } else if (sscanf(ev, "%32[a-zA-Z0-9]:%d", atz_name, &(ret->min)) == 2) {
 
130
        } else if (sscanf(ev, "%32[a-zA-Z0-9_]:%d", atz_name, &(ret->min)) == 2) {
126
131
                /* validate zone name and assign pointer to struct thermal_zone */
127
132
                if ((ret->tz = get_thermal_zone(atz_name)) == NULL) {
128
133
                        clog(LOG_ERR, "non existent thermal zone %s!\n", atz_name);
161
166
 
162
167
        if (ti != NULL && ti->tz != NULL)
163
168
                temp = ti->tz->temperature;
164
 
                
165
 
        clog(LOG_DEBUG, "called %d-%d [%s:%.1f]\n", ti->min, ti->max, 
 
169
 
 
170
        clog(LOG_DEBUG, "called %d-%d [%s:%.1f]\n", ti->min, ti->max,
166
171
                        ti != NULL && ti->tz != NULL ? ti->tz->cdev->name : "Avg",
167
172
                        (float)temp / 1000);
168
173
 
170
175
}
171
176
 
172
177
/*  static int acpi_temperature_update(void)
173
 
 *  
 
178
 *
174
179
 *  reads temperature valuse ant compute a medium value
175
180
 */
176
181
int acpi_temperature_update(void)