From: "Adam J. Richter" <adam@yggdrasil.com>
To: alsa-devel@alsa-project.org, perex@suse.cz
Cc: linux-kernel@vger.kernel.org
Subject: Patch?: linux-2.5.59/sound/soundcore.c referenced non-existant errno variable
Date: Fri, 17 Jan 2003 15:57:17 -0800 [thread overview]
Message-ID: <20030117155717.A6250@baldur.yggdrasil.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1251 bytes --]
linux-2.5.59/sound/sound_firmware.c attempts to use the
user level system call interface from the kernel, which I understand
works on i386 and perhaps all architectures, but requires a variable
named "errno." (Actually, it mixed things like close() and
sys_close(), but that's beside the point.)
I could just declare a "static int errno;" in the file, but I
thought it might be helpful to use filp_open, vfs_read and filp_close
instead, which shaves a few cpu cycles and avoids the need to allocate
a file descriptor number. I think that this also seems to be the
convention for other kernel facilities that want to open their own
files briefly. I've attached a patch below. The patch shrinks
sound_firmware.c by six lines. I have only verified that the patch
compiles and that the soundcore module now loads.
Comments are welcome. If this patch looks good, then I'd
appreciate it if someone more connected to sound development would
integrate it and forward it to Linus.
--
Adam J. Richter __ ______________ 575 Oroville Road
adam@yggdrasil.com \ / Milpitas, California 95035
+1 408 309-6081 | g g d r a s i l United States of America
"Free Software For The Rest Of Us."
[-- Attachment #2: fw.diff --]
[-- Type: text/plain, Size: 1168 bytes --]
--- linux-2.5.59/sound/sound_firmware.c 2003-01-16 18:21:34.000000000 -0800
+++ linux/sound/sound_firmware.c 2003-01-17 15:38:38.000000000 -0800
@@ -9,41 +9,35 @@
static int do_mod_firmware_load(const char *fn, char **fp)
{
- int fd;
+ struct file *file;
long l;
char *dp;
- fd = open(fn, 0, 0);
- if (fd == -1)
+ file = filp_open(fn, O_RDONLY, 0);
+ if (!file)
{
printk(KERN_INFO "Unable to load '%s'.\n", fn);
return 0;
}
- l = lseek(fd, 0L, 2);
+ l = file->f_dentry->d_inode->i_size;
if (l <= 0 || l > 131072)
{
printk(KERN_INFO "Invalid firmware '%s'\n", fn);
- sys_close(fd);
+ filp_close(file, NULL);
return 0;
}
- lseek(fd, 0L, 0);
dp = vmalloc(l);
- if (dp == NULL)
- {
- printk(KERN_INFO "Out of memory loading '%s'.\n", fn);
- sys_close(fd);
- return 0;
- }
- if (read(fd, dp, l) != l)
- {
+ if (dp != NULL) {
+ if (vfs_read(file, dp, l, &file->f_pos) == l) {
+ filp_close(file, NULL);
+ *fp = dp;
+ return (int) l;
+ }
printk(KERN_INFO "Failed to read '%s'.\n", fn);
vfree(dp);
- sys_close(fd);
- return 0;
}
- close(fd);
- *fp = dp;
- return (int) l;
+ filp_close(file, NULL);
+ return 0;
}
/**
next reply other threads:[~2003-01-17 23:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-17 23:57 Adam J. Richter [this message]
2003-01-18 2:49 ` Raja R Harinath
2003-01-18 3:13 ` Petr Vandrovec
2003-01-18 15:40 ` Raja R Harinath
2003-01-18 20:27 ` Petr Vandrovec
2003-01-18 20:40 ` Andrew Morton
2003-01-19 4:14 Adam J. Richter
2003-01-20 15:27 ` Horst von Brand
2003-01-21 16:48 ` Bill Davidsen
2003-01-21 17:01 ` Horst von Brand
2003-01-20 19:53 Adam J. Richter
2003-01-21 8:35 ` Horst von Brand
2003-01-20 20:01 Adam J. Richter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030117155717.A6250@baldur.yggdrasil.com \
--to=adam@yggdrasil.com \
--cc=alsa-devel@alsa-project.org \
--cc=linux-kernel@vger.kernel.org \
--cc=perex@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®