* [PATCH] ray_cs: reduce stack usage
@ 2005-01-28 5:49 Randy.Dunlap
0 siblings, 0 replies; only message in thread
From: Randy.Dunlap @ 2005-01-28 5:49 UTC (permalink / raw)
To: netdev, jgarzik, corey
[-- Attachment #1: Type: text/plain, Size: 387 bytes --]
ray_cs: reduce local stack usage in ray_dev_ioctl
from 1048 to 468 (on i386) by making 'range' kmalloc-ed
instead of an automatic stack variable.
struct iw_range range; // 564 bytes
Signed-off-by: Randy Dunlap <rddunlap@osdl.org>
diffstat:=
drivers/net/wireless/ray_cs.c | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
[-- Attachment #2: raycs_stack1.patch --]
[-- Type: text/x-patch, Size: 2487 bytes --]
diff -Naurp ./drivers/net/wireless/ray_cs.c~raycs_stack ./drivers/net/wireless/ray_cs.c
--- ./drivers/net/wireless/ray_cs.c~raycs_stack 2005-01-27 20:38:05.678592648 -0800
+++ ./drivers/net/wireless/ray_cs.c 2005-01-27 21:05:51.637328424 -0800
@@ -1467,33 +1467,39 @@ static int ray_dev_ioctl(struct net_devi
/* Basic checking... */
if(wrq->u.data.pointer != (caddr_t) 0)
{
- struct iw_range range;
- memset((char *) &range, 0, sizeof(struct iw_range));
+ struct iw_range *range;
+ range = kmalloc(sizeof(struct iw_range), GFP_KERNEL);
+ if (!range) {
+ err = -ENOMEM;
+ goto ioc_out;
+ }
+ memset((char *) range, 0, sizeof(struct iw_range));
/* Set the length (very important for backward compatibility) */
wrq->u.data.length = sizeof(struct iw_range);
#if WIRELESS_EXT > 10
/* Set the Wireless Extension versions */
- range.we_version_compiled = WIRELESS_EXT;
- range.we_version_source = 9;
+ range->we_version_compiled = WIRELESS_EXT;
+ range->we_version_source = 9;
#endif /* WIRELESS_EXT > 10 */
/* Set information in the range struct */
- range.throughput = 1.1 * 1000 * 1000; /* Put the right number here */
- range.num_channels = hop_pattern_length[(int)country];
- range.num_frequency = 0;
- range.max_qual.qual = 0;
- range.max_qual.level = 255; /* What's the correct value ? */
- range.max_qual.noise = 255; /* Idem */
- range.num_bitrates = 2;
- range.bitrate[0] = 1000000; /* 1 Mb/s */
- range.bitrate[1] = 2000000; /* 2 Mb/s */
+ range->throughput = 1.1 * 1000 * 1000; /* Put the right number here */
+ range->num_channels = hop_pattern_length[(int)country];
+ range->num_frequency = 0;
+ range->max_qual.qual = 0;
+ range->max_qual.level = 255; /* What's the correct value ? */
+ range->max_qual.noise = 255; /* Idem */
+ range->num_bitrates = 2;
+ range->bitrate[0] = 1000000; /* 1 Mb/s */
+ range->bitrate[1] = 2000000; /* 2 Mb/s */
/* Copy structure to the user buffer */
- if(copy_to_user(wrq->u.data.pointer, &range,
+ if(copy_to_user(wrq->u.data.pointer, range,
sizeof(struct iw_range)))
err = -EFAULT;
+ kfree(range);
}
break;
@@ -1632,6 +1638,7 @@ static int ray_dev_ioctl(struct net_devi
DEBUG(0,"ray_dev_ioctl cmd = 0x%x\n", cmd);
err = -EOPNOTSUPP;
}
+ioc_out:
return err;
} /* end ray_dev_ioctl */
/*===========================================================================*/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-01-28 5:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-28 5:49 [PATCH] ray_cs: reduce stack usage Randy.Dunlap
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).