[PATCH v2] of: Fix of platform build on powerpc due to bad of disaply code

Thomas Zimmermann tzimmermann at suse.de
Thu Jan 19 21:00:04 AEDT 2023



Am 19.01.23 um 10:53 schrieb Michal Suchanek:
> The commit 2d681d6a23a1 ("of: Make of framebuffer devices unique")
> breaks build because of wrong argument to snprintf. That certainly
> avoids the runtime error but is not the intended outcome.
> 
> Also use standard device name format of-display.N for all created
> devices.
> 
> Fixes: 2d681d6a23a1 ("of: Make of framebuffer devices unique")
> Signed-off-by: Michal Suchanek <msuchanek at suse.de>

Reviewed-by: Thomas Zimmermann <tzimmermann at suse.de>

Thanks again for taking care of this issue.

> ---
> v2: Update the device name format
> ---
>   drivers/of/platform.c | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/of/platform.c b/drivers/of/platform.c
> index f2a5d679a324..8c1b1de22036 100644
> --- a/drivers/of/platform.c
> +++ b/drivers/of/platform.c
> @@ -525,7 +525,9 @@ static int __init of_platform_default_populate_init(void)
>   	if (IS_ENABLED(CONFIG_PPC)) {
>   		struct device_node *boot_display = NULL;
>   		struct platform_device *dev;
> -		int display_number = 1;
> +		int display_number = 0;
> +		char buf[14];
> +		char *of_display_format = "of-display.%d";
>   		int ret;
>   
>   		/* Check if we have a MacOS display without a node spec */
> @@ -556,7 +558,10 @@ static int __init of_platform_default_populate_init(void)
>   			if (!of_get_property(node, "linux,opened", NULL) ||
>   			    !of_get_property(node, "linux,boot-display", NULL))
>   				continue;
> -			dev = of_platform_device_create(node, "of-display", NULL);
> +			ret = snprintf(buf, sizeof(buf), of_display_format, display_number++);
> +			if (ret >= sizeof(buf))
> +				continue;
> +			dev = of_platform_device_create(node, buf, NULL);
>   			if (WARN_ON(!dev))
>   				return -ENOMEM;
>   			boot_display = node;
> @@ -564,10 +569,9 @@ static int __init of_platform_default_populate_init(void)
>   		}
>   
>   		for_each_node_by_type(node, "display") {
> -			char *buf[14];
>   			if (!of_get_property(node, "linux,opened", NULL) || node == boot_display)
>   				continue;
> -			ret = snprintf(buf, "of-display-%d", display_number++);
> +			ret = snprintf(buf, sizeof(buf), of_display_format, display_number++);
>   			if (ret >= sizeof(buf))
>   				continue;
>   			of_platform_device_create(node, buf, NULL);

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Ivo Totev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20230119/a3eea061/attachment.sig>


More information about the Linuxppc-dev mailing list