FreeBSD/sys/dev/iicbus/max6690.c
/*
 * This function returns the number of sensors. If we call it the second time
 * and we have allocated memory for sc->sc_sensors, we fill in the properties.
 */
This function returns the number of sensors. If we call it the second time
and we have allocated memory for sc->sc_sensors, we fill in the properties.
This function returns the number of sensors . If we call it the second time and we have allocated memory for sc - > sc_sensors we fill in the properties .
static int
max6690_fill_sensor_prop(device_t dev)
{
	phandle_t child;
	struct max6690_softc *sc;
	u_int id[8];
	char location[96];
	int i = 0, j, len = 0, prop_len, prev_len = 0;
	sc = device_get_softc(dev);
	child = ofw_bus_get_node(dev);
	prop_len = OF_getprop(child, "hwsensor-location", location,
			      sizeof(location));
	while (len < prop_len) {
		if (sc->sc_sensors != NULL)
			strcpy(sc->sc_sensors[i].therm.name, location + len);
		prev_len = strlen(location + len) + 1;
		len += prev_len;
		i++;
	}
	if (sc->sc_sensors == NULL)
		return (i);
	prop_len = OF_getprop(child, "hwsensor-id", id, sizeof(id));
	for (j = 0; j < i; j++)
		sc->sc_sensors[j].id = (id[j] & 0xf);
	prop_len = OF_getprop(child, "hwsensor-zone", id, sizeof(id));
	for (j = 0; j < i; j++)
		sc->sc_sensors[j].therm.zone = id[j];
	for (j = 0; j < i; j++) {
		sc->sc_sensors[j].dev = dev;
		sc->sc_sensors[j].therm.target_temp = 400 + ZERO_C_TO_K;
		sc->sc_sensors[j].therm.max_temp = 800 + ZERO_C_TO_K;
		sc->sc_sensors[j].therm.read =
		    (int (*)(struct pmac_therm *))(max6690_sensor_read);
	}
	return (i);
}
static int max6690_fill_sensor_prop ( device_t dev ) { phandle_t child ; struct max6690_softc * sc ; u_int id [ 8 ] ; char location [ 96 ] ; int i = 0 , j , len = 0 , prop_len , prev_len = 0 ; sc = device_get_softc ( dev ) ; child = ofw_bus_get_node ( dev ) ; prop_len = OF_getprop ( child , " " , location , sizeof ( location ) ) ; while ( len < prop_len ) { if ( sc -> sc_sensors != NULL ) strcpy ( sc -> sc_sensors [ i ] . therm . name , location + len ) ; prev_len = strlen ( location + len ) + 1 ; len += prev_len ; i ++ ; } if ( sc -> sc_sensors == NULL ) return ( i ) ; prop_len = OF_getprop ( child , " " , id , sizeof ( id ) ) ; for ( j = 0 ; j < i ; j ++ ) sc -> sc_sensors [ j ] . id = ( id [ j ] & 0xf ) ; prop_len = OF_getprop ( child , " " , id , sizeof ( id ) ) ; for ( j = 0 ; j < i ; j ++ ) sc -> sc_sensors [ j ] . therm . zone = id [ j ] ; for ( j = 0 ; j < i ; j ++ ) { sc -> sc_sensors [ j ] . dev = dev ; sc -> sc_sensors [ j ] . therm . target_temp = 400 + ZERO_C_TO_K ; sc -> sc_sensors [ j ] . therm . max_temp = 800 + ZERO_C_TO_K ; sc -> sc_sensors [ j ] . therm . read = ( int ( * ) ( struct pmac_therm * ) ) ( max6690_sensor_read ) ; } return ( i ) ; }
This function returns the number of sensors.
This function returns the number of sensors .
/* Fill the sensor location property. */ /* Fill the sensor id property. */ /* Fill the sensor zone property. */ /* Set up remaining sensor properties */