~ubuntu-branches/ubuntu/saucy/lm-sensors-3/saucy

« back to all changes in this revision

Viewing changes to lib/sysfs.c

  • Committer: Bazaar Package Importer
  • Author(s): Aurelien Jarno
  • Date: 2009-10-14 00:20:17 UTC
  • mfrom: (1.1.2 upstream) (0.1.6 sid)
  • Revision ID: james.westby@ubuntu.com-20091014002017-36cfephnx9saq42i
Tags: 1:3.1.1-4
* Bumped Standards-version to 3.8.3 (no changes).
* Drop libsensors4 postinst script and the dependency on makedev | 
  udev. This part has been moved to i2c-tools.

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
 
139
139
#define MAX_SENSORS_PER_TYPE    20
140
140
#define MAX_SUBFEATURES         8
141
 
#define MAX_SENSOR_TYPES        5
 
141
#define MAX_SENSOR_TYPES        6
142
142
/* Room for all 5 types (in, fan, temp, power, energy) with all their
143
143
   subfeatures + VID + misc features */
144
144
#define ALL_POSSIBLE_SUBFEATURES \
153
153
        switch (type & 0xFF80) {
154
154
        case SENSORS_SUBFEATURE_IN_INPUT:
155
155
        case SENSORS_SUBFEATURE_TEMP_INPUT:
 
156
        case SENSORS_SUBFEATURE_CURR_INPUT:
156
157
                return 1000;
157
158
        case SENSORS_SUBFEATURE_FAN_INPUT:
158
159
                return 1;
184
185
        case SENSORS_FEATURE_TEMP:
185
186
        case SENSORS_FEATURE_POWER:
186
187
        case SENSORS_FEATURE_ENERGY:
 
188
        case SENSORS_FEATURE_CURR:
187
189
                underscore = strchr(sfname, '_');
188
190
                name = strndup(sfname, underscore - sfname);
 
191
                if (!name)
 
192
                        sensors_fatal_error(__func__, "Out of memory");
 
193
 
189
194
                break;
190
195
        default:
191
196
                name = strdup(sfname);
 
197
                if (!name)
 
198
                        sensors_fatal_error(__func__, "Out of memory");
192
199
        }
193
200
 
194
201
        return name;
247
254
        { "average", SENSORS_SUBFEATURE_POWER_AVERAGE },
248
255
        { "average_highest", SENSORS_SUBFEATURE_POWER_AVERAGE_HIGHEST },
249
256
        { "average_lowest", SENSORS_SUBFEATURE_POWER_AVERAGE_LOWEST },
 
257
        { "input", SENSORS_SUBFEATURE_POWER_INPUT },
 
258
        { "input_highest", SENSORS_SUBFEATURE_POWER_INPUT_HIGHEST },
 
259
        { "input_lowest", SENSORS_SUBFEATURE_POWER_INPUT_LOWEST },
250
260
        { "average_interval", SENSORS_SUBFEATURE_POWER_AVERAGE_INTERVAL },
251
261
        { NULL, 0 }
252
262
};
256
266
        { NULL, 0 }
257
267
};
258
268
 
 
269
static const struct subfeature_type_match curr_matches[] = {
 
270
        { "input", SENSORS_SUBFEATURE_CURR_INPUT },
 
271
        { "min", SENSORS_SUBFEATURE_CURR_MIN },
 
272
        { "max", SENSORS_SUBFEATURE_CURR_MAX },
 
273
        { "alarm", SENSORS_SUBFEATURE_CURR_ALARM },
 
274
        { "min_alarm", SENSORS_SUBFEATURE_CURR_MIN_ALARM },
 
275
        { "max_alarm", SENSORS_SUBFEATURE_CURR_MAX_ALARM },
 
276
        { NULL, 0 }
 
277
};
 
278
 
259
279
static const struct subfeature_type_match cpu_matches[] = {
260
280
        { "vid", SENSORS_SUBFEATURE_VID },
261
281
        { NULL, 0 }
267
287
        { "fan%d%c", fan_matches },
268
288
        { "cpu%d%c", cpu_matches },
269
289
        { "power%d%c", power_matches },
 
290
        { "curr%d%c", curr_matches },
270
291
        { "energy%d%c", energy_matches },
271
292
};
272
293
 
341
362
                sensors_fatal_error(__func__, "Out of memory");
342
363
 
343
364
        while ((ent = readdir(dir))) {
344
 
                char *name = ent->d_name;
 
365
                char *name;
345
366
                int nr;
346
367
 
347
 
                if (ent->d_name[0] == '.')
 
368
                /* Skip directories and symlinks */
 
369
                if (ent->d_type != DT_REG)
348
370
                        continue;
349
371
 
 
372
                name = ent->d_name;
 
373
 
350
374
                sftype = sensors_subfeature_get_type(name, &nr);
351
375
                if (sftype == SENSORS_SUBFEATURE_UNKNOWN)
352
376
                        continue;
357
381
                case SENSORS_SUBFEATURE_TEMP_INPUT:
358
382
                case SENSORS_SUBFEATURE_POWER_AVERAGE:
359
383
                case SENSORS_SUBFEATURE_ENERGY_INPUT:
 
384
                case SENSORS_SUBFEATURE_CURR_INPUT:
360
385
                        nr--;
361
386
                        break;
362
387
                }
399
424
                /* fill in the subfeature members */
400
425
                all_subfeatures[i].type = sftype;
401
426
                all_subfeatures[i].name = strdup(name);
 
427
                if (!all_subfeatures[i].name)
 
428
                        sensors_fatal_error(__func__, "Out of memory");
 
429
 
402
430
                if (!(sftype & 0x80))
403
431
                        all_subfeatures[i].flags |= SENSORS_COMPUTE_MAPPING;
404
432
                all_subfeatures[i].flags |= sensors_get_attr_mode(dev_path, name);
579
607
                        entry.chip.addr = 0;
580
608
                entry.chip.bus.type = SENSORS_BUS_TYPE_ISA;
581
609
                entry.chip.bus.nr = 0;
 
610
        } else if (subsys && !strcmp(subsys, "acpi")) {
 
611
                entry.chip.bus.type = SENSORS_BUS_TYPE_ACPI;
 
612
                /* For now we assume that acpi devices are unique */
 
613
                entry.chip.bus.nr = 0;
 
614
                entry.chip.addr = 0;
582
615
        } else {
583
616
                /* Ignore unknown device */
584
617
                err = 0;