]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
wifi: ath10k: allocate dummy net_device dynamically
authorBreno Leitao <leitao@debian.org>
Mon, 22 Apr 2024 12:39:02 +0000 (05:39 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 24 Apr 2024 11:00:17 +0000 (12:00 +0100)
Embedding net_device into structures prohibits the usage of flexible
arrays in the net_device structure. For more details, see the discussion
at [1].

Un-embed the net_device from struct ath10k by converting it
into a pointer. Then use the leverage alloc_netdev() to allocate the
net_device object at ath10k_core_create(). The free of the device occurs
at ath10k_core_destroy().

[1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/

Signed-off-by: Breno Leitao <leitao@debian.org>
Acked-by: Kalle Valo <kvalo@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/wireless/ath/ath10k/core.c
drivers/net/wireless/ath/ath10k/core.h
drivers/net/wireless/ath/ath10k/pci.c
drivers/net/wireless/ath/ath10k/sdio.c
drivers/net/wireless/ath/ath10k/snoc.c
drivers/net/wireless/ath/ath10k/usb.c

index 9ce6f49ab2614e58baf88c75cff51159e40b6dad..8663822e0b8d34604632a8055038ac98159904d1 100644 (file)
@@ -3673,11 +3673,13 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
        INIT_WORK(&ar->set_coverage_class_work,
                  ath10k_core_set_coverage_class_work);
 
-       init_dummy_netdev(&ar->napi_dev);
+       ar->napi_dev = alloc_netdev_dummy(0);
+       if (!ar->napi_dev)
+               goto err_free_tx_complete;
 
        ret = ath10k_coredump_create(ar);
        if (ret)
-               goto err_free_tx_complete;
+               goto err_free_netdev;
 
        ret = ath10k_debug_create(ar);
        if (ret)
@@ -3687,6 +3689,8 @@ struct ath10k *ath10k_core_create(size_t priv_size, struct device *dev,
 
 err_free_coredump:
        ath10k_coredump_destroy(ar);
+err_free_netdev:
+       free_netdev(ar->napi_dev);
 err_free_tx_complete:
        destroy_workqueue(ar->workqueue_tx_complete);
 err_free_aux_wq:
@@ -3708,6 +3712,7 @@ void ath10k_core_destroy(struct ath10k *ar)
 
        destroy_workqueue(ar->workqueue_tx_complete);
 
+       free_netdev(ar->napi_dev);
        ath10k_debug_destroy(ar);
        ath10k_coredump_destroy(ar);
        ath10k_htt_tx_destroy(&ar->htt);
index c110d15528bd05d53f371882d1bd9ae91a191e3f..26003b51957477007be3ae102c773783eaa37282 100644 (file)
@@ -1269,7 +1269,7 @@ struct ath10k {
        struct ath10k_per_peer_tx_stats peer_tx_stats;
 
        /* NAPI */
-       struct net_device napi_dev;
+       struct net_device *napi_dev;
        struct napi_struct napi;
 
        struct work_struct set_coverage_class_work;
index 5c34b156b4ff49514be3a66bb2fda11a80202a52..558bec96ae40edd582bbccd119d29e9959e54442 100644 (file)
@@ -3217,7 +3217,7 @@ static void ath10k_pci_free_irq(struct ath10k *ar)
 
 void ath10k_pci_init_napi(struct ath10k *ar)
 {
-       netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_pci_napi_poll);
+       netif_napi_add(ar->napi_dev, &ar->napi, ath10k_pci_napi_poll);
 }
 
 static int ath10k_pci_init_irq(struct ath10k *ar)
index 0ab5433f6cf6f261cde6347edf38a219e979843d..e28f2fe1101b2c36466c6750a101a67cf67b8906 100644 (file)
@@ -2532,7 +2532,7 @@ static int ath10k_sdio_probe(struct sdio_func *func,
                return -ENOMEM;
        }
 
-       netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_sdio_napi_poll);
+       netif_napi_add(ar->napi_dev, &ar->napi, ath10k_sdio_napi_poll);
 
        ath10k_dbg(ar, ATH10K_DBG_BOOT,
                   "sdio new func %d vendor 0x%x device 0x%x block 0x%x/0x%x\n",
index 2c39bad7ebfb9acab22a2d06e5434883814cf15e..0449b9ffc32d752f35522972a8b40dc29bf260ca 100644 (file)
@@ -935,7 +935,7 @@ static int ath10k_snoc_hif_start(struct ath10k *ar)
 
        bitmap_clear(ar_snoc->pending_ce_irqs, 0, CE_COUNT_MAX);
 
-       dev_set_threaded(&ar->napi_dev, true);
+       dev_set_threaded(ar->napi_dev, true);
        ath10k_core_napi_enable(ar);
        ath10k_snoc_irq_enable(ar);
        ath10k_snoc_rx_post(ar);
@@ -1253,7 +1253,7 @@ static int ath10k_snoc_napi_poll(struct napi_struct *ctx, int budget)
 
 static void ath10k_snoc_init_napi(struct ath10k *ar)
 {
-       netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_snoc_napi_poll);
+       netif_napi_add(ar->napi_dev, &ar->napi, ath10k_snoc_napi_poll);
 }
 
 static int ath10k_snoc_request_irq(struct ath10k *ar)
index 3c482baacec1065027d1314012d0942273f9c738..3b51b7f52130ee3d94c9b2791dccf47a46e52e95 100644 (file)
@@ -1014,7 +1014,7 @@ static int ath10k_usb_probe(struct usb_interface *interface,
                return -ENOMEM;
        }
 
-       netif_napi_add(&ar->napi_dev, &ar->napi, ath10k_usb_napi_poll);
+       netif_napi_add(ar->napi_dev, &ar->napi, ath10k_usb_napi_poll);
 
        usb_get_dev(dev);
        vendor_id = le16_to_cpu(dev->descriptor.idVendor);