net: aquantia: Switch alloc_etherdev to devm variant
Subsystems (3)
PATCH 1/1 net: aquantia: Switch alloc_etherdev to devm variant
Allows some simplification by avoiding calling free_netdev.
Tested on AMD based x86 system using AQC108 chipset.
--- drivers/net/ethernet/aquantia/atlantic/aq_main.c | 3 ++- drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c | 11 +++-------- 2 files changed, 5 insertions(+), 9 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_main.c +2 -1
@@ -30,7 +30,8 @@ struct net_device *aq_ndev_alloc(void)struct net_device *ndev =NULL ;struct aq_nic_s *aq_nic =NULL ; - ndev =alloc_etherdev_mq (sizeof (struct aq_nic_s ),AQ_CFG_VECS_MAX ); + ndev =devm_alloc_etherdev_mq (aq_nic->ndev,sizeof (struct aq_nic_s ), +AQ_CFG_VECS_MAX );if (!ndev)return NULL ;
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +3 -8
@@ -224,13 +224,11 @@ static int aq_pci_probe(struct pci_dev *pdev, err =aq_pci_probe_get_hw_by_id (pdev, &self->aq_hw_ops, &aq_nic_get_cfg (self)->aq_hw_caps);if (err) - goto err_ioremap; +return err; self->aq_hw =kzalloc (sizeof (*self->aq_hw),GFP_KERNEL ); -if (!self->aq_hw) { - err = -ENOMEM ; - goto err_ioremap; - } +if (!self->aq_hw) +return -ENOMEM ; self->aq_hw->aq_nic_cfg =aq_nic_get_cfg (self);for (bar =0 ; bar <4 ; ++bar) {
@@ -296,8 +294,6 @@ static int aq_pci_probe(struct pci_dev *pdev,iounmap (self->aq_hw->mmio); err_free_aq_hw:kfree (self->aq_hw); -err_ioremap: -free_netdev (ndev); err_ndev:pci_release_regions (pdev); err_pci_func:
@@ -318,7 +314,6 @@ static void aq_pci_remove(struct pci_dev *pdev)iounmap (self->aq_hw->mmio);kfree (self->aq_hw);pci_release_regions (pdev); -free_netdev (self->ndev); }pci_disable_device (pdev);
Signature · 1 line
2.17.1
kbuild test robot
build botThank you for the patch! Yet something to improve:
Hi Rosen,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on net/master]
[also build test ERROR on v5.0 next-20190306]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Rosen-Penev/net-aquantia-Switch-alloc_etherdev-to-devm-variant/20190309-181154
reproduce:
# apt-get install sparse
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'All errors (new ones prefixed by >>):
>> drivers/net/ethernet/aquantia/atlantic/aq_main.c:33:16: sparse: error: undefined identifier 'devm_alloc_etherdev_mq'
vim +/devm_alloc_etherdev_mq +33 drivers/net/ethernet/aquantia/atlantic/aq_main.c
27
28 struct net_device *aq_ndev_alloc(void)
29 {
30 struct net_device *ndev = NULL;
31 struct aq_nic_s *aq_nic = NULL;
32
> 33 ndev = devm_alloc_etherdev_mq(aq_nic->ndev, sizeof(struct aq_nic_s),
34 AQ_CFG_VECS_MAX);
35 if (!ndev)
36 return NULL;
37
38 aq_nic = netdev_priv(ndev);
39 aq_nic->ndev = ndev;
40 ndev->netdev_ops = &aq_ndev_ops;
41 ndev->ethtool_ops = &aq_ethtool_ops;
42
43 return ndev;
44 }
45 ---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation