Skip to content

Commit d0bcb10

Browse files
leitaoPing-Ke Shih
authored andcommitted
wifi: rtw88: Un-embed dummy device
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 the private struct by converting it into a pointer. Then use the leverage the new alloc_netdev_dummy() helper to allocate and initialize dummy devices. [1] https://lore.kernel.org/all/[email protected]/ Tested with RTL8723DE and RTL8822CE. Signed-off-by: Breno Leitao <[email protected]> Acked-by: Ping-Ke Shih <[email protected]> Tested-by: Ping-Ke Shih <[email protected]> Signed-off-by: Ping-Ke Shih <[email protected]> Link: https://msgid.link/[email protected]
1 parent 4c9aa94 commit d0bcb10

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

drivers/net/wireless/realtek/rtw88/pci.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,12 +1682,16 @@ static int rtw_pci_napi_poll(struct napi_struct *napi, int budget)
16821682
return work_done;
16831683
}
16841684

1685-
static void rtw_pci_napi_init(struct rtw_dev *rtwdev)
1685+
static int rtw_pci_napi_init(struct rtw_dev *rtwdev)
16861686
{
16871687
struct rtw_pci *rtwpci = (struct rtw_pci *)rtwdev->priv;
16881688

1689-
init_dummy_netdev(&rtwpci->netdev);
1690-
netif_napi_add(&rtwpci->netdev, &rtwpci->napi, rtw_pci_napi_poll);
1689+
rtwpci->netdev = alloc_netdev_dummy(0);
1690+
if (!rtwpci->netdev)
1691+
return -ENOMEM;
1692+
1693+
netif_napi_add(rtwpci->netdev, &rtwpci->napi, rtw_pci_napi_poll);
1694+
return 0;
16911695
}
16921696

16931697
static void rtw_pci_napi_deinit(struct rtw_dev *rtwdev)
@@ -1696,6 +1700,7 @@ static void rtw_pci_napi_deinit(struct rtw_dev *rtwdev)
16961700

16971701
rtw_pci_napi_stop(rtwdev);
16981702
netif_napi_del(&rtwpci->napi);
1703+
free_netdev(rtwpci->netdev);
16991704
}
17001705

17011706
int rtw_pci_probe(struct pci_dev *pdev,
@@ -1745,7 +1750,11 @@ int rtw_pci_probe(struct pci_dev *pdev,
17451750
goto err_pci_declaim;
17461751
}
17471752

1748-
rtw_pci_napi_init(rtwdev);
1753+
ret = rtw_pci_napi_init(rtwdev);
1754+
if (ret) {
1755+
rtw_err(rtwdev, "failed to setup NAPI\n");
1756+
goto err_pci_declaim;
1757+
}
17491758

17501759
ret = rtw_chip_info_setup(rtwdev);
17511760
if (ret) {

drivers/net/wireless/realtek/rtw88/pci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ struct rtw_pci {
215215
bool running;
216216

217217
/* napi structure */
218-
struct net_device netdev;
218+
struct net_device *netdev;
219219
struct napi_struct napi;
220220

221221
u16 rx_tag;

0 commit comments

Comments
 (0)