* [PATCH] starfire: use BUILD_BUG_ON for netdrv_addr_t
@ 2010-08-28 5:08 Akinobu Mita
2010-08-28 22:41 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Akinobu Mita @ 2010-08-28 5:08 UTC (permalink / raw)
To: netdev; +Cc: Akinobu Mita, Ion Badulescu, David S. Miller
Detect size mismatch for netdrv_addr_t at build time rather than
checking at module load time.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Ion Badulescu <ionut@badula.org>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org
---
drivers/net/starfire.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 26c3634..c3bf288 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -2078,11 +2078,7 @@ static int __init starfire_init (void)
printk(KERN_INFO DRV_NAME ": polling (NAPI) enabled\n");
#endif
- /* we can do this test only at run-time... sigh */
- if (sizeof(dma_addr_t) != sizeof(netdrv_addr_t)) {
- printk("This driver has dma_addr_t issues, please send email to maintainer\n");
- return -ENODEV;
- }
+ BUILD_BUG_ON(sizeof(dma_addr_t) != sizeof(netdrv_addr_t));
return pci_register_driver(&starfire_driver);
}
--
1.6.0.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] starfire: use BUILD_BUG_ON for netdrv_addr_t
2010-08-28 5:08 [PATCH] starfire: use BUILD_BUG_ON for netdrv_addr_t Akinobu Mita
@ 2010-08-28 22:41 ` David Miller
2010-08-29 22:59 ` FUJITA Tomonori
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2010-08-28 22:41 UTC (permalink / raw)
To: akinobu.mita; +Cc: netdev, ionut, fujita.tomonori
From: Akinobu Mita <akinobu.mita@gmail.com>
Date: Sat, 28 Aug 2010 14:08:45 +0900
> Detect size mismatch for netdrv_addr_t at build time rather than
> checking at module load time.
>
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: Ion Badulescu <ionut@badula.org>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: netdev@vger.kernel.org
Applied, but I suspect we will see some interesting build failures now
if that ugly and brittle ifdef test which constrols the netdrv_addr_t
define isn't %100 accurate.
Fujita-san, what this driver does is actually pretty reasonable. It
has two kinds of descriptors, one supports 32-bit addresses and the
other supports 64-bit addresses. It wants to CPP test which one to
use so that the driver is not burdoned with two duplicated sets of
routines.
Maybe we should provide a DMA_ADDR_T_SIZE or similar macro? What do
you think? Anything is better than what it uses now:
/*
* This SUCKS.
* We need a much better method to determine if dma_addr_t is 64-bit.
*/
#if (defined(__i386__) && defined(CONFIG_HIGHMEM64G)) || defined(__x86_64__) || defined (__ia64__) || defined(__alpha__) || defined(__mips64__) || (defined(__mips__) && defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR))
:-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] starfire: use BUILD_BUG_ON for netdrv_addr_t
2010-08-28 22:41 ` David Miller
@ 2010-08-29 22:59 ` FUJITA Tomonori
2010-08-30 4:25 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: FUJITA Tomonori @ 2010-08-29 22:59 UTC (permalink / raw)
To: davem; +Cc: akinobu.mita, netdev, ionut, fujita.tomonori, linux-arch
CC'ed to linux-arch,
On Sat, 28 Aug 2010 15:41:25 -0700 (PDT)
David Miller <davem@davemloft.net> wrote:
> From: Akinobu Mita <akinobu.mita@gmail.com>
> Date: Sat, 28 Aug 2010 14:08:45 +0900
>
> > Detect size mismatch for netdrv_addr_t at build time rather than
> > checking at module load time.
> >
> > Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> > Cc: Ion Badulescu <ionut@badula.org>
> > Cc: "David S. Miller" <davem@davemloft.net>
> > Cc: netdev@vger.kernel.org
>
> Applied, but I suspect we will see some interesting build failures now
> if that ugly and brittle ifdef test which constrols the netdrv_addr_t
> define isn't %100 accurate.
Yeah, looks like you need to add another hack for powerpc?
> Fujita-san, what this driver does is actually pretty reasonable. It
> has two kinds of descriptors, one supports 32-bit addresses and the
> other supports 64-bit addresses. It wants to CPP test which one to
> use so that the driver is not burdoned with two duplicated sets of
> routines.
>
> Maybe we should provide a DMA_ADDR_T_SIZE or similar macro? What do
> you think? Anything is better than what it uses now:
Introducing something like CONFIG_DMA_ADDR_T_64BIT works?
include/asm-generic/types.h has:
#ifndef dma_addr_t
#ifdef CONFIG_PHYS_ADDR_T_64BIT
typedef u64 dma_addr_t;
#else
typedef u32 dma_addr_t;
#endif /* CONFIG_PHYS_ADDR_T_64BIT */
#endif /* dma_addr_t */
But the above can't be perfect so about twenty architectures define
dma_addr_t. With CONFIG_DMA_ADDR_T_64BIT, we can clean up all the
mess nicely, I guess.
> /*
> * This SUCKS.
> * We need a much better method to determine if dma_addr_t is 64-bit.
> */
> #if (defined(__i386__) && defined(CONFIG_HIGHMEM64G)) || defined(__x86_64__) || defined (__ia64__) || defined(__alpha__) || defined(__mips64__) || (defined(__mips__) && defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR))
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] starfire: use BUILD_BUG_ON for netdrv_addr_t
2010-08-29 22:59 ` FUJITA Tomonori
@ 2010-08-30 4:25 ` David Miller
2010-08-30 4:57 ` FUJITA Tomonori
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2010-08-30 4:25 UTC (permalink / raw)
To: fujita.tomonori; +Cc: akinobu.mita, netdev, ionut, linux-arch
From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Date: Mon, 30 Aug 2010 07:59:38 +0900
> But the above can't be perfect so about twenty architectures define
> dma_addr_t. With CONFIG_DMA_ADDR_T_64BIT, we can clean up all the
> mess nicely, I guess.
Yes, that's what we need.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] starfire: use BUILD_BUG_ON for netdrv_addr_t
2010-08-30 4:25 ` David Miller
@ 2010-08-30 4:57 ` FUJITA Tomonori
0 siblings, 0 replies; 5+ messages in thread
From: FUJITA Tomonori @ 2010-08-30 4:57 UTC (permalink / raw)
To: davem; +Cc: fujita.tomonori, akinobu.mita, netdev, ionut, linux-arch
On Sun, 29 Aug 2010 21:25:34 -0700 (PDT)
David Miller <davem@davemloft.net> wrote:
> From: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
> Date: Mon, 30 Aug 2010 07:59:38 +0900
>
> > But the above can't be perfect so about twenty architectures define
> > dma_addr_t. With CONFIG_DMA_ADDR_T_64BIT, we can clean up all the
> > mess nicely, I guess.
>
> Yes, that's what we need.
Ok, I'll take care of this.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-08-30 4:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-28 5:08 [PATCH] starfire: use BUILD_BUG_ON for netdrv_addr_t Akinobu Mita
2010-08-28 22:41 ` David Miller
2010-08-29 22:59 ` FUJITA Tomonori
2010-08-30 4:25 ` David Miller
2010-08-30 4:57 ` FUJITA Tomonori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).