patch-2.2.11 linux/drivers/net/wavelan.c
Next file: linux/drivers/net/wavelan.h
Previous file: linux/drivers/net/via-rhine.c
Back to the patch index
Back to the overall index
- Lines: 229
- Date:
Mon Aug 9 12:04:57 1999
- Orig file:
v2.2.10/linux/drivers/net/wavelan.c
- Orig date:
Thu Apr 29 11:53:41 1999
diff -u --recursive --new-file v2.2.10/linux/drivers/net/wavelan.c linux/drivers/net/wavelan.c
@@ -1616,11 +1616,8 @@
if((frequency->e == 0) &&
(frequency->m >= 0) && (frequency->m < BAND_NUM))
{
- /* frequency in units of 250 kHz (as read in the offset register) */
- short bands[] = { 0x30, 0x58, 0x64, 0x7A, 0x80, 0xA8, 0xD0, 0xF0, 0xF8, 0x150 };
-
/* Get frequency offset. */
- freq = bands[frequency->m] >> 1;
+ freq = channel_bands[frequency->m] >> 1;
}
/* Verify that the frequency is allowed. */
@@ -1791,6 +1788,7 @@
u_short table[10]; /* Authorized frequency table */
long freq = 0L; /* offset to 2.4 GHz in .5 MHz + 12 MHz */
int i; /* index in the table */
+ int c = 0; /* Channel number */
/* Read the frequency table. */
fee_read(ioaddr, 0x71 /* frequency table */, table, 10);
@@ -1801,6 +1799,12 @@
/* Look in the table if the frequency is allowed */
if(table[9 - (freq / 16)] & (1 << (freq % 16)))
{
+ /* Compute approximate channel number */
+ while((((channel_bands[c] >> 1) - 24) < freq) &&
+ (c < NELS(channel_bands)))
+ c++;
+ list[i].i = c; /* Set the list index */
+
/* put in the list */
list[i].m = (((freq + 24) * 5) + 24000L) * 10000;
list[i++].e = 1;
@@ -1969,14 +1973,12 @@
}
else
{
- int bands[] = { 915e6, 2.425e8, 2.46e8, 2.484e8, 2.4305e8 };
-
psa_read(ioaddr, lp->hacr, (char *)&psa.psa_subband - (char *)&psa,
(unsigned char *)&psa.psa_subband, 1);
if(psa.psa_subband <= 4)
{
- wrq->u.freq.m = bands[psa.psa_subband];
+ wrq->u.freq.m = fixed_bands[psa.psa_subband];
wrq->u.freq.e = (psa.psa_subband != 0);
}
else
@@ -1986,9 +1988,9 @@
case SIOCSIWSENS:
/* Set the level threshold. */
- if(!suser())
- return -EPERM;
- psa.psa_thr_pre_set = wrq->u.sensitivity & 0x3F;
+ /* We should complain loudly if wrq->u.sens.fixed = 0, because we
+ * can't set auto mode... */
+ psa.psa_thr_pre_set = wrq->u.sens.value & 0x3F;
psa_write(ioaddr, lp->hacr, (char *)&psa.psa_thr_pre_set - (char *)&psa,
(unsigned char *) &psa.psa_thr_pre_set, 1);
/* update the Wavelan checksum */
@@ -2000,7 +2002,8 @@
/* Read the level threshold. */
psa_read(ioaddr, lp->hacr, (char *)&psa.psa_thr_pre_set - (char *)&psa,
(unsigned char *) &psa.psa_thr_pre_set, 1);
- wrq->u.sensitivity = psa.psa_thr_pre_set & 0x3F;
+ wrq->u.sens.value = psa.psa_thr_pre_set & 0x3F;
+ wrq->u.sens.fixed = 1;
break;
case SIOCSIWENCODE:
@@ -2087,12 +2090,6 @@
{
struct iw_range range;
- /* Verify the user buffer. */
- ret = verify_area(VERIFY_WRITE, wrq->u.data.pointer,
- sizeof(struct iw_range));
- if(ret)
- break;
-
/* Set the length (useless: it's constant). */
wrq->u.data.length = sizeof(struct iw_range);
@@ -2117,9 +2114,12 @@
range.max_qual.level = MMR_SIGNAL_LVL;
range.max_qual.noise = MMR_SILENCE_LVL;
+ range.num_bitrates = 1;
+ range.bitrate[0] = 2000000; /* 2 Mb/s */
+
/* Copy structure to the user buffer. */
- copy_to_user(wrq->u.data.pointer, &range,
- sizeof(struct iw_range));
+ if (copy_to_user(wrq->u.data.pointer, &range, sizeof(struct iw_range)))
+ ret = -EFAULT;
}
break;
@@ -2136,18 +2136,12 @@
{ SIOCGIPHISTO, 0, IW_PRIV_TYPE_INT | 16, "gethisto" },
};
- /* Verify the user buffer. */
- ret = verify_area(VERIFY_WRITE, wrq->u.data.pointer,
- sizeof(priv));
- if(ret)
- break;
-
/* Set the number of available ioctls. */
wrq->u.data.length = 4;
/* Copy structure to the user buffer. */
- copy_to_user(wrq->u.data.pointer, (u_char *) priv,
- sizeof(priv));
+ if (copy_to_user(wrq->u.data.pointer, (u_char *) priv, sizeof(priv)))
+ ret = -EFAULT;
}
break;
@@ -2169,14 +2163,11 @@
struct sockaddr address[IW_MAX_SPY];
int i;
- /* Verify where the user has set his addresses. */
- ret = verify_area(VERIFY_READ, wrq->u.data.pointer,
- sizeof(struct sockaddr) * lp->spy_number);
- if(ret)
- break;
/* Copy addresses to the driver. */
- copy_from_user(address, wrq->u.data.pointer,
- sizeof(struct sockaddr) * lp->spy_number);
+ if (copy_from_user(address, wrq->u.data.pointer, sizeof(struct sockaddr) * lp->spy_number)) {
+ ret = -EFAULT;
+ break;
+ }
/* Copy addresses to the lp structure. */
for(i = 0; i < lp->spy_number; i++)
@@ -2215,13 +2206,6 @@
struct sockaddr address[IW_MAX_SPY];
int i;
- /* Verify the user buffer. */
- ret = verify_area(VERIFY_WRITE, wrq->u.data.pointer,
- (sizeof(iw_qual) + sizeof(struct sockaddr))
- * IW_MAX_SPY);
- if(ret)
- break;
-
/* Copy addresses from the lp structure. */
for(i = 0; i < lp->spy_number; i++)
{
@@ -2231,13 +2215,18 @@
}
/* Copy addresses to the user buffer. */
- copy_to_user(wrq->u.data.pointer, address,
- sizeof(struct sockaddr) * lp->spy_number);
-
+ if (copy_to_user(wrq->u.data.pointer, address, sizeof(struct sockaddr) * lp->spy_number)) {
+ ret = -EFAULT;
+ break;
+ }
+
/* Copy stats to the user buffer (just after). */
- copy_to_user(wrq->u.data.pointer +
+ if (copy_to_user(wrq->u.data.pointer +
(sizeof(struct sockaddr) * lp->spy_number),
- lp->spy_stat, sizeof(iw_qual) * lp->spy_number);
+ lp->spy_stat, sizeof(iw_qual) * lp->spy_number)) {
+ ret = -EFAULT;
+ break;
+ }
/* Reset updated flags. */
for(i = 0; i < lp->spy_number; i++)
@@ -2283,14 +2272,11 @@
/* Are there addresses to copy? */
if(lp->his_number > 0)
{
- /* Verify where the user has set his addresses. */
- ret = verify_area(VERIFY_READ, wrq->u.data.pointer,
- sizeof(char) * lp->his_number);
- if(ret)
- break;
/* Copy interval ranges to the driver */
- copy_from_user(lp->his_range, wrq->u.data.pointer,
- sizeof(char) * lp->his_number);
+ if (copy_from_user(lp->his_range, wrq->u.data.pointer, sizeof(char) * lp->his_number)) {
+ ret = -EFAULT;
+ break;
+ }
/* Reset structure. */
memset(lp->his_sum, 0x00, sizeof(long) * 16);
@@ -2304,15 +2290,10 @@
/* Give back the distribution statistics */
if((lp->his_number > 0) && (wrq->u.data.pointer != (caddr_t) 0))
{
- /* Verify the user buffer. */
- ret = verify_area(VERIFY_WRITE, wrq->u.data.pointer,
- sizeof(long) * 16);
- if(ret)
- break;
-
/* Copy data to the user buffer. */
- copy_to_user(wrq->u.data.pointer, lp->his_sum,
- sizeof(long) * lp->his_number);
+ if (copy_to_user(wrq->u.data.pointer, lp->his_sum, sizeof(long) * lp->his_number))
+ ret = -EFAULT;
+
} /* if(pointer != NULL) */
break;
#endif /* HISTOGRAM */
@@ -4265,6 +4246,11 @@
/* Create device and set basic arguments. */
dev = kmalloc(sizeof(struct device), GFP_KERNEL);
+ if(dev==NULL)
+ {
+ ret = -ENOMEM;
+ break;
+ }
memset(dev, 0x00, sizeof(struct device));
dev->name = name[i];
dev->base_addr = io[i];
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)