diff options
Diffstat (limited to 'board/sunxi/chip.c')
| -rw-r--r-- | board/sunxi/chip.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/board/sunxi/chip.c b/board/sunxi/chip.c index 270af2506d2..b60a739df41 100644 --- a/board/sunxi/chip.c +++ b/board/sunxi/chip.c @@ -40,16 +40,12 @@ struct dip_w1_header { u8 data[16]; /* user data, per-dip specific */ } __packed; -int extension_board_scan(struct list_head *extension_list) +static int sunxi_extension_board_scan(struct udevice *udev, + struct alist *extension_list) { - struct extension *dip; - struct dip_w1_header w1_header; struct udevice *bus, *dev; - u32 vid; - u16 pid; - int ret; - int num_dip = 0; + int ret; sunxi_gpio_set_pull(SUNXI_GPD(2), SUNXI_GPIO_PULL_UP); @@ -60,6 +56,11 @@ int extension_board_scan(struct list_head *extension_list) } for_each_w1_device(bus, &dev) { + struct extension dip = {0}; + struct dip_w1_header w1_header; + u32 vid; + u16 pid; + if (w1_get_device_family(dev) != W1_FAMILY_DS2431) continue; @@ -82,18 +83,19 @@ int extension_board_scan(struct list_head *extension_list) w1_header.product_name, pid, w1_header.vendor_name, vid); - dip = calloc(1, sizeof(struct extension)); - if (!dip) { - printf("Error in memory allocation\n"); - return num_dip; - } - - snprintf(dip->overlay, sizeof(dip->overlay), "dip-%x-%x.dtbo", + snprintf(dip.overlay, sizeof(dip.overlay), "dip-%x-%x.dtbo", vid, pid); - strncpy(dip->name, w1_header.product_name, 32); - strncpy(dip->owner, w1_header.vendor_name, 32); - list_add_tail(&dip->list, extension_list); + strlcpy(dip.name, w1_header.product_name, sizeof(dip.name)); + strlcpy(dip.owner, w1_header.vendor_name, sizeof(dip.owner)); + if (!alist_add(extension_list, dip)) + return -ENOMEM; num_dip++; } return num_dip; } + +U_BOOT_EXTENSION(dip, sunxi_extension_board_scan); + +U_BOOT_DRVINFO(dip) = { + .name = "dip", +}; |
