From patchwork Wed Aug 14 15:04:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819213 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.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 E93FE1B3F16 for ; Wed, 14 Aug 2024 15:04:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647861; cv=none; b=WGcoXYqtgJmelk3HsPIT6/6g348iLimfpnW1zaN0zx4/VLDZ54oEZSGfC9ZYUuyVe+1vBLi+wFE8o6YHrMHbloWwgVlzOZX5uPpjdYYUSWplqPyywC5DBZ3cL66/Bc+9YRD/nCp33E6bUnak8zLc9WfMJ48c2mFUuCR9iw6psD0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647861; c=relaxed/simple; bh=rPSu/s1mk/65EmKeel3ZSXNy2qhadMl26zNDJ4MnfSg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JP4w0jlgERt4H6/LdGCEMYpdqv8oksMlbV8Uy5KwAqKFXjpUVtu0+uBotKfM7mdXH1mncBKanN7VUQw6nb+QrsUPFw1JHcXnVzZOSlKhm2JOrbB5JTes1hbcvdsjWDMs0cVfSiwPtyQnvCYw6G9dcxXCtZInMGu7u8e2v3CPg+k= 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=fsq7ttHb; arc=none smtp.client-ip=209.85.128.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="fsq7ttHb" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-42816ca782dso51660065e9.2 for ; Wed, 14 Aug 2024 08:04:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647858; x=1724252658; 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=3la53aoQx5CXNdnscGkAvwRAocgNTDTT4f12xEvMb4M=; b=fsq7ttHbHDp0Ny3Owogw4yYAyxCrcxeAxvjstUc+ysLUhhRiLKEPz7MtJkWj9E5xFg lIxv5/TaJ3HIlJE2JpPTVxuFoUHHfaIE2u/gF+fchqjIu3e2xT2o31uFtFIRkZE2iI58 nhu7+lSr7CA6eMzwz5DoPszUIYpepvOUWEKi3LFQUIL9xIhq8G/b3kiFxFW0sWCp4UeM f9y5N1V1i4lwB+J3I272PtO+oMPMxkxZZiuij3YncOsolHdokU8mR/B/0xrALjVcjPZk M0bGRsQUQ056Tr4lZNVi4XwJN1EMYXoPKzIlPxwvPMOFBUHeRp6QryKnvafwhD6tDjO3 CN4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647858; x=1724252658; 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=3la53aoQx5CXNdnscGkAvwRAocgNTDTT4f12xEvMb4M=; b=R7eaqhJIzs3HWidZOvc3a2q576bPJ5xRkws3IzoV+8JXLvDmQWcD0CusQWKXJBX54N FwrPobMFKbarFR8ZdvHB/3lJzKhzJPaLRhXrioisHnzVeW5F/VEQwoQk8CJFP0OWQmAA U8MfH1VulyUk6RZuFkO0Nfkl0Yq/bfg033pBBDqrayshuqkiVVGGke/54vrei9S/0evQ wFz9Qh3Pas/GbtQkOygo2lneJpOuXSwBMawmbRp5mSzRt+bnNT8iCkfPMCgT2M4cjz3O ilRL/1Tc03To77M6FZkIuYmqyEKt7YLt1m6eb7cFu2MfITlxKZOtzWieJ9rOBn6g7SlO UeGg== X-Forwarded-Encrypted: i=1; AJvYcCUREZ19554+q8DCE+aiFnz2Q6C7/YTTFL38vDtKsw9TM/sDuDHEXGvVoAkoKQQTqDQZj6QeWs+7/hwEjoFm@vger.kernel.org X-Gm-Message-State: AOJu0YyojQRzB3uVCWuFiZTkg+tV7xtuVcS/tKIrTlEz6iyvGGHSw7b8 8UqBqObO/Jv3cA0pUAS/jOjMasvhYJoS2lNMqq06QhB7UoYrkHUx7tJogufl8bQ= X-Google-Smtp-Source: AGHT+IEEcMUngaR/huI9xnvuAYfbKL2PYJIZ2I2Vju7agb/lAgnPLeyDFgJH4wZoy7E1fNPizlP13g== X-Received: by 2002:a7b:c385:0:b0:429:d43e:db9e with SMTP id 5b1f17b1804b1-429dd26701dmr17332745e9.36.1723647858216; Wed, 14 Aug 2024 08:04:18 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:17 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:05 +0200 Subject: [PATCH 1/7] regulator: bd718x7: 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: <20240814-cleanup-h-of-node-put-regulator-v1-1-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2068; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=rPSu/s1mk/65EmKeel3ZSXNy2qhadMl26zNDJ4MnfSg=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdnvE3Tn9NSxneESR03vM+B9CHmU3fn1L1iH fTFW0d70F2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHZwAKCRDBN2bmhouD 19SiD/9H7/t31qMp/9HOygrF7TQy7/pnv8R03i/MYIwYR69rIis3AfXj8hHucOo68d8YkO+17HV lzkY17jjrFSogIb6rrYQiJEbm2DGsPSc7nEbwFLsxWSqESCQOYapjwnWRF+VcjVnOYKG6tP4v85 PZ0W1q6Nj0eP09oMecGZkHAVwtni5yfEeu7gZT+rQoK5zB3TU/0gRq59NBPQxmQmrfcNalqPO0Y oSLOLXD9JAwPzOb5pxlUGOkuqWchnkoC1dbA9ntblSVJY1wm6EVmZ3plr3zJ1ezTE4jmBFQSphe YczAeSTvS2pYbEL+MPMx4cjMIghjAXsvafZxZ1xAdQH0vnJu7etHKfHwSDPdsm4rNokdQBeCOUn SupZ8PkQvlWpqMQgjYCY96Vbr5eo6MIj+ZzinZ7BxHA1EouaFtSGZhWFMG8f1gSPPlmyeu1h96L 3dkF/K/Nuvw1W8hXOIGD3eyF4erBxHoB+Ox6ivagmni51cAFEifICvmOfjOtXUthc18OM8cAhTE 7GjTNHLAnVqdS4mCrkGpvrqk8JGba3XyADO7uspHBoyzD944CtmUuj/OTTXiK6aXF3t46onz7KB 1mV/+d6V9G+JxlBLfcmuCJ7D1Wd2+SMmcY/eC4jCfZ9WPH0iG24VBedhx1uSdVbmsoNapiDafhZ k7GXMyCKl5IZr9g== 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 and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski Acked-by: Matti Vaittinen --- drivers/regulator/bd718x7-regulator.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c index c3fb05dce40c..1bb048de3ecd 100644 --- a/drivers/regulator/bd718x7-regulator.c +++ b/drivers/regulator/bd718x7-regulator.c @@ -2,6 +2,7 @@ // Copyright (C) 2018 ROHM Semiconductors // bd71837-regulator.c ROHM BD71837MWV/BD71847MWV regulator driver +#include #include #include #include @@ -1635,18 +1636,17 @@ static int get_special_regulators(struct device *dev, unsigned int num_reg_data, int *info) { int ret; - struct device_node *np; - struct device_node *nproot = dev->of_node; int uv; *info = 0; - nproot = of_get_child_by_name(nproot, "regulators"); + struct device_node *nproot __free(device_node) = of_get_child_by_name(dev->of_node, + "regulators"); if (!nproot) { dev_err(dev, "failed to find regulators node\n"); return -ENODEV; } - for_each_child_of_node(nproot, np) { + for_each_child_of_node_scoped(nproot, np) { if (of_property_read_bool(np, "rohm,no-regulator-enable-control")) mark_hw_controlled(dev, np, reg_data, num_reg_data, info); @@ -1656,22 +1656,15 @@ static int get_special_regulators(struct device *dev, if (ret == -EINVAL) continue; else - goto err_out; + return ret; } ret = setup_feedback_loop(dev, np, reg_data, num_reg_data, uv); if (ret) - goto err_out; + return ret; } - of_node_put(nproot); return 0; - -err_out: - of_node_put(np); - of_node_put(nproot); - - return ret; } static int bd718xx_probe(struct platform_device *pdev) From patchwork Wed Aug 14 15:04: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: 819504 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 006231B3F3E for ; Wed, 14 Aug 2024 15:04:21 +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=1723647864; cv=none; b=estJFFllnA7KGKkG9YbdIDhkDdPOQw3dwfYkLMRaP9XnyrPA5djQeJkcbH1n9ahVzNiaOzhOfG92PheMClizQyaycETp5QTUDthde8hCIehWRn/g7WZ/sQjwk1l9zBNR8QYPdMzImxloKEfWND/TkMzhF8szsO+ScXTvAIpf1No= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647864; c=relaxed/simple; bh=MNChZLpbj/MWNGgnwsRcQZFxOn02r/u5ky3hmD/OW5o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l16OlK3k1/g2nmaShf67iAIWYbxMMXWIx1P8BIO7IU99y11/IqvzA6CnOjrwToDhsRf+QImFPbRejlT671V5E/0KsuFQZiuQMc+jcBTSM8qv5SGe4wdhJMaPiOgrnWH+9zFBml6R5xCgXqgs4d/BTnGY2Flr2GG/oXgNGbcKaa0= 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=kNYfndFp; 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="kNYfndFp" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-428243f928cso46993355e9.3 for ; Wed, 14 Aug 2024 08:04:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647860; x=1724252660; 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=dEeIEqLVY1ZOACq24mYbeXb9wBOy2fSNM9DcJntAJ74=; b=kNYfndFplcqaoU0uQe8HW/45LKEDHMEukIBG0zICkmQejdgyyLvHmzUOfo/atPpVDo EpwTmijGxf5Dwn7he0KSkSWqsiy7+l++gyfNpwlSJWBQRUdLYgketgpYWbkfilknB7Iw 8BHu8SjhzZo0e73lNAtTQ1rDoTdJQfGDXpA/cqmctFOl67H5LHyGJpuD0zMv9jE2Gabg eD8kcbYnAyg1McBt2lMHhq1+s12Tcg+AlUjjQQw7/KSGB1tjAIFrpmmbQzuV0SvJtjQt taG2jfOTC0AQAMudcKC1mwi5vpUyf7TTesjt14tNSO2F/kxYQNNS0OfmQNV8ZNzz/WPn FE1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647860; x=1724252660; 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=dEeIEqLVY1ZOACq24mYbeXb9wBOy2fSNM9DcJntAJ74=; b=YLABH9JEuX4zebh01x4wDkJJxTcps3h7EO/VOa2iaqPDkuqiYMPM+rGQJ2+S69UTPH RiKeJhZ0g69v8rzHmZYEo0UfcQOKs45NmaHowYAcOA9Df55TDreOrdW414GsrqhnW9bH FdYJeRIaZ/qQt9/G46CSJzH2Efki0IZEY/MP55eaaGO0vvHl0sXp+KCybCzPchXmt4hl jqLjfgjiItGPBuKVcCHbGcehMOAL8JBuGzfv5PE8GqZIkAoCyfkbHG5WkMV/TU88pAhK kSnQBePV3OrOC4D/09PpKCdpaCsJhKv0FxLcRt4Qxoki8+qVe4YS6xuYh9BSiXHAZLHn ZwJA== X-Forwarded-Encrypted: i=1; AJvYcCU7q0CLv+Mn58vAz+anWFM2F4TXx7DVZdLNEwfiW0ajMueEk9FtqZtM8ljzHIdS6Det16t4nJr1WN/JWyx2YOQMVxJc+CJ1efblqwoiiw== X-Gm-Message-State: AOJu0Yxu1GptYCLcNJfSfG5D2EOWfPJuQSwQcMq5nT1wrU9OfVgmsh6+ OQQlw3HkiyfxGTXqqrdf5X0Kl0i8Pz2ZDUlhe2ok39u4syAgChsmrWlRRkR9Iww= X-Google-Smtp-Source: AGHT+IFT+r/UF1JH6FSsBdVJjL7VZm2U3O/9DdLtdnvhN4tdlKULjzOhZLrhWci1h9xgCzKbbXSdTQ== X-Received: by 2002:a05:600c:45d4:b0:426:641f:25e2 with SMTP id 5b1f17b1804b1-429dd25fa5emr22233205e9.25.1723647860210; Wed, 14 Aug 2024 08:04:20 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:19 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:06 +0200 Subject: [PATCH 2/7] regulator: bd96801: 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: <20240814-cleanup-h-of-node-put-regulator-v1-2-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2266; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=MNChZLpbj/MWNGgnwsRcQZFxOn02r/u5ky3hmD/OW5o=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdoruzUKLXQwbjGAbagYQRMvAI3PsR0rLQ3V 3/d6GTLP6uJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHaAAKCRDBN2bmhouD 15VjD/915tQj7Qr/6BMFohsF8gAVyxOqUm4K+gtazmjt00iFyD/Orfef6dj8ZvNjvrJrWRq0W6+ pXjE8qpNUNa3Wtgo1JPy609NgdDYqcR6/3EBi4BBlVji++M7tWPG8JemQgwc15rdWMtB6Ej5oRR DoRO21/y2QoVbOuEVt5K4oYn8lg2O5nPVWJzm0s7WsrbIw79DqJtci8BU2nhPlcV2rhlm+YLWb9 Xxbr8HfPE9lqPCO8iz0Smvz1f9I8gr7DBJjOJ6a6Dfc7TVqyXLBKi2bZBtYq7b25f4OtgR/6KNP 7lHQ+3ZT1uKR5aZ80FYXj43Ll2njZERAWhYqVgkdqjE2Rcxnf9mKckvPYGWAe+e+J2kKY8SwUyt L/oPBj6Dyh5PB+bwMVtnLjPYdFKFRjQyW+KUHTcrznWlxtndQX9DO/Cdrbyou4pskzambf/W3fw 9oE4f8Y3tT6tN/IEraEh6FcVLI4fGays5v52k8T9k+cN5Wn8jTY7OHGeXZnJCWTsM7+z5RhkG90 gWRIcBmRA3lPQ8WxbBbf/UFT9szAjyaOqDffANjGHs9xlq/l5pV7iLsusIm0ngvcEe8tzJMpat/ npiHx9Q1S1L9u4zZTdkec/mDGVOYm2xjr63eWgQZ/39CNwG5b+dpRTgbmh8W6mrxj23NAbZtGuX wtbSUQR6cYuCv7A== 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 and make the code a bit simpler. Add also brackets {} over outer for loop for code readability. Signed-off-by: Krzysztof Kozlowski Acked-by: Matti Vaittinen --- drivers/regulator/bd96801-regulator.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/bd96801-regulator.c b/drivers/regulator/bd96801-regulator.c index ec5b1a6b19e8..9876cc05867e 100644 --- a/drivers/regulator/bd96801-regulator.c +++ b/drivers/regulator/bd96801-regulator.c @@ -34,6 +34,7 @@ * conflict in your downstream driver ;) */ +#include #include #include #include @@ -453,15 +454,14 @@ static int bd96801_walk_regulator_dt(struct device *dev, struct regmap *regmap, int num) { int i, ret; - struct device_node *np; - struct device_node *nproot = dev->parent->of_node; - nproot = of_get_child_by_name(nproot, "regulators"); + struct device_node *nproot __free(device_node) = + of_get_child_by_name(dev->parent->of_node, "regulators"); if (!nproot) { dev_err(dev, "failed to find regulators node\n"); return -ENODEV; } - for_each_child_of_node(nproot, np) + for_each_child_of_node_scoped(nproot, np) { for (i = 0; i < num; i++) { if (!of_node_name_eq(np, data[i].desc.of_match)) continue; @@ -476,11 +476,9 @@ static int bd96801_walk_regulator_dt(struct device *dev, struct regmap *regmap, dev_err(dev, "Initializing voltages for %s failed\n", data[i].desc.name); - of_node_put(np); - of_node_put(nproot); - return ret; } + if (of_property_read_bool(np, "rohm,keep-on-stby")) { ret = regmap_set_bits(regmap, BD96801_ALWAYS_ON_REG, @@ -489,14 +487,11 @@ static int bd96801_walk_regulator_dt(struct device *dev, struct regmap *regmap, dev_err(dev, "failed to set %s on-at-stby\n", data[i].desc.name); - of_node_put(np); - of_node_put(nproot); - return ret; } } } - of_node_put(nproot); + } return 0; } From patchwork Wed Aug 14 15:04:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819212 Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.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 D14011B580B for ; Wed, 14 Aug 2024 15:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647867; cv=none; b=QjfoVQ65jWowECHqiEDDnmCiWxj3uTx5ng4C+seifinO1Ku6Uarmp8ceyWEPIlO3Pxbz8YSGPisMkEufurLnXU3ypFuYV6iFnDlMfLRMKD7P1pTftr8ky9lhPkNBA8SUJJ3bUdQ/OiaWi+uWUjjEuFQQ+JXu8rVqJGYTf4R3YW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647867; c=relaxed/simple; bh=HKFKyZib5VKnJdUuDJakQAsIhOr5X3HZ7uhakSIt1BE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=p5ZIPv9cr/M6P4/5yLu9pere8ghxwrMu8P4xIF6W2LmmtNWY7k6Us+fDcv7CVU8VJ7XXrZ6IHSl1N/4vrQ3QAGj6nQmOdn9Pt+0eozPSec1KcqIeW8UMEN3fMZZyl1lTaX6qhXeDUJquMohfa16mKz49aT4Q0kUZuGpJJBkbz8g= 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=orDNm7Ao; arc=none smtp.client-ip=209.85.167.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="orDNm7Ao" Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-52efa16aad9so8699157e87.0 for ; Wed, 14 Aug 2024 08:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647863; x=1724252663; 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=ql92g3IlSel/JMsJTBmGL12yP4qS4j4UtrmTRytGT1s=; b=orDNm7AoFP7TzEYZEMbQ98x7rfuzflilFXbLB6r46d1feAFzpArl8m16zfVU5FPA15 cZg/vrgj/fp3bVPG6dvJwXrzHHSYzIGCzaIrYooEEuR5SsdbuekwvCPwcWf8lChYw4IV 7M9FmYcgwXZKq2q9MlAZB+7yyC9HeLKuBPAnc3VBlLMhGwTKLKpB7zNu6xdtfK0fAjHS ux8B/sKDZTzEkOraGkGSAe/3amkAern+B6LCKVJAA+qC1N1roYWoQEpfnOcniJEv4Xwu 2bAMmwhxOhxpEgdWDR/PWN1Rs83k9vNDZXBn0RBEwf7aT6gvon2tcdkYVkKe8DWVKalD DMMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647863; x=1724252663; 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=ql92g3IlSel/JMsJTBmGL12yP4qS4j4UtrmTRytGT1s=; b=YCybJTPEXqCjXmYKSRITv1LpR8dFL40vvUlWHrmRnxpNGMeLoSynTP1SsqbvLXQfa4 m6mL+TCCfjEnidmbnM3tzg5SFj4r17OUQBEPRDji3NHqei1x+daDgHDxM9ywmq+QLPcr 1uRy53FjNpT5wyo6ePQzxISyjQeHIMT/UfCvpC7W247SXlYpxtacSMluxGJnawPcm5Rh CU3RcrQX8saNhqrpJr+QAf8sO+4tAi/8SahnFrR7gF0P2xZIYoxxZsyNUP7rNqaWsto4 l4KOIKln78GnWj3IhJksk4TGNQOHgeXNsuNg1P+DytvePItRPGQDx6ZnJ5fROtkf7Wyz phng== X-Forwarded-Encrypted: i=1; AJvYcCUL5gexbHCwfYdEV5CB4JjyWx1/OewV1JK8zMI7iKbp7lVaLqrE80rwXU31lAgg2wS/8mIEAiNvJc7yLsmf/qN76T/tqblu1wFZovEoxQ== X-Gm-Message-State: AOJu0Yyh9REKoqkVq/XK7HTREua3lXtkLFCEXCp78RMHAQX08oF4h0Q4 Lf7S7GxW6cOF5MutRW/XLIofXKvLtn1xYpwZWUlJRfRMG+K808H/McJsWwckqB8= X-Google-Smtp-Source: AGHT+IGu3DwjbZr/7noh9P2H71pz2ZOViSHbSyH2U0t4pwvKJvHyX+AJnV0p3bUqSkfSvtJejl7obw== X-Received: by 2002:a05:6512:239b:b0:52e:fa5f:b6b1 with SMTP id 2adb3069b0e04-532edbd598fmr1593960e87.60.1723647862671; Wed, 14 Aug 2024 08:04:22 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:22 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:07 +0200 Subject: [PATCH 3/7] regulator: max8997: 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: <20240814-cleanup-h-of-node-put-regulator-v1-3-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2267; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=HKFKyZib5VKnJdUuDJakQAsIhOr5X3HZ7uhakSIt1BE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdp9nwqP+7IBK1IA/FESYOQpVx8C/ZOu7nHN dyB7jnGN/iJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHaQAKCRDBN2bmhouD 19D8D/9qJRD6vc6koDrB7DKkh+SqxKz5mPXuv81NfvAKp+tFZIxwGsSE38f242goqHEvg0UqrX9 dawZdUvXXPprvW8yQUvzaosVLYsXRc6VmfshmGrpqBOk1m7yHeJLDFbwYAvAxMbQSTjub+eHBnN R8a14Pkkize/+HCavGbDnRoeJskMzDuMt3Vpdic7fxO7D55FQ1aAT2NLQpMt3rOpCxnc+QNF84g PFN22YiJ/B2BWzAydXgdiNxzseufjng+ISc0XK5QCxtC9L9F0gNZnFZ7+iRLRu3rZgRGSJmFYfw QlC5J0Iwpm+sxUTvElWmuSTx/LXZhWZ0xVCPWhD92bnWtjRTKG+cPiVf1aKNTycw88Wq1a8dSv9 PuPlf2Y3RIPsJgfNmgYoy/SarvcQ6DD5hm9lzdz9qRxq4ymiYnDQRj6sF7N0TFXHCnU3UDMyAs3 t6UaPf5u1/NlLJCcIGwl1GFQnZVvVBESEkXWMWKTDNExWPgxXaM+/1kA56qZF+XzWvG6EEewhVL rT1bbgSgbq9UYwRaK3nj1lbQSF64DQqb5o0l5trm4M8Zvwj8zqtICo1+qGYnC1qWdB9aKaiH26S LGa+pzCVV7KA/5n8YKfdMYFDfROyoBI8vLci1zwaovbUlNk67VJYY41rGvFg5znsw5ne6eSX6/b 4rvA8VGg995OeZg== 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. Signed-off-by: Krzysztof Kozlowski --- drivers/regulator/max8997-regulator.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/max8997-regulator.c b/drivers/regulator/max8997-regulator.c index cdbfb4561dd8..e77621b6466c 100644 --- a/drivers/regulator/max8997-regulator.c +++ b/drivers/regulator/max8997-regulator.c @@ -8,6 +8,7 @@ // This driver is based on max8998.c #include +#include #include #include #include @@ -876,7 +877,7 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, struct max8997_platform_data *pdata) { struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct device_node *pmic_np, *regulators_np, *reg_np; + struct device_node *pmic_np, *reg_np; struct max8997_regulator_data *rdata; unsigned int i, dvs_voltage_nr = 1; @@ -886,7 +887,8 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, return -ENODEV; } - regulators_np = of_get_child_by_name(pmic_np, "regulators"); + struct device_node *regulators_np __free(device_node) = of_get_child_by_name(pmic_np, + "regulators"); if (!regulators_np) { dev_err(&pdev->dev, "could not find regulators sub-node\n"); return -EINVAL; @@ -898,10 +900,8 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, rdata = devm_kcalloc(&pdev->dev, pdata->num_regulators, sizeof(*rdata), GFP_KERNEL); - if (!rdata) { - of_node_put(regulators_np); + if (!rdata) return -ENOMEM; - } pdata->regulators = rdata; for_each_child_of_node(regulators_np, reg_np) { @@ -922,7 +922,6 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, rdata->reg_node = reg_np; rdata++; } - of_node_put(regulators_np); pdata->buck1_gpiodvs = of_property_read_bool(pmic_np, "max8997,pmic-buck1-uses-gpio-dvs"); pdata->buck2_gpiodvs = of_property_read_bool(pmic_np, "max8997,pmic-buck2-uses-gpio-dvs"); From patchwork Wed Aug 14 15:04:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819503 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 157BF1B3F0D for ; Wed, 14 Aug 2024 15:04:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647867; cv=none; b=gZh9/fv6vdJsAiRiawW1Agw/ilao4n/pDLAusD7GMMwdp+oDVmFy/fC+43pI1RJhDkk0nt4g+Xry8i7YmciViPp/bM2WSzT3+vAmLJdZwwJaCLk6dLRYL1XfIYvnI/Sx1aVmHFkGIbAkgwo2isy0h20W1Dkl/M24ZBwwvUEd4ag= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647867; c=relaxed/simple; bh=krE+SHok9HZd63yAd9AD4NQ/RWe30H45bGKZExWRrHY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=G8K8ta/44AU51c2LVjbtvLNj80awfAlMNAiCK8JkqTgx1yeo9lVYyYLxOpkacI9DQYkeCD5rpSAEvWEupC6HGFwo9p/ZcTnL0E6506dvhU2H5p0O+vkRTHuMQXMC/hoJdfTPTZQO4ObCOHrYdfyz1zCrjLC00GLBbotYfI/7rVk= 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=wHRYqxwo; arc=none smtp.client-ip=209.85.128.50 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="wHRYqxwo" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-428fb103724so5726375e9.1 for ; Wed, 14 Aug 2024 08:04:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647864; x=1724252664; 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=5O3B7PyV7G/t+42xNPn3Ro9dRzqDxhODbgBFGwCT/6c=; b=wHRYqxwo8E0KAtu+UVZl3G3ST45mn8I+jDYG9/VF7z8Zd5IBGq8Jpe3duqwwoNfrtJ j4Fyd79I11IqWAlW17kMmVGMRN7A7cNIaNWvLWufRIUcVVlua91LlvbGx3S5g9PyayrW AW6pwiJft0aMICAu+a8wV1quoPGN9qWojH0Tk1JygZy5EKE/9IvJ89zfIciP3vW1tZwx s9oWessgZcWaeGpXzMO3Nyohu5owaFBDrBcNwAFocCRFScotUNsKPcRH0RaVtFckWB54 BuWWDOk86xlsVyYemZdEAb7In85gjGHS3CdrVOqt0S4zKHOHwGINt7FXOOxBImzgIaMM oRaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647864; x=1724252664; 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=5O3B7PyV7G/t+42xNPn3Ro9dRzqDxhODbgBFGwCT/6c=; b=a+sR1/dEVBqPI9j6uD7Zf+CN4GmPajkIIYcMZVLoucGqjv5rsglL+uI2Ldsbbq3G/m EhLzEbYYCHa7vHEK5tmC4UbhvC+USK35WhSaPTlSaOwcnqu03NU0l49X3OJ6SeZ+y+Zj SSG9gPlyTdXVMpT9uz1H+ULYP1IgY7n4xz2Pia6gm9k8jefHhbg1Y27E0mSYJbbfZ9Vh EabLwNpQ7U+VCJUjo7NoPIAaQhO7G7Nt8cBfpQWSjFx1CWxfY55ybQ7LBTDdkQVPDoz/ MXdfhfhGSJjg9TN93Ap9bvxvibDRi+TA3dIc308NUd9Yyaw1eIpxtEVXCGKSu+BbxCa0 ZO9w== X-Forwarded-Encrypted: i=1; AJvYcCUGiL3l8oMHofzmeaHC69Bd3K0pOMvYMTQryEA2UuG5Sb7lHBGDyuU4NDYu68oA81+ksWVU0w91qq39p4TKDk9OJQnkVK6Mpb96xhPoBQ== X-Gm-Message-State: AOJu0YwG4pGIFXl4Yjle6958ysVxunIOnSZ8WSXRvfyJcMZokqzqRJJV 7GNePTCoJ9lKj5ePwA30Qi94BcX3nF6jnNLKrO7cwv/JLMUWBr64aXsHH8MU4y0= X-Google-Smtp-Source: AGHT+IE6GnWj7iNSWQ5cVSoFgUQG2+GjrEsQBNVpM5I8gWXB0aUTdw2SAlkBE6MigloaWs//cNK/xw== X-Received: by 2002:a05:600c:3512:b0:428:e820:37dc with SMTP id 5b1f17b1804b1-429deeb550cmr19752005e9.7.1723647864513; Wed, 14 Aug 2024 08:04:24 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:24 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:08 +0200 Subject: [PATCH 4/7] regulator: s5m8767: 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: <20240814-cleanup-h-of-node-put-regulator-v1-4-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2654; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=krE+SHok9HZd63yAd9AD4NQ/RWe30H45bGKZExWRrHY=; b=kA0DAAoBwTdm5oaLg9cByyZiAGa8x2qgzdRJ7uWuEFgWetBG5o2CYJimnjQmNpYDIYru8BeeL YkCMwQAAQoAHRYhBN3SYig9ERsjO264qME3ZuaGi4PXBQJmvMdqAAoJEME3ZuaGi4PXq6AP/jvd Iimx4qgmPCWd3AGNnGR+rQ0isWDzcSZQ93/mymBfT9iD3jkwm1+U+h245332W//C7xyrDnDvFEO O+z8IQ6QVDTylIa+aIly14fHTaGQ51qEEvVU/4sf0sKAjNFbclF4R8B8ODNyyyIQre4qEqDTQGa WGHHsBoWTYTTdBm7XMgA5Kl2aEyoabBzM6rKFZ8emQ0+yGbR5L6XxJjlwjTWzRxdpS/ZFNBwmBQ YPUHwKvyrgtoBpWY09moq3QNmVLyAxiOnXmeBG+EBYAA5m3FjTjwMo9JTHgjoxdSbHr6OAJ/eaI 46o3/Ono7o1YrlF3563wCxSwiwLb24/vt/arV7ZmY4yhAoMTJKALvCCtbLpSeAjRMeTXumyOfhK 6w06o9uPWfgzxDKpjkw8+MpmfWCMGKUUkAdzfbu/yem76YuWlt2iqkz00OKhYRXlgdrXaPzdejO 5858LZ163EUFa8telnsJtiYQQFmgwNALmBejk/7EbDehPyqOMAY01nulvbpWYsRf220BlU7xN1K TIWxwdmuQNzx9KhFJ56Gs1XGIvpf1dWOSaHM7FIhgymlpuFAgTx8wmDYs4vO5soTo9f9YAJ/0MG D9q4QsGtXdqz37clEN9yMkXAIYuCFND1xYHehOvVX1iyvLTpyGXczNwxabb6T50odkjWwTKlxWk +7TUE 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. Signed-off-by: Krzysztof Kozlowski --- drivers/regulator/s5m8767.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index bfc0e143bf40..d25cd81e3f36 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -3,6 +3,7 @@ // Copyright (c) 2011 Samsung Electronics Co., Ltd // http://www.samsung.com +#include #include #include #include @@ -521,7 +522,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, struct sec_platform_data *pdata) { struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent); - struct device_node *pmic_np, *regulators_np, *reg_np; + struct device_node *pmic_np, *reg_np; struct sec_regulator_data *rdata; struct sec_opmode_data *rmode; unsigned int i, dvs_voltage_nr = 8, ret; @@ -532,7 +533,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, return -ENODEV; } - regulators_np = of_get_child_by_name(pmic_np, "regulators"); + struct device_node *regulators_np __free(device_node) = of_get_child_by_name(pmic_np, + "regulators"); if (!regulators_np) { dev_err(iodev->dev, "could not find regulators sub-node\n"); return -EINVAL; @@ -544,18 +546,14 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, rdata = devm_kcalloc(&pdev->dev, pdata->num_regulators, sizeof(*rdata), GFP_KERNEL); - if (!rdata) { - of_node_put(regulators_np); + if (!rdata) return -ENOMEM; - } rmode = devm_kcalloc(&pdev->dev, pdata->num_regulators, sizeof(*rmode), GFP_KERNEL); - if (!rmode) { - of_node_put(regulators_np); + if (!rmode) return -ENOMEM; - } pdata->regulators = rdata; pdata->opmode = rmode; @@ -581,7 +579,6 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, rdata->ext_control_gpiod = NULL; } else if (IS_ERR(rdata->ext_control_gpiod)) { of_node_put(reg_np); - of_node_put(regulators_np); return PTR_ERR(rdata->ext_control_gpiod); } @@ -603,8 +600,6 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, rmode++; } - of_node_put(regulators_np); - if (of_property_read_bool(pmic_np, "s5m8767,pmic-buck2-uses-gpio-dvs")) { pdata->buck2_gpiodvs = true; From patchwork Wed Aug 14 15:04:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819211 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (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 BF6211B86C5 for ; Wed, 14 Aug 2024 15:04:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647870; cv=none; b=Eu2VaANNEaK5BGJZ0sNUWOtcmff3ahGbcNvP2WQX7Wr/W53fP2oE0M8y19FlJoysbNAhEqESjNp/F8YC/1n1B9joql5UjxT1irB/sot1J1575jWG5icOLTF4xO8yIwFdnVTRUnrLQl322u/oa6AKvqcDPH7rg4AAPsONTmgq6zs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647870; c=relaxed/simple; bh=eOLW+7XCSrgYl8oNaIQs1U9NSlOctUB76u7J7/B21Wk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NY6TTY1VHej2uk2QScTMfHRdS7Hx6jsI42BtQDZiFats4DqV5bTtaKY+YeacITNnwaDRcqnFIo5jyOuWGes2SE8RX6/14/sXnP6LQaKBWGtPqfqMzZSMqBraKYQ275X4Y/2nQlI6MUQi6NtB3b+h9oSrYLqW8LQUDxhoKVu4qyk= 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=J9i4ww6n; arc=none smtp.client-ip=209.85.167.53 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="J9i4ww6n" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-530e062217eso8359153e87.1 for ; Wed, 14 Aug 2024 08:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647867; x=1724252667; 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=9KwtbTNhxK6QLwV2KuYR/1Wk3sxaWn7bUkVHDhGR+MM=; b=J9i4ww6njmjJjZgXFqzGWUSMo/f7dCMJhAjoOfjSa7W1CUIkWhxHzGxxh3V7F6cuiq hXfGRbeSa3dBTa5yc9igyzQqrqSPn7Uf6lsj/tKXUOYyLUz/+69m3k8rHZmbK/7C6awF nOpH0gt2OGVtNXFA7b+RuP63Vvlsd1KFCNfQ3qDAGjopxuCwXMCWZ0C+BloUs4JlVxTL feyMwBJ58WJ+OFAguSWLPGWDzAVpjevA/z7syLSTZ1eBjH/K/9CDiOr3/8SsBJfpdDFy ivwZBp7oc8FwoSUJFFKi1Cx5UCoa9s1e3kJaunDVbml5/UJf8Cc/QL6eeV/GHU9ZXzvc vwEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647867; x=1724252667; 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=9KwtbTNhxK6QLwV2KuYR/1Wk3sxaWn7bUkVHDhGR+MM=; b=rR1yp5NTZhV4O7/lyIgA63SZ9d13Nil260Ph6/0K9V1GMbQAXXmCCD+/tbiHTJY88s 9VgMErsL1/FjwrPSJpg317moowcuWuIwewjYMYFYnhnTGpYQWY5q9WoCt1/YHkU4D0IW qnq2OUhvDbwrk1TeiYaMdlADYHuKMjkXP0mg0dav/68kjUTMxB6PSKjp6D+n9vX4mWUe x/KrYtYY8B12uKJrOSQ2RzsGvhoqXHQn0fGLRMfg9Jdmb/s+aOtZERqGdeamLHGerDUS 7DdEbm4touRovFPMkykCcizP7wYoW6Sdbsdjf9S00c1Uw+jtn34x5SHva35kiqDB2rEa /Tng== X-Forwarded-Encrypted: i=1; AJvYcCWzg9z5EaX9mq13rj829w/FvsRLSc3Nx1qGVULZc96+PT7mTpFKUtFp+RMPaD2pn/CQcic/lyARXxM4kLjXopCuxWSI3I1DNX6nNc9a2Q== X-Gm-Message-State: AOJu0YyPvO/LAtQ8F2jv4wHKq4wiof7s9ibkqzVamnQzJGTOn6OhDdGY DvuVoOv2QdvrP/eY81I5EYfsejW+BFeDLUrYYreN0FilUsveyiLzTWPVrc43nbA= X-Google-Smtp-Source: AGHT+IHWzR0X1/chVI5nyA1bbHhSLG/im51ue7HmP59m16YndqKv/URofmBboXJLf4NWv6CumXY1WQ== X-Received: by 2002:a05:6512:128a:b0:52c:f3fa:86c with SMTP id 2adb3069b0e04-532edba1f04mr2399025e87.18.1723647866779; Wed, 14 Aug 2024 08:04:26 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:26 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:09 +0200 Subject: [PATCH 5/7] regulator: qcom-rpmh: 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: <20240814-cleanup-h-of-node-put-regulator-v1-5-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1376; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=eOLW+7XCSrgYl8oNaIQs1U9NSlOctUB76u7J7/B21Wk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdrmXbX+7wxh+iBPMjSGusVfyVLcDmyopVEi Nu88lC7I1yJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHawAKCRDBN2bmhouD 18SWD/9IPpuPdYyOE7Twj4hDzgTcOT9AIVyIT41gFT4Y4Z6jo8XeP+z5bovXs/kpHX3pEuzFq3h eyPfwoxpaUuIEY+UhO0808X6GZwdGqofvuRisDO6osxa11w+CVPKGqW5xJ6gUmOaXdoWUN4x12I TUDwvuGTZQ77KyG+cLBAovMp/YjDe+uqnkv9SHxh503dnBrEAanMsX7rtsWbywnhNmQc3MSdEYP MB3mZnzVxYepZNmDi6tBK6iz26Uc0sb3PX8nJQG9GsHN/M+OB42VMGegkPoxEB6eFAhbvkwtGjd hk95FjI2jS2r0psjHIo5+bUtUlZxlg1A/caT03HoixwHlXCv1I+R2VzgoHsw/mIxhItu+quTRI8 uBclKP91xKYg+M/+tAnFz+zwNuHUyT+JwYciz37mWfkYTnfdglfLz80ksdY7QiE9SNCqBHJmmU2 rlg9dHV8D5v9enKX6juMfbToc81LfN5HRCj2AFIH14lptzs0matpmHQWwR8r+lTimxzPQjQfGs7 4l9dtaYw8lcUPoWkRWWuy0V8eAwBjPh3JvdCL0Xi5VRgMp9BnqE/Vjni6DsVjMqcQ7gB0Jl23Gd wFkfK/kUNyJsQhXHmCppXV7SqODs0xCQ+cDpPLlgjokumG6D2SrLNi1+VPyIq93YuB9teHEAOLm X97Wj0+Qwn62jew== 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. Signed-off-by: Krzysztof Kozlowski --- drivers/regulator/qcom-rpmh-regulator.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/qcom-rpmh-regulator.c b/drivers/regulator/qcom-rpmh-regulator.c index 80e304711345..6b4cb7ba49c7 100644 --- a/drivers/regulator/qcom-rpmh-regulator.c +++ b/drivers/regulator/qcom-rpmh-regulator.c @@ -1537,7 +1537,6 @@ static int rpmh_regulator_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct rpmh_vreg_init_data *vreg_data; - struct device_node *node; struct rpmh_vreg *vreg; const char *pmic_id; int ret; @@ -1552,19 +1551,15 @@ static int rpmh_regulator_probe(struct platform_device *pdev) return ret; } - for_each_available_child_of_node(dev->of_node, node) { + for_each_available_child_of_node_scoped(dev->of_node, node) { vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL); - if (!vreg) { - of_node_put(node); + if (!vreg) return -ENOMEM; - } ret = rpmh_regulator_init_vreg(vreg, dev, node, pmic_id, vreg_data); - if (ret < 0) { - of_node_put(node); + if (ret < 0) return ret; - } } return 0; From patchwork Wed Aug 14 15:04:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819502 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (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 C2B141B86C8 for ; Wed, 14 Aug 2024 15:04:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647873; cv=none; b=vDrIxasU8XtJe/kJE+w4veJ1KjsgFS3aSbQ2yb6TmUYzE7GQxYL2mA9o+6zOn3opSXBbCiwTy6vb1kt+86eVZLPyBJH++Gzc/6J0XYo1s7TUf60mWc1GXvq3TtwGDiSjBO7cnRFZIqVq+JMSgFjs8boS5OUA8pyOwo0rC0AhT+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647873; c=relaxed/simple; bh=eBGTSGUpvddpWZ+1sT4gEslKcB5kBGvw5yw7ydkjC2k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Jfj9wbQQKHzTHumEIhjNPGkNNBlomHybgxzcVTfN3zN68dlnh1zbJI/4V3467MrLNU9L1rwHebBXwMw5TB4sGtlpBTfuMPcqgLkDlh+LNJhfYNsfCPo87KaUZclevwmZpvsUqv4BGw1M5Ar5puzTtTpEdfEKWw4xYzpuHXBfpTg= 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=avRnCjsQ; arc=none smtp.client-ip=209.85.167.42 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="avRnCjsQ" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-530e2235688so7295441e87.3 for ; Wed, 14 Aug 2024 08:04:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647869; x=1724252669; 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=Uby3vx5C44xympQeIPbZuYUa73IoZNR3m1Cs5S0QTJc=; b=avRnCjsQ9b+v2L261w03SscxwU2RjV5e51dxK/jIslXiau1RUlDUcJD2358vHY/ftC XW6UWoJQJqKasx44c/KLcw0Bi44pFez6SqwaZhs9Gt+3bytgL9nhb/eXre5BycHduonW FXaJ0DVBSWGyF4YGL/m9FdYLSyMen34QHj9YlYGuFDLvvniEd4AY0I0wMYQg/hI2ER23 mTJyj8JOnw0Vv565XuR7On9nX7pHlsQQWM1OkTmwkzNhVzJ1SBiOpjC0xQTj4BJyGIgL cedp4UPvujhkkgOP4fK2Gd9v8RFsiCV2vMfBKMv9m1fzekKvw8Ax9hQsgX9p6vBLsgkR MlVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647869; x=1724252669; 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=Uby3vx5C44xympQeIPbZuYUa73IoZNR3m1Cs5S0QTJc=; b=agmAqM9yUt4hOIIB+SEbHH9AUvAqFfG2M3VlMwj5xR6YWnugAeP4D3kOw0ICZbFjAV Ldv+QXzMg78JBihtINxfjZw/Xgr2CblHPbH7XyCiHRbR9xTFoi3wdUJselqTOaBQzYAy pAq0OH87Hy+DaPlxD6NUfWCuG97J/l5xlK1/2hdctNEqeQYKJowMTXWslrYgDfco7BFt P92tqPSAnoUWD3W/QeBA+IYAHQMpS3+VoCZD9CjXBTrAvFnRcdfqg/vvacO5opB5p7IV aqH+nSYovBx7HW0zdrtxb0L2antv88Bc72lmmLyiw4BoSYO0Nyy1Mz4ztDv4/f55D4+B oGBw== X-Forwarded-Encrypted: i=1; AJvYcCU0dwU0B+SL6auauZBE+I96jT0LzOUWeA12qWiVbEaD0lkbDY9YYeYUHf0Wza9ytR8y4gVOmd6fQCj0soHfMNKaWXYqMnkcIMcTlJwnrA== X-Gm-Message-State: AOJu0Yw/mbQlnf7nDQQY9EMpOZXLp6NjVcnFQ75MiDzXiZGYSSerHpMx gPY6ktKAbjk9D2kmCoeDhqJETIatrviBft/GF64qhoekPHDUL93YcPHgLxm2Uv0= X-Google-Smtp-Source: AGHT+IGocQ+sfcCI0BsP7dFMq93jhRdGBeu3R77b4skm0zxlJaGhDpoe9Yu7aRhk+YK7m/4igocdpA== X-Received: by 2002:a05:6512:3daa:b0:52c:d9a3:58af with SMTP id 2adb3069b0e04-532edbbea6dmr1706687e87.49.1723647868534; Wed, 14 Aug 2024 08:04:28 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:28 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:10 +0200 Subject: [PATCH 6/7] regulator: qcom-smd: 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: <20240814-cleanup-h-of-node-put-regulator-v1-6-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1371; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=eBGTSGUpvddpWZ+1sT4gEslKcB5kBGvw5yw7ydkjC2k=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdsbGg5jhGJCbxxUs0v8Bv4OUF1uvi+EO1FC F3GEVhn6JeJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHbAAKCRDBN2bmhouD 1yPiEACadxHRdHC3Qbt35GS0lKK/OD/r0A69dULWvdqQ1NN9HvfQaK5Hx7jbFXnjONsqn3KPMDC EGL0ATj/SWGAUxYjIXNk/EzUw1vF461IkUHUstovhu7pqEZsMTdS8t9YxFzYBOh5DdmOQZrfHtU SWFo7VISazhvpFuge/3lQS7L/NYMeb1k6nREZd926dVaoL15IJpyAnrbd+k5nUP9eHsOGTIinUF b2sdJ9GsfnIWvUh503gqMx47bBb51hauURzkb9g6CmFJd7Gwo6wbCCwlhp2KKWGsGywJ9vozaSH 8ggbvKEVF1TsTNPHI19jkqdRD7yySvl73tsQTe6nOg2ueJWvBRfjMuhcmXeirtgeW2vAJGShEjN /iJ1+ep5RSfkl5QEKfO4OreTj2NELrlxm2B2HzCZGxv6c8b1GXVjqLSWvELfR34stg4/RgKcV7r FGCFwPGoQaaq0tHYOglqBaX/KnHKCjRH3CK/ZrjyaOBcF2rRzgZLT/7g6hJDkerfOCx7qcB7lWU HRlK9/Ocgj0gVyfCHppH4q1/bBtt33K0osv+E+1L51Hl5J4LWqMkDIaCo4pnG71h4lW8DGXYATs On62TrglDkCpWgvmimD3jbo704nE2gh/g+kZPrLN1lEEf33c5BKh1Nku83Oywr3QkwXySFt6d8R jrAv31M2iAyjOKQ== 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. Signed-off-by: Krzysztof Kozlowski --- drivers/regulator/qcom_smd-regulator.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c index 3b7e06b9f5ce..6761ada0cf7d 100644 --- a/drivers/regulator/qcom_smd-regulator.c +++ b/drivers/regulator/qcom_smd-regulator.c @@ -1435,7 +1435,6 @@ static int rpm_reg_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; const struct rpm_regulator_data *vreg_data; - struct device_node *node; struct qcom_rpm_reg *vreg; struct qcom_smd_rpm *rpm; int ret; @@ -1455,18 +1454,14 @@ static int rpm_reg_probe(struct platform_device *pdev) if (!vreg_data) return -ENODEV; - for_each_available_child_of_node(dev->of_node, node) { + for_each_available_child_of_node_scoped(dev->of_node, node) { vreg = devm_kzalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); - if (!vreg) { - of_node_put(node); + if (!vreg) return -ENOMEM; - } ret = rpm_regulator_init_vreg(vreg, dev, node, vreg_data); - if (ret < 0) { - of_node_put(node); + if (ret < 0) return ret; - } } return 0; From patchwork Wed Aug 14 15:04:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819210 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.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 393141B8EA8 for ; Wed, 14 Aug 2024 15:04:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647873; cv=none; b=CH8NsbBGq6f9Ecdicn/4pcEEMyKe/Mz3qfRv0RIfoxgh1/vlPzHzLKpGp7nHa7g9YQ1/d3rponnOZfDeq9t4bG9hInwvMD/BPwJYW3DrUu/4Oc+nn9mnIyJe48PEDa/KVHHX8Pa9/bbAgE/pAjgpfRZoSHZKDhnVGYeYFLkq3iw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723647873; c=relaxed/simple; bh=OoJl37VhWa2/ok3yWXn0smE+qe2VclKzB2yD7J0hAwk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=A0QZ8XWG+gOmyHwWoZleTn6qep1+0x387dN7i3pX9GZrGLCba0rPPMSzvzkcdo62rK7Hd68GJeHfwSvyEd65bYpr0qQg2QSFiFRg05P+1qw7KASBnJRnB/88zQosB+dmPa96U/U7yc7LavOPeEaTRZUDvwcIxGkADwl8ygkkqJM= 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=pdS568tv; arc=none smtp.client-ip=209.85.221.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="pdS568tv" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-368313809a4so599382f8f.0 for ; Wed, 14 Aug 2024 08:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723647870; x=1724252670; 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=ACUznNue5Vc1PvREpF5uL8d3frSCLJ2XL4UNUgbbF6Q=; b=pdS568tvUza2UEI4RAWVRTasjZ4Rk2RWjZ/u9U5hltwn0ye8WDmEAJMPTu/Dn9UNS5 XS256qiK8h4BKzp29peHYAgJc/yH18Nmoz7lTmJSV+rOeXgHZvkIsps0K+1H8muiLZUf Nvpnp467wUma71cs7GYegcX0TG6Pb2YqVNvZmNRcqwBgzf0rtDgISBUfR5g6PMpNeijs voI7Ynvs39+fuBgED6KMqvHmsqPWiA0Av4zwHaIf6ExEbuRyr61RQ/fOPleKkltRtwOo rKdkGj55it/rtP1GJF9rD/rasTv3yl3ADgBWnUW7WwnJS1I7is26aLbP2xO96B9rYLk9 Enbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723647870; x=1724252670; 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=ACUznNue5Vc1PvREpF5uL8d3frSCLJ2XL4UNUgbbF6Q=; b=u4pbCMT3uLAwP6k1gtEpA+YJ8P+izI27iZklZeMvoz3loRjJ8cBBfrG61VzMziLFmv fyxGSfpnUiLhuLas8DAa11hPHED0V4iVwCjr//KtmnCtkgVqrZ5Tut5ij9SV5xKG+k1k sCBGtEEaSN2Oc3ipgbjeHW4UIBG/cGsngqODbQ67s4TmeBLgjl0byrKxDPbSMAsIQV2h Xl5opdA2tOTqKxGPTF2ROIrHYaJdN9aUX3wMtctr832kdqSX5MN2SH7JSU55Xm1Y1FrV HYcgi4iPfpAt3H7XFZk6hI/ETXGB6uiirbqAAUTIIo2zf+DbYLyZssWxxlQIn89b7xsC 2rbw== X-Forwarded-Encrypted: i=1; AJvYcCXCTQgFFFj77uG8FlikIyHi3AbNifo6aN30E6xMeHW97av6GetSIbeRsPf/20ktstCKjYa/4eNlH0CHA1hJSPSxf4lIR2ng/aV1kNw6Tg== X-Gm-Message-State: AOJu0Yz3G05D/3L8WA3UneDdcRR7IfQyerVtGww7LOQ+FrNB9JC6LUpZ eQ948p0zaRTutaAjHOVpsx+/+Qp4cWH7xjLjoR2JVv5oQfILiH37Ng5Hw9bFWao= X-Google-Smtp-Source: AGHT+IF+u9tmYTlfOnF0EY/D0BDpgP+0OTvzQjNTeJeoB9+1fHj7S8CddXYLDq5O/F0RKg2kn5vuxw== X-Received: by 2002:adf:f3ce:0:b0:36b:bb7b:9244 with SMTP id ffacd0b85a97d-3716e3eaecamr5350141f8f.1.1723647870395; Wed, 14 Aug 2024 08:04:30 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429ded7cfbasm22313425e9.45.2024.08.14.08.04.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Aug 2024 08:04:29 -0700 (PDT) From: Krzysztof Kozlowski Date: Wed, 14 Aug 2024 17:04:11 +0200 Subject: [PATCH 7/7] regulator: scmi: 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: <20240814-cleanup-h-of-node-put-regulator-v1-7-87151088b883@linaro.org> References: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> In-Reply-To: <20240814-cleanup-h-of-node-put-regulator-v1-0-87151088b883@linaro.org> To: Matti Vaittinen , Liam Girdwood , Mark Brown , Krzysztof Kozlowski , Sudeep Holla , Cristian Marussi Cc: linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org, arm-scmi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1391; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=OoJl37VhWa2/ok3yWXn0smE+qe2VclKzB2yD7J0hAwk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmvMdt9P9crcfh3Lp+LZmfqSw+yRnKP3vsTTgTz 4j9XGKy5+2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZrzHbQAKCRDBN2bmhouD 14guEACS3kV18JgvbTMljOcJKLNuprPK6EWt3rzyAwJz6S/prQ5m8/dJcjR0LfXPOSIKpr8T07P RjGOLmrYXsdGs5RKuWilAcUETR+HBy75Fd7L6qWKvOgiEkF3f/zxxnrGJr1TywAhiJzNyZxnc7e D1oX9a00U9Nq/G7TzzId+WggIZVkMhVb6Wjvy6bMT13co6O7OJ3S2DwWuqW7vrG/rt09V6amwTJ c6fr5IINXgPXbfdgZMIlT3hSoZP5vCY+3hIUGQgFPNOtjR8oFIR7BHtnTgftiqqg2U0a2B7RdYv PIRFwmhK1wP5Ld75kd11lTS47+YajB59ydM6XTotcBcPYK5fTlwqInYN2s6SX1igw8axui7mYsT X8kDCi6zpnihNFTmXGZlTK5gqt+yZrPnMWUGyBl54qGI8nTq9zw9zGGNdp2ZAFPUFU2ARCibepr orZZAgeDiuFQUSQaaHd5uYLBmthqW3vWYl1uxEpgbX6l+0tvLNwN2//N9rM9sEnvHkwbLkhunWV 9gw9jKHQVdg4JHI3Fw2hzYoFwshNDapb7HWbJa0qU8g0nyVCFAvdfJix3aqSJwiQIkLO5dAbsJI l2VZSD4h0HLaesOv1QiiAOvn8x5X1Js77S24usuDWoCHb0yL60XqMFejLhdxqcKPm+rWOYnvO7r HL18HE2d+32PggQ== 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. Signed-off-by: Krzysztof Kozlowski --- drivers/regulator/scmi-regulator.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/regulator/scmi-regulator.c b/drivers/regulator/scmi-regulator.c index 29ab217297d6..9df726f10ad1 100644 --- a/drivers/regulator/scmi-regulator.c +++ b/drivers/regulator/scmi-regulator.c @@ -297,7 +297,7 @@ static int process_scmi_regulator_of_node(struct scmi_device *sdev, static int scmi_regulator_probe(struct scmi_device *sdev) { int d, ret, num_doms; - struct device_node *np, *child; + struct device_node *np; const struct scmi_handle *handle = sdev->handle; struct scmi_regulator_info *rinfo; struct scmi_protocol_handle *ph; @@ -341,13 +341,11 @@ static int scmi_regulator_probe(struct scmi_device *sdev) */ of_node_get(handle->dev->of_node); np = of_find_node_by_name(handle->dev->of_node, "regulators"); - for_each_child_of_node(np, child) { + for_each_child_of_node_scoped(np, child) { ret = process_scmi_regulator_of_node(sdev, ph, child, rinfo); /* abort on any mem issue */ - if (ret == -ENOMEM) { - of_node_put(child); + if (ret == -ENOMEM) return ret; - } } of_node_put(np); /*