[PATCH] virtio: simplify of_node handling in virtio_device_of_init

Clement Amar posted 1 patch 2 months, 1 week ago
drivers/virtio/virtio.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
[PATCH] virtio: simplify of_node handling in virtio_device_of_init
Posted by Clement Amar 2 months, 1 week ago
Replace goto with return for simple error

Signed-off-by: Clement Amar <clementamar@gmail.com>
---
 drivers/virtio/virtio.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
index 5bdc6b82b..b49113ea8 100644
--- a/drivers/virtio/virtio.c
+++ b/drivers/virtio/virtio.c
@@ -493,16 +493,12 @@ static int virtio_device_of_init(struct virtio_device *dev)
 	 * Simply don't init of_node in this case.
 	 */
 	if (!of_device_is_compatible(np, compat)) {
-		ret = 0;
-		goto out;
+		of_node_put(np);
+		return 0;
 	}
 
 	dev->dev.of_node = np;
 	return 0;
-
-out:
-	of_node_put(np);
-	return ret;
 }
 
 /**
-- 
2.43.0
Re: [PATCH] virtio: simplify of_node handling in virtio_device_of_init
Posted by Michael S. Tsirkin 2 months, 1 week ago
On Mon, Apr 06, 2026 at 11:21:59AM +0200, Clement Amar wrote:
> Replace goto with return for simple error
> 
> Signed-off-by: Clement Amar <clementamar@gmail.com>

I don't see the point, sorry.

> ---
>  drivers/virtio/virtio.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c
> index 5bdc6b82b..b49113ea8 100644
> --- a/drivers/virtio/virtio.c
> +++ b/drivers/virtio/virtio.c
> @@ -493,16 +493,12 @@ static int virtio_device_of_init(struct virtio_device *dev)
>  	 * Simply don't init of_node in this case.
>  	 */
>  	if (!of_device_is_compatible(np, compat)) {
> -		ret = 0;
> -		goto out;
> +		of_node_put(np);
> +		return 0;
>  	}
>  
>  	dev->dev.of_node = np;
>  	return 0;
> -
> -out:
> -	of_node_put(np);
> -	return ret;
>  }
>  
>  /**
> -- 
> 2.43.0