diff --git a/sys/dev/fdt/fdt_slicer.c b/sys/dev/fdt/fdt_slicer.c index 122567c38602..03bc6803fab7 100644 --- a/sys/dev/fdt/fdt_slicer.c +++ b/sys/dev/fdt/fdt_slicer.c @@ -46,19 +46,19 @@ __FBSDID("$FreeBSD$"); #define debugf(fmt, args...) #endif -static int fdt_flash_fill_slices(device_t dev, const char *provider, +static int fill_slices(device_t dev, const char *provider, struct flash_slice *slices, int *slices_num); static void fdt_slicer_init(void); static int -fdt_flash_fill_slices(device_t dev, const char *provider __unused, +fill_slices(device_t dev, const char *provider __unused, struct flash_slice *slices, int *slices_num) { char *slice_name; - phandle_t dt_node, dt_child; + phandle_t node, child; u_long base, size; int i; - ssize_t name_len; + ssize_t nmlen; /* * We assume the caller provides buffer for FLASH_SLICES_MAX_NUM @@ -69,19 +69,17 @@ fdt_flash_fill_slices(device_t dev, const char *provider __unused, return (ENOMEM); } - dt_node = ofw_bus_get_node(dev); - for (dt_child = OF_child(dt_node), i = 0; dt_child != 0; - dt_child = OF_peer(dt_child)) { + i = 0; + node = ofw_bus_get_node(dev); + for (child = OF_child(node); child != 0; child = OF_peer(child)) { if (i == FLASH_SLICES_MAX_NUM) { debugf("not enough buffer for slice i=%d\n", i); break; } - /* - * Retrieve start and size of the slice. - */ - if (fdt_regsize(dt_child, &base, &size) != 0) { + /* Retrieve start and size of the slice. */ + if (fdt_regsize(child, &base, &size) != 0) { debugf("error during processing reg property, i=%d\n", i); continue; @@ -92,24 +90,19 @@ fdt_flash_fill_slices(device_t dev, const char *provider __unused, continue; } - /* - * Retrieve label. - */ - name_len = OF_getprop_alloc(dt_child, "label", - (void **)&slice_name); - if (name_len <= 0) { + /* Retrieve label. */ + nmlen = OF_getprop_alloc(child, "label", (void **)&slice_name); + if (nmlen <= 0) { /* Use node name if no label defined */ - name_len = OF_getprop_alloc(dt_child, "name", + nmlen = OF_getprop_alloc(child, "name", (void **)&slice_name); - if (name_len <= 0) { + if (nmlen <= 0) { debugf("slice i=%d with no name\n", i); slice_name = NULL; } } - /* - * Fill slice entry data. - */ + /* Fill slice entry data. */ slices[i].base = base; slices[i].size = size; slices[i].label = slice_name; @@ -124,12 +117,9 @@ static void fdt_slicer_init(void) { - flash_register_slicer(fdt_flash_fill_slices, FLASH_SLICES_TYPE_NAND, - FALSE); - flash_register_slicer(fdt_flash_fill_slices, FLASH_SLICES_TYPE_CFI, - FALSE); - flash_register_slicer(fdt_flash_fill_slices, FLASH_SLICES_TYPE_SPI, - FALSE); + flash_register_slicer(fill_slices, FLASH_SLICES_TYPE_NAND, false); + flash_register_slicer(fill_slices, FLASH_SLICES_TYPE_CFI, false); + flash_register_slicer(fill_slices, FLASH_SLICES_TYPE_SPI, false); } static void