Re: [PATCH 01/12] pinctrl: devicetree: Factor out dt_find_controller() helper

From: Andy Shevchenko

Date: Sat Dec 05 2026 - 07:01:26 EST


On Fri, Dec 04, 2026 at 10:38:29PM -0800, Dmitry Torokhov wrote:
> Move the ancestor walk that locates the pin controller for a DT
> configuration node out of dt_to_map_one_config() into a new
> dt_find_controller() helper using __free(device_node) to manage the
> device node reference across all exit paths. Return an ERR_PTR() on
> lookup failure, NULL when skipping a self-referenced hog, or the matched
> controller pointer, eliminating the magic return value of 1 between
> dt_to_map_one_config() and pinctrl_dt_to_map().
>
> No functional change intended.

Is it just for keeping exit paths unified in terms of device node references?
I think the commit message needs more elaboration on "why?".

...

> +static int dt_to_map_one_config(struct pinctrl *p,
> + struct pinctrl_dev *hog_pctldev,
> + const char *statename,
> + struct device_node *np_config)
> +{
> + struct pinctrl_dev *pctldev;
> + const struct pinctrl_ops *ops;
> + int ret;
> + struct pinctrl_map *map;
> + unsigned int num_maps;

Make it reversed xmas tree order, please.

> + pctldev = dt_find_controller(p, hog_pctldev, np_config);
> + if (IS_ERR(pctldev))
> + return PTR_ERR(pctldev);
> + if (!pctldev)
> + return 0;

--
With Best Regards,
Andy Shevchenko