static int envctrl_read_cpu_info()

in char/envctrl.c [362:391]


static int envctrl_read_cpu_info(int cpu, struct i2c_child_t *pchild,
				 char mon_type, unsigned char *bufdata)
{
	unsigned char data;
	int i;
	char *tbl, j = -1;

	/* Find the right monitor type and channel. */
	for (i = 0; i < PCF8584_MAX_CHANNELS; i++) {
		if (pchild->mon_type[i] == mon_type) {
			if (++j == cpu) {
				break;
			}
		}
	}

	if (j != cpu)
		return 0;

        /* Read data from address and port. */
	data = envctrl_i2c_read_8591((unsigned char)pchild->addr,
				     (unsigned char)pchild->chnl_array[i].chnl_no);

	/* Find decoding table. */
	tbl = pchild->tables + pchild->tblprop_array[i].offset;

	return envctrl_i2c_data_translate(data, pchild->tblprop_array[i].type,
					  pchild->tblprop_array[i].scale,
					  tbl, bufdata);
}