Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3498565pxb; Mon, 4 Apr 2022 18:55:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuj1pGaDNc7NSOqkeaChsnWfae7b6mh8i7k5ZsQJQ2CBlpT777LWJeHMJ/J9p9GNEc8e9I X-Received: by 2002:a63:1d1f:0:b0:399:5cd:15b6 with SMTP id d31-20020a631d1f000000b0039905cd15b6mr860304pgd.91.1649123751722; Mon, 04 Apr 2022 18:55:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649123751; cv=none; d=google.com; s=arc-20160816; b=IP8YZ7SG81XY4t6iV1uzTiO+5rjIHZ8yls6q5THrWoK49GCp97aJAPY+pn/S+pA8Np pQAdr9q/D98AHvw6wygc7a2EhtxK65lKjWz6crHdhw/uSLmian4KUa45Fs43TD50okSC KTzLBOwW2sUKn6Ihi8GaLmxkoao6hKSCqGsl8WS8B1kb2qD007MiszUKg9zNuktkTn7/ 6jsZvNqvqm+grQO9cwK2ByN0PH1L7f5IT3ESA23KtWXCXlkWUQi/ZN4foNIKmMoN0hhl QuSbvuq0u8+YZMu01R3ndKZ+zOCrrGC+ifvIKjdxk8w0gZvMcZAU4ir9AagWBzLCpCTM yuSg== 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 :dkim-signature; bh=nCHNYot625EnAVBK5VOhUP+5vbgUYJ9BdY/54uVs0mY=; b=x1GdpCyhDZ7GtDxQrV7kcub9gKp2nsJ4RojkuE8vyWRzfXijm3DdMAnERVi/sVxX95 7M3RHUcilMa6j91b2brJD/LlUlh5oCbhvXSbPXiD24vn7v8DKkll/3saeAZTqGqM4h87 2Um3Dbbo0WKud4W7rwOFkkGO5qYX1wQTp7t4JgG7jj0PcZ2u77Z0V/EJp614SCXER8Ps cgCOnCx5yeuvFIwA9cKUd2dLEkYNHbZzeb0opwuYdtcHmT/M/pmuUp1aeG29DKqdkkYP iiCba09pci1j+LILG2ytNCaCu5jP03VWxvcsu2/KtKsUFuxCbo8rpZStNOZtGdb4EZOd fSZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=ts+JPCiG; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id x12-20020a170902ec8c00b00153b2d16663si11954189plg.619.2022.04.04.18.55.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 18:55:51 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=ts+JPCiG; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CFA8F325701; Mon, 4 Apr 2022 18:00:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355391AbiDDJ7g (ORCPT + 99 others); Mon, 4 Apr 2022 05:59:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355007AbiDDJ7X (ORCPT ); Mon, 4 Apr 2022 05:59:23 -0400 Received: from ssl.serverraum.org (ssl.serverraum.org [176.9.125.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9848E3BFBC for ; Mon, 4 Apr 2022 02:57:26 -0700 (PDT) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ssl.serverraum.org (Postfix) with ESMTPSA id 7E0282224D; Mon, 4 Apr 2022 11:57:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1649066244; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nCHNYot625EnAVBK5VOhUP+5vbgUYJ9BdY/54uVs0mY=; b=ts+JPCiGtXb2+nvWTf7wPUYySMiTz4tdow6DFbPbVlFy/GT7hVythTAc0Tzs4I461Ae3EC oSF+/K/mkb1twTOhH5W+SmtxZtfi+DHemFShOxfDAmBrXYqz+bSjj9dllkv0f6mDTO606D k5vTJbwIoCdWl0CztRlWBylerNLtBTs= From: Michael Walle To: linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Shawn Guo , Li Yang , Ulf Hansson , Sudeep Holla , Arnd Bergmann , Dan Carpenter , Michael Walle Subject: [PATCH RESEND v2 3/7] soc: fsl: guts: embed fsl_guts_get_svr() in probe() Date: Mon, 4 Apr 2022 11:56:05 +0200 Message-Id: <20220404095609.3932782-4-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220404095609.3932782-1-michael@walle.cc> References: <20220404095609.3932782-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Move the reading of the SVR into the probe function as fsl_guts_get_svr() is the only user of the static guts variable and this lets us drop that as well as the malloc() for this variable. Also, we can unmap the memory region after we accessed it, which will simplify error handling later. Signed-off-by: Michael Walle Acked-by: Arnd Bergmann --- drivers/soc/fsl/guts.c | 42 +++++++++++------------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index 0bea43770d51..4e5675ab5f73 100644 --- a/drivers/soc/fsl/guts.c +++ b/drivers/soc/fsl/guts.c @@ -14,18 +14,12 @@ #include #include -struct guts { - struct ccsr_guts __iomem *regs; - bool little_endian; -}; - struct fsl_soc_die_attr { char *die; u32 svr; u32 mask; }; -static struct guts *guts; static struct soc_device_attribute soc_dev_attr; @@ -119,40 +113,27 @@ static const struct fsl_soc_die_attr *fsl_soc_die_match( return NULL; } -static u32 fsl_guts_get_svr(void) -{ - u32 svr = 0; - - if (!guts || !guts->regs) - return svr; - - if (guts->little_endian) - svr = ioread32(&guts->regs->svr); - else - svr = ioread32be(&guts->regs->svr); - - return svr; -} - static int fsl_guts_probe(struct platform_device *pdev) { struct device_node *root, *np = pdev->dev.of_node; static struct soc_device *soc_dev; struct device *dev = &pdev->dev; const struct fsl_soc_die_attr *soc_die; + struct ccsr_guts __iomem *regs; const char *machine = NULL; + bool little_endian; u32 svr; - /* Initialize guts */ - guts = devm_kzalloc(dev, sizeof(*guts), GFP_KERNEL); - if (!guts) - return -ENOMEM; - - guts->little_endian = of_property_read_bool(np, "little-endian"); + regs = of_iomap(np, 0); + if (IS_ERR(regs)) + return PTR_ERR(regs); - guts->regs = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(guts->regs)) - return PTR_ERR(guts->regs); + little_endian = of_property_read_bool(np, "little-endian"); + if (little_endian) + svr = ioread32(®s->svr); + else + svr = ioread32be(®s->svr); + iounmap(regs); /* Register soc device */ root = of_find_node_by_path("/"); @@ -167,7 +148,6 @@ static int fsl_guts_probe(struct platform_device *pdev) } of_node_put(root); - svr = fsl_guts_get_svr(); soc_die = fsl_soc_die_match(svr, fsl_soc_die); if (soc_die) { soc_dev_attr.family = devm_kasprintf(dev, GFP_KERNEL, -- 2.30.2