Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp752169lqo; Thu, 16 May 2024 23:45:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVaBapkPA2rsfASOHknkchAhQvTzUhvLLZwGfgJsHRha5/Tc1cP2BCEdReMSg4ZJMdKjg+ShXjDD/STvL6EXoV02ias2+DZM9NxT9Hu4Q== X-Google-Smtp-Source: AGHT+IEaNSg0Ud2K/762oMn+6Y0RcHObX83VX1TXUFIGJ59Ymb8Nglmce6F90uD/OIcdvMkV356S X-Received: by 2002:a05:6808:2995:b0:3c9:713c:1269 with SMTP id 5614622812f47-3c9970bd1b5mr19543037b6e.38.1715928322190; Thu, 16 May 2024 23:45:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715928322; cv=pass; d=google.com; s=arc-20160816; b=qWt1qiXCbOHG5lJKYAK34xE0rmRUzW/IRu8SxlHrOLkh3xTDB7mJCPscRYD27/6p6d tfO+ml8hmbaNZ+6Z2+u1AdSAAxnUC+flwZlq7x/igP9kMGutQ8/E6rFklNzt/3Q8XOUa jCGnQn/JP7VzT4FH6TFvZncR9u5wkWB5aRThTZC81uqbr3qqaBZEUfFd4FwN1ufCj131 /Ws/QplYyJcm05EKIjkWkbDK6Ecz5uA0r7d7gilXAGTSx49L9dQwPwRrhcIvgga+khcW LXEFhN4g9CAdf3gyif6Iajy4IMBixLH2ed0ikzH8HHtdFsq/y5dhNKRuzDbrQBYLeQlX bAyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=z/uK7yf6eIe+jSuaXNY0ImTzPYAvaGtkUIkCxsmH9qM=; fh=+GU34/zUiJa+HVrriqfxbB87cwLEnid1dI1yuZrKSAQ=; b=r7s9EePu4DIN/FrFEnYpK2RnNL015pvK2dIcu5TR3lT8n9U1gWcjmcNIGLShiSvHNU GzYkCVHKBHFWHQdeLGMwxDM4T218A91RjOHAZA5+jvnpnBAKKIeBT6ClDV8FhjZKf4Xp t3akoHbXCXwnqg8tfTrzuQJF7TYWpyh2Xw2O+Rq3yYVq7DLarMP1SIHp5cJjUuEXxKlT Z+Bjfv3mdX9FlDb7BkdGByIGdaJNorwljUyoU2gcKcfZfJAChIEv95pN2IVVRXPQnQ0J HmFrNTCDxadCpRsFqE6lGmPpjp+SAB3WFeOEwyorVb/x6+0NG6e3uL6F1g/On6hbmC/j OO8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b="tMmyJ/dM"; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-181769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id d2e1a72fcca58-6f4d2b3d546si16993028b3a.304.2024.05.16.23.45.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 23:45:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-181769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b="tMmyJ/dM"; arc=pass (i=1 spf=pass spfdomain=foss.st.com dkim=pass dkdomain=foss.st.com dmarc=pass fromdomain=foss.st.com); spf=pass (google.com: domain of linux-kernel+bounces-181769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-181769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C4E1F2820E2 for ; Fri, 17 May 2024 06:45:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2011A14F65; Fri, 17 May 2024 06:45:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="tMmyJ/dM" Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (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 E6D86134A6; Fri, 17 May 2024 06:45:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.207.212.93 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715928313; cv=none; b=QxeDOVLQUvmebinNSVCBDr4L7vYNjG2WseJRCPo9d2FDHgk9fsceqn4w+A19oGPzq5GeMxbBUCA3WRw0TXkC5YHoxoUwJpdxOh55h1Nn+e+2KxvMAB1b5kcfK3Q4zY/QIBoOFbLkuyvkZf9GhCdfh472J1Ly2NSzt7qrgKPbT0w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715928313; c=relaxed/simple; bh=2d8ySRlSXwbmMwAUg60FXtHZ9wSpOywMHJPzjAcqCyM=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=qwfcRLoQHYOUXCm14h/Snun7+MoY2JYDbzxmeU86B//PjV0tNYa0LNdV9Y546rpObpLl8Rw/PEQ3sCCR39QvODscVt7d3qXP+0hK5GZTdk3L1hDJrpPWPqnJ3COBRcHmQoMB1fgT1eBXxQheMGKxTgHYylxebxjHko23GmI9y0Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=tMmyJ/dM; arc=none smtp.client-ip=91.207.212.93 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 44H0KKJs005405; Fri, 17 May 2024 08:45:07 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= selector1; bh=z/uK7yf6eIe+jSuaXNY0ImTzPYAvaGtkUIkCxsmH9qM=; b=tM myJ/dMGKQ2x/4Ia33JfzZHcbgnx7LWrzROgMgfHhzPWq0PRz9OjTTociU4rQ6I5R IYFzIFLY0ReOsUeTwx91iz945oEF7HmCnXypJxQbRi3+yIQ+10AwkrblW/lieGiG 65WmOoAnpKxBY/y2iy7RqLElDrZOTGjUwgSsM2gVxnZyEqUNzyno7y/GRQZZjFEV OSxYVDjB6Y2pyBD6b+pV2aLeUDSz9GEULXeSjZOMbAB/C/K1yx0SCrI3zfofnHJ6 AZOrbjQ26YwAEE/E5uByqagJzdtxukCnzwMGt6xODMYg2i6T+bOOvR/RP2gycvfH b3ijlVxPrqbcbkxrKm6w== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3y4symgb72-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 17 May 2024 08:45:06 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id B49C64002D; Fri, 17 May 2024 08:44:56 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 871E621058D; Fri, 17 May 2024 08:44:26 +0200 (CEST) Received: from [10.48.87.62] (10.48.87.62) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Fri, 17 May 2024 08:44:23 +0200 Message-ID: Date: Fri, 17 May 2024 08:44:23 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 08/20] pinctrl: st: 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 , , Krzysztof Kozlowski , Sylwester Nawrocki , Alim Akhtar , Geert Uytterhoeven , 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 , Tony Lindgren , Stephen Warren CC: , , , , , , , , , , , , , Peng Fan References: <20240504-pinctrl-cleanup-v2-0-26c5f2dc1181@nxp.com> <20240504-pinctrl-cleanup-v2-8-26c5f2dc1181@nxp.com> Content-Language: en-US From: Patrice CHOTARD In-Reply-To: <20240504-pinctrl-cleanup-v2-8-26c5f2dc1181@nxp.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SHFCAS1NODE1.st.com (10.75.129.72) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.11.176.26 definitions=2024-05-16_07,2024-05-15_01,2023-05-22_02 On 5/4/24 15:20, Peng Fan (OSS) wrote: > From: Peng Fan > > Use scope based of_node_put() cleanup to simplify code. > > Signed-off-by: Peng Fan > --- > drivers/pinctrl/pinctrl-st.c | 37 +++++++++++-------------------------- > 1 file changed, 11 insertions(+), 26 deletions(-) > > diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c > index 5d9abd6547d0..fe2d52e434db 100644 > --- a/drivers/pinctrl/pinctrl-st.c > +++ b/drivers/pinctrl/pinctrl-st.c > @@ -1195,10 +1195,10 @@ static int st_pctl_dt_parse_groups(struct device_node *np, > struct property *pp; > struct device *dev = info->dev; > struct st_pinconf *conf; > - struct device_node *pins; > + struct device_node *pins __free(device_node) = NULL; > phandle bank; > unsigned int offset; > - int i = 0, npins = 0, nr_props, ret = 0; > + int i = 0, npins = 0, nr_props; > > pins = of_get_child_by_name(np, "st,pins"); > if (!pins) > @@ -1213,8 +1213,7 @@ static int st_pctl_dt_parse_groups(struct device_node *np, > npins++; > } else { > pr_warn("Invalid st,pins in %pOFn node\n", np); > - ret = -EINVAL; > - goto out_put_node; > + return -EINVAL; > } > } > > @@ -1223,10 +1222,8 @@ static int st_pctl_dt_parse_groups(struct device_node *np, > grp->pins = devm_kcalloc(dev, npins, sizeof(*grp->pins), GFP_KERNEL); > grp->pin_conf = devm_kcalloc(dev, npins, sizeof(*grp->pin_conf), GFP_KERNEL); > > - if (!grp->pins || !grp->pin_conf) { > - ret = -ENOMEM; > - goto out_put_node; > - } > + if (!grp->pins || !grp->pin_conf) > + return -ENOMEM; > > /* */ > for_each_property_of_node(pins, pp) { > @@ -1260,17 +1257,13 @@ static int st_pctl_dt_parse_groups(struct device_node *np, > i++; > } > > -out_put_node: > - of_node_put(pins); > - > - return ret; > + return 0; > } > > static int st_pctl_parse_functions(struct device_node *np, > struct st_pinctrl *info, u32 index, int *grp_index) > { > struct device *dev = info->dev; > - struct device_node *child; > struct st_pmx_func *func; > struct st_pctl_group *grp; > int ret, i; > @@ -1285,15 +1278,13 @@ static int st_pctl_parse_functions(struct device_node *np, > return -ENOMEM; > > i = 0; > - for_each_child_of_node(np, child) { > + for_each_child_of_node_scoped(np, child) { > func->groups[i] = child->name; > grp = &info->groups[*grp_index]; > *grp_index += 1; > ret = st_pctl_dt_parse_groups(child, grp, info, i++); > - if (ret) { > - of_node_put(child); > + if (ret) > return ret; > - } > } > dev_info(dev, "Function[%d\t name:%s,\tgroups:%d]\n", index, func->name, func->ngroups); > > @@ -1601,7 +1592,6 @@ static int st_pctl_probe_dt(struct platform_device *pdev, > int i = 0, j = 0, k = 0, bank; > struct pinctrl_pin_desc *pdesc; > struct device_node *np = dev->of_node; > - struct device_node *child; > int grp_index = 0; > int irq = 0; > > @@ -1646,25 +1636,21 @@ static int st_pctl_probe_dt(struct platform_device *pdev, > pctl_desc->pins = pdesc; > > bank = 0; > - for_each_child_of_node(np, child) { > + for_each_child_of_node_scoped(np, child) { > if (of_property_read_bool(child, "gpio-controller")) { > const char *bank_name = NULL; > char **pin_names; > > ret = st_gpiolib_register_bank(info, bank, child); > - if (ret) { > - of_node_put(child); > + if (ret) > return ret; > - } > > k = info->banks[bank].range.pin_base; > bank_name = info->banks[bank].range.name; > > pin_names = devm_kasprintf_strarray(dev, bank_name, ST_GPIO_PINS_PER_BANK); > - if (IS_ERR(pin_names)) { > - of_node_put(child); > + if (IS_ERR(pin_names)) > return PTR_ERR(pin_names); > - } > > for (j = 0; j < ST_GPIO_PINS_PER_BANK; j++, k++) { > pdesc->number = k; > @@ -1678,7 +1664,6 @@ static int st_pctl_probe_dt(struct platform_device *pdev, > i++, &grp_index); > if (ret) { > dev_err(dev, "No functions found.\n"); > - of_node_put(child); > return ret; > } > } > Reviewed-by: Patrice Chotard Thanks Patrice