FreeBSD/sys/powerpc/powermac/smu.c
/* On the first call count the number of fans. In the second call,
 * after allocating the fan struct, fill the properties of the fans.
 */
On the first call count the number of fans. In the second call,
after allocating the fan struct, fill the properties of the fans.
On the first call count the number of fans . In the second call after allocating the fan struct fill the properties of the fans .
static int
smu_count_fans(device_t dev)
{
	struct smu_softc *sc;
	phandle_t child, node, root;
	int nfans = 0;
	node = ofw_bus_get_node(dev);
	sc = device_get_softc(dev);
	for (root = OF_child(node); root != 0; root = OF_peer(root)) {
		char name[32];
		memset(name, 0, sizeof(name));
		OF_getprop(root, "name", name, sizeof(name));
		if (strncmp(name, "rpm-fans", 9) == 0 ||
		    strncmp(name, "pwm-fans", 9) == 0 ||
		    strncmp(name, "fans", 5) == 0)
			for (child = OF_child(root); child != 0;
			     child = OF_peer(child)) {
				nfans++;
				if (sc->sc_fans != NULL) {
					smu_fill_fan_prop(dev, child,
							  nfans - 1);
				}
			}
	}
	if (nfans == 0) {
		device_printf(dev, "WARNING: No fans detected!\n");
		return (0);
	}
	return (nfans);
}
static int smu_count_fans ( device_t dev ) { struct smu_softc * sc ; phandle_t child , node , root ; int nfans = 0 ; node = ofw_bus_get_node ( dev ) ; sc = device_get_softc ( dev ) ; for ( root = OF_child ( node ) ; root != 0 ; root = OF_peer ( root ) ) { char name [ 32 ] ; memset ( name , 0 , sizeof ( name ) ) ; OF_getprop ( root , " " , name , sizeof ( name ) ) ; if ( strncmp ( name , " " , 9 ) == 0 || strncmp ( name , " " , 9 ) == 0 || strncmp ( name , " " , 5 ) == 0 ) for ( child = OF_child ( root ) ; child != 0 ; child = OF_peer ( child ) ) { nfans ++ ; if ( sc -> sc_fans != NULL ) { smu_fill_fan_prop ( dev , child , nfans - 1 ) ; } } } if ( nfans == 0 ) { device_printf ( dev , " \n " ) ; return ( 0 ) ; } return ( nfans ) ; }
On the first call count the number of fans.
On the first call count the number of fans .
/* First find the fanroots and count the number of fans. */ /* When allocated, fill the fan properties. */