From patchwork Wed Nov 23 14:41:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 25026 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2834230wrr; Wed, 23 Nov 2022 06:48:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Be1lKzjxgdJc9x37v6EmqGaFYqydTNNqfKdUh77d/MwWSIO0bIeWgwZEF6eum7gtxOKiF X-Received: by 2002:a17:906:234a:b0:7ac:e7b1:20c8 with SMTP id m10-20020a170906234a00b007ace7b120c8mr11530015eja.68.1669214929306; Wed, 23 Nov 2022 06:48:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669214929; cv=none; d=google.com; s=arc-20160816; b=X/ZE206mGzh7aZKQxjs+Tg3lImny//wC5M339kfM5mxQxMrfT4EF3Z9AW7T2+fLktz ys9TGAmEYsVqjB1qSC9ItnmEL88KlkGx1umv4Bk3eL2rTvNTfDj23PTA1j8Xxa5Vpx8V LGAr7ApEswYv6rdX6yyyvP/FlG68NuUFBhwRavnFcbCtVmn2cr0Bm7PHIHRUhUEY50I4 zZ3LjMM57d8RbYa/025eQOx3+pm5qJpcQhd2gx2hNrd+zDa+eIl5eBYqmy8J0KPtGO36 FzlE1xsHwgsf665KBkySeoxxiV5nF51rgfZZAJtWS1r4Fq+t4SjguMwxg7Ncow+zt69a g0SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=pIRLeCYkI0O65rifvSM+7LRoSpXb6BrwQ8SXCPLbAM8=; b=hiUASxbAZZoasuPYYfO9X5E3/q+iGSXlrEmJ0vepCLRy4IFJH8Q00ZGNZzSkjOZesw MUnBR1NMlg4lLTL7n6E5Kz1UzNjmrjjAsADqtFvrdcon5RMrZqdaJAlNG+eIXrSMj/KT vWCja4kh2AkPLi4t5lZM7gF0lsQcbbO5OcvyMFoeWG9WmA0NLzGALJz+KeGOwOQPsL9T lt8euAgSdOH35uxptFfKHC5mpopUWIExzH1FlOtXJSkXQmC+9hK4e/6QqRIf+JbfoqYf hFXV/1ZAQIV14v9wF5ZG9jAGF/ApNrJbiNO5Ouz4TEuwPJDfQnOEHryhDRgdey8yyOtA AUdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f17-20020a170906825100b007a1e33462c1si11124022ejx.268.2022.11.23.06.48.24; Wed, 23 Nov 2022 06:48:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238872AbiKWOmA (ORCPT + 99 others); Wed, 23 Nov 2022 09:42:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238130AbiKWOli (ORCPT ); Wed, 23 Nov 2022 09:41:38 -0500 Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5406E53EF0 for ; Wed, 23 Nov 2022 06:41:33 -0800 (PST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed10:881b:815b:474d:c3fd]) by albert.telenet-ops.be with bizsmtp id nqhS2800C49U0Rd06qhSTe; Wed, 23 Nov 2022 15:41:30 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1oxqwH-001Rqh-NY; Wed, 23 Nov 2022 15:41:25 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1oxqwH-0012HN-2m; Wed, 23 Nov 2022 15:41:25 +0100 From: Geert Uytterhoeven To: Krzysztof Kozlowski , Vignesh Raghavendra , Miquel Raynal , Richard Weinberger , Mark Brown Cc: Philipp Zabel , Sergey Shtylyov , Wolfram Sang , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 2/6] memory: renesas-rpc-if: Move resource acquisition to .probe() Date: Wed, 23 Nov 2022 15:41:18 +0100 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750298713320936337?= X-GMAIL-MSGID: =?utf-8?q?1750298713320936337?= While the acquired resources are tied to the lifetime of the RPC-IF core device (through the use of managed resource functions), the actual resource acquisition is triggered from the HyperBus and SPI child drivers. Due to this mismatch, unbinding and rebinding the child drivers manually fails with -EBUSY: # echo rpc-if-hyperflash > /sys/bus/platform/drivers/rpc-if-hyperflash/unbind # echo rpc-if-hyperflash > /sys/bus/platform/drivers/rpc-if-hyperflash/bind rpc-if ee200000.spi: can't request region for resource [mem 0xee200000-0xee2001ff] rpc-if-hyperflash: probe of rpc-if-hyperflash failed with error -16 The same is true for rpc-if-spi. Fix this by moving all resource acquisition to the core driver's probe routine. Fixes: ca7d8b980b67f133 ("memory: add Renesas RPC-IF driver") Signed-off-by: Geert Uytterhoeven --- v2: - Move forward in series, - Add Fixes tag. --- drivers/memory/renesas-rpc-if.c | 49 ++++++++++++++++----------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-if.c index 224973ac859f88fa..42c5f9f10135b86a 100644 --- a/drivers/memory/renesas-rpc-if.c +++ b/drivers/memory/renesas-rpc-if.c @@ -277,32 +277,7 @@ static const struct regmap_config rpcif_regmap_config = { int rpcif_sw_init(struct rpcif *rpcif, struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); struct rpcif_priv *rpc = dev_get_drvdata(dev); - struct resource *res; - - rpc->base = devm_platform_ioremap_resource_byname(pdev, "regs"); - if (IS_ERR(rpc->base)) - return PTR_ERR(rpc->base); - - rpc->regmap = devm_regmap_init(&pdev->dev, NULL, rpc, &rpcif_regmap_config); - if (IS_ERR(rpc->regmap)) { - dev_err(&pdev->dev, - "failed to init regmap for rpcif, error %ld\n", - PTR_ERR(rpc->regmap)); - return PTR_ERR(rpc->regmap); - } - - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dirmap"); - rpc->dirmap = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(rpc->dirmap)) - return PTR_ERR(rpc->dirmap); - rpc->size = resource_size(res); - - rpc->type = (uintptr_t)of_device_get_match_data(dev); - rpc->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); - if (IS_ERR(rpc->rstc)) - return PTR_ERR(rpc->rstc); rpcif->dev = dev; rpcif->dirmap = rpc->dirmap; @@ -705,9 +680,11 @@ EXPORT_SYMBOL(rpcif_dirmap_read); static int rpcif_probe(struct platform_device *pdev) { + struct device *dev = &pdev->dev; struct platform_device *vdev; struct device_node *flash; struct rpcif_priv *rpc; + struct resource *res; const char *name; int ret; @@ -732,6 +709,28 @@ static int rpcif_probe(struct platform_device *pdev) if (!rpc) return -ENOMEM; + rpc->base = devm_platform_ioremap_resource_byname(pdev, "regs"); + if (IS_ERR(rpc->base)) + return PTR_ERR(rpc->base); + + rpc->regmap = devm_regmap_init(dev, NULL, rpc, &rpcif_regmap_config); + if (IS_ERR(rpc->regmap)) { + dev_err(dev, "failed to init regmap for rpcif, error %ld\n", + PTR_ERR(rpc->regmap)); + return PTR_ERR(rpc->regmap); + } + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dirmap"); + rpc->dirmap = devm_ioremap_resource(dev, res); + if (IS_ERR(rpc->dirmap)) + return PTR_ERR(rpc->dirmap); + rpc->size = resource_size(res); + + rpc->type = (uintptr_t)of_device_get_match_data(dev); + rpc->rstc = devm_reset_control_get_exclusive(dev, NULL); + if (IS_ERR(rpc->rstc)) + return PTR_ERR(rpc->rstc); + vdev = platform_device_alloc(name, pdev->id); if (!vdev) return -ENOMEM;