From patchwork Tue Oct 8 09:00:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 833808 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) (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 461FF1C8315 for ; Tue, 8 Oct 2024 09:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728378025; cv=none; b=f0CKToovuTYewmd30P6yLyad73hxuqk/oNwV7qDDZUIT6qUffvBbO2VUYgni06A1NgfkIX+3rt5oGBV+YuedJnjuGPpHD1IKIgZW18Ke9NHANF1AufXCigrCUbmEHhjHM0YyvZeF5TiHfggXxjkqIT8li8dkfKJTS6J3nM/uXIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728378025; c=relaxed/simple; bh=r5aPI6Cjn0TQVJCWexA1Rya/HBg2dq+HlU8Qr2gItOQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MgzMWwvzcj2bf0bkboGjxjXR+ZpjI+xvYBdqnF8yR7MbrFuvzuGxI+6s8tO5ONMD4oRW85UoVkvtPNnMgK7LveA849suZn8WsXXXQ2McXf8I6mMbBfHFN977stdy//BvEZgRPQosmPMNpMzDbJp5Z0y0URzvfU9bT+2mz9lgY1k= 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=XQaDwyb/; arc=none smtp.client-ip=209.85.208.51 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="XQaDwyb/" Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5c8789e8e98so856519a12.3 for ; Tue, 08 Oct 2024 02:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728378021; x=1728982821; 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=adCWIIzBDnCRS+ya+uwdE4DOJNV+C/EsMYDSwCJFffY=; b=XQaDwyb/8GmP0gjHsZvRQSSxztSP9bAbKlFZV7XhF0C2PItkhAB4AAhdyU5a58BUAp zEjR9aF++7ftaSq8ru1qV/m8RRIdnSfnoWrUlLTxVJ7CmQAYu2aNNEQQRgsxu6zXXmMt an2DFFVhDnbu9sAFQET9doPiZ8dIzPaZaMjok2vTtVQU5jSmxB25/ThyvF9VogJMMOnq jI9lOmA/G0dxwNJfStICBoOrTpW2HojRYRszezpXUPvx1XqmbN0UAuJEW1Yb3MuEe2Xt oDWqNtE1S+4QW0FoXccOWZtDBfO/mwnb5efYjTGxF8vmT1lJTC4vRC21sPOXACieYby9 K9KQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728378021; x=1728982821; 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=adCWIIzBDnCRS+ya+uwdE4DOJNV+C/EsMYDSwCJFffY=; b=mNoxiq51PKuQBbP02+sQ2HgpZdvAJm9PdHSXPX4pPYOtG7+xMVzp0nyRIUdwDXfWC9 gLDdH0Cn3s0ucGlkdDLf4ldW0kuxkQvqix2g7ANMAwi2x6yF4jFBcGfoxaLaEyBKuIv3 67gZU0UzUG4M+wP72G3WmeUDEZ0KPrGKxnXLKSky+bqtxOWzrcR1E2LVWPEaI9e5lvHf vUhLEPCKpuWVgStH0c8+Utryj6NvXTXJVlIrW1G5aAMogWaLEb+F+GWmIztzg/8v27a5 bRna+mZK38v4fw1OGHPlDygckjp/UlroTr7UtxiVFhOHdGezN3VlhbYM9IYpjimjAyNG rF2g== X-Gm-Message-State: AOJu0YwtqSnp+gSK09CNtLcAR/9lutE8kF+5uuxJ9WspbALbspoayaNN KHO3ljUSxXqqdDvan84c82a/P5AcNHhgEHOUXBfVuMlvOccLfJfstSow0qGunJQ= X-Google-Smtp-Source: AGHT+IFyV5YlbliLB9Sn5wjUH6COxSzrncdb5qLhEV2J0ae0yBBiwgw0xI+8Arc8blW6t7WRxnafRg== X-Received: by 2002:a17:907:9443:b0:a99:482c:b2cf with SMTP id a640c23a62f3a-a99482cbc1emr374351766b.6.1728378021503; Tue, 08 Oct 2024 02:00:21 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a994e6e571asm294701166b.85.2024.10.08.02.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 02:00:21 -0700 (PDT) From: Krzysztof Kozlowski Date: Tue, 08 Oct 2024 11:00:02 +0200 Subject: [PATCH v3 2/6] 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: <20241008-b4-cleanup-h-of-node-put-thermal-v3-2-825122398f71@linaro.org> References: <20241008-b4-cleanup-h-of-node-put-thermal-v3-0-825122398f71@linaro.org> In-Reply-To: <20241008-b4-cleanup-h-of-node-put-thermal-v3-0-825122398f71@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.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1919; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=r5aPI6Cjn0TQVJCWexA1Rya/HBg2dq+HlU8Qr2gItOQ=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnBPSceSnEJp2lwlWByHAa/bugTQ/6DRWAT9fJb uGRxYnCYsqJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwT0nAAKCRDBN2bmhouD 17qJD/oDEDMG+qPpZYnaeRaztl0WT4abQ4WaCF2e5zgAu1S4llK2iQRYU0KB6Ddesl0KwXgMASd lmhBMg7VnYj8ZVR1cKExnTlws7HzVniO1HtKucpHlVo/1w9q/4nF5qusN2cj5/1NRIWgPA+U4CM GixsfXrDqjN7X2TaZ1eD9alLmIWjLXzyCiC2Hv4/E87ml31QZI8BM61nDrC23BRD9QnYUqkJMcU +j0H+99j9zNVohXBZrjDt/Nv6e6R1/tw/vgZgsomtaoO1Q6K2XYkl03q0ceZQS4jjqEq0Gmi0xV v0u2ZQlDTkKdB0oCeTuBwOqRsI62HW2J8tSnS6be7Otj2SDBNKEMT+D5O/6Dn3x1U2U81G9kZ6T 6EQQ8wQLExZprKqb89dkvyNw1gbBo5hKIaM+2PSXbxat3Jv+WpGq5mxrC2LfhzmFJmBqqjguyB/ k5+i9d46I76NJz63ak0t2QV8I+zn+aC10/+1CPDRO3V1laC+Zj3uoelmnA3gvgPYv+oFFOR1VyN q27M4IGIzUPAAl2t3IKzEqO9qFpl/Ba7gIHqUVDEWXzxbhd2ylR+H1sPz57KliloCQZmRJR+Q0W 1XqAaqaIAiFBXYKdSz/CZziyTsQTwHfi6k22ruGEkOWSbFJKBuyWMiQkDaWkCSH+YgwtHlvT2gw YynUKo3nC3wtIng== 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 f0ffc0e335ba9406f4fd858d6c561f9d23f4b842..d7d6f62caa13d545e5f7fae4c8ac1e737bf4c4b1 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -96,10 +96,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); @@ -108,15 +107,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; @@ -127,15 +123,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 Tue Oct 8 09:00:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 833807 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (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 57B9F1CF5CB for ; Tue, 8 Oct 2024 09:00:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728378031; cv=none; b=TICdaDWD6d5t0QPt5WduXVRg9pt4sabb+O12kKlv1s1IO1jBhprGZ4T89HoOx+keUbEHNYHEXM0k+5OZ2chTQjt6ihIogBvDbxc9arx3oTIVsreU75VdrsrKylIeRekS92L8XHPenO3iB382MPEtifO7ikW6rA2PBdG6x1Z9C8s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728378031; c=relaxed/simple; bh=fMDVmrSNIlAN6mKgDdvZqzHHbI0RRw3DAu9CnirmtAM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=aCsyulHT2jOVUXvmXbiMC0KDlF9TugcDYX4cDY8vfAApsDbN/0GpqFW7jFx6dGZS0OapWG1Oq+2u68wqYeP2dJMdaRvxGjs35b0RafUeBLI1cDyszQaaeIoD/OgPLyfLLYYiOHK7KPpVdJjlhYZsaH7v1BpQKIrGrk3hRkBgHAA= 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=r7g0f0Mv; arc=none smtp.client-ip=209.85.218.54 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="r7g0f0Mv" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a994df6bf42so18428566b.2 for ; Tue, 08 Oct 2024 02:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728378025; x=1728982825; 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=7hI3WMX3UyIZgodODIkEfxJvby1HaOS571OBh/jtnnQ=; b=r7g0f0MvVYOKENuXMfVXB8Uk5Qr/6ZSIJ7mBm9iya6Ndfe9SY39rhcA8neGC/YeLaY 7RdSFz3x0on0Ox+xmf9wC4eY8CAe/kmgBykOq/9M/tbrhGqrR44rJozVrFO+7UPGadzJ Jj1Pe0uSTYLqmM8eZ1a/JhNNTfYx5lwXKRbz+gKAbsFo/Y6fUlqilTBzwHQdofzuc0y9 y/EDV4ZT2AIwvHPfK3nrNW1r2AGlnyMVE2jf7c2AgIwUao9X71ZfvpPeIt2SoCV3VSJB 28GS03/TNQIuajregT40noZPhBsn9MtpFHi8y6OT1nwk4EpKViNECYCwDE0L4fQEMaFM sMYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728378025; x=1728982825; 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=7hI3WMX3UyIZgodODIkEfxJvby1HaOS571OBh/jtnnQ=; b=hCmQcg8dFJwvM+jXJBrpWzCmqSE2Mv4QsyfzXJVhI+Jd1SCvXTxppVgshG7i7aTOS4 db/g6DTNxKkkHiRcPXnf+P1hucl+VCR8HU/1PHEHzL0c8i0XrBnAUZx4jjkR7FpNiVEL x+rCChd419hje7+EKY/51UYPmhV0bJWqekX2CtAoMWLa2/WAvYQOXre/EBP05737vY/S zd2Na1El53sRqkyjBCzjUNZV0vpZn2YmTsnzO9CaZFoB2UtoqEyFqRn3dQZ/x/nllbW9 VGz572E1HhpLNfRPVCifARLzZVlFeQpm1WF/08rS4AvC7+ZadA8QIPQEAizIK1qZ7LFH MXzg== X-Gm-Message-State: AOJu0Yz5WeOTJLPHa2hfgwPwLfBjLq8YOh3ZYz1wphYVZ94ROepjCMXt fGK7erA+st5NJoFj+Fn6pS8T1b/g4ipfYl49MvKxoVhOjCzICPoDKFI/220I3XU= X-Google-Smtp-Source: AGHT+IGn3CxuMTqoQCh13mz4jC9JwZZSlRHEULhxnYn2dzYEgwR+mm0SUFPiPolkk77R3YOE5iHsbg== X-Received: by 2002:a17:907:980c:b0:a99:55e7:9736 with SMTP id a640c23a62f3a-a9955e79ec7mr244229366b.0.1728378025394; Tue, 08 Oct 2024 02:00:25 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a994e6e571asm294701166b.85.2024.10.08.02.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 02:00:24 -0700 (PDT) From: Krzysztof Kozlowski Date: Tue, 08 Oct 2024 11:00:04 +0200 Subject: [PATCH v3 4/6] 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: <20241008-b4-cleanup-h-of-node-put-thermal-v3-4-825122398f71@linaro.org> References: <20241008-b4-cleanup-h-of-node-put-thermal-v3-0-825122398f71@linaro.org> In-Reply-To: <20241008-b4-cleanup-h-of-node-put-thermal-v3-0-825122398f71@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.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1389; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=fMDVmrSNIlAN6mKgDdvZqzHHbI0RRw3DAu9CnirmtAM=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnBPSd09eIsYVkCYVYCFtZlxLflDGibJpZer6/c cwqxX/AN7CJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwT0nQAKCRDBN2bmhouD 1/IWD/9fe/DMRWMYbu4UcWX2DGRdX/wQYi2rD7n8B+VkDmq0wfAQZ0HLkkbappU3ISFcb+qEqEo ukgaKzu1lpDWZXDdGsUfbinrxufa5/xftAt2khQWgmWq5QwdtwBIF5jm4dGHvc+yQEBaoJ3ZGeq aMXoaSTCMCAogUZc0ic+SdX/plf+qg7gs4nimuwtpndONT+hq3qYHvk3hC5x0nhAMJ0gSmKS840 6g6ySO1Ji/wqZp81AifDouypuz7xj3vm2mKT+SWOOcYmnlx8gwHCXXvCgaIs1ulUwxMXkB11p7Y R6k4dVvZqTb8HSOB0Ez5JVkEJZ1w2HxF+rt/doKnG0Rw9faIlqf2eJ7B6DoujNofmCvqSrK5cax vCo+kx1rVHqwH0LZZdbgmYNZ7GrLR1yTM0gBfm0b0QQCHSgIw5EPAKT4ntW41iySAt9VWiWbP2U leE0F/Ffqbjg33IoY9O636bHq081Srro9eR1vdQmzDJK97cx2tBueTKltT6mLhZhz3PtgQpZSib x96MJXhDmBFG6meZHxPTkJXkFoc5punDftyolCJsk7u9nyxVx9BjzZ0mM5SfsX84ulV/e9OYOyg GE4vXrRlnSLyDllpDe7PngXzY8YE8XgxqOeDEEilgxx30OoFYTxCjzQYBJ/2YzVE4ieyMkl991V AD3UH91yTwkEzmQ== 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 5e94a45eba3eef65e436a01b3aa58aabf5f706c2..d7f2e6ca92c2c9fb532ca5d4bcc22b6c2cddbdb0 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 Tue Oct 8 09:00:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 833806 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (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 D42231D54D3 for ; Tue, 8 Oct 2024 09:00:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728378033; cv=none; b=I3j1z7kVKnw24HZAovSAzVPU5Xw/wd7p8xnTDRT6m7XlYwUUso/rFQpGmpwsWGazRwI6MPU2P796LGoJ84xAVU6VCNHgJzRGB5/Ne/8uWsZktgHOCQqu7TLqJK3AWexD4rjeUuQamjQ8A0UUIvkIcNKqBcx2eEkkRPzWfClj8f8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728378033; c=relaxed/simple; bh=FhSSUbYjEIvtsOA30smmw3DQZNhLSc6w/jfUrv5pJGQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bOtDObe/k6kjn7RKZwzefpfMZszqIFTdGe/PELRX+ad0gSf4FR19PFuUBhYWynm5TfNntx7c4Dn/KUDf+oCBDFblWAYDwBeJRQbtIOcKipZ6NlGO7IZ+38jAmv/yuC/TEY+UGE62F3mcdwUA7f6Lxf9sFYfOD712BTvIOpvway4= 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=pFkUD8SQ; arc=none smtp.client-ip=209.85.218.41 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="pFkUD8SQ" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a9953d3b2cdso22270966b.3 for ; Tue, 08 Oct 2024 02:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728378029; x=1728982829; 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=WqvSXxv/sXZh4YDTgQXsf5TmgeATsSUVXTwwhzFav38=; b=pFkUD8SQrF7dN4wJxVAAqXAxjByuPm8DaBRY+Uvs4Rtz9HX0L+1/n9XHe/lIyMvRIz 73mxxAyfJqobbHEQLKBuyIDgwisHIqLMTHolUDnZS7zDWdnQKXZAh9RFw+9JZEPm2XAK 2sD4cvUdxqkJUDvFYP9cyyS0JOF9vdELJhgEN7B+NxRPK6PSaeOChXGMZ3dJqoaHFCcW jAfDTsJYlh8VxecJ9R5F6ZfrPTeazxRsrK9E9TJOdKLyKoWuex+cAEBbvp9tDesPkG19 EnKIrHY1aaeTkXsK9sKz0SJlMTkRwFa3vVLvjbj6jXMK/t2f3Z0T5rRzdmuTsnoIXV9x uw7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728378029; x=1728982829; 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=WqvSXxv/sXZh4YDTgQXsf5TmgeATsSUVXTwwhzFav38=; b=T/bhwZLpUXIBas5dmDORCHoRFhtwtBSdJImiTscNj7BX4GSxyqIjrXhRGF/mUU5zds xKafkiaLYtUtkfNeZykg3Hae8IVBG21jSUdk4iFdeW3Co709CtZci5AYytbnZ2WYMI9a wzKEjR6oUFGBPKS7aFcKkk6KlBmk3tdZbgI+cOOjInkXcBYYZrfkew5V0IyLIaRnL0sw x/KIoxAZexFN1GkybrcWgZuz++1I/BRooFB4O6a+anHD/N+TCDgvK84ZCzciksQvTHHG 5Xq94a5ae8s1Ft02i1AuufPnv1x5euvX6pAFa1I4nLAUL17Xbms5+X4V6xjyLQ/cT41j 1JWA== X-Gm-Message-State: AOJu0YxFr52yAn/R4j7bK79HuTRteQtJZDiqIqTZcTw3CvmBowAqaLBo GRuHNcjfvT+Oja9DU66Kgq+aXQt0Q0ebu5SHDCAJWYp2lKf3M3nwoYMc67KRpds= X-Google-Smtp-Source: AGHT+IFnyQZ00WTesS7K+tvwWCInNJHE2ElAD+QHyyO9zbJNo147gVcQXc2DQgTrdqZeOoQgnFBBVg== X-Received: by 2002:a17:907:a4d:b0:a80:f54c:ad68 with SMTP id a640c23a62f3a-a991bce2e1cmr668029966b.2.1728378028617; Tue, 08 Oct 2024 02:00:28 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a994e6e571asm294701166b.85.2024.10.08.02.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Oct 2024 02:00:28 -0700 (PDT) From: Krzysztof Kozlowski Date: Tue, 08 Oct 2024 11:00:06 +0200 Subject: [PATCH v3 6/6] 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: <20241008-b4-cleanup-h-of-node-put-thermal-v3-6-825122398f71@linaro.org> References: <20241008-b4-cleanup-h-of-node-put-thermal-v3-0-825122398f71@linaro.org> In-Reply-To: <20241008-b4-cleanup-h-of-node-put-thermal-v3-0-825122398f71@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.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1794; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=FhSSUbYjEIvtsOA30smmw3DQZNhLSc6w/jfUrv5pJGQ=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnBPSfE1YKQx6eHCEVnRKeY3oZT2E67IuVgGqTh yKvFuSWE12JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwT0nwAKCRDBN2bmhouD 1//PD/0a92e+IdVlo1Rd94IpF461K36Nbu2qEwIl8Z7fifaGiJu7QHKtVmk47ZohZ6B8ygJYuXm T0qST14kdxL/AXy/Y23FX+h7AETR5L4omrqBZwsIcD6EeX1ap7QKpE9Ir8kjlTurpPf4N9XRvEP ZhxUCifgdhjpf5bHjGF69fW8S76we++KAKPCJJXV2YZ7NEM0TL6zbkJvcuOXsVXtMnmqZohB/Dn 3SjUZKT2nWWBEZAJLm++7ll2iXeue5bZReaf55ifDGSEGvht2vQonR3dTnaHAC8NMTsdlOHBIVv +MAN3obefMgGDXwMlSlxI4DME6H+LSJ/PUzba99CpgbLug+WFpRGodxXjNBEfJWlG2sNGWYWdd4 NuciO0D92ILoNmqk2paqYfM+BW9yanrVfIusWnDfzPt4iwUupv7/9+C+vSYkaMCRbo1Z8EyLy8O ot2Yoe91ibgcUCIjXx1o04tJ2JzP1rZFx4guOdjJvHMvvG/ZTKXcUiQ/SIkMupPathCMA2jCdwz wlXL5F8KSRRw0s5MaPGsrMh20yBKEgblq8+vPrNkJ8Lf8Oes9PFuNLTEqjJJgJEw9KgoL36/2zG lVpIywoGSVHcPjAotUE9tFiDT4q4ibyUp7Qt9HdKh5yTFk0qOmu3YaDG9gQer/pxcvTE/OjrctQ iYfmhRS9ItI4tAA== 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 3203d8bd13a8fc2a9e5a59b3547cefc2440542c6..22674790629a7b549d1ce618998ff51f6553613e 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; }