From patchwork Thu Oct 10 18:06:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13830624 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.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 EECF61C1ABE for ; Thu, 10 Oct 2024 18:06:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728583597; cv=none; b=qQnRgPOrPFtQMt45WwTpd3SwbcIxfOYIBG+NLDKUeNcLOQ5pNmf8MWS5uW9gujH+6KJQOtDwnASzFQlWGsVi1+T6mDFuQ8C3sCwyPf91A5VQAb60/bvjW3wbSR8tP+hZWnNxVVEGOzBzAbau7JHZcR+i8dJwjfFxF3oMF4HjA4c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728583597; c=relaxed/simple; bh=21ObDeB7Uw+CZa7niRziQZGtHt4YzVv2qAEMDtifp+A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PpxgWRTnzQ+bXN8M6L2/cN4n/3MIxnUs4qYtzv8/OsXO4drDBL0S76gltKHPIwgjxckiJBwWrivGcGmK+DXy9uwuz2uJXapqfpS/gkF0fZ6EmJzRsGP5ZSS4ppkkaxpLg9yCxuID6mt0IaE7lnJktTixv/PlD8xCpDJ27L5F388= 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=f66KCI0E; arc=none smtp.client-ip=209.85.218.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="f66KCI0E" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a995d3cc573so14636866b.0 for ; Thu, 10 Oct 2024 11:06:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583594; x=1729188394; 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=XVR/FvDP5mhKIoh1Y1kujnxSoI8PJE0vC17HhQCmzJ4=; b=f66KCI0ED/RW9AUI9gXWyzfhNMrARv9YV3j4Q5LVzVkZ+AO8W0vOfqjNKXWTqKBnao W6DjwWjzHM6ml8voRIRJenSlaQm/cFsWPu5/XKcMgryVuS1KkSwWhruLPKv/bOmtmeoA 3eG8usTQKHx9iihBXkHVMY0hvqKMAwudI+2lZ6bwDDGprUAzlf5vQu2OVTXNuQrUSmP9 y85RLgmJ+CgkeWetB25XK8UmVbD75jQuNqkgKYrj/FoNnzrFtdteEoXqpqLVi/umHjfY 2cTYVUhEUAbshVmfEmUwKOeSCBv/sm+46RslQkoBt+4jV8aU4883dgsERrAL3opvAEcW M3HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583594; x=1729188394; 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=XVR/FvDP5mhKIoh1Y1kujnxSoI8PJE0vC17HhQCmzJ4=; b=sFhjmf5vJRxZ5KVF7bGkoZubha3EZqQtV6Ob+HZozxgIuS13+AROyHHPamA3mgcTwd N2jReP/Ok8h7PO9sE+rK1E+hfjRzmWyqgdPRtgn2SY7KxA/vUyHSzHiyWI2QeYESSdlj iyPcIOTeqH542dfdmASFFco26wkGd6winMwT+viArDHx9Ms9ZYY5Y6xVgBbmKiNTAhZL +ueJNwo9R/dkvAkP8xrC0lY+jJ2eC7ZsHeeeGMH96vk/mafTD4d1tXHy6Evx+WCX7lrV qY7LatzPGKngEdcxCMed46d8OANetK7k2VcDhlpKYFWxMSzw8DyiKEko8AXcczjWfjd+ Zzqw== X-Forwarded-Encrypted: i=1; AJvYcCWWoYnUG2LT2lEP307+CppCy1/GMxzBYHMMWSUxYPmD6id+/hk5QOMr3uGM5MflmUudFRYXJcYAQtsuA7lx@vger.kernel.org X-Gm-Message-State: AOJu0Yw9e6hzkrklKAjYiweR4jSAA0fMdYiHxzlCls8IGIyTOAQ0r6kW oAy7orK0PPPuHIdNmBhgiFreUpwFG5qbzT900/8SoHYXN7kaXmxu63V/MAwrWec= X-Google-Smtp-Source: AGHT+IHpSo1bYpbQTRApH52ZLkx22//wr4+WM4NMb5T69enhQxaHE8oy4HxKVHQ9HPHYW4HoXxn5kw== X-Received: by 2002:a17:907:2d8e:b0:a8d:4410:3bd6 with SMTP id a640c23a62f3a-a998d16a1bcmr285817266b.4.1728583594256; Thu, 10 Oct 2024 11:06:34 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:33 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:17 +0200 Subject: [PATCH v4 1/6] thermal: of: Simplify thermal_of_should_bind with scoped for each OF child Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-1-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@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, Jonathan Cameron , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1418; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=21ObDeB7Uw+CZa7niRziQZGtHt4YzVv2qAEMDtifp+A=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBegb1ST/vPn7ZbI4vbAm3dM40R8drrb7KNXe ium4Vc1Q5qJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXoAAKCRDBN2bmhouD 1wR/EACaO+1utPorr9k+KbMHdTtCwjgZJ0u+vdGMXRDDjW3QbIQfwJl/2brqpM6MmZv+QBLAhe3 9E67zox8RRdjTRvyCyV4B4qXqA88p9tnj9iLBBgNt4I9aXXeYwpfIGaRk/FDZtVsG+kT9qRe5gW njBUzqQELD10L77i8aglLv7Wz2BZyLegcXh1RpiE/jBphdpydEfiG7zMT/gupnQ9uG946N9Hkzs rVXexntG66EPfAzg8fG6a/fTjnzwTwEYP3mfb644cLbAa0+Fq2BS1YdupOyRkuQEweVTeWQhM2u MGHBXwWcEULDqc9I///ZayC7rqIeSa0AEqyXt6IegYO9eNHWtbTOFk4L2Wsb6xiPflzQyvEECdO ubdTdXqDvabhRuvsl/xY4SLKqzzwhF1QY5FmyCzD0w42dLuzC0+4k6oKn7zGxt+yyn7VysLqJ1C LC/bNXi9OEVnDQpSVJoPPVn2PanSEBiI28SySUhmf8V9qUDUfsPzZpQUSbSCp0x6xS+ViWdVMt6 tHFuaKM/rvM4RCYbTGPktSGmHKaFqetIeaheu51jTt6e0U9ts/rPeksEP3RC55+aUNH5FSOByhM zt4jqgBHUYsKZ4C7WvkKn3CixKM0yVU0uv3pFzg+0rs1d/CdnaO7JoqeGQoi25NfFG1jJvSPeUN p4g7KXqiXCwj83A== 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: Jonathan Cameron Signed-off-by: Krzysztof Kozlowski --- Changes in v3: 1. New patch --- drivers/thermal/thermal_of.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index a4caf7899f8e4a5f3422e4c02c66502b5050fd6d..f0ffc0e335ba9406f4fd858d6c561f9d23f4b842 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -301,7 +301,7 @@ static bool thermal_of_should_bind(struct thermal_zone_device *tz, struct thermal_cooling_device *cdev, struct cooling_spec *c) { - struct device_node *tz_np, *cm_np, *child; + struct device_node *tz_np, *cm_np; bool result = false; tz_np = thermal_of_zone_get_by_name(tz); @@ -315,7 +315,7 @@ static bool thermal_of_should_bind(struct thermal_zone_device *tz, goto out; /* Look up the trip and the cdev in the cooling maps. */ - for_each_child_of_node(cm_np, child) { + for_each_child_of_node_scoped(cm_np, child) { struct device_node *tr_np; int count, i; @@ -334,7 +334,6 @@ static bool thermal_of_should_bind(struct thermal_zone_device *tz, break; } - of_node_put(child); break; } From patchwork Thu Oct 10 18:06:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13830625 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 D68AF1CB33E for ; Thu, 10 Oct 2024 18:06:37 +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=1728583600; cv=none; b=NChSltF+fS98uuuDn9vaWj/RSdGEBImi4Xl+Th8b/rG2A8O8Quz64UgYofHkpSxghGQZt3gwgo00z1vKfvFgqzc/0nEz0dJUJc8TUt5mhPpDJBbqbJ3MB0Hjc9+qby2abtrRTUV7CaBjjxOygJCwuuphnMUBRsKEjeciyfOsLVc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728583600; c=relaxed/simple; bh=aNb62zhsaKHIGiPAT70VpnT9AK5gMixXxxVjnHNtWyg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OmNKPzr540CkGCGkeqKDWDkGAi2LrQzuEA/jaP+zn7AFqpXqsG+DDe15Dnyhn/MTK9CgChYk2h67Dr5gjtIzN6WTJGBItMsM0aUD1R6ddv2f1AcRLHvtlcXuPh3RilmPJdC/nPcnHu4jJoX7/LURHCy0/3TvKcV7cDLlo3kpWq8= 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=JYUeEiQd; 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="JYUeEiQd" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a994c01e77aso12272466b.1 for ; Thu, 10 Oct 2024 11:06:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583596; x=1729188396; 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=9TkkM0LfkMfefPTa5rHdBKo7UEPK6bYMYTQ0A6kZ7h4=; b=JYUeEiQdBN819BTclfLBxEneGFD9dd+nnFydxvn/aKh/4ndfkPJjzQXBMc6PvmYInO guOhnyWJDwikrVoinxYIzwNQxBDSDDQ1PAGdc3I3/Qn0UzjOjSG6tCZthAgDXIBFPKT8 Uga/RNd+CnFYRVJ5GHDvGmR7jsz065AuD2EHug8bgYL/OfFyTmx3OvWUtHwQvtrxDa3K Ygjymg8G2X3GRLcYnMDhTYXTxqFINSX7pjR3WpYO5lzyONvz3mnJHesCHWtYZ72ytwOT 4/vyREVehm2Hfsj+2vXBpU2Jo7S1bOpBCG2y5DwEZyj9vsVXrIbbdEtoEyiiK7pFtjb/ Mmog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583596; x=1729188396; 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=9TkkM0LfkMfefPTa5rHdBKo7UEPK6bYMYTQ0A6kZ7h4=; b=JNADVK2iqJ+3D1VwWQtKwRNvBzhrUeI73b/gJMUcWn3Yo2iyc4d6TqZCQ4ax4iCOvw RECa1ZwiwUevigIXe29GkIJ52hqFUKIkpzHHxWjgF02/baSIDyIVUf8rWp/cli676iWS bCHj1wQB5TmFQZfX9yaWB3N6tFd7Yq2/2+jm4Jlz90YG7LobXQ912/j9agegF8UOwAKJ iWuv+I3/YDppYfOVCUeD0ChJhmqninE3AL7Vc+26wIS0g0uDb2CrTGiwMQQ1fOmuWxaM oi1U9TN1OUQn5nizO54hFKeHAs0IQB5xisbGf8fLIE51Z40v/QV8Xl8VMfJvWlMPfYex iUyA== X-Forwarded-Encrypted: i=1; AJvYcCVnSaUdGDbha7xh97yQTM6W7HjcXZPaD3PjZzxhB2E5pK1BdGnuOKgvM9rGcPQmkrFTBcAInVBxyE4WNRKQ@vger.kernel.org X-Gm-Message-State: AOJu0YybPV0jZbCsQbVPlY817xVzO4H+NvOJf2R6gp+sLb1GF9zYSZMV 292JCd5H4NDvxPZAR5StwbbJP+aPCyBOzm5tBlMeMGsVt00M55NFvUs2qDrAefE= X-Google-Smtp-Source: AGHT+IHQRcErwxHEKdjZt+qsy96mbwbA+guyRE+y4sdV2qs9+3gIUD4PBa5Cd/NrmsCIMD8+zgg50A== X-Received: by 2002:a17:906:7956:b0:a80:f63e:159b with SMTP id a640c23a62f3a-a998cf45766mr262023366b.0.1728583596117; Thu, 10 Oct 2024 11:06:36 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:35 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:18 +0200 Subject: [PATCH v4 2/6] thermal: of: Use scoped memory and OF handling to simplify thermal_of_trips_init() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-2-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@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, Krzysztof Kozlowski , Jonathan Cameron , Chen-Yu Tsai X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2767; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=aNb62zhsaKHIGiPAT70VpnT9AK5gMixXxxVjnHNtWyg=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBehPqvqDFh6IfCbkUeXvLZoTSi0gnsGqnksp eTAMoFrw+KJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXoQAKCRDBN2bmhouD 1ye1D/486TX4yMFc+ACmtgLM7zbJrXqUMiIGwM0J59oJV5FJLLInEAecAXxLtIUAEj0lC59biU9 Ny0TJWWJatFtaWOlaTJkn9IS37gYCHGuCPHBVclw7lwJ8X+6w8MlCj2K4XcjXSBpC9AMKRfUyBa fTeYhRMZs8KR6TyNmbDhxSkpKD4Ehx6UnFdM9EMg6yylnWIE117rJtSwcHyZkCS+IzVaV57YjDu UHCV181U0knrxBjU0QGzvK0yafY471v7ykkgueBYUc+OdZDELxoSGlPcTpcIBIiJp7opZ1mWdDM w6+ka7YoWt9Qz3CtkNApPn0oSbyj0ZEKN2lZ5X0gqtckJVh/VeHGJl+TFpsM6gR9OC1KtuEIHQK 4zQvpJggWGVRC6Zm6RGfi2R9woFXMnEdwEso/Nzt8eUQkKLaQS7KACvC21U6rmUt77/GXq2BRHX HyXlvc+1nIZP/zj0n1m6xL0SB1mYf5KMFbCeleY/qjjif7gXpOSRZ7jNsnWGwG2ASNHNWM1u/tQ OmdtPnSTluq5tZGFzgB5vldo45QwkB4tf9o9jUxNJkPihsXpiqb2PnFGnwoYnCXAkRw340DAMMT tx/Ijc0LsoVxeKkEp9y1gnSL1mHUdAzUH2q2lkIwiXklkpSppBTOGuFiBq0jwNmLYBcNXORr2Lf SaxsThJH/GQ8tSA== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Obtain the device node reference and allocate memory with scoped/cleanup.h to reduce error handling and make the code a bit simpler. The code is not equivalent in one minor aspect: outgoing parameter "*ntrips" will not be zeroed on errors of memory allocation. This difference is not important, because code was already not zeroing it in case of earlier errors and the only caller does not rely on ntrips being 0 in case of errors. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Chen-Yu Tsai Reviewed-by: Jonathan Cameron --- Cc: Jonathan Cameron Cc: Chen-Yu Tsai Changes in v4: 1. Significant change: kzalloc() also with scoped-handling so the entire error handling could be removed. 2. Due to above, drop review-tags (Chen-Yu, Jonathan). Changes in v2: 1. Drop left-over of_node_put in regular exit path (Chen-Yu) --- drivers/thermal/thermal_of.c | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index f0ffc0e335ba9406f4fd858d6c561f9d23f4b842..37db435b54b124abf25b1d75d6cc4fb75f1c1e5c 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -95,11 +95,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,36 +106,23 @@ 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; - } - - *ntrips = count; + struct thermal_trip *tt __free(kfree) = kzalloc(sizeof(*tt) * count, GFP_KERNEL); + if (!tt) + return ERR_PTR(-ENOMEM); count = 0; for_each_child_of_node_scoped(trips, trip) { ret = thermal_of_populate_trip(trip, &tt[count++]); if (ret) - goto out_kfree; + return ERR_PTR(ret); } - of_node_put(trips); + *ntrips = count; - return tt; - -out_kfree: - kfree(tt); - *ntrips = 0; -out_of_node_put: - of_node_put(trips); - - return ERR_PTR(ret); + return no_free_ptr(tt); } static struct device_node *of_thermal_zone_find(struct device_node *sensor, int id) From patchwork Thu Oct 10 18:06: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: 13830626 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) (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 D21FA1CEAAC for ; Thu, 10 Oct 2024 18:06:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728583601; cv=none; b=b/G0GclfrsoobFZSYzfF3aGqj+0XEgicFOwL9oPJvPgIOhUjrYypyKl4SXA1FlExPO5raC5Wq+ILGO/mHbNRGbbmFgFPam2sou8LYIjT9bGaaBLLV0fKasQiYHqrLYnEIx6hkIABc4oubDdeAnZLPrk3BRkI39wOc644hiY+ISw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728583601; c=relaxed/simple; bh=IKkYyEEUqBTCZShccEeitn/IT5/XA0WevxOw6lxgVCI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=No/QQnvVbxnOOXR2rIjgTqGiGtsNxmScIOrXdfAtT/yceuBZfqtdqAZaIsfWReKwoZ4pl0oVMAkX7hKnvFq9xIUO3b7WDOmFiYvFV4F6gF8HNbxwj3V2gl0pdriVPZrqFaz0b7Lpr0XJ6fYPQ/6mplaLTsUnc8Y75C8ix4Mwjrk= 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=w97/BlgC; arc=none smtp.client-ip=209.85.208.48 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="w97/BlgC" Received: by mail-ed1-f48.google.com with SMTP id 4fb4d7f45d1cf-5c937982445so189471a12.2 for ; Thu, 10 Oct 2024 11:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583598; x=1729188398; 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=1QMbawNbB2pemOrxGvjwG9oTD4DjBo2bQpJ4URqAkxc=; b=w97/BlgCy8YYLYoj4BKLpUJ68+fGqJiR3N1AY70sTIigJMz2fkS60uHk0PYdKmY5Y8 q5mFpF+0Ka5X+7vD5Qm+CBWI69VO2l8Bb92zp0BkqjdLdd/mRlvonhPtRMMjiFKZ/HCe bat+jQfOPmLEZoXgmny9R4DdqmMLUb+3/xE0bG5yPuBW1ZBnXbROd/X0oxLgazLn9TJH tAy7J5Ljf/92rUVqDbmD+htVBFNrdBm98h9ri25HGJuJCbQp+uJCbflLPrzgv5CX5qiG MWFw3y8zMqt11LwJXoOJhL5Ni3fGm+l9L4zi03K5mtueRBplsinHrZAgwh8KS7mTulVT VHoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583598; x=1729188398; 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=1QMbawNbB2pemOrxGvjwG9oTD4DjBo2bQpJ4URqAkxc=; b=HJjLcToxdRcNARmb3C5Z5f6MzwFG7gANVnszWZhxEUh4dCOcgrqKiWxhHymjMyO9F1 yxL3bAVnDgEauEh69aw0N5VmFQdRP1sluSo3r+ZDJlS+hkmAuxAZVI6q5xlMghRyTQ9Q xffIrcVvlABG0h3J1iSC+rrWtQF8H8puh0B0qK2GJlbdwBRvqp7CRUHS47b4fZyNw36k H/EaYHkI+nj+ZtdSRYl48+XAE4vhO6/Ru8ftkqtJY8riPmtk0QzJ5W5+xKGAki3l/QNO g+b/8Nh+6brERSuRXdlVR/zVhLBjt2HckvDH4Xqtw2PyRC2Q2z129Pw01UTshmDpDneN uAnA== X-Forwarded-Encrypted: i=1; AJvYcCWxZbp/J79qYNXRewAlxbri2VkRXc0aQsBnJHNUNiFMwrhTVg8ZAzBHQgt0OKCtbOpuYv9hpgXU0S1ah9kB@vger.kernel.org X-Gm-Message-State: AOJu0Yzq01ZfZoJmLB5CwquOAosVuFu7OwAKCHnRA3gFKlc+6oCWbDeF VzB4Fgj0sUX4Kb/IqkDOPLhmQLIHKr4m6Phgrl391R2/8EILkEtxQBvnx6MVYPA= X-Google-Smtp-Source: AGHT+IGoLFle7c3swn9/rv3LyHsELE4XyheQpS1XJpGhNDCvGHEEviqlcrtkS1myk5GRLypn6mdLCQ== X-Received: by 2002:a17:907:ea5:b0:a99:6036:900 with SMTP id a640c23a62f3a-a998d16a50emr323248866b.4.1728583598040; Thu, 10 Oct 2024 11:06:38 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:37 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:19 +0200 Subject: [PATCH v4 3/6] thermal: of: Use scoped device node handling to simplify of_thermal_zone_find() Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-3-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@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 , Jonathan Cameron , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2293; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=IKkYyEEUqBTCZShccEeitn/IT5/XA0WevxOw6lxgVCI=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBehPUvBEauTEbyosFo9Xwu1uK9auHaT6zB9A VFMj1hVK7qJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXoQAKCRDBN2bmhouD 1zQqD/4qvqH3gUy07CdQwQksDO1VwmECOuVXL8ucYoDSkfJ7iXfUWjIwVueTMozOgXG5ffgbbdh n0/UPMG13ETnJ8NHsDtPuqB08OQnf4G2RzZuTzqYvEOD/3aDQjpNLXYneuw3oWDhiIJ1po/jPoH hl65pj944m0cx7/B9hEHLRirR5BFuBvs6US40buZ1Dn60LcaLXb7OIWt6A+d8V+Ad2HOUC5rzjA YcVdtW8FmRcIy/6Tj8sqP0h3IBzAkFNE8rVCh0avCTYWFxLqd0FsrmlGKgqmSo3Z6ix7rH4hwNG JNq1kXjmrLBghMxb0m2IXA+XGhd9czJnH+CQypj/AHN0VLz49eMxBxelC+PoWRbbnhmB8oGhZZ7 YTad7W1uGdR+kgHTfRpUwCzwSp70/AuyL5LzEo6YEX/UUCWqkivt6jvLTdL9vZKAKyyhxewh9JI XYkw8CYFFCp6ByuF4P5C86814J7wEX3x4faqcWIIo+KjUwC/2TZzdZJwrgcUJKOZy478DnqSEzp Jtm31R4QnRfz6xzkEfDlChFJDlWZiM4qibx9q+b90Cm5K1erObf+JEX5Aiavwv3FHio103gxUk2 DMgQUXr9gpJMNcDQeXjTC93WlJUwttKVw02K0N0HYMu+KfwMaQBCtzU5XtDtNcuIb0W6Q0SQi3o 6WsRYwn/NCW/aOw== 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 Reviewed-by: Jonathan Cameron Signed-off-by: Krzysztof Kozlowski --- 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 37db435b54b124abf25b1d75d6cc4fb75f1c1e5c..66514120f460940ed7cfba791140c958b99e056e 100644 --- a/drivers/thermal/thermal_of.c +++ b/drivers/thermal/thermal_of.c @@ -127,10 +127,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); @@ -148,8 +147,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++) { @@ -161,22 +159,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 Thu Oct 10 18:06:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13830627 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 D37791CF299 for ; Thu, 10 Oct 2024 18:06:41 +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=1728583603; cv=none; b=gGmYf/f0ht8RnfVZ/Y6s9BeANQeUFke5otOUXtrb83zrM8IcnsEk59PfLhFvW5HjXtkPGX+3WhiFsErtNyHAqrUOTQdPhwp1h+36k+5jiGr4uxiJhmEhjT955ATiMUI6H4AIpnjT1WJplNNhPDGqdTKbj+r22ofV7HJSuCb2J94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728583603; c=relaxed/simple; bh=F/6M460B12wipWGDyJ3DH4nQN17g4TQGelqGAmG6zMM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A8icWpFNVLzt2dr3v9vlzioy820NGk6jscsgcJZNBa3Y+yjzjkodQknlngRqTV4PS9Bulxu10MWdAWRpmfBNmZOKz/9qRMfuEyzb4PxCuh7cLS8iJKitwg8Io0fQ37SJhD+QzaPQaoYHZpjYE9CKTh2VlC8XLvScAVsDdZoUqCs= 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=fCQBIrb+; 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="fCQBIrb+" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a994dbc40a0so15261166b.3 for ; Thu, 10 Oct 2024 11:06:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583600; x=1729188400; 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=T87muPGakKecqoFQwCwDAV8Lh+PZOzuzFVteMhdsZl4=; b=fCQBIrb++u9it0wia94mKsZaeUq+nlK2c83G8PhJloyTSV5yPH3nvqHn0GVMB4ClyS 2KbJhqbP+rVpQCJ1z2i/kO5cOGpPujmwrR3SG29Ebk53tYgTvs/PcCKFLZoJiCkn2wrU 9mSqHoGlZ0kMuEMhPWDZuSUrBNOZXa+tPnIrHlQ5pIQZWvG9IEjiaQIUQEZf698TUTj3 UcwyTvoG9c2JvH7dMzgmMb1TSghIIB10ZLC8kZS1CEIZMv+0wmX6arEwp5QlHHWAtB6/ q5+m59c0r1d4VmAMxgBmDIMO6B2cbG+3Ad1pgyDqmplfjIU7caJLcMmrME6it1FQ+rka iS+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583600; x=1729188400; 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=T87muPGakKecqoFQwCwDAV8Lh+PZOzuzFVteMhdsZl4=; b=QWX11ni0KEtWcWD0ri8pLhlPYjN9gIWZ+shhp5h9Pd3ErFhB32eCtHpOLW19KbzMbw EnnczDpABwW+6tdN2kIFJDGFPnKi3+FqB6OdZ8/kWJEkDcO7QBj6LPOuqRVRapFu5yfm FoUxWBCEK0Od5JRXTtoOhld5Bdd6yb1M7llqAUuJL26YVFGjLvVmfleYA4HukFCOW/+Z Vv9IxJp1p4WIhRYNry3NeUT4KSVp6PAYDeL9cyY5I2shukIG77+5CARPoETvJabRF5Oz HhB5trJ0BjA7oFccgzcqTVFV3UsULSaG7+EErzN2BSqBdw2i15T/934lHiQZg7Wrd/AU RdTA== X-Forwarded-Encrypted: i=1; AJvYcCXFE8F7Oul8C8iNRKsjS2eMEXQGGsgrCcxO2A2JVCkovURVq+KQc8k1HoKcDXJ7zMApjWRrhAQkdJZPevri@vger.kernel.org X-Gm-Message-State: AOJu0YzZDXm46kGICQJe5zSny4XV2JD+8KQNteL5R8AE/8nGgdbM51LE 64jVYiQ/lgM4UNPgH7hndZg5eOUTy15dQrJy6y6Q3cq+RxxEhtFo/cv3fcGO324= X-Google-Smtp-Source: AGHT+IFrJLzGfmSeY4fLffFxiKpfgPVtVi0hI0pqAhjV/N3dGTkIuoCJA+UIpnDwUjrA9tlgsN7+gA== X-Received: by 2002:a17:907:3f1d:b0:a99:53cf:26d5 with SMTP id a640c23a62f3a-a998d307d15mr331306666b.11.1728583600130; Thu, 10 Oct 2024 11:06:40 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:39 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:20 +0200 Subject: [PATCH v4 4/6] thermal: qcom-spmi-adc-tm5: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-4-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@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 , Jonathan Cameron , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1450; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=F/6M460B12wipWGDyJ3DH4nQN17g4TQGelqGAmG6zMM=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBeibSc7HHoJfMrPMNz85qOOfTsHttHWu8lLh rAfMZtJv+CJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXogAKCRDBN2bmhouD 151lD/4nfzF0ejhz0ulFE2vT8CeAE7Ieg+4VBtu2Dsv9RMUy4rYMvfjiHgZNGU5s3mhdapRtgwV +j8bOKgBQsUXU/HzoWG9sf54gPp6k1Bpcg9ab3KfWSDMBbHSNrM0PUPBa1DY75PiFI97fDEel8j 3HNyRupjhiOQxMpHLSfesKOPXHk1nmTbGbUx+K/z5EduD023nVQSw6R9Bmnw5un/fxwWJpZQord nKD5OO5fIxUCaXUOiWDx1pv4v4Ieb069xF480SvUFU3SB1/2fD3htTcq3feZVkL5JG9DJjI0oDl JwEvxNsHl5pVkh054LprqvH5X8o6HyrToK7GHCwCeQ1R0DGiGP07WBb3LFgADZjGC8h2fYo1SSA Gnr6qISd6GtAn3xhJIcBbo3xSWtJD2Uf7hZMhLDbJfdjl5Vlq2CQ18IAvS6s0o0qiiGox9qtkie NrxWxNUNkWK120IBXyduE8/EgAsVeBKd0lnU5Y5LxLlWgyz15vq8vday7JkPYVtMzxjxuZWbQQL s3GYktASoFB026qr+pzzRNsruCUnVXbQ+MYrvcyFV7meWrX0dubnOunJbuy+fqccRsEUbsbCDWt +5/Zu8wUDuKev+8QrVnVhfjkJGcpz68HGRoFwkLpqELydAz5GxSiSf9WfvAse11dJXSwWIb2tBz IXhmCGmCmQMkFcA== 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 Reviewed-by: Jonathan Cameron 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 Thu Oct 10 18:06:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13830628 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.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 AA0391CFEA0 for ; Thu, 10 Oct 2024 18:06:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728583606; cv=none; b=r5M+EhxOWMr1a1aYQwkBAuT9RaU6eJh/y3M2MEBqb+RTLKa55NsBzXl7zFFoQn7C4CqDaR8VCmBOjiiCG0s53YW1lvzbnlhy1ETq1h3oWV8z2AfvA22kUuSZg2ytq5xQR7Mc37CIspNm12DmEAr2eAdDuGD/tKVE0PEuA7t1QTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728583606; c=relaxed/simple; bh=BdGrjkiZQWh1WcuBimpPZ6XtKP2yiGuNF+kzNxp4Gjs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mrcy+oJ9L76fsBsvBh2aC6rq+lr5FoeIeIXC6bponQv9gHIFkhc03dL3gtKs1pRkOw3N0UPCTVIj25lRm5oaixa7X2OynGpYLfdP/+d225VmMb7DaOKX9ABWXChCvzOwdD5I200LdOAY2OB3yxGFwyCcIgP2IOzVyGv5dZtBaqM= 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=UDnW3irf; arc=none smtp.client-ip=209.85.208.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="UDnW3irf" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5c8ae7953b2so198564a12.2 for ; Thu, 10 Oct 2024 11:06:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583602; x=1729188402; 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=zMe5HePhBUeYRfUt+t783COcyrs/YnND8+jdMLpIJ/Q=; b=UDnW3irfRlBBzJA6wvhsvd/N4jeYI8g5e20JWNxq2e/RRKJZoBRvG1Ox4fmiZiVcW0 DfcCi4EONCaaQ0aBo59qc3rLxrYcbLGmkC12ZBUSDwcd6Wryb6ydU4b/7Jd24OIZHnvM fRJhtb9w9ywNZdOb3BvI4SJkgH5QCC2u8dBLYGqipU5TLiyT3ELZsop70tdpYKekWuWy LH2DJymbFMhO0KVbpcfmTiCFEZhfxsm4YbgTUlfovOqU0Cq73x+S0Alus5xZ5Gex/YEz DLp5vUhtIYVU7KY9n4FhSuBs9ErGZJIqkykVAhMBx9zenUhDE9aOXZUbb0nr2uxQlVgq DMNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583602; x=1729188402; 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=zMe5HePhBUeYRfUt+t783COcyrs/YnND8+jdMLpIJ/Q=; b=p0CjGhd08keZNkT20PXaQcqXOxDcb/+PpjWAium9lBzjxIG4vJ+a/w3JSagDUjBXbe BRxt1hvbDEIzw5IC3Ihi9Jm64ijKxzUKKJQTj6UVORpP043ADOR+kGkYaWp+4Tjec5Ik PdlexT0iB1seFoG8vV/DXlA97V4CExJjh1cGJmPiUJPQ9GPqqIO357pBTROB3wENgRC1 xMMSbGpf/paueGqwFVvc0T0OHDk9sHfHZoVFDEG/zlgyR7AXg+ZYLGa3QBzTEQu5sQiR iFScbjkrvX4nDoq9CwG4wLB4EuAkfveHofuZ6sOa5ssk5V2E4e+aUwIBYXGsVHPFZ4FX sdNQ== X-Forwarded-Encrypted: i=1; AJvYcCUnGgGYN5AIwhqk13NmZRDqlN/p1bTrX5dZIPvE1IeK0P/XERlj5vK9FJotJSpZTXkk3qu28vCt/TOJM8u+@vger.kernel.org X-Gm-Message-State: AOJu0YxLqcQQ7AsG6tXXKRQR1QK1pgLIozsSG9BXM7a1bHnIMFFg8Jsi GJMrzeGHrTzKWEnt9mcLbt6o3zSE4oizU4N/URWnSgQmOTE+nWCOOpK86xnhqrI= X-Google-Smtp-Source: AGHT+IFjB63/jfrBk0eN6WcJADeEZxL3im8HrhNr5oZenhrqyJbL9Yal33sIcZCX4teS9nhkZm9GTw== X-Received: by 2002:a17:907:940f:b0:a99:6ca0:30cf with SMTP id a640c23a62f3a-a998d117c8amr324118866b.2.1728583602014; Thu, 10 Oct 2024 11:06:42 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:41 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:21 +0200 Subject: [PATCH v4 5/6] thermal: tegra: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-5-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@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 , Jonathan Cameron , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1477; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=BdGrjkiZQWh1WcuBimpPZ6XtKP2yiGuNF+kzNxp4Gjs=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBejWV/QRORUzTaED875a/UAIUxkqjmo8EOWT kMOrdM0W7WJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXowAKCRDBN2bmhouD 18Z+D/9J0c7qqVdhn8oGOHhT50RX0ZxNnG/KK59zCeLsNgdpi8PtrKyaLDCkg5tnoYFYe+s2Rtq 4/ULr0gtVWSYjewjs+JwL2DenODGLK393X9djFuOVFYTJAkZjKwOp9u9vm+VeyEPWcl2fjZ2BC6 9Yy4YtoH4iqpiwqsocJlCzguxZL7//bURxaHbhk+LbqnHbrwH9cKk+TecI3Ia6MATdkjt90b4OE ve40c/G5MAJOjcKCqgXJQkNiC1W9dQ+s5iQ1g1Y885Al3kHUKGi6A/cjqg5Q+JsfNJ73Q+k6rT9 C08DY7x5GWlpVRdkNKEl/K0+oGhZUGhxZFwvgBAl91HlIgRn8LvMjQw7EaWng2SlLOwMQYrtlS4 JxNaMGKbccQo2rWiSA7trOUY0dGMQOxTaYDh/n858DvzIKFgtQw8IxU+F2Kl01ljhF+j83Kg267 pQuqO8JhZg1tvBE/XFQknST/+ga35RiHIZWgTusHM1fK2mgaqs7c6/Zon6sOLf1uDfsi5Zy0NEw y/LQdfnWOvr1EmDljXe2YZSAedCiMpEA3OiuuI8UU6eiSjto324tSJdfNyps3kLwZ/hL2OylK51 XD74I51ro7VBUjK01Ou8JUDTG1qj9D/zbvX6BFPja9bPg6Hl9vRQP9yYKJqsV3Y7dWuWFsxpzKG GhkctaLnxk2P4hA== 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 Reviewed-by: Jonathan Cameron 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 a023c948afbddd6d9fc1a00b2fe310c71147bda9..ff4eedb553fb6e78c94b714dd179193c244b6589 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 Thu Oct 10 18:06:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13830629 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 A01BA1CF5F3 for ; Thu, 10 Oct 2024 18:06:45 +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=1728583607; cv=none; b=aKXmqktzkqbjPeA99EMP2g3rWjqqlaKQG8TUWjdekTfXrOiNPNFe99IWzMcIuo+WHUBC/foWqWaRWe42fpsb5cJMVE71nJ25fovq0vdVSjPa2Okq1ArJCY4R2XTwYdcFom5Z+XeZoK7xnbRBVKLNZxyKF1YN7exGXIYc36wHvrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728583607; c=relaxed/simple; bh=wYClXJKWHiD7HQHxTZ+cA0c/iCEus3r1K31L8rg0g5w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=seWEeznC/34DkHEf+ux3snGsU20gLv2IArjLrNfPbw4iXuMVU8GScXSdrnW4YRak3A7vpROo+43BXMOgtCfjn5gp7Q/jNaUkZBxfq/C7nLx1Kx64aG9lAsDRAuPYvFzC90JEmMaEE9ROO5xcJdCNNkfX03XP4MSpCXkQZlJ8z9A= 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=nWHk5IC5; 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="nWHk5IC5" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a9952a6020fso16813066b.1 for ; Thu, 10 Oct 2024 11:06:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728583604; x=1729188404; 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=zNHd9uOUFYMvCAXebRo/fjYtsxyYPOLWHoAaGWoy1tE=; b=nWHk5IC5HdSoGnlWGLsrvwI+TxX5BcP9e4naSk9yw2kclbmyPY0Qp6k1k1UlM1rAM3 1WAfX/vvKjbLhtICBPZneOXouH7U+nbWBGsadNEJEKJ+7h6f6zk+40fVdhQCB2uHec1z 6B6Ibl65q5tegbgm6RLk5cdtzCbDvR9gjJmFwlpyJHB7/w7AHHJzHfcN/d5anGintbju N2Iut4g0uuv5ZmO3BmL8EYqIcfYQ8xEDQhcK01MP93dbbCl6JeVqoDQJ3g9x8CjKDC96 mtEVRwHJzQQhOhaNvt61hr7fFsqw8scIo2olyp84MR5iIuxHddlGkiir1VhFBQaoLnpC o4og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728583604; x=1729188404; 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=zNHd9uOUFYMvCAXebRo/fjYtsxyYPOLWHoAaGWoy1tE=; b=uUQSI3XoG/wOc/duSA2+EmnJBd7NvQQlPrErZDNN45AWCKQjxts84BheRiEvMXndLp b7Ekr3D/g6N3kO6lLBE/3cLu+s+cZknxQneRd+LUxz2iOpXPCC44A49ptleJKfQiyhvu nmstl7hipWeeZ0mRTdCLiy1cmDLw+KymYDR++R95JqaEmh5vjCtAuGVYpjhwAFCff8+S lrNXOVuA2B/0MRYFM66oR357FcewjGIwG0c4cNoA35OxxSYmXNSygDmDG1ivOz4RAWvV 8Rm4O7OOVE85111a9Tp+tmcRF+hidsTPfhLbVxWcRaVv2MDhjnRVEpKeVOgSU1JqnUFc 4syA== X-Forwarded-Encrypted: i=1; AJvYcCXO8fNP9C8cSxmxZTETU634HjE4mDREM0WtHxkaM6T7hzmMGP05X/yhzqZqPUppAQvG5tbss8JxqO01zB/7@vger.kernel.org X-Gm-Message-State: AOJu0YxE5Pihg0SuDPRRPl0ovKQpzYxMTFAcG3paeUlmhZwZZG0OuAko ahgF8rQJLxKvQMAsdhxZ2o2Ugnmgk6+Gv1uEsvOzs9v7A1pWgx8K7ifQsoTuX9c= X-Google-Smtp-Source: AGHT+IHXG8VaZInUUFAvxb002JlgmJFHrC3mhFZJAVtrcbAFOAxaAouRcGLkivAX5NM5oRoVFuCHnw== X-Received: by 2002:a17:907:d24:b0:a99:8cd3:5810 with SMTP id a640c23a62f3a-a998d1f64c8mr283223566b.8.1728583603840; Thu, 10 Oct 2024 11:06:43 -0700 (PDT) Received: from [127.0.1.1] ([178.197.211.167]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99a80c1b8asm119757966b.116.2024.10.10.11.06.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2024 11:06:43 -0700 (PDT) From: Krzysztof Kozlowski Date: Thu, 10 Oct 2024 20:06:22 +0200 Subject: [PATCH v4 6/6] thermal: sun8i: Use scoped device node handling to simplify error paths Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241010-b4-cleanup-h-of-node-put-thermal-v4-6-bfbe29ad81f4@linaro.org> References: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@linaro.org> In-Reply-To: <20241010-b4-cleanup-h-of-node-put-thermal-v4-0-bfbe29ad81f4@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 , Jonathan Cameron , Krzysztof Kozlowski X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1855; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=wYClXJKWHiD7HQHxTZ+cA0c/iCEus3r1K31L8rg0g5w=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBnCBekdByvAQz7PIlOWkUvsQ+WBs5zS53VgUcf0 2GuMObk5cuJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZwgXpAAKCRDBN2bmhouD 1/yKD/410uKcFyGlvzO15ze4hOKRpWLw5V67Kx5zo8B43YJaHxuSHUBpoOJeBWXrAQgdtP2GXzE l/qxBeSvhw3/GFyFCDOYDyG6HtkW3qO5tIqx8fVOCxHTiB0yf1+boloOALHg6vBDKdpzDHOBUNK b1YDa8X9+f1mk6f0pxvVyfKWfO5Uviy/aQHM1dc5Ccm4dZo8U3j7EQH4upqTCjjavpifP3MY3oT HuInbdw5jbjjlFdpo/ol4J4bSkwdH/4nj3349zrPrfnZ7SQOapQwexeoXfSXuKCdR8CgZDAb3cp O6LB80/4qxIJeiIbZZtgaGrBLXKSGT1g+T8er0tzcd+tA1SyZK6ZPB0wDH0pT7CdWrIhdpovTEM hRfI9tQsU0s5vI6wuU3DiNNP6KGsVqTJ6HgqBpCnQT2SeeJb7/Yn/rHj/+H5rPV61vr+8hNj8Lu qPy0HtHZAK+Cc76xRkB493/Z1IYRLJy6P5Pqumw+2e2OrmnG2A8q+IiwbWFOZ27DwwAfh1F1rjk QrLJV7lq513bxJLg9IFDzSO4lp4ZeaZH5wAmI0CM2u3/AAkkcZSblw5syk2ZrqWBdHDWtr4Vdnq l1jmQTDe1UvwKHwTbNvQBUJswCUTUtCcGKAadL/Hpd3Zo2rxZxtBcYQyKvZAHwIKsBif/rgIoTx pIR+Lgn8zsIoDqQ== 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 Reviewed-by: Jonathan Cameron 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; }