FreeBSD/sys/dev/ofw/ofw_fdt.c
/*
 * Get the next property of a package. Return values:
 *  -1: package or previous property does not exist
 *   0: no more properties
 *   1: success
 */
Get the next property of a package. Return values:
-1: package or previous property does not exist
0: no more properties
1: success
Get the next property of a package . Return values : - 1 : package or previous property does not exist 0 : no more properties 1 : success
static int
ofw_fdt_nextprop(ofw_t ofw, phandle_t package, const char *previous, char *buf,
    size_t size)
{
	const struct fdt_property *prop;
	const char *name;
	int offset;
	offset = fdt_phandle_offset(package);
	if (offset < 0)
		return (-1);
	offset = fdt_first_property_offset(fdtp, offset);
	if (offset < 0)
		return (0); 
	if (previous != NULL) {
		while (offset >= 0) {
			prop = fdt_get_property_by_offset(fdtp, offset, NULL);
			if (prop == NULL)
				return (-1); 
			offset = fdt_next_property_offset(fdtp, offset);
			if (offset < 0)
				return (0); 
			name = fdt_string(fdtp, fdt32_to_cpu(prop->nameoff));
			if (strcmp(name, previous) == 0)
				break;
		}
	}
	prop = fdt_get_property_by_offset(fdtp, offset, &offset);
	if (prop == NULL)
		return (-1); 
	strncpy(buf, fdt_string(fdtp, fdt32_to_cpu(prop->nameoff)), size);
	return (1);
}
static int ofw_fdt_nextprop ( ofw_t ofw , phandle_t package , const char * previous , char * buf , size_t size ) { const struct fdt_property * prop ; const char * name ; int offset ; offset = fdt_phandle_offset ( package ) ; if ( offset < 0 ) return ( -1 ) ; offset = fdt_first_property_offset ( fdtp , offset ) ; if ( offset < 0 ) return ( 0 ) ; if ( previous != NULL ) { while ( offset >= 0 ) { prop = fdt_get_property_by_offset ( fdtp , offset , NULL ) ; if ( prop == NULL ) return ( -1 ) ; offset = fdt_next_property_offset ( fdtp , offset ) ; if ( offset < 0 ) return ( 0 ) ; name = fdt_string ( fdtp , fdt32_to_cpu ( prop -> nameoff ) ) ; if ( strcmp ( name , previous ) == 0 ) break ; } } prop = fdt_get_property_by_offset ( fdtp , offset , & offset ) ; if ( prop == NULL ) return ( -1 ) ; strncpy ( buf , fdt_string ( fdtp , fdt32_to_cpu ( prop -> nameoff ) ) , size ) ; return ( 1 ) ; }
Get the next property of a package.
Get the next property of a package .
/* Find the first prop in the node */ /* No properties */ /* Internal error */ /* No more properties */ /* Check if the last one was the one we wanted */ /* Internal error */