Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp471655lqm; Wed, 1 May 2024 06:31:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXUDIacHxNsX+9H1vR7FSda2V9qwn2zad90cJ0Vj9bM5J0u/WynP0nIDTkmkqXj/xVjFySQJir1tyqV8CeGKsSSoQjdgzYqibeBmM8Atg== X-Google-Smtp-Source: AGHT+IHQQP9rf4Aj0B3/QP9oQ8XLezE9c14Ywx3igsSO+quhpjZdIYAxaccuI5CAJoDjVCKa/iUx X-Received: by 2002:a17:906:6b97:b0:a55:b67c:bd04 with SMTP id l23-20020a1709066b9700b00a55b67cbd04mr5150773ejr.4.1714570295862; Wed, 01 May 2024 06:31:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714570295; cv=pass; d=google.com; s=arc-20160816; b=JociVeUbC32ZTcMYMJ7y4/8GLwXGtN/JOzdkLitZpupWexZQeMPHkSwbeGyQJVYIxu 5TwPDPYmGDyKv0HJmzVYlXG/S3EqnX8btvHH0lqwFupVG+ROnueE6olhnEErs4sRxl84 c+TxMfUbg5+r2uY5LkXz5cDgQTPgmkb3J4dSpFXZjKbE+DgRCDk08Ch3xPsQdMNYWUJF 3aXb6idXNZ94ghMqMI0YFMfUMzv85+dg+z7J3rre9QAekaTvQL1uLjuuCfTP9nq27XvY kfHryc854tUVurYqbAweJ7LlUjBK8x8xhN0Y3a/aHAxHSF3APyL0shO5PImDKolEXnEl MYbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:from :dkim-signature; bh=c8oK9gFYZNPK8JjkQaEUib/TlJXrHwdRQFsXpehmfQo=; fh=+ZuTSA/A/XBOoqmfjMraO8yGX4Q3zMCLGYDy7BIH2dE=; b=Lv4K+1v5MbE0iSgkigPx7ikCbqA3F8IhDzFoPoRh6e+31/HXY0ZyGeCjDeu9GWmCu+ itFL1xdn23SzW3H1jdx8aw8IvVHIjCun7W448mucKhN4jmi0gYALtUNNZtqzTtJ+qwKC MHRTjJAgh+B3/Q5sYR2CsPH0AdntYRNy0FgiZ86k+klXRCxMASz2H+kKmYKOl64p8fGA 7FPpYgxECq1yvwVHSj0Bu7VLFlSJWYy1dcOUXXtFdzuAKMCsrfbx9MfYqftQrP34qAzi 2HkpOtr2vQqKMphzTIa+QSyIKj79sl3/42kxq21nwdfFXjmbU5XoJ+zqx9clWk3EOt2u sQuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=oxCQdFTt; arc=pass (i=1 spf=pass spfdomain=canonical.com dkim=pass dkdomain=canonical.com dmarc=pass fromdomain=canonical.com); spf=pass (google.com: domain of linux-kernel+bounces-165319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165319-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id hp16-20020a1709073e1000b00a5565142899si16639486ejc.335.2024.05.01.06.31.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 06:31:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=oxCQdFTt; arc=pass (i=1 spf=pass spfdomain=canonical.com dkim=pass dkdomain=canonical.com dmarc=pass fromdomain=canonical.com); spf=pass (google.com: domain of linux-kernel+bounces-165319-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165319-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6E4BA1F23789 for ; Wed, 1 May 2024 13:31:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D53612E1E0; Wed, 1 May 2024 13:31:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="oxCQdFTt" Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCACD5029A for ; Wed, 1 May 2024 13:31:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.122 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714570287; cv=none; b=RITmYkAXKUE0FUTI1Ru1dhubqXtgxepDU2hr6pefXL60OqC6y6Gi5OUFoPicfGstz5D6JF88q4GOlm0bxjgp4QNnMLPuQJTH0NB35a2H9+C/j0pdI54DfnwzHRD97dE+JIVq1WrF7Dksrg08/iWCj423M811Uz7/BoamhZf4AhY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714570287; c=relaxed/simple; bh=GOV9SpBdrbLUHNqrWyub6cb3BrALMYIpAncwmbro2yc=; h=From:In-Reply-To:References:Mime-Version:Date:Message-ID:Subject: To:Cc:Content-Type; b=g4LaT+nNnP3Fex+So0G8W4ZPItJEEY1EuNsj6je6+9NMe74NC6Xvn/WLN+jAOiDqfadHiGAWbxLlM4olGzD1K+0ST4ncE16c1kY2BM/WujX4Z3Ai1ffvbxlk7idWSmto53uvN+i6W4JBhlpB37tERq1F6pulySQe7R9N3ZyFdJc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=oxCQdFTt; arc=none smtp.client-ip=185.125.188.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 536FF410AF for ; Wed, 1 May 2024 13:31:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1714570279; bh=c8oK9gFYZNPK8JjkQaEUib/TlJXrHwdRQFsXpehmfQo=; h=From:In-Reply-To:References:Mime-Version:Date:Message-ID:Subject: To:Cc:Content-Type; b=oxCQdFTtQhG9tOtVfZ7VTu7oupcXNvpxRK91LOOnA3CtloGmCaC15xPhLxDM4Eux/ qhZ5CeTXAN337oRF53S5UJ6uo/fQ2IWXPKIgu0mM69RI6QKHnJbLwtA4zfnpf9Tr8R EasLBjqltjLiXR8s2xU9cgLuhGFOog5uAufzbICIXkDFhu/v6qTW9QEzCLaFsr5Rkn RAiwWTzlytxQ4te9a1NwCCGiC36zIf/+5Ligs260ieh/+f7hfnYQ6DxXGkRlMISawx VTW1BH7f0eH7vbgpqV62FmrO1r0OSbxpuIm5RfxYG8etuAUMcOcj/dOggknPHtktE0 hvkp4TrDFNh3A== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a58db282330so83876966b.0 for ; Wed, 01 May 2024 06:31:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714570278; x=1715175078; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=c8oK9gFYZNPK8JjkQaEUib/TlJXrHwdRQFsXpehmfQo=; b=icyE5O1ll20gUPzP7JsQPH9rVSnwfOvMVpr4xubrRn8q/ADsh8rEU30plodw1KOyCK lFRRcTjAFMuB5OLCgFsY9wDRyIXmGWB0nGBJNCBBk3OogoBFhDp4yJX/W/WIJQgw7sKL XxbrUXPfHo+3v8Eu9ayMVPCEar2gh86APP/e8PBbE8p0cR4mIbrr3HIo9HC7MJBozpDd veG2NPdd4e3MzvuygQEQ1+4AlEIkHBenbwm7Qj++PGortqbxVXWlGpL3lA8TEfSDjKmC FUHfgyrFvxWDf1kspFWqKmeNAxOLwl/mNMvDUdrmbu4ZvcWJrq7UNNglsaOrc0zO+B1W YPaA== X-Forwarded-Encrypted: i=1; AJvYcCXxO2ySDzeYyAtwdijp4qHaxoPeocRDxkIh1tHOtDdvgc+sq/BYCboBnaLWo2tOiwbUd6pIhLbcJ2KSs2fuwSTdKZYLJ/XOV5EU8f3T X-Gm-Message-State: AOJu0YyLWom5KP2gvkKaziwtBS8G94RQOc3sdkNrld7RT+nnAHd6L2Hg pLh9i4oSu8d0G8qngsokj5QunSS/pPbx3aLDZI6qeuWiCaW272c2M7G3m3KqgBV98j2sE7YdY/6 6jhjZjYP+q/vu9HCrlC+aZM+p610zG5N/L7c4MSdTdXGkhgRePC+BR6n+jhOIusxSD7OB7WTnG0 +e3BXwD7jMz30PHpp4J9SGwknqdG4NVwtqPRNY6gpgjIcqUjZtgLuI X-Received: by 2002:a2e:a7ce:0:b0:2df:8ce6:96cb with SMTP id x14-20020a2ea7ce000000b002df8ce696cbmr955472ljp.8.1714570258155; Wed, 01 May 2024 06:30:58 -0700 (PDT) X-Received: by 2002:a2e:a7ce:0:b0:2df:8ce6:96cb with SMTP id x14-20020a2ea7ce000000b002df8ce696cbmr955417ljp.8.1714570257684; Wed, 01 May 2024 06:30:57 -0700 (PDT) Received: from 348282803490 named unknown by gmailapi.google.com with HTTPREST; Wed, 1 May 2024 08:30:56 -0500 From: Emil Renner Berthing In-Reply-To: <20240501-pinctrl-cleanup-v1-5-797ceca46e5c@nxp.com> References: <20240501-pinctrl-cleanup-v1-0-797ceca46e5c@nxp.com> <20240501-pinctrl-cleanup-v1-5-797ceca46e5c@nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Date: Wed, 1 May 2024 08:30:56 -0500 Message-ID: Subject: Re: [PATCH 05/21] pinctrl: starfive: Use scope based of_node_put() cleanups To: "Peng Fan (OSS)" , Linus Walleij , Thierry Reding , Jonathan Hunter , Dvorkin Dmitry , Wells Lu , Maxime Coquelin , Alexandre Torgue , Emil Renner Berthing , Jianlong Huang , Hal Feng , Orson Zhai , Baolin Wang , Chunyan Zhang , Viresh Kumar , Shiraz Hashim , soc@kernel.org, Krzysztof Kozlowski , Sylwester Nawrocki , Alim Akhtar , Geert Uytterhoeven , Patrice Chotard , Heiko Stuebner , Damien Le Moal , Ludovic Desroches , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Dong Aisheng , Fabio Estevam , Shawn Guo , Jacky Bai , Pengutronix Kernel Team , Chester Lin , Matthias Brugger , Ghennadi Procopciuc , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Sascha Hauer , Andrew Jeffery , Joel Stanley , Dan Carpenter Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-samsung-soc@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-riscv@lists.infradead.org, linux-mediatek@lists.infradead.org, imx@lists.linux.dev, linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, Peng Fan Content-Type: text/plain; charset="UTF-8" Peng Fan (OSS) wrote: > From: Peng Fan > > Use scope based of_node_put() cleanup to simplify code. > > Signed-off-by: Peng Fan Acked-by: Emil Renner Berthing > --- > drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c | 27 +++++++++------------- > drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c | 18 +++++++-------- > 2 files changed, 19 insertions(+), 26 deletions(-) > > diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c > index 6df7a310c7ed..27f99183d994 100644 > --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c > +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7100.c > @@ -480,7 +480,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, > { > struct starfive_pinctrl *sfp = pinctrl_dev_get_drvdata(pctldev); > struct device *dev = sfp->gc.parent; > - struct device_node *child; > struct pinctrl_map *map; > const char **pgnames; > const char *grpname; > @@ -492,20 +491,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, > > nmaps = 0; > ngroups = 0; > - for_each_available_child_of_node(np, child) { > + for_each_available_child_of_node_scoped(np, child) { > int npinmux = of_property_count_u32_elems(child, "pinmux"); > int npins = of_property_count_u32_elems(child, "pins"); > > if (npinmux > 0 && npins > 0) { > dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: both pinmux and pins set\n", > np, child); > - of_node_put(child); > return -EINVAL; > } > if (npinmux == 0 && npins == 0) { > dev_err(dev, "invalid pinctrl group %pOFn.%pOFn: neither pinmux nor pins set\n", > np, child); > - of_node_put(child); > return -EINVAL; > } > > @@ -527,14 +524,14 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, > nmaps = 0; > ngroups = 0; > mutex_lock(&sfp->mutex); > - for_each_available_child_of_node(np, child) { > + for_each_available_child_of_node_scoped(np, child) { > int npins; > int i; > > grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child); > if (!grpname) { > ret = -ENOMEM; > - goto put_child; > + goto free_map; > } > > pgnames[ngroups++] = grpname; > @@ -543,18 +540,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, > pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); > if (!pins) { > ret = -ENOMEM; > - goto put_child; > + goto free_map; > } > > pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL); > if (!pinmux) { > ret = -ENOMEM; > - goto put_child; > + goto free_map; > } > > ret = of_property_read_u32_array(child, "pinmux", pinmux, npins); > if (ret) > - goto put_child; > + goto free_map; > > for (i = 0; i < npins; i++) { > unsigned int gpio = starfive_pinmux_to_gpio(pinmux[i]); > @@ -570,7 +567,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, > pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); > if (!pins) { > ret = -ENOMEM; > - goto put_child; > + goto free_map; > } > > pinmux = NULL; > @@ -580,18 +577,18 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, > > ret = of_property_read_u32_index(child, "pins", i, &v); > if (ret) > - goto put_child; > + goto free_map; > pins[i] = v; > } > } else { > ret = -EINVAL; > - goto put_child; > + goto free_map; > } > > ret = pinctrl_generic_add_group(pctldev, grpname, pins, npins, pinmux); > if (ret < 0) { > dev_err(dev, "error adding group %s: %d\n", grpname, ret); > - goto put_child; > + goto free_map; > } > > ret = pinconf_generic_parse_dt_config(child, pctldev, > @@ -600,7 +597,7 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, > if (ret) { > dev_err(dev, "error parsing pin config of group %s: %d\n", > grpname, ret); > - goto put_child; > + goto free_map; > } > > /* don't create a map if there are no pinconf settings */ > @@ -623,8 +620,6 @@ static int starfive_dt_node_to_map(struct pinctrl_dev *pctldev, > mutex_unlock(&sfp->mutex); > return 0; > > -put_child: > - of_node_put(child); > free_map: > pinctrl_utils_free_map(pctldev, map, nmaps); > mutex_unlock(&sfp->mutex); > diff --git a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c > index 9609eb1ecc3d..4ce080caa233 100644 > --- a/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c > +++ b/drivers/pinctrl/starfive/pinctrl-starfive-jh7110.c > @@ -150,7 +150,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, > nmaps = 0; > ngroups = 0; > mutex_lock(&sfp->mutex); > - for_each_available_child_of_node(np, child) { > + for_each_available_child_of_node_scoped(np, child) { > int npins = of_property_count_u32_elems(child, "pinmux"); > int *pins; > u32 *pinmux; > @@ -161,13 +161,13 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, > "invalid pinctrl group %pOFn.%pOFn: pinmux not set\n", > np, child); > ret = -EINVAL; > - goto put_child; > + goto free_map; > } > > grpname = devm_kasprintf(dev, GFP_KERNEL, "%pOFn.%pOFn", np, child); > if (!grpname) { > ret = -ENOMEM; > - goto put_child; > + goto free_map; > } > > pgnames[ngroups++] = grpname; > @@ -175,18 +175,18 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, > pins = devm_kcalloc(dev, npins, sizeof(*pins), GFP_KERNEL); > if (!pins) { > ret = -ENOMEM; > - goto put_child; > + goto free_map; > } > > pinmux = devm_kcalloc(dev, npins, sizeof(*pinmux), GFP_KERNEL); > if (!pinmux) { > ret = -ENOMEM; > - goto put_child; > + goto free_map; > } > > ret = of_property_read_u32_array(child, "pinmux", pinmux, npins); > if (ret) > - goto put_child; > + goto free_map; > > for (i = 0; i < npins; i++) > pins[i] = jh7110_pinmux_pin(pinmux[i]); > @@ -200,7 +200,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, > pins, npins, pinmux); > if (ret < 0) { > dev_err(dev, "error adding group %s: %d\n", grpname, ret); > - goto put_child; > + goto free_map; > } > > ret = pinconf_generic_parse_dt_config(child, pctldev, > @@ -209,7 +209,7 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, > if (ret) { > dev_err(dev, "error parsing pin config of group %s: %d\n", > grpname, ret); > - goto put_child; > + goto free_map; > } > > /* don't create a map if there are no pinconf settings */ > @@ -233,8 +233,6 @@ static int jh7110_dt_node_to_map(struct pinctrl_dev *pctldev, > *num_maps = nmaps; > return 0; > > -put_child: > - of_node_put(child); > free_map: > pinctrl_utils_free_map(pctldev, map, nmaps); > mutex_unlock(&sfp->mutex); > > -- > 2.37.1 >