From patchwork Sun Aug 25 13:50:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13776776 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 A041BC5320E for ; Sun, 25 Aug 2024 13:51:07 +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:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=EF9Qqgl26owRqH1FstKdyvbEmMtUlay6Jv/0hyaG+ok=; b=BYo6Rxb4rO6ocLDWSwB/ynmbzw uIuxscTNIch5Co2BXmVBHyc0bG+B80HLLOuJ6C91vL2o8E+L58chcuaiYEirDpwV0b4JVqk5YAzsU a7hYVznGxAYSEarEVGaoh2AJKBiNYbfTPBJx/Lcgvh+stx0bqTcTXoSEDs3JSMjEgamkNJp/Wd6yQ XSLRkd0A3iDxCv40B9YtT43b0Jw0xKpIkBKm1JxElvsoUvUe9ci5xXOWQIp/SqJ0okm6Y81kUyXjF 1exZfK+uUeAD011dWUSzbAXIiLSyV2VSsnnzs1FIpkWGA6GVAUn1uk+0o41oXCvvPkBVy3ZQ4pgTi 8q6bgy5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siDdv-00000004QN3-1qg7; Sun, 25 Aug 2024 13:50:55 +0000 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siDd9-00000004QFE-1nyT for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 13:50:09 +0000 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4281e715904so3932345e9.0 for ; Sun, 25 Aug 2024 06:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724593805; x=1725198605; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EF9Qqgl26owRqH1FstKdyvbEmMtUlay6Jv/0hyaG+ok=; b=WtTTemMtA88v7WVzUd0ZaUzLrPDbV29upDXGHP9BMlOszE3hy2POnJPrO/Vo0jTN52 mJxYkD0tR1lCybtylL3snNksveZZlURQzFPZ9dqM4gz2W/bs54Px3E+NOzEgbuOKgFyd 475QNMsgztLyKeR5uyvYAWwRkRbyQhe2cDegrTNv4utQI9zBID/8DKrYGDGpXU1Fnvrr rNFFA5rHQXCQgI41t6aUVONTSTjE8HVOmQd4/Wx+wY+b+0Ux79pda0jCD16WuNXWA44o jw/JELkfMN+xoGuYX6QWI+UwOCql/wvRFrltDt82Ia5hE8PN6Z0gbn6Ubq0A4VL1f9qN hMxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724593805; x=1725198605; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EF9Qqgl26owRqH1FstKdyvbEmMtUlay6Jv/0hyaG+ok=; b=Fxg/t2/eEkub+xU+7k7Jo76Fxn2Ckt0s43NDk57RYQhdqfnbgYeS7WFfmVZBayjgAT UiR1vYHU6baIXlFg/DFcJJw1o0t03qLtCCG4CVJ7rbxI2K2+iQwGW6aUitsTeSG++XhG HoJc96kc2pMIix3jGqg5WfWUxKgUa+OipwE83vvz/d6fG7B8pleZXZVARh2k0Q5lVT1N Q4sBFMUU+XRx2gieT+xEQV+E1PW00YaWJ0N7fM8Ek3/j9rSnHyVfQQLvxo1YTR1M9g7g tHeBfTGSY/Bn/t5/jBpgIcslcFRAvSqMDwZBOLT9gj03P7iWmYYTrkWa3XKm59Sc5zJ9 lQ3Q== X-Forwarded-Encrypted: i=1; AJvYcCWWfgR5eNc93AcCHB+8/tZo7OI9z0J0JGks0IuHYHeyBIyFwbD7e2q4FQgdQZhpMd/NQ+MqkxalrxPlvKuJGwZs@lists.infradead.org X-Gm-Message-State: AOJu0YzjXfH/UfHO2tqYN6JqFxnbH/twG9yg47CM7HAJnP9qgAvC+OmL ZTJ3J6H6eMoOpQLt6CaHC+6E2eWxZ8wefYK/HTSlbbJYboZHuTtea70GdPJR2uA= X-Google-Smtp-Source: AGHT+IGnENfrPvjukEnSzPjhx2HARE0cEYrdN08tvFIdvbOIg83EEt5QK6KAQ4UxwiIxW/204HD2Vg== X-Received: by 2002:a05:600c:3b90:b0:426:5dd5:f245 with SMTP id 5b1f17b1804b1-42acc8dedbfmr32194235e9.2.1724593805455; Sun, 25 Aug 2024 06:50:05 -0700 (PDT) Received: from krzk-bin.. ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac514e1f7sm122188365e9.5.2024.08.25.06.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 06:50:05 -0700 (PDT) From: Krzysztof Kozlowski To: Vladimir Zapolskiy , Krzysztof Kozlowski , Miquel Raynal , Michal Simek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski , Jonathan Cameron Subject: [PATCH 1/2] memory: pl172: simplify releasing AMBA regions with devm Date: Sun, 25 Aug 2024 15:50:00 +0200 Message-ID: <20240825135001.48963-1-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240825_065007_526109_AD485027 X-CRM114-Status: GOOD ( 12.64 ) 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 Use devm_add_action_or_reset() and dev_err_probe() to make the probe() error handling simpler around amba_release_regions() cleanup. This allows to drop the remove() callback entirely. Suggested-by: Jonathan Cameron Signed-off-by: Krzysztof Kozlowski Acked-by: Vladimir Zapolskiy Reviewed-by: Vladimir Zapolskiy --- drivers/memory/pl172.c | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/drivers/memory/pl172.c b/drivers/memory/pl172.c index db5fbee34077..be7ba599cccf 100644 --- a/drivers/memory/pl172.c +++ b/drivers/memory/pl172.c @@ -187,6 +187,13 @@ static int pl172_parse_cs_config(struct amba_device *adev, return -EINVAL; } +static void pl172_amba_release_regions(void *data) +{ + struct amba_device *adev = data; + + amba_release_regions(adev); +} + static const char * const pl172_revisions[] = {"r1", "r2", "r2p3", "r2p4"}; static const char * const pl175_revisions[] = {"r1"}; static const char * const pl176_revisions[] = {"r0"}; @@ -232,13 +239,14 @@ static int pl172_probe(struct amba_device *adev, const struct amba_id *id) return ret; } + ret = devm_add_action_or_reset(dev, pl172_amba_release_regions, adev); + if (ret) + return ret; + pl172->base = devm_ioremap(dev, adev->res.start, resource_size(&adev->res)); - if (!pl172->base) { - dev_err(dev, "ioremap failed\n"); - ret = -ENOMEM; - goto err_no_ioremap; - } + if (!pl172->base) + return dev_err_probe(dev, -ENOMEM, "ioremap failed\n"); amba_set_drvdata(adev, pl172); @@ -256,15 +264,6 @@ static int pl172_probe(struct amba_device *adev, const struct amba_id *id) } return 0; - -err_no_ioremap: - amba_release_regions(adev); - return ret; -} - -static void pl172_remove(struct amba_device *adev) -{ - amba_release_regions(adev); } static const struct amba_id pl172_ids[] = { @@ -292,7 +291,6 @@ static struct amba_driver pl172_driver = { .name = "memory-pl172", }, .probe = pl172_probe, - .remove = pl172_remove, .id_table = pl172_ids, }; module_amba_driver(pl172_driver); From patchwork Sun Aug 25 13:50:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 13776777 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 06357C5320E for ; Sun, 25 Aug 2024 13:51:49 +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:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pVr+4PPQohBq2Hhdcp2P4lz8bIedV9DtOFUZkPdBmHE=; b=3fHezucdINoYezhe+gRZy4L0Y/ 3cdRwzaTEhUE8ey9invWM1iQiw3Yjm6fgA6Hx53ky/XSczdt84FaOcVYdPWhZ/XKrl4caDctZQCA8 3rqni1LW9FJIJZSJeW32yojvRViKHquF2Och0DCjHD+18LEuAGpz60U2oHel8L1w+/NKyCTuYss5/ w1BxuSGcdv3ZBvOc9Nul6LtDA0BNMFWxFToFwkQqxgxcAk3014A1TKW+l6Zx5g7Eddb+FIiSo9jed 6GjKKooX3Z2+Lq+2Rer/vS38HuttBotc4zh0t9ZqkuFVDRxhTwmWuWxhqAk/NrxRkPutBY2wKjtNk 9KPQfA/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1siDee-00000004QT0-0d5v; Sun, 25 Aug 2024 13:51:40 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1siDdB-00000004QFr-0DGO for linux-arm-kernel@lists.infradead.org; Sun, 25 Aug 2024 13:50:10 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4280921baa2so3910915e9.2 for ; Sun, 25 Aug 2024 06:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1724593807; x=1725198607; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pVr+4PPQohBq2Hhdcp2P4lz8bIedV9DtOFUZkPdBmHE=; b=WXtB1fBDdflH5J/KQDGxdyXSlVPwUvmDqlrUcjOeAaXyIvpCEJUSBQYkdan5EzUPoC Kqn9NmYn//4928VGFHyhrRbJ/p7ULP334Hl46fBqeF7cxzBjqWX9sWJmfbPGGjD6GrRn 6ytF7hBHq12h1y8g8v2ajmLJRaS+PpqPyy6WQmEpOaljTlZG7RhACyHsopXkz6lOYs1Y Z26IdQTLB6tzmdHvuqi3C4Dh6z6Np7RAv+nsjHxm6n6Fbf2IlHio7r2NtEfh0bmfwA1M fgrdXKh6hFsCciYtb0yzbDZsa3K5aJU0+V+JeKpqgv/SitVShe4s9UHEiqdoBlV+ADCJ 28hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724593807; x=1725198607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pVr+4PPQohBq2Hhdcp2P4lz8bIedV9DtOFUZkPdBmHE=; b=a9IrGaGbdBUh0mNAAlKo0KZTwKewoCAGg/2f2nXx85cO5vEmaLM1syvkoyHHFT8P/T l0jXt5nuZYFN/VTx8IHgyNlwiobU/gO9KZr0nXSFrFqT+8Kj45xRT0YEyIOC5awMhLM6 pqI8e86p/BOQKXRSyvR7MdKeouxQaUPHlaYID7OL1pagZe46Hw4O4NNzx8WX2zumrS/E oAUmy0lL+EIasAqadBIoglog5vSj47eVRUWd/4oWilR1TMMbJQy8m16cBz5fIZ0drSc8 zxvkwkxU8fnyf0Sj+52pGgrWY7GGiKRPetyW8faoJjNcaYjf5jAEAzW8VNyQ8Gtp5oxi yOHQ== X-Forwarded-Encrypted: i=1; AJvYcCXJ21zEK+rSxo7pIH3msdBRTwB52htAOY7+CVsYp8bYnL0Z4Lw4DeXM9Bg0Xllk5Tim9XE7DMchgUbL4AIcTt4J@lists.infradead.org X-Gm-Message-State: AOJu0Yz1AkB6bKqkWSMdAKxr3ocFzEt6hcCfh3ujnPxwZ7p3nbHIPJyo Mv4l5RdOQ/e0j14L1xbod4At02ZL1hqol82nuedLiB3nf75ufDnBIpTwnrZt2Gw= X-Google-Smtp-Source: AGHT+IF1JPg8c/K+unhOGNVfEAMIz5SMqT+TqLYrkg4HV3S7iZetXZI5aLVbvkuvFOtR1wwGEAxw3w== X-Received: by 2002:a05:600c:198c:b0:425:73b8:cc5d with SMTP id 5b1f17b1804b1-42acc8da99dmr32783395e9.1.1724593806925; Sun, 25 Aug 2024 06:50:06 -0700 (PDT) Received: from krzk-bin.. ([178.197.222.82]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ac514e1f7sm122188365e9.5.2024.08.25.06.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 06:50:06 -0700 (PDT) From: Krzysztof Kozlowski To: Vladimir Zapolskiy , Krzysztof Kozlowski , Miquel Raynal , Michal Simek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Krzysztof Kozlowski , Jonathan Cameron Subject: [PATCH 2/2] memory: pl353-smc: simplify with scoped for each OF child loop Date: Sun, 25 Aug 2024 15:50:01 +0200 Message-ID: <20240825135001.48963-2-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240825135001.48963-1-krzysztof.kozlowski@linaro.org> References: <20240825135001.48963-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240825_065009_148078_5832B226 X-CRM114-Status: GOOD ( 12.43 ) 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 Use scoped for_each_available_child_of_node_scoped() when iterating over device nodes to make code a bit simpler. Suggested-by: Jonathan Cameron Signed-off-by: Krzysztof Kozlowski Reviewed-by: Miquel Raynal --- drivers/memory/pl353-smc.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/memory/pl353-smc.c b/drivers/memory/pl353-smc.c index 994c7a792e34..28a8cc56003c 100644 --- a/drivers/memory/pl353-smc.c +++ b/drivers/memory/pl353-smc.c @@ -74,7 +74,6 @@ static int pl353_smc_probe(struct amba_device *adev, const struct amba_id *id) struct device_node *of_node = adev->dev.of_node; const struct of_device_id *match = NULL; struct pl353_smc_data *pl353_smc; - struct device_node *child; pl353_smc = devm_kzalloc(&adev->dev, sizeof(*pl353_smc), GFP_KERNEL); if (!pl353_smc) @@ -93,12 +92,13 @@ static int pl353_smc_probe(struct amba_device *adev, const struct amba_id *id) amba_set_drvdata(adev, pl353_smc); /* Find compatible children. Only a single child is supported */ - for_each_available_child_of_node(of_node, child) { + for_each_available_child_of_node_scoped(of_node, child) { match = of_match_node(pl353_smc_supported_children, child); if (!match) { dev_warn(&adev->dev, "unsupported child node\n"); continue; } + of_platform_device_create(child, NULL, &adev->dev); break; } if (!match) { @@ -106,9 +106,6 @@ static int pl353_smc_probe(struct amba_device *adev, const struct amba_id *id) return -ENODEV; } - of_platform_device_create(child, NULL, &adev->dev); - of_node_put(child); - return 0; }