Skip to content

Commit 247aa00

Browse files
ksornekanguy11
authored andcommitted
iavf: Add helper function to go from pci_dev to adapter
Add helper function to go from pci_dev to adapter to make work simple - to go from a pci_dev to the adapter structure and make netdev assignment instead of having to go to the net_device then the adapter. Signed-off-by: Brett Creeley <[email protected]> Signed-off-by: Karen Sornek <[email protected]> Tested-by: Konrad Jankowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 4a15022 commit 247aa00

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

drivers/net/ethernet/intel/iavf/iavf_main.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ MODULE_LICENSE("GPL v2");
5151
static const struct net_device_ops iavf_netdev_ops;
5252
struct workqueue_struct *iavf_wq;
5353

54+
/**
55+
* iavf_pdev_to_adapter - go from pci_dev to adapter
56+
* @pdev: pci_dev pointer
57+
*/
58+
static struct iavf_adapter *iavf_pdev_to_adapter(struct pci_dev *pdev)
59+
{
60+
return netdev_priv(pci_get_drvdata(pdev));
61+
}
62+
5463
/**
5564
* iavf_allocate_dma_mem_d - OS specific memory alloc for shared code
5665
* @hw: pointer to the HW structure
@@ -3681,8 +3690,8 @@ int iavf_process_config(struct iavf_adapter *adapter)
36813690
**/
36823691
static void iavf_shutdown(struct pci_dev *pdev)
36833692
{
3684-
struct net_device *netdev = pci_get_drvdata(pdev);
3685-
struct iavf_adapter *adapter = netdev_priv(netdev);
3693+
struct iavf_adapter *adapter = iavf_pdev_to_adapter(pdev);
3694+
struct net_device *netdev = adapter->netdev;
36863695

36873696
netif_device_detach(netdev);
36883697

@@ -3866,10 +3875,11 @@ static int __maybe_unused iavf_suspend(struct device *dev_d)
38663875
static int __maybe_unused iavf_resume(struct device *dev_d)
38673876
{
38683877
struct pci_dev *pdev = to_pci_dev(dev_d);
3869-
struct net_device *netdev = pci_get_drvdata(pdev);
3870-
struct iavf_adapter *adapter = netdev_priv(netdev);
3878+
struct iavf_adapter *adapter;
38713879
u32 err;
38723880

3881+
adapter = iavf_pdev_to_adapter(pdev);
3882+
38733883
pci_set_master(pdev);
38743884

38753885
rtnl_lock();
@@ -3888,7 +3898,7 @@ static int __maybe_unused iavf_resume(struct device *dev_d)
38883898

38893899
queue_work(iavf_wq, &adapter->reset_task);
38903900

3891-
netif_device_attach(netdev);
3901+
netif_device_attach(adapter->netdev);
38923902

38933903
return err;
38943904
}
@@ -3904,8 +3914,8 @@ static int __maybe_unused iavf_resume(struct device *dev_d)
39043914
**/
39053915
static void iavf_remove(struct pci_dev *pdev)
39063916
{
3907-
struct net_device *netdev = pci_get_drvdata(pdev);
3908-
struct iavf_adapter *adapter = netdev_priv(netdev);
3917+
struct iavf_adapter *adapter = iavf_pdev_to_adapter(pdev);
3918+
struct net_device *netdev = adapter->netdev;
39093919
struct iavf_fdir_fltr *fdir, *fdirtmp;
39103920
struct iavf_vlan_filter *vlf, *vlftmp;
39113921
struct iavf_adv_rss *rss, *rsstmp;

0 commit comments

Comments
 (0)