Skip to content

Commit

Permalink
dpaa_eth: simplify variables used in dpaa_cleanup_tx_fd()
Browse files Browse the repository at this point in the history
Avoid casts and repeated conversions.

Signed-off-by: Madalin Bucur <madalin.bucur@nxp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Madalin Bucur authored and David S. Miller committed Oct 31, 2019
1 parent 9a4f4f3 commit ae1512f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1585,13 +1585,13 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct dpaa_priv *priv,
struct device *dev = priv->net_dev->dev.parent;
struct skb_shared_hwtstamps shhwtstamps;
dma_addr_t addr = qm_fd_addr(fd);
void *vaddr = phys_to_virt(addr);
const struct qm_sg_entry *sgt;
struct sk_buff **skbh, *skb;
struct sk_buff *skb;
int nr_frags, i;
u64 ns;

skbh = (struct sk_buff **)phys_to_virt(addr);
skb = *skbh;
skb = *(struct sk_buff **)vaddr;

if (unlikely(qm_fd_get_format(fd) == qm_fd_sg)) {
nr_frags = skb_shinfo(skb)->nr_frags;
Expand All @@ -1602,7 +1602,7 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct dpaa_priv *priv,
/* The sgt buffer has been allocated with netdev_alloc_frag(),
* it's from lowmem.
*/
sgt = phys_to_virt(addr + qm_fd_get_offset(fd));
sgt = vaddr + qm_fd_get_offset(fd);

/* sgt[0] is from lowmem, was dma_map_single()-ed */
dma_unmap_single(priv->tx_dma_dev, qm_sg_addr(&sgt[0]),
Expand All @@ -1617,15 +1617,15 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct dpaa_priv *priv,
}
} else {
dma_unmap_single(priv->tx_dma_dev, addr,
skb_tail_pointer(skb) - (u8 *)skbh, dma_dir);
skb_tail_pointer(skb) - (u8 *)vaddr, dma_dir);
}

/* DMA unmapping is required before accessing the HW provided info */
if (ts && priv->tx_tstamp &&
skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) {
memset(&shhwtstamps, 0, sizeof(shhwtstamps));

if (!fman_port_get_tstamp(priv->mac_dev->port[TX], (void *)skbh,
if (!fman_port_get_tstamp(priv->mac_dev->port[TX], vaddr,
&ns)) {
shhwtstamps.hwtstamp = ns_to_ktime(ns);
skb_tstamp_tx(skb, &shhwtstamps);
Expand All @@ -1636,7 +1636,7 @@ static struct sk_buff *dpaa_cleanup_tx_fd(const struct dpaa_priv *priv,

if (qm_fd_get_format(fd) == qm_fd_sg)
/* Free the page frag that we allocated on Tx */
skb_free_frag(phys_to_virt(addr));
skb_free_frag(vaddr);

return skb;
}
Expand Down

0 comments on commit ae1512f

Please sign in to comment.