From patchwork Thu Sep 26 23:20:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831709 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.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 8A22D1B0135; Thu, 26 Sep 2024 23:21:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392882; cv=none; b=mtsRsAUwAO9Wl4p0GBWb9tgLewfAlkiQyRvyPmY7x38diVK0fbEqDu2qaAc3Ex0mF0CRC9Az6UYjLAoOk8iJcaxbgaV2fNGXSttdVdj5JoW+FgwrYy6hqJfP6/F9YXZ4ZTreCdT31M++n98sS/zn6k7EPX2OHd1iDX+Us76oW/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392882; c=relaxed/simple; bh=1/lxG5uyf8ycEv9Q6sKFSvHVcULTiG1X47zomtk2GFw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ewtTLnsYjI2r1HoJK5NAIcI1T0Upvu1DMXvYBqioieT776EITZW3K5RrSJ0E9wjrG7hucEAnpYg/vTni9voRcqb7ym6IZG2bozZzOnMXlJY9G312qtJz7y6igIKPDHVNdsh5MylXrHn6/8YfgcgDAS11ZRYeYNeEWRRw8KYW83E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CeHSICb0; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CeHSICb0" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a8d6d0fe021so244075966b.1; Thu, 26 Sep 2024 16:21:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392879; x=1727997679; 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=HGJHwDpR/ji/cnkncpEc2TmRR9IZ/lolVNsmw4iGQAY=; b=CeHSICb0gKqejYJR/aASEOyZ55yFEL+fhJlTrXUIcD9FSVrtz5VKYMIqZZ0Ma8PLuy g3yzYs7uqwdyagI5+8GJT9ogmZHw6KV1u7AOXLJxjEo/anKw4QMwil6+CqJXfah7f+cN iUUe1Xk9+iTZgcBa7D9IlJbCYIx8B/lfU6k6SKvQ9AnVuHK78Oe/xdhM9lBk40AxiixD 8xmzQFMZSczxq8xvmuCJBDH5I72zyM91sACqswpmbqtdoh5Drn/lKWfhcFcynrLl4xxM iI2ZJhDHBDpu40mReXDsoaYKlSBGhSuQ0oXE0a9T8ARlUtQ/S7Js/Z5+EQEaFvMERh5I n8XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392879; x=1727997679; 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=HGJHwDpR/ji/cnkncpEc2TmRR9IZ/lolVNsmw4iGQAY=; b=h3/Djj4QC8bLITF953ERMn7XBsJiqGhBvOQvbRcIRMjOxNAVTs5G5dvQABiX9ysTqd nox/ONL++XrktKC0pxWvGWVbR17cnZPoZUgA46rvqFJmxsSQmnpo7bLaK4KsZUuSrEll ncVHFTEmr1xbWdpls8AsFJcnGRhyslepG8GVleJJ8r4HjKhFkVDuPapUzE42/m7Bsr3N lfS/I1jG51E0C4W2nbpa/4efWf3mLaCNOBuQupUBq1bhuBNjmM0fz2sXFz3wsZnnGhr+ FBZpAFFaX0uWEin/N8cGVxGBLQ5sjlDNlLPlWZQNA1LY4zWbvV/lQYQTh1qi1JlUMjfd WJxQ== X-Forwarded-Encrypted: i=1; AJvYcCUWcfPEgH9SgouBrjhCzIlxEbSft2TdMc8wxrXN16UD3e8xtgOqRIgVdczYObQPqKUEyaDwUqWe@vger.kernel.org, AJvYcCUiGgAhkHcoySCNouWlI20ZRU31qDSvMuvmu72H/jkMGmopv6L3ej4dUjvw4wgm0HhouvOpnFOk1+RnjNg=@vger.kernel.org X-Gm-Message-State: AOJu0YyK12NOzwogPluCjtYKBhPe8JpRdd1xDGYzZk1V6CNTkREC0OEW PjbyZVJJmuiBWVy7VVB4aeFz8AbwkTLxH+KsGRvyQZuuqmiuLJNN X-Google-Smtp-Source: AGHT+IGY5Dz4pgmEK6u+H4dMIOw35D4e/9hhSxXD8+4Iw9UMbO9AvkfpZ6JWD1p0Ig/DDcHSjiCZSw== X-Received: by 2002:a17:907:a41:b0:a86:91c3:9517 with SMTP id a640c23a62f3a-a93c496167fmr87272966b.35.1727392878703; Thu, 26 Sep 2024 16:21:18 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:18 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:20:52 +0200 Subject: [PATCH 01/18] leds: flash: mt6360: fix device_for_each_child_node() refcounting in error paths Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-1-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco , stable@vger.kernel.org X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1575; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=1/lxG5uyf8ycEv9Q6sKFSvHVcULTiG1X47zomtk2GFw=; b=l7jxa1PVRIFHMQnforadtxXgycvAan+1W9FAPjf/oLjtSQJykU+rNGG9xia/dfVKvn20xfSza 2IKbNR03aEtAABYWTigl5u7JrFYAD61XGGxXgkaMcyX799cHVY4tp95 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The device_for_each_child_node() macro requires explicit calls to fwnode_handle_put() upon early exits to avoid memory leaks, and in this case the error paths are handled after jumping to 'out_flash_realease', which misses that required call to to decrement the refcount of the child node. A more elegant and robust solution is using the scoped variant of the loop, which automatically handles such early exits. Fix the child node refcounting in the error paths by using device_for_each_child_node_scoped(). Cc: stable@vger.kernel.org Fixes: 679f8652064b ("leds: Add mt6360 driver") Signed-off-by: Javier Carrasco --- drivers/leds/flash/leds-mt6360.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/leds/flash/leds-mt6360.c b/drivers/leds/flash/leds-mt6360.c index 4c74f1cf01f0..676236c19ec4 100644 --- a/drivers/leds/flash/leds-mt6360.c +++ b/drivers/leds/flash/leds-mt6360.c @@ -784,7 +784,6 @@ static void mt6360_v4l2_flash_release(struct mt6360_priv *priv) static int mt6360_led_probe(struct platform_device *pdev) { struct mt6360_priv *priv; - struct fwnode_handle *child; size_t count; int i = 0, ret; @@ -811,7 +810,7 @@ static int mt6360_led_probe(struct platform_device *pdev) return -ENODEV; } - device_for_each_child_node(&pdev->dev, child) { + device_for_each_child_node_scoped(&pdev->dev, child) { struct mt6360_led *led = priv->leds + i; struct led_init_data init_data = { .fwnode = child, }; u32 reg, led_color; From patchwork Thu Sep 26 23:20:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 830933 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.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 84FA919FA8A; Thu, 26 Sep 2024 23:21:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392885; cv=none; b=E1AEn8zF57gglAUgvdu6bqhcR7F/pQFv5vbHwpqeN0S6ziBJopLW+/DTkvMmtUlHOt4u1WCwM3VZE9iSwilEBqrLgWN7vr1uTP++5szdNH4afT2ypcu9HLOlni7lytpkalACmWdKnjsOd59haNmrRolHzR7Vs129ihgVU8iyDx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392885; c=relaxed/simple; bh=da+yiLrVSVhzxfXeLXUvwNG1cBTZv5IPC9inOzFUOgI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ktSCx4pdhiDeZVwEWM7017T+n3zg/Iuba717SBE9CBCbqNYDs9Xa3owoVtkfpyoDhjd+EG4zAfbpC1W61h3248RXk6XMFkOTliI/gPbrGZisNrlqtA//nW8jK1t+N5QKsrzmXd6uBtgAtk7XlFflWHnvUs7pjtjWC6uJJ1eArd0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Dd0XjdCQ; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Dd0XjdCQ" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-5c71f1396e4so1766368a12.0; Thu, 26 Sep 2024 16:21:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392882; x=1727997682; 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=SRhQyVKcgRlVjIYoZT+41pIKZJrgjINAhed1beNUQXI=; b=Dd0XjdCQYGePZYgn73KrJf4/iRm73yNjHD5ZHJ7iXrpGewfkHRA3egatUpMMdsv74C KBmcUHdNTz+VZwTmCyqhknN7i4afWVcezp4SJcB/tqtojkT8OWJ4w9xl8+K5vvH0ntb8 2aFeufwpZiT7tr/evC4KYi8kSOp2K6tTer73DCXPWZRG3lI1buKdse6IGG8E5mHbSVEl JzCMh4wxGeTmHuqJS23iohNbrHRjXou1docPvqWKa++7VRDLiTKP5pO2JPnLVTdXV1IY 8ZUFTxz434zSd/7Bt47E2Tt4XpBMSSueWGiOGQlsh19rxSSSzxqZVSv7sPqC557dmZvy +ecA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392882; x=1727997682; 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=SRhQyVKcgRlVjIYoZT+41pIKZJrgjINAhed1beNUQXI=; b=qYKypyl6lgUXaw+woNB/4x8C7oBTkNywdjH50oNnf7aFSI7vl1LVNYJaT3m8oopu5E 61iIGZmMUUIsNQe45QX34H+MqMi/7pOc8ck8ilFSLlJG1Uh4cvSKlqES/ogsAnU4AUFB xTmjXx02xFOSuh93Pi6oXdYYaEgtzcH6HJOQXm/MO2jqzCQBRGs2uS93WLCfFOmV3bE/ gwfvU75VKVP5yK/1g+j8D0MZllcerbhUZ6OMpZc172xuQVmaMIgbLeYuulIHdfERXiVA hU/K723ao6OhKobmAbiMGGNlsprFnk92hwja08q7drb07aNERB7QloeyrlYfz9CEbdYJ uigQ== X-Forwarded-Encrypted: i=1; AJvYcCWDKTHHUj1GI5MIkIuA2efQTovktt+uGtHiBGio5H8Vk2GLU8c1Ko/hy2LKEfog/8vdmwVCwvFpbUwNZE4=@vger.kernel.org X-Gm-Message-State: AOJu0Yzrmu36rHnd34bsjUgWluyF/lD6g4L83jo339mLFPIrE9ve/hoG WIhXRB9zk6Tx8dIud1MXqbEifMdjBnan/QLQoKWcl9juZd5QsT/B X-Google-Smtp-Source: AGHT+IGd2PJRYpLODXkVXKvFBOHOE+/1R0umomGP/eN5VLC0TMztnCr42izK4H4rLnfkXKxJDXG3EA== X-Received: by 2002:a17:907:2d90:b0:a8d:510b:4f48 with SMTP id a640c23a62f3a-a93c491952fmr82476866b.22.1727392881724; Thu, 26 Sep 2024 16:21:21 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:21 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:20:53 +0200 Subject: [PATCH 02/18] leds: flash: mt6370: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-2-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1546; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=da+yiLrVSVhzxfXeLXUvwNG1cBTZv5IPC9inOzFUOgI=; b=+HkfaGOfTwfbLA3hl6LrR4cqzOrg7pu6sEXSeJ1n0Dv/N3Wgj5+SYNtD9fefjVYJnlMGIaRy1 uy9KHs3e49mDqhgLOoZkQSYwrgF26sZfTIiULhEDZkfR2xEXsDOl9l8 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco --- drivers/leds/flash/leds-mt6370-flash.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/leds/flash/leds-mt6370-flash.c b/drivers/leds/flash/leds-mt6370-flash.c index 912d9d622320..dbdbe92309db 100644 --- a/drivers/leds/flash/leds-mt6370-flash.c +++ b/drivers/leds/flash/leds-mt6370-flash.c @@ -509,7 +509,6 @@ static int mt6370_led_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct mt6370_priv *priv; - struct fwnode_handle *child; size_t count; int i = 0, ret; @@ -529,22 +528,18 @@ static int mt6370_led_probe(struct platform_device *pdev) if (!priv->regmap) return dev_err_probe(dev, -ENODEV, "Failed to get parent regmap\n"); - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { struct mt6370_led *led = priv->leds + i; led->priv = priv; ret = mt6370_init_flash_properties(dev, led, child); - if (ret) { - fwnode_handle_put(child); + if (ret) return ret; - } ret = mt6370_led_register(dev, led, child); - if (ret) { - fwnode_handle_put(child); + if (ret) return ret; - } i++; } From patchwork Thu Sep 26 23:20:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831708 Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.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 405C91B1405; Thu, 26 Sep 2024 23:21:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392887; cv=none; b=k1ZL1FqMqtm5fY7ZZO59iYVAsBZ0bGPaCYZqmySLdAaR96TsEo2uFrIo8kd8d/nyTel8LRO+/vkGrD+HFeaSUH3IHDBD8aom8SefWfqcMtCB5maig5nn2Qy+TJaeG1GlKr9CYAMAv73Y11DLQDScVNSc8vPjyeJttrkNWFoIxvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392887; c=relaxed/simple; bh=wZ6akrPJfNHUSfXIEENEHvfLrdMCasbCDwbd/LiltB0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DZerU9Ct2Bs5NFT+Vl3bxDN3kwBqSqNttvnTfGkI8qHa1Q61ssmzA6t8mCVMflCKlOOrNDUH8HfdJcgskF/GsOl5McgPf+bGakoHj/KeKUKe8GyL5VL7Jq1y/qJYsTxoJyYvkymS9GEYSnFLA1OdEY4MUrBN3UEMsOWCuDHotVQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=N+7LOPUe; arc=none smtp.client-ip=209.85.218.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="N+7LOPUe" Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a90349aa7e5so219784066b.0; Thu, 26 Sep 2024 16:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392884; x=1727997684; 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=HNd4acINmmNerLNUmXoF50X4J1ylsjRdPZ4qMlEZiVs=; b=N+7LOPUeHecVslP7mv0dDdOufAusm6tj5bzpbZRi2OwZsPBWb9Z1Cqbh4D6ST+MJxh eDHFwcnKinGJg7Ln60pRfK+q/UFuLgNpQmsiADVyXmflmBgoTAvRq72vuEka+dKRy3yD MLnqS+Gl1FbNWhcPAlp1Q1Amg+SYaksQvwLDs329nCqOPajVvV50IoP5dwqDJMF1FnqY BA7+70Z5uM70tqWrEHJd1H/rbpfj0+1Y5GqEVWGVEw3aqweP2IH6ZHPtbOK+T0Mct3UF ajpZ8xlhRXpjlEduanZnzL40UN7gadESNSJq/q3NpNPWV5Y8NeJvOknDe/AtsQKclI7m 2ohw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392884; x=1727997684; 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=HNd4acINmmNerLNUmXoF50X4J1ylsjRdPZ4qMlEZiVs=; b=mJ2Gy6tyqD+sZ6JasPrui9OcuRHs382JDwkek/XymqaNQyuWNtkuDigqt6KrQ7Ehdd 8zEzZSPRCwBq9/sbWKsp9Z2gH0uRq2plBjh9wLiAvngqH018NeyJ0tkgd6wQlACKVx/b ris6PmlMjeScnemT13W8JhFBIduLsTkSXCnnJYW/WiV45+9Wdrw54GH3SYpbNT0+OEnn TrW0Xp2La13lMiiVMwT5agmJ7VCv/XTz5CmQpfSa0ZJGFkOtrRA8kaKhpJnkXjhDlC6S A8tXs2EXYvg5geUlr8thE3y4tqx3UE98CvPnT+5uF/eCxH+/p2ArC7jQtuzaAmIkY/Lt T93A== X-Forwarded-Encrypted: i=1; AJvYcCWw+XrvjWQpSu99vWZpzv9QWqHRX3WM+VVLXljwD5u9FiFD7OR9P1+nLcr7lReqMlmDfJHHUGqeSn5U2w4=@vger.kernel.org X-Gm-Message-State: AOJu0YxujUt4LxufJPZGOP72hlt+rs0ojPH+j5nwwAnGyk6bshBEYBmg JD085iIkaCXa8jcMxdyXFKZKKbYiQOs6rhxs87jZRJke231vmh/x X-Google-Smtp-Source: AGHT+IEaJkjaI1Z6tqe57O4cY/kSpV7TlwQqKprn1eIz034AUHy+NubnWwLak/p5Xh3t4FDbODMYtg== X-Received: by 2002:a17:907:96a7:b0:a8a:3f78:7b7b with SMTP id a640c23a62f3a-a93c4916e6cmr73897666b.14.1727392884471; Thu, 26 Sep 2024 16:21:24 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:24 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:20:54 +0200 Subject: [PATCH 03/18] leds: flash: leds-qcom-flash: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-3-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1584; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=wZ6akrPJfNHUSfXIEENEHvfLrdMCasbCDwbd/LiltB0=; b=51y1SjR6ulBD3qqgS2qUF2cR+3GmbQoLP5twgUKAKBCLM1UNA7NMBuE8fYTAvAWvhCwVEKFCh S+CcP+wu+pwAJEAW1NzXp4grrO/7Uy2C/nu/OWMtTu//R6mCOAKLHae X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco --- drivers/leds/flash/leds-qcom-flash.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/leds/flash/leds-qcom-flash.c b/drivers/leds/flash/leds-qcom-flash.c index 41ce034f700e..ab848c5acd2d 100644 --- a/drivers/leds/flash/leds-qcom-flash.c +++ b/drivers/leds/flash/leds-qcom-flash.c @@ -812,7 +812,6 @@ static int qcom_flash_led_probe(struct platform_device *pdev) { struct qcom_flash_data *flash_data; struct qcom_flash_led *led; - struct fwnode_handle *child; struct device *dev = &pdev->dev; struct regmap *regmap; struct reg_field *regs; @@ -896,7 +895,7 @@ static int qcom_flash_led_probe(struct platform_device *pdev) if (!flash_data->v4l2_flash) return -ENOMEM; - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { led = devm_kzalloc(dev, sizeof(*led), GFP_KERNEL); if (!led) { rc = -ENOMEM; @@ -914,7 +913,6 @@ static int qcom_flash_led_probe(struct platform_device *pdev) return 0; release: - fwnode_handle_put(child); while (flash_data->v4l2_flash[flash_data->leds_count] && flash_data->leds_count) v4l2_flash_release(flash_data->v4l2_flash[flash_data->leds_count--]); return rc; From patchwork Thu Sep 26 23:20:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 830932 Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com [209.85.208.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 D40001B1420; Thu, 26 Sep 2024 23:21:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392889; cv=none; b=aq6XAMDy3vCvC/T5/U2EMKo++Md/tYdx6PdtAa4bJkeU7SywxUlGJu0JUdSvyz8fRSTp1GrKWeIJ4LYR54oJYzCPhxbWyOIS6lo9rWfJ7lYkAM7pYIBh5+mHjZD0vYqXpywzEEKozTH8ASIlKU/ZRUXHhh8Ac8vo8zoOynhjhmg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392889; c=relaxed/simple; bh=d0/jBZeOQ8xCvysG4yJkfCKJi0DJ8XXoa660caQmywM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CgGk8gBxf00OW7Y0Kqt9QdEHMn/ug8fNs9e4awideoa82z94ZntrIDzgTbMavBkAaadLTZ0Z9FUGw4NeBtpTEGHd77ePj63eLVuuH4RwGThOXKVUitZ+l9R+9T+2dNG2T9j2VguUabbUJQujIX7AMUWh/JGbQqNmmtm0TeVKG7U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DD0y2voO; arc=none smtp.client-ip=209.85.208.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DD0y2voO" Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-5c876ed9c93so1578568a12.2; Thu, 26 Sep 2024 16:21:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392886; x=1727997686; 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=97MJYpYNh2OXN36yrgEntTFOxNkCwTKF272jX4EBFYg=; b=DD0y2voOIVN588i+EkmjXWPYyCxbY+5XI0z52AD51ejDqOHqPqMGxFdLdLGprFoBhr l8W+Vn5qsudKD4EOf29+IV7ZI5G3GNTc+GkxUr1Pmw9ZuDtcaeL+Tke88vgi2rU7h3D6 EegSt+HZbBUqrfDhhz4c02yX4SVKTk2ISa4GB9hM+XTzX5KA66PBL/fxmKaX+M7p4QMX fTfz8xMRmbO9m4M0qVRq960d+di70lF7z3DCCGchpDYw6AH1K8ANp+gtsKpYOXcLtSMl Je6qMX0ZCeSE59KXfh2HnAKNSjg3Q0qLooN+LHwCD45iGuQ6MM9uXswVrX5UxEPqEAEw 5N7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392886; x=1727997686; 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=97MJYpYNh2OXN36yrgEntTFOxNkCwTKF272jX4EBFYg=; b=bh7GecA7BwEwQ6WqFAFwRtOmUVisTJA7/C0t1y/uJIwUO0D+4jb9dBx4j8rEet0WKo jBipMIFk695l2WfZmFSv+bQ9Fo13Cy+m+rLfDz2uxQVWkLW4Dy4YO1lciakXn6MlntKx XbjB0RFxujbp1ZvwfFXVdhbLod/u3Qp8ubO9E+IZdy7PbBhE6rV3x5mG5KOrEdehhtI1 lqtRjV0+LacW5mpIba8IHXvzAPGwOPX9jaxs6WM2oyA1g6tR+v60C9+aoOlhfdykXGvL cO2XwT4IFDgVihAvFLosQvD9EjezlutTjN7jdZghwVUHFwMf64UFmweDvdCEUfNgoyR/ j/qg== X-Forwarded-Encrypted: i=1; AJvYcCWE5yOjrXuyyosi903gZvl0dORe2bSCvqp8KlNo53cGjlgVkocsEn0yGooQ5GxwaHrItXoZcVDpnJXXAms=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3UBFSi/YOvXX4F1x7icT3fu8dOQT5DwPzzFFe4t/ZeNtQNKYf ZsEJANnJe1OTJyHfveYW4QaUJZCqAqTiuTnlc3H9sEebu3jQnNHg X-Google-Smtp-Source: AGHT+IGEbTyX4azDhptvTAbyqHSfEzTyPNNE/JgVuXwIVkiF6dJaxNfrq6Yp0EW4PANwfpfda2QaAA== X-Received: by 2002:a17:907:d14:b0:a8a:83e9:43e2 with SMTP id a640c23a62f3a-a93c48f926amr75943566b.12.1727392886119; Thu, 26 Sep 2024 16:21:26 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:25 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:20:55 +0200 Subject: [PATCH 04/18] leds: aw200xx: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-4-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1474; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=d0/jBZeOQ8xCvysG4yJkfCKJi0DJ8XXoa660caQmywM=; b=tR0vcqDoOSP5Z2owKMnAB9bhX8x7lqHl3M+byu6E1aArGwC6Yf4PxLgUabwsOkMjFx/oaq0zI VzAnF+19OBbC8V0VBuGNYGHfa/Q/kR9spuC+zWidBB4bco6IBrAZbCS X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco --- drivers/leds/leds-aw200xx.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-aw200xx.c b/drivers/leds/leds-aw200xx.c index f9d9844e0273..08cca128458c 100644 --- a/drivers/leds/leds-aw200xx.c +++ b/drivers/leds/leds-aw200xx.c @@ -409,7 +409,6 @@ static int aw200xx_probe_get_display_rows(struct device *dev, static int aw200xx_probe_fw(struct device *dev, struct aw200xx *chip) { - struct fwnode_handle *child; u32 current_min, current_max, min_uA; int ret; int i; @@ -424,7 +423,7 @@ static int aw200xx_probe_fw(struct device *dev, struct aw200xx *chip) min_uA = UINT_MAX; i = 0; - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { struct led_init_data init_data = {}; struct aw200xx_led *led; u32 source, imax; @@ -468,10 +467,8 @@ static int aw200xx_probe_fw(struct device *dev, struct aw200xx *chip) ret = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); - if (ret) { - fwnode_handle_put(child); + if (ret) break; - } i++; } From patchwork Thu Sep 26 23:20:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831707 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A4001B150F; Thu, 26 Sep 2024 23:21:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392892; cv=none; b=Mf1kryW2XuNzr+64tVNoOao2sgdV+WOuNnjMqYVIwbanKe0IaHmQ8MrNc+e5hPuBltT9zombNpbscaO3jXLv8Ly81fsZ4iV7lrwQjXPDf965O+EB5A52XlJEYsEeec6CjkkPYYC2LMBwJpsH2qQmoazAGn7TGRe/Pwkj0d7rWe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392892; c=relaxed/simple; bh=ReP7Qr/J0AJ2qUDKb/L8HtY4TnwQiLgJ9A1DOQKpN7I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=DDAJ+74NWCZE0R/vnwrWMHe+bDfqtvWaVKEe4oG/L9IcW7eskeJAib6F72ZRdWmxP2NsPvb1meIgzrQfuL22fNP4LJBLPSVbqi963MfUuaXV6+n1YLWcCWDEQsgrD3l716XN+9H0RY5HEl3bd0Fyg8evZucm3/891jJOM8jR0AI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Ux+DkKbV; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ux+DkKbV" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a8d6d0fe021so244089066b.1; Thu, 26 Sep 2024 16:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392890; x=1727997690; 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=RKtvZEPDH+fIZPKBCRGZ7MZSFbm8PGwqKLmwiboGd/E=; b=Ux+DkKbVvzno4Gm6x8XdNYwXvk0Wfy48f7bKF5Qfozszl8ckpIOW5drtmQycjnqY67 V3P3s0yWBgtmb20+sH09amo7Bflc41OYQxAgYL5y4YOgPjitBU/S5EMjTuS+P8Sm7Tz4 V2TG1uJ0GKH2ATrwMpLn6RuzobWOqOrRxBmuICVOosRGdrE4E5F5wXTJ+T34paf0Q2TY 3brVqDZoIVTayOK0tYqH00u6CNR+ISga0mEl35JZmpl5E7wW9i/CvQemij0vzYXdOeuP guSPsZ4wsIeSayy4//c6cKscy6u0LnT8E+FhOlAwpnl+q5IROq1GUFI0XHeC8GVNB5M/ Z2AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392890; x=1727997690; 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=RKtvZEPDH+fIZPKBCRGZ7MZSFbm8PGwqKLmwiboGd/E=; b=gUd3xKP8QswHmphD/cTB6riFtVjryl2MGP+m01JiTqL4bkEmG95Pm2nsCCtH2YJnKi Fi1JDVdgejB5p9CuVEJ+5ebM6glOwbYkNZFsZdk0aSKMCXQc8JDr5SOE9q0KTkwSUnSk 17vydFv1OEjqCDRMUOL6DFvpn8T5iIz1SmOaW7lrpqMa6lZWMtFzLZNCUbhnXv0+9tYq yqTIDdQqPaAtC+vYDBkd7mehzKSDjqwP5dPUJ5u89tdMqobfeqZDf9gkk1SIBzZIyRvB Sc3jRoJdq1pzxNBQ4JeoG2IbUkijB5q7UL0MxVBfzYwPwcIeV0DLaACGSwFtOjkyjRtq fvRw== X-Forwarded-Encrypted: i=1; AJvYcCWrN28YF9PrIXA7gYYj9mj7H8axy53Hl32Ri5TW5WzmcCFq9+CR8tX0qpSTiSb0/kni52w4T335X3TJFIg=@vger.kernel.org X-Gm-Message-State: AOJu0YyxkZoZ5FFhWWv0x9JlXLzeJyXwCByciuwwbEGNTBWVP9hQi6pJ 4is6WkQwfb7YQ1wZoyHMp+/XokkgKaZOi+VEcCKN/qxeKuFWqiJw+WklnZ/8 X-Google-Smtp-Source: AGHT+IHjxclqmwCts53ey2Mkw8lOf7cm6f6r/L5Uli3GTjR48O81vxvj6U2y1w0YBmydxDpTTVPPDQ== X-Received: by 2002:a17:907:6ea4:b0:a8d:555f:eed1 with SMTP id a640c23a62f3a-a93c4946d94mr84366166b.31.1727392889478; Thu, 26 Sep 2024 16:21:29 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:28 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:20:56 +0200 Subject: [PATCH 05/18] leds: cr0014114: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-5-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1242; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=ReP7Qr/J0AJ2qUDKb/L8HtY4TnwQiLgJ9A1DOQKpN7I=; b=jAh+BzDwMT0vn09JLTdN0MvzxhKKOiSKKW8O/GHNIet44fgm7ZR14Rvbw3/y5IEMMN9dMTqL7 Q05KmODqeDkDJyq7FeIhBaMWdt9zpVsDxf2x/EqmSbBsNmsdTzpoi0R X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco --- drivers/leds/leds-cr0014114.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/leds/leds-cr0014114.c b/drivers/leds/leds-cr0014114.c index c9914fc51f20..7e51c374edd4 100644 --- a/drivers/leds/leds-cr0014114.c +++ b/drivers/leds/leds-cr0014114.c @@ -181,11 +181,10 @@ static int cr0014114_probe_dt(struct cr0014114 *priv) { size_t i = 0; struct cr0014114_led *led; - struct fwnode_handle *child; struct led_init_data init_data = {}; int ret; - device_for_each_child_node(priv->dev, child) { + device_for_each_child_node_scoped(priv->dev, child) { led = &priv->leds[i]; led->priv = priv; @@ -201,7 +200,6 @@ static int cr0014114_probe_dt(struct cr0014114 *priv) if (ret) { dev_err(priv->dev, "failed to register LED device, err %d", ret); - fwnode_handle_put(child); return ret; } From patchwork Thu Sep 26 23:20:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 830931 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11FBA1B1D49; Thu, 26 Sep 2024 23:21:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392894; cv=none; b=N88FyZoeSJrwBTu5mX6zajvVVs0W87uWHz8DNTCeO6vpl+X0qQBahN5VJWzrI/EZWVF7OAnOdOy+LP48Gbfh0AbI3CKt3bdzS0XTo14dexrRvZdtHSoDCsjvfGNU4CewmTA0LOhuLxshnkiIY+UW1bPSf6HqWSl+vCy7KDLWT0U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392894; c=relaxed/simple; bh=V8haQmgnRaMTwlG5K1E7vGaVHwPa1IZaQXMfy8Pe7ck=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=poNoupFvMEXL8RrzVyPyg0B4UwkMyydW8Vh4kyeFO6ASHvhhUM+QM1oE/ge+XcjmsSUt+qkxpcKB/NfkvcV4IvSuSF1MlHgGM0xy6Pq5ZJAkqwAsvLHo7xLrCL2ajr4Q6I40yCUaCUrkJMxTNKOufMwMjM7eg/fvAX8BT5gjzc4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SJzdvAZM; arc=none smtp.client-ip=209.85.218.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SJzdvAZM" Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-a8d2b4a5bf1so181252766b.2; Thu, 26 Sep 2024 16:21:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392891; x=1727997691; 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=SJpECgac0QWqDyY0V1N/RenFz/N/de4tQaF+Hl64Xww=; b=SJzdvAZMc3xuJaeamzKwR0zNL0pmhHKbHtKuJJiRWrsYubGaXfYO7s0KP6guoP+EYe zCrn7kr1mfbGB6cy+hy/1cD13r2zlMmjNWWZk1zC7tLQYGUQUqVz0GuF6AhkePnLsF1z EQ6U3tWbYs/R14w52yH1lvr5S6VlE1aXmnHH6jY5X76lHZuinwwG8oXJGg5MToaFCjVl 3J1HYAdSDnjbxn2KVBhLYW1MGARgVyjvy2ta8TnptQlr3Jq5mtNH1+pPcyzR80Oa/aeD al+D7CIcj7XkbxEQ/kPzL+xV8RUCUBG2sgqNhWyAwdP2BFNts3x85J2ZYzzDDNt/l3fd Ru9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392891; x=1727997691; 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=SJpECgac0QWqDyY0V1N/RenFz/N/de4tQaF+Hl64Xww=; b=qfHMyMwNOw0HrTMNMaodG11Z4znjM5kyvfVgsYAPk2B02GBIImHVDnNHNXucHa0LWA uFKSwpAa2A7UH/RKrY+j90YJmgh7hAexi3F05ZtwBt3UxXorxgmKffsnEj/wOlkttnyz NUsyMvL1ncg0gNWrab2+V5THgH6NmKcRhlnbN2aUGZaYy0RqlE2Rz9xnPHN3oBwv6sdc fbN7WoZPz0upjKFp/bZ3oYcQvUpumxc8k9dSrFEEpoO4+zRTbU9xhaqEDA18f9VkEl50 T/MDnqLRYVjuelnKv3WNhU9OYLjniw2RoYYYtyY0be+fyk2IBUhL0WpeeBEg0OFMlrCp Up7Q== X-Forwarded-Encrypted: i=1; AJvYcCWi29aZ8K+qh2e+lXTmexvtOovlLVNU/6rMJkdhjjHBGgRrzgkUZcBEKYKjuog+u98j69hZ8R5Am9s/LiE=@vger.kernel.org X-Gm-Message-State: AOJu0YzSWTMN8+bKf1+tbgcnXPVi4gjYZe6opcBMj+BIBCh3QDs+gDk0 cvkEcH+h2ooi1xyRzolKctevDucPzQrghzSbTaRuPjqLhMbwLGvz X-Google-Smtp-Source: AGHT+IGSWoR1fCEWrIDtr8bTLXKGUTs29eDV3zKtmwo1hMD14zDFeQuF3IPtFA71mpm1QVUnbVuMZA== X-Received: by 2002:a17:907:2681:b0:a7a:ab8a:38f with SMTP id a640c23a62f3a-a93c4a67dcamr84483466b.41.1727392891222; Thu, 26 Sep 2024 16:21:31 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:30 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:20:57 +0200 Subject: [PATCH 06/18] leds: el15203000: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-6-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1939; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=V8haQmgnRaMTwlG5K1E7vGaVHwPa1IZaQXMfy8Pe7ck=; b=sTqeCbZp2AB1Bc5Bt7/iASwDkXreNOXxX6b+ivRKl7l5AcLYxvapJeVNieVkPiZPuXREO5n0U 8lb5CaGQyzlD8lCR4pv1xcQkTYZrQwZmlV1zDdjGoSHCfLUUuJ9Nwts X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). After switching to the scoped variant, there is no longer need for a jump to 'err_child_out', as an immediate return is possible. Signed-off-by: Javier Carrasco --- drivers/leds/leds-el15203000.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/leds/leds-el15203000.c b/drivers/leds/leds-el15203000.c index d40194a3029f..e26d1654bd0d 100644 --- a/drivers/leds/leds-el15203000.c +++ b/drivers/leds/leds-el15203000.c @@ -237,22 +237,20 @@ static int el15203000_pattern_clear(struct led_classdev *ldev) static int el15203000_probe_dt(struct el15203000 *priv) { struct el15203000_led *led = priv->leds; - struct fwnode_handle *child; int ret; - device_for_each_child_node(priv->dev, child) { + device_for_each_child_node_scoped(priv->dev, child) { struct led_init_data init_data = {}; ret = fwnode_property_read_u32(child, "reg", &led->reg); if (ret) { dev_err(priv->dev, "LED without ID number"); - goto err_child_out; + return ret; } if (led->reg > U8_MAX) { dev_err(priv->dev, "LED value %d is invalid", led->reg); - ret = -EINVAL; - goto err_child_out; + return -EINVAL; } led->priv = priv; @@ -274,17 +272,13 @@ static int el15203000_probe_dt(struct el15203000 *priv) dev_err(priv->dev, "failed to register LED device %s, err %d", led->ldev.name, ret); - goto err_child_out; + return ret; } led++; } return 0; - -err_child_out: - fwnode_handle_put(child); - return ret; } static int el15203000_probe(struct spi_device *spi) From patchwork Thu Sep 26 23:20:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831706 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D41891B07A9; Thu, 26 Sep 2024 23:21:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392896; cv=none; b=mjs0fx53xj1LD8cfzYSg/OypDlLloDKGRT93CK1/ZDu4ZARgfgCc9fD06ZfmclpdTLkjCAmMd4ygXwT4vbIiIbuNMCHuKLrKueLhF8w1rencmVZ4o4WZtTAhdvp064ZumjOiNO7N5TpEOlYM/0DSvf3p1Eh8CRwZaNWIvh8QzaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392896; c=relaxed/simple; bh=YvOQrDMAC/x5xAIds/zbIhc77SSn9FZnaj7kTpsmuOI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pVwWJR0PpJCWzEK0OxwPWmv4bK1RI2U9KIU+DFI6NTsCBvHRbtB6uILSWW0WXxusquI4KQfFZy6ad21VZCgB1TSi693q2q38gU/WR2Esrxxy28BeqtByVz2L9vwVDgNlyI4w5wFBHJR1cyNsGDUVzvgjOkffr694QWOm9uja99c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NF6I7R4K; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NF6I7R4K" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-42cc8782869so14259375e9.2; Thu, 26 Sep 2024 16:21:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392893; x=1727997693; 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=njNW1TfRFsU+HRABWUBqLsQLOj2MxWgzdzaH2G/Qjz8=; b=NF6I7R4K1DRDIkDTMrq17Rc53UTA3qcBio4PRfk9uP97Rvf0tR0gl/ZK3VauyVTqJP uuezL60i8kMSNFGyMO6sT6wvmOKmJ/cu83KVMip+dHGvKmil5CjZFTQDuqS67jntCgJF XAlpDrVpREH6BgrD6xAq2K3RYNgR+AXuAmz3mYJMISIE0bjCNLLdNbLS3IXi8o2MZ+gj +cNv51C4VoLSQbXG5dGLLGl13YR8E1UroD2Iars8Kfj21ShdBE9M64F++q/vO6uKDIm2 SU2Vy4i1bx5DXmZyz/G24E9Q7KdV5A6TvTsMZNVnVjsfT9DsVhhSD/Ve3IaDb/9FpWcJ 7Hbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392893; x=1727997693; 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=njNW1TfRFsU+HRABWUBqLsQLOj2MxWgzdzaH2G/Qjz8=; b=C7HQgcahHePFKM30+LxFmak0sLz2lvNN6RrmP4hu2aBkEC5rS35Ss1N2vrxYtjAKgl J3o3RCavubxmrvbZpMTFsTSJDlTG8D2GGSuVrWT0ODm45s4OTEm246fHW5I3CUfj7Gp8 ypZjr1BBgLKENZqLCeJN8QcyDfp2EarE9Zuwz9KDo1L0757Lo2B1+cCHxYXzQpV1WG2n ngsML6uz2XS1wupq89ByJpoSYTvsAiy9QmHUSaak8Zvt74LNucR2DS3mEYMoF8EcdkfY EWJnTXlJj8K+eXYR68hUXzcoac5T6KT4kEWeKKG3lZ/YqRPWn7+yHibV9bGzLwCwFzdq LwTQ== X-Forwarded-Encrypted: i=1; AJvYcCVb5PCbz4N4uIyhkuxZZfsFf2IAKqqg6bv72XTzYPM251oN1o0Uc2P3q3JPHuf+1iwoxDIMh09cedJn2PQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxGakg+MxjIsPzeQJWCXGxVjae6A/cQoXJ9/7UBaWBrd0rRTSaS EMcKYrTBA3bhobStYwDoG7pSryJXT6hTOCbOLThkKbE4+vi30suG X-Google-Smtp-Source: AGHT+IFoitU4rHzuAlGaN0CepshD8zukebslAy4qEv5jClIy8HmE5FNZn/uF/6GAUB+QSUSFAl2R6w== X-Received: by 2002:adf:f4c8:0:b0:374:b97b:c69 with SMTP id ffacd0b85a97d-37cd5b1b9damr807113f8f.48.1727392892968; Thu, 26 Sep 2024 16:21:32 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:32 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:20:58 +0200 Subject: [PATCH 07/18] leds: gpio: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-7-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1859; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=YvOQrDMAC/x5xAIds/zbIhc77SSn9FZnaj7kTpsmuOI=; b=F2/BmA3k318R3nNJ4o+UdX5dm9/ZS5qzvXg9eIRN46g7PjN1BIAHbn7DjaItKHdhF2qnEkj6C BtRfhRRoXksBEEmVczX8toVRs3aBAvQxOXiWB/l5LPYF47XYVrkWYG1 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco --- drivers/leds/leds-gpio.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c index 4d1612d557c8..7d4488191241 100644 --- a/drivers/leds/leds-gpio.c +++ b/drivers/leds/leds-gpio.c @@ -148,7 +148,6 @@ struct gpio_leds_priv { static struct gpio_leds_priv *gpio_leds_create(struct device *dev) { - struct fwnode_handle *child; struct gpio_leds_priv *priv; int count, used, ret; @@ -162,7 +161,7 @@ static struct gpio_leds_priv *gpio_leds_create(struct device *dev) priv->num_leds = count; used = 0; - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { struct gpio_led_data *led_dat = &priv->leds[used]; struct gpio_led led = {}; @@ -176,7 +175,6 @@ static struct gpio_leds_priv *gpio_leds_create(struct device *dev) if (IS_ERR(led.gpiod)) { dev_err_probe(dev, PTR_ERR(led.gpiod), "Failed to get GPIO '%pfw'\n", child); - fwnode_handle_put(child); return ERR_CAST(led.gpiod); } @@ -192,10 +190,9 @@ static struct gpio_leds_priv *gpio_leds_create(struct device *dev) led.panic_indicator = 1; ret = create_gpio_led(&led, led_dat, dev, child, NULL); - if (ret < 0) { - fwnode_handle_put(child); + if (ret < 0) return ERR_PTR(ret); - } + /* Set gpiod label to match the corresponding LED name. */ gpiod_set_consumer_name(led_dat->gpiod, led_dat->cdev.dev->kobj.name); From patchwork Thu Sep 26 23:20:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 830930 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.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 644091B011E; Thu, 26 Sep 2024 23:21:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392898; cv=none; b=GqsiyeqXRIXVKNRX5UydstWw4zbci19ERkH6yMako0TnspD+AOeewKmj9UzDDFm/xanWaSnc5g8V+Jj0rXfB50xNvTAn3ygJAuaFwsVe6F8Du1qendiL7jbyZOCoC2ksUzeSQYRjrw2Ib671L6AWT7iyPjHXofvPfUs6dWq05XM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392898; c=relaxed/simple; bh=v0iYfIBPWrhBeMk5GmLZkiz62OQVqii6tL7xBG0nuYo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hq00gFDN30PCWikqSE5f6S9TjW8Tvc9Jag+O5nrHQDZYZZOhA2I03XC+ORObWKOwpXz6oDCbCKZDISwo8Lydab39g5ByaZ4QkwfQtiazHoeNiFSGQSfq4XEKEHId8xIbG1geIdkcJUWK6xYRl9jHgP0IPGGDau/ltI7hGtrKWUE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=myN/rJcP; arc=none smtp.client-ip=209.85.218.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="myN/rJcP" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a8a7b1c2f2bso219137666b.0; Thu, 26 Sep 2024 16:21:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392895; x=1727997695; 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=9z03eGnj6iGqYzDELmW5r9JfCTcrG6sf4eOCgWvySkE=; b=myN/rJcPQl/Xt2Mo07MDV9otKzSsI1xTjiJUO5qJ3pJ9wBX8qb0xNywr9eL4T/mey1 dFGeKFN3dxlh5KL5xxsnC//gh8+ta/45Qv04bD3qyKpi4k6IshWhZA4FA4RVXBWFfGtG 5X6yzKgtNZzZpkkfTG38KJxGCQWwnj2iRog8suV63HRSLe9gf3ULDN1FmCEWptHxqQJI ncx1GKC/SSbDVXn73Q/1QoqHwRDty8LtWSQp2quj8J3Meidl9u+JuXjq7my8Blt95oYN ZNRk4O5SFrx+eZBBpJlJ9IMxOCD18ON0Xa5IhOK/MiJQXEyB2XpMAdT7yjPAOTx6nyBv 5u9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392895; x=1727997695; 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=9z03eGnj6iGqYzDELmW5r9JfCTcrG6sf4eOCgWvySkE=; b=Ey1JXFrFq02xGVqVyHC6xpeygbpj68qW86NY/KhQxJUi6y63QQbCs/KE4kzTIejvjW GSs3Uk7YUPXeO2O1AJbt2ScJmqnrDUJD5Nhvf8gw+2X/zkSDtkoUA0QqYtAyIUUjJRp5 iG4NtqRypFwH7wmgstsdw+gXeYT3rGGpZQ3wT60SaRV5xpdvoOqBqvnUnelRLkkXyTyZ 9vF//WFO4oIKDEpWEvZ+xn7IyCrw4yCNX7iB5p74zfUEqgZXl9TV5QgH1ribqZeyLYIX SZNcsAOyzrnvDO+VZx22MCpFVDtlktkLMhj2DBtwOD3u8f+HbUVz6gtf6hwqZ+J/q4jV N8JQ== X-Forwarded-Encrypted: i=1; AJvYcCWnMd194ejSlA7QC9tUMkL4S32tG4cECi2LiR0iQQN+4hywwTd/MEoqgfekVGXnU3vd3r61qPGdkt4l+e4=@vger.kernel.org X-Gm-Message-State: AOJu0YxDkyM27Ry0WtqLHjxY1vrF3fEscFqc/q+QDwLts7/C5qX50uhk CzeIKJLCr+UqxAY1dY6wUBYWHbTNCXEjjp33/the1xmFt2LKZ9spM23URfMT X-Google-Smtp-Source: AGHT+IHzRwIU6UAzlavm/QZ6zyKdlkN5H8May0eKhpEiWtxIy3j8Q0eikPpKvoRwQ2Ar8Be+Bn0Hew== X-Received: by 2002:a17:906:4787:b0:a8b:154b:7643 with SMTP id a640c23a62f3a-a93c492a5dcmr98770966b.28.1727392894740; Thu, 26 Sep 2024 16:21:34 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:34 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:20:59 +0200 Subject: [PATCH 08/18] leds: lm3532: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-8-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=2745; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=v0iYfIBPWrhBeMk5GmLZkiz62OQVqii6tL7xBG0nuYo=; b=vv0qMx18gJDO2AXmo395Dj+OG11mPwp0TR26/SNLfM9jrHi1Va8TeNdbSx8stlq/n+ILIf4c3 gYOYGMQVm0qArDwfN4d+6vbuDJ3QihySKHfjHS8w1myjgZBJRpxCUpZ X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). After switching to the scoped variant, there is no longer need for a jump to 'child_out', as an immediate return is possible. Signed-off-by: Javier Carrasco --- drivers/leds/leds-lm3532.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/leds/leds-lm3532.c b/drivers/leds/leds-lm3532.c index 54b5650877f7..24dc8ad27bb3 100644 --- a/drivers/leds/leds-lm3532.c +++ b/drivers/leds/leds-lm3532.c @@ -551,7 +551,6 @@ static void gpio_set_low_action(void *data) static int lm3532_parse_node(struct lm3532_data *priv) { - struct fwnode_handle *child = NULL; struct lm3532_led *led; int control_bank; u32 ramp_time; @@ -587,7 +586,7 @@ static int lm3532_parse_node(struct lm3532_data *priv) else priv->runtime_ramp_down = lm3532_get_ramp_index(ramp_time); - device_for_each_child_node(priv->dev, child) { + device_for_each_child_node_scoped(priv->dev, child) { struct led_init_data idata = { .fwnode = child, .default_label = ":", @@ -599,7 +598,7 @@ static int lm3532_parse_node(struct lm3532_data *priv) ret = fwnode_property_read_u32(child, "reg", &control_bank); if (ret) { dev_err(&priv->client->dev, "reg property missing\n"); - goto child_out; + return ret; } if (control_bank > LM3532_CONTROL_C) { @@ -613,7 +612,7 @@ static int lm3532_parse_node(struct lm3532_data *priv) &led->mode); if (ret) { dev_err(&priv->client->dev, "ti,led-mode property missing\n"); - goto child_out; + return ret; } if (fwnode_property_present(child, "led-max-microamp") && @@ -647,7 +646,7 @@ static int lm3532_parse_node(struct lm3532_data *priv) led->num_leds); if (ret) { dev_err(&priv->client->dev, "led-sources property missing\n"); - goto child_out; + return ret; } led->priv = priv; @@ -657,23 +656,20 @@ static int lm3532_parse_node(struct lm3532_data *priv) if (ret) { dev_err(&priv->client->dev, "led register err: %d\n", ret); - goto child_out; + return ret; } ret = lm3532_init_registers(led); if (ret) { dev_err(&priv->client->dev, "register init err: %d\n", ret); - goto child_out; + return ret; } i++; } - return 0; -child_out: - fwnode_handle_put(child); - return ret; + return 0; } static int lm3532_probe(struct i2c_client *client) From patchwork Thu Sep 26 23:21:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831705 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BAFA1B1D6E; Thu, 26 Sep 2024 23:21:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392899; cv=none; b=IdrTJ8ow41o/oHMUL81nO/RKlrs4aUdo3N1pRnJZNOBkV3jMc3mII5deWUp22+zPYjL+YTTXf2cIYofjoMJ6VujCwVIjnhwEgKbPxCB0xMlqteswJ4ZsLaGhBdiObjyTwzo/eKRB9EnJMcY04fFyjKZxaLvoTly80V8KN3VX6Xc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392899; c=relaxed/simple; bh=fs0ieuWlVTuCmcLPVCaC9tRU1u41+9gEsw3Vo/oP6MU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bxvJWAaLoryF9rS7lD4MYxCbgJFqGc3RegJ8anSbES+N76UPkKhh2hHTznJyRxWuaYvb165F29eakA/aKnFxGhis2JSbU+6gmIqcybE9TU00Bqmo3ISbJ+LJAHjyMjDzpHDrcC/RQ5enPA0pnUxE6BgyV7kZopnrBkx4wmPY5t4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=m5eMFceH; arc=none smtp.client-ip=209.85.218.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m5eMFceH" Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-a8d60e23b33so205020466b.0; Thu, 26 Sep 2024 16:21:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392896; x=1727997696; 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=SQNsFzUPUUPsb4bHTQ95hMBvvP4G234MZae0hcpLMbY=; b=m5eMFceHfJGEwqpIquUFJdMdfLUxmFUd/tWymI+6SKLZwiWOi1XQaM/xh2sWwqD5U9 LBbcpAFCAinGrwW6kNYA6cjuDeqK6ksjT/1xrZ6iEBBwKJaMn6KYsRtZgXVCTy7fHyFj pKJFJfr8sb+8Ssa4hhfCibPQbHExBNXmFb38oRVvE8BQiV93a1FM+LvMJ65XEW4auo1u /tdwNfNFMEwTUqiKOdUN4KkbdMZ16Znoz0DcD0Un+kYAeDpiVK3JlzLRJ/nsLVlhbMeA fc053Gg20ANLXXEUXp76sDXT0htXBRpJWnLtFAxlnnperwwCKYGIusIYbseb7uQwurS+ WeWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392896; x=1727997696; 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=SQNsFzUPUUPsb4bHTQ95hMBvvP4G234MZae0hcpLMbY=; b=SCUAVYplG04vIq/m8W8PypjtZk/1WSVOCJhfd1Kw9XNpt0WxcbR+Wd6FOneAnBNChb 6U85mmpgXbruxFnrX1ZaHb+obmmv8yEWbv6dgaoW1t2aKz83BiUaZkrTPmyAZWgnIZsD cPTZc/0rUtbBXVbRfWBTWO7xl6GWQsleeeIDiSKdRjyniry+TH/euXXQzn1vAyPZceZL GR/TYn0lxv6Er2NjZVUyipeS9U4rN4MNmqLJFgjUNOjokw9YqSPEvigJ0cBYGBEIJK6d 0gMXTAPVhGLIuBrk1oL8hnluAuvGc/OxZmfUd2Nd3NEJ0F1L9ywahO/aIzHMEFKqaAqn 1+6g== X-Forwarded-Encrypted: i=1; AJvYcCVVf/IPmA4r6jOkW+bKc9emZx4cj6lur1Q5PQn03BqYiKQc73As/GllurJM9G58bKTAwvhp8CptSjMa3p4=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6i6O8yWkSzsCJ28TY3Z3G8f2/qj6rSTwKPFtvxiSyZumfsoXe k6eHsmqzBx2wsJ0feQfoLfC6D5IhcwfUgh29KDPZBA6+bPjgc5AX X-Google-Smtp-Source: AGHT+IEyOGNZ71T4Vzvgj3bKvi7dihBSn/dSInDBzZVsM1XUQPQ44OJgPDcuSpfwKzM4zpJDbvxA3w== X-Received: by 2002:a17:906:794c:b0:a8c:d6a3:d03a with SMTP id a640c23a62f3a-a93c491f3b2mr103908966b.21.1727392896321; Thu, 26 Sep 2024 16:21:36 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:35 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:21:00 +0200 Subject: [PATCH 09/18] leds: lm3697: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-9-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=2273; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=fs0ieuWlVTuCmcLPVCaC9tRU1u41+9gEsw3Vo/oP6MU=; b=W7PpV2kxni+RR0wy6YwJI0c2sUNCxXu+i08YXpIMr6XkyMRvsaXGdZ2iuGj13YAu0Wxs7NeRP b7bgPKb5Zo6AJcco0ow/T7yOT/DNC6kxjWbdvRLSxzKncZ93rGydqGU X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). After switching to the scoped variant, there is no longer need for a jump to 'child_out', as an immediate return is possible. Signed-off-by: Javier Carrasco --- drivers/leds/leds-lm3697.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-lm3697.c b/drivers/leds/leds-lm3697.c index 99de2a331727..7ad232780a31 100644 --- a/drivers/leds/leds-lm3697.c +++ b/drivers/leds/leds-lm3697.c @@ -202,7 +202,6 @@ static int lm3697_init(struct lm3697 *priv) static int lm3697_probe_dt(struct lm3697 *priv) { - struct fwnode_handle *child = NULL; struct device *dev = priv->dev; struct lm3697_led *led; int ret = -EINVAL; @@ -220,19 +219,18 @@ static int lm3697_probe_dt(struct lm3697 *priv) if (IS_ERR(priv->regulator)) priv->regulator = NULL; - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { struct led_init_data init_data = {}; ret = fwnode_property_read_u32(child, "reg", &control_bank); if (ret) { dev_err(dev, "reg property missing\n"); - goto child_out; + return ret; } if (control_bank > LM3697_CONTROL_B) { dev_err(dev, "reg property is invalid\n"); - ret = -EINVAL; - goto child_out; + return -EINVAL; } led = &priv->leds[i]; @@ -262,7 +260,7 @@ static int lm3697_probe_dt(struct lm3697 *priv) led->num_leds); if (ret) { dev_err(dev, "led-sources property missing\n"); - goto child_out; + return ret; } for (j = 0; j < led->num_leds; j++) @@ -286,17 +284,13 @@ static int lm3697_probe_dt(struct lm3697 *priv) &init_data); if (ret) { dev_err(dev, "led register err: %d\n", ret); - goto child_out; + return ret; } i++; } - return ret; - -child_out: - fwnode_handle_put(child); - return ret; + return 0; } static int lm3697_probe(struct i2c_client *client) From patchwork Thu Sep 26 23:21:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 830929 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B52F1B29A9; Thu, 26 Sep 2024 23:21:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392901; cv=none; b=GYO8kQuEvIuQGbzPOKc4GaxQ12McxBB5yWj2w6e0gSszj3Jby2y/SDxbJEV/svO2wTuQTChhh5hTXRGz8/96i+8frx9VULuGYiaaXlMSb2ZS+zLQQozIkewgv/8e5MYrgnfc2LkDG0ekzbieh25v+OP7uEttmzFD7dAi+QYVe9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392901; c=relaxed/simple; bh=wVCMNpNXMBYRf/3Qo+CvGWvj1uX3gLZ/0II5tIZcKP4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LNYFIRp9esC71/19aNujp1SVlBWJeW/Zzq897F1NbEbKmcqPBiB/d1LKqPxWxpJ2tAuUaDLaX/u8a3VzKpB0Ikq+YbE3SQWnc4qb02QLzu4spxXMxHxobNBvXzCONI55E7OeYPm+pQhS+65oY+YZuJ6FasokIBFGaRt2Q2dBps4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=jCEsEMwj; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jCEsEMwj" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-5356bb5522bso1911727e87.1; Thu, 26 Sep 2024 16:21:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392898; x=1727997698; 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=SbKG8yQzAXSNKnNqMlC3vDG+SObBOdoBsMSFHrHh/gQ=; b=jCEsEMwjpKHyrTRIIUajscpo1nqwp3l1TzBhgSiWhP4Yg5bShrCR5/qIc7U5jEDafd GNKdzrMojjd47YYosAFJNiXGQmn1kSHFr2lh99TFtJWAzz8WX8oMO+jouHqIo4bfXg6h 5G5+oAlO03qbxbKHMr9ar2Qk4LhQYxKdk5oiKApiOm3XmaB5S786BHZ7tKq2F4FUgclM /Ed1oArOu7HjedBHYvWpI6L+vrmuibJlSLurtC62ngJQIP1Dz+Zgre3eE/4RpQ7hqwp+ xUaH7QTnwqCXcejqIH9d23LN8usWnj9efokNyD5nUS3axOSnQukqE+qE0MQB3i82O8qy Oilg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392898; x=1727997698; 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=SbKG8yQzAXSNKnNqMlC3vDG+SObBOdoBsMSFHrHh/gQ=; b=KhZVKI3Q7KVwqdD9JSYc8SIPWqD044QRh8mflt9uPLvNKnyVX8mlKFptL/CwDYii34 dxAcYSV42nceBBsKEe6DxkU+GDZLw0sWYdtTSz8GNSq36RCIMXIcTg6QlP30QEH3A7yd B+yTU14GqpvcCQtmm+5LNUMLG00FSHX+9440yurqRfMNRvE0gl6lz8wKK38HKk5I+wzN PG7cGY8Q4dGF3qDiiVPMmGpHqUQbvUnoO3konIDkCVW1W01B1rAzkGu8nhCsjEwKZ9T4 yThkqakYs1NOCvOs+qTNbcQtetfL1wi/FFxwK10HYYspdbIX1fC/XLyO7z09HRP3+mIn eDnw== X-Forwarded-Encrypted: i=1; AJvYcCVtbPBAut/EhNo1EIpgBVoJG4pt1G2+fF7W9MGnhUMxriW53sVur0AI4aghyW+ryJxPdYbQeHEERw+Vqw8=@vger.kernel.org X-Gm-Message-State: AOJu0YweKgOfnxVxCx/dnt7tjXxJV9SnljZAn/0OHz65vg5EkbcxdMye xMat+8I2daiZcGwv+R5ztYHebeJYPGcDJIkku1EOhkfGk7yUEBjG7aoCVN8e X-Google-Smtp-Source: AGHT+IHargOBULwRmlTYho66CY6TIIKNF6jhPFgs1jxdfin7EzZ3x+Ihx+4IF9Pdg3mdG2UXbYfTUQ== X-Received: by 2002:a05:6512:3b0e:b0:533:4477:28a2 with SMTP id 2adb3069b0e04-5389fc3bd4cmr983572e87.16.1727392898039; Thu, 26 Sep 2024 16:21:38 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:37 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:21:01 +0200 Subject: [PATCH 10/18] leds: lp50xx: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-10-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=2725; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=wVCMNpNXMBYRf/3Qo+CvGWvj1uX3gLZ/0II5tIZcKP4=; b=gvqzp5RpDFRs+Bq7QHctcXoi4uXIDmfAqWPfacNwek7XmLGTnkrq8CcrnDg8YhcpKi7G9Dh5l Mj0YUm6RICjA0yWhlPqzXPpjj3PJpAdJDq6e44FbnnPGX71dsvI63Wq X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). After switching to the scoped variant, there is no longer need for a jump to 'child_out', as an immediate return is possible. Signed-off-by: Javier Carrasco --- drivers/leds/leds-lp50xx.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/drivers/leds/leds-lp50xx.c b/drivers/leds/leds-lp50xx.c index 175d4b06659b..32ca45aec76c 100644 --- a/drivers/leds/leds-lp50xx.c +++ b/drivers/leds/leds-lp50xx.c @@ -434,7 +434,6 @@ static int lp50xx_probe_leds(struct fwnode_handle *child, struct lp50xx *priv, static int lp50xx_probe_dt(struct lp50xx *priv) { - struct fwnode_handle *child = NULL; struct fwnode_handle *led_node = NULL; struct led_init_data init_data = {}; struct led_classdev *led_cdev; @@ -454,17 +453,17 @@ static int lp50xx_probe_dt(struct lp50xx *priv) if (IS_ERR(priv->regulator)) priv->regulator = NULL; - device_for_each_child_node(priv->dev, child) { + device_for_each_child_node_scoped(priv->dev, child) { led = &priv->leds[i]; ret = fwnode_property_count_u32(child, "reg"); if (ret < 0) { dev_err(priv->dev, "reg property is invalid\n"); - goto child_out; + return ret; } ret = lp50xx_probe_leds(child, priv, led, ret); if (ret) - goto child_out; + return ret; init_data.fwnode = child; num_colors = 0; @@ -475,10 +474,8 @@ static int lp50xx_probe_dt(struct lp50xx *priv) */ mc_led_info = devm_kcalloc(priv->dev, LP50XX_LEDS_PER_MODULE, sizeof(*mc_led_info), GFP_KERNEL); - if (!mc_led_info) { - ret = -ENOMEM; - goto child_out; - } + if (!mc_led_info) + return -ENOMEM; fwnode_for_each_child_node(child, led_node) { ret = fwnode_property_read_u32(led_node, "color", @@ -486,7 +483,7 @@ static int lp50xx_probe_dt(struct lp50xx *priv) if (ret) { fwnode_handle_put(led_node); dev_err(priv->dev, "Cannot read color\n"); - goto child_out; + return ret; } mc_led_info[num_colors].color_index = color_id; @@ -504,16 +501,12 @@ static int lp50xx_probe_dt(struct lp50xx *priv) &init_data); if (ret) { dev_err(priv->dev, "led register err: %d\n", ret); - goto child_out; + return ret; } i++; } return 0; - -child_out: - fwnode_handle_put(child); - return ret; } static int lp50xx_probe(struct i2c_client *client) From patchwork Thu Sep 26 23:21:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831704 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84A261B29C4; Thu, 26 Sep 2024 23:21:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392903; cv=none; b=rEE8PizexV2UnrOiqgAtzQHTGqO6wCcYejRT8FD/fZ8oMXbURSw0LfHgrneKz3Rdgo+1i1aDndPEGj1dN6xoqDxBwxYhKXrimmfeMT6JL09wOleVBLQW1Ahn6rc5RZP1WmNSpKcvOPiUT7OP84QLjHU3j1mVKcv01NdNu5h1vqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392903; c=relaxed/simple; bh=GGAv58INZAAcONt61Bpt35Ntgip4w7Gu6UUVWWUtppE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V4lPHeqkspIfKvfiZvqqdeFzb8414DhXtrXcNMpPJMI7WHEo95AEVgmsNCTFvvv4JS9GDVfIr6qsOEPXgYUxgK/jXhBPdXpKgQ+dVJW/NBiu1iTXxOngI+z+G8Gl7WRFDfDi7sB6ibDmlRobmLXveSGavb9uGCGDElQNeObuNug= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JwQTNoX/; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JwQTNoX/" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-374c3400367so1338900f8f.2; Thu, 26 Sep 2024 16:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392900; x=1727997700; 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=QsOsZwrJIVejL5A3KYmk/iH+gmiGbQUrbC+6txQSDz8=; b=JwQTNoX/tM81HF+rgHbgxoy4Ap1iVaDYgSbYFJGjxq9XTdEmwx345v3WdO7kcq8ifK hX/S7vxLXd7POLS3FMLJ80qVhC0nFef7dzM1Q/kl2ebjremjK4c2x5HJ5TNOEt/3C36x IT+ZP6s4vMNjYztEQd5sMqxHxR+7TIEFKAfk/BD0qb0uAgEiTlslcPzJ9L1p/kdvduck 5L7i8Nid/3NrVPazsX3l3VQh4/HKxeSm3P97ObXxPnqWVtYAqcvM04ulIOwZsin1fMCV SLIMoTj3awqAkrG9OVxFMNkl48zoaKkmNMKjl3A6fbWj2p7hfUWC3MsSZKa5TexqaDvC Vx/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392900; x=1727997700; 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=QsOsZwrJIVejL5A3KYmk/iH+gmiGbQUrbC+6txQSDz8=; b=tyY61cP5kTlcYahkxKSBAbnRYkja3yqP594mHdTrV3GpCW8y4NNvwiJoy8ST5kNkGr 47nY5veji5Wf1eclW+S4PaMvCWhW0+ZFog7aK8E3063eCBuAoYyaXE3A5Af/SAwl7MVJ FOzIE4fP/O1A/Ggf+pQVbBz2FarmUFpE/FDYYU6Aso5I/Jh6DIbIVu8lKX4oCInGKl2+ bIgPDRwvUIdpdZxDqCiijn6Lks9Pr7J9uE4mLmm8PrUZSpHa4e8FPHBxmThk2jKA97LT ttwKhDxYB4XIar2iuu4UFsrncoIRqEG7xxDeAm/VlPBlPutUSAsnOP4bHq4R0inyekxo vTwg== X-Forwarded-Encrypted: i=1; AJvYcCWOgnYEB/Rs+d2RO3+5PJgrCnT3IYdwP1E37yvarEomSMAiVJZB3n39iApnYQWCmphtlbz/EeruniAQeAE=@vger.kernel.org X-Gm-Message-State: AOJu0YyIfKEJHr9Sm2y/+7riHV+fABYUbbdN5iXwB+fNUfXxz4rxvp40 yVHos06IIeyBWjpLmpOmDwmcFtw++OF+yr3tMM9FCkVxpP5dQTL4 X-Google-Smtp-Source: AGHT+IFUS8qz9IpKL5ZcAZ8OyFyLvVNgici/BBziOfQFbnEaYTDdxY4F9CAtftsOOYRvJ/CoOPKo9w== X-Received: by 2002:a5d:574b:0:b0:37c:cf1a:b2a8 with SMTP id ffacd0b85a97d-37cd59def87mr961455f8f.0.1727392899862; Thu, 26 Sep 2024 16:21:39 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:39 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:21:02 +0200 Subject: [PATCH 11/18] leds: max77650: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-11-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=2297; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=GGAv58INZAAcONt61Bpt35Ntgip4w7Gu6UUVWWUtppE=; b=8bF3DQ/2DWcbOXH4dFor2UErTpk8gkcWEtJam43Nw0mF8/Zn9foJ+D7oYX405KrNhZyrd0vzr F5Z7Ns6Yd7HCiI8Ke73l2dScfUxJ1IBnD7u7ujtB4pnx6fEvO1lSltl X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). After switching to the scoped variant, there is no longer need for a jump to 'err_node_out', as an immediate return is possible. Signed-off-by: Javier Carrasco --- drivers/leds/leds-max77650.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/leds/leds-max77650.c b/drivers/leds/leds-max77650.c index 1eeac56b0014..f8c47078a3bb 100644 --- a/drivers/leds/leds-max77650.c +++ b/drivers/leds/leds-max77650.c @@ -62,7 +62,6 @@ static int max77650_led_brightness_set(struct led_classdev *cdev, static int max77650_led_probe(struct platform_device *pdev) { - struct fwnode_handle *child; struct max77650_led *leds, *led; struct device *dev; struct regmap *map; @@ -84,14 +83,12 @@ static int max77650_led_probe(struct platform_device *pdev) if (!num_leds || num_leds > MAX77650_LED_NUM_LEDS) return -ENODEV; - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { struct led_init_data init_data = {}; rv = fwnode_property_read_u32(child, "reg", ®); - if (rv || reg >= MAX77650_LED_NUM_LEDS) { - rv = -EINVAL; - goto err_node_put; - } + if (rv || reg >= MAX77650_LED_NUM_LEDS) + return -EINVAL; led = &leds[reg]; led->map = map; @@ -108,23 +105,20 @@ static int max77650_led_probe(struct platform_device *pdev) rv = devm_led_classdev_register_ext(dev, &led->cdev, &init_data); if (rv) - goto err_node_put; + return rv; rv = regmap_write(map, led->regA, MAX77650_LED_A_DEFAULT); if (rv) - goto err_node_put; + return rv; rv = regmap_write(map, led->regB, MAX77650_LED_B_DEFAULT); if (rv) - goto err_node_put; + return rv; } return regmap_write(map, MAX77650_REG_CNFG_LED_TOP, MAX77650_LED_TOP_DEFAULT); -err_node_put: - fwnode_handle_put(child); - return rv; } static const struct of_device_id max77650_led_of_match[] = { From patchwork Thu Sep 26 23:21:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 830928 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.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 4B19A1B2ED0; Thu, 26 Sep 2024 23:21:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392905; cv=none; b=ZRuH56q08UeOjkg5QMJKJJwzG+1sqFhuymObZJsAmGfnN/f9yNQS+L9GDJUv7fKkwiEJhLxTVApVbPU54LfDYnVikxkraYAV/yD7X2tohKTnmEBU2liBdrbFwufAZKnV4bY24T1oBCxooYGwYfHPaESTr+0uH4TIyL3TnQh7lEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392905; c=relaxed/simple; bh=Jz/4B/tgbBWqjdHctAGZYjiz0MxFy7WzJiMpp8ER/SE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Pdl6t8EpIsS2VFBTMc5F7UcQ1h52DPKJYyaJW03vPtrDpo0TeLjnRZOiRVWHQxKwzHTw6ANA3i4awtR1PGbidrLAnbnAEe7WRwe69iG5uXfYL/t+eZNv160kR8X3QmEBFismJvRuopAqsRjeO1MjmxdPQI3fJXtsSrOXnD90c7Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JAaxqIAD; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JAaxqIAD" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a8d2b4a5bf1so181261466b.2; Thu, 26 Sep 2024 16:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392903; x=1727997703; 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=m7h6S8dVKu0rivFQ344WPkvtRjYXL2xD9tqPuM/hQA0=; b=JAaxqIAD4cdQDqpMNzdT+aLhoNN3divup7toGEUs/QwdF+7zcFGz1N6yw8NAnwYH1J 4IatnLyl1GJ6Nja6i6mLGR9MTCeDlvyrLdUbwsOI8zkUDtZ0FWrCnFwtcRAt8yFrrxrC aLycCwcTAa8HqYFYvVrjnMtvosYj6XSxagPdNNrtXykvlx6b6XPjCJzVl47yEB76hDSK 7nTtF4Q+1rEX4CMmsWnKT10euxLnw3yLMgx5vVtbRRvI7s4HHV+JUhBx6hgkxYnPfrO1 LH9DmfwQ+2JWrjXT4+TfzJchza162e2xlApptN1IC80v6rhEUvcFZHJNm7i+H1luLS7E kKtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392903; x=1727997703; 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=m7h6S8dVKu0rivFQ344WPkvtRjYXL2xD9tqPuM/hQA0=; b=A3T52sHgZm+3KwPlI7sl/wqvvzVGjF79b+9Kkzs+bbKbY44waWdo/qfUqojRNHZ0iH lljp2znhfkZOup5WDKAm6axI1mgstYdBCcFEK8J0UK8+wy/VVV5pbZqr8bH9xjrl/5M2 1wZAILt9IpUf2uze6b5Z+JvOxy/9bQ8LaHKegDnkSvhHk/B8mXNQN05v5pMzFNA2wwbX /V0nV0xZgQMicGrtvnSjgrygAmOVGY5u01MzSU3gvTko9uQFHaNhM7PzRiO29E8K6wQo VcKKQVlRDB0MAXr4fOog8Rfi4nsIzvMQwuPO3Lziu99e13/fv2lEF2z8HhQ8utRJ2Enr X3eA== X-Forwarded-Encrypted: i=1; AJvYcCVQvmDyAQqFUG9GCHnhOlFbSyztY6S1/pFbV+tyk2rWef/93amDNvVRtOw7OUk/oIK0ac2ZilqWXEmTsWY=@vger.kernel.org X-Gm-Message-State: AOJu0YyOdeILt1PxtqQIMuGO1EAiP03aQWV8N5ISNPakwCO+sn9w6Uz+ FCQm92GEx9EvEFWx7FksrhZY33JD5iRVgAR//yC4z625ysGNR3c2tJ7debE6 X-Google-Smtp-Source: AGHT+IGvoYtTRlxo+ZCSr+7IZ7oL03DwfddA8kVTy/0vVLsrqZIZv4yAr3ANwPUYnXfyhoxnViIYyQ== X-Received: by 2002:a17:907:3fa2:b0:a8d:29b7:ecfd with SMTP id a640c23a62f3a-a93c4aab828mr100357366b.54.1727392902592; Thu, 26 Sep 2024 16:21:42 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:41 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:21:03 +0200 Subject: [PATCH 12/18] leds: ns2: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-12-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1248; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=Jz/4B/tgbBWqjdHctAGZYjiz0MxFy7WzJiMpp8ER/SE=; b=qKqtyfzAGtYGnjb8UqcfA9/S/SX/eIKdm4rVtvNbSdblTDBXwzHMlUAHLJLiyKXWonL5oGDQU 78Jcr4LvBg5AaqQMyyw/4oVbokWmBpUiGyTqttgSpH73fYZpZIVLpnW X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error path. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco --- drivers/leds/leds-ns2.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index f3010c472bbd..4c6f04a5bd87 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -238,7 +238,6 @@ static int ns2_led_register(struct device *dev, struct fwnode_handle *node, static int ns2_led_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct fwnode_handle *child; struct ns2_led *leds; int count; int ret; @@ -251,12 +250,10 @@ static int ns2_led_probe(struct platform_device *pdev) if (!leds) return -ENOMEM; - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { ret = ns2_led_register(dev, child, leds++); - if (ret) { - fwnode_handle_put(child); + if (ret) return ret; - } } return 0; From patchwork Thu Sep 26 23:21:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831703 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E93001B2EFD; Thu, 26 Sep 2024 23:21:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392909; cv=none; b=qXwpQndlK8N2/TqT0XHlAkb41dv1mOszyORGPPW8ghIVNeZNjNJ7ofYcoAOeVhucirwSBUNtLXhp7g+YUTVDLvrkbrYSeLtQQdUQ8KTXy0mfcQuV6I8tCKwOR2i6JmYEEMTpw1RQaeNtrPb9wbnLYJsxeNclQB4rAwl7r0a8P6M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392909; c=relaxed/simple; bh=Pv0inpasEwKB4z2yQMzZWyX6wkHoCypZJXtRjmgK+mU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=M9rM8D1lCc8RPRdYJON12KMhy/xI4nF6hamuYsZ5mBJtciEIf65GcknDr5CsAllu6l+sccBHaiuzcXqf/4GbsSwJujtMakxXOFlLD9ZZJ5QHQQxfL+FgPQzOAFZma+fTB4o6VsIKL+eCixF2acV4WwN9/3XnE9lUWrJzlZY7+qc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l1rrjzic; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l1rrjzic" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-5c87ab540b3so1725333a12.1; Thu, 26 Sep 2024 16:21:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392906; x=1727997706; 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=TyRYSLB4FUMG7ZQozSGEenWyDF3XZ2iz0mCpEEN+5z4=; b=l1rrjzicrN/g+TOD/i9h2UJo496dGFW2cKYHgoCWwZhTgeoT3cmP/Cd2HYUfHgrjXQ PXCIZjTmVvpzb2jRubm7NIu+0dCZ1Se/HQpEqD6HsVM2lL5efKocpK1VxMmTnYoD1s+v /44fQr8JDJOAltYes7hI0bWO9nNGokkYHvusbRlQibBHzutDvn33dk4PVGd+a1xV5usr habGImawYyzLVF8aXDbqGLQXJMJeNs21yiTJlvSrVES3Ncg1bB8M86WrJKjkv0D+DETZ cnoVfHcNUUGEbl2XVeW0EXPkKkjejp/azWYPfiH8BaFa1YFmSiGw+bHQGPEf564CyanR FnwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392906; x=1727997706; 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=TyRYSLB4FUMG7ZQozSGEenWyDF3XZ2iz0mCpEEN+5z4=; b=awRcb7BfANLJVkjexEzqqtLubxOmjmhocUx7sEquqShPXxByClbGGhhRAczN08F71l RA9AQ7M5JvAQFQ3MZVShU1hj8Hg0KfCI71xyQSeyJabYrIlzUFwvxLXkJ6HP4eYne4bY mR9nrkYldDCGk/iaxao5vXV/9lHFovJHrSs0t4e1ttcbI6ud+lX/CvKssaX7/lQQxWlR EpVaeIN5rNA3IjR27WgoSAbOV8nOJIW2WFZHcrzmzB4Lem6DkL8yYYA1blbzebYfDGUP Vdlb/eQtEyAN4Gqcvn2nqcgZwvT2bul1IhuhvEzF2B80/yAAuNvdCr5k0HCRGdcq9AlA zXAA== X-Forwarded-Encrypted: i=1; AJvYcCUuMQ8Q9IJEfNiJrGKhaviu2a5v1jvSJQKiYe+rFwI/0xoJRvF64gT7XOrq5KQOjUpPDYvqB596nNqW4K8=@vger.kernel.org X-Gm-Message-State: AOJu0YzgbrkiKLbRwHrOeKQxrnAWgXcEWO8xO3XMGh9c1u554BwJGJx1 JyQB0ZJhJnK7dICZ+9JfMVilYjq9raGAzdEWxL1iT61YYnVJh0asVW6n7dSL X-Google-Smtp-Source: AGHT+IF2h6rfpoYNPcv3IJUyf/0VxJB+Tzg7enQ3X9qTLHoriZAfUF5SXe05FRA9//n3nOpoi2FKjQ== X-Received: by 2002:a17:907:36cd:b0:a7a:acae:340b with SMTP id a640c23a62f3a-a93c32119afmr152457166b.31.1727392906224; Thu, 26 Sep 2024 16:21:46 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:44 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:21:04 +0200 Subject: [PATCH 13/18] leds: pca963x: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-13-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1968; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=Pv0inpasEwKB4z2yQMzZWyX6wkHoCypZJXtRjmgK+mU=; b=4OyN2lOQijDJ7XTOSToVZf5Jm5nLKGku+MN88b0WkN8LPNF8MQ75n8vIksJCldHP70NcDZrab N/kVJn2HWk2DcMaBUelGlqT9fiv7ll/wbB/w8wUBdi5v4GKnZbdtw3R X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). After switching to the scoped variant, there is no longer need for a jump to 'err', as an immediate return is possible. Signed-off-by: Javier Carrasco --- drivers/leds/leds-pca963x.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index b53905da3592..050e93b04884 100644 --- a/drivers/leds/leds-pca963x.c +++ b/drivers/leds/leds-pca963x.c @@ -306,7 +306,6 @@ static int pca963x_register_leds(struct i2c_client *client, struct pca963x_chipdef *chipdef = chip->chipdef; struct pca963x_led *led = chip->leds; struct device *dev = &client->dev; - struct fwnode_handle *child; bool hw_blink; s32 mode2; u32 reg; @@ -338,7 +337,7 @@ static int pca963x_register_leds(struct i2c_client *client, if (ret < 0) return ret; - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { struct led_init_data init_data = {}; char default_label[32]; @@ -346,8 +345,7 @@ static int pca963x_register_leds(struct i2c_client *client, if (ret || reg >= chipdef->n_leds) { dev_err(dev, "Invalid 'reg' property for node %pfw\n", child); - ret = -EINVAL; - goto err; + return -EINVAL; } led->led_num = reg; @@ -369,16 +367,13 @@ static int pca963x_register_leds(struct i2c_client *client, if (ret) { dev_err(dev, "Failed to register LED for node %pfw\n", child); - goto err; + return ret; } ++led; } return 0; -err: - fwnode_handle_put(child); - return ret; } static int pca963x_suspend(struct device *dev) From patchwork Thu Sep 26 23:21:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 830927 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.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 05C731B3728; Thu, 26 Sep 2024 23:21:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392911; cv=none; b=QtDPglrud8LxVD+FT+7RHR4yZvZvbEG9SFqVHIurm8OzsPsLLEGzxgJVrKeTogBW5nxQI+uOCKUWce6/fyoRzml6qF7GHSWJ1HIqmwgyYOw1LRklck83AFH/wC/YlbjSNJlOwUE1m7nJ7f44aGP9X0apzmJk/Sq/RicyP3JK+qY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392911; c=relaxed/simple; bh=h1wO2Y5y3snunIjQvp9wEO38mWmGcGSDzqEh5GMe7fI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LpfP3BjUhaxYaCZMnE0/0bmwdqAitORPk/HIZfjO1Dms+DRN6hGrTukqUjBuGdmku5LSDhn3h8ftWW6UED+iuNBm10veSGKMnIgrIP3UD0yv3dNyLWBooddiNmpTuDjCEnoH0vnngenmla0jdegZROQ51r9HVFjYIL7izUa3D8A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ktZI0q0+; arc=none smtp.client-ip=209.85.167.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ktZI0q0+" Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-5365a9574b6so2530340e87.1; Thu, 26 Sep 2024 16:21:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392908; x=1727997708; 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=hHGLYSMhagE5fSOewtprIrN3fA4YzjKM29kt0KG+UpM=; b=ktZI0q0+jWp2b1aLzFLXEA2g13x8LU2XQxKxjO0i6LcMPy+KUeevNAlJ2IoNLQF/CE +8dg1UECdQ6v42s44MJ0DkVyk3i9FF017eXaq7I/xnFBYA27qxoYysJ0v1bKreEWcv/0 ODlHljDcrHqAfJNFKMeCMV0xbH3WaFggJ+dKMry8z18bwgXGGiLHR7erAybL8Pp1QF2H PhTptFgj8+AN3Itk95KgcZLkqgIf2LI8QxU6ojtfbf0CXvCTQLFQS26ghzVlYvAItepQ LuVFh9aj0zmCHgkzq8Rqn8Oo2KGWPd9vh/GkzEcrEoyrW3qWrNyFxzGW6hzp3NEp6fhZ i9Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392908; x=1727997708; 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=hHGLYSMhagE5fSOewtprIrN3fA4YzjKM29kt0KG+UpM=; b=dtrOuYORUfTEEKuEq9dj0yEgnLesOBfp0NXb7V1pwoJ6fWpMjVEkHRGEc3IEt7oDPH /R1xNR4aU9k7UAJ6yPp8D6zQVsUCmfDZncJjurpK23Jy7d13rh4n1NRt0OC5uL5VosZY 5o/Wd4bDuXgwNwm9R0SA2v9Xhp9RuqTZMB0ayMluXrvE/YAK92KjcuNOi+H/bx0KlEB8 QCSbKdojhNYigoWjHkWx5f4bcoiXhe/scX2uo1wsoBvPJ5uYh4GLzf4rpJTj/Z1h9qup QbKkKRIFJ71kN6jx/xXh66CO4kOX42zAJ0Lm3LQnVMhTDu57vNBa5APmMFjX3tgmWInP RZDA== X-Forwarded-Encrypted: i=1; AJvYcCXikiLGOsbnKbxWvtRV2el6dg08vVA1HbmO/v7nwMi6y8kLwqorXb6idzYFl1xtDpP8LtPUPSR7aICoY5g=@vger.kernel.org X-Gm-Message-State: AOJu0Yxal0kuXI4dXHn4VoCfO8YGZmDLjY+5TfF37HqIiqL3AgNdBkRj kXzWO3yCZy4pRz42itdiMvgRgzr80Ndmbjig+LO/joEbLldikoPz X-Google-Smtp-Source: AGHT+IHlD2G2E7GSRoMpuBNsI0X5mi6Ua8JvRQEFmnFC/8WxUbT+wMtBf0onF8DjiKH20jT0Ia2fqA== X-Received: by 2002:a05:6512:3d8d:b0:52c:9877:71b7 with SMTP id 2adb3069b0e04-5389fca4475mr1025221e87.59.1727392908032; Thu, 26 Sep 2024 16:21:48 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:47 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:21:05 +0200 Subject: [PATCH 14/18] leds: pwm: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-14-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1845; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=h1wO2Y5y3snunIjQvp9wEO38mWmGcGSDzqEh5GMe7fI=; b=J1kuyS1rctHLvv769c4EZm6T2XBPkiw9ibZoWkMdEGXw3txrJVIYnZXZTRhRj50ABFFbr7IzF VoKASt4M5y0BuAGDuF4YB9A9l9nGY60szrd+yDBg2/dQb2i/6z43d4J X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). After switching to the scoped variant, there is no longer need for a jump to 'err_child_out', as an immediate return is possible. Signed-off-by: Javier Carrasco --- drivers/leds/leds-pwm.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c index e1b414b40353..7961dca0db2f 100644 --- a/drivers/leds/leds-pwm.c +++ b/drivers/leds/leds-pwm.c @@ -140,21 +140,18 @@ static int led_pwm_add(struct device *dev, struct led_pwm_priv *priv, static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv) { - struct fwnode_handle *fwnode; struct led_pwm led; int ret; - device_for_each_child_node(dev, fwnode) { + device_for_each_child_node_scoped(dev, fwnode) { memset(&led, 0, sizeof(led)); ret = fwnode_property_read_string(fwnode, "label", &led.name); if (ret && is_of_node(fwnode)) led.name = to_of_node(fwnode)->name; - if (!led.name) { - ret = -EINVAL; - goto err_child_out; - } + if (!led.name) + return -EINVAL; led.active_low = fwnode_property_read_bool(fwnode, "active-low"); @@ -165,14 +162,10 @@ static int led_pwm_create_fwnode(struct device *dev, struct led_pwm_priv *priv) ret = led_pwm_add(dev, priv, &led, fwnode); if (ret) - goto err_child_out; + return ret; } return 0; - -err_child_out: - fwnode_handle_put(fwnode); - return ret; } static int led_pwm_probe(struct platform_device *pdev) From patchwork Thu Sep 26 23:21:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831702 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.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 CD4361B3739; Thu, 26 Sep 2024 23:21:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392913; cv=none; b=iXSFxWJYkRu+X7mEArseDl9zmu96pHB/axbq1ZmA02XH752Vsg7POmH5duthY7U2CuK+DCpmaZFbM/BPlAWxdqa/QSObFmSqR5LKdL4shSJREgdUjjU1erg50s6DMjsLlhZ6z/WIK7SwrpUcOn8pKz+JVd1rxevxdsUuWnnTIqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392913; c=relaxed/simple; bh=Fm7F+4MLH582iBnJnE4p4FnmOoiX1OKki6L98DcIN8s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EMToa2iEyngUmE9MDokTqq8M/81pwfpeqWT9v3QlasOCoTqqz+V8emFzm1uXhJhJoOcT6zbselGRDg45AZYG9WHsbO08CKSz/XI7jvGaovpGtB4ZTkfC7/bEUo4HrfcoKLlBuc9jkWmg6shspLU1NWILYEXXXPGDYkYFJKUAoBg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RVB2m4bT; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RVB2m4bT" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a8d56155f51so176267766b.2; Thu, 26 Sep 2024 16:21:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392910; x=1727997710; 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=KxTvYBMAH6K76CxmrsMQCXDoyFzNi14dQqKe3hz4/gE=; b=RVB2m4bTgAPvuXM5vsxXUXNjIg2u+i6cLz99IN97LBLD4gjgkz8AMUh2J3Et9UIJlb mwgWW+lAwV/aZj85BQ2cBu3qy9k00GagdZlaAHZcmCWUOE6yM0adrQOxDoDWE9T/afrV zP5xJbvwTu8fgbVYgkOddjjMPv+zpWfIsT/l1whKbO4Mhva1CpjJAtssG9qKvKNlqfpQ mGlVieBMGe3t/5s+Pms00oZBx2UD7KPT5JPu/U9FqMuK2NRbhlDBaNozOz0AJqf1h7Lj 7xq5aGCQRxoFYruaFBUp/vm5yo43mVBSypn1jA0dopsFZcIwUMsJqHnz2EL9fdDh8A8I iezw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392910; x=1727997710; 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=KxTvYBMAH6K76CxmrsMQCXDoyFzNi14dQqKe3hz4/gE=; b=iC9hsZv1PStbbnISjjBuHnjHjCegcl9dPOJrfYcR3HneUpgd8BKsBpiSdhotBPUQ0z GS1CxHb0DdiH/1ltNj7DHvRvcsgE5DpEhztrbcFihbfVwGv5xRSxE2Q/z110GPPkJV4R 8mpZ3khmFRiIE3PrdaSYxGsnOc1zH38LhgQaUK4A90P81hT5P292xMQsSPnYRe183Nzn oU7/XVZVsnyygL1aOxp45gik686FEvn7QM5DjHWcsirhHaRS53kiHtV7qMKB8jmsd7R7 1GMBovjcEALnY7x5KoZrRZMxiWG1czg+ytuPnn/voeQOI6rLz79WztOLuKl6F4BlD1Lq +g+A== X-Forwarded-Encrypted: i=1; AJvYcCUPI2+UTMO1ptz5vrI09WW00v2UlNDMuBeD2JswXwHoMHycM7DcCQJpVvAghqWHNVQz1KrqWumRUDFIdY8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0MmKEfPA78ZokWs7q2dbeExHIjOK/5mV+TW3DFE8VbJRJr5qA XeTE62pjBWwGELhg3l+ucFHQwZFT+DdB9m031p5OjqbTqkSsmYVE X-Google-Smtp-Source: AGHT+IGRFpVHqTjLsEHhuX5kjF6xyPuBHJW+zrrF725EKx1jN/+wFjAEQNE/hCfydi8zaA50x0RLFw== X-Received: by 2002:a17:907:7e85:b0:a77:f2c5:84b3 with SMTP id a640c23a62f3a-a93c491f380mr76021266b.22.1727392910067; Thu, 26 Sep 2024 16:21:50 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:49 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:21:06 +0200 Subject: [PATCH 15/18] leds: sun50i-a100: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-15-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=3318; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=Fm7F+4MLH582iBnJnE4p4FnmOoiX1OKki6L98DcIN8s=; b=f73Nl+8leOeKTCe124dSLiK3ZYOKg3Q7P72HDYcJ6IZ07AvEQUvjA731Hl8QEMGU3egu+VFHI +vPMS/2qRmIBoqp6rhj8XlbLqzyW7QoOokmZylHrnKLr2RNAmi848fy X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). The error handling after 'err_put_child' has been moved to the only goto that jumps to it (second device_for_each_child_node()), and the call to fwnode_handle_put() has been removed accordingly. Signed-off-by: Javier Carrasco --- drivers/leds/leds-sun50i-a100.c | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/drivers/leds/leds-sun50i-a100.c b/drivers/leds/leds-sun50i-a100.c index 4c468d487486..03f1b6424692 100644 --- a/drivers/leds/leds-sun50i-a100.c +++ b/drivers/leds/leds-sun50i-a100.c @@ -392,7 +392,6 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev) struct sun50i_a100_ledc_led *led; struct device *dev = &pdev->dev; struct sun50i_a100_ledc *priv; - struct fwnode_handle *child; struct resource *mem; u32 max_addr = 0; u32 num_leds = 0; @@ -402,21 +401,17 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev) * The maximum LED address must be known in sun50i_a100_ledc_resume() before * class device registration, so parse and validate the subnodes up front. */ - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { u32 addr, color; ret = fwnode_property_read_u32(child, "reg", &addr); - if (ret || addr >= LEDC_MAX_LEDS) { - fwnode_handle_put(child); + if (ret || addr >= LEDC_MAX_LEDS) return dev_err_probe(dev, -EINVAL, "'reg' must be between 0 and %d\n", LEDC_MAX_LEDS - 1); - } ret = fwnode_property_read_u32(child, "color", &color); - if (ret || color != LED_COLOR_ID_RGB) { - fwnode_handle_put(child); + if (ret || color != LED_COLOR_ID_RGB) return dev_err_probe(dev, -EINVAL, "'color' must be LED_COLOR_ID_RGB\n"); - } max_addr = max(max_addr, addr); num_leds++; @@ -502,7 +497,7 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev) return ret; led = priv->leds; - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { struct led_classdev *cdev; /* The node was already validated above. */ @@ -527,7 +522,11 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev) ret = led_classdev_multicolor_register_ext(dev, &led->mc_cdev, &init_data); if (ret) { dev_err_probe(dev, ret, "Failed to register multicolor LED %u", led->addr); - goto err_put_child; + while (led-- > priv->leds) + led_classdev_multicolor_unregister(&led->mc_cdev); + sun50i_a100_ledc_suspend(&pdev->dev); + + return ret; } led++; @@ -536,14 +535,6 @@ static int sun50i_a100_ledc_probe(struct platform_device *pdev) dev_info(dev, "Registered %u LEDs\n", num_leds); return 0; - -err_put_child: - fwnode_handle_put(child); - while (led-- > priv->leds) - led_classdev_multicolor_unregister(&led->mc_cdev); - sun50i_a100_ledc_suspend(&pdev->dev); - - return ret; } static void sun50i_a100_ledc_remove(struct platform_device *pdev) From patchwork Thu Sep 26 23:21:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 830926 Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.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 B28A91B375D; Thu, 26 Sep 2024 23:21:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392916; cv=none; b=DXP+jF27kBq8+On3EU1s3+fwvakoTRejN65MX1jNbBpFyJcmJ9Vr+8e7SWsNQrcjcLl60VO0fdKSOZfdbgwdsT/GAL3cRvVs1QTBJbmWrdqeWTHzMQuGqkbpL07q2yzr7jLi6zGCxdoG2NdyYsuqvP5lXn+OSpHCOoqWkraq7Tc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392916; c=relaxed/simple; bh=uZ6AU+qHxNHc+7ZSbOLvFpKS951bl9x9VeT+GuFOE+o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j7W8Sip0WlzouJa+MM/fMkMf4p/VishzspWecw2AoEDe699oId+zkghUQL5Tcz78qbml8EWERwjLyXCYrHTL6xya6A/87dVPv4xU1ss/Y+Afqc2YkdxfY+dvAhKrVn/b9V+/E1dCph23uodh7h7jPSx677649bNibKHn6eoWmbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=M20uEIee; arc=none smtp.client-ip=209.85.218.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="M20uEIee" Received: by mail-ej1-f43.google.com with SMTP id a640c23a62f3a-a93a1cda54dso199224566b.2; Thu, 26 Sep 2024 16:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392913; x=1727997713; 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=NM+8ic/Px3mQTsuCcs62/53dsl/B3jVBAf4+IMQjl4A=; b=M20uEIeezalgqPg4rC+dIeKgx90p1389IMYDibmYzBJZ8xsXrjh0h8803N49d3/w+4 9meI2BATrrDbkdXo3ay6V3RoLsF+zFI1EC4m0UExCr4Wz9NW7FUQbhBdBaklCz+4snh8 kqIDcO2/jepsaz+A3927xEY5j57mVogzBatnLAl4sWQ8VuW6L0HR4gWL6ynX+9vCJwfG LSIBvBbvuKTmkdwdNbTZklmj/GocZSQV1rbKGOLiQUi0jJCPov/7hNkVz9CaXE95ff3k K0e4rFrHZONV9yvqpcM8uDet1SCeeVq+OjOYjJh+up/XR6MFYYwSrKcNNXtLZTdo5lcm uv8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392913; x=1727997713; 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=NM+8ic/Px3mQTsuCcs62/53dsl/B3jVBAf4+IMQjl4A=; b=rk0M6GmG+kknt581lYRWTUwooBJNIEdl/fgr8whvnLww2zrzAHbUil89ifTs7nPR79 Z0G3QzuB8+aq2K2cNTXIuB7zBVLOJbeHMI91re1nvOIAxOphnj8B2R6vZAL03Id3IVcv 84sx+gi0SO555BU1xovwVkv+HUV/kKlxlsCcRRkemeFr9bmdVOYF4FP9qB96clRZdAxO LF6YUoLB8NYaiKQDHXeDg+RPtEy3sVnxYujJ+WK2m6ZyVuRUy1hNSWPMsfv0VOwVL1Yk avK5qqsVFrOsEm/0sbjghvko4Q0cIiwsPJ2o8exq/RicTCyQTN52er4YO7t64OOgn0LO EJ+A== X-Forwarded-Encrypted: i=1; AJvYcCUtuRrIWTMDDvzyHko6urZA4j/a18GP+H7cS3y3aoXBtZRoDwtTAdCewustBgZHXIlVLl+rI9wUHLYcq7w=@vger.kernel.org X-Gm-Message-State: AOJu0Yy27GtcU49akgahtOLdgIzbTTX609JL6hgkqwD9fxx0qgZPoWPu IylXjgaz/QbW86pfTmh5oqhIeekz+ehMXr7v+kY80+gOyWI0/aag X-Google-Smtp-Source: AGHT+IEjGS5H1uM127zHsUDENMHQP4peBo2B0LKYmvOBCuq2OU03bEqMYA+oUjVvyxH/GoEWditQPw== X-Received: by 2002:a17:907:1c0f:b0:a86:aee7:9736 with SMTP id a640c23a62f3a-a93c4ac9334mr83767066b.46.1727392912970; Thu, 26 Sep 2024 16:21:52 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:51 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:21:07 +0200 Subject: [PATCH 16/18] leds: tca6507: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-16-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1443; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=uZ6AU+qHxNHc+7ZSbOLvFpKS951bl9x9VeT+GuFOE+o=; b=NGlWdNHQgGpOwQAC3L9GY90Rn3MtzUIW2LrL0gjOsK+kWA98v8Pom7eibl6iKW9m1g68g/UJo C3/17jLgkcHBEyM4LlOU2NTx5/2Qx+Dapk5n5sfsJBSp2CMoP1wmmcy X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error path. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco --- drivers/leds/leds-tca6507.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c index 4f22f4224946..acbd8169723c 100644 --- a/drivers/leds/leds-tca6507.c +++ b/drivers/leds/leds-tca6507.c @@ -658,7 +658,6 @@ static struct tca6507_platform_data * tca6507_led_dt_init(struct device *dev) { struct tca6507_platform_data *pdata; - struct fwnode_handle *child; struct led_info *tca_leds; int count; @@ -671,7 +670,7 @@ tca6507_led_dt_init(struct device *dev) if (!tca_leds) return ERR_PTR(-ENOMEM); - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { struct led_info led; u32 reg; int ret; @@ -688,10 +687,8 @@ tca6507_led_dt_init(struct device *dev) led.flags |= TCA6507_MAKE_GPIO; ret = fwnode_property_read_u32(child, "reg", ®); - if (ret || reg >= NUM_LEDS) { - fwnode_handle_put(child); + if (ret || reg >= NUM_LEDS) return ERR_PTR(ret ? : -EINVAL); - } tca_leds[reg] = led; } From patchwork Thu Sep 26 23:21:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 831701 Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com [209.85.218.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 8E6D51B1408; Thu, 26 Sep 2024 23:21:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392919; cv=none; b=G2n14s0esqWYTIitPfF3W/Qw4Tr8NR0i8T6wzYJx0CVD1WWITbykSCdsmP4MTO6mIjNB5QcOEnGI5Q5TMygrgOutR//EIuc6T0CldLT6T1mKTyVxpwwt73jtKYQ2c4xSfsZ8U6b4VOnsv1nX6XI4lkZgrVy0UR6fXTxI20tCQKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392919; c=relaxed/simple; bh=Upol74WYOlhW6c4peUbPQECrXBC2IELBkPGR+0SYZwE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kvc99W7y9WqzALbM03375LFOpC4d7hcUTUxXDaK/lJz8rNLOAjUhPzrQEp8KSvUBXhAApzJx1uXtcjGEWMkWJTOtIJlTJU74GopULcHmk8fKu0uiuXVJmZUw0D67QOzT79JQ8PPVlILPDQv6JQNuni57TB76YFwi2v7IZBlxd3I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bNIIMx3K; arc=none smtp.client-ip=209.85.218.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bNIIMx3K" Received: by mail-ej1-f47.google.com with SMTP id a640c23a62f3a-a8ce5db8668so235704966b.1; Thu, 26 Sep 2024 16:21:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392916; x=1727997716; 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=WkHqvkI/1/i2Yqceu5g2GJiVANgvtprMciXZ8BQ+brY=; b=bNIIMx3K03a74a8k/jR634uO86f6Ncvp5cpdsoWImXK/c5wuAfg8XRI813wHhfMgth Wj8mtroB5lMkgDhRFgbguagkCGPrM+XlJYN5gKbSF8PlU1rNmhx0SbFIlgEHx4blVWE6 aKZbmyAxseguxDky8InW9AvVwg1S30O1mK5a3q0Gj6vQHg5JPfVwciS8cmeLUHojHxMc ZAbTA6IUfaKlKr1yXbPGIhNvw28gwIMWoVz4uAxw7hi6UytKNf69Vk42kdOMh/efVvn3 6S0KnSl0Zgd0MkH3AkBm9LOHNQVFwwb2TX2VAre+R3CgC8GBSKPMdVGabQYH66GGP/YO fOdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392916; x=1727997716; 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=WkHqvkI/1/i2Yqceu5g2GJiVANgvtprMciXZ8BQ+brY=; b=J+KZbmoWfkrnPIWsKPb4oeWh3tqc6c9BLjaFZxRJj71TbpERGjLSnTO7veMlZcmTXj EPvK7//lNJX8CC3kEXwkBgMVk9vhhd+bwi3OQrjloNqhe7ldJ10q8WTPaqkD4L5QUWt7 3OhTJbHh3TekWV+VeysFi7JdTYWTfdTydS+run8RVd9jyzVN28PYNPfGMP9E1Z7T5vmM wn4ZtY7l+NtB/ZCkybaWqSSwQuZIBBEJtBaEA2SDu+yx1hzFTdywEcBwEjRvh3QCSm/x IpE4VkBe+SlwHGTSEEVWlVrDCOO1hChDY/HHm77cqyxkzWvUHuEoS5S3nk3j11q0NPTK PkKw== X-Forwarded-Encrypted: i=1; AJvYcCWJ3vww7mAju+i0pj94y2QwBQYNr1sXURUW/XN3tAfWbSSPR1eWmnDNrNXboC4gCk17gso4FhSH8EJhjgs=@vger.kernel.org X-Gm-Message-State: AOJu0Ywpg71HLVVyQ5ZbOSI7+MHvk8R5bKEOlQ7HHhw1bnxxQ1ZupdbQ EFrdDJZv0l3cTBQ2/NgjVTCc3dIsNUbnl0b/CvBLokc4aVQIifci X-Google-Smtp-Source: AGHT+IHu7GUf4pEGuh3ajW4RTtn5QFJeznBoUNPfpuLLhiJAhuYOKyTqQymBYsqixg5g1+2YdfLoVw== X-Received: by 2002:a17:907:7b91:b0:a86:c825:7678 with SMTP id a640c23a62f3a-a93c4a98df0mr96575666b.64.1727392915679; Thu, 26 Sep 2024 16:21:55 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:54 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:21:08 +0200 Subject: [PATCH 17/18] leds: rgb: ktd202x: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-17-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=1313; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=Upol74WYOlhW6c4peUbPQECrXBC2IELBkPGR+0SYZwE=; b=f5ds5pKXTIF+B1jMaYwlb8PPJAHi7VfKk6RXlM18dKn8C3IQVGT8JccELHUU4Z+ooOWcfqKQS 27cVaVRUn+uAh7+rCzd53VFlBKfzGLxtf5g5DJWnaFLJwjdJFD+8kOV X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error path. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). Signed-off-by: Javier Carrasco --- drivers/leds/rgb/leds-ktd202x.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/leds/rgb/leds-ktd202x.c b/drivers/leds/rgb/leds-ktd202x.c index d5c442163c46..04e62faa3a00 100644 --- a/drivers/leds/rgb/leds-ktd202x.c +++ b/drivers/leds/rgb/leds-ktd202x.c @@ -495,7 +495,6 @@ static int ktd202x_add_led(struct ktd202x *chip, struct fwnode_handle *fwnode, u static int ktd202x_probe_fw(struct ktd202x *chip) { - struct fwnode_handle *child; struct device *dev = chip->dev; int count; int i = 0; @@ -509,13 +508,12 @@ static int ktd202x_probe_fw(struct ktd202x *chip) /* Allow the device to execute the complete reset */ usleep_range(200, 300); - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { int ret = ktd202x_add_led(chip, child, i); - if (ret) { - fwnode_handle_put(child); + if (ret) return ret; - } + i++; } From patchwork Thu Sep 26 23:21:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 830925 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FC931B3B27; Thu, 26 Sep 2024 23:21:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392920; cv=none; b=E0DWqpLWaIw7s4rij48I38M/zGQXb36FS2AHOXAU9pAAvob13AR1KGe/XVTAJ/hs/m95dhrT30CCtFVPPgLBP4Jda91q4udai4zXPeCmCTQeOzEKtj4ZJh5WrQwLwjarGDM/X2dHz0DYP9evWqzMH/giZF2GnJR1wpWfh7204kQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727392920; c=relaxed/simple; bh=PSVqt2hzPQNutXFJ1ySerbu1QMLwioqVyiO4z6jxrQ8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r3CD6ZPVDhtPCwG9sefp6teC6+k2L7tVWqj+zwEI/qD6WRhcLzUs+2Q0wXscjqkVzti3bZS4FJ9AJ34t0mtUAfGXgITQUmMSpqFepjlSaRHJfBbwvorWxtMwRFwh+YdGiTGfphkngjiaQ46wKXkoUbni7d69fbQ2tOWmCZn44Hg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YKxt75Lo; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YKxt75Lo" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a83562f9be9so137032466b.0; Thu, 26 Sep 2024 16:21:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727392917; x=1727997717; 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=gsf1H9vGvMDgxqrrd3JfvSIa5200NszB5Zt97OWrjd0=; b=YKxt75Lod7JTxgh00DxWyHCw5JtauNMlKx92+JQ4zvjIRoXHy/CFfqJ1uI5uPNm8pI rWde9XAfWMGIGY0yvaT3vDBCDZ+49SFG4uQPD2bGUsjaT7Jkzdv4XOwpMdB/zDEIi3KM pP+L/SLDWzvyOKU7HlCzk/5s73skMV0Kh2EjXutiPfDmla3xZFGmul0QLQQyTrmKbXpz yvqfbZA/kAXUiMKOMwCx46TXok0JvnXWNeBpEthQVm9HJ4qkaoSVw9MGP9rvf5OlKK+g YjeuSnQwpjZxrDE/7MiRJJlj6JovB/1NHtPg4WEF2z1moYXviBiskT5Z+TgxAE5icBtI mnoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727392917; x=1727997717; 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=gsf1H9vGvMDgxqrrd3JfvSIa5200NszB5Zt97OWrjd0=; b=AK8aS3tXG8FqCGUJrz1hZKTlfDgAr1mfFHgYmkYPnsOjnS5cM8CDspxmd92iaKNz77 K5aiLJlvjg6cqSOHJ1xMjE/0u3ZrnAdcqVlYu2iDTKbUh1nWhhNU2kybPDm2MpkGe8BA WSwbgbxe3trCkvw3maLnRQVyWhEXJ2mEyo0i8nesOFZXeMnx/A1N5gHBmS4930sNW2Kk 1rQULngUtNmOW+dyOtj8gdtPC0/o/1auKJG71daVqOh/uLOkmbuhaXXt/Nnvsmuv8TiO 87JAeich4cYP34yC/IxJvt3JyrVDl74W7wko6j6zleZPYAS55h+FoJWbndH1Zs9shPGp IqHg== X-Forwarded-Encrypted: i=1; AJvYcCVZ5eOvozJIboXNS9rTE6Qqio62phWKTpYa7jkqLBAcGp6k2VuiXq0qOjQUJ9cWHYTbzB9i2DIlYDA33kY=@vger.kernel.org X-Gm-Message-State: AOJu0Yzkf914JWMQ3/IO5XXRwAsCnpaUJhxgGg3HjdPXssndHEXLgZGL 6uSfy++vB4iCbKtaLMRWzAZahJ3a1bvuanAaNVsFoKE6idXpw5vb X-Google-Smtp-Source: AGHT+IFFYGWgxNe3W6HVZ9vKaXN55rWL1eirSET5THcsDSbxqgt+Ehox2JsTuD01KAWPP5hH/gwWVw== X-Received: by 2002:a17:907:320d:b0:a8d:128a:cc23 with SMTP id a640c23a62f3a-a93c4c2d809mr96338766b.59.1727392917484; Thu, 26 Sep 2024 16:21:57 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-3989-b03c-7705-998b.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:3989:b03c:7705:998b]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a93c27773c0sm50368166b.1.2024.09.26.16.21.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 16:21:57 -0700 (PDT) From: Javier Carrasco Date: Fri, 27 Sep 2024 01:21:09 +0200 Subject: [PATCH 18/18] leds: rgb: mt6370: switch to device_for_each_child_node_scoped() Precedence: bulk X-Mailing-List: linux-leds@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240927-leds_device_for_each_child_node_scoped-v1-18-95c0614b38c8@gmail.com> References: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> In-Reply-To: <20240927-leds_device_for_each_child_node_scoped-v1-0-95c0614b38c8@gmail.com> To: Pavel Machek , Lee Jones , Matthias Brugger , AngeloGioacchino Del Regno , Gene Chen , Jacek Anaszewski , Bartosz Golaszewski , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jonathan Cameron Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1727392874; l=3209; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=PSVqt2hzPQNutXFJ1ySerbu1QMLwioqVyiO4z6jxrQ8=; b=CwV0EpzUvZAO2Xr3Lvw35f2AWkJgxILgyeJ44eQr3MbK8h5/RqojjHPTG/zr0owvVEhgiQYxU 1I/cZWn0KknD6O57SSfoyl0TPR+QYf61STH2RPg5oIKED+kOJG42L2i X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Switch to device_for_each_child_node_scoped() to simplify the code by removing the need for calls to fwnode_handle_put() in the error paths. This also prevents possible memory leaks if new error paths are added without the required call to fwnode_handle_put(). After switching to the scoped variant, there is no longer need for a jump to 'fwnode_release', as an immediate return is possible. Given that the loop is called in the probe function, and it already uses dev_err_probe(), the common "dev_err() + return" has been updated as well. Signed-off-by: Javier Carrasco --- drivers/leds/rgb/leds-mt6370-rgb.c | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/drivers/leds/rgb/leds-mt6370-rgb.c b/drivers/leds/rgb/leds-mt6370-rgb.c index 359ef00498b4..fe76e8e27f9c 100644 --- a/drivers/leds/rgb/leds-mt6370-rgb.c +++ b/drivers/leds/rgb/leds-mt6370-rgb.c @@ -905,7 +905,6 @@ static int mt6370_leds_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct mt6370_priv *priv; - struct fwnode_handle *child; size_t count; unsigned int i = 0; int ret; @@ -936,37 +935,27 @@ static int mt6370_leds_probe(struct platform_device *pdev) if (ret) return dev_err_probe(dev, ret, "Failed to allocate regmap field\n"); - device_for_each_child_node(dev, child) { + device_for_each_child_node_scoped(dev, child) { struct mt6370_led *led = priv->leds + i++; struct led_init_data init_data = { .fwnode = child }; u32 reg, color; ret = fwnode_property_read_u32(child, "reg", ®); - if (ret) { - dev_err(dev, "Failed to parse reg property\n"); - goto fwnode_release; - } + if (ret) + dev_err_probe(dev, ret, "Failed to parse reg property\n"); - if (reg >= MT6370_MAX_LEDS) { - ret = -EINVAL; - dev_err(dev, "Error reg property number\n"); - goto fwnode_release; - } + if (reg >= MT6370_MAX_LEDS) + return dev_err_probe(dev, -EINVAL, "Error reg property number\n"); ret = fwnode_property_read_u32(child, "color", &color); - if (ret) { - dev_err(dev, "Failed to parse color property\n"); - goto fwnode_release; - } + if (ret) + return dev_err_probe(dev, ret, "Failed to parse color property\n"); if (color == LED_COLOR_ID_RGB || color == LED_COLOR_ID_MULTI) reg = MT6370_VIRTUAL_MULTICOLOR; - if (priv->leds_active & BIT(reg)) { - ret = -EINVAL; - dev_err(dev, "Duplicate reg property\n"); - goto fwnode_release; - } + if (priv->leds_active & BIT(reg)) + return dev_err_probe(dev, -EINVAL, "Duplicate reg property\n"); priv->leds_active |= BIT(reg); @@ -975,18 +964,14 @@ static int mt6370_leds_probe(struct platform_device *pdev) ret = mt6370_init_led_properties(dev, led, &init_data); if (ret) - goto fwnode_release; + return ret; ret = mt6370_led_register(dev, led, &init_data); if (ret) - goto fwnode_release; + return ret; } return 0; - -fwnode_release: - fwnode_handle_put(child); - return ret; } static const struct of_device_id mt6370_rgbled_device_table[] = {