[PATCH v2 2/3] soc: ti: knav_qmss_queue: do device_node auto cleanup

Jonathan Cameron Jonathan.Cameron at Huawei.com
Fri Jul 5 03:52:05 PDT 2024


On Wed,  3 Jul 2024 12:25:27 +0530
Kousik Sanagavarapu <five231003 at gmail.com> wrote:

> Use scope based cleanup, instead of manual of_node_put() calls, which
> automatically free()s "struct device_node".
> 
> While at it, refactor the code from knav_queue_probe() into the seperate
> functions to make auto cleanup look more neat.
> 
> Doing the cleanup this way has the advantage of reducing the chance of
> memory leaks in case we need to read from new OF nodes in the future
> when we probe.
> 
> Suggested-by: Julia Lawall <julia.lawall at inria.fr>
> Signed-off-by: Kousik Sanagavarapu <five231003 at gmail.com>

One trivial thing inline
Reviewed-by: Jonathan Cameron <Jonathan.Cameron at huawei.com>

> @@ -1668,6 +1686,25 @@ static int knav_queue_start_pdsps(struct knav_device *kdev)
>  	return 0;
>  }
>  
> +static int knav_queue_setup_pdsps(struct knav_device *kdev,
> +				  struct device_node *node)
> +{
> +	struct device_node *pdsps __free(device_node) =
> +			of_get_child_by_name(node, "pdsps");
> +
> +	if (pdsps) {
> +		int ret;
> +
> +		ret = knav_queue_init_pdsps(kdev, pdsps);
> +		if (ret)
> +			return ret;
As per original style, readability slightly helped by
a blank line here.

> +		ret = knav_queue_start_pdsps(kdev);
> +		if (ret)
> +			return ret;
> +	}
> +	return 0;
> +}





More information about the linux-arm-kernel mailing list