[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
get_user/copy_from_user
[ooops, majordomo caught it on the word [config] ... fixed]
---------- Forwarded message ----------
Date: Fri, 27 Apr 2001 15:51:56 +0200
From: owner-kernelnewbies@nl.linux.org
To: owner-kernelnewbies@nl.linux.org
Subject: BOUNCE kernelnewbies@mail.nl.linux.org: Admin request of type
/^\s*config\b/i at line 9
>From chirag@slashetc.net Fri Apr 27 15:51:31 2001
Received: from [202.93.129.53] ([202.93.129.53]:20996 "EHLO slashetc.net")
by humbolt.nl.linux.org with ESMTP id <S92250AbRD0NvL>;
Fri, 27 Apr 2001 15:51:11 +0200
Received: (from chirag@localhost)
by slashetc.net (8.11.2/8.11.2) id f3RDf6r01005
for kernelnewbies@humbolt.nl.linux.org; Fri, 27 Apr 2001 19:11:06 +0530
Date: Fri, 27 Apr 2001 19:11:06 +0530
From: Chirag Kantharia <chyrag@yahoo.com>
To: kernelnewbies@humbolt.nl.linux.org
Subject: get_user/copy_from_user
Message-ID: <20010427191106.A898@slashetc.net>
Reply-To: Chirag Kantharia <chyrag@yahoo.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Mailer: Mutt 1.0.1i
Sender: Chirag Kantharia <chyrag@yahoo.com>
Return-Path: <chirag@slashetc.net>
X-Orcpt: rfc822;kernelnewbies@humbolt.nl.linux.org
Hi!
I am writing a driver for a PCI card. I have been able to write most of
the fops functions. I'm having problems with ioctl presently. Basically,
I have to allow a user application to get/set some data to PCI config
space. This user application is linked with a library which does all the
dirty work. The function in the library, while ``getting'' data from the
config space, passes two arguments, one of which is the index into the
config space (in other words, an offset) from which the data's to be
retrieved and the second argument is a pointer where the data's to be
stored.
I am trying to retrieve these two arguments from the ``arg'' parameter
using:
struct xtcsound_data {
long location;
long value;
};
static int xtcsound_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
struct xtcsound_data val;
switch(cmd) {
case XTCSOUND_PCI_CONFIG_READ_REGISTER:
printk("before get_user_ret\n")
get_user_ret(val, (unsigned long *)arg, -EFAULT);
printk("after get_user_ret\n")
break;
case ...
}
The first printk gets printed, while the second doesn't. Evidently, the
get_user_ret returns with -EFAULT. Instead of struct xtcsound_data, I
tried with
unsigned long val[2];
get_user_ret(val, (unsigned long *)arg, -EFAULT);
which doesn't work either. I tried copy_from_user as well.
I was unable to find much documentation on how get_user and
copy_from_user works. Could anybody point out what am I doing wrong
here? Any pointers would be appreciated.
chyrag.
--
Chirag Kantharia, slashetc.net/chyrag/
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.kernelnewbies.org/