Skip to content

Commit 1e1205b

Browse files
hkallweitdavem330
authored andcommitted
r8169: add helper tp_to_dev
In several places struct device is referenced by using &tp->pci_dev->dev. Add helper tp_to_dev() to improve code readability. Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 73c86ee commit 1e1205b

File tree

1 file changed

+22
-15
lines changed
  • drivers/net/ethernet/realtek

1 file changed

+22
-15
lines changed

drivers/net/ethernet/realtek/r8169.c

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,11 @@ MODULE_FIRMWARE(FIRMWARE_8168H_2);
887887
MODULE_FIRMWARE(FIRMWARE_8107E_1);
888888
MODULE_FIRMWARE(FIRMWARE_8107E_2);
889889

890+
static inline struct device *tp_to_dev(struct rtl8169_private *tp)
891+
{
892+
return &tp->pci_dev->dev;
893+
}
894+
890895
static void rtl_lock_work(struct rtl8169_private *tp)
891896
{
892897
mutex_lock(&tp->wk.mutex);
@@ -1609,17 +1614,19 @@ static void rtl_link_chg_patch(struct rtl8169_private *tp)
16091614
static void rtl8169_check_link_status(struct net_device *dev,
16101615
struct rtl8169_private *tp)
16111616
{
1617+
struct device *d = tp_to_dev(tp);
1618+
16121619
if (tp->link_ok(tp)) {
16131620
rtl_link_chg_patch(tp);
16141621
/* This is to cancel a scheduled suspend if there's one. */
1615-
pm_request_resume(&tp->pci_dev->dev);
1622+
pm_request_resume(d);
16161623
netif_carrier_on(dev);
16171624
if (net_ratelimit())
16181625
netif_info(tp, ifup, dev, "link up\n");
16191626
} else {
16201627
netif_carrier_off(dev);
16211628
netif_info(tp, ifdown, dev, "link down\n");
1622-
pm_runtime_idle(&tp->pci_dev->dev);
1629+
pm_runtime_idle(d);
16231630
}
16241631
}
16251632

@@ -1678,7 +1685,7 @@ static u32 __rtl8169_get_wol(struct rtl8169_private *tp)
16781685
static void rtl8169_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
16791686
{
16801687
struct rtl8169_private *tp = netdev_priv(dev);
1681-
struct device *d = &tp->pci_dev->dev;
1688+
struct device *d = tp_to_dev(tp);
16821689

16831690
pm_runtime_get_noresume(d);
16841691

@@ -1781,7 +1788,7 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)
17811788
static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
17821789
{
17831790
struct rtl8169_private *tp = netdev_priv(dev);
1784-
struct device *d = &tp->pci_dev->dev;
1791+
struct device *d = tp_to_dev(tp);
17851792

17861793
pm_runtime_get_noresume(d);
17871794

@@ -1794,7 +1801,7 @@ static int rtl8169_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
17941801

17951802
rtl_unlock_work(tp);
17961803

1797-
device_set_wakeup_enable(&tp->pci_dev->dev, wol->wolopts);
1804+
device_set_wakeup_enable(d, wol->wolopts);
17981805

17991806
pm_runtime_put_noidle(d);
18001807

@@ -2234,7 +2241,7 @@ static void rtl8169_get_ethtool_stats(struct net_device *dev,
22342241
struct ethtool_stats *stats, u64 *data)
22352242
{
22362243
struct rtl8169_private *tp = netdev_priv(dev);
2237-
struct device *d = &tp->pci_dev->dev;
2244+
struct device *d = tp_to_dev(tp);
22382245
struct rtl8169_counters *counters = tp->counters;
22392246

22402247
ASSERT_RTNL();
@@ -4615,7 +4622,7 @@ static void rtl_rar_set(struct rtl8169_private *tp, u8 *addr)
46154622
static int rtl_set_mac_address(struct net_device *dev, void *p)
46164623
{
46174624
struct rtl8169_private *tp = netdev_priv(dev);
4618-
struct device *d = &tp->pci_dev->dev;
4625+
struct device *d = tp_to_dev(tp);
46194626
int ret;
46204627

46214628
ret = eth_mac_addr(dev, p);
@@ -5261,7 +5268,7 @@ static void rtl_request_uncached_firmware(struct rtl8169_private *tp)
52615268
if (!rtl_fw)
52625269
goto err_warn;
52635270

5264-
rc = request_firmware(&rtl_fw->fw, name, &tp->pci_dev->dev);
5271+
rc = request_firmware(&rtl_fw->fw, name, tp_to_dev(tp));
52655272
if (rc < 0)
52665273
goto err_free;
52675274

@@ -6692,7 +6699,7 @@ static inline void rtl8169_make_unusable_by_asic(struct RxDesc *desc)
66926699
static void rtl8169_free_rx_databuff(struct rtl8169_private *tp,
66936700
void **data_buff, struct RxDesc *desc)
66946701
{
6695-
dma_unmap_single(&tp->pci_dev->dev, le64_to_cpu(desc->addr), rx_buf_sz,
6702+
dma_unmap_single(tp_to_dev(tp), le64_to_cpu(desc->addr), rx_buf_sz,
66966703
DMA_FROM_DEVICE);
66976704

66986705
kfree(*data_buff);
@@ -6727,7 +6734,7 @@ static struct sk_buff *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
67276734
{
67286735
void *data;
67296736
dma_addr_t mapping;
6730-
struct device *d = &tp->pci_dev->dev;
6737+
struct device *d = tp_to_dev(tp);
67316738
struct net_device *dev = tp->dev;
67326739
int node = dev->dev.parent ? dev_to_node(dev->dev.parent) : -1;
67336740

@@ -6839,7 +6846,7 @@ static void rtl8169_tx_clear_range(struct rtl8169_private *tp, u32 start,
68396846
if (len) {
68406847
struct sk_buff *skb = tx_skb->skb;
68416848

6842-
rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
6849+
rtl8169_unmap_tx_skb(tp_to_dev(tp), tx_skb,
68436850
tp->TxDescArray + entry);
68446851
if (skb) {
68456852
dev_consume_skb_any(skb);
@@ -6891,7 +6898,7 @@ static int rtl8169_xmit_frags(struct rtl8169_private *tp, struct sk_buff *skb,
68916898
struct skb_shared_info *info = skb_shinfo(skb);
68926899
unsigned int cur_frag, entry;
68936900
struct TxDesc *uninitialized_var(txd);
6894-
struct device *d = &tp->pci_dev->dev;
6901+
struct device *d = tp_to_dev(tp);
68956902

68966903
entry = tp->cur_tx;
68976904
for (cur_frag = 0; cur_frag < info->nr_frags; cur_frag++) {
@@ -7123,7 +7130,7 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
71237130
struct rtl8169_private *tp = netdev_priv(dev);
71247131
unsigned int entry = tp->cur_tx % NUM_TX_DESC;
71257132
struct TxDesc *txd = tp->TxDescArray + entry;
7126-
struct device *d = &tp->pci_dev->dev;
7133+
struct device *d = tp_to_dev(tp);
71277134
dma_addr_t mapping;
71287135
u32 status, len;
71297136
u32 opts[2];
@@ -7287,7 +7294,7 @@ static void rtl_tx(struct net_device *dev, struct rtl8169_private *tp)
72877294
*/
72887295
dma_rmb();
72897296

7290-
rtl8169_unmap_tx_skb(&tp->pci_dev->dev, tx_skb,
7297+
rtl8169_unmap_tx_skb(tp_to_dev(tp), tx_skb,
72917298
tp->TxDescArray + entry);
72927299
if (status & LastFrag) {
72937300
u64_stats_update_begin(&tp->tx_stats.syncp);
@@ -7348,7 +7355,7 @@ static struct sk_buff *rtl8169_try_rx_copy(void *data,
73487355
dma_addr_t addr)
73497356
{
73507357
struct sk_buff *skb;
7351-
struct device *d = &tp->pci_dev->dev;
7358+
struct device *d = tp_to_dev(tp);
73527359

73537360
data = rtl8169_align(data);
73547361
dma_sync_single_for_cpu(d, addr, pkt_size, DMA_FROM_DEVICE);

0 commit comments

Comments
 (0)