From nobody Tue Jun 30 21:24:56 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B99BC433FE for ; Sat, 8 Jan 2022 16:16:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229868AbiAHQQW (ORCPT ); Sat, 8 Jan 2022 11:16:22 -0500 Received: from smtp04.smtpout.orange.fr ([80.12.242.126]:54933 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbiAHQQV (ORCPT ); Sat, 8 Jan 2022 11:16:21 -0500 Received: from pop-os.home ([90.11.185.88]) by smtp.orange.fr with ESMTPA id 6EOAnCR2IWUfj6EOAnE8Wo; Sat, 08 Jan 2022 17:16:20 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Sat, 08 Jan 2022 17:16:20 +0100 X-ME-IP: 90.11.185.88 From: Christophe JAILLET To: rmody@marvell.com, skalluru@marvell.com, GR-Linux-NIC-Dev@marvell.com, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH] bna: Simplify DMA setting Date: Sat, 8 Jan 2022 17:16:16 +0100 Message-Id: <1d5a7b3f4fa735f1233c3eb3fa07e71df95fad75.1641658516.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" As stated in [1], dma_set_mask() with a 64-bit mask will never fail if dev->dma_mask is non-NULL. So, if it fails, the 32 bits case will also fail for the same reason. So, if dma_set_mask_and_coherent() succeeds, 'using_dac' is known to be 'true'. This variable can be removed. Simplify code and remove some dead code accordingly. [1]: https://lkml.org/lkml/2021/6/7/398 Signed-off-by: Christophe JAILLET --- drivers/net/ethernet/brocade/bna/bnad.c | 34 ++++++++----------------- 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet= /brocade/bna/bnad.c index bbdc829c3524..f1d2c4cd5da2 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.c +++ b/drivers/net/ethernet/brocade/bna/bnad.c @@ -3421,7 +3421,7 @@ static const struct net_device_ops bnad_netdev_ops = =3D { }; =20 static void -bnad_netdev_init(struct bnad *bnad, bool using_dac) +bnad_netdev_init(struct bnad *bnad) { struct net_device *netdev =3D bnad->netdev; =20 @@ -3434,10 +3434,8 @@ bnad_netdev_init(struct bnad *bnad, bool using_dac) NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_TSO | NETIF_F_TSO6; =20 - netdev->features |=3D netdev->hw_features | NETIF_F_HW_VLAN_CTAG_FILTER; - - if (using_dac) - netdev->features |=3D NETIF_F_HIGHDMA; + netdev->features |=3D netdev->hw_features | NETIF_F_HW_VLAN_CTAG_FILTER | + NETIF_F_HIGHDMA; =20 netdev->mem_start =3D bnad->mmio_start; netdev->mem_end =3D bnad->mmio_start + bnad->mmio_len - 1; @@ -3544,8 +3542,7 @@ bnad_lock_uninit(struct bnad *bnad) =20 /* PCI Initialization */ static int -bnad_pci_init(struct bnad *bnad, - struct pci_dev *pdev, bool *using_dac) +bnad_pci_init(struct bnad *bnad, struct pci_dev *pdev) { int err; =20 @@ -3555,14 +3552,9 @@ bnad_pci_init(struct bnad *bnad, err =3D pci_request_regions(pdev, BNAD_NAME); if (err) goto disable_device; - if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) { - *using_dac =3D true; - } else { - err =3D dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); - if (err) - goto release_regions; - *using_dac =3D false; - } + err =3D dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); + if (err) + goto release_regions; pci_set_master(pdev); return 0; =20 @@ -3585,7 +3577,6 @@ static int bnad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pcidev_id) { - bool using_dac; int err; struct bnad *bnad; struct bna *bna; @@ -3615,13 +3606,8 @@ bnad_pci_probe(struct pci_dev *pdev, bnad->id =3D atomic_inc_return(&bna_id) - 1; =20 mutex_lock(&bnad->conf_mutex); - /* - * PCI initialization - * Output : using_dac =3D 1 for 64 bit DMA - * =3D 0 for 32 bit DMA - */ - using_dac =3D false; - err =3D bnad_pci_init(bnad, pdev, &using_dac); + /* PCI initialization */ + err =3D bnad_pci_init(bnad, pdev); if (err) goto unlock_mutex; =20 @@ -3634,7 +3620,7 @@ bnad_pci_probe(struct pci_dev *pdev, goto pci_uninit; =20 /* Initialize netdev structure, set up ethtool ops */ - bnad_netdev_init(bnad, using_dac); + bnad_netdev_init(bnad); =20 /* Set link to down state */ netif_carrier_off(netdev); --=20 2.32.0