FreeBSD/sys/mips/mediatek/fdt_reset.c
/*
 * Loop through all the tuples in the resets= property for a device, asserting
 * or deasserting each reset.
 *
 * Be liberal about errors for now: warn about a failure to (de)assert but keep
 * trying with any other resets in the list.  Return ENXIO if any errors were
 * found, and let the caller decide whether the problem is fatal.
 */
Loop through all the tuples in the resets= property for a device, asserting
or deasserting each reset.

Be liberal about errors for now: warn about a failure to (de)assert but keep
trying with any other resets in the list.  Return ENXIO if any errors were
found, and let the caller decide whether the problem is fatal.
Loop through all the tuples in the resets = property for a device asserting or deasserting each reset . Be liberal about errors for now : warn about a failure to ( de ) assert but keep trying with any other resets in the list . Return ENXIO if any errors were found and let the caller decide whether the problem is fatal .
static int
assert_deassert_all(device_t consumer, boolean_t assert)
{
	phandle_t rnode;
	device_t resetdev;
	int resetnum, err, i, ncells;
	uint32_t *resets;
	boolean_t anyerrors;
	rnode = ofw_bus_get_node(consumer);
	ncells = OF_getencprop_alloc(rnode, "resets", sizeof(*resets),
	    (void **)&resets);
	if (!assert && ncells < 2) {
		device_printf(consumer, "Warning: No resets specified in fdt "
		    "data; device may not function.");
		return (ENXIO);
	}
	anyerrors = false;
	for (i = 0; i < ncells; i += 2) {
		resetdev = OF_device_from_xref(resets[i]);
		resetnum = resets[i + 1];
		if (resetdev == NULL) {
			if (!assert)
				device_printf(consumer, "Warning: can not find "
				    "driver for reset number %u; device may "
				    "not function\n", resetnum);
			anyerrors = true;
			continue;
		}
		if (assert)
			err = FDT_RESET_ASSERT(resetdev, resetnum);
		else
			err = FDT_RESET_DEASSERT(resetdev, resetnum);
		if (err != 0) {
			if (!assert)
				device_printf(consumer, "Warning: failed to "
				    "deassert reset number %u; device may not "
				    "function\n", resetnum);
			anyerrors = true;
		}
	}
	OF_prop_free(resets);
	return (anyerrors ? ENXIO : 0);
}
static int assert_deassert_all ( device_t consumer , boolean_t assert ) { phandle_t rnode ; device_t resetdev ; int resetnum , err , i , ncells ; uint32_t * resets ; boolean_t anyerrors ; rnode = ofw_bus_get_node ( consumer ) ; ncells = OF_getencprop_alloc ( rnode , " " , sizeof ( * resets ) , ( void * * ) & resets ) ; if ( ! assert && ncells < 2 ) { device_printf ( consumer , " " " " ) ; return ( ENXIO ) ; } anyerrors = false ; for ( i = 0 ; i < ncells ; i += 2 ) { resetdev = OF_device_from_xref ( resets [ i ] ) ; resetnum = resets [ i + 1 ] ; if ( resetdev == NULL ) { if ( ! assert ) device_printf ( consumer , " " " " " \n " , resetnum ) ; anyerrors = true ; continue ; } if ( assert ) err = FDT_RESET_ASSERT ( resetdev , resetnum ) ; else err = FDT_RESET_DEASSERT ( resetdev , resetnum ) ; if ( err != 0 ) { if ( ! assert ) device_printf ( consumer , " " " " " \n " , resetnum ) ; anyerrors = true ; } } OF_prop_free ( resets ) ; return ( anyerrors ? ENXIO : 0 ) ; }
Loop through all the tuples in the resets= property for a device, asserting
 or deasserting each reset.
Loop through all the tuples in the resets = property for a device asserting or deasserting each reset .