Simplify PCIE DMA mapping management by eliminating extra copies of {address, size} pairs to/from temporary data structures. Map and unmap operations may use skb fields directly via introduced 'MWIFIEX_SKB_DMA_ADDR()' and 'MWIFIEX_SKB_DMA_SIZE()' macros. Signed-off-by: Dmitry Antipov <dmantipov@xxxxxxxxx> --- drivers/net/wireless/marvell/mwifiex/pcie.c | 14 +++++------ drivers/net/wireless/marvell/mwifiex/util.h | 27 +++------------------ 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index 6697132ecc97..4c7c17fd2387 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -197,15 +197,14 @@ mwifiex_map_pci_memory(struct mwifiex_adapter *adapter, struct sk_buff *skb, size_t size, int flags) { struct pcie_service_card *card = adapter->card; - struct mwifiex_dma_mapping mapping; - mapping.addr = dma_map_single(&card->dev->dev, skb->data, size, flags); - if (dma_mapping_error(&card->dev->dev, mapping.addr)) { + MWIFIEX_SKB_DMA_ADDR(skb) = dma_map_single(&card->dev->dev, skb->data, + size, flags); + if (dma_mapping_error(&card->dev->dev, MWIFIEX_SKB_DMA_ADDR(skb))) { mwifiex_dbg(adapter, ERROR, "failed to map pci memory!\n"); return -1; } - mapping.len = size; - mwifiex_store_mapping(skb, &mapping); + MWIFIEX_SKB_DMA_SIZE(skb) = size; return 0; } @@ -213,10 +212,9 @@ static void mwifiex_unmap_pci_memory(struct mwifiex_adapter *adapter, struct sk_buff *skb, int flags) { struct pcie_service_card *card = adapter->card; - struct mwifiex_dma_mapping mapping; - mwifiex_get_mapping(skb, &mapping); - dma_unmap_single(&card->dev->dev, mapping.addr, mapping.len, flags); + dma_unmap_single(&card->dev->dev, MWIFIEX_SKB_DMA_ADDR(skb), + MWIFIEX_SKB_DMA_SIZE(skb), flags); } /* diff --git a/drivers/net/wireless/marvell/mwifiex/util.h b/drivers/net/wireless/marvell/mwifiex/util.h index 4699c505c0a0..495f1a74b62d 100644 --- a/drivers/net/wireless/marvell/mwifiex/util.h +++ b/drivers/net/wireless/marvell/mwifiex/util.h @@ -53,30 +53,11 @@ static inline struct mwifiex_txinfo *MWIFIEX_SKB_TXCB(struct sk_buff *skb) return &cb->tx_info; } -static inline void mwifiex_store_mapping(struct sk_buff *skb, - struct mwifiex_dma_mapping *mapping) -{ - struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb; - - memcpy(&cb->dma_mapping, mapping, sizeof(*mapping)); -} - -static inline void mwifiex_get_mapping(struct sk_buff *skb, - struct mwifiex_dma_mapping *mapping) -{ - struct mwifiex_cb *cb = (struct mwifiex_cb *)skb->cb; +#define MWIFIEX_SKB_DMA_ADDR(skb) \ + (((struct mwifiex_cb *)((skb)->cb))->dma_mapping.addr) - memcpy(mapping, &cb->dma_mapping, sizeof(*mapping)); -} - -static inline dma_addr_t MWIFIEX_SKB_DMA_ADDR(struct sk_buff *skb) -{ - struct mwifiex_dma_mapping mapping; - - mwifiex_get_mapping(skb, &mapping); - - return mapping.addr; -} +#define MWIFIEX_SKB_DMA_SIZE(skb) \ + (((struct mwifiex_cb *)((skb)->cb))->dma_mapping.len) int mwifiex_debug_info_to_buffer(struct mwifiex_private *priv, char *buf, struct mwifiex_debug_info *info); -- 2.41.0