[PATCH 07/16] board: sunxi: Refactor CHIP board extension code

Kory Maincent kory.maincent at bootlin.com
Mon Oct 6 10:44:56 CEST 2025


On Fri, 03 Oct 2025 18:33:47 +0200
Kory Maincent <kory.maincent at bootlin.com> wrote:

> Clean up and improve code structure in the sunxi CHIP board extension
> detection implementation.

It seems I forgot to build test CHIP_defconfig because there is a build error
here.

pw-bot:cr

> 
> Signed-off-by: Kory Maincent <kory.maincent at bootlin.com>
> ---
>  board/sunxi/chip.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/board/sunxi/chip.c b/board/sunxi/chip.c
> index 270af2506d2..ea0d3a56f5f 100644
> --- a/board/sunxi/chip.c
> +++ b/board/sunxi/chip.c
> @@ -42,13 +42,7 @@ struct dip_w1_header {
>  
>  int extension_board_scan(struct list_head *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;
>  
>  	sunxi_gpio_set_pull(SUNXI_GPD(2), SUNXI_GPIO_PULL_UP);
> @@ -60,6 +54,12 @@ int extension_board_scan(struct list_head *extension_list)
>  	}
>  
>  	for_each_w1_device(bus, &dev) {
> +		struct dip_w1_header w1_header;
> +		struct extension *dip;
> +		u32 vid;
> +		u16 pid;
> +		int ret;
> +
>  		if (w1_get_device_family(dev) != W1_FAMILY_DS2431)
>  			continue;
>  
> @@ -90,8 +90,8 @@ int extension_board_scan(struct list_head *extension_list)
>  
>  		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);
> +		strlcpy(dip->name, w1_header.product_name,
> sizeof(dip->name));
> +		strlcpy(dip->owner, w1_header.vendor_name,
> sizeof(dip->owner)); list_add_tail(&dip->list, extension_list);
>  		num_dip++;
>  	}
> 



-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com


More information about the U-Boot mailing list