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

From: Jonathan Cameron
Date: Fri Jul 05 2024 - 06:52:17 EST


On Wed, 3 Jul 2024 12:25:27 +0530
Kousik Sanagavarapu <five231003@xxxxxxxxx> 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@xxxxxxxx>
> Signed-off-by: Kousik Sanagavarapu <five231003@xxxxxxxxx>

One trivial thing inline
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>

> @@ -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;
> +}