Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6834667imu; Thu, 31 Jan 2019 00:03:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN6KOquT+PRmwMj0EI/B6UlDDLP1HVObndsQKcT79F4wAaZXRIO3GOL+U0o6W8U56u50OQSj X-Received: by 2002:aa7:8802:: with SMTP id c2mr33632144pfo.20.1548921824270; Thu, 31 Jan 2019 00:03:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548921824; cv=none; d=google.com; s=arc-20160816; b=c0bCGRqWMNtcUxm9P7ZHNdC2ynUOKIx4cwgAzXKSfrBdcFkcrAvAJ/0eOKdhorLoSZ xUzXjXrdq6M1kgXpH6MP8C+twPlbIDy+QbRXTdDVe32cxjJVKNDftuq5xVTmyzK47rir MEHS45xfjfxfYOrHrBlMT6gjf+Qwwq2ajfrK8LNSiXT02BRFyauiylySYSH3qNZmWpID 6SRHGAc+rAzBKKK5w3sYRGtH/QtnLK4OXs2tEye4gpwuZfk2uLPkVw2LGwB8B2Lixi/4 f8M7qPbTOOHSw3Agk3fpokeNjI4sdNCclqTh/BEJPF3b0zawxxV37ZdEOmwLjGvywR4z 6JgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=9tUt9BZ2PqoFZsPMmvkDBKxZVnN3VK4lzmMgH1eSIhs=; b=HB8c7Zd6Q4naEkhuZ1u8bjtD2MfN17NZNPEVM/YPddoRKCPURYFKkbaEpLfyy1ztl9 xtUCcAP5WURUfyuhzawgznw33SOKcj6HHGkBdH33pwNkvK9SS37bvCTqQkz2dN4Dfp9m ugOXS8OZ58nct5MAsIHNgC6/gGggR7ZyXn9GyhzWG0zLnUGkIjmUtkF9SIKfbNHBNbyA eMA3jneyS8as6fPJTjcXs1Bne9O5hGPcQGVVc173nX2+O9Xz626x0R7X/nETfz845+S6 laQSruOxdo3Ee0a0VTdRrJdsXUfnS0L6iHf4xZZn6oQU5YayyAFjZ4cuk03hC1IXanVe 8huw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s80si3855414pfa.130.2019.01.31.00.03.28; Thu, 31 Jan 2019 00:03:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731367AbfAaICG (ORCPT + 99 others); Thu, 31 Jan 2019 03:02:06 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:9831 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725855AbfAaICE (ORCPT ); Thu, 31 Jan 2019 03:02:04 -0500 X-UUID: 4951c54a53204df580ce47673a529fe7-20190131 X-UUID: 4951c54a53204df580ce47673a529fe7-20190131 Received: from mtkcas07.mediatek.inc [(172.21.101.84)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1053852584; Thu, 31 Jan 2019 16:01:59 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs08n2.mediatek.inc (172.21.101.56) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 31 Jan 2019 16:01:56 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 31 Jan 2019 16:01:56 +0800 From: To: , , , , , , CC: , , , , , Honghui Zhang Subject: [PATCH v2 1/2] PCI: mediatek: Use resource_size function on resource object Date: Thu, 31 Jan 2019 16:01:52 +0800 Message-ID: <1548921713-5355-2-git-send-email-honghui.zhang@mediatek.com> X-Mailer: git-send-email 2.6.4 In-Reply-To: <1548921713-5355-1-git-send-email-honghui.zhang@mediatek.com> References: <1548921713-5355-1-git-send-email-honghui.zhang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-SNTS-SMTP: 35E5A7B92BE2FA1A7C5DE91269123E30A57F6697C5DE280A9D1E796F540EA96F2000:8 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Honghui Zhang scripts/coccinelle/api/resource_size.cocci complain about the following warning: pcie-mediatek.c:720:13-16: WARNING: Suspicious code. resource_size is maybe missing with mem Use resource_size(mem) instead of mem->end - mem->start to eliminate the complain. Since the MMIO window size for both MT2712 and MT7622 are all 0x1000_0000, this change also fix the AHB2PCIe window size smaller than HW MMIO window size issue by change the values of fls(size) from fls(0xfff_ffff) to fls(0x1000_0000). Signed-off-by: Honghui Zhang --- drivers/pci/controller/pcie-mediatek.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 55e471c..01126b8 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -654,7 +654,6 @@ static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) struct resource *mem = &pcie->mem; const struct mtk_pcie_soc *soc = port->pcie->soc; u32 val; - size_t size; int err; /* MT7622 platforms need to enable LTSSM and ASPM from PCIe subsys */ @@ -706,8 +705,8 @@ static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) mtk_pcie_enable_msi(port); /* Set AHB to PCIe translation windows */ - size = mem->end - mem->start; - val = lower_32_bits(mem->start) | AHB2PCIE_SIZE(fls(size)); + val = lower_32_bits(mem->start) + | AHB2PCIE_SIZE(fls(resource_size(mem))); writel(val, port->base + PCIE_AHB_TRANS_BASE0_L); val = upper_32_bits(mem->start); -- 2.6.4