From patchwork Fri Aug 16 15:31:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13766528 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A73EC3DA4A for ; Fri, 16 Aug 2024 15:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=4sCEiKf2B9DqzQ8Bb94EFqGzHc8DX0w0QdFuF8Rhqn4=; b=VM0aKh/dtyF9iL/xRgRjyx/XYb hjG9VCQlVEMAP7ku/8M/ZL18cQ8tlYcAaAgdTLWmIy1JS6OdyDicsiccUSoITm4exZrRH03cJq++S yCy+maPogro09I/qaKL2E5ebVRC2MJcnTSPe9G/TDqu6h5cmwmz5vJe4pFbjc5s76ZFyaCnVxH6pC VlMW3yNrF5doJfD5M33TQfJprUYK7D4xkIndRJrUp55oQRH0ZGXlowdIRQqQ2fBrPw+uNvcM6KNmG WOyNWzjaKasKO2/Y/fISXepqWUskAT1MEqIMk06IKZXNgTsWG0Wi5gCcl8Wq64PU4nf03thcHwiBJ 3rHSpeLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyxk-0000000DPKe-414l; Fri, 16 Aug 2024 15:34:00 +0000 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1seyvm-0000000DOWf-3Lu8 for linux-arm-kernel@lists.infradead.org; Fri, 16 Aug 2024 15:32:00 +0000 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4280c55e488so11223065e9.0 for ; Fri, 16 Aug 2024 08:31:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723822317; x=1724427117; darn=lists.infradead.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=4sCEiKf2B9DqzQ8Bb94EFqGzHc8DX0w0QdFuF8Rhqn4=; b=qNKAaI8wq/Mwx8mO5q51juTq5uHMGTqcmBIaKh3KN9C5QYkPvq05JzEi5CiIz+6hAM aNfDGZz4NYDV5T46bYMp1Sum+W/51glu1sk7lzWAyahmhDyrm7bMn5dC4Utbvxk9DbFB AOwx3B5SoEj9GFb3AAuQ7mMVVjtKGMcmPftWR/3wlIlF7WUUcEcYBeo4/fl95uQ1aPn6 txpKR7Pwp75JcCCSuMy3q/rN0xooFK8Apjlxlb6rEeir7GFE/oy2yd2eBif1w5nw6oLF klfMboptuwfrt74xMhnHpqZbVGN634eWFA6/XnV/JDysRA1zMAdanXX3Y0V5m6elRJlS I7rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723822317; x=1724427117; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4sCEiKf2B9DqzQ8Bb94EFqGzHc8DX0w0QdFuF8Rhqn4=; b=MNk5f7dFUjdmELUzovzJNy2clvXMyKJyYeWugAOCk34LRQ3quG97zfLwVZ4yIoUmID lu47J4UzAEYhWeARtwZtotg8Ne9Vz/Q7l4KtgIXy9IyuVvYipNu32XoL3t4hXrq3KcYt GJyQ7AKifuFJSVfle3k2GAR0GNvI0+lx/1bHaTCnpfHEtFIhC8HZSSaOGu5LJKtx0YQO gWZ3RmlVA9b9ZbH8l+heqcAn2kliX/rGw2aOc+ifzsIrnsKHdQhW2sMpJphwQVdocJia CjcIhbAgsXE/mCerT4RGmsEOYydS+jhKAy9V/kNQn7JUzDqzwHIsgKzjTS5xxlPuGte/ iK3w== X-Forwarded-Encrypted: i=1; AJvYcCWkaXce8tdaKfS0jXu/TeKu0GDpmYo+69386d/J2Xdh3LMjnzM0Af9O45MpcYsv7g0U3WzqmsjrXjKAnNSuklKfvMPu3PA9cZyhCu2VnA1q7BXQs10= X-Gm-Message-State: AOJu0YxZogTKgJiQ5YfZAjircLYu3UWYCD/QQ399rpAmPvqWEUp+s/dP y08O8xpzM0qJ9rJLLEPjoiP1mX5lSOSGjOLcKzVfZmsvTK+INuLfq/9gVtgTeL8= X-Google-Smtp-Source: AGHT+IHyXrDHQQ8xvlWiTDWTVoEhaAwJIa4Z1GZboPifzHF1ML55V2Wee10MVI+0W3m/5b6OJzB4SQ== X-Received: by 2002:a05:600c:1909:b0:427:ee01:ebf0 with SMTP id 5b1f17b1804b1-429e232c0e2mr51862515e9.8.1723822317254; Fri, 16 Aug 2024 08:31:57 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-371898497f0sm3853661f8f.39.2024.08.16.08.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Aug 2024 08:31:56 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 16 Aug 2024 17:31:34 +0200 Subject: [PATCH 02/17] leds: ktd2692: Use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240816-cleanup-h-of-node-put-var-v1-2-1d0292802470@linaro.org> References: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> In-Reply-To: <20240816-cleanup-h-of-node-put-var-v1-0-1d0292802470@linaro.org> To: Pavel Machek , Lee Jones , Sean Wang , Matthias Brugger , AngeloGioacchino Del Regno , Riku Voipio , Orson Zhai , Baolin Wang , Chunyan Zhang , =?utf-8?q?Marek_Beh=C3=BAn?= Cc: linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2165; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=9Die7rsR0B6JZR+OB5IykGhnUTGNXFPzBPfH+JonqpE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmv3DaAzLdZslDk0FQE8r1wjsl32N1ooly3he/+ EvtSvhfqEaJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZr9w2gAKCRDBN2bmhouD 17GeEACO5DbF3CFK0Jm/yLGicXuoliag3DYz7K6gsIaFii1FHbBFpZHVfrfgWYFVJ8CYd37v68w soy0nF1zPooHW/VDuHGHdPQM+JHUmVqvUunZEIc6hxiP2ega264eB3t/cyXxpJyTy8EvxTvH2S8 RLZm6GSGQmTFb9b8tFr9kTeC0FPg7i9FJRzkCCEnlXJsRplK/CW/sk/c0+7xsTXgWn1+cHnB/z4 1nWHl/IamnG7It/5//a4DlRR+8XeAL4iQLc5liQIgR8ab1IjKSuVly/W2f3FPjckkMMVIAiP0NY lXZuuMD4Xg/spf/HqwoTG9qlMAo2UDELs19WB5qozuKnq/OLe9OJzUV/t5gEjEOKr7Kf6HnP4NP pPGUQwe9j9k1bsE36op0VjHzY6nDR1vZDxTvmO6sJeGeptqHCWQtkQoXncP0hdgHEy+YiO9j7Sf MyH6enXPvNslJ+WiY6GLycxqvWbCVG/y7jOtjlzW9Nl3UNHbPuh7ZVt+C8GZ5DfJxPZVUHZ4yxU JI6xexzf69WgGGMsrLOmRbNZeopiDlAirPTz/tKiocePbzX73jydUexldAE2IPUgDYT0hjPcWpk yk5iGPgYLagzljdrUiIib+oUnd6ApXqoYlXT8TLGe1VdfmbbssaXp6dH/f3iRB+T0u79f23A33U ex5HyA/XSxDiKpw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240816_083158_848756_4D1274E6 X-CRM114-Status: GOOD ( 13.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Obtain the device node reference with scoped/cleanup.h to reduce error handling and make the code a bit simpler. Signed-off-by: Krzysztof Kozlowski --- drivers/leds/flash/leds-ktd2692.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/leds/flash/leds-ktd2692.c b/drivers/leds/flash/leds-ktd2692.c index 7bb0aa2753e3..16a01a200c0b 100644 --- a/drivers/leds/flash/leds-ktd2692.c +++ b/drivers/leds/flash/leds-ktd2692.c @@ -6,6 +6,7 @@ * Ingi Kim */ +#include #include #include #include @@ -208,7 +209,6 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, struct ktd2692_led_config_data *cfg) { struct device_node *np = dev_of_node(dev); - struct device_node *child_node; int ret; if (!np) @@ -239,7 +239,8 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, } } - child_node = of_get_next_available_child(np, NULL); + struct device_node *child_node __free(device_node) = + of_get_next_available_child(np, NULL); if (!child_node) { dev_err(dev, "No DT child node found for connected LED.\n"); return -EINVAL; @@ -252,26 +253,24 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev, &cfg->movie_max_microamp); if (ret) { dev_err(dev, "failed to parse led-max-microamp\n"); - goto err_parse_dt; + return ret; } ret = of_property_read_u32(child_node, "flash-max-microamp", &cfg->flash_max_microamp); if (ret) { dev_err(dev, "failed to parse flash-max-microamp\n"); - goto err_parse_dt; + return ret; } ret = of_property_read_u32(child_node, "flash-max-timeout-us", &cfg->flash_max_timeout); if (ret) { dev_err(dev, "failed to parse flash-max-timeout-us\n"); - goto err_parse_dt; + return ret; } -err_parse_dt: - of_node_put(child_node); - return ret; + return 0; } static const struct led_flash_ops flash_ops = {