From patchwork Sun Mar 19 16:31:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring (Arm)" X-Patchwork-Id: 13180461 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 CE6A1C6FD1F for ; Sun, 19 Mar 2023 16:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ifeeHqM3f+N2AWDStjj5vWaYTua07YAcGyoPZV3q3mo=; b=b81mVzcs3hbOg/ yI2zHQRoTk1/lNcZPRgTMuR0OT0SILhi38T3Q2SO4OJIF+m70i04qkFbLBuZzrdIBcyiyg+cWBuAW M7Wp8etMXRp+Ui5mYn7ISQjYJHg/8BDOWki+dlJP2KC5hcJwGZoBpnpMfKmMsYsMFr9mBmoH/kFBL vrS9as8JPhrgwNk/L3EbPS3OF4UNURbxoKfKFwFoZYCfUGFc/jswy7bF2PohPOt2CVdtmzFk1aO9F 7ggX6Q4/HsUXYeoyjMJFozWAOD+UFk9Tpd88rhcBVnUpnX5ZsX8m11CNNR6rtoydy6VJ40sRiEx7w GpqaFRJF38PLaQ0nuSqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pdvwc-0071Ti-1H; Sun, 19 Mar 2023 16:31:42 +0000 Received: from mail-il1-f181.google.com ([209.85.166.181]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pdvwZ-0071T7-0M for linux-arm-kernel@lists.infradead.org; Sun, 19 Mar 2023 16:31:40 +0000 Received: by mail-il1-f181.google.com with SMTP id r4so5413102ila.2 for ; Sun, 19 Mar 2023 09:31:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679243498; 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=kw5CAGPFONZEAhyqY84+LOi8v69hjMXriBK96mcuDDk=; b=QOMTv9hFO+8Tqkwbvaap+6F3hfP631fBfbixhMxSsOTUw6eDoe+8MRG3IgtRkPOggL VO70bRsMg0CwjSgyQbA/h2epPCRkvFsRJsAvUn2fGoPv5ArUhcc+sRT69evtfZdBFnlt TyXP0uPo5l3gtUDXi2xylT4nLIluDH6w2SyZaG+jMoDJAyUSiuRRi8dFgFS4leXakmD8 Fth9GWWbhEv2Th7ZnoXHKDSqFSryR91yMGworMDmXuEM4zKMnPw2ur4DcBrJeKoiSVue ip7KSg1zh2RQpgV2G8oC+lHTbS63hYdd6ibtBeba0oP9/fz2J4+zw/lEBygSQ8JtWxLK hf0A== X-Gm-Message-State: AO0yUKX7rryabagItptIwROJRkg294UC0eDY21gHMN1XH/JEEqg/DZ5v kJDHAPIJGXFS7r17N7Z0qg== X-Google-Smtp-Source: AK7set/MpMVQ7EQFB7nhMDZe1DCOVy4MPhpGUoqiwKkhY0F96+ZljO6aB6dmdffFzjKMCv65P0acUA== X-Received: by 2002:a92:c682:0:b0:310:9c85:9db6 with SMTP id o2-20020a92c682000000b003109c859db6mr3500430ilg.24.1679243497880; Sun, 19 Mar 2023 09:31:37 -0700 (PDT) Received: from robh_at_kernel.org ([2605:ef80:80c7:2689:137d:d795:47e4:3de1]) by smtp.gmail.com with ESMTPSA id t131-20020a025489000000b004063510ba19sm2605739jaa.101.2023.03.19.09.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Mar 2023 09:31:37 -0700 (PDT) Received: (nullmailer pid 225033 invoked by uid 1000); Sun, 19 Mar 2023 16:31:34 -0000 From: Rob Herring To: Russell King , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] ARM: bcm: Use of_address_to_resource() Date: Sun, 19 Mar 2023 11:31:25 -0500 Message-Id: <20230319163125.224833-1-robh@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230319_093139_148004_5B395A3E X-CRM114-Status: GOOD ( 14.30 ) 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 Replace open coded parsing of "reg" with of_address_to_resource(). Signed-off-by: Rob Herring --- arch/arm/mach-bcm/bcm_kona_smc.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/arch/arm/mach-bcm/bcm_kona_smc.c b/arch/arm/mach-bcm/bcm_kona_smc.c index 185335843bbd..f236e12d7a59 100644 --- a/arch/arm/mach-bcm/bcm_kona_smc.c +++ b/arch/arm/mach-bcm/bcm_kona_smc.c @@ -31,34 +31,23 @@ static const struct of_device_id bcm_kona_smc_ids[] __initconst = { int __init bcm_kona_smc_init(void) { struct device_node *node; - const __be32 *prop_val; - u64 prop_size = 0; - unsigned long buffer_size; - u32 buffer_phys; + struct resource res; + int ret; /* Read buffer addr and size from the device tree node */ node = of_find_matching_node(NULL, bcm_kona_smc_ids); if (!node) return -ENODEV; - prop_val = of_get_address(node, 0, &prop_size, NULL); + ret = of_address_to_resource(node, 0, &res); of_node_put(node); - if (!prop_val) + if (ret) return -EINVAL; - /* We assume space for four 32-bit arguments */ - if (prop_size < 4 * sizeof(u32) || prop_size > (u64)ULONG_MAX) - return -EINVAL; - buffer_size = (unsigned long)prop_size; - - buffer_phys = be32_to_cpup(prop_val); - if (!buffer_phys) - return -EINVAL; - - bcm_smc_buffer = ioremap(buffer_phys, buffer_size); + bcm_smc_buffer = ioremap(res.start, resource_size(&res)); if (!bcm_smc_buffer) return -ENOMEM; - bcm_smc_buffer_phys = buffer_phys; + bcm_smc_buffer_phys = res.start; pr_info("Kona Secure API initialized\n");