From patchwork Fri Aug 16 07:40:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13765624 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63E4F13B2A4 for ; Fri, 16 Aug 2024 07:40:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794050; cv=none; b=sHdo4742kjA7u291IM1zs42H0z2pVXECYZzEzfIsX3cZJTV+Wr6po84PwwRWppGofId8WtLJDASdranvrTFdpvZN0gixSITWf7FmXoDTV0q+Tcd6eakdrwAMwZBLclbLBucKRLyZ160PPYTfZ9mdFpzdXDsfTp1nYqYtzC1P/cw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794050; c=relaxed/simple; bh=PGsw5QEex7CpuDWx1RGJUm5OKheN4rGmrB1iCwFW2V4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Lnfg9OzWFwZgGSPvhFQQIFn+MZEu3vQID+0+vAhuQtdd2jR9dQdypKW/aAbORUZ15CzEgRWCmYJAQdkTb5QQ7O8kqE7txrclzHqq8Lbqk3EDPkG6GFacPOJMg42Fys9UBlPKIqLpziZfOYhqKfkj+wprw/960hf8QJfw29vdnf0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=cUEFcnkc; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cUEFcnkc" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-52efa16aad9so2135145e87.0 for ; Fri, 16 Aug 2024 00:40:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723794046; x=1724398846; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=1uGkngSoQ6xXDida4nnB27AlMz6Imue7QU/aLBQagO8=; b=cUEFcnkco1NOUOBwqzayBXVnkyiizhu3Wf5+NeVRjJzb1O44CtaBuhJ8KQS7O6sT9J ASQjmTpqQxaMPhZrq4LrD2CuwAGcfdX/XWNnBXh513bZZf9T4Hpflr3CqDsZ/580P6XP 0/ma4R6pGOtEAGhEmYmHW0lPcmv5oShAIXr/cqgYd0EROM44niMY7p4cUSFizIcAARSC hnYMc23hfKudwvn97bgfjyaz3XSXwO5K54uWuTM13o2WQBj5JwAHotpbZ5F+aWTmPH+x T3jziHl8TwfIKluX+Ahvg7PcOzpVEXBPfMBwFMCI86ZLOWHUu5Ibp3AMz7SO6AJXtgOL BnZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723794046; x=1724398846; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1uGkngSoQ6xXDida4nnB27AlMz6Imue7QU/aLBQagO8=; b=WPcOtEIclGbNKIYtBHvAWyVM/iLLwaC+ZkLudZ+VwR4dmpISs3/ExDNOj3C4C3qcp/ HvyAT5L5IrCMqa6cxlhIVi+YumgUjwe7HBfs9eGa6+U6p1wN/UzhQT1/YGYsXFC8rpgM IdL9l42XlOtvBq4tYlILb4PGUJvg1WOa5du9EpHHitTyeBdcxmBXgB1AWMbs0HhOSiyu zONbtmS/JP7fBY/VSLd0R+Sa/eZ8hziEC80rPQytUzqgkdrPkeTwLoSEim07xtn9jbI9 S2WNAOYGffITBUJnVr5cS9GfGonqqZD4TIzwwrwiygjnQdHu7iNWZ98e++RrWp69SlNA f44w== X-Gm-Message-State: AOJu0Yxkx6WfiNzKnSFSiuYDhphj2SZxiedEpAgBw9mw0oP971Tgs5/3 Vf1ASbuDe+AhswC5SslZQ7xHJ5+6h9wIErVBJ+A+pF7qUwiqe01IvaIbHrN0F6o= X-Google-Smtp-Source: AGHT+IHVpxmEDbWkRu0WtK0xFv4zm5wdQAu15HLyFiw3HU25oGcA8Yg4aEM9aSa1ga5Xo/0m7M9nHg== X-Received: by 2002:a05:6512:10c1:b0:533:6f3:9857 with SMTP id 2adb3069b0e04-5331c6904c5mr1276139e87.5.1723794046302; Fri, 16 Aug 2024 00:40:46 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded3596esm68549625e9.22.2024.08.16.00.40.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 00:40:45 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 09:40:31 +0200 Subject: [PATCH v2 1/7] thermal: of: Use scoped device node handling to simplify of_find_trip_id() Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-b4-cleanup-h-of-node-put-thermal-v2-1-cee9fc490478@linaro.org> References: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> In-Reply-To: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Chen-Yu Tsai , Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1658; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=PGsw5QEex7CpuDWx1RGJUm5OKheN4rGmrB1iCwFW2V4=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvwJ0a2oOLNxyHQgqOvUweDO+R4Igmr3Jpxu3e NoVVWn7VOaJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr8CdAAKCRDBN2bmhouD 1x/KD/4vzaf8o3Cs0YXq3URfWkk0gwTnAVURfyW6uwwZpyfLnu/c3oMd7TTIoOy4TNwSwBSvZjc W1rBbtDFaOvz/BBNm219y03iR1zBBaOpeShkSB0pRHJDwWgHDJpXMX1rau2AlDrA+f4lwJjPILf VXDQDyQFtUhwZ9ANVb7UDabNpbh1ImBgtqpCVwkdG+D9Oo40/5W6IaiLPj/BywB05eaoKvlyQ8v sOBetRdJQ8g/TYq4YQLEWL9Ze8hkP/+60KpyrwR5Dq8aldz2hbKQHN0XyILqw6jq2/Ra1J600BI PjyOV7YkvKAqF4BWp6IX6+rn21G5Alc9RO6A3p+S2++7HhBwdR7qU6kWgg60hXYtQJFphCOq+a5 7Is+mjf50wlyoW/3KMKA8wfZKBaTD3i4fbMEdOd31RnBImAduYDdeYmTJtCso7+w9hPPPU6g7GX MyXe7aPL/JaXdn4pU0rPJ5GSCArix+Tg8WlCpLgIisjgtPoVULa3cSCOedhgTN7A+wYpiNMPDhx x+XBdvyGoCoX3au0cqqSH1wJIeUez1zzUyoN+MVfxo7rv2qrpcJm+mzOMSjhBlBFpyJ5Vd7eT5O WY1I3zLiEZZj+Gb9Zk4IpHXFreff/DOnjmmqZrSL/1B5/F5MQCkf9vIflh6tMbvHzx2aE6K3BfV +2Qf1zWMPdhl/Vw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Obtain the device node reference with scoped/cleanup.h and use scoped for_each_child_of_node_scoped() to reduce error handling in of_find_trip_id() and make the code a bit simpler. Reviewed-by: Chen-Yu Tsai Signed-off-by: Krzysztof Kozlowski --- drivers/thermal/thermal_of.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 1f252692815a..a2278d4ad886 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -8,6 +8,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -22,11 +23,9 @@ static int of_find_trip_id(struct device_node *np, struct device_node *trip) { - struct device_node *trips; - struct device_node *t; int i = 0; - trips = of_get_child_by_name(np, "trips"); + struct device_node *trips __free(device_node) = of_get_child_by_name(np, "trips"); if (!trips) { pr_err("Failed to find 'trips' node\n"); return -EINVAL; @@ -35,20 +34,13 @@ static int of_find_trip_id(struct device_node *np, struct device_node *trip) /* * Find the trip id point associated with the cooling device map */ - for_each_child_of_node(trips, t) { - - if (t == trip) { - of_node_put(t); - goto out; - } + for_each_child_of_node_scoped(trips, t) { + if (t == trip) + return i; i++; } - i = -ENXIO; -out: - of_node_put(trips); - - return i; + return -ENXIO; } /* From patchwork Fri Aug 16 07:40:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13765625 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 236D413E039 for ; Fri, 16 Aug 2024 07:40:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794053; cv=none; b=NXNYkmhygrF7R9twrqiQsJ1sWsPnzuwkPb90e89/w5yK6y7tQvON+tlX+H7iFfBeSL1sfwipfmnIf8Lu6DFh2Xnh08PuVXqnwVt6QJZHwxWtCf0kxVG7OCJn1FbMZdIJJkWkw2xB0BM9pool+r9gNeixchYIdxvIL87gp5RpO54= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794053; c=relaxed/simple; bh=qxgv5qfoaV6bk0OmgUgWLVEm3V76aGC+t6S+7+lxV4o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oDwciaFPeZWz4lMcQCd7aHj5B7PWlBRjweOA5yBnByWFvlOsOR0W6FimmyoOdSiV1uKykWjwwGoKuCkzR9lgL67dOe82W1uEe67brOq1djtP/KIzLzP0jOezXUYQKMoC9eFCXSnzeK10MnwQs9EHN4CplxSDb1SBQFMgFnf+RGE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=KxFnNi+N; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="KxFnNi+N" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4281ca54fd3so12040915e9.2 for ; Fri, 16 Aug 2024 00:40:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723794048; x=1724398848; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=tWnAc9E8rxrrK2bbeb3Pwo9Qok9E02qmGv7eCa97j/0=; b=KxFnNi+NAbHm6u03vaF/2g5ES1iezk0rmu1Mq7xQpUxALPG4Ev09SyKYtuu3H2ZE+u e+6lGTEw8xq+ST3PNAJ3HXXus8zhX6ohL0nA7ysPwOXFtnRJhE84002tYn5nb6K2hqta wOXFgZarzYdokpNP06QXdQRnOdm0IvJ1Jf2auwAX5OH8+GTh55sJqQpqBSxFtVyvpJGX lcPEssCCjeJxuwP8HfOOSuu1h6b2xTpXN8YZ3Vp6mzNxn8lrWkbnnNGg+y7Ck6KY72hn XLXtth8OncFqWstCtulEA2BYXApHqTB1MmjHosHtnFdRbn3YVK3QWvK8JLwgniSmCe+/ YejQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723794048; x=1724398848; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tWnAc9E8rxrrK2bbeb3Pwo9Qok9E02qmGv7eCa97j/0=; b=iLPp+tkvljlTC376+lrZRXEnwu/jlX6r6r5A+B4u/NVz9db3B5ozHtR2b9hI+AXQtb W12fhsFBokXelCpyX+sDeckwrTObM17UyhRktVaLbWWOaCpeJSQPqusgCEvWP/yQqKD/ Xd4Pf+jZvi32+/r34wRXCUadlzxTR7QzZl+M6sWP+fHszcKoXIROT836qjdzk/sYid6+ YUf2fcmJFTIBQqFag9ITjBQCe9tiwUmgXY1HiNwbFRxHOw2ZU3lTbB7GgpuNJLqbbv8E r3rRsxbLU5xFFwIUdWhvk1zLMS/a1SQWXL/DAlNM8Z3fKdDm6fbqgq+na5BI3HEHDQIb MhNA== X-Gm-Message-State: AOJu0YwM5M+JuWFJeEhjDluxgrGubTY79glrH+9ucrwq6Vda6MbcWFz9 35jLksZi+w6cAGWzrFGgzFkY+EgbdZ79t0uhCMbzO5HxdH1KKbzUp3iDDjyz+Eo= X-Google-Smtp-Source: AGHT+IFzZLTDR5Z98Up78oxxOH+SbWTXfGpurjJuT98BrROkaRsrI5irwTZI7n2q0qacDhrKuwnF0g== X-Received: by 2002:a05:600c:46cb:b0:426:50e1:ea6e with SMTP id 5b1f17b1804b1-429ed7b79dbmr14872275e9.18.1723794048073; Fri, 16 Aug 2024 00:40:48 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded3596esm68549625e9.22.2024.08.16.00.40.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 00:40:47 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 09:40:32 +0200 Subject: [PATCH v2 2/7] thermal: of: Use scoped device node handling to simplify thermal_of_trips_init() Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-b4-cleanup-h-of-node-put-thermal-v2-2-cee9fc490478@linaro.org> References: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> In-Reply-To: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Chen-Yu Tsai , Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1865; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=qxgv5qfoaV6bk0OmgUgWLVEm3V76aGC+t6S+7+lxV4o=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvwJ1LBtoOQCdO9Cr1eEJODRs6I3T1W1H/w+SX U+gR/nFdGyJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr8CdQAKCRDBN2bmhouD 1xccD/0WObW22ZnbaV0PXY8czCHkU1Yim1p2MtptSNdwFysLYe8ouBEf5h0y2cVtx/WQve6U6Tm NRMDHm6TIiZ27dHtIGoEeMHJ5aE3VT+XaMnWZWNfYtPR6dYouYGFE01zHfrZA86jC76t4niQIS1 a0i8S/EO22tIYbNommV4h4Z8R1AXRsmERkng26Mqa6u36FwpC3mYKeJAIPet/tdYrIpgWxtiN6s JVETWM+MDJEpe/NCavkDNYUt/a9gB5Sfc3mYa34U5dKU4p0UUQLePzG2GIcao0vvhxsPfroWoa3 ntTls/kc8KJ4IORiALnrEZKIgr7tCXB7Csszwj7/B5N39OEqkTsXDefW9QuQy5bqR8m26qoJ1kI N5FZwQXzVfrvqK48rV2j0xfABUt3fsvhNhIf2RSoaKLIU3NBN9l4IibaQCwvZc+5QO5v5TzX0SM 15jyp/5pBeYp9XoMnKqXwPGye4w589dsJNpviP2ll0/hJ3zLyF05DZJLIQaCqdMSCjMIY/E4kRO IzPLGF7Qu+B1bzcKtOYEwZOmxj3CHSilb0tKztEo1XZON/Hw/h0hQk5Gyk1zZYlWLayUsebzO/E cG0Nv0ab5vTM99EmNXc+EOXesnUDcBQ/H4Z/D6f8zaJRjH7X2EbJDDWCK5/ZnoIBkRI6sQhToru LfpnO6jio4rXUKA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Reviewed-by: Chen-Yu Tsai Signed-off-by: Krzysztof Kozlowski --- Changes in v2: 1. Drop left-over of_node_put in regular exit path (Chen-Yu) --- drivers/thermal/thermal_of.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index a2278d4ad886..2a50910f35d3 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -117,10 +117,9 @@ static int thermal_of_populate_trip(struct device_node *np, static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *ntrips) { struct thermal_trip *tt; - struct device_node *trips; int ret, count; - trips = of_get_child_by_name(np, "trips"); + struct device_node *trips __free(device_node) = of_get_child_by_name(np, "trips"); if (!trips) { pr_err("Failed to find 'trips' node\n"); return ERR_PTR(-EINVAL); @@ -129,15 +128,12 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n count = of_get_child_count(trips); if (!count) { pr_err("No trip point defined\n"); - ret = -EINVAL; - goto out_of_node_put; + return ERR_PTR(-EINVAL); } tt = kzalloc(sizeof(*tt) * count, GFP_KERNEL); - if (!tt) { - ret = -ENOMEM; - goto out_of_node_put; - } + if (!tt) + return ERR_PTR(-ENOMEM); *ntrips = count; @@ -148,15 +144,11 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n goto out_kfree; } - of_node_put(trips); - return tt; out_kfree: kfree(tt); *ntrips = 0; -out_of_node_put: - of_node_put(trips); return ERR_PTR(ret); } From patchwork Fri Aug 16 07:40:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13765626 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB87B1411ED for ; Fri, 16 Aug 2024 07:40:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794053; cv=none; b=UbPcWulJhj4hRvyr/cHT0QvXDCfAzzRa0MXz9Gdp/zM3b/cEvVH3ap6B8AbEMprBmvwVlFiZ1DGSsIu2TCNKR0XUIb/cG32Q13Fw1Q4K9jQd9G1KGC8eO+Fixmla8z/BeyeRQhlcOwC+hX2jsNkAj9FPOVvxnZZf8IvfJbFIw+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794053; c=relaxed/simple; bh=6s2gwWxKV3mqwXT+dwK4AlJBQic8xfrisA4opFVm0UE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cdLakRhPIN53uyZsKDQ5XTRmwGh0LQ4jqm8HjZXTJaILmyoWFO5Gj/gLwBigWvFivCxjAlKt3QruwWgDsWVAzPKYn2Aeqwn82mkiNQjY1OixMpBVBPhNNA2+fxZ+nzOb8HgxRWUer7eiAVWRBauyx4dppkF9e9I06Dd73U7k71E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=NGBXsM3y; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NGBXsM3y" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-428243f928fso17059675e9.0 for ; Fri, 16 Aug 2024 00:40:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723794050; x=1724398850; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=gwBGzdvPQE1+PlP2CGFn94m3kIMhbJ1ppl7JVIwU/Xs=; b=NGBXsM3yz/RmUwBn8ckcxpg0oezJcRkKyfYCcab37HzqnMVeoLYjfKKYt++IDlxWYQ n8fGKkVdGTvYvJKF8vrEhp6bWWT9BeQKqDaSKhKdcq7lzhleva4wiBA3My2Lor5+SCsO poM+MuP0oIAvBSUJ04uf/WPgTvfX3uEz8mkRc8AF+iJ7C4mJ96hauaiFKqlqcz+qBs1e yM4t96i806WmQd5ecSnU434eKaLkDQ+0jkRj5Ldt163UyyeO0njqyV5EVFXSlLLon2GI chP5lbKzR04otvxDt5+x0uz1l5Hr5dXRKDCDTerUHRAQRSnTEPY8F3/dqvY/cYUIU9JG Rt3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723794050; x=1724398850; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gwBGzdvPQE1+PlP2CGFn94m3kIMhbJ1ppl7JVIwU/Xs=; b=aqduaTmAlKkM3ZoT0KX3NmxJjG/Z9HXrjVBCF0GKqeUOWEt+cCYTzkxVoRku+vwGuv 9Sib3ffxjUNAYpogEJ8sA/Ifqeaasbb6hTyjInoO24I4NqOZHDNPm0giwvvdH8HUtDRS OJDvxKBu2rDZPx3V8XSuDqw/vl/GQnvSuvgMBH42axbuZzRwJ95MqMsQteCl5DvMU7wk HaZ8yUSkUs83ieMlA8KHzpnw8ZOJDr9Nx+Wlqv8imFdhAme1xSUTyvMByokstlME5+Lk OMs7vCy0fnk1SQNWQ6XoBidOxedg6gSndWF6Wp1ak/R0NHxE0aR7F9pFAG5tfdBrbDqm 7XbA== X-Gm-Message-State: AOJu0Yz9kEUPAbmRoVZE3N1zJQwIQgkKeGK5gCkpUxqZiFnSLC/NGGak Hdp5qob9osH4ustD4GSMuL/NkEjWa8b6TLPiRL6wVF6sUN5xK6PNVA0mvsJPhLY= X-Google-Smtp-Source: AGHT+IHDNoBVC9DJTAN7nMWLgAJqFIpeUDbPlSUB2QVzC6f0vvEYmRzQmwtSF9FAc0KhjOO6gOsnCw== X-Received: by 2002:a05:600c:314a:b0:429:a3e:c786 with SMTP id 5b1f17b1804b1-429ed7d63efmr16437415e9.24.1723794049913; Fri, 16 Aug 2024 00:40:49 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded3596esm68549625e9.22.2024.08.16.00.40.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 00:40:49 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 09:40:33 +0200 Subject: [PATCH v2 3/7] thermal: of: Use scoped device node handling to simplify of_thermal_zone_find() Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-b4-cleanup-h-of-node-put-thermal-v2-3-cee9fc490478@linaro.org> References: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> In-Reply-To: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Chen-Yu Tsai , Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2305; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=6s2gwWxKV3mqwXT+dwK4AlJBQic8xfrisA4opFVm0UE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvwJ2/xkGjrR2HLRRCkRnrdwrqzBDjdW9vwQDu 1NHmeLLv4SJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr8CdgAKCRDBN2bmhouD 14KYD/4j35A7vHJMVva9jFQ0cMzcZ6YdZMHe6OP0JJSb8mMlKA1s1B2BsZz+nMpVUWIY+2x0H3h sGzAoiG/OvTTlK7dxg73Z14uKEXLe/Nhcfpp31/tfPazE8Qt6Is9TEEwUcs1k9p6w2xsSnTnAi2 splayRHNzbrKXwFOuZv3ZkT7j6pgxu0DClbPaZvmIx+gvOJUTX118gds8FK1oIP/ON2NfmOt6ni +x/AuGUdfVHzuk7xzuLIHLsAhAmhV/kj5IokJjSz5QZKCstDeoPDY5F9voMexvJinkW/I9znMq4 YAfRZMm/g702PbGTzd8MGXn+Nit5dejzrm6DTn+k7RXZsCSStzsHL4KCHScpD/fxUkY0SzKRVPV +69zpM0F+mqxwlz4JPuCzUqQtfg5zvE2rHcQQrP0FitAQdciBV8jcPlJ68LpjClPOW6f711Kb0P pkUrptRVLQ02NqjvEhHsW4eGB3QBBX38GI4S8I45jHGFcw1XYgpinYeCq+SsyILyAM9ah0059VC QLPvv8lNHpqm4l66+odOdUugDwPSy3YGyfNn77ZpEdOOke7FGGNWRWFBFkofev2xJua7SqG4iy6 cCcMy1kb+js5A6Y8XWzXLyZECp7oTRKQzg0whFvzwTBGjhWOTv9qlLW3ZhP1X/SWdF2fJ7z1CQv ImfcxuBeksGl/vQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Reviewed-by: Chen-Yu Tsai Signed-off-by: Krzysztof Kozlowski --- This depends on my earlier fixes: https://lore.kernel.org/all/20240814195823.437597-1-krzysztof.kozlowski@linaro.org/ --- drivers/thermal/thermal_of.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 2a50910f35d3..94cc077ab3a1 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -155,10 +155,9 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n static struct device_node *of_thermal_zone_find(struct device_node *sensor, int id) { - struct device_node *np, *tz; struct of_phandle_args sensor_specs; - np = of_find_node_by_name(NULL, "thermal-zones"); + struct device_node *np __free(device_node) = of_find_node_by_name(NULL, "thermal-zones"); if (!np) { pr_debug("No thermal zones description\n"); return ERR_PTR(-ENODEV); @@ -176,8 +175,7 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int "#thermal-sensor-cells"); if (count <= 0) { pr_err("%pOFn: missing thermal sensor\n", child); - tz = ERR_PTR(-EINVAL); - goto out; + return ERR_PTR(-EINVAL); } for (i = 0; i < count; i++) { @@ -189,22 +187,18 @@ static struct device_node *of_thermal_zone_find(struct device_node *sensor, int i, &sensor_specs); if (ret < 0) { pr_err("%pOFn: Failed to read thermal-sensors cells: %d\n", child, ret); - tz = ERR_PTR(ret); - goto out; + return ERR_PTR(ret); } if ((sensor == sensor_specs.np) && id == (sensor_specs.args_count ? sensor_specs.args[0] : 0)) { pr_debug("sensor %pOFn id=%d belongs to %pOFn\n", sensor, id, child); - tz = no_free_ptr(child); - goto out; + return no_free_ptr(child); } } } - tz = ERR_PTR(-ENODEV); -out: - of_node_put(np); - return tz; + + return ERR_PTR(-ENODEV); } static int thermal_of_monitor_init(struct device_node *np, int *delay, int *pdelay) From patchwork Fri Aug 16 07:40:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13765627 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2C7A14388F for ; Fri, 16 Aug 2024 07:40:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794057; cv=none; b=T1ZDCcIgsK7XMndORioZrOXTuSmyPHhEF0JwyY5JsFrubod9Zcumkc+byeD0OTonnWWhCRS6zy2m/tY5Ta+flywuOHpHvFKZ3GoPE4DW31hZqhg+4JqQJknfCs83N9dFkFJJvblmETmQ+fYPJuQ52Y/ogd4ea7E//Y6qEMsWMe8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794057; c=relaxed/simple; bh=9M5ntznKTX5NDEFACMt23t7+gXPt/dasJVMFbG8WF/M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qHIp0ZWbGHnA9SySoTmHX4PIi4rur0OY0gsTe9hs9xYd5wvevqdOWQTWw9Hrz0qQ988syXUtR3wuq1/DbofsiT0Yn6TlgfDvTG6Ee45FEZjqc1Ii3QEdxrU94yxis/SObnlsAXq2Wsu8aH3qaIVVaEzBl+3ZugQmHcLLoAQOziw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Eb90VByx; arc=none smtp.client-ip=209.85.208.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Eb90VByx" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2ef1c12ae23so14946131fa.0 for ; Fri, 16 Aug 2024 00:40:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723794052; x=1724398852; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=NpiLIHd7RwewW+o/fTDGbmxF9iEJfCFxBRNxKUku6uc=; b=Eb90VByxzOuc3RJPVDMIkIywo54AUDWzqyw10c8rsYAgTbkoyCn3oMqcEZQgFThuU8 cG9NIjFey05N119ActgiTtkoIU+BNOE8PoyNdkS+jMJVrU7QZor9+nEzwbhNgHyiDmPS zcYq3jba/8+XAFXBlGxcy36Z/d0T1zJjIbBcioG8hhcCgRTdEt+vgIBy9bIasKqxLejD 1tH8hrCDOojaHF/L32Wv5fCqhNYUPbslXaC//G9UhlQ85PnRqjl3KKC0EYLLG7VH1xqV p/fBH6VbVoduWPNiSMdoIvCeZ+rHZbgJ1JDh1ylmGnrlpBF6gT3HjlwlMd2iZ6NqDh5h gmAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723794052; x=1724398852; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NpiLIHd7RwewW+o/fTDGbmxF9iEJfCFxBRNxKUku6uc=; b=vwVJ+Wsbo+Ik2MdFKvkj+YXG+fyNIXRvoVacF6+XOJmO9GjPocSZpv5Nnhk7Wl/cLA uxgBk+4TGI1TEFbhV05WdXTogvQ3MMvah6T5996lbjbxz4UiASRmjyUetleJoBFWW55v pvHg3IpLI9bvjKWCW69999Llas6BHnWwrPs4+hwD384QaYS6X+wHvXVWJNZ0utSQFNUf qOyumYHMZ+dpIQGj7Z1stEKF8E74++i6D2E4at5y2Y/ZbcTh2X6q8EUTa+5pXlDItBLJ DPDQ96DNGDOinq1J6nGS69rxFzwz2lOYJucDllP/imOc1SxRcNDZJZnD5tCeZtyhTvWG lcVg== X-Gm-Message-State: AOJu0YydtUnlLyKmsDYGBLHEmrU1qOvbK7PTDe4XjEcRKOSIbNjuT+UM CujnOnwv16gP1Vhf37IBFbgehKKhakUeBxU5/91G/zDGP4QyRKWgAIEjl7yKyv4= X-Google-Smtp-Source: AGHT+IELCc+OCzcJ/Js9NwPDwHfifOzvE4gl8BthiWmIBR2Eaem8CWHrHiKiF111j3uXtD+30pxdXA== X-Received: by 2002:a2e:a99d:0:b0:2ef:2490:46fb with SMTP id 38308e7fff4ca-2f3be5f59femr14797761fa.37.1723794051688; Fri, 16 Aug 2024 00:40:51 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded3596esm68549625e9.22.2024.08.16.00.40.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 00:40:51 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 09:40:34 +0200 Subject: [PATCH v2 4/7] thermal: of: Simplify thermal_of_for_each_cooling_maps() with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-b4-cleanup-h-of-node-put-thermal-v2-4-cee9fc490478@linaro.org> References: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> In-Reply-To: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Chen-Yu Tsai , Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1310; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=9M5ntznKTX5NDEFACMt23t7+gXPt/dasJVMFbG8WF/M=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvwJ3KbC+CIW/wgMP/qsQhWUwSxbE78dCD5pPL pLwIbQ3KvGJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr8CdwAKCRDBN2bmhouD 1wEiD/9ZPNQh9CCdAjJ7tvBzsxq+KQKtvaWC/fQDIECn5V/X2lAA0i7fPqDihwYNGci0qdbP77c nGwvi5k79aqQ/K9EHna3OBQR343woYrPjcIQ/3kYcvzY9DdqIXbNaGVHtypT154nMeZysDY1jbd ZxM2XiVBivBQvsad9X21O6NKdbP3u6KvuLXNj6aaIJ0gPQYU9/PInP2wU/21gIYSAZTsVLEwxaf 9Gb0c87Irgoq1zyV/6LIzngJVoJtQavHuWHgA66hTlAlYhZYAqq/TTUsJzNP2tWmEVUVz7qL8rw 8nGc9pL64W+FFW2EvNgZNbFFT42DsghleR66MnBH/hMxcLpyg4lYtAt6Nzd6kHBYzexQzp2Tq3m dXNHetyc4N0Qg24s02eeR8eILN/iHrAKJAhYEPuLrRNODZs3yBDSk+ZxJJ78w2B/I7jRDiwTnaj fZxW9te26WMReCULmYh/TV3wBj/O2qgl8ZwEogLuB5xZ3fEqfBnHRfT5mIGSzJ4YG85T+K/hJMR ayrpjXDymP7W+xnSv8auBecvBDVuTBMeHWvoxaSIf7jqrathAKibinrv5qi8KU2uG4A2i6rQtZ+ 2QlPWRmMoyiFKZdF+ylcC+RC2TyCdKGZLQFkq7SwSQXMs2KTP358oSRs6MeyTky/OfRLPvq+Xy5 52INWgb0WAFW/4Q== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Reviewed-by: Chen-Yu Tsai Signed-off-by: Krzysztof Kozlowski --- drivers/thermal/thermal_of.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index 94cc077ab3a1..ce398fde48bb 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -373,7 +373,7 @@ static int thermal_of_for_each_cooling_maps(struct thermal_zone_device *tz, int (*action)(struct device_node *, int, int, struct thermal_zone_device *, struct thermal_cooling_device *)) { - struct device_node *tz_np, *cm_np, *child; + struct device_node *tz_np, *cm_np; int ret = 0; tz_np = thermal_of_zone_get_by_name(tz); @@ -386,12 +386,10 @@ static int thermal_of_for_each_cooling_maps(struct thermal_zone_device *tz, if (!cm_np) goto out; - for_each_child_of_node(cm_np, child) { + for_each_child_of_node_scoped(cm_np, child) { ret = thermal_of_for_each_cooling_device(tz_np, child, tz, cdev, action); - if (ret) { - of_node_put(child); + if (ret) break; - } } of_node_put(cm_np); From patchwork Fri Aug 16 07:40:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13765628 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DBE114A4FB for ; Fri, 16 Aug 2024 07:40:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794057; cv=none; b=VDfUcwkaWFTRIkegqaRc+zjFaeKKB9WALqnvVn666ykr0bDKMgrAU9YlZk4tH5pKq61xxN9VAqIUt7kW7niHeobDAZVmoQcuW9PvTIRg/xa6LHA9j67Pc6C7RgmMkU+Hc1bFaCFluh0Ufd84UGF2bLU43YS+3ORx1GT0Ct9LVBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794057; c=relaxed/simple; bh=PbJeEGZU3UpmozZSCe3r0DvMlYlbAp7Fh7CGsGwwTnk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GxLw8MeyVfwAj3Th8/akwpOkqigRdFwEia1GxyAxEBoUyi75ZICBkjT5LtxSlLCcfsDJtHm61COBe1M7NUR/XO65lsdttwG2rZupVDhdmJ4L4/SiVrKCKtw3BFNfO7uNqInIbCn+nTsxy0Wqjeb2LBgda7bf2QvW+Hhr0p82E+A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=DJi0EE35; arc=none smtp.client-ip=209.85.128.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="DJi0EE35" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-42808071810so12091835e9.1 for ; Fri, 16 Aug 2024 00:40:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723794053; x=1724398853; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=0wMpDkMtET/7aAM65Zz2/Kcs6PKgOPihE5IRKM0OVVc=; b=DJi0EE35vju7zEq3P8l1XDiXS5LlurXhoN3F5GfKoZRfOTA1hittAGKXflAPhDBr9I +DMsl2j90UOMZ1qdaTkm8uX2gNZiDx4yg8nu0lrHrzqbfXhUraKtdZs76ejDNEkBfbV6 HNcHkAWz6C+M9St7BBh8cqW8zZmUBn0p82qdihOteK9aLflAf7SvnJJdZt1inP6ZI5jO QvKjnUzVoF2LR7cs+mbJDt1eO0vOd1eLavUW3c86ScsTB1u55Ck1iPL9VrbakiLecovi vz1+iPWCyYiFcXLzji+geuEnnBd4AjXHC7KZ/NHUhKEoaPwj9nnlhl6sB30luGaKm/OV lGbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723794053; x=1724398853; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0wMpDkMtET/7aAM65Zz2/Kcs6PKgOPihE5IRKM0OVVc=; b=tKs2b9qtIk5gyd+9G17DBbReYJfRHSyan0usiZrmqW1EYSzGOZHWRlVF7sE9gihKb9 bsY9+XmYcYX5fBHJuo17x98YOieTSuMKVXhtxhkYFFvUMwxzgpdcF0esRqWzbj4LsQnz 17W6PfwReIPqH8RZj0o70r4vOE4+PHHTQ30pZB/KzUXA2XdT6irCSToksH7ZcXu4kPNx 68+IZxiROQUXaOLanWw+YpN79jeDgGwx52EmILEdZW3vjLW/bI2HVyk1KdLVk+pGLuI/ +SBbG40lTK1HAfNgoxDgq+Y9jNre11WI/6G5sqzGt7vqGueMpmir1z7xqv+fxv6uCEEs rcHQ== X-Gm-Message-State: AOJu0YzjS5MwbLIE+dbrDpGsHtWboUSIRG2m6hZ7pR0KiZgb8FZ6Iijd 9qMyINcfBlkkii5c7FzUc0UlBEx8o5ZUkPxuWw3/4wuh8QNxSHg2t6t7xqashNQ= X-Google-Smtp-Source: AGHT+IEnXbQO9mmtyvuxjzYjdXQUi2maQz0qIi0DaT7l9WqGJwLWdeuDft0i/qsT1e/F2DXQfswARQ== X-Received: by 2002:a05:600c:4f48:b0:426:5b84:86d2 with SMTP id 5b1f17b1804b1-429ed7b9391mr16384705e9.20.1723794053471; Fri, 16 Aug 2024 00:40:53 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded3596esm68549625e9.22.2024.08.16.00.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 00:40:52 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 09:40:35 +0200 Subject: [PATCH v2 5/7] thermal: qcom-spmi-adc-tm5: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-b4-cleanup-h-of-node-put-thermal-v2-5-cee9fc490478@linaro.org> References: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> In-Reply-To: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Chen-Yu Tsai , Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1333; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=PbJeEGZU3UpmozZSCe3r0DvMlYlbAp7Fh7CGsGwwTnk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvwJ4R960iiX78E9nbSk6rU3XcRyumrrr+WNwm b9uWv5JL4uJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr8CeAAKCRDBN2bmhouD 117ID/9EACqKFcFO6/LOiwiOQBgFhDpNJAh5abY1rYNUwH6civPjvKo7M1pZANYtvFOAb1NcY+K L0XUBZ1qUwcnHA4TEelwGC0qKPEU2delRJzqiitq/NS84JtEIZN3EXedyZAEvaGMr8kY5sAQ2Lj ezGPzEZRdSmWeBFbR3R6HgVKuZTmLfXO8g3yCatnh1PQyomIywfLrFk60IFFqiIS2cafdrsv8Wm qSUw2PK2e0cM/4dc4HptXcs+fr/zCC+sSICFfCKZ5LWia8XVwXxopYBK3NHbpD2ndfaFJRamXhA cLqeLQXVXxmTSt4sy2bEMQb/SJRE8Adi6sNdoxQoB2xxCWpRTYRgQmkHmu4qZvfsy5b2DoUg4WA qiWVWtqt8Cfn8i/UHVqlJ7+idqLMCACVEw/6v3LxwJQ0nrQ93wmRHqwiR5QmK/8ndrgBnNPjb5b 3JsQaU8mlC1O/ZHGA34DuII/fv+D8b4cHHSP0IMAR6m6JqIMCmnlNWNWSrxgF31Lgk+D5z8rpYM auRMmfihug05VxVXVoYJ27RBVuRpmN+Rkrp2rvAXYHuddV0DmEL06/ZlF0psI/X7TgNCjWbjPeX bBpNobaS18uO01FwmZbRdjVzYV6G40GYDQT1rbs32LG/aL36N8DPRrkSTdgySwNFEsu5VprtL7J +fC+fPiASEAIR0g== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Use scoped for_each_available_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Reviewed-by: Chen-Yu Tsai Signed-off-by: Krzysztof Kozlowski --- drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c index 7c9f4023babc..19cdb98c310e 100644 --- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c +++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c @@ -938,7 +938,6 @@ static const struct adc_tm5_data adc_tm5_gen2_data_pmic = { static int adc_tm5_get_dt_data(struct adc_tm5_chip *adc_tm, struct device_node *node) { struct adc_tm5_channel *channels; - struct device_node *child; u32 value; int ret; struct device *dev = adc_tm->dev; @@ -982,12 +981,10 @@ static int adc_tm5_get_dt_data(struct adc_tm5_chip *adc_tm, struct device_node * adc_tm->avg_samples = VADC_DEF_AVG_SAMPLES; } - for_each_available_child_of_node(node, child) { + for_each_available_child_of_node_scoped(node, child) { ret = adc_tm5_get_dt_channel_data(adc_tm, channels, child); - if (ret) { - of_node_put(child); + if (ret) return ret; - } channels++; } From patchwork Fri Aug 16 07:40:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13765629 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 055F314EC55 for ; Fri, 16 Aug 2024 07:40:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794059; cv=none; b=YlfEbvy14bP3Ua4RAAlPrwVtxm+gqoDCtt62AWv+zw+PwyoZxVNMk3Vjj2EDoVweVqukvtHI2JYo1KIotsCQ06fpCAfmyAwEvxArkYPQxTpxNLmkhbXZD3ognR27XFVxhtKr+jwus4pec4YGP+i/m1kjE7ayN93ayWKzxYOtQEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794059; c=relaxed/simple; bh=IirK1kH8ZFaYK+Qd1HN3sx/SR5DeUZclZQLJnYIcqp8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S5ueJD/PFnlVGvRJtDr57RyOhEC8S6iTKGEtVb69xOslWladvhWmZCrx/b9lqGx1w5NfsIYARl/8ULJN1qlMXlfq7RWk2Rfo3q0EX4btAjFNwVEFkTuC8FAstgPGW1MvwKhqOWMphZhK+k9AEnXv8Z4yXA/t5SEr2SHs2WGeReo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=sRFDflZe; arc=none smtp.client-ip=209.85.208.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="sRFDflZe" Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2eeb1ba0481so23952381fa.2 for ; Fri, 16 Aug 2024 00:40:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723794055; x=1724398855; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=oOnuVPSEiv2AcMdh6RSWf26c7BxWtZXwLCBzhkW1eTQ=; b=sRFDflZelQqLh2GzBncplbSib1SK1tJ/h6i36pCkAQErUXZCF6NCh3CFoJRQ8VfCQC FjBiSUkYCpiH3kjdcY/C3v3IHCc4seQ0Deq2o0CKTDGxsT2FCtzsEvgerHlE2kZegpIZ Gxagtb47e4R23zS9AymrLM786jKhKyQ5IaeFcNoT3qlk5rlfoHRuEQ+coD4FqVD56nEn HGSwJOaSn2fHnkxCLJYplwJPytTaubkrd/T1/KMaunsoIPXrZ6B//SaXfjEmfuVL0xZ2 U4iLBpZpG6V4rJHHKLTuXLUlNRDS6dGQGeDEBYW+iiT67Opc0OSf5PYzvpbUhkQ7xxPg l7xA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723794055; x=1724398855; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oOnuVPSEiv2AcMdh6RSWf26c7BxWtZXwLCBzhkW1eTQ=; b=tIrt6LmAz/bpI0S7RP6lWeRwJluqOj0poKnEVmmDmuVI6fnMt72jOQOfihtQq9o6Lo QPKArRI47k7aNSH6sg8HSV/RXb8uJFXqwYnUwC8PQL6zS4L8g9D5cggQyvlnqx5mcgdb zY/oRImV/0r4X93BZaGFxQgB2m2a7OSuS80LalniOZO1riK493+ksZoi9TAr5h/V1DdE to4xU2u04hNdotSjClqvSA2RUXjA4EujgKVPuBLx8bP10Ynqjrqvy6P1qucyzLa5OAgV //bdo3fOIHvlFGMG4d0kL6V4CJuboHW67TDCOwD/BDOJo+Gzjlht4nDqu9FlP87X8+wg VprQ== X-Gm-Message-State: AOJu0YxPNUm95Wjsay1RfSCaIMzVCA6ZG1p4YBvYr4YjXWE7fWxwvxxD uTayzvI61WuCe9IhuKyQRMBla1taZ0GszHhTKN9vaHUHGgK46Y+PIIT9yLXlnbs= X-Google-Smtp-Source: AGHT+IGm5wS69TxUWTKg0DzxkZwTJea1xUpbHE65rKz/zhe5yL4AjAz5VVHvzlDKSEanOGu6NzifNg== X-Received: by 2002:a05:6512:2346:b0:52d:582e:4117 with SMTP id 2adb3069b0e04-5331c6e979dmr1102171e87.54.1723794055062; Fri, 16 Aug 2024 00:40:55 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded3596esm68549625e9.22.2024.08.16.00.40.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 00:40:54 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 09:40:36 +0200 Subject: [PATCH v2 6/7] thermal: tegra: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-b4-cleanup-h-of-node-put-thermal-v2-6-cee9fc490478@linaro.org> References: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> In-Reply-To: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Chen-Yu Tsai , Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1360; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=IirK1kH8ZFaYK+Qd1HN3sx/SR5DeUZclZQLJnYIcqp8=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvwJ5VFTD7jL8T2C8EqxXgCoZt3AMXm79PgzLr sTjGUCyw1CJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr8CeQAKCRDBN2bmhouD 185yEACQBjW7Xgteb2o2laP/JQ0q3JXG2b2i0GZGwB62iEyDcJl4EGxBEYWTcrT46Hu2ROUiWQp w1q3LqVeSLyeTgJBHMJsSkkjhfuUxKQWw56DNwzQKUAyh4Fdvghc2CKYG+cwcEqTJQL7tSdDgZw KYLGFFrEkyk3wlvOtQakEetOfeo25JvN7cRrlsXV3PoH7YO17+UAPON1ou4KYLlykgmm/ppYxUd zfql28aKU4u9B2AymcC5MR22oqSwFYKHVjQee4HAkz8S8v3VxD+I3eOrdmsVTiEukprVNg1i6TZ xDhx4+YF1Js9VHiz2UVhiS1WNClUjtIuJRk+FxwL1cfiMLo43nZA2J326D9ZW5/QTY1wQDRshq8 pYZv/BwvC3nqcvQ1L7hQdwtGEH/p3B6EqwVyNuTsVQIMWdU2WxbS9n9ema0tyKKRmhXFNiKERvg Jtbbz3Nn2TjOjTzxxSVJJESFTZ565vyBN4moKHimhY2oMLxrSrX7af74T4DSE8QQYtOuOPRhHaG YURgdAWhPOrQxyXTmWnTKOsanvyYzCnnmD4G+PoRKKH0ukZbLede20bOFqANr+ARvzEvAPEKL/0 Ot1U/iyTkPXgGJFg9NJxZCHrGHulNvz47ruEPfYLGRTO/XsI7D2CInaZbbbJqzrSxTFMgr/2Tnl OIS185LIZoedfSg== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Use scoped for_each_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Reviewed-by: Chen-Yu Tsai Signed-off-by: Krzysztof Kozlowski --- drivers/thermal/tegra/soctherm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index a023c948afbd..ff4eedb553fb 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -1651,7 +1651,7 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct tegra_soctherm *ts = dev_get_drvdata(dev); - struct device_node *np_stc, *np_stcc; + struct device_node *np_stc; const char *name; int i; @@ -1668,7 +1668,7 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) return; } - for_each_child_of_node(np_stc, np_stcc) { + for_each_child_of_node_scoped(np_stc, np_stcc) { struct soctherm_throt_cfg *stc; struct thermal_cooling_device *tcd; int err; @@ -1683,7 +1683,6 @@ static void soctherm_init_hw_throt_cdev(struct platform_device *pdev) if (stc->init) { dev_err(dev, "throttle-cfg: %s: redefined!\n", name); - of_node_put(np_stcc); break; } From patchwork Fri Aug 16 07:40:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13765630 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B49BF154452 for ; Fri, 16 Aug 2024 07:40:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794061; cv=none; b=o5B8VnGsCKnchNW9SlwjRyX6xAV8jhqBn+txLjniRpntapmoFM1zHwwP8i7NBGfK14JZvT9LAxiIbD/Z6mrp3MqtPs+poJVjS/NKNzQI2Yz+HuZu36JTRMZdNMtilUpqQXtDyZHwYWA2clJK1QoWvPtqhslDrDTFFH7AfBzO4/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723794061; c=relaxed/simple; bh=7lYxEsVb/qq30tr2DD3cTPV+RMRQzHM7Fgim2MXKpBA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VRatjrR1vJQow4GEjcbnxjGl4KhTrfWyqyfnScCiMTuCNEJvxrjv1J0tLUqyc9U9eogGehf78DR85Dnj3xg1VXLdxuIsX6uJY+QFeJgQfY0YD4cuYjWb5WHPWlFtl5g904Q8hzkDFx1RqKzmeaATl51CzxHF7irQsos91ou5T6A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=NeoJhy2D; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="NeoJhy2D" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2f0271b0ae9so21727841fa.1 for ; Fri, 16 Aug 2024 00:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723794057; x=1724398857; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=9JdqhQJg9tqO70Am2MfrLJH9G5/c61L2bJdKSagfTBo=; b=NeoJhy2DT3avlxi/yl4BB3bFw81hJXz8LQ2VLNUbe3bBdMRpNh6Icjl1KzuHQckUKJ yJhz0QXxGnnuJ/UggzlITMmIM77mjVkaxJXCNxVti4V1EDJC/pAw9FCnAFzcA0OJVxid g9nhxRONX9jvYQWUfmr+jk9Da5t3FbuIEV8PEZNdDoVrFxu6WnAxKFXer2qHeIbmqz0m Rc4sWdGxj8wLuC6DTN/a7tk2hQO7+nFy73Gx+Yl9RqkTBAOJWg2QM2/n0Qgd9CZNvH30 BO+YfQude3Hv+7qOqWD8n5tttp//jTtyOQgqifupPAnkdlK5q71iwFRsII/4rRiJI8hp Jk0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723794057; x=1724398857; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9JdqhQJg9tqO70Am2MfrLJH9G5/c61L2bJdKSagfTBo=; b=Q2iV+BZcHRaOuwV7aMnZPk0O/0c7MNFFEo7Dw0aOfKcJAaQCxeTWwFqxYSj8pUdE1J n6aAznNH337xK2+LzbXsG1P/HMnjc6swIaIuKFk0AL+hP/xfh2gPk2tremW/M5YhpwAH TvNDJcj6Zp5McmU1zaF4O+pTQ8hhGkiQTqOw+KRZ8zPVJXkxw70to3lf/TxfIyY+yo3T l0j59b36GCU8gQ6g25aG7Va4ywslm4R/V6MQp1vcZBHnfT9ZHe2xmcGj0ul6zHdLc7WH ULEfgXaYKMawdzIwUzYzU6o55+3xiwOr2C7ood4zhJ4V7V74XhDyYkOhD/P3zh4hSewO qvew== X-Gm-Message-State: AOJu0Yz16F+4JTlCnGzmC8OgRFT4kTmMVMPFPdL0ZRM+HKsiPRd0oNJD qw+/mvo8HDkgks81FVgqtfr1ZOJ7iTwm2dvG0edqAOmIpAfGPVxCqqf5KI4csLw= X-Google-Smtp-Source: AGHT+IFng46YGuFdeI8Nsjr6y894x3z2p9eM8ib37Z+84ygXNOpNmPnx5CY2gqlXge3dOuzGltuT+A== X-Received: by 2002:a05:651c:2209:b0:2f3:bfcc:245f with SMTP id 38308e7fff4ca-2f3bfcc27dfmr11018411fa.32.1723794056695; Fri, 16 Aug 2024 00:40:56 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded3596esm68549625e9.22.2024.08.16.00.40.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 00:40:56 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 09:40:37 +0200 Subject: [PATCH v2 7/7] thermal: sun8i: Use scoped device node handling to simplify error paths Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-b4-cleanup-h-of-node-put-thermal-v2-7-cee9fc490478@linaro.org> References: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> In-Reply-To: <20240816-b4-cleanup-h-of-node-put-thermal-v2-0-cee9fc490478@linaro.org> To: "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Amit Kucheria , Thara Gopinath , Thierry Reding , Jonathan Hunter , Vasily Khoruzhick , Yangtao Li , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-tegra@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Chen-Yu Tsai , Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1738; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=7lYxEsVb/qq30tr2DD3cTPV+RMRQzHM7Fgim2MXKpBA=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvwJ6UNfnp0tie7SEZ/wP0iNL7BdNyio7hvR8O v0rrbnESNqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr8CegAKCRDBN2bmhouD 1yXCD/0ZSANIEvytztUy7N1aKygpEA0W+OtaWAfHgzje8/nrrw37Vj7R9F5U4d8bCnca1YbpaBR 0hFoPL1ztdLpO+arwSdcLIm311bsrZFi0M9FMTULTEztYtIcWnFgUn2JgDkDr7NYbxliR1um32t CX+ZZl4YyROsC+sNKqeOFUr0vA/lAJPsSi4n8v8rKWyGSUwS/FvP/UMgMQy3KsdUhkNIBWAl5Td eZTf1Jso13H9hy4vqqQfK4vs0Yjg37f27NjIbisRXtmR2luP7BynqijMS4wz2YQhOREaepvqCT9 sSpeHUc7reUrQg/QXq4/pXWUKc8JVdwkpi0GyQK0PLugPhp1zGJ27xHJknJ+8MDBPDUs9AmScrk SGiE5WS3faW4kayaCtidnEqTo6ziq3t8BlrDsIrvV4DOTcSTb7kZLJKoHJoVuOyGi8Uj/qTR3iS h4x0pRufI2cFbUgxeowOeRl2/j44xA8p7+TP9nP2cZDj0M8nKL06pS2z+GXlFbVicA9y7kgVGyM P1ep9T1Aoea+3RWm0ayHrKqsQQhtpWXvAKLpXyOLkOJikfRXvnIEXW+9l2HuynHGpvunkK4qMr6 9JOC9JzZPWD7NctDtgPUhzxqK8O/Q9eSJXA/oXGJqSXUG1zXmcFlXCrv8WeoPh3Lla/ePLSskyU q2P213hlz5q6OXQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Reviewed-by: Chen-Yu Tsai Signed-off-by: Krzysztof Kozlowski --- drivers/thermal/sun8i_thermal.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/thermal/sun8i_thermal.c b/drivers/thermal/sun8i_thermal.c index 3203d8bd13a8..22674790629a 100644 --- a/drivers/thermal/sun8i_thermal.c +++ b/drivers/thermal/sun8i_thermal.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -348,19 +349,18 @@ static void sun8i_ths_reset_control_assert(void *data) static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node) { - struct device_node *sram_node; struct platform_device *sram_pdev; struct regmap *regmap = NULL; - sram_node = of_parse_phandle(node, "allwinner,sram", 0); + struct device_node *sram_node __free(device_node) = + of_parse_phandle(node, "allwinner,sram", 0); if (!sram_node) return ERR_PTR(-ENODEV); sram_pdev = of_find_device_by_node(sram_node); if (!sram_pdev) { /* platform device might not be probed yet */ - regmap = ERR_PTR(-EPROBE_DEFER); - goto out_put_node; + return ERR_PTR(-EPROBE_DEFER); } /* If no regmap is found then the other device driver is at fault */ @@ -369,8 +369,7 @@ static struct regmap *sun8i_ths_get_sram_regmap(struct device_node *node) regmap = ERR_PTR(-EINVAL); platform_device_put(sram_pdev); -out_put_node: - of_node_put(sram_node); + return regmap; }