From patchwork Mon Aug 12 13:33:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13760599 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 A4CB4C3DA7F for ; Mon, 12 Aug 2024 13:36:30 +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=SQA/PjjohkpV6TqZg91y0zhylBtn0W2KyopE+/TT64c=; b=cO3F+/KGpmyHGC+7qqqBHieIxZ 1fXeg1LLDNrqQof7t60uX4HimLnDGHyEH7jG6O0MfDVsujTP+CNHmiVFuzU039+GR6/lVFnLWLwKb 4ZAyBM7roEEyUayK+3O8eGaQ5BB4Bd/u0HpGnmDaATUX3KdDGzq61jYiZ0oEZM2e0CG8IOLUFigXu BusBuVquNC6Wb9ieAcSuMA2dAgPNg1ONIpf12xoEsd+KXmJfq5NHyM7613pv+nrHPaUOO6+ixxDvO EcLkY5nQH85OxCjKmR7biddIR7thC3WDnXqANsPFzzmSsXQuyrTCOWJdBwKnycm/YxCjP1I5kzz6d QrUtAooQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdVDc-00000000RSq-15WW; Mon, 12 Aug 2024 13:36:16 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdVBw-00000000R88-1q3G for linux-arm-kernel@bombadil.infradead.org; Mon, 12 Aug 2024 13:34:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=SQA/PjjohkpV6TqZg91y0zhylBtn0W2KyopE+/TT64c=; b=Tg3NLm2aenRjrd0cmlmVcn7+qU pCYTmddOs8LObVWCK0CUtmOH3S3ktxi4DGapmgd1disP2Db/pUpIGudklgLCZ2EexuPifTGS0jY1t jMmDYvX8k8dt6b1UgDk3Md9P+31J7TwgSLdSwc+BHhW40lc/WtiCdhuBCbPKEb7AmM1QvuqW5LSl/ 86yOi6oB+CzhwBdevh/TaS0LdgvOZSc94h8XcH83isFmbmhRIDBQZQU8UJA2gFaaOlqCFmlxGCviX 5rol463NGlOBHztaZQy7EWyjY43ot0Vthd5goOgi+0dtTRlgeE2+pSm0hd7hOG1RVt95i4FXyAANm DHx2d88A==; Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sdVBs-00000007ZZ8-1nUC for linux-arm-kernel@lists.infradead.org; Mon, 12 Aug 2024 13:34:30 +0000 Received: by mail-lj1-x22e.google.com with SMTP id 38308e7fff4ca-2f16767830dso43571971fa.0 for ; Mon, 12 Aug 2024 06:34:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723469665; x=1724074465; 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=SQA/PjjohkpV6TqZg91y0zhylBtn0W2KyopE+/TT64c=; b=jRXP/qQdRVAO+2XqFNUZUkCAGXLuqbC3Yf84za9QgJVoe6tp0M+uTJGRDgbHJpmcrH UVqctQOfoBYP6iJUm+ZTSYgYEDDmqKeWm66QPZ8qba5u7qrz2q94HVD1YV5zj987y8XZ /qHNhOJbcuhwmsFIuXaIcUKG0VYT/QZIAI0KXOLtUjE8RHUVgTDWHUMIsdw197mYNwLI zmcL2nte79pLkg3VqFNlgKxf50jXolmvOHNSrm81HNlPp0d+kZ/XVpapf5C1v3KrVfYx mnvvQEcQtzf2Z36i3jQrMZQkNPzkaeEkNJOZfkoRABAR4io499Xxiv4OuqhIIXWZ1f0F b2WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723469665; x=1724074465; 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=SQA/PjjohkpV6TqZg91y0zhylBtn0W2KyopE+/TT64c=; b=O+RqgfCYVqwbnRB4eWBp1uvo182jBj2EQOI3uV5MYdTztnlRprcm9LFkGcTvygJU9h rzTcGGgt4OuYcJVAOkuaTl+eJlr7zOefX75U7PQuO0XTyYmFJx5WcvhPWZ6rn0c6SxXY cJ+nPX2vMP0rkunBFNFApsK4Q0O5c/zyU448G95dJ91D88Qk1xTHeP8+0UAX3RNg4Dzs FzMOIP4N4UquHLFdThmrq8pItOuG7b81f3ePMTJ3ubqfPMRIvPtDQm0A54XH3RBmoMMI A0hp7UR1CPauIKdoI89KHA0h5XVeR8rS8FvIve7Pt5t7pN+PiyL2lUeBxjc45mNDGKUv fREQ== X-Forwarded-Encrypted: i=1; AJvYcCUYMdGT0JeuskWV2SWdizCapUVvoPjUAApglV7MpJB0yC5bv8VjYnJNxC0D5w4TV8bpyWpmqw7IyRcJczHYymjXVRNOuc4wGeYkmr/TpUdmzu+ovGw= X-Gm-Message-State: AOJu0YzowO2Ge4MyID8ZpIECwlTBH5RuCDYufynwlAqDFdC5FHDtWo5B cingpgWCoN/NQ0yOvgND/UadzYee61OzLHX0KL28iuYy/z+zIa8ukdpFAzMFhzw= X-Google-Smtp-Source: AGHT+IFuG2qd+DzlKsP6QmlNw7cGw4vQwIOF5kCUyHlkAobIrwVs2DCtPwAfbJ5IawKIByi9iNKEWA== X-Received: by 2002:a2e:d11:0:b0:2f1:9248:c325 with SMTP id 38308e7fff4ca-2f2b717bb9dmr2097961fa.31.1723469664458; Mon, 12 Aug 2024 06:34:24 -0700 (PDT) Received: from [127.0.1.1] ([178.197.215.209]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429c7737c64sm102733975e9.31.2024.08.12.06.34.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Aug 2024 06:34:23 -0700 (PDT) From: Krzysztof Kozlowski Date: Mon, 12 Aug 2024 15:33:57 +0200 Subject: [PATCH 3/9] memory: samsung: exynos5422-dmc: use scoped device node handling to simplify error paths MIME-Version: 1.0 Message-Id: <20240812-cleanup-h-of-node-put-memory-v1-3-5065a8f361d2@linaro.org> References: <20240812-cleanup-h-of-node-put-memory-v1-0-5065a8f361d2@linaro.org> In-Reply-To: <20240812-cleanup-h-of-node-put-memory-v1-0-5065a8f361d2@linaro.org> To: Krzysztof Kozlowski , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Lukasz Luba , Alim Akhtar , Maxime Coquelin , Alexandre Torgue , Thierry Reding , Jonathan Hunter , Santosh Shilimkar Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-tegra@vger.kernel.org, Krzysztof Kozlowski X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2782; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=ZuL1arzThZP1bH0X88EKns0i/Pwsb1RnCMJkbCddCK8=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmug9THrzP+A1BH/yeTSMDTHI9G2M6wGjffRCSn dlrxuuifPyJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZroPUwAKCRDBN2bmhouD 188OEACJwoc0GJ4OOrq04S9Eqnai7E1TmoY+QS6g/X4/oh4fUgYz6R5MGupwE7ya/svO86v4gOl OLe8SdJZKjvqK76134ROWFAUJfVnt+x5RIg6hxI7LsqUOCxd4+P35lymy4T1T6M1Wm1YD+bzZcT b+hJuth2lbekjBDszhBlcuwsLCR+eP4qOP4X60dIIz/DTwLKRIsNKi1ZzceLBcnU3FxO29VYJo7 gPDrthDsbabgcU/p+jDKZpqlwyVbYPGmOwXrB+qA/6UpNUkSgS3rEBGULDktmxaOWiCVYAf/uxU hnIEBvoqeT7dGdF/zxzP4IXa33L8dQ3nEhTktFn/KUFO7KSP0npI9YqxGe2wTq4U1Iu5Vv280pp ebL96l+uGfl7yGN0vm3XsrETWTo9jkdwTEC6nNhFbXQbMeZfppqiXSnheVM6pyTepzKzcHhmXOo 0BysbLIOGMoxpcppLMfsoaimruRVTEn8PloUDzWjtD16zDFGKzngIrJuXFP0QKUiK7nLK+tFGiT kt4gMkJiRZCBIxDLPT2HkMhtyfSZMcKX/sIsKruL/TqdZ2oD4zY3RiNFWtZ9NDMNRI2wQP/yB6X Jbg4bT8+JbyRvvxHwF0/F4UaF2Wz9fGUB/XnfSw5mFRgs6GJP2sFYXsymEwhYpm/d8s6rmdQ643 NIuOrNP6Z8e6AGA== 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-20240812_143428_787561_1D0D7243 X-CRM114-Status: GOOD ( 14.67 ) 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 Reviewed-by: Jonathan Cameron --- drivers/memory/samsung/exynos5422-dmc.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/memory/samsung/exynos5422-dmc.c b/drivers/memory/samsung/exynos5422-dmc.c index da7ecd921c72..d3ae4d95a3ba 100644 --- a/drivers/memory/samsung/exynos5422-dmc.c +++ b/drivers/memory/samsung/exynos5422-dmc.c @@ -4,6 +4,7 @@ * Author: Lukasz Luba */ +#include #include #include #include @@ -1176,10 +1177,10 @@ static int of_get_dram_timings(struct exynos5_dmc *dmc) { int ret = 0; int idx; - struct device_node *np_ddr; u32 freq_mhz, clk_period_ps; - np_ddr = of_parse_phandle(dmc->dev->of_node, "device-handle", 0); + struct device_node *np_ddr __free(device_node) = of_parse_phandle(dmc->dev->of_node, + "device-handle", 0); if (!np_ddr) { dev_warn(dmc->dev, "could not find 'device-handle' in DT\n"); return -EINVAL; @@ -1187,39 +1188,31 @@ static int of_get_dram_timings(struct exynos5_dmc *dmc) dmc->timing_row = devm_kmalloc_array(dmc->dev, TIMING_COUNT, sizeof(u32), GFP_KERNEL); - if (!dmc->timing_row) { - ret = -ENOMEM; - goto put_node; - } + if (!dmc->timing_row) + return -ENOMEM; dmc->timing_data = devm_kmalloc_array(dmc->dev, TIMING_COUNT, sizeof(u32), GFP_KERNEL); - if (!dmc->timing_data) { - ret = -ENOMEM; - goto put_node; - } + if (!dmc->timing_data) + return -ENOMEM; dmc->timing_power = devm_kmalloc_array(dmc->dev, TIMING_COUNT, sizeof(u32), GFP_KERNEL); - if (!dmc->timing_power) { - ret = -ENOMEM; - goto put_node; - } + if (!dmc->timing_power) + return -ENOMEM; dmc->timings = of_lpddr3_get_ddr_timings(np_ddr, dmc->dev, DDR_TYPE_LPDDR3, &dmc->timings_arr_size); if (!dmc->timings) { dev_warn(dmc->dev, "could not get timings from DT\n"); - ret = -EINVAL; - goto put_node; + return -EINVAL; } dmc->min_tck = of_lpddr3_get_min_tck(np_ddr, dmc->dev); if (!dmc->min_tck) { dev_warn(dmc->dev, "could not get tck from DT\n"); - ret = -EINVAL; - goto put_node; + return -EINVAL; } /* Sorted array of OPPs with frequency ascending */ @@ -1239,8 +1232,6 @@ static int of_get_dram_timings(struct exynos5_dmc *dmc) dmc->bypass_timing_data = dmc->timing_data[idx - 1]; dmc->bypass_timing_power = dmc->timing_power[idx - 1]; -put_node: - of_node_put(np_ddr); return ret; }