char driver on linux-kernel-2.4.21
Hi,I am new to driver. I am trying to build the char driver in kernel 2.4. When i compile the source i getting the following errors and warnings,
i.e, chardev.c:256: variable `Fops' has initializer but incomplete type and chardev.c:72:`EBUSY' undeclared (first use in this function)
chardev.c:63: warning: `struct file' declared inside parameter list
chardev.c:63: warning: its scope is only this definition or declaration, which is probably not what you want
chardev.c:63: warning: `struct inode' declared inside parameter list
chardev.c: In function `device_open':
chardev.c:72: `EBUSY' undeclared (first use in this function)
chardev.c:72: (Each undeclared identifier is reported only once
chardev.c:72: for each function it appears in.)
chardev.c: At top level:
chardev.c:97: warning: `struct file' declared inside parameter list
chardev.c:97: warning: `struct inode' declared inside parameter list
chardev.c:127: warning: `struct file' declared inside parameter list
chardev.c:127: warning: `struct inode' declared inside parameter list
chardev.c:168: warning: `struct file' declared inside parameter list
chardev.c:168: warning: `struct inode' declared inside parameter list
chardev.c:197: warning: `struct file' declared inside parameter list
chardev.c:197: warning: `struct inode' declared inside parameter list
chardev.c: In function `device_ioctl':
chardev.c:225: warning: passing arg 1 of `device_write' from incompatible pointer type
chardev.c:225: warning: passing arg 2 of `device_write' from incompatible pointer type
chardev.c:236: warning: passing arg 1 of `device_read' from incompatible pointer type
chardev.c:236: warning: passing arg 2 of `device_read' from incompatible pointer type
chardev.c: At top level:
chardev.c:256: variable `Fops' has initializer but incomplete type
chardev.c:257: warning: excess elements in struct initializer
chardev.c:257: warning: (near initialization for `Fops')
chardev.c:258: warning: excess elements in struct initializer
chardev.c:258: warning: (near initialization for `Fops')
chardev.c:259: warning: excess elements in struct initializer
chardev.c:259: warning: (near initialization for `Fops')
chardev.c:260: warning: excess elements in struct initializer
chardev.c:260: warning: (near initialization for `Fops')
chardev.c:261: warning: excess elements in struct initializer
chardev.c:261: warning: (near initialization for `Fops')
chardev.c:262: warning: excess elements in struct initializer
chardev.c:262: warning: (near initialization for `Fops')
chardev.c:263: warning: excess elements in struct initializer
chardev.c:263: warning: (near initialization for `Fops')
chardev.c:264: warning: excess elements in struct initializer
chardev.c:264: warning: (near initialization for `Fops')
chardev.c:269: warning: excess elements in struct initializer
chardev.c:269: warning: (near initialization for `Fops')
chardev.c:256: storage size of `Fops' isn't known
Here is my source code for the errors,
static int device_open(struct inode *inode,
struct file *file)
{
#ifdef DEBUG
printk ("device_open(%p)\n", file);
#endif
if (Device_Open)
return -EBUSY;
Device_Open++;
Message_Ptr = Message;
MOD_INC_USE_COUNT;
return SUCCESS;
}
struct file_operations Fops = {
NULL,
device_read,
device_write,
NULL,
NULL,
device_ioctl,
NULL,
device_open,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,0)
NULL,
#endif
device_release
};
Thanks a lot in advance.
Last edited by vinoth_f87; 04-30-2009 at 05:25 AM.
|