2010-08-04 04:45:31

by Javier Martinez Canillas

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Javier Martinez Canillas <[email protected]>
---
drivers/staging/rt2860/rt_pci_rbus.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/rt2860/rt_pci_rbus.c b/drivers/staging/rt2860/rt_pci_rbus.c
index 3004be6..244c754 100644
--- a/drivers/staging/rt2860/rt_pci_rbus.c
+++ b/drivers/staging/rt2860/rt_pci_rbus.c
@@ -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;
--
1.7.0.4



2010-08-04 05:12:19

by FUJITA Tomonori

[permalink] [raw]
Subject: Re: [PATCH] staging/rt2860: fix bad dma_addr_t conversion

On Wed, 04 Aug 2010 00:45:19 -0400
Javier Martinez Canillas <[email protected]> wrote:

> DMA addresses are not pointers and shouldn't be assigned to NULL.
> This patch was generated against today linux-next.
>
> Signed-off-by: Javier Martinez Canillas <[email protected]>
> ---
> drivers/staging/rt2860/rt_pci_rbus.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/staging/rt2860/rt_pci_rbus.c b/drivers/staging/rt2860/rt_pci_rbus.c
> index 3004be6..244c754 100644
> --- a/drivers/staging/rt2860/rt_pci_rbus.c
> +++ b/drivers/staging/rt2860/rt_pci_rbus.c
> @@ -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).