From patchwork Mon Jul 8 10:25:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13726385 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 270BBC3271E for ; Mon, 8 Jul 2024 10:26:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=jI6VExt196cOGjHLMIZgkrjN4DBF+pr/VqM+rA0L/Ng=; b=p2LeiPR7gPTUhr7QW9WMhNxvt5 L60tHeOgpo3Kyfgxf5Y3U61QyXIB4UmBZrcm7f8gXwEOeEM7I4HvEdsN54pRBvfH8Zwlpx5PmuJ6s lPbGAtLX2M41XifqgvwgJV0ilUxaId+V9IaeeVwaMoLMn6bbRJiX0IK57GFwUN0BI0OX6RAk+Os2h p6Px2nInyS4GsktE79wll8ZaB+kB/38BbYzRuU8kVwNmGwmYfq/xKieMJ3fdX13YgIoQUewGmNhC6 9k7VQi24/yaTCi3oXZ2gmIdiH3sVGQ8eoM1qIDc3Ur0SAJ0cwzjWYMMHW5GaRgV9sz+g+km6j/4js 58zuDz/g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQlZA-00000003RYA-1Dt3; Mon, 08 Jul 2024 10:25:52 +0000 Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sQlYm-00000003RRv-0qNo for linux-arm-kernel@lists.infradead.org; Mon, 08 Jul 2024 10:25:29 +0000 Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-57ccd1111aeso4795291a12.0 for ; Mon, 08 Jul 2024 03:25:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720434327; x=1721039127; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=jI6VExt196cOGjHLMIZgkrjN4DBF+pr/VqM+rA0L/Ng=; b=g6162hcU1XxljxSSLGsfsMOgtJn9ZRzpwHOHZnxd5qDeOzKeU+Ci72Bo0cca7X81wD pFD2VKqCa8oPy9NBLjGnhOPQ9j3/2PUBebSMCbs0g83XFiboM9SdHC7oOTygHbCU9WLZ nIuxIt87QXwFpoXFM1lXNM6vR0QVA6KajBuLg8Cw5zW90HEzyaGoywSO6csTh2cKZKaE OmM+nrBZMuB1rBlC3MOiCAabnAwqZoGX8567sL6bU81azRc4cY//Ar28MXRYvARSkuRB hFOjlrd6TYT7LJzozy/0fHQZsF8lqPzxDyIQUj0UYsTUxs2PliJmnoMybI5Gf0r6wqCl aGTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720434327; x=1721039127; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jI6VExt196cOGjHLMIZgkrjN4DBF+pr/VqM+rA0L/Ng=; b=YKzEiagfzqnHgYT2MGjF5YesYp6pyokKAKX+l6n/OQ49Ojpe5gsxnEmAsYiA4dV8Mh tqsZm4USI3EJFr48R+hnQp6VFJ7Pl9qMkbU7WBYj1kW8B6IszNtGLereIX/NnO2kuENB FVRKdwfigDQ0I/xv3L5LuxpkZqF3fcL6Pcm/dfZVFvzxoaq+D+98oZltyvj7NZuvHLbn Pcl9Gci4AibOE9hXvfx6HmPsYWE4sO/Mjtl/zCpWaYH4R4AoHg1Bv9X09OGmEOc/v36q uv2xzhWSTui9geNsY1CPAgkbmJtCXT1O0uCOhmt5ZiMwBToNmmohA0KL8zT0/t4S4pS9 5W/Q== X-Forwarded-Encrypted: i=1; AJvYcCWvFB3jCVESPBRsAb2lI5CJyy/TEjEBFerUc9xroY/F2PwBsHqhYhwfUeNDn5qUYeZoMKxdbdbysZgGlqI0R0jcxJC6Ze2V3R6PWhCXjWiBKt3sBY8= X-Gm-Message-State: AOJu0YxiulWdodJCr6RuCotw+CibrOdstG1K5Pe6uqaf7Y8walSiHiln 5cA7dZHLzkxtx91hKLsxVBCcMCfD2Ca5RwWlYzxoJ19h+ZFLRYrEsWMqNc1qhY79KgSK70FT9kM + X-Google-Smtp-Source: AGHT+IFGnbgPOvevHxHVID3Wzld0NPCwFbKNE9rjCXjOAdsm+hZ7aEjxXKtcxeG1n3/cwquRVy1giw== X-Received: by 2002:a05:6402:35ca:b0:58d:115c:f529 with SMTP id 4fb4d7f45d1cf-58e5a6ee3f6mr7598736a12.7.1720434326728; Mon, 08 Jul 2024 03:25:26 -0700 (PDT) Received: from krzk-bin.. ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-58b246087e0sm8045437a12.62.2024.07.08.03.25.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jul 2024 03:25:26 -0700 (PDT) From: Krzysztof Kozlowski To: Linus Walleij Cc: Peng Fan , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, Krzysztof Kozlowski Subject: [PATCH PULL] pinctrl: samsung: Use scope based of_node_put() cleanups Date: Mon, 8 Jul 2024 12:25:19 +0200 Message-ID: <20240708102520.26473-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240708_032528_273831_79035B4D X-CRM114-Status: GOOD ( 15.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Peng Fan Use scope based of_node_put() cleanup to simplify code. Signed-off-by: Peng Fan Link: https://lore.kernel.org/r/20240504-pinctrl-cleanup-v2-20-26c5f2dc1181@nxp.com Signed-off-by: Krzysztof Kozlowski --- Hi Linus, I got only this one in the queue, so sending directly. Best regards, Krzysztof drivers/pinctrl/samsung/pinctrl-exynos.c | 16 ++++------------ drivers/pinctrl/samsung/pinctrl-samsung.c | 19 +++++-------------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c index ce5e6783b5b9..b79c211c0374 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c @@ -662,7 +662,7 @@ static void exynos_irq_demux_eint16_31(struct irq_desc *desc) __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d) { struct device *dev = d->dev; - struct device_node *wkup_np = NULL; + struct device_node *wkup_np __free(device_node) = NULL; struct device_node *np; struct samsung_pin_bank *bank; struct exynos_weint_data *weint_data; @@ -692,17 +692,14 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d) bank->irq_chip = devm_kmemdup(dev, irq_chip, sizeof(*irq_chip), GFP_KERNEL); - if (!bank->irq_chip) { - of_node_put(wkup_np); + if (!bank->irq_chip) return -ENOMEM; - } bank->irq_chip->chip.name = bank->name; bank->irq_domain = irq_domain_create_linear(bank->fwnode, bank->nr_pins, &exynos_eint_irqd_ops, bank); if (!bank->irq_domain) { dev_err(dev, "wkup irq domain add failed\n"); - of_node_put(wkup_np); return -ENXIO; } @@ -715,10 +712,8 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d) weint_data = devm_kcalloc(dev, bank->nr_pins, sizeof(*weint_data), GFP_KERNEL); - if (!weint_data) { - of_node_put(wkup_np); + if (!weint_data) return -ENOMEM; - } for (idx = 0; idx < bank->nr_pins; ++idx) { irq = irq_of_parse_and_map(to_of_node(bank->fwnode), idx); @@ -735,13 +730,10 @@ __init int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d) } } - if (!muxed_banks) { - of_node_put(wkup_np); + if (!muxed_banks) return 0; - } irq = irq_of_parse_and_map(wkup_np, 0); - of_node_put(wkup_np); if (!irq) { dev_err(dev, "irq number for muxed EINTs not found\n"); return 0; diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index 623df65a5d6f..a7deae4afdcc 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -251,7 +251,6 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev, { struct samsung_pinctrl_drv_data *drvdata; unsigned reserved_maps; - struct device_node *np; int ret; drvdata = pinctrl_dev_get_drvdata(pctldev); @@ -266,12 +265,11 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev, &reserved_maps, num_maps); - for_each_child_of_node(np_config, np) { + for_each_child_of_node_scoped(np_config, np) { ret = samsung_dt_subnode_to_map(drvdata, pctldev->dev, np, map, &reserved_maps, num_maps); if (ret < 0) { samsung_dt_free_map(pctldev, *map, *num_maps); - of_node_put(np); return ret; } } @@ -849,16 +847,12 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions( * and create pin groups and pin function lists. */ func_cnt = 0; - for_each_child_of_node(dev_np, cfg_np) { - struct device_node *func_np; - + for_each_child_of_node_scoped(dev_np, cfg_np) { if (!of_get_child_count(cfg_np)) { ret = samsung_pinctrl_create_function(dev, drvdata, cfg_np, func); - if (ret < 0) { - of_node_put(cfg_np); + if (ret < 0) return ERR_PTR(ret); - } if (ret > 0) { ++func; ++func_cnt; @@ -866,14 +860,11 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions( continue; } - for_each_child_of_node(cfg_np, func_np) { + for_each_child_of_node_scoped(cfg_np, func_np) { ret = samsung_pinctrl_create_function(dev, drvdata, func_np, func); - if (ret < 0) { - of_node_put(func_np); - of_node_put(cfg_np); + if (ret < 0) return ERR_PTR(ret); - } if (ret > 0) { ++func; ++func_cnt;