Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp430569pxb; Fri, 28 Jan 2022 02:17:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBRdYuel3WY/Mtpz/spLpw9zZ/7QqEKxxTvXD5vThzTILB8w9FO7qJyM89qT+fhUP381I1 X-Received: by 2002:a63:380f:: with SMTP id f15mr6059901pga.60.1643365075874; Fri, 28 Jan 2022 02:17:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643365075; cv=none; d=google.com; s=arc-20160816; b=BLUMU1NYVCpmpyYWF5GUJpRClP5sRQOZpnQ7p/6hqaDwpb0VgX3W5nKPRurv0bvsDd pEjRqI5lYlTXHegIlRq1LzRWgkuhTJYmXN3BGdW/pKU3L6TCGyDkiPUYkmYnQ/4wwN2B VLijmLzgGfaJNf8ba/EBTTEA4BokPe4gQavKXBtc9JyWlXVp49HlUNF5FGsBZspS/j8m DszLK25lcq5u+DyR1t/OpcmYO56fquDc9eKzqr9UCeMZtcG5xEiVgftxVXOw3oK4kFjC DtwksfmfE1LIUoKcDkix1eawprBbxF/COCdqn+Z0iZBk81NHF1cH5Sh1iAEP15VQYni2 sApA== 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=dQTEDWQ6RIfy9o8kck9NRnhKASlbYsvOAuvfyda4Dbk=; b=nnCl/PThWcXtlaD6Z8kVvK+S6jN/lMtXX3NuLaad9fVEAVNhIX4M+xoErac1dIYp6k kMpELLZRHoW+IUXGRvzSL+zteavCHaE7Q0JPPmU0rb8ObaiZtUau7lpqtdb4y9y8StRM leTLNj7TYdQPvQl3eQ6xcqUzLHPKL4HUlFGCKnLW1NvaBeNB0rk+jsu9TMggAWYBa6Lr TY7gtHIdArpyidRtkkvWTVIb3exxAvtm+ROJJ5IlX7ZZr3oaR07hlrkweHnoWihZt3De Dz3gmBhMo7NYD6sg+UXEvcZJ+lCjd3a1O/JSyEqyCk3Hn30eDi5E8aiM+Mp4fDY9oBF+ jUHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=j2CFrtte; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 13si4789492pgv.584.2022.01.28.02.17.44; Fri, 28 Jan 2022 02:17:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2016061301 header.b=j2CFrtte; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243980AbiA0Qls (ORCPT + 99 others); Thu, 27 Jan 2022 11:41:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243935AbiA0Qln (ORCPT ); Thu, 27 Jan 2022 11:41:43 -0500 Received: from ssl.serverraum.org (ssl.serverraum.org [IPv6:2a01:4f8:151:8464::1:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9581AC061747 for ; Thu, 27 Jan 2022 08:41:43 -0800 (PST) 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 EF3F7223EF; Thu, 27 Jan 2022 17:41:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2016061301; t=1643301700; 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=dQTEDWQ6RIfy9o8kck9NRnhKASlbYsvOAuvfyda4Dbk=; b=j2CFrtteb7RlK1NVCouApJ3i42knoDyzSgub6t4Rf+8bnIDvlrm5EC1PiHr+As3PeNR6/U fjs6yXq9WlFlEYlcaTpqsy+pqXce1RJ6Cw27+FbLuOYjzBrr+84kfWow4gTat0dm3DG1/x fObvanLb2C4B+ZC7369DmTzO+oH16kw= From: Michael Walle To: linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Li Yang , Ulf Hansson , Sudeep Holla , Arnd Bergmann , Michael Walle Subject: [PATCH v1 3/7] soc: fsl: guts: embed fsl_guts_get_svr() in probe() Date: Thu, 27 Jan 2022 17:41:21 +0100 Message-Id: <20220127164125.3651285-4-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220127164125.3651285-1-michael@walle.cc> References: <20220127164125.3651285-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- drivers/soc/fsl/guts.c | 41 +++++++++++------------------------------ 1 file changed, 11 insertions(+), 30 deletions(-) diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index 0bea43770d51..536377988fb4 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,28 @@ 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; + little_endian = of_property_read_bool(np, "little-endian"); - 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); + 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 +149,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