From patchwork Thu Apr 6 17:30:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 13203781 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 3BEB2C7618D for ; Thu, 6 Apr 2023 17:31:24 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iMNyOfNdu51+BkmYAWDzk8E9fFYg5nNsiOpLN2bT9Ks=; b=UTI47loOb1TBZr 4xzj52n5WsVnWJZhXR1n98bTNBzbmhqALzGZG5gXtkbakCZX28ggKNQAoU3SNpMMiegQ0EPyko7Sk 8Iqtvnlq+B2bvpYysRt7KEFQQzq5i3lh8vJa7FbyP3Nv6bFNuVyqOHrFUdEOB4h3gNgwbmaNFhrRC Xvpqv61Y8f/PkaUH+v4dZtSOeqwwWIs1kBKA1V9OpepC8eqikrkac1+pcS7oZmzufYjvXgQs2QyNo Y2oIkIvM77C/xNueNchLmRlQCX4SmNb41jsZXMf0+tRFYreUl3v1ufFGOyektGTFbup0gqvQPSJtu 8j75eHC14KvjZKkC9KoQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pkTRI-0088lU-0b; Thu, 06 Apr 2023 17:30:24 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pkTRE-0088kB-0p for linux-arm-kernel@lists.infradead.org; Thu, 06 Apr 2023 17:30:21 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9ED9664A7A; Thu, 6 Apr 2023 17:30:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A998C433D2; Thu, 6 Apr 2023 17:30:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680802219; bh=ZJKba0+w5vwtN3goyHbArkfj6XhrRd7mEr46lY1n1Ag=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=A/aOGZg8KrdEMzpZI1ZeCrSP4OnuuIbmN7t1goTxUddA3EpT32t4hIgRvxTsJ/jst ZwNNbKdwws39ddAoVRaU1QVsD95W0ubL/CnuF+zr/fpO+t+fQp+cI72uMBpi7lS3Kn NLfYa7tGHwTPUkWdexCqfEznsGxvrzHKvuOmtwPzcpqwJjPerGnHofRBDNTUWt1xgx j7ZFOI45igB4whQCI+izb+bW8ETqlztIK2h57iYMlbEP2eZoXyl7nUVssesLGOj1bW vGgTA16WwcSQYNcakf/rYoZ5F+Dbud8uFg6SWG4dnUkg1DLiw7aldFriFo2r/NnA9m a5qZwJJhOm11g== From: Simon Horman Date: Thu, 06 Apr 2023 19:30:09 +0200 Subject: [PATCH net-next 1/2] net: stmmac: dwmac-anarion: Use annotation __iomem for register base MIME-Version: 1.0 Message-Id: <20230406-dwmac-anarion-sparse-v1-1-b0c866c8be9d@kernel.org> References: <20230406-dwmac-anarion-sparse-v1-0-b0c866c8be9d@kernel.org> In-Reply-To: <20230406-dwmac-anarion-sparse-v1-0-b0c866c8be9d@kernel.org> To: Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.12.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230406_103020_333823_16FF6AF1 X-CRM114-Status: GOOD ( 13.60 ) 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 Use __iomem annotation the register base: the ctl_block field of struct anarion_gmac. I believe this is the normal practice for such variables. By doing so some casting is avoided. And sparse no longer reports: .../dwmac-anarion.c:29:23: warning: incorrect type in argument 1 (different address spaces) .../dwmac-anarion.c:29:23: expected void const volatile [noderef] __iomem *addr .../dwmac-anarion.c:29:23: got void * .../dwmac-anarion.c:34:22: warning: incorrect type in argument 2 (different address spaces) .../dwmac-anarion.c:34:22: expected void volatile [noderef] __iomem *addr .../dwmac-anarion.c:34:22: got void * No functional change intended. Compile tested only. Signed-off-by: Simon Horman --- drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c index dfbaea06d108..2357e77434fb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c @@ -20,18 +20,18 @@ #define GMAC_CONFIG_INTF_RGMII (0x1 << 0) struct anarion_gmac { - uintptr_t ctl_block; + void __iomem *ctl_block; uint32_t phy_intf_sel; }; static uint32_t gmac_read_reg(struct anarion_gmac *gmac, uint8_t reg) { - return readl((void *)(gmac->ctl_block + reg)); + return readl(gmac->ctl_block + reg); }; static void gmac_write_reg(struct anarion_gmac *gmac, uint8_t reg, uint32_t val) { - writel(val, (void *)(gmac->ctl_block + reg)); + writel(val, gmac->ctl_block + reg); } static int anarion_gmac_init(struct platform_device *pdev, void *priv) @@ -77,7 +77,7 @@ static struct anarion_gmac *anarion_config_dt(struct platform_device *pdev) if (!gmac) return ERR_PTR(-ENOMEM); - gmac->ctl_block = (uintptr_t)ctl_block; + gmac->ctl_block = ctl_block; err = of_get_phy_mode(pdev->dev.of_node, &phy_mode); if (err) From patchwork Thu Apr 6 17:30:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 13203779 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 35742C76196 for ; Thu, 6 Apr 2023 17:31:20 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mGk/QU55skgmtXY5atTzAYyN0FDN9RaSeONYsZc9aCg=; b=ROF3c3EvUgff6S fY5cZrrE8ZPBvie55uYuMC8ZhqXArHd3ASQGrJEQDF3OY9BUneq5v/e7LisWBWLfZytW7gOZ7RAHD vnT6rzpU7PSrYESQZuqKMnuFmyC2SwqJrRoHeaHbx8pm3LcLaiqAldd9Ox6lgC9edFn6fDVa0QVzI HEChqScWc1jkjBhJ1tM5I3+2+rLlrMQZuKGMDL+7fAeA0cIH6knoNmaub9mlRcTSVdaQCqy5ePeyn CvxabLjVuy0BRitYrZv0Hr/9uV+sQxIhwejeBCgsPslEit5DJwTGwNBMhtt0k15v7G9GbVl+5OYSW BdyJyYsA30EqBgqthfHA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pkTRL-0088lw-0g; Thu, 06 Apr 2023 17:30:27 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pkTRG-0088kv-1E for linux-arm-kernel@lists.infradead.org; Thu, 06 Apr 2023 17:30:23 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 019F564A7B; Thu, 6 Apr 2023 17:30:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 763E8C433EF; Thu, 6 Apr 2023 17:30:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680802221; bh=uTezeCfzpYKuhuhU2D8QgaY4IY+HPF1/VqkokcAEH/s=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=asWJygQgC55dAkjx6udpdZntn9zuHt+kcQ0wgfPkXijrhvumhv4d/EdkWjZEHE7N+ yQ9SaMwOJrnlBbTp5gMzf0WuZR6An4wuvhlKq2VTDDN7QWKJ+PFershPATGcWAZqHO 5W9BmCuXhTOb73ykf4CFUIIX0dMjlDlXoa9Y7finaHR447+dLH1oGzE4KthCFZNQB4 OWacI/iuswF2dqqdr+nS1SlS0t6eDREd4RYsfrZ9UgjrnpVaGChDZqcNkroTRPYeUe P7+WiNdpj3HseW4keCiCN2oq67bx0VL2IAwOaid3tZFAg5Q0KAeMJRz0UhxcaRM9M1 A6OsHLO0kcUkA== From: Simon Horman Date: Thu, 06 Apr 2023 19:30:10 +0200 Subject: [PATCH net-next 2/2] net: stmmac: dwmac-anarion: Always return struct anarion_gmac * from anarion_config_dt() MIME-Version: 1.0 Message-Id: <20230406-dwmac-anarion-sparse-v1-2-b0c866c8be9d@kernel.org> References: <20230406-dwmac-anarion-sparse-v1-0-b0c866c8be9d@kernel.org> In-Reply-To: <20230406-dwmac-anarion-sparse-v1-0-b0c866c8be9d@kernel.org> To: Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni Cc: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.12.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230406_103022_454388_E3BFB1CC X-CRM114-Status: GOOD ( 13.48 ) 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 Always return struct anarion_gmac * from anarion_config_dt(). In the case where ctl_block was an error pointer it was being returned directly. Which sparse flags as follows: .../dwmac-anarion.c:73:24: warning: incorrect type in return expression (different address spaces) .../dwmac-anarion.c:73:24: expected struct anarion_gmac * .../dwmac-anarion.c:73:24: got void [noderef] __iomem *[assigned] ctl_block Avoid this by converting the error pointer to an error. And then reversing the conversion. As a side effect, the error can be used for logging purposes, subjectively, leading to a minor cleanup. No functional change intended. Compile tested only. Signed-off-by: Simon Horman --- drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c index 2357e77434fb..9354bf419112 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-anarion.c @@ -68,9 +68,9 @@ static struct anarion_gmac *anarion_config_dt(struct platform_device *pdev) ctl_block = devm_platform_ioremap_resource(pdev, 1); if (IS_ERR(ctl_block)) { - dev_err(&pdev->dev, "Cannot get reset region (%ld)!\n", - PTR_ERR(ctl_block)); - return ctl_block; + err = PTR_ERR(ctl_block); + dev_err(&pdev->dev, "Cannot get reset region (%d)!\n", err); + return ERR_PTR(err); } gmac = devm_kzalloc(&pdev->dev, sizeof(*gmac), GFP_KERNEL);