Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp4929983pxb; Tue, 28 Sep 2021 07:09:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIioiBoC2ztVIv9HjUf8ohjaU1r3Cuf95F31pS/RfGXN2AXLFe8sHhalrGJUHkDz6VicTf X-Received: by 2002:a17:902:e892:b0:13c:9ce7:af60 with SMTP id w18-20020a170902e89200b0013c9ce7af60mr5324547plg.41.1632838188458; Tue, 28 Sep 2021 07:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632838188; cv=none; d=google.com; s=arc-20160816; b=AW4lvjW8otWK6r42cjwhDmDc9NgQ8APnyUKB5iFSI78ipGatdWV6aA2I8BMakN5fym LCw07EJTFXSYRRyp9L2aParWcmAydKGZyW1onIeeIKztCJlqx1phfh61wFjHcHDTWsZW zN9XA+kk5Xz4zrSZ5jZHOS1gR4QVymN8Wrfr3wkGhThme292EQ1whb3lgvQxMaL+Njl0 JkDePbnkuuVAapD9AonfzOCYXfASnXBTZ7XgOi6YkDvjGaAZrJ6302X++DVfbXi0L9zW jP90ZBqTNmTHet6//15pha0eQMdLTNYYbQnOZ4vVnQuKXKLwoqIAa2UszjwgiBTNKpf2 oeeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=gmec7z2NJJIGLAdY3LbaVY9/hJfdBxkuHGnNPZUzNSg=; b=VefiEA8nh5Wz49L4DqYj+0KP1cAsHxHiTUX7tfkMwsyOrShUiRcyBXAiOxqZloX+WI UUiYdwijA8DBhIM64O2njaA1H+0bWPtamvzVmiYmUSxagWR3PskrKW5qU9TAJQlxer+D YQeLXUlMbIWfuf+T+63/T0QUNj1Q8jSGnYNHpxe/ImM313XfH78yDlsYjZkpwxVmTiC1 SPtUE8DJ1WovJAehChqZfVMMNPwnFHoqITzrfq4Ph4yt+x31v9JP9mZIvR6DcHxk4cTm aw3Zaiw20QfMhHV9TTy1PJBMFTsLJcnSN+dK6PdgScTUlkMqPMgrvzQgFPj4m2Gzdgri TMJw== ARC-Authentication-Results: i=1; mx.google.com; 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 w70si23620003pgd.232.2021.09.28.07.09.33; Tue, 28 Sep 2021 07:09:48 -0700 (PDT) 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; 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 S241220AbhI1OJh (ORCPT + 99 others); Tue, 28 Sep 2021 10:09:37 -0400 Received: from relmlor1.renesas.com ([210.160.252.171]:53552 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S241202AbhI1OJc (ORCPT ); Tue, 28 Sep 2021 10:09:32 -0400 X-IronPort-AV: E=Sophos;i="5.85,329,1624287600"; d="scan'208";a="95295300" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 28 Sep 2021 23:07:51 +0900 Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 452A74007535; Tue, 28 Sep 2021 23:07:48 +0900 (JST) From: Lad Prabhakar To: Krzysztof Kozlowski , Rob Herring , Geert Uytterhoeven , Vignesh Raghavendra , Miquel Raynal , Richard Weinberger , Mark Brown , Philipp Zabel , Sergei Shtylyov , devicetree@vger.kernel.org, linux-mtd@lists.infradead.org, linux-spi@vger.kernel.org, Wolfram Sang Cc: linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Biju Das , Lad Prabhakar Subject: [PATCH 5/6] memory: renesas-rpc-if: Drop usage of RPCIF_DIRMAP_SIZE macro Date: Tue, 28 Sep 2021 15:07:20 +0100 Message-Id: <20210928140721.8805-6-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210928140721.8805-1-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20210928140721.8805-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org RPCIF_DIRMAP_SIZE may differ on various SoC's. Instead of using RPCIF_DIRMAP_SIZE macro use resource size to get dirmap size which is already part of struct rpcif. Also make sure we return error in case devm_ioremap_resource() fails for dirmap. Fixes: ca7d8b980b67 ("memory: add Renesas RPC-IF driver") Fixes: 59e27d7c94aa ("memory: renesas-rpc-if: fix possible NULL pointer dereference of resource") Signed-off-by: Lad Prabhakar Reviewed-by: Biju Das --- drivers/memory/renesas-rpc-if.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/memory/renesas-rpc-if.c b/drivers/memory/renesas-rpc-if.c index 77a011d5ff8c..140cb4e2b789 100644 --- a/drivers/memory/renesas-rpc-if.c +++ b/drivers/memory/renesas-rpc-if.c @@ -147,8 +147,6 @@ #define RPCIF_PHYINT 0x0088 /* R/W */ #define RPCIF_PHYINT_WPVAL BIT(1) -#define RPCIF_DIRMAP_SIZE 0x4000000 - static const struct regmap_range rpcif_volatile_ranges[] = { regmap_reg_range(RPCIF_SMRDR0, RPCIF_SMRDR1), regmap_reg_range(RPCIF_SMWDR0, RPCIF_SMWDR1), @@ -244,7 +242,7 @@ int rpcif_sw_init(struct rpcif *rpc, struct device *dev) res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dirmap"); rpc->dirmap = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(rpc->dirmap)) - rpc->dirmap = NULL; + return PTR_ERR(rpc->dirmap); rpc->size = resource_size(res); rpc->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL); @@ -547,8 +545,8 @@ EXPORT_SYMBOL(rpcif_manual_xfer); ssize_t rpcif_dirmap_read(struct rpcif *rpc, u64 offs, size_t len, void *buf) { - loff_t from = offs & (RPCIF_DIRMAP_SIZE - 1); - size_t size = RPCIF_DIRMAP_SIZE - from; + loff_t from = offs & (rpc->size - 1); + size_t size = rpc->size - from; if (len > size) len = size; -- 2.17.1