Exemplo n.º 1
0
/* Look up a chip in the intern chip list, and return a pointer to it.
   Do not modify the struct the return value points to! Returns NULL if
   not found.*/
static const sensors_chip_features *
sensors_lookup_chip(const sensors_chip_name *name)
{
	int i;

	for (i = 0; i < sensors_proc_chips_count; i++)
		if (sensors_match_chip(&sensors_proc_chips[i].chip, name))
			return &sensors_proc_chips[i];

	return NULL;
}
Exemplo n.º 2
0
const sensors_chip_name *sensors_get_detected_chips(const sensors_chip_name
						    *match, int *nr)
{
	const sensors_chip_name *res;

	while (*nr < sensors_proc_chips_count) {
		res = &sensors_proc_chips[(*nr)++].chip;
		if (!match || sensors_match_chip(res, match))
			return res;
	}
	return NULL;
}
Exemplo n.º 3
0
Arquivo: rrd.c Projeto: OPSF/uClinux
static int
applyToFeatures
(FeatureFN fn, void *data) {
  const sensors_chip_name *chip;
  int i = 0, j, ret = 0, num = 0;

  while ((ret == 0) && ((chip = sensors_get_detected_chips (&i)) != NULL)) {
    for (j = 0; (ret == 0) && (j < numChipNames); ++ j) {
      if (sensors_match_chip (*chip, chipNames[j])) {
        int index0, subindex, chipindex = -1;
        for (index0 = 0; knownChips[index0]; ++ index0)
          for (subindex = 0; knownChips[index0]->names[subindex]; ++ subindex)
            if (!strcmp (chip->prefix, knownChips[index0]->names[subindex]))
              chipindex = index0;
        if (chipindex >= 0) {
          const ChipDescriptor *descriptor = knownChips[chipindex];
          const FeatureDescriptor *features = descriptor->features;

          for (index0 = 0; (ret == 0) && (num < MAX_RRD_SENSORS) && features[index0].format; ++ index0) {
            const FeatureDescriptor *feature = features + index0;
            int labelNumber = feature->dataNumbers[0];
            const char *rawLabel = NULL;
            char *label = NULL;
            int valid = 0;
            if (getValid (*chip, labelNumber, &valid)) {
              sensorLog (LOG_ERR, "Error getting sensor validity: %s/#%d", chip->prefix, labelNumber);
              ret = -1;
            } else if (getRawLabel (*chip, labelNumber, &rawLabel)) {
              sensorLog (LOG_ERR, "Error getting raw sensor label: %s/#%d", chip->prefix, labelNumber);
              ret = -1;
            } else if (getLabel (*chip, labelNumber, &label)) {
              sensorLog (LOG_ERR, "Error getting sensor label: %s/#%d", chip->prefix, labelNumber);
              ret = -1;
            } else if (valid) {
              rrdCheckLabel (rawLabel, num);
              ret = fn (data, rrdLabels[num], label, feature);
              ++ num;
            }
            if (label)
              free (label);
          }
        }
      }
    }
  }

  return ret;
}
Exemplo n.º 4
0
/* Returns, one by one, a pointer to all sensor_chip structs of the
   config file which match with the given chip name. Last should be
   the value returned by the last call, or NULL if this is the first
   call. Returns NULL if no more matches are found. Do not modify
   the struct the return value points to! 
   Note that this visits the list of chips from last to first. Usually,
   you want the match that was latest in the config file. */
static sensors_chip *
sensors_for_all_config_chips(const sensors_chip_name *name,
			     const sensors_chip *last)
{
	int nr, i;
	sensors_chip_name_list chips;

	for (nr = last ? last - sensors_config_chips - 1 :
			 sensors_config_chips_count - 1; nr >= 0; nr--) {

		chips = sensors_config_chips[nr].chips;
		for (i = 0; i < chips.fits_count; i++) {
			if (sensors_match_chip(&chips.fits[i], name))
				return sensors_config_chips + nr;
		}
	}
	return NULL;
}