From patchwork Fri Aug 16 15:31:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 820239 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (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 98F3B1BCA14 for ; Fri, 16 Aug 2024 15:31:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822319; cv=none; b=rtzcZwtE5vdSVv4pZan4G/Sl8K7pxJJjg0C0RYbVTknJDW4zK6j/kmzLNagECZxQ+W1gLNb0iYcNnHDecVzdfKH4P3+vjI/aL8TPQz2UCQZKui33XvXSEeVN/aNIDC//3wIrElqXGlvTYIA7a5yBihcMCdT67aZJ0VyfOkAhy2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822319; c=relaxed/simple; bh=a1YGQS8jzBzLcYjwPx4kf8irSYV8QsT8hVGiKzaSR0k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JUDNmDg4ZR8CJO36gSiE+l+kzbB/4puMbPKOynw2k+Z+nQR2+RbkVmeZpyckxK8fddxtyNguNEweK/3xA/5bGr4zDbIzIM6wAAMr22nO6SSoACtlEongRlxvOtf6Lm/YyOXcNOMhhWnmgQKApGLRyu7IyImAXcqq4sYK65lUyug= 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=jL62j729; arc=none smtp.client-ip=209.85.128.45 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="jL62j729" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-428163f7635so16675495e9.2 for ; Fri, 16 Aug 2024 08:31:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822316; x=1724427116; 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=Bs19CWciVe69z8rsWTOPtucmozrfgqJROhrJ589EkVY=; b=jL62j72902DrAg0sWroJIIgWBMR3G7Ln6CNvTs0L4cvUW9XuarstT+vGKPIUWfwXo2 AnGclMa+iWyBPY7WNur6GrfXzv7UdJK7ly9guXgwpBX9bgfh4Q/iJpfzcBvcKUX0DhvV CHPw3wT2UlwSfqNz5vXHii+ebWUh3fImKEjKzldneR+Ci5J91i6PGCTc+N8qoQY2rXEN 5PPly6x6ejh5VK+lXU822filgCl1BsCxjUFlNCFx3qJcqdRl+d3qj4cjrWrEIB5YdKrc m7ZG/eytovp43dsV4hNXnh/byvk7oafE/6mmknC9RR/eOE7NNze4Bsha1cmuSlqGjW60 l7EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822316; x=1724427116; 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=Bs19CWciVe69z8rsWTOPtucmozrfgqJROhrJ589EkVY=; b=vorDkqLnFBV2EAnmCFRwS/I68zcyx0fa0in7d9RIdeaSJI4lZBA7k9hA+CXdG/LEqQ a/2h1g9ddZ8L0k7aQJsRpcpKit5YIiEf4RH0lN9JlUsGJLOuSMf8EGBRC3xt/+msWd0N yfajC8hql9ru1izJVqdfGaNu7sxtAtTNTOusx0i2QCe8uqc7hYecOsMmAeTEWuFf/JZi j/NJBStzb/I+0ZZn7HIvEBK7wluFh2apRkVLTGnLg55JgDMp35JBp0y7mDx+KfxlZAEt zx87KBi4yC7xBxNPBx98UhUT7ZnqwVwWpj0JNuKIwFCIG5qeqb58ymZUmznGg/qBh7Jc YIdw== X-Gm-Message-State: AOJu0Ywd7AM738KxDemDvHL36q9WpTvHH5GmcZvG72bzXHjrdQNKfUpf N5tI6WI3oZYmojulDhtzcyVijuFBNDngcMRLAWEstePwWlUpU/0gRSiLCyIpwR4= X-Google-Smtp-Source: AGHT+IGR3dEEF3paPLhCSZQYsm1dXDhlnka2LZPKsFs9HlMVLbvtSAJs2IkTJafZE9YHaH92MT5WjA== X-Received: by 2002:a05:600c:4fd1:b0:426:6353:4b7c with SMTP id 5b1f17b1804b1-429ed7855f7mr22773225e9.8.1723822315663; Fri, 16 Aug 2024 08:31:55 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.31.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:31:55 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:33 +0200 Subject: [PATCH 01/17] leds: aat1290: Use scoped device node handling to simplify error paths Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-1-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2066; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=a1YGQS8jzBzLcYjwPx4kf8irSYV8QsT8hVGiKzaSR0k=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DZOpqtaUv4QAkOdHVd+6wkSZBmNTro/fzvY CO/ZnU/HP+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w2QAKCRDBN2bmhouD 18eeD/44UH0sp3C6aYfp1LBephrs+liKt3nfnjZdWSJ0v/TieMbxVM6d4zS9ydJ5ky9FnYwB/bn /67+vER0yxMdbgcdPdnq+7RJo3bpW2eqChHfkD1gR59G6Ochw7Zhoue60ljd9KsBK2RPJ9+7Dd+ Bk0oHl3jNMvbjNIfNBaqvnSCmvazbnZi2n1JrGvRuuhOSF6/oY0hlzCzYJj6U3J5JLoUHo/RvEv xIDgNvQXD1Ul8c2AhudnTWUCCXGpw5bwLleLXZNh6r77KiudcrQ+wHjc+3AyB5100d/IDZV9pLz T5KFT9Qqgr1UnhKUPqvmz/9zaqtUAp1yqWgIyE6dCiKKs5ll1ljE/4lx04RwwH7gIhPAUDp19um 23NJqm8wECy/46SyyMgwAsCkV2PlLcjsTWknCQUnZKJlQawsbb/R6DYLt0NlwpkK5q+B5uh4cl7 kq4UnvALsghb7p84K1nYZ43IKYhaeH0AvYe7Q0nL3rFlNOTwi0+nCoCC8v9EleQ4sNat1X3RRxR Bu8JX6oRfVsvIDPeQ1hzmdLHAmva4nLqWQQ3yEu8cwGljT1m2fYTuEzrn7BQnFKV/xC5rID1TqV vbAdvyBu4MsxqHL8865ARm42fwwkprl2/gxxZdxmhDNYDD0KmvvJ3WQ0qiDzJATfz6/2/NPYVWP V56tjRRvGbYMRoQ== 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/leds/flash/leds-aat1290.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/leds/flash/leds-aat1290.c b/drivers/leds/flash/leds-aat1290.c index e8f9dd293592..c7b6a1f01288 100644 --- a/drivers/leds/flash/leds-aat1290.c +++ b/drivers/leds/flash/leds-aat1290.c @@ -7,6 +7,7 @@ * Author: Jacek Anaszewski */ +#include #include #include #include @@ -215,7 +216,6 @@ static int aat1290_led_parse_dt(struct aat1290_led *led, struct device_node **sub_node) { struct device *dev = &led->pdev->dev; - struct device_node *child_node; #if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS) struct pinctrl *pinctrl; #endif @@ -246,7 +246,8 @@ static int aat1290_led_parse_dt(struct aat1290_led *led, } #endif - child_node = of_get_next_available_child(dev_of_node(dev), NULL); + struct device_node *child_node __free(device_node) = + of_get_next_available_child(dev_of_node(dev), NULL); if (!child_node) { dev_err(dev, "No DT child node found for connected LED.\n"); return -EINVAL; @@ -267,7 +268,7 @@ static int aat1290_led_parse_dt(struct aat1290_led *led, if (ret < 0) { dev_err(dev, "flash-max-microamp DT property missing\n"); - goto err_parse_dt; + return ret; } ret = of_property_read_u32(child_node, "flash-max-timeout-us", @@ -275,15 +276,12 @@ static int aat1290_led_parse_dt(struct aat1290_led *led, if (ret < 0) { dev_err(dev, "flash-max-timeout-us DT property missing\n"); - goto err_parse_dt; + return ret; } *sub_node = child_node; -err_parse_dt: - of_node_put(child_node); - - return ret; + return 0; } static void aat1290_led_validate_mm_current(struct aat1290_led *led, From patchwork Fri Aug 16 15:31:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819872 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.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 E85D61BDA94 for ; Fri, 16 Aug 2024 15:31:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822320; cv=none; b=R3OqtA3vbt7/7eAr3mdkDGcrwgd+Dr7TG7UJoeb+lG1Znaq6SJdNx7wTXqjIGN+ORRH5hgSaOLNr6lqEvxboD8JEEaqd1UH8wkJluQe+dxatgTVRNm6csljY6WWj9k2Qzouu2F0/bjVUZPpt9u+XZi0yk7wiYVsJmIkQnJqtdZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822320; c=relaxed/simple; bh=9Die7rsR0B6JZR+OB5IykGhnUTGNXFPzBPfH+JonqpE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V4DnbS4tuKMl1ZSiI1tAk8JCSTgnQFIm6/4oJV9ZRoz8ow/WN7KjQ2E/dzR/tMla84eH75jrfqkpGNYtqXwUZSDUrCZERfO7+vrpQQ6bUivKfwVBA1x/IdLJAx5GkSI6P95hpxX+gfGD/WSBIGKrEvxJAjH8ebTbLEYXICGtcfA= 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=s0SMxiw6; arc=none smtp.client-ip=209.85.128.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="s0SMxiw6" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-428fb103724so16743295e9.1 for ; Fri, 16 Aug 2024 08:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822317; x=1724427117; 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=4sCEiKf2B9DqzQ8Bb94EFqGzHc8DX0w0QdFuF8Rhqn4=; b=s0SMxiw6ZNsHicOqw0Yc2tD7qb7FyeCB2DQXtyvz27vDjz18c2K8DWeIcRXtk6iimg AC+oWXxpX4wKbjlgkgGFYcIBA0yRm2sRhIIDQIuaJW4Kldi70Q2AsW4h7GYJ3CvxGUX0 YwsLxhkFfMx6Dsz3oqjP6SGX/tJoEYbNeogqLz0+vXshqS4pFUDy7EYUGPUI0fg1z2xb 9Tru6JUc9L+j5wX1aqaDfmOJx/3ycxk1o99881hmtN/0hVWO+7sT0BbNEZmoZA/f0xCi KcDy4jdQfGNFYIpUQSBMFX3krHR1QAg7zWWTd9TTWIsdbuLkGShKO0J1GRm+ku0Y7Y/Z /1fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822317; x=1724427117; 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=4sCEiKf2B9DqzQ8Bb94EFqGzHc8DX0w0QdFuF8Rhqn4=; b=SuZZUy2gLVQX9HVFn3r1lefqE6iYgPAVwfJwyj/s67b7YbpusV1bwYuPxW5jc0YFpn Wycnz5q+M0OE6/mq+1OL/8k4/frTGFMTwNOLwx8MhEqvDzGP3LnfHJhVNq7hQ2SdISVE rP4CKCnkx+ooGkrXk2qadzDq5AFucqTwd23nEKUfnkhViNMeRsMQkNljTHGjqStdolHH CWjgSqqU3cj+cBaUtQpPYqGtMCu3nMq8xE6qqbY2DpxZzPwEYy9TTOLKl/oQjuFK1rf0 W+MVCLn6k5GgJft2PE3um50xYfnO0Eq/XcLFjlxLd09lY6IBXnw6mx/IOLDeoTargOeP qIYg== X-Gm-Message-State: AOJu0Yy3pzxAkijQ+QZo51xaJccFeF1pTh7eAv5PW7dfs0SDoEftDAse EO900AIcrtAhCZi8FFri0pu1TNnY9qMx729GSBMwQmCukTC9YLDY4t6YEB0RarM= X-Google-Smtp-Source: AGHT+IHyXrDHQQ8xvlWiTDWTVoEhaAwJIa4Z1GZboPifzHF1ML55V2Wee10MVI+0W3m/5b6OJzB4SQ== X-Received: by 2002:a05:600c:1909:b0:427:ee01:ebf0 with SMTP id 5b1f17b1804b1-429e232c0e2mr51862515e9.8.1723822317254; Fri, 16 Aug 2024 08:31:57 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:31:56 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:34 +0200 Subject: [PATCH 02/17] leds: ktd2692: Use scoped device node handling to simplify error paths Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-2-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2165; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=9Die7rsR0B6JZR+OB5IykGhnUTGNXFPzBPfH+JonqpE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DaAzLdZslDk0FQE8r1wjsl32N1ooly3he/+ EvtSvhfqEaJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w2gAKCRDBN2bmhouD 17GeEACO5DbF3CFK0Jm/yLGicXuoliag3DYz7K6gsIaFii1FHbBFpZHVfrfgWYFVJ8CYd37v68w soy0nF1zPooHW/VDuHGHdPQM+JHUmVqvUunZEIc6hxiP2ega264eB3t/cyXxpJyTy8EvxTvH2S8 RLZm6GSGQmTFb9b8tFr9kTeC0FPg7i9FJRzkCCEnlXJsRplK/CW/sk/c0+7xsTXgWn1+cHnB/z4 1nWHl/IamnG7It/5//a4DlRR+8XeAL4iQLc5liQIgR8ab1IjKSuVly/W2f3FPjckkMMVIAiP0NY lXZuuMD4Xg/spf/HqwoTG9qlMAo2UDELs19WB5qozuKnq/OLe9OJzUV/t5gEjEOKr7Kf6HnP4NP pPGUQwe9j9k1bsE36op0VjHzY6nDR1vZDxTvmO6sJeGeptqHCWQtkQoXncP0hdgHEy+YiO9j7Sf MyH6enXPvNslJ+WiY6GLycxqvWbCVG/y7jOtjlzW9Nl3UNHbPuh7ZVt+C8GZ5DfJxPZVUHZ4yxU JI6xexzf69WgGGMsrLOmRbNZeopiDlAirPTz/tKiocePbzX73jydUexldAE2IPUgDYT0hjPcWpk yk5iGPgYLagzljdrUiIib+oUnd6ApXqoYlXT8TLGe1VdfmbbssaXp6dH/f3iRB+T0u79f23A33U ex5HyA/XSxDiKpw== 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/leds/flash/leds-ktd2692.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/leds/flash/leds-ktd2692.c b/drivers/leds/flash/leds-ktd2692.c index 7bb0aa2753e3..16a01a200c0b 100644 --- a/drivers/leds/flash/leds-ktd2692.c +++ b/drivers/leds/flash/leds-ktd2692.c @@ -6,6 +6,7 @@ * Ingi Kim */ +#include #include #include #include @@ -208,7 +209,6 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, struct ktd2692_led_config_data *cfg) { struct device_node *np = dev_of_node(dev); - struct device_node *child_node; int ret; if (!np) @@ -239,7 +239,8 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, } } - child_node = of_get_next_available_child(np, NULL); + struct device_node *child_node __free(device_node) = + of_get_next_available_child(np, NULL); if (!child_node) { dev_err(dev, "No DT child node found for connected LED.\n"); return -EINVAL; @@ -252,26 +253,24 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, &cfg->movie_max_microamp); if (ret) { dev_err(dev, "failed to parse led-max-microamp\n"); - goto err_parse_dt; + return ret; } ret = of_property_read_u32(child_node, "flash-max-microamp", &cfg->flash_max_microamp); if (ret) { dev_err(dev, "failed to parse flash-max-microamp\n"); - goto err_parse_dt; + return ret; } ret = of_property_read_u32(child_node, "flash-max-timeout-us", &cfg->flash_max_timeout); if (ret) { dev_err(dev, "failed to parse flash-max-timeout-us\n"); - goto err_parse_dt; + return ret; } -err_parse_dt: - of_node_put(child_node); - return ret; + return 0; } static const struct led_flash_ops flash_ops = { From patchwork Fri Aug 16 15:31:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 820238 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8F801BE226 for ; Fri, 16 Aug 2024 15:32:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822323; cv=none; b=nyvTCrDRsWacmRYYD+1ewgKm0l7uddgiHkcFAPKfAnv3ixXgKGgmQxZtOJ84bWg4zhuQDtnv5d+QlG8Ut0C1ShNecbBgjebPtXJz8TWOj+vFKRxXqx7Ox0MAU2E6VG/nsiqplhjhV9KOlGdvDg2hATtDvpljL0FAflGgJMyAYMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822323; c=relaxed/simple; bh=5KMyb/0ghZiWoNxxGIN0+j8uXXpKKlWx7oozmJ4CEcs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sMGntK6PZMVuhpOVGgZKT9Sfmys5LW4VnFolUaokDN3j+hO56AYItC9XKQRWgkelk/r+6P/xo9utIH0V4jeLH8JSA33nBKXEIpeeFmM3AGpID9MMtc1LKrlwJieTHyL+SlpqjatpS2UvAEdGGiYM0pgtbA2tqnOSIh0xkc86FA4= 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=zt64dWwG; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zt64dWwG" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-428163f7635so16675865e9.2 for ; Fri, 16 Aug 2024 08:32:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822319; x=1724427119; 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=CMXjCi1nWSGJw2HEGXaKpvGQBWqmSFyvM6Rv3lJzOnk=; b=zt64dWwG53OErxxJWStMAjFLyyARIxX/Jv6p7wzrz1N2ilL3sWJNDPWifXZZZ3Ep6m tjlxXpi3DgmGcJcS5z2vOU1ywAmObQZnY5WNa2urETMWGTW76fv7fRw2523NrOOoug1w 935xV94efRPZEPh91ba5Ed3bzQL1B2OjGNioiuvAZo0wcIPhiddfLqrGIX/CJQY1zT/0 NvX4gAfeIVn+8qaeer0sfG7b9oypNhPOAhfvYQFRU8x5dunuHEGu4yZGYOhEsLDjNsaY p7EQU8EO7krBUw1QdfX383jfS5zIyCuYjc/MVRZcCsTY3bj7jOVY52V1ZAZjEGlSUwai K9IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822319; x=1724427119; 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=CMXjCi1nWSGJw2HEGXaKpvGQBWqmSFyvM6Rv3lJzOnk=; b=JwUHLftVsw54cSoe42PzgqsjqgzWGEFwDFRQtjBKCK/qxHdPX7n1UhOOyiro7FFpOn p6KFOdW6bgi+hFmyOCZGbuvyKCXQALBWxKb5o+vIoydCq+SihIPsGkcPoNGzjdg7wgUi YKe477A3NEAoKZj6rrbRPjo8VHDMlvJ59hc7eXfAh7CvYW20iVP/d3hhUeBmgXLWVy+H WjDNVEkfVFC5zEL16bQrqe5qN3j6dowPvnybWMvc1Lu3NgqYqIOiR7scUk2LpRal6UWx 46HddoUC4CknwHSes11qkfk0IZ7nVT0sgA9bi31FpfaADug++uXLvwXWg0Jlo2HS0QnM 5ONg== X-Gm-Message-State: AOJu0YxJzKiuHa4WB0+wLU/ZtDIK4P18lWhS7gPO/lWqs5T9/o99ojvi GJcgUHyp1usI6y0PDEbZaBxTEbAd18kdNiq9molUgDnkRetDj2IIELghUKSDZ44= X-Google-Smtp-Source: AGHT+IHQVp9RMVKnFXRmolzPy8dcbt7NmXN/jroL6chg+fDJWYg7uMIzfeBfP3NPtNgAOQVI5RxN+w== X-Received: by 2002:a05:600c:1987:b0:428:9ba:39f with SMTP id 5b1f17b1804b1-429ed79e212mr21385555e9.11.1723822318959; Fri, 16 Aug 2024 08:31:58 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:31:58 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:35 +0200 Subject: [PATCH 03/17] leds: max77693: add missing of_node_get for probe duration Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-3-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1838; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=5KMyb/0ghZiWoNxxGIN0+j8uXXpKKlWx7oozmJ4CEcs=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DbVDkrgpNCWbqNPXUp9YCFjKcR3EI+TV8pk PJEmPek6O2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w2wAKCRDBN2bmhouD 16uRD/9jJHb7kLUKzwpJD2ZWds7O67ALfXb3ZP6DUa7effzfaE+ihgB7WVZpKDFSz4Ynnq+GhzC SD7hYFMiD1dlIU45EiowQ6w17hk6OGGckkc4oS5UDLJHqO38ddcLxZMtxjHDGR8DPAIRHYRRSCV aeJF3qb6rx4DHfiGx+7HuYGQahBxc5wQO7aUmpD+tKb30AdRIIpxWoRL34DC3QyNlAkpBwXC34u S8wYpbf1rQQxBswNLYYVojtvNJmVa+/7G4urNcX3L2t5N9Ocz78wJ2KXKaJ6PmByMd996E0Wi2c zM3+rJPt//QRSatrCP+YBcu9vxG86z9Ssu+7kV3vDNkYop/8zteJ8ZUPHPgVNxvBuFt0JLzL8QR 39T+Se5p7DgKy2U7tH/cp8FZ8cwH87/8uXrGiwhgi5r6tn9THegbdFj1ZwKt6Q4phJpPKJxglY6 bWKZfin1lyWgHMxA++9MV8mY7GtZ+lh8kRrvMJWq+Y9eva4qZJlXBk9O+Fu6OLzi+fHGL65R2LX JTUkAzxdPa/proprkZCnXopEdTizjxhet3j0QeFnBB5lAtMSuUttFIZKMxZg0OE96gq4JtVmGMy 56lHesBi9ptFlDGB2uRlD2OAXJ0+NmuyD0GOY548/WByuED2YjR12ECGeD4jD7KlanlFHSgqIAE FqnXEfx8WMfK5ig== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B At beginning of probe() function, the driver iterates over OF children and assigns found device node for later. The code uses for_each_available_child_of_node() which drops the references on children on each successful pass, thus the probe function operates later on the device node without holding the reference. Fix this by increasing the reference count for found child node and drop it at the end of the probe, because it is not needed further (the V4L init code takes its own references). Signed-off-by: Krzysztof Kozlowski --- drivers/leds/flash/leds-max77693.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/leds/flash/leds-max77693.c b/drivers/leds/flash/leds-max77693.c index 9f016b851193..16b169e658de 100644 --- a/drivers/leds/flash/leds-max77693.c +++ b/drivers/leds/flash/leds-max77693.c @@ -649,7 +649,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, return -EINVAL; } - sub_nodes[fled_id] = child_node; + sub_nodes[fled_id] = of_node_get(child_node); sub_leds[fled_id].fled_id = fled_id; cfg->label[fled_id] = @@ -968,7 +968,7 @@ static int max77693_led_probe(struct platform_device *pdev) ret = max77693_setup(led, &led_cfg); if (ret < 0) - return ret; + goto err_setup; mutex_init(&led->lock); @@ -1000,6 +1000,8 @@ static int max77693_led_probe(struct platform_device *pdev) else goto err_register_led1; } + of_node_put(sub_nodes[i]); + sub_nodes[i] = NULL; } return 0; @@ -1013,6 +1015,9 @@ static int max77693_led_probe(struct platform_device *pdev) err_register_led1: mutex_destroy(&led->lock); +err_setup: + for (i = FLED1; i <= FLED2; i++) + of_node_put(sub_nodes[i]); return ret; } From patchwork Fri Aug 16 15:31:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819871 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 454801BE84B for ; Fri, 16 Aug 2024 15:32:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822324; cv=none; b=D2FFrC+O9werw/ZvJdvSDHHtYEViAclOWiELpL++0sAUTT3qdGhIQoyHQcy5xSPXiODvJB7ub6kVAAXelefLFfU7N9YnahgQiDa2KFvY+jN7lrvaooJAdhZvr/uaw8l3pg6+yvcKfqwu1crXVgYeqOVUxHZq+1VoWfGovgoJrko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822324; c=relaxed/simple; bh=haphcDVabNY+m5Vrc9+jwTzdz2gW4B9j++QCcBv7uus=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sBZIJuYFebQBTV6WKvROKZShNq6HuwJKBJgkE9kiBXvcUoc/x9LUI/o4BDqceFCqHyXBJgieH7MF8rXHu1mIia+v8FN6uMyXOf3TZeDJC4opr/GJucvelFHHhy4dpalL2jVNv+mlvexAxDUDKdN4WYvolCkvHPdREx9o7uPslfc= 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=DDuPN+5R; arc=none smtp.client-ip=209.85.221.45 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="DDuPN+5R" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-367963ea053so1486226f8f.2 for ; Fri, 16 Aug 2024 08:32:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822320; x=1724427120; 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=JmSp/tI6/cAsvRbhfMHRpQD46ohRd+mOrBdZEg+M/0c=; b=DDuPN+5RUhLuKELNtFzqxEBL9OAmgy7IyE9eanUVDFCWRTuw/BWFzniyJOlEdMR+0u /jFYIGgqzIGQoGzPX/0RYbyEH2lL4pcM8eB8f1uoEtEVZ0MB2UBNCWHtYuH9HFfiu0me AXbP779P6I1A3gF333nvC8wGwDLwbIB9F8MA7uFPrZTzsgxd3HMYlL1vFBoZJDO1stP3 b8WqkUuq+Xg5p63c/2C2nG1e2sp85AlBrZAMKMwGGzbsTqSAYTqlZCfXVktcbbwiRPrc OM9H1gyInE8TqW1PfChABXeDppBE0Nhe7bgTGS9gIxHc2j7AClnSTbn0cm//kLDQ816S p+UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822320; x=1724427120; 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=JmSp/tI6/cAsvRbhfMHRpQD46ohRd+mOrBdZEg+M/0c=; b=U7wVzzhrtifV0CqJEy9rFD0nmRy/HzvQfLI8wHnNKb1fjSmqGDyAN4//A/blN01P94 MPxECZB+TqIwBDTQMpMr8rg9UbRb6s9C3ZAfaJmo7O8RkTgyxwH4P0zYy6X9wpjWYRwb OeVMOiy07K/umvMqZvJYhAKHWeyfgCuPXICGexb5xwYz9u4DzKO1TEYE4YYZ0KmrrPr0 yVM2Hz0BK4qFyhv2csbF05WDnHglD/pk9D2NP6UDRwOB4ldfCs9AHTaeWn92SFxbm425 1N5Z/KbW8wJXuahHsR1aGthUBple0asg6i+pYrSzmr2JqhyroyqLXeaQXBmsFujgl7fR 1c0w== X-Gm-Message-State: AOJu0Yymbt/T9YSXSm3Nzto4j+iI3It1YrZHGxFwgfSM1klqeozN4ZYt n/Q22dvFkEc7a7FRU+9Waon2G55OiCWYcdurDi3b0+cUc2zyh73lx+03nu6uNB0= X-Google-Smtp-Source: AGHT+IENvgflPrCRLHnfFtaGxKPmZxIFqASabhejGrvVmiQr8wKujrxn8UdnFq1rYdKsHedXwj+CoA== X-Received: by 2002:adf:a443:0:b0:368:7f8f:ca68 with SMTP id ffacd0b85a97d-3719464e70fmr2963005f8f.30.1723822320474; Fri, 16 Aug 2024 08:32:00 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.31.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:00 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:36 +0200 Subject: [PATCH 04/17] leds: max77693: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-4-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2297; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=haphcDVabNY+m5Vrc9+jwTzdz2gW4B9j++QCcBv7uus=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DcFsjEVoUNxcpg4fNpAtVDyd+JTLcgwo8Hw k/LlBeAdrSJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w3AAKCRDBN2bmhouD 17zkD/0b5uHnjnzjPvy7kRfLttY9Q5sWPLsfyEq6CLUzPTCBewXF8K27CAlQIluNVr9MosDCghO U7QGtLk8uSvJj9KQ02Yig2QWAcy/s5wRX+ONqPYRue6VOXglHUB0PaP/hurfyKbriRaOUyg3bm3 Ffad+VfZ46D5xsiEVre/lHkn2amNZE4K2cYDi73IjaGDH4+rdGn/xY4GWlBlA0sDiFaaZbq9mE9 1bHtk3cykDUdm2ykX4X+1ycApN5D9e0drHjadREgiSLjd8NQmMWPwb9yroUwjZSfEPsFZzXEiGH ESatJmodVxi+VpuKSU6tN+pn36jp7Uvo8oJLg2ciIqkhH7l/8f26PToam8oq0III9BmKa7K+WE2 SA2i561NmARvZKIb7ov2/YXtvUFPzgn/7ENHvP3gnz3QrvNmc6UPPaGIWeENQnPPlEqh9VDOciQ GtOI3WZtohFdCug3984yJMuJtGZ2lScEuevzxO0cF2t1KI8+qhrQ4yog1t0e/OS5HQT8Iz4fa8g XzXe3ZIxRQQ4cV9Dazp74uPSEkMMyN8EKzdftcVEuL48b9NbqZBencwcIcjhkt6pPpRXBMgLvu4 weZ7WS3MKriAVqcl2tPp4IjWatK/agobg3xKELYxOlZDdKiHQJc6uUI665Mi9MamHNKIXUMmcyo ejGSHUPPEivrccw== 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/leds/flash/leds-max77693.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/leds/flash/leds-max77693.c b/drivers/leds/flash/leds-max77693.c index 16b169e658de..90d78b3d22f8 100644 --- a/drivers/leds/flash/leds-max77693.c +++ b/drivers/leds/flash/leds-max77693.c @@ -599,7 +599,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, { struct device *dev = &led->pdev->dev; struct max77693_sub_led *sub_leds = led->sub_leds; - struct device_node *node = dev_of_node(dev), *child_node; + struct device_node *node = dev_of_node(dev); struct property *prop; u32 led_sources[2]; int i, ret, fled_id; @@ -608,7 +608,7 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, of_property_read_u32(node, "maxim,boost-mvout", &cfg->boost_vout); of_property_read_u32(node, "maxim,mvsys-min", &cfg->low_vsys); - for_each_available_child_of_node(node, child_node) { + for_each_available_child_of_node_scoped(node, child_node) { prop = of_find_property(child_node, "led-sources", NULL); if (prop) { const __be32 *srcs = NULL; @@ -622,7 +622,6 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, } else { dev_err(dev, "led-sources DT property missing\n"); - of_node_put(child_node); return -EINVAL; } @@ -638,14 +637,12 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, } else { dev_err(dev, "Wrong led-sources DT property value.\n"); - of_node_put(child_node); return -EINVAL; } if (sub_nodes[fled_id]) { dev_err(dev, "Conflicting \"led-sources\" DT properties\n"); - of_node_put(child_node); return -EINVAL; } @@ -681,10 +678,8 @@ static int max77693_led_parse_dt(struct max77693_led_device *led, if (++cfg->num_leds == 2 || (max77693_fled_used(led, FLED1) && - max77693_fled_used(led, FLED2))) { - of_node_put(child_node); + max77693_fled_used(led, FLED2))) break; - } } if (cfg->num_leds == 0) { From patchwork Fri Aug 16 15:31:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 820237 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.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 ED3001BF310 for ; Fri, 16 Aug 2024 15:32:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822325; cv=none; b=uVsagX3YYxzMBYvIzWqO1DdT8hkufTYyOqpBnthegmK7mwPbBfVBqUXxzEy99IzBxKPYxbpFWSJXpz8xcsyoZZvF31x57vY80VAx4CYe+D/MMVK7PxH+dJ+o1xZ3Q/zjmHhUzrn1SSKhI5SG7weL/BlTycDmb1l4ya5U19U/eYY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822325; c=relaxed/simple; bh=OVXsaLaHpAF5uH0owWFBXjKO4nS2BM2WznX7TKsIhSw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZcCcfu3YOyBjzEze3gS2k0GdyNNVabV3TZTEJmnYc48aU/RGcGYXqVxzogu243u0p3x7MiSaMQSRaLGzwZpioikDe8cQh111/uMSKxwMBISFJjyMqmhVvi/bXWpDrJhPNBzGvECW+KK+8jh9Q3di5Vjztyy9l9RuiFyDi5t+fFM= 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=lh1YLS8b; arc=none smtp.client-ip=209.85.167.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="lh1YLS8b" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-52efc60a6e6so3120419e87.1 for ; Fri, 16 Aug 2024 08:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822322; x=1724427122; 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=LbHR44bLM4FZ52+TjzVnIlbfMCn5qE1DnTHfiWLJ7c8=; b=lh1YLS8bjJKZJXIrtXwsmiZPpTP5u3UMZnex1ZCgckt+7MJ8jxolT8fsv6yP3sJBg/ cXTaIoycNrGbT1cgzcIJcQvsCf+j3fPjGP2Ods5haTWDiSwu75A47LvsJWXoS6YdINHe RrUI5OfN2tnrk+aAtOy9PTszzKZSXEeHZtmiZcG87qFGX1X9pnUlPrZ4tEO3Qur3rGeh 2GA1AGRgvQivnI+KvChqTIO/0/iZHs7IOjROFQVujbJTcl9HbE3d6UV2xHNFJf2wLOPz 5CWSBTf1dseQ1PMCjRXlHbpkeaAF+HmoWZoNMgQMjS2Ypi9j7W0RZZgkVLhV2TmYs6yG /a6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822322; x=1724427122; 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=LbHR44bLM4FZ52+TjzVnIlbfMCn5qE1DnTHfiWLJ7c8=; b=qMCduoEIGRd4RQ6G0R+9DzAIVaelNPbIK6uiwZABb+FMpKJMIKHbkoa6CiKwr+iYeU gWPXZWcDON1ClhE5voLILR7IpOuVwH3CizzUflAh1lv0KT2UYGFKxtGBfly+qVoqFsw9 7NVwnDYgITu0WLG4Q8DhUTZpCRFDAze6PRBa8R7FHzbVgSQajpQ671EK8Szp7NZP7OzI GtBbmbd2CjWDE191PK1zr9bBbj+7zT68wUb40lK3Yrd3IYmOZhedyIixtdmCsh04sccI PiX3+WVTxWSyDSomXQzjJLB6vd0QdGhpYQk5KbEvLKgrtdN4fjzkwryd7T1Y4UMPfKbu bXLg== X-Gm-Message-State: AOJu0YxfifAQ7nBgkqeHvpUdzdsEbzREeVPE3Vun6N7LldhfQgxBnkRX Zoedd8b6L6a5YumPpoqsvCH4V/PD/8++Bj5zHstRQP4nkk886FBWEWcWTtjEHco= X-Google-Smtp-Source: AGHT+IHxActLiG1YjVcFGYIn8S8tpL7GYn5YjKZvtEnowQwIDKLJw+P78NbSRNVlVr9yhYxdj5YjcA== X-Received: by 2002:a05:6512:3a8d:b0:533:966:72cb with SMTP id 2adb3069b0e04-5331c6e324bmr2378225e87.48.1723822321846; Fri, 16 Aug 2024 08:32:01 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:01 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:37 +0200 Subject: [PATCH 05/17] leds: 88pm860x: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-5-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1266; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=OVXsaLaHpAF5uH0owWFBXjKO4nS2BM2WznX7TKsIhSw=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DdGtKK9vF/Igsn3otgQXRhwFYgtdI8zMghG N6WWewQV0WJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w3QAKCRDBN2bmhouD 19gEEACXTE/Bt5Piq+7QmHZKIKxE1e5XsrbSqm+4ImFiwaVig9kbXgGQLSXRH5UEENiLqiPpXwb cGBK827MslxTx5lvc0eqR0xGw5V0SUzmr24svS0ymsfjoLQvv0gpM5IIT8/j9xELhWXIvzDq9Eq NxoLtGrjXoWOkh2UU6ivt+4pSlksA3XINGNsi/nJBBe+x05EcF0F/Xhkrp8eaz0B3eYuQ7y/xIM ijNujYDLau798JvaH9MxCHeJykRB6NgKBBae8AzwIQamvrRPgKQM+KwzMVvEGCOohOrgibC49Mh 231FWX5ZK/ciy22x3L13xDzYEAfAtuZLNAPGLovVhPGnAkeTBnJLHrPLa26Ab1+t1O8oYSL5SoB +Cu4/Hegu3x+oE4M/EugmWJlSuSXJCIYcPDXv37kaN6dNfUfCI2r6WR6yyOgpb3yGtIMdNrCZiv kNFB7MweAhEoln+tKaWZtathfLXF2PMhC6ikSGMWp17TLFwxy3nO5PARn/xkUj2OgHgjGy24ZVb OBobeUnbLjcKLj6LZcBbcKRadYhL5H1xYV9W3aGmCX/LIwvQGNrKQ2dNpaVgX+bPie592yDYuJP n2mb05+YBpkWuLztzlqcQAWqhRVggciLTuzTJZXz9fe1mGRy3B5l8npgdzp5ZHx7IvTCqjYKS7t QMf28Mjz4M4dbnA== 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/leds/leds-88pm860x.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/leds/leds-88pm860x.c b/drivers/leds/leds-88pm860x.c index 033ab5fed38a..81238376484b 100644 --- a/drivers/leds/leds-88pm860x.c +++ b/drivers/leds/leds-88pm860x.c @@ -115,7 +115,7 @@ static int pm860x_led_set(struct led_classdev *cdev, static int pm860x_led_dt_init(struct platform_device *pdev, struct pm860x_led *data) { - struct device_node *nproot, *np; + struct device_node *nproot; int iset = 0; if (!dev_of_node(pdev->dev.parent)) @@ -125,12 +125,11 @@ static int pm860x_led_dt_init(struct platform_device *pdev, dev_err(&pdev->dev, "failed to find leds node\n"); return -ENODEV; } - for_each_available_child_of_node(nproot, np) { + for_each_available_child_of_node_scoped(nproot, np) { if (of_node_name_eq(np, data->name)) { of_property_read_u32(np, "marvell,88pm860x-iset", &iset); data->iset = PM8606_LED_CURRENT(iset); - of_node_put(np); break; } } From patchwork Fri Aug 16 15:31:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819870 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 063DB1BF32E for ; Fri, 16 Aug 2024 15:32:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822326; cv=none; b=ry+pc+gNlEJ5vXjys/fIADmfvQ50RnXxUqhj5ex6MyMpvgcwpm8cnr/A/KddUrqOdY2Cx5Kt6SBTFlETJdqGDBMjIs4We5XNCqM5uIQBPYOXTqZYFkCQJSaxpYRmYF1tB9krMALmY6xp2/0U24R2099R1f1n0/wMtLRSZXAdAdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822326; c=relaxed/simple; bh=jPAa7n3fQCOZoqW7oKViIUd50z7rPIx9W0P9wLhVk9w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jofIGv/Jheey9Wsdf9IfVPnrfICnw4QlXTI23/qWL2d+kV76eIMojbiOpT+KKgn7ipwxnAqHiPKQ/Ll/3TgqAod5su0BuzUylQJCelTyWXqMB20bJ6e+QgYt0wMrxz2qIAkoQ4N3LtI3qf/Io2vDaxg6RSDYoKZDJcR+SJs8XAo= 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=PmLYQ6KG; arc=none smtp.client-ip=209.85.128.43 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="PmLYQ6KG" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-429c4a4c6a8so15715635e9.0 for ; Fri, 16 Aug 2024 08:32:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822323; x=1724427123; 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=SlPHB4gr+L6a3Oj22+1JrD6FFL140QqYHUkR8oZywNI=; b=PmLYQ6KGpyhT0koV6NCziEdI7PiEnSBgyYJ1PVSFVNEA4s+q65VuLBCPuSYU40+kwx mvJTFZPaZYK4CnNZRxh4sruMhqaoyOlTOJXu3a8wocZkdOAAwqUL6UvLyAsxweIQJwUO 7p6jH1AjteMvbh9n4jLAyqYvY/w/+fJyQ2PnF7jo2V9VMGZHgL2JRX/ss+XIsxxl21+I Y255GhnkGLdaJE2ZICRmvvm7s9tEebb92EnlqVFid1l3dngz/1uITlzGotRL/AUhmKr2 feNdyzjWpJ26n7ZJYERbFQurbHVweUzbngm6CFCh16LRMg843EyTEtZ1TbvosGh65m4A aKCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822323; x=1724427123; 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=SlPHB4gr+L6a3Oj22+1JrD6FFL140QqYHUkR8oZywNI=; b=hwUmj8qI4YJjBl8WyK93ZyB2Ju+1UWlqjLDDuduJIKfmz9pYK0fO7Qd4xFz5pAtr97 H/jBccH00RSiThqcb06o1xx7QVA4eyRKoiIj5+O0BY2e0g5ymnpjs9/h1tscxOEsxCEt FtT8n/T+pGOPBFoRb28QVpriGsUIO5o5hjSZsQn9u86PPuNT4x9FepKUj4y1CVBMnJVI oLT4YiTY3ezdcG6ROOA0Pc1tLUdA01mxydSflQm6/aam6fTasAwxXBQZordFlyhyYc9I AErBe/UjYNoDOJuM1ikJsWsugf8KYpBQ+MvF4z2jYQf6vVjT4VcxK6zeesiq9Egjm13y 9s7A== X-Gm-Message-State: AOJu0YyB1gpPgxtMRKQXVQXrCrbR8xXXOhW0ys48akYn0EkPve6bBlQI h+HoJPM6oOy7BI+mzAdXd2vJHjdjXlUyMjptA5+qfQViuJ17jhJOUqgCd6za4Ko= X-Google-Smtp-Source: AGHT+IFBqViSqYS/Qn+XxO+w4C7+CaQs7V1F2BGvW2XzllPgvjc7cAPVBUQf03iTq4tSEpEg3x4Iag== X-Received: by 2002:a05:600c:3589:b0:426:6388:d59f with SMTP id 5b1f17b1804b1-429ed7a6224mr21796435e9.1.1723822323342; Fri, 16 Aug 2024 08:32:03 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:02 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:38 +0200 Subject: [PATCH 06/17] leds: aw2013: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-6-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1390; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=jPAa7n3fQCOZoqW7oKViIUd50z7rPIx9W0P9wLhVk9w=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DerHRigkFM7NozDs05CzB4VVyXWnkCs7tkx sIk5q1y1CuJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w3gAKCRDBN2bmhouD 18ZrD/97YWODT5Z5+DTebBI3wZE+0JSm6MgT/9fQqSV/jAaNDxPDxtcrU9f1tlmGpI9FQ3ztA1w 5kIZXiEWrzUgc01OD/J1u+jXMzVC1rntgQmcCz3eR3mo7vdPoClcn8T4O64bLR388bwI+a/olF8 ujcI81Zj77ajVSpsdceGMgG+REsRgUhZioX3In0qTtBtjFsadb/4L8RWNBVOt0AO5upLV8A/3gn JF6ZkJUcMAY0Qi0Da3wK33LBIxv2tlml2WyLQR7yfSeNJ+dBKo3cAPBXVC/GV/put6MdXTZbbOG ntf71ez6jrXpLB9FsKzXgKCZzAXfFyaj7c6KDKJZ0qdComtXvSZ9+mSp1BaMRlT4eBSVFgM3cZR aKo+cuCf9Ncg2VJFtXFtMzUFZexM9DjBvAC1DEpVp+NIeqZRM3mp7qsMfRUG9nTl2RVE3i62Yer peM1zsF7ZPtFOxd4B+nLZz4t6+pY9/fwPN8b5qz6rLrUQw6zir30lR/BIxNcgMmuFUK2hhjIedu zkFHEl6XDKHT1SYYpTDgvlWsGjQll18W4iojiDomjGXNaDHA6idfH18a2C2nDQ0S6Grm5I/A4RB 9B5KZAgZi4zpiIw7aIsDRpYPQKDdovhX36Zqllgl60VZ5jN4ls0x1PBS4nHla9fOA5RQvPNMBvL PMAHdiIqEHJcgMA== 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/leds/leds-aw2013.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-aw2013.c b/drivers/leds/leds-aw2013.c index 6475eadcb0df..216755d6010f 100644 --- a/drivers/leds/leds-aw2013.c +++ b/drivers/leds/leds-aw2013.c @@ -263,7 +263,7 @@ static int aw2013_blink_set(struct led_classdev *cdev, static int aw2013_probe_dt(struct aw2013 *chip) { - struct device_node *np = dev_of_node(&chip->client->dev), *child; + struct device_node *np = dev_of_node(&chip->client->dev); int count, ret = 0, i = 0; struct aw2013_led *led; @@ -273,7 +273,7 @@ static int aw2013_probe_dt(struct aw2013 *chip) regmap_write(chip->regmap, AW2013_RSTR, AW2013_RSTR_RESET); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { struct led_init_data init_data = {}; u32 source; u32 imax; @@ -304,10 +304,8 @@ static int aw2013_probe_dt(struct aw2013 *chip) ret = devm_led_classdev_register_ext(&chip->client->dev, &led->cdev, &init_data); - if (ret < 0) { - of_node_put(child); + if (ret < 0) return ret; - } i++; } From patchwork Fri Aug 16 15:31:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 820236 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 B02B31C0DD3 for ; Fri, 16 Aug 2024 15:32:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822328; cv=none; b=mJpEDWxHpmHnoBwNrkosy8QFWuaL8JUyAzrc+WvKXL7B+2gzrNZXBV56oU18U9i2Fd9jJ4RuRFSJWmqkHTmLZ3a1JGEwEzNgdQYJ/VtaVDdo4kW1LfBdLnosvehXCwsFC95SUjGLTG9oZnM0Yu6/F9ATkOn+OCj+tqNjsB4lB0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822328; c=relaxed/simple; bh=m6Hk8gKMX1w5RtMdLACIAQ5rXDRi8vsYTQoqOdYtge4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u226M82cuSSrG7Bcz91yCjKOi3SGGf4sZMsttjnFqdy2ZHIGEu3cGH6FmeV0d7SAU7PFhsnAXFJG6nQyFFvUFWkKwwXs1/z1JzT996D8H2ThmlcdHdUgltYKfl7pE6CaOEKFXTt2bZvX5/3Hor5ARheYJu4T8r0Az4QFOYyQ3dI= 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=gOQe+Ndo; arc=none smtp.client-ip=209.85.128.52 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="gOQe+Ndo" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-429e29933aaso14822095e9.0 for ; Fri, 16 Aug 2024 08:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822325; x=1724427125; 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=IpSzvs+nYkevHrGD0uZRXPPuCA8pLPFmiuPfAoAZn4g=; b=gOQe+NdoAdEiA8JJG/EuPXAkfi5v4CNVJ7lzNk7Cidi/RNgHC2tKrZ98wJsRdZoONa j6sdTNIjk1AATL9VAJnt+oO90HIMj+7002jAnD675vQUtSJ1UEbEWVPBlUxWUWCo80f4 erTlIOZgSBYOVC3VVcKkUNGKCoMyULx6an+UDf5d75iW7TY5CHxMdjU2fCErMTuhj2Fl 3cBnJiKD0qR1N/CFr9Fi8r5KDxthBx1+jyflXTOCw8ka6BNRLyIU2SUse7T478EXhZdx RlwQ2dRhEpsGHQhwO44UBwP6ncFmOLXbyAWJvqyw5qSNmD9+eY3m1VsK+Jyp7SN/UG5T quQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822325; x=1724427125; 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=IpSzvs+nYkevHrGD0uZRXPPuCA8pLPFmiuPfAoAZn4g=; b=dqHTrmMmqysSEJsM3fUQDMHcmLf9oJrqtvx2LhXu81/rVkWk8FbxCajn7LlHE2flly 7XRGeBKtGmPRTbEiYW/BFSkrfQw6r73qMDCh2u9SFXXWhLzgAGrLPacFPhb/h7lf1NiF cUM4utPCEr3DcwwNL2gNb8jVxqfjhSQqjTOQRw2KXv5OsckLoq+9xyTrl4WEMw9ykpev 2d3AoHlrM4C1hdUnv9XyImgpiwJ+FhE0iCNHw9Ih215/qBfLWYTEnV+3hW7LoFsWQmJ8 WZ41cADC1f3ItNoR7g2f8J9EYEGlKfUmug8e5H9azkF7pIVo+rjhklD21xLiP400Pm+q mwbQ== X-Gm-Message-State: AOJu0YxTWwAE/j15fN6WcTwHVuQDq01BJrvir6RfJusESgqcTg5LLnvs 9mVML9IoiOUSyg6Yk3WGc16SQeyQpdjGkvt3Jj5NJf5fKYmquxwUiHSKSuAvuoc= X-Google-Smtp-Source: AGHT+IFIM8SM/oUAoIoij6/+F29yCUYD7CkGrKL1zCzaVxOUpWq9yef5gSYP4cevO1RzYy6a3+hjag== X-Received: by 2002:a05:600c:3143:b0:426:51ce:bb14 with SMTP id 5b1f17b1804b1-429ed7e43femr20311845e9.30.1723822324872; Fri, 16 Aug 2024 08:32:04 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:04 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:39 +0200 Subject: [PATCH 07/17] leds: bcm6328: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-7-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1378; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=m6Hk8gKMX1w5RtMdLACIAQ5rXDRi8vsYTQoqOdYtge4=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Dfttu0MwP3EZEIzlwWVIzETU/wM+a6ZdT+U j6PqUtmWHWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w3wAKCRDBN2bmhouD 147yD/9gLAyT7CaUKu376rhokAa5nBq87hnVOfCdhHEcAQUegVx3PHvtzhd1qXPs+duPUC0yuV7 Do3NvZOVUcUJRIHkBt/UXC6hUR1sJBk6WXUjJOkMj46EOuhLuwpwzLoQt/oVR4u2EO5i1FPOoTG D0Dl3i1+iWU8Fp6BAqYuZhd+e0lDEfaAkO9dSIEli4r45FXW2ljOBOky5fHTOUzPo4GoPRatKCN OrSd7SNZQ+CiOMREI6sEwJ2HVPu3xmcMAXas9HoDQKcVDdf7zHek0y+kxMU3cRX3tg0ApwR6kcL xJqDIBG2fUDG1RyLrMwaSe5nd6+NjEfzjRUQz/BuVkLV7WLafu1R23us2RtQlVzaQfzrnKou4hC 6jGSuH5a2I9OqFbVh2AwwM79Mfl8xHFEqwPrn0OaC2kKNOLrYTatVf199VGOzrcLbB218zt9LwR BRVxtpUk4zm56QgpLS6AW9O0DRGBFsSptO1UFHbsMQK170y6mJaNERN8RnkRLnN14EPw+y/acbL VQ5Ok6Ek8WU/LdX4ct0HkFJfcfaV72fBxQ2HSJpQoV+cXp2AKyaznPx9WMLwOfgT1NkS3j+Oo9M 5CTDWkCmklwcwRPvtNc5/dwJlXbY2Z/WdKS0zlQ6LOniVJx+yMLFFPzOL8+9HuAg+8jbU9MByx/ 5SnE2hJywDwR/8g== 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/leds/leds-bcm6328.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c index 246f1296ab09..29f5bad61796 100644 --- a/drivers/leds/leds-bcm6328.c +++ b/drivers/leds/leds-bcm6328.c @@ -392,7 +392,6 @@ static int bcm6328_leds_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev_of_node(&pdev->dev); - struct device_node *child; void __iomem *mem; spinlock_t *lock; /* memory lock */ unsigned long val, *blink_leds, *blink_delay; @@ -435,7 +434,7 @@ static int bcm6328_leds_probe(struct platform_device *pdev) val |= BCM6328_SERIAL_LED_SHIFT_DIR; bcm6328_led_write(mem + BCM6328_REG_INIT, val); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { int rc; u32 reg; @@ -454,10 +453,8 @@ static int bcm6328_leds_probe(struct platform_device *pdev) rc = bcm6328_led(dev, child, reg, mem, lock, blink_leds, blink_delay); - if (rc < 0) { - of_node_put(child); + if (rc < 0) return rc; - } } return 0; From patchwork Fri Aug 16 15:31:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819869 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.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 DF7001C0DF2 for ; Fri, 16 Aug 2024 15:32:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822329; cv=none; b=tbRZASl/iDFPrHImGriH4zci6FNhFNIO+OtenoKYdvcYQVza+eoV/cZcnVdqEfo1CXu0vnQTwPJlfKSrHiJ+rKCiU27Inibu6ToVMmz/kpa5ygfbHDXQY/AFtA9Wzb/S/mRmNqfPiCMusUL3SvF5k+fdw/582BozhEaEst5ggFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822329; c=relaxed/simple; bh=gN/N7MTnfesRcU0ZUz+5FDMsGWVo2Qy6wwU3HvO2nBU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kj35QFp4Ykt7C+efnwSM10ee/6MVHfJibn2LYDhai6NhK6GqO7STYiuYBUv7RXFTz5S9YjPprAvQ2IFIoZbN0VJdRHKIJQ6+kq2UraHb9Ssk9cd310TpXrTz01iah/otI8y5CZvUR5LMivepnn4Rx25vFZb6EVzbbjpYlJhu59c= 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=a14Z0ROV; arc=none smtp.client-ip=209.85.221.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="a14Z0ROV" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-368440b073bso1164014f8f.0 for ; Fri, 16 Aug 2024 08:32:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822326; x=1724427126; 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=bO9KX3t0CameG4s7E8ol/+1HoTbso6o0yUSmdA3MC9U=; b=a14Z0ROVNTMFCtz5/KnYCCTsImukXJxImZhQ8+le03PpQDDYnPZV89UF7255DPpjul iT+7f5QPf5kF4CaaN4P8cuyoiBHq7DXF36NjVlqQWcOrCYbIos5VTgZtQl7QEdE47XAS gtCldn/5renLmjVmulJmmfp2Hj6Xh7B4XCUC2xIaQHIcOXGm4w/QTyUhp+0IvUwkKqR+ 4DR1LLW1bP2OcO/oCNgJDTNEbrzzfnNzMnt3IeS+bHdCr5b3uzTZFI/rKVVs3+uP6qv6 C5+Hnzv4VHCQ0ADuvPOIifZLVBdE+PfRai6GrDH7DAE7q5LHxEwvew+lPukrkAcg4EX9 QE4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822326; x=1724427126; 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=bO9KX3t0CameG4s7E8ol/+1HoTbso6o0yUSmdA3MC9U=; b=ZGSlmsS4MzQxQcKnWT/QFMv08hGx03dF5crnOxigUXD9w3if+LUOulwZhi0sLq8nX5 d0q2chiTNJKO6V1OA88h5iIKqW/8Dx0VDyij0m1gD/u9kWI/nsEYMEd6kynNgsvSq8me oAmXxYzN/zx53J/+tf4o3f7qSjXotELBJbzNMcxMVUKTfP5QyWomZVNWNiXBhbJBjSV9 kJPt7JqS0kyybfIrm+TvNym64cCxXrvxoxgvIxuY9I4+Z20M0OsSYJf1QX5Bed+MAFoA hSiUTBV3yxgu7LCBbvKPyexAxbsjDbrfgEIXDAkOK22jz7Z0BPDdbrD8QjP5NalP9Dte p8wg== X-Gm-Message-State: AOJu0YzUenC3NaHKDcmrjjY4+mPBaky0oCBHsQZsFexcjIiaRpkMb7lQ 5elkc7zmrVmga+89cV6iBi1jhdUr7hOn6Kf5YjuwJLYBqniTUsdiGoTeD8qsjdo= X-Google-Smtp-Source: AGHT+IFO6DlpkZlrb7PQDXCCkwkdt1PkYJMksByyV9gy/3kYvIXYmOf5Fd1cqFTrDNfriARDeJMtyA== X-Received: by 2002:adf:e6c3:0:b0:365:aec0:e191 with SMTP id ffacd0b85a97d-37186d740a7mr5074245f8f.21.1723822326272; Fri, 16 Aug 2024 08:32:06 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:05 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:40 +0200 Subject: [PATCH 08/17] leds: bcm6358: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-8-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1287; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=gN/N7MTnfesRcU0ZUz+5FDMsGWVo2Qy6wwU3HvO2nBU=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DfPgJIiHDC3hZ2bkc5m7qeMomLAN1W2uZDq zxZ4A5tqh6JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w3wAKCRDBN2bmhouD 18UJD/9O2BpM8SXiXEcgj51PM7x8myw6JvKSH40bF5oY9mhYIhkrZpWkbw+Q/7QL7B2EcIXbGwo LrmxiMbQvg87Z7lN78d8yf0GJr2ja+HX25WLRTCfL9lAoXbHMGotJD66V3I3D4I/NRdUbQTDzMa GHxvligWU2jeLN1qjSSE4Z5ZXQcFGaQ22RBOgL5IhzzmHNjVyaQ0I7YMKWJ5UcwIh88EXJikd90 9Mj5JYSJO5GCunLxqgi5x20aMYuVoCPdhfrhykPvY1/WrKKcA/qfmrjY5VrzSJv06q4CRJ0xQqD MMTkyJKgY4S7pwZuJA3SsLEgggw4C2Mcdut6XkUdyiYwmWIk5T9sd2U6qVhDGyzw3GoTtyfvkdh 3bv18L9qH84cqiM2E9uvA5HGw0+tNVVqcfAaA73pn3TugUj2UBQw0ZACpoNU61mgPROTd9zjE8g 2ljGiXGegvDG5Lc3FdUQ8NMq27W6vFFcZ7fqUFh9ifzKYDwuU20YsvxySGmH2DbOdhc/wTDNhdD ErXZc8VIuCFnfQrbciDcVUluC73s8YaaAMVICIhZNMluBx0SGWut77qF8+CCA/yBy86CXrd1Be1 mbGNuNEztzvTIQQeX55KCYhBtgdSnordy28kcn6S2dP5p29AGcaoNW3aG83jOWEDjwSyBfuAJ6b aRt8rutA2xi1+dw== 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/leds/leds-bcm6358.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c index 86e51d44a5a7..51fcff2a64fd 100644 --- a/drivers/leds/leds-bcm6358.c +++ b/drivers/leds/leds-bcm6358.c @@ -147,7 +147,6 @@ static int bcm6358_leds_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev_of_node(&pdev->dev); - struct device_node *child; void __iomem *mem; spinlock_t *lock; /* memory lock */ unsigned long val; @@ -184,7 +183,7 @@ static int bcm6358_leds_probe(struct platform_device *pdev) } bcm6358_led_write(mem + BCM6358_REG_CTRL, val); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { int rc; u32 reg; @@ -198,10 +197,8 @@ static int bcm6358_leds_probe(struct platform_device *pdev) } rc = bcm6358_led(dev, child, reg, mem, lock); - if (rc < 0) { - of_node_put(child); + if (rc < 0) return rc; - } } return 0; From patchwork Fri Aug 16 15:31:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 820235 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 4CCE11C2312 for ; Fri, 16 Aug 2024 15:32:09 +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=1723822331; cv=none; b=Ut4+/ziwZBOY3Cg+NYNlmAoUo74liOJqg1lA/9sb+5nCzmkQrhYp6wT582hQTarJNXU9VbMnaIEha9JWBIWDRxPX2BKojSN1HYNWpedZ7QKqgPF1CfQCaddJxt7FsXjjhmyuMH5Fc6GHKj0y2Hyvust1N+UI7dzgikQzPfgv2VU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822331; c=relaxed/simple; bh=+81/quQFHALMpUB6fQmVb6mYEiHO0lEYq5t7UhRRMzs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Pss5vN8hSsrjNoLqlHiczsxFeV0g8YXHHgAZgWAcFI25DvHVWroNN+zJnhPO4Wvptu29CvRqI8xGpQ1orHfAJsuD6magCdalK6e+uy01qCNE/x3azPQypXEwHJllJubjV4cX+M4LkB+tpKRBRGSG/W4LhbBMIPEIwp77jb4RRDY= 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=Mk4VUMnu; 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="Mk4VUMnu" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-371941bbfb0so573790f8f.0 for ; Fri, 16 Aug 2024 08:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822328; x=1724427128; 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=LGaV2RDOc8MAwrZD+PEbChQMiUdw7FasLLrpXnw03mg=; b=Mk4VUMnu+OJVGrawouDVin58SeQT6PbCEp4RNNDcp4CUBHymeM+PmpMMAGU0KRqxvp ys9e5FZY1aI3o2WmENTAtCkPrJXHpc14ljMv8+gNAlB7JrnY24fQwpzVvTUXqnKbNSN8 JNgFl7nCUvA6rgiXtWAkgTVX1XiPHc1xSDLO/sc9cR0D8uKfLQ/D1+8jCXd0gDJV/2n4 12LvLOLYebJs4aCQG+/zQLXdzueaOw3R2drEh3g28o7rHR/r8CL5/cUDes1EkJ3LjOPL Bk32YDgx+aOA0MEpXCyGJgZKoVYxx16co+mT3uwKybE4fImZyek0IPyct/9EACMtMCa7 ffOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822328; x=1724427128; 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=LGaV2RDOc8MAwrZD+PEbChQMiUdw7FasLLrpXnw03mg=; b=mm0LSIPx9o7HTW+gFmXxjrjuiPeETN9ST5NX4lfwPjwEVdEtoXTKV+jqyLDXNKExiR OJYtE4P57TX4z1UQKKkPMBgWm2xmF7le8TvGGeMpqFNlejq9zlSDeXxxh1IN1ThQErk5 IXlqjH8Rlgb1Q/pfpei9XX37qv7XJEzq24UJCdIMhAADM8YNb9bJCVjBMqEUnHUe3c36 lSoOIwh258twx/w614gY5GEBxyvLnoQvjMD53hw+mtLTquQRi0zB80GPh2+43cZBRPDe FSNjuHFPPtaoLfrHL0aUkZuwb0FVxcQr6lNPLTybxECM+53jiD44j39LU1yaXNVih7L6 3MrA== X-Gm-Message-State: AOJu0Yz3EAwxgKxSGFaK293lLXzOubyAmYjp37YOBXh6u266IGrDvsYB K3YDvscQHXAqK7Jfkqr4Eudj9cJA2ku6CAkgzqx2UZpD63aThO+4InRH5Wp9sw8= X-Google-Smtp-Source: AGHT+IFfmPaV7HvNPh3uTKrf3gPU3+DlTc+If8+6DTZ+FnUuks5SQ2r0R/qNXIMR4vvm/S2Vv5bzyQ== X-Received: by 2002:a5d:4e4e:0:b0:360:7887:31ae with SMTP id ffacd0b85a97d-3719468d263mr2762190f8f.54.1723822327656; Fri, 16 Aug 2024 08:32:07 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:07 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:41 +0200 Subject: [PATCH 09/17] leds: is31fl32xx: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-9-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1925; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=+81/quQFHALMpUB6fQmVb6mYEiHO0lEYq5t7UhRRMzs=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DgYLr3gj7531lmAyEQypWWevzG4gT7CE04J K7wVw1+wd2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w4AAKCRDBN2bmhouD 18xTEACSro+sjGBUtLTGgjVaSxyV60PtwZwyOAK7Fqq5RH1ZZVgzESSlUU4qdgNYZeDkODJl+XV q7Orhu0Ajk5cK5db9fLOIQJkaXRvUU47dRau+PErZEtCvDdRmpFkxBMmw8KR0l/Vnv4RYUZV3Jm P0cQEcKCg9YRbojaWpMU+quoyK5LaLGG+Cx0tPZeSuUJpJTOGFZ1J45hL6greDe5n2VKdBukx6a aZWqSnZrvVfGnwiUx5a2CGDix7osxzq7lmbmutLc6T/AY65rW3hg5oCT1O7jYY3uuXD0Laf42eC BBTlIhd6KtnfY2oto8IDnEA2vKT8PjFD/nN7rSdU41LNMMDMDYz7erZQsvRjYvSqguihznoR5/B Bv+QTFItKK/xXo1rDiigsO8nYwzjLJLRt6HRkQJYq+Vjpoalu2pdQst+Ag3PG0PL2UBBR5jGGgm T8gf3mtGBE39cfCl/Mzx0EtK+q1COmuvOZzQdjByTdCoDc81E41quD4JvGt4IjHKJttzblIkOuw wD1jYqT4VIgAxshxIwIGVhY7xHvx7CIPQjOmj499jKFh4+alZP/cTnAnUfiDZ4m/3sKulB8kiqF 9NGVGnke+Ui9f3fbfrhIjExOqOW7HcXHD7w+LwnJSHkvbiclraXKpDezFEiTmuvKQ2slyYcVW1r zTb+hCEeRcSiRkA== 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/leds/leds-is31fl32xx.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/leds/leds-is31fl32xx.c b/drivers/leds/leds-is31fl32xx.c index b0a0be77bb33..8793330dd414 100644 --- a/drivers/leds/leds-is31fl32xx.c +++ b/drivers/leds/leds-is31fl32xx.c @@ -363,10 +363,9 @@ static struct is31fl32xx_led_data *is31fl32xx_find_led_data( static int is31fl32xx_parse_dt(struct device *dev, struct is31fl32xx_priv *priv) { - struct device_node *child; int ret = 0; - for_each_available_child_of_node(dev_of_node(dev), child) { + for_each_available_child_of_node_scoped(dev_of_node(dev), child) { struct led_init_data init_data = {}; struct is31fl32xx_led_data *led_data = &priv->leds[priv->num_leds]; @@ -376,7 +375,7 @@ static int is31fl32xx_parse_dt(struct device *dev, ret = is31fl32xx_parse_child_dt(dev, child, led_data); if (ret) - goto err; + return ret; /* Detect if channel is already in use by another child */ other_led_data = is31fl32xx_find_led_data(priv, @@ -385,8 +384,7 @@ static int is31fl32xx_parse_dt(struct device *dev, dev_err(dev, "Node %pOF 'reg' conflicts with another LED\n", child); - ret = -EINVAL; - goto err; + return -EINVAL; } init_data.fwnode = of_fwnode_handle(child); @@ -396,17 +394,13 @@ static int is31fl32xx_parse_dt(struct device *dev, if (ret) { dev_err(dev, "Failed to register LED for %pOF: %d\n", child, ret); - goto err; + return ret; } priv->num_leds++; } return 0; - -err: - of_node_put(child); - return ret; } static const struct of_device_id of_is31fl32xx_match[] = { From patchwork Fri Aug 16 15:31:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819868 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (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 EEA8E1BDAA0 for ; Fri, 16 Aug 2024 15:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822332; cv=none; b=L2GdPSncC660VEeFNyV8V7gIYIlxL1YJIDWlNGNdY8uHDoLazF7Mi2gFCC6sbf1r5eDsC7NoZKWduhol4pIXM/20qgs9wT4yH8zr3WJjU7EhMKmPnaDy340bDjoCSiOImvDSWrIEQX6xk5t94TwDPdnrqR/fDf1ZZO0+aynG+cA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822332; c=relaxed/simple; bh=pmrGUTEyc4+OdSgnYm2SLaaXl8kY77CCNdxnjrRu1fY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=grpqs44Hjk2qNAa9TCwt3MieDo8FXEa1o9iaE34salOC/GzMtPdJ+fcjif/3fwHx39FZcp6EONx6i71ew2QLudJpcLu5jRaqWnDsMh2JSvWHneGvyFmoKD7zgBxEZG3Xl21ymSHxtYh8EAZMqWRRRb0AgiX4mz0gcutLwlrpUcY= 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=F0U6SocS; arc=none smtp.client-ip=209.85.221.52 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="F0U6SocS" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-3717ff2358eso1125738f8f.1 for ; Fri, 16 Aug 2024 08:32:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822329; x=1724427129; 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=fUGzP1t9Gta8AcQElPeRx7Ldl4ob+d0gDQH5kp4CXpA=; b=F0U6SocS/GRTd4IW0FVII1Ce/EFQ914e2FkgRncYAWnifKw/G+ZXRSsIKYBkGGE5xS gLVEi53ChflLlLNgZhUpH8mbywDpzWfWGPnqxdo8YOCQUECIokDGQnvGglwK6PdHFY5c UZHvKyH0zt9RhbVk+tgxgErKGhQX3PHWcDi5yd3+QbCRwKcU/GB+ww0EswtBEjFxq5+K 1eIbaOzFiIXdbJ16p0LB0bXm7sA1+c4gVjjado2OrpvcG6yEakSHy9JHRH3tE6WUc2ip 9IIbNQS3b8QeIev7IkjIx1D7d14sjs3uyO1JYO+5BxWV5DECGuuN4hp/KqyC5/F1oD4d I9AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822329; x=1724427129; 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=fUGzP1t9Gta8AcQElPeRx7Ldl4ob+d0gDQH5kp4CXpA=; b=oc4xmeZbFdEcj+bn2lYYL9DHLMLxGNyisrLBKFPJpKFzBy7cuT1MW1U8RpSS8CvKpn lH5ddO5dNxnrJ8jR4yYikhpyPmQtPt1KXLZz878TfeSMeVIh0bkWdIy4r4GDZdD8Gkc+ LukYN5wU83WbJV/py3xM24UJiE79+HxC1bM6cTEZ0p0Emq5UUBPG53EefRKxnvk8oyzd 3QZlxQCOZVSKOyl9bqJqv2/0ft4S2OFrJCSylPAzsbDN3bjeigNIqljTtUQJigqPcUJ9 5osdxMpxrjwNyzYhtR6xoECGq3O8M/6B1xjPmcREYs0my7asXavtkElenOMJ7WIGAR0F 1YYg== X-Gm-Message-State: AOJu0YzdFMTaHzpVi8zp/EPCRdM/pT7/2VZCzDVqyLsXwBJXpPp7GUSO oCJVs25u/ItT6GgqEMiRoNy5//B7t0WMAZPDlAz//gUdLge1VenChy4hVhvlR8U= X-Google-Smtp-Source: AGHT+IGhEOtCAhmiEJzyM6rHhtwOV8c0tEKSFIqBbM2oY0Emu/CY0p4z+M30teYyAFMwJF8/lsh8kw== X-Received: by 2002:adf:e907:0:b0:371:8f32:557e with SMTP id ffacd0b85a97d-371946a48bemr1879100f8f.39.1723822329270; Fri, 16 Aug 2024 08:32:09 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:08 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:42 +0200 Subject: [PATCH 10/17] leds: lp55xx: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-10-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1023; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=pmrGUTEyc4+OdSgnYm2SLaaXl8kY77CCNdxnjrRu1fY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DhRHjXK+VVZ1wGfuTNvr54zgIfsr6GoeBrH 1NeN/M93z2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w4QAKCRDBN2bmhouD 1/ByD/9j6wZL4arhQNjD+UFfZLKCUSB+07X+VLcSzVuP8NTqtzt9JdzpwATyKwe+8mx4uaDZxsb GyCQxZBMeiJ5WyJ0GIhCw2HIc3aA9GoNieEjdRCZvaDvuh22wl5qUf5h9TBXcWlOP8nuX12gTbW VO79LyvYiS6Wcwfr38fhMxmCImw6vRxdBXOPdyJkqaeR7LptXb1w+5/c1xXHnd2D3xDHZhLahod QGtHiwJrNTQSZxwK8V3o4Sp+GG7KRxXMfXxsXxC/0LP6LMxe8NvryP+/ILF99EkLvjFEb7cAI1o 2Yy/dUh36Wnt2bPgvIFZjQDGPLcRSNGjvfe1XaIHeoq3dNte0b+umeva9edjpAGZw3IgKOe6R3D CEzVN2rDv/DbS8biy9Ru226n+ymrguhAn12JQSErEnQ/Suw9+3NnXjhNUtl2KeSXWhMTeKaVcl5 bJ0cDPBAehRG+k+e3ERjKnM5USAn9Jfgv7mRXpjdRCKcFBvNQ/0lnEA0e93da9h/mbXGfCAsJHe rxMoQ3aGihwQ7gGOAce92nHK4uyVHPuOj3UPq1ZoAnPjup8U8p3xLhNBj0Rdhw6TnwiyHdfqluv aivLqNn/0d44N/vgtlMX69I0VOhGgC28XeI05p99ukmU8CUtzwlQUZKApdcBL3wVj3h63Y5NejQ 9gCn501ogVJCjxA== 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/leds/leds-lp55xx-common.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 29e7142dca72..d493b31c215a 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -1173,16 +1173,13 @@ static int lp55xx_parse_multi_led(struct device_node *np, struct lp55xx_led_config *cfg, int child_number) { - struct device_node *child; int num_colors = 0, ret; - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { ret = lp55xx_parse_multi_led_child(child, cfg, child_number, num_colors); - if (ret) { - of_node_put(child); + if (ret) return ret; - } num_colors++; } From patchwork Fri Aug 16 15:31:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 820234 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 6E9281C379D for ; Fri, 16 Aug 2024 15:32:12 +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=1723822334; cv=none; b=jHF7mtzpixZ3Q6CEtKhsMJeC5+Gi/Q5A2XmFafxZm3WF798nr3+KIR30brt0pxoUdoBWDVcWCW3nrAQnU8pegmNSRcJ2J9FNlQF0jtFRa5fI0gxe4zuucRZ0Dbsg638vJYEHSZEIhSRFru/e3VVX/gtwc2Lpj7luF/QkeWDPUzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822334; c=relaxed/simple; bh=lKaguPS9XCpAsm5c5uDkmtZO7d+eB+Wkab1pNRXTP9U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VfyYB0M3pp1vR9DxIBZH9+rgAAOiRJVLRojlArr3/V9Ju7qCzlEabOookDy9qIGH6+sfy2CKIRAaRfuqDtIAtkFkRJpVYT11frY7IRiV9Ma12sVjNld73i/PaWymLRZlJAaGJgzMjAP4EkcvL+Js4TrqFD/lTYIV3YHnOIZzgXk= 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=cssStGTM; 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="cssStGTM" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-42808071810so15443865e9.1 for ; Fri, 16 Aug 2024 08:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822331; x=1724427131; 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=ExS3Adk0ysbxVxPe6mSqv52zzn6f2EvdipX95Ynjg4g=; b=cssStGTMRpZAFnXSUzg2HJwc3Q+Q8CbIZyNKVxBku0/BRRVDdEp7hkzIeDL4i/xzsU cxiTf+u4kK9ds13ivqEQf89eCoihJSS4Gic6NEtDCMHH5USw96gmcjSmf/eJs3L9AW1W eg2VUdEcTc/wGotWhoAdOFA3nAGYqTxVfeFpEprg77/e/uUX1BqdvP5MyIwNqkteI4Ev Dgu/4DKRnRiNrdMVhHE4j7QSAoLiiQeyuUUIEw4vYW1RrgFaXuZ6SQ5uZxEOKQXTIdM4 4clym8EBjBxoHOr1xI3rnU57lAOnNa5+HUdehzRBrq0zczfEt2gg3UzbeaCDp4bPwC4i X6qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822331; x=1724427131; 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=ExS3Adk0ysbxVxPe6mSqv52zzn6f2EvdipX95Ynjg4g=; b=TSSkJ1Co7jWDdL+M0fx3aFpscHk/m6yrb2UqPGkjVkWeEviD3CRMKnA2QsvJzeoF3j kJUnS42qOlMFvKqb0aqMg7QWPyJWusddILfA1r+R9UQphBbH4xCqLeq/05i08C48fhKY tM+duYzDZEYhD5uL1b51rhfb3c5tWB8yAJsYiTiEVkEU0a1AvTg7nb9LuMqoQBGpPp5s EDUKoIq4xmJ+DT5a9dB8gUJKyVbZ9g0Hb/BkkFXsjflamv4ulEUSCpGrFfXsMG7wegAR xCYkf4YLFl/voqMfJE0fLN2SQcvHScI7iQL6iJelqerBHvBpN7ph/CfX0o4StxyVjUuA aRTg== X-Gm-Message-State: AOJu0YyWF6HnSKAcTi8biNxzHjfy0459pPPFKklBYblhsdj/0dgeDP9L 5sme7IPPgvwuO4l03/BZCQO2AcPPwb9NZD4yEb0h2D4c97JCiD1A7cBDBq29g1Q= X-Google-Smtp-Source: AGHT+IGY3LRWMur+RIX2EsOyWFfYB56XC96QTNt2jgmYdeU0Jid4hrYTxjzYfgcQsMTsb6CsL+XrrA== X-Received: by 2002:a05:600c:358b:b0:426:68f2:4d7b with SMTP id 5b1f17b1804b1-429ed78562fmr22527545e9.3.1723822330645; Fri, 16 Aug 2024 08:32:10 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:10 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:43 +0200 Subject: [PATCH 11/17] leds: mc13783: Use scoped device node handling to simplify error paths Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-11-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2357; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=lKaguPS9XCpAsm5c5uDkmtZO7d+eB+Wkab1pNRXTP9U=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Di/6NaLLFot+D5dfegT8i/v6A5joRiEW89N jDAhq5CjM2JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w4gAKCRDBN2bmhouD 1+8tEACVczd8uQcgqQnn1chR1D9ZHwx5vpecvoE+zaIxLcF5I+90rwhxxDn8jJIGBDIEB4D9lEY 8VArDs5hWgYidus4DO8QPVMc724Na7iEO7XzHXA0vlYqglosEqKSCnk4YhLj9qeh3+5O3s9AvHO R33hSdaUSKRYUo3TbrUsZEGXIeFOzwtCuHLsZ7q5n1zPLKNnM3zoWIwsYsAhBbyKKJG2C0DiGSQ 2C2cIy6FWj+wnvnOugue2gimQjVJfyuQN9DzLZ8XGwrti2/8VvZRNUjkfCI2rAJxr9kwhYzVzr/ MpKyOM/P4/YzNG8obVj+CwBkV+W8vCB0nXinpOgz7ZP9U7h5exRrnzfkT8OYQkEMN2K1KF5XpST DCGPitYNCxFLKDO3lSHmtS/5Uinxi5W9s9bcES7OcytdUjcqNr4rFP8F6AXsJZZEnBu9LTX2vnJ CyxeqAjuuhSzLaQqA75FgTeeQ1Q7SpHfyvewqraZVxTQRKdeuJJvXZo/aKCdvfZtzuo5bYGaBeC OiRKTvWBCZtlOIob7/WKFTNmtZyltasnmpOPnHBdyojcJynwE1/+XZ/AzSPpVBnvmulZACpMAT0 3YFovAp4Rms2RRR8qDQXBvLFJMeuUkgoSK2KBHBiUy0eo/yRQDOxKD6WC52EALjbTb/BLwiLhox wdc6cj6rorb2j6Q== 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/leds/leds-mc13783.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c index bbd1d359bba4..da99d114bfb2 100644 --- a/drivers/leds/leds-mc13783.c +++ b/drivers/leds/leds-mc13783.c @@ -12,6 +12,7 @@ * Eric Miao */ +#include #include #include #include @@ -113,7 +114,7 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( { struct mc13xxx_leds *leds = platform_get_drvdata(pdev); struct mc13xxx_leds_platform_data *pdata; - struct device_node *parent, *child; + struct device_node *child; struct device *dev = &pdev->dev; int i = 0, ret = -ENODATA; @@ -121,24 +122,23 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( if (!pdata) return ERR_PTR(-ENOMEM); - parent = of_get_child_by_name(dev_of_node(dev->parent), "leds"); + struct device_node *parent __free(device_node) = + of_get_child_by_name(dev_of_node(dev->parent), "leds"); if (!parent) - goto out_node_put; + return ERR_PTR(-ENODATA); ret = of_property_read_u32_array(parent, "led-control", pdata->led_control, leds->devtype->num_regs); if (ret) - goto out_node_put; + return ERR_PTR(ret); pdata->num_leds = of_get_available_child_count(parent); pdata->led = devm_kcalloc(dev, pdata->num_leds, sizeof(*pdata->led), GFP_KERNEL); - if (!pdata->led) { - ret = -ENOMEM; - goto out_node_put; - } + if (!pdata->led) + return ERR_PTR(-ENOMEM); for_each_available_child_of_node(parent, child) { const char *str; @@ -158,12 +158,10 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( } pdata->num_leds = i; - ret = i > 0 ? 0 : -ENODATA; + if (i <= 0) + return ERR_PTR(-ENODATA); -out_node_put: - of_node_put(parent); - - return ret ? ERR_PTR(ret) : pdata; + return pdata; } #else static inline struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( From patchwork Fri Aug 16 15:31:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819867 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 B91D51C37B2 for ; Fri, 16 Aug 2024 15:32:13 +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=1723822335; cv=none; b=VRL2GI9hIc2Pt/PK4S59UusLs6dN01+4Ft7+ILap2vjX8hP+44W9SgsgvSB4Ie7+gPfsTAx/359QeOzjYhULJo+6IYxvV+dzUX4z8sCkWZJboWajyBAns5BHJ3MA/UqwbyhMgxxN5kye4H1+DBJ2DSl3s74/DbJSvJdqo8OVD0w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822335; c=relaxed/simple; bh=dbGzjAZfh7gVxRz/TIXrMdBv0rDvyB2K7+HnKJ4gJaE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ooylpq4mEYlOj0MspfZadq774yNxBrSnxFHB2PgyuRZV89+pnG3LSbW0NC8cuPaPCMv82IAsrcJS5WkfXOMweTtfFFcysSDwlnaOSpRah+QKeAIgnvtmhGgDVQp0lX/yyBYV7pi1U87LvLDzIbCjeAcSG2JZr2LbMoXBmUobsNA= 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=hMZTPDJc; 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="hMZTPDJc" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-3718eaf4046so957632f8f.3 for ; Fri, 16 Aug 2024 08:32:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822332; x=1724427132; 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=BqtNBWOnQ3Xg+u5frXQomaMjbI/CKyIXNSmcFe+MZzY=; b=hMZTPDJcK8kcTMmYxXBesHldyBQEnCLrt8mnvPhqcjnQ+tyErspfNMW7oSDChh89XI ZVal1dnvbPorPzD2TMoi/2f/TXRDapTY0JDlkHajoeK7b3mhTHrqPQTOSbpB36u1AptO DL9DVoNp5NfqNSAra6AoZ/h1SYNwYlBb7LuJ/d1HYnm0whgYgNAqoUcvyBjXR9qIsjNS 6Y4zcwuZsDlQRlgmDhW5e7tAhjHDkLvptmYC2s17Vi1AzmxgkLRMWy1tZiS5NvE4tnoz BU6c57GZxJrYWQZClXRVX33NYmqC163AHm6/pxqBxulcyiOGH7SzIs/9UopLz6+lcL6O b5tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822332; x=1724427132; 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=BqtNBWOnQ3Xg+u5frXQomaMjbI/CKyIXNSmcFe+MZzY=; b=X4QQSH3azb88V8MmYPUfdpj8JQez6fc36LUFHYh7nagv5TNRf2XwEpn9ynaKlroELo /YEQ8GCWij5qaHRwtSzGauXouzS467nbZnwy4Dg5ydmCUZTMrntGbLlljU37S9Q96yoa qZoWB031dzGEU1gZccxbVsXsJej6H/fDJ0siwC4iIsBwJ9oKoxzySQ+JMSBULuI4tr6V Wfwrb/69Tq8NQxuCN+qPexId0tN898Ns5Gu0vUt2tTgHFJLHAOvit0prgW6omhm0vRrg b2WImovv79vy+w8RY/+Hgy5Nx4w4bHTrKhPH3Jj7bhZC1TWGdg0FLCGLUgQxgQ1XWxnJ p5Ow== X-Gm-Message-State: AOJu0Yz0CyVvJKWOguR3lAhpi9AftWUSAndFbnmZ0qBNxMSzSNwszjV8 yE5Ver8cZFbkoii7RRunMbyWs0or8kYZL8+/nd8uexknE9zydkO0k1NtXFNMPTk= X-Google-Smtp-Source: AGHT+IGnK3961YuWU4oZFJTYCKl0K2mdOewbI1FmFnvK2B2BUfG+eWPO7zTzTcEARCDrYvRBocT5SA== X-Received: by 2002:adf:fe03:0:b0:368:4def:921a with SMTP id ffacd0b85a97d-3719469f891mr2605779f8f.48.1723822332005; Fri, 16 Aug 2024 08:32:12 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:11 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:44 +0200 Subject: [PATCH 12/17] leds: mt6323: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-12-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2340; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=dbGzjAZfh7gVxRz/TIXrMdBv0rDvyB2K7+HnKJ4gJaE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Djss2TXuF8dbygBzG44V3L56XAVS0ojN1I5 q5iB2VHMQSJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w4wAKCRDBN2bmhouD 1yUUD/92B+FeoNj59qOoLdJpY0L0jdj1oyZClGW92U7HP3VT2O9z9IFmIMEsFaaI70ggtfNrrGo n3LOrAyB3l1wKms4gb+ZQSmDRYF5Aa0oupBSWPo4/aDejYD6KmRMAG6N1jQlZSmmmbDOYITeoJd pHY3KY4kK5eIJy1/HBfZ4YmW0yQp1zlOJYB+JlaPWYtOU4whCpzmVuXybd33sRRgAKutoEzPJSK QfRT7WC9b+BMO5Z5XYutvBjQszr0jXXfkJuznDkY2yYLDhZJ1aBxdW+aY/BX1re1l0S3/dD48xH xkhARVtXmtZHfioc97M9oW1CJJmzNdsK5JaE/6/hFEghYexU2cN5K8VdAx7ydXoRFJTZGwguwZq SEcdGBMuI272hkbmFHQQsXr3mScckzIePahhWqnSh+hG49AcsO6DZ4J44sD230+IsaXQYmqlmxF RJrtUXpKSFLuN9+xRUPtEkKwnxLGIzOZC2Fa571U5F71wPuGmfVZ8FMNuw430ewjLkDcmyh4Tpl knNeNMNGypnIQTo3/FXuuXkjkgg6zZdomcMYrOTE9PfDpVsGWt8O/bJeetz5k6c5H6Qc/3zFYgD MpW3r9d2aTq7KnrbfguCP3P+CA84Qd+xusPgfqTB2WQ13DGwInvp81b0AQbKe/WXO67p8qpCloV XifrHJi3R9eQxcg== 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/leds/leds-mt6323.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/drivers/leds/leds-mt6323.c b/drivers/leds/leds-mt6323.c index 40d508510823..a19e8e0b6d1b 100644 --- a/drivers/leds/leds-mt6323.c +++ b/drivers/leds/leds-mt6323.c @@ -527,7 +527,6 @@ static int mt6323_led_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct device_node *np = dev_of_node(dev); - struct device_node *child; struct mt6397_chip *hw = dev_get_drvdata(dev->parent); struct mt6323_leds *leds; struct mt6323_led *led; @@ -565,28 +564,25 @@ static int mt6323_led_probe(struct platform_device *pdev) return ret; } - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { struct led_init_data init_data = {}; bool is_wled; ret = of_property_read_u32(child, "reg", ®); if (ret) { dev_err(dev, "Failed to read led 'reg' property\n"); - goto put_child_node; + return ret; } if (reg >= max_leds || reg >= MAX_SUPPORTED_LEDS || leds->led[reg]) { dev_err(dev, "Invalid led reg %u\n", reg); - ret = -EINVAL; - goto put_child_node; + return -EINVAL; } led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); - if (!led) { - ret = -ENOMEM; - goto put_child_node; - } + if (!led) + return -ENOMEM; is_wled = of_property_read_bool(child, "mediatek,is-wled"); @@ -612,7 +608,7 @@ static int mt6323_led_probe(struct platform_device *pdev) if (ret < 0) { dev_err(leds->dev, "Failed to LED set default from devicetree\n"); - goto put_child_node; + return ret; } init_data.fwnode = of_fwnode_handle(child); @@ -621,15 +617,11 @@ static int mt6323_led_probe(struct platform_device *pdev) &init_data); if (ret) { dev_err(dev, "Failed to register LED: %d\n", ret); - goto put_child_node; + return ret; } } return 0; - -put_child_node: - of_node_put(child); - return ret; } static void mt6323_led_remove(struct platform_device *pdev) From patchwork Fri Aug 16 15:31:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 820233 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D2FD1C3F0F for ; Fri, 16 Aug 2024 15:32:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822336; cv=none; b=sm+AuJ+NOSmk1ml5DZV3Of3mIzORjnr7lmvZgvcl0zDQnQoPm0W1Rk2rN+CSfKHsxi3TyNd+vNpBqFh1SmSKWI3cbLW4ghFPpR5zccZIwM4QWEddRKuD5E3c/9iIo9UivCxXl3bj/1KnN6bo5pHh/i0LDcXYz/37DD1asm0ftJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822336; c=relaxed/simple; bh=ZbpwvH2ustjiwLvVNFB7gNYO6vZKL2oVpGeN6mWbO44=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FIe2f8brZaA9UYP8jQ3RHyr5/Npgun2r4Kpke024Rz5CISaiv6755ezLL8cBk2bf1qXlciDRO1nu8IPwG10HFOaDt0+nBR+JRZ/5JOpq4Tl77sxyn3zvCYK33RpIF/TbdQR98W2Q3OtuyQu40X9dzBrIiy/HV2jFMENwQCx5I5Y= 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=AlIWNI5N; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AlIWNI5N" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4281c164408so14867165e9.1 for ; Fri, 16 Aug 2024 08:32:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822333; x=1724427133; 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=0JgxLZXaOT7jTL6qyBA9SLrwZQeJRHeBJE8R6L3hV10=; b=AlIWNI5Nbr2dsS2braiesxfSuHAtlapKnUKxJDAMCfvoKb43Mk+ktqOsnrdgeeYJ8p DeMZM/FwPRUNFhF2A3nI0s4qN7qF2njf19VU7Fdi5B/gmPY0KWpFh4aQpLn0QkQuuYa7 Mmi88vWknfQxUpyBDp5ttiTC0iA03vcOaGTI50wvTNWS4kshxSp7sQKsHAweUjeuTtex n6X0Beij2O1kRF5JjMSTm27nQ1f9uje/1yJE8VsXEFRAULmU6j6zRdIQDStodofQEJQ7 1O1NmcL6qVwYzoR6foQSjWYskzODMxq9yt3+j5BbVQ5jfbDMrc2ljRcpdqs0X8pL68d2 cfow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822333; x=1724427133; 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=0JgxLZXaOT7jTL6qyBA9SLrwZQeJRHeBJE8R6L3hV10=; b=LU3nq55ZQ4Tbg12UYnwYSCNIqNGoHP3/Citv7+XfKv6NZLia0/AgE9RaVI/D4gm9do VQmSxLK/TpiuW6kw+5J8+k7Qha3GaEt++qIkpzAU7INdOyvTkiVfkoiR9EhH5QZGTmo3 0x0Exp+lhpgqG5Knn2Yfn6bVYvDQt8p8EL2hAlqAdE/rn5d5gtFDuq4iKe+zWFuUxOo0 IC2w033KBjetLvSotNyLNYINclRdudeGUlYATesaXtNbCqMm1iEGQT72gIC4JNZs9+N2 KN0A9/Y72kJBhifS7yE+gcEf7i556axEMDDwj0Nppteq/IXkVz8zbi19zmRHS7fpMZpb ABwg== X-Gm-Message-State: AOJu0Yz9itTLQtxwP5ZDHOFlW1ysX9BVHKOBny56lrLsgFkevJazsnXc ZSc1G2k3xiZsJKpFwZjP0//2cMt7KOFPgNEoxMYfF+Su5rLEbcPIJG0CfkDZxv0= X-Google-Smtp-Source: AGHT+IGEXRtSKYqMHdRXL9A0IVWYnjdiaFA3vVmWXlDDw3F+xS7fwXoLMur4GHVC1AGF3Jdg085/ig== X-Received: by 2002:a05:600c:3b1e:b0:428:1fa1:7b92 with SMTP id 5b1f17b1804b1-429ed7ae3ecmr20377775e9.19.1723822333456; Fri, 16 Aug 2024 08:32:13 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:12 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:45 +0200 Subject: [PATCH 13/17] leds: netxbig: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-13-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2775; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=ZbpwvH2ustjiwLvVNFB7gNYO6vZKL2oVpGeN6mWbO44=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DkDqyZck82XNzSXwocQQY4b+BjTR2I/skAe /0iaxSnekWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w5AAKCRDBN2bmhouD 1zT7D/9LA9styAbhhWAgbwLixcjU5nsbijFUo4i2fJCjHsFr6OI5L9kYopu/4IqvUkdsFfIoLoi Am8mhH37EL2J7Wqaa4UyyyDhl828FW+J5WWGorkvyeZub68/URCiLwlvw754aiqAlZvXBcUW/wq DBvZUCDT2I93vgdlaK8T+jaeqXFh/ZiPBGOopvru4O/IHC8Q3T/uKoAKcF/IlmDptsz/l127ml3 Wj1RmTgWTFJ1fnpxd4gFo9bEMZ8NcmHpidcBQY8G8A82hJlKNJ3qqz5RXVPaySGdGSv/9YUF7bw rdOrzSpRB3vBzgAt9HuRDAdzaCZJRYlbW7g4/mDP71dpVRnDebllQX/BJhobp4h+MA+4ZLGFfET /fCp//41B8J4LrjD14f7Z/j3HXXGthuMBpi+WTQRXiS5QSRwzAjIYV13D+dmbCuzGPD8aMwAWLZ Vii9spzKcwv3Y20GxPQuHXVeIIY8Fp3lyhfwCO7HBJbzmUi9sKfcWPvjKzFIpJHodgEt/L34942 8qp2LY/qUq2KqrGKhePZtJW8D5tfXBrpDWpVZPb2zByLex/FttuvcKtjzvwP1q6pf2J/MzD8ba9 QJbWLFhD1zPgxo6X+YG9IePLDsz6HLk1vH8xbfu8ppnwbToivodXMGG9k78U7yqj6vG2S4ZjsC+ neKFv1FiAciy6/Q== 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/leds/leds-netxbig.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c index 77213b79f84d..af5a908b8d9e 100644 --- a/drivers/leds/leds-netxbig.c +++ b/drivers/leds/leds-netxbig.c @@ -423,7 +423,6 @@ static int netxbig_leds_get_of_pdata(struct device *dev, struct device_node *gpio_ext_np; struct platform_device *gpio_ext_pdev; struct device *gpio_ext_dev; - struct device_node *child; struct netxbig_gpio_ext *gpio_ext; struct netxbig_led_timer *timers; struct netxbig_led *leds, *led; @@ -507,7 +506,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, } led = leds; - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { const char *string; int *mode_val; int num_modes; @@ -515,17 +514,17 @@ static int netxbig_leds_get_of_pdata(struct device *dev, ret = of_property_read_u32(child, "mode-addr", &led->mode_addr); if (ret) - goto err_node_put; + goto put_device; ret = of_property_read_u32(child, "bright-addr", &led->bright_addr); if (ret) - goto err_node_put; + goto put_device; ret = of_property_read_u32(child, "max-brightness", &led->bright_max); if (ret) - goto err_node_put; + goto put_device; mode_val = devm_kcalloc(dev, @@ -533,7 +532,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, GFP_KERNEL); if (!mode_val) { ret = -ENOMEM; - goto err_node_put; + goto put_device; } for (i = 0; i < NETXBIG_LED_MODE_NUM; i++) @@ -542,12 +541,12 @@ static int netxbig_leds_get_of_pdata(struct device *dev, ret = of_property_count_u32_elems(child, "mode-val"); if (ret < 0 || ret % 2) { ret = -EINVAL; - goto err_node_put; + goto put_device; } num_modes = ret / 2; if (num_modes > NETXBIG_LED_MODE_NUM) { ret = -EINVAL; - goto err_node_put; + goto put_device; } for (i = 0; i < num_modes; i++) { @@ -560,7 +559,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, "mode-val", 2 * i + 1, &val); if (mode >= NETXBIG_LED_MODE_NUM) { ret = -EINVAL; - goto err_node_put; + goto put_device; } mode_val[mode] = val; } @@ -583,8 +582,6 @@ static int netxbig_leds_get_of_pdata(struct device *dev, return 0; -err_node_put: - of_node_put(child); put_device: put_device(gpio_ext_dev); return ret; From patchwork Fri Aug 16 15:31:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819866 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DECE1C3F28 for ; Fri, 16 Aug 2024 15:32:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822338; cv=none; b=q/rP9V5UiYdSiYlwPIdXyfxNihthkwarf3ztWDlJ/C17QDwfj8PZ2KPCHFnYedXxZ0XPlS3S31u/z12zH6YaX/q8Kgi34HALDt72x8aVh2b2iusIGEg1d6k7GGjVK59xYSC1CXtEzFH7B9LwsXElXVrErrIv8uLrPcP81IFd/dk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822338; c=relaxed/simple; bh=3ARnnx7uT2kjUKO/lBdUAxqqDcV1RDRByaeh6p9QzVk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mFhgEcnpNr5J5dPB4+d/pvl1J0dJa8NRaGTwMfFLzF2YI/+UHZzXZvKdTsghArLyEiZcG47xCUoaTiMRCIbAEqovmo939msEM2lDACx1ep+Eoy3qEyHqOsOZzx6PIEexglfK8iyqMy8VNXOLN8xBP01qQW2ktZkOVetPWMD5UIo= 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=BKNSOX7f; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="BKNSOX7f" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4280c55e488so11224715e9.0 for ; Fri, 16 Aug 2024 08:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822335; x=1724427135; 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=LOl1ZqBXdbAJXZzTI3BlQ8z/3fBsZwwoZ15vO5UkJdk=; b=BKNSOX7flAFtVilcKIw3BjpXNGzn4eU3cILCKRB0fSZ6SWhexbvHVt9K0F/SDsDc3z MMZrWiADE1Hh8iNbl4HX19sakphr8WyuxafJ/EdsjjrpDJMylUP0IS+UP+oVXeJDGFcE WBGEHe4faNl6i8zvEeukJQyY3ZovcrJP5xYxCWTygTsvfgF9ohivcxovaFN53AtYN6Vf X7rwiGFmZRZt/CSuErTn2pUXbwkMzgFNYbEGDDYa4GmPAYk3SL3SdW/R130IwVPIj2VE aCmC1E3umaXSDuGK4j93uu+Q9mfLpFTICeP2Evc93AMRLOFc3k/XV/hIY28qcyUf5ej4 FS5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822335; x=1724427135; 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=LOl1ZqBXdbAJXZzTI3BlQ8z/3fBsZwwoZ15vO5UkJdk=; b=Zi/3k2t4rtJQ5dHz7bRoq5YqiA9CdGdjDfNWVjFwbLArHS4S+139lKu6KxQZl3XiB1 xl457I8RMC3MiITcCHpHU1RwIcupOoR6sLpZNcDvoL4cuJfaeMAjETMm4CUfKiiTaw1R OljZOFczJtVpKKocimGIFCfXNZzt5PkLBUGJmW+Ep10kYxQZa8BTERyWoW9DqgDrhben rHejY9PA24wTUvN+5dtmXu2SpL3iCqqD++dWB7KoSyiFJWtkuqwn5DqZKDEfQvoQ5Rs3 Pz3Abx1n3lFVZVgRQzKNB+G1jHvWE5j5/MLO2etr4aypjiODea/+92D1U8P7XeCSwItb qEPw== X-Gm-Message-State: AOJu0YxcsfvKhsHDD6fNlzTgLmCrHDusw8piym1j0TyHrHGe8B+fmJp4 YDEFnV3Z6kVtyyRm6TySa4uS5XSXLW/ZiOmVK+hJY3KJVyWnB+lsI0wHmjE6MuU= X-Google-Smtp-Source: AGHT+IEFjSH4WqobBhV+up3oZ7ztZRwBuC3HgNzLRXaYpTTRLatXBwsIRxgmIFfySIZM1KogU0AXTQ== X-Received: by 2002:a05:600c:450c:b0:424:8743:86b4 with SMTP id 5b1f17b1804b1-429e232b8a0mr50953985e9.6.1723822334803; Fri, 16 Aug 2024 08:32:14 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:14 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:46 +0200 Subject: [PATCH 14/17] leds: pca9532: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-14-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1474; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=3ARnnx7uT2kjUKO/lBdUAxqqDcV1RDRByaeh6p9QzVk=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Dl9NwZPB/MApEGkh1nDqgHmMiX/P3/AIqpm RoLHvTk8y6JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w5QAKCRDBN2bmhouD 19g0D/wMAqWjPIbSHETSNRfB9R/1HlUm5xI5ndiN59Zcgwr/clBCSt48gRDMuFGS05K/kNaSvRO 8IbtYru6I5aMaoGCHU1KgbcevPw39TynUzLejaKERSJ2zXJ8UQ+qvh80ce/3XMYlfCBf9b19psi xRyJnm70aht0YnafXUBRfWvp6Im9/I7y1YV+tXBnLIKXrWLznSUDTHXSs7EKODOjnqt4mFNJfew qMZ4Lu9SFU+kG99RWVs4R96XWtdI5gtCmt9yjriDw5/cD9GE4Ad7Wjk+juXE5HvEjl/hZ0OnokN 3HsBKw9y+68dZIwQVVDmPPZJb50/DGJstWUwxOti9yfDxKYMCkW/+dZf1/LxZYvuxb/0WOvODM5 PNeM2bx/y0m/cOQY6GAYpu8UgoAbMWzQxufvxjUN52w+IQjQ7w3epmoZLycDyPEFvVQ9+Nz7kOQ I3QvW+PFDLC+htKn3wV0X1Adnhj3CWolfRDdVQ5m/UMB2EwDZy+VOthEx7pNzC5wcmFzTXoL6Sx 4D/8ee8LHgG/8I5MiNA6wVgqUJCu/NJE1DY6XJ1JuVTbs8qyCiLVW8bJ/yo4ecJgPpBBhPTGdfE Ld2si21avus1XNVlYHHao2BVVh3XLSmqiMvmaWBGvQw3Y2J0/nbyOBAcRN0BUWe6W+N0RGJ2O2a fZZYbzRJlMQmwbQ== 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/leds/leds-pca9532.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-pca9532.c b/drivers/leds/leds-pca9532.c index 9f3fac66a11c..338ddada3de9 100644 --- a/drivers/leds/leds-pca9532.c +++ b/drivers/leds/leds-pca9532.c @@ -506,7 +506,6 @@ static struct pca9532_platform_data * pca9532_of_populate_pdata(struct device *dev, struct device_node *np) { struct pca9532_platform_data *pdata; - struct device_node *child; int devid, maxleds; int i = 0; const char *state; @@ -525,7 +524,7 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np) of_property_read_u8_array(np, "nxp,psc", &pdata->psc[PCA9532_PWM_ID_0], ARRAY_SIZE(pdata->psc)); - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { if (of_property_read_string(child, "label", &pdata->leds[i].name)) pdata->leds[i].name = child->name; @@ -538,10 +537,8 @@ pca9532_of_populate_pdata(struct device *dev, struct device_node *np) else if (!strcmp(state, "keep")) pdata->leds[i].state = PCA9532_KEEP; } - if (++i >= maxleds) { - of_node_put(child); + if (++i >= maxleds) break; - } } return pdata; From patchwork Fri Aug 16 15:31:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 820232 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 016B91C4607 for ; Fri, 16 Aug 2024 15:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822339; cv=none; b=eBeJ8k95FEeZeVcf1BeJ56KHUnbA9E+MURzqaiMcJGBptSX5a9yTWBkw3FGYij87PKOvBSwN1W0t5rPzJ4W4fZrkLImmoG3hnlf4he3OGcB0Lcqisx0usv6G4207Zh2ylwRnG7IfbavHF+hA8NJ1rPpLpZgSmSbFgENqQp95IQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822339; c=relaxed/simple; bh=P/bMkN6MpG1hpAYn2CS2V4doNmtsHBv2dg+qwQSz6uY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kU+wqxruPZPnd0uDEUtAHqIusfESFVW8iMExjdm65LuAOkUkQBBCENPP5Md7O7hAijYv8CJt0dJPXU/2uYwd76ldOUBn7BzmtJ+uXX5rPfRZX3nWY8oVal75EN4G2PhIi0+1KSAdLnynanmmThTKypbnQDju9Zy+vLyZCHJimUc= 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=M5Wq6bGl; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="M5Wq6bGl" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-42817f1eb1fso15479625e9.1 for ; Fri, 16 Aug 2024 08:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822336; x=1724427136; 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=82u0aLxCOMmAENgy1g3HMnv8Q8OUR/q6nxVGVYKir68=; b=M5Wq6bGlzKHiX/nRBnmIYHjJ1DoteqazCN3RhFOOxAVrUbIkuapXgRjDRQB5HaOqRt O82Vb4QsyeKOC4QRYEpQn/DyP7C/vo0SOwiZAZvA17C2R9z5NHjfNkhr8YMo6Ox+8bSx pt8LgWboGLo5TiUEKpLXSFKxXb+MQ+POa/StDqAtH0PGpmxUvnVL19kcjHvNsPx6JcdF 4a6p0RAxMoA92yQLxGsF8u1Xqqap90P6xkr2/25A32eCxsjthNVhFwe85OPqHGiKd30q HJ4C42QWqUXG8tQO3WfsoLDNX5vp9wuuy1gXB5ODVE6gc0oTKH9utDsPlrO2gtBLHPeX fFmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822336; x=1724427136; 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=82u0aLxCOMmAENgy1g3HMnv8Q8OUR/q6nxVGVYKir68=; b=SRj6hmSzNIp+SpbfklrhcoaBCjTxL9amKWQ6j2nilN8agJzDDxOl5hFOY/s0nSmEN3 7wKUIxGNPdoiOFrVIB3g4nTJ+mbztOcaW5qqdKajCjPvRiPJGLRj3t5ZZoyhPISJxkhZ iM8J4YBFybLxE8KQwtzK8f6C3iZIjH6uF4OLddlA/n+Pew77kImDOF09EnAS//UyohnQ Fl4WY4+si91tvMBWq0FG1c5+dwHPckiIqzyRwC5lc0IpdnI8vKpiPVOScmOS4w7DdRXn J+WWSi3tJ9u2BfA8iaEP1VM9iNqgwhg+jS8YW5qgruuUxrlDqZJvdo7Gb2ukg0pklaqi 0HXA== X-Gm-Message-State: AOJu0YzAkpvljbksZt538R4ynlRAaQv2izOJajDqeP4gI9rd6kHIx64f WuSY7jFOQQJkqWrKpt8jbTGVxUGQKujYAp8MHTWcl40FI+NyXIi31I6MYEvD/Gk= X-Google-Smtp-Source: AGHT+IFoty7tTAPOCyav/M+yMTn7h/aGTkjK2dWYaVz5fLcCWS//Y230cKvMHPE242A86aP9/IgluA== X-Received: by 2002:a05:600c:46cf:b0:426:64f4:7793 with SMTP id 5b1f17b1804b1-429ed7af3d8mr25468635e9.22.1723822336156; Fri, 16 Aug 2024 08:32:16 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:15 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:47 +0200 Subject: [PATCH 15/17] leds: sc27xx: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-15-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1485; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=P/bMkN6MpG1hpAYn2CS2V4doNmtsHBv2dg+qwQSz6uY=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Dm8noI8EzoG5LCskKgbLFVnnrv1PYZVipeX tFmNsyKbeGJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w5gAKCRDBN2bmhouD 180EEACar4IcrZlsd3xk9bIpi0NxSlkXiLAuI8nxmW6mz+cNcfhPQWr4juEKIKU8SWq8Bcjuz0A RA0/Qwpgh/ThAWVSamp8X55go6COy9pVnFY/WIozfcjxLDmnjQc2rNa03f5aknsPajDOz2WoySW vV/UYxxrb2GFPccA/TJERMXE5GeOfqMzjLmOmv2GvpLO6MLT77aVmgva9B55Rg8FG2SyQx0J7pE Lo3Sb5LhsPgASPhBfGo1CNKh/s7c0mO4IhaZIY9gT/M+cJ3k5+2F+tBX95He9It9KNZkpBRh8mF qMOxPToh9G+2XWQbtx7/6RT1NWgXf0xEbwhed0/huc3VhD3QRluxkKuxaUuWrVlS+mRbjiCqm4z pKWcD56pWCpwCxStIm4WVykqOfcDFy7YZTDuSt3s5rxPTEkWutlE/sag3C3XQ8DXw76QWs8k3YE Aj5VT+19zWwY9Gsa7lvRt/KKMZpWgL2FZA+YPZHGspCt0j2sSimeiy3R0rUMnY7U+yVbXXAy1R7 ely/fkQQKsGD6yfysPNqnHAvqiH4vxarsInC0k7iVnm8T8hj1Kd+axD2KUF+Ap1hUF8wvNRJY9O +8lEqFLj2LocXZuxPu+xEX1QvniXbD8I0kYayTZoa+jVonEkM36vST9pM1G2uzlrWhIDTSKn7S7 mTyIm3ENeFrPMCA== 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/leds/leds-sc27xx-bltc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/leds/leds-sc27xx-bltc.c b/drivers/leds/leds-sc27xx-bltc.c index f04db793e8d6..cca98c644aa6 100644 --- a/drivers/leds/leds-sc27xx-bltc.c +++ b/drivers/leds/leds-sc27xx-bltc.c @@ -276,7 +276,7 @@ static int sc27xx_led_register(struct device *dev, struct sc27xx_led_priv *priv) static int sc27xx_led_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *np = dev_of_node(dev), *child; + struct device_node *np = dev_of_node(dev); struct sc27xx_led_priv *priv; u32 base, count, reg; int err; @@ -304,17 +304,13 @@ static int sc27xx_led_probe(struct platform_device *pdev) return err; } - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { err = of_property_read_u32(child, "reg", ®); - if (err) { - of_node_put(child); + if (err) return err; - } - if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) { - of_node_put(child); + if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) return -EINVAL; - } priv->leds[reg].fwnode = of_fwnode_handle(child); priv->leds[reg].active = true; From patchwork Fri Aug 16 15:31:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 819865 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 988301C462D for ; Fri, 16 Aug 2024 15:32:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822341; cv=none; b=Qe4/Ig/w4nSGqJQUpD3XS/OBummBEECj0M+AGcoHPPZLBWdq0ZxqrVOpQgPtHElH8SLIcfG1/DVbO0Zfwg03Gw1h0fM13aym6SgUuOP0b+1hqRrm4xAjoQUrvvW0i6VzFBPp/z4Ki0D6GyQEqYLWaWG735kRDcdEdcpnBd9rIRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822341; c=relaxed/simple; bh=HqurU8v6FoUuPIeHjxpMhqt9yfUTtSWFQuHadg1beqc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LGQ8HL6sNIUiV66lNaF6045Cph9266amZxgK5dRvaqo+Vwrp1zV7sCIae2eNItrhY9IdBD+7+6UArhT8qpBWA/CpwwEQZjgB0Q7KL/hyoGF412X+hmythecFpTZdf33vHJGuRQqyzAyUImeLZ+oJRwrYADFiAmGau/DLxcDsN4Y= 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=zvQIZ+Lo; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="zvQIZ+Lo" Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-52efd530a4eso3409265e87.0 for ; Fri, 16 Aug 2024 08:32:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822338; x=1724427138; 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=d4o6NVK+5RxP9AE82dc0tQeAqHho4Q+RR5k5EOL8qCE=; b=zvQIZ+LoqGoAcqg0sNzRFRvXKZgqvUzwF1f2upOBw9un894jr8Zd8hwXWdCRwDl7Ak pR+tElq70vPTpFKtIaZD1fcTdDW5Dt5vscOvaELgsAwRMIp/Xz7WKveNYwD7YfgOMz87 yXBSSk9cEC1qhzPTf3VFXgeWR7KYzCtzN0aWZiaCkfKjZQCxwXj2ZrvpcZx6v9WPUI8j tN6snZAhAdqZ+S80ySbiTDAoOADgREpb2D5YoJfBdfyOf9s3+eaaI9JILNvdd6hckkZ3 gAILUzH12CVQrOSFTb/fzVC91YRwXEsvyJ0NQtrKQ0DWv7rbDakiJRJ2wXnVc37oluBP UTeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822338; x=1724427138; 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=d4o6NVK+5RxP9AE82dc0tQeAqHho4Q+RR5k5EOL8qCE=; b=HJ+O3OnC6hqAmyDDtZgrhXsKr+gK4x0MzrJXacjTQk9zaE//+bcRVnFnzy30Maw9ju UgW/1XwKLnxQ9GRTXbe+tP/V3AOfUKsWZMpqxA0z3rJ4TJ+rb4Vr3CrR0irfzS9YH5oE T3qZFiGM2zsrrOZZrsOV70QTavxSKr2HYsV5MulnqzbecI4rdU4qKJ+IKE9ebcGsWf5x vmXAMtlBLl4AztYhggNDqivHZ9AS1ZrtBmvxNGRSSJCy+Vkz0I6XRUjLcHJ+2IUMhkv1 7eh/5Ww01o38MfEzwfv46SdfDAPO7b4CsiBoWEE5GvqfrNjRwaTM3BHd+xv6YGmTdieh 4xdA== X-Gm-Message-State: AOJu0Yy8T2zI5FffMQvI1TSIrU8+5nk0MILn6WcpaqjmUoTnxNMTqr0o xWzgVHG4Jp9qJrNSyNktRs+5ldjvvU/zckyMiT3UNEYtD8yT7AsCBfypx1HBC0s= X-Google-Smtp-Source: AGHT+IET/CjplVHoqhJT1dgGbpnM7bOR/IOJJFLcUpaq7hdaaWtUXfMeQ9ArJ1WuxrwkKCsQRRpLyg== X-Received: by 2002:a05:6512:3d1e:b0:533:d7d:a34e with SMTP id 2adb3069b0e04-5331c695987mr2342012e87.7.1723822337538; Fri, 16 Aug 2024 08:32:17 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:17 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:48 +0200 Subject: [PATCH 16/17] leds: turris-omnia: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-16-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1244; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=HqurU8v6FoUuPIeHjxpMhqt9yfUTtSWFQuHadg1beqc=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3Dn/4FodrZqZy9l8ymKC3RzvyZz5qUjuY2CL I8dXCHswfSJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w5wAKCRDBN2bmhouD 1/k9D/9UMNk7RM3WQGHAruhcdLJVhguE7sJuyHNKcv0JiIT7rLqrxgI0kl0TXtijoBLQifUtmXZ n35/z2TOA0jMGVqDPqGfeNVLVubMwH2nrI2Ni5HcdxRIcVmOI5Qx8hGIAXD8y0+OJYkM+e9+MMW 09hTenPhrVmvb8M7YhycHH1JSDV9cQj5pWdYrcf9X259N9O2dQzVfpdI4UA9GtQqSNLEkbuW9Hp y74zqYk3zBvM3xAlvg43roVpp4MqjH45PtJ11CNOOpMNAVh4KO+73Sx7Y/Zxhc/iHv18ky49WfS lGjmWX7aYivBbwfKDQrc1uuJsio9CXHKui9IFVREXod3XAW8dFzQmBJhlmrhp2ppVcf3wqOCd/g v2zH8BG+SM+ulHja62+nlUfuD6B6vDBpNLRKLkHC0jKuhUb2yXe4OFT17v8Vwkzs6/t0vCbKIoW idbzDQf82L1WtL+yWv/brsico0O/8/FBiODTt15BMAZ4wYOG5YrOem6kGbv8kSxea9vP+S7vpdO 9JpanPlCJQ8Z4xlCm3uumDcswywrJ9FhFvqonNLpVQfBwk6gcMt7q1GkAsIB0P6LjEgEHgdm3qD ZGlGjHkSWXHGIFYWFg5IYbAYfEzX3nOZJAkkSKxMA+DQOjYqzxql8WnOoHOeUfh0p5rdk1Os5pI C3oB8c3EPtY7V/g== 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/leds/leds-turris-omnia.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-turris-omnia.c b/drivers/leds/leds-turris-omnia.c index 39f740be058f..1ef942b5cefa 100644 --- a/drivers/leds/leds-turris-omnia.c +++ b/drivers/leds/leds-turris-omnia.c @@ -452,7 +452,7 @@ static int omnia_mcu_get_features(const struct i2c_client *client) static int omnia_leds_probe(struct i2c_client *client) { struct device *dev = &client->dev; - struct device_node *np = dev_of_node(dev), *child; + struct device_node *np = dev_of_node(dev); struct omnia_leds *leds; struct omnia_led *led; int ret, count; @@ -497,12 +497,10 @@ static int omnia_leds_probe(struct i2c_client *client) } led = &leds->leds[0]; - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { ret = omnia_led_register(client, led, child); - if (ret < 0) { - of_node_put(child); + if (ret < 0) return ret; - } led += ret; } From patchwork Fri Aug 16 15:31:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 820231 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 AD2881C578E for ; Fri, 16 Aug 2024 15:32:20 +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=1723822342; cv=none; b=gRWvViEyzk964gt1DTeUrphhp/JOD5QoIkjfC8d8vzJMl1UgwoBVMtZW9Wkkbl5VrIf3N/ek/o8LeQ3O6zGtIFzlpdiKykfFScy8P0CQTwbAy68N117JB4rMtYVPfIRgiZd6Elsw/lQOduVQnQe1mK0YAf53ZJUnzsduuDibPk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723822342; c=relaxed/simple; bh=evm4/Qf1Gix0CG1zjk2y90RZHb2Oo+FXRI+CwqZngfA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YyXES6GNfbyc1/+ODIaa/xQZw6dtLh0WDCvFpoqyWEAwW1ehKeU2C3yIDaURUxIIOJlJ6EPc7g3Bt7oOl/KXBZD6+KLa17+nP0rNBBXtSy9ZXZPW8TC5mi7lxP2BHCQNk2npt0jgDQVWNcbXVVJiawTnGAtBCjE8uw+q5V0oJq4= 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=JczSFs7Z; 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="JczSFs7Z" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-428e1915e18so14755275e9.1 for ; Fri, 16 Aug 2024 08:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822339; x=1724427139; 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=i72cl2LG6rsfBE9NuFNe0vCjzQLf8lqqkLVcJWffpKE=; b=JczSFs7ZSvunsqpKG0tEFpCPMfCVKwpUkJ9EhwdByAotzt/2sR8MvwtwfomvDKVzqT 2QIeR02aa0p82Ta9ucEnF9354TAw8CJxxqDF8BRsG7kCt1TuZjvFksBgbfP1X0gi8tL8 CUCj1GE1vXfp6b4FnzWK5/JHVwqkafKqChWdnfQIXbA7P7nVYIx76IBbgTSM/UZB4XXN hlJhBzE5Z6jEpkcTZ7TUbv+0fOBYird/7oNiJQ7vKyhW9kk8fkK5w0rMbDL0Cjp3MmUN TV+b3sh0bhqCKSi5eX+CqpIF7xasaiQFN6jAz9QNcx644b6IP29pDd0W2EmT3o3MTccT z0UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822339; x=1724427139; 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=i72cl2LG6rsfBE9NuFNe0vCjzQLf8lqqkLVcJWffpKE=; b=T7w+Z8+J1Yl8SYEtlm+7KbD8A3yybtnGHUh836h3YWA+bUYmlst5y3+W954XqZqyhj tvwefaTE/5gaFXZxGUlOrmfjd74HfCJlQxF108oPosq2gh8h5i2DpnVm8dTWBypcjM4y 8qRUM7Jz+1vZ3lP8Pwl9s9uQrkLU1fgPXbH7sV233oPzMtu0Uo8hWgSmLKQmxe8A1OAO TEaenonUKZlXxlNGBpnaxcauFvm/60/G3lI/dfImwL3GLNszJmQZsGB7xRmyQoO9eTY1 0IGBYVEGOaxode4DGdzx6D+EQO3nA8nI+U2/+4xPGhKws8GpT0dLaQkyltr2xKsmZpuK Rlsg== X-Gm-Message-State: AOJu0Yyc8O7qtHM88OLU4rc7dX0N06PqQc8EvsRQf1Vbn2QdtiTJW6eF dDlLvpn927OhkFGoFqeavuQRiYezGh7tMdYbaoFEuLd4u/br2XGYUB03Y+GSdMM= X-Google-Smtp-Source: AGHT+IED0WYx0TreQX2OrKap07J96mSpWj6wWPju1D8qe2yhsCsW41zGu895F7DsFQ1Mn543/zW+Kg== X-Received: by 2002:a5d:4b02:0:b0:371:82ec:206f with SMTP id ffacd0b85a97d-371943293cdmr1861574f8f.16.1723822338955; Fri, 16 Aug 2024 08:32:18 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:32:18 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:49 +0200 Subject: [PATCH 17/17] leds: qcom-lpg: Simplify with scoped for each OF child loop Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-17-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1848; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=evm4/Qf1Gix0CG1zjk2y90RZHb2Oo+FXRI+CwqZngfA=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DojUfs6j9ghjY8rYQZeR83/DBn5C5vGVai7 SH1nEKJD1aJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w6AAKCRDBN2bmhouD 12UID/4yUfw9u/p7xohuwxORPZDDT+wUHcCCjyoUV2diG+Nd0Oqzcv35eu6NeZNl7BNB3X0EQoQ VQn8BrW9aEHJFgdQC2UPhVqwKnqyy2th/AJfD9MDAa63IdWIdTPI4ZAUqhAMFTHyj4QCIM+Cewp 6LSA+M0GHdFwqqZXKWRyINxmfNb+nD1yOcUJSn1p4mQVAlwWCr5tXZEmhFh/pvurGumxCqeHGt4 EEPK8uuEV/ZrxuMoKFKYaZxEmbrQkvfISkoql4+54GXtQ4u7qmSdTqCSESVW8wrX19GteWzW34w /3rW7iV14tptFvALyHd80HwsDP/FpK1oa9PDUI4ukf8VXk4DMcTg0/DlK553j0gew5RgjMZszdh D6o0hFLVuvoe4M/wRvnYDb2c/HvPKNwKG2yLIkft3ezelGstcfsyprKU6Wvg9ui2s4MSiYcfIpb RkiasvWRnhtsxaMbCeE0GbtB8xTkCUJufOlMHca6MY6/0upIL7buM+iZ2gQD03zfpWZChYZ9xRT noGcSiHIFcHWGBT7QU3Aac96iJHkrY4pfr8vq2oE3o8DZhpegNlm58HqHDk0kl89GIR+JuccPSF ZN/CyNtXDJP5V8DPnd4ZHC6QzRAeZYyQ3PrXV/BluuDVR+gcWQ4G60i6McsRcpRxELK+EFjjgst yLwTWCItNdg6GjA== 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/leds/rgb/leds-qcom-lpg.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/leds/rgb/leds-qcom-lpg.c b/drivers/leds/rgb/leds-qcom-lpg.c index e74b2ceed1c2..f3c9ef2bfa57 100644 --- a/drivers/leds/rgb/leds-qcom-lpg.c +++ b/drivers/leds/rgb/leds-qcom-lpg.c @@ -1368,7 +1368,6 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np) { struct led_init_data init_data = {}; struct led_classdev *cdev; - struct device_node *child; struct mc_subled *info; struct lpg_led *led; const char *state; @@ -1399,12 +1398,10 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np) if (!info) return -ENOMEM; i = 0; - for_each_available_child_of_node(np, child) { + for_each_available_child_of_node_scoped(np, child) { ret = lpg_parse_channel(lpg, child, &led->channels[i]); - if (ret < 0) { - of_node_put(child); + if (ret < 0) return ret; - } info[i].color_index = led->channels[i]->color; info[i].intensity = 0; @@ -1600,7 +1597,6 @@ static int lpg_init_sdam(struct lpg *lpg) static int lpg_probe(struct platform_device *pdev) { - struct device_node *np; struct lpg *lpg; int ret; int i; @@ -1640,12 +1636,10 @@ static int lpg_probe(struct platform_device *pdev) if (ret < 0) return ret; - for_each_available_child_of_node(pdev->dev.of_node, np) { + for_each_available_child_of_node_scoped(pdev->dev.of_node, np) { ret = lpg_add_led(lpg, np); - if (ret) { - of_node_put(np); + if (ret) return ret; - } } for (i = 0; i < lpg->num_channels; i++)