aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2008-01-13 09:16:34 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:09:50 -0500
commit60da481b98082ff5ffd233b18683c3ffe3ab618c (patch)
tree3660cdeef28b88f3fc6997b299ac5a3158654b20 /drivers/net
parenteb189d8bc9824bcb2187ffdab27d77ab469264c3 (diff)
WAVELAN - compile-time check for struct sizes
Convert optional struct size checks to non-optional compile-time checks. Furthermore BUILD_BUG_ON() which will be optimized away by the compiler. Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/wavelan.c34
-rw-r--r--drivers/net/wireless/wavelan.p.h1
-rw-r--r--drivers/net/wireless/wavelan_cs.c33
-rw-r--r--drivers/net/wireless/wavelan_cs.p.h1
4 files changed, 9 insertions, 60 deletions
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c
index b343ce2235eb..03384a43186b 100644
--- a/drivers/net/wireless/wavelan.c
+++ b/drivers/net/wireless/wavelan.c
@@ -49,27 +49,6 @@ static int __init wv_psa_to_irq(u8 irqval)
49 return -1; 49 return -1;
50} 50}
51 51
52#ifdef STRUCT_CHECK
53/*------------------------------------------------------------------*/
54/*
55 * Sanity routine to verify the sizes of the various WaveLAN interface
56 * structures.
57 */
58static char *wv_struct_check(void)
59{
60#define SC(t,s,n) if (sizeof(t) != s) return(n);
61
62 SC(psa_t, PSA_SIZE, "psa_t");
63 SC(mmw_t, MMW_SIZE, "mmw_t");
64 SC(mmr_t, MMR_SIZE, "mmr_t");
65 SC(ha_t, HA_SIZE, "ha_t");
66
67#undef SC
68
69 return ((char *) NULL);
70} /* wv_struct_check */
71#endif /* STRUCT_CHECK */
72
73/********************* HOST ADAPTER SUBROUTINES *********************/ 52/********************* HOST ADAPTER SUBROUTINES *********************/
74/* 53/*
75 * Useful subroutines to manage the WaveLAN ISA interface 54 * Useful subroutines to manage the WaveLAN ISA interface
@@ -4215,14 +4194,11 @@ struct net_device * __init wavelan_probe(int unit)
4215 int i; 4194 int i;
4216 int r = 0; 4195 int r = 0;
4217 4196
4218#ifdef STRUCT_CHECK 4197 /* compile-time check the sizes of structures */
4219 if (wv_struct_check() != (char *) NULL) { 4198 BUILD_BUG_ON(sizeof(psa_t) != PSA_SIZE);
4220 printk(KERN_WARNING 4199 BUILD_BUG_ON(sizeof(mmw_t) != MMW_SIZE);
4221 "%s: wavelan_probe(): structure/compiler botch: \"%s\"\n", 4200 BUILD_BUG_ON(sizeof(mmr_t) != MMR_SIZE);
4222 dev->name, wv_struct_check()); 4201 BUILD_BUG_ON(sizeof(ha_t) != HA_SIZE);
4223 return -ENODEV;
4224 }
4225#endif /* STRUCT_CHECK */
4226 4202
4227 dev = alloc_etherdev(sizeof(net_local)); 4203 dev = alloc_etherdev(sizeof(net_local));
4228 if (!dev) 4204 if (!dev)
diff --git a/drivers/net/wireless/wavelan.p.h b/drivers/net/wireless/wavelan.p.h
index fe242812d858..b33ac47dd8df 100644
--- a/drivers/net/wireless/wavelan.p.h
+++ b/drivers/net/wireless/wavelan.p.h
@@ -400,7 +400,6 @@
400 */ 400 */
401#undef SET_PSA_CRC /* Calculate and set the CRC on PSA (slower) */ 401#undef SET_PSA_CRC /* Calculate and set the CRC on PSA (slower) */
402#define USE_PSA_CONFIG /* Use info from the PSA. */ 402#define USE_PSA_CONFIG /* Use info from the PSA. */
403#undef STRUCT_CHECK /* Verify padding of structures. */
404#undef EEPROM_IS_PROTECTED /* doesn't seem to be necessary */ 403#undef EEPROM_IS_PROTECTED /* doesn't seem to be necessary */
405#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical). */ 404#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical). */
406#undef SET_MAC_ADDRESS /* Experimental */ 405#undef SET_MAC_ADDRESS /* Experimental */
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c
index da1d4e8f0f6b..c2037b2a05bf 100644
--- a/drivers/net/wireless/wavelan_cs.c
+++ b/drivers/net/wireless/wavelan_cs.c
@@ -71,27 +71,6 @@ static void wv_nwid_filter(unsigned char mode, net_local *lp);
71 * (wavelan modem or i82593) 71 * (wavelan modem or i82593)
72 */ 72 */
73 73
74#ifdef STRUCT_CHECK
75/*------------------------------------------------------------------*/
76/*
77 * Sanity routine to verify the sizes of the various WaveLAN interface
78 * structures.
79 */
80static char *
81wv_structuct_check(void)
82{
83#define SC(t,s,n) if (sizeof(t) != s) return(n);
84
85 SC(psa_t, PSA_SIZE, "psa_t");
86 SC(mmw_t, MMW_SIZE, "mmw_t");
87 SC(mmr_t, MMR_SIZE, "mmr_t");
88
89#undef SC
90
91 return((char *) NULL);
92} /* wv_structuct_check */
93#endif /* STRUCT_CHECK */
94
95/******************* MODEM MANAGEMENT SUBROUTINES *******************/ 74/******************* MODEM MANAGEMENT SUBROUTINES *******************/
96/* 75/*
97 * Useful subroutines to manage the modem of the wavelan 76 * Useful subroutines to manage the modem of the wavelan
@@ -3794,14 +3773,10 @@ wv_hw_config(struct net_device * dev)
3794 printk(KERN_DEBUG "%s: ->wv_hw_config()\n", dev->name); 3773 printk(KERN_DEBUG "%s: ->wv_hw_config()\n", dev->name);
3795#endif 3774#endif
3796 3775
3797#ifdef STRUCT_CHECK 3776 /* compile-time check the sizes of structures */
3798 if(wv_structuct_check() != (char *) NULL) 3777 BUILD_BUG_ON(sizeof(psa_t) != PSA_SIZE);
3799 { 3778 BUILD_BUG_ON(sizeof(mmw_t) != MMW_SIZE);
3800 printk(KERN_WARNING "%s: wv_hw_config: structure/compiler botch: \"%s\"\n", 3779 BUILD_BUG_ON(sizeof(mmr_t) != MMR_SIZE);
3801 dev->name, wv_structuct_check());
3802 return FALSE;
3803 }
3804#endif /* STRUCT_CHECK == 1 */
3805 3780
3806 /* Reset the pcmcia interface */ 3781 /* Reset the pcmcia interface */
3807 if(wv_pcmcia_reset(dev) == FALSE) 3782 if(wv_pcmcia_reset(dev) == FALSE)
diff --git a/drivers/net/wireless/wavelan_cs.p.h b/drivers/net/wireless/wavelan_cs.p.h
index ca551a5d1390..33dd97094227 100644
--- a/drivers/net/wireless/wavelan_cs.p.h
+++ b/drivers/net/wireless/wavelan_cs.p.h
@@ -459,7 +459,6 @@
459#undef WAVELAN_ROAMING_EXT /* Enable roaming wireless extensions */ 459#undef WAVELAN_ROAMING_EXT /* Enable roaming wireless extensions */
460#undef SET_PSA_CRC /* Set the CRC in PSA (slower) */ 460#undef SET_PSA_CRC /* Set the CRC in PSA (slower) */
461#define USE_PSA_CONFIG /* Use info from the PSA */ 461#define USE_PSA_CONFIG /* Use info from the PSA */
462#undef STRUCT_CHECK /* Verify padding of structures */
463#undef EEPROM_IS_PROTECTED /* Doesn't seem to be necessary */ 462#undef EEPROM_IS_PROTECTED /* Doesn't seem to be necessary */
464#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical) */ 463#define MULTICAST_AVOID /* Avoid extra multicast (I'm sceptical) */
465#undef SET_MAC_ADDRESS /* Experimental */ 464#undef SET_MAC_ADDRESS /* Experimental */