Skip to contentSkip to conversation

staging/rt2860: fix bad dma_addr_t conversion

PATCH In review Javier Martinez Canillas 2 participants 2 messages Aug 4, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging/rt2860: fix bad dma_addr_t conversion

DMA addresses are not pointers and shouldn't be assigned to NULL. This patch was generated against today linux-next.

---
 drivers/staging/rt2860/rt_pci_rbus.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/rt2860/rt_pci_rbus.c +1 -1
index 3004be6..244c754 100644
@@ -218,7 +218,7 @@ void *RTMP_AllocateRxPacketBuffer(struct rt_rtmp_adapter *pAd,
 				   PCI_DMA_FROMDEVICE);
 	} else {
 		*VirtualAddress = (void *)NULL;
-		*PhysicalAddress = (dma_addr_t)NULL;
+		*PhysicalAddress = 0;
 	}
 
 	return (void *)pkt;
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 13 lines · On Wed, 04 Aug 2010 00:45:19 -0400 Javier Martinez Canillas…

DMA addresses are not pointers and shouldn't be assigned to NULL. This patch was generated against today linux-next.

---
 drivers/staging/rt2860/rt_pci_rbus.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/rt2860/rt_pci_rbus.c +0 -0
index 3004be6..244c754 100644

drivers/staging/rt2860/rt_pci_rbus.c void *RTMP_AllocateRxPacketBuffer(struct rt_rtmp_adapter *pAd, · line 222

Quoted 6 lines
drivers/staging/rt2860/rt_pci_rbus.c +1 -1
@@ -218,7 +218,7 @@ void *RTMP_AllocateRxPacketBuffer(struct rt_rtmp_adapter *pAd,
 				   PCI_DMA_FROMDEVICE);
 	} else {
 		*VirtualAddress = (void *)NULL;
-		*PhysicalAddress = (dma_addr_t)NULL;
+		*PhysicalAddress = 0;
 	}

This doesn't look correct since zero is a valid DMA address on some architectures.

I recommend removing the else part completely. If you need to mark a rx buffer invalid, adding a flag to the rx descriptor structure of a driver is a popular way (see other network drivers, e.g. bnx2).