Messages in this thread | | | Subject | INIT_REQUEST & CURRENT undeclared! | Date | Fri, 5 Mar 2004 17:54:44 +0530 | From | "Jinu M." <> |
| |
Hello All!
I am studying the block device driver. I just tried the request function (blk_init_queue). Even though I included linux/blk.h on compiling I get "INIT_REQUEST" & "CURRENT" undeclared.
Below are the code and the cc command I use to compile it. I would like to know what the problem is.
Thanks in advance, -Joy
*** simple.c *** /* kernel headers */ #include <linux/module.h> #include <linux/pci.h> #include <linux/init.h> #include <linux/blk.h>
#define DEV_NAME "jdev" #define MAJOR_NR 220
/* GPL Licensed */ MODULE_LICENSE("GPL");
/* version information */ static char version[]="Block Driver 0.1\n";
/* * ioctl() entry point */ static int simple_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { int minor = MINOR(inode->i_rdev);
printk("device number = %d\n",minor);
return 0; }
/* * open() entry point */ static int simple_open(struct inode *inode, struct file *filp) { int minor = MINOR(inode->i_rdev); printk("device number = %d\n",minor);
return 0; }
/* * close() entry point */ static int simple_close(struct inode *inode, struct file *filp) { int minor = MINOR(inode->i_rdev); printk("device number = %d\n",minor);
return 0; }
static struct block_device_operations ji_bd_op = { owner: THIS_MODULE, open: simple_open, ioctl: simple_ioctl, release: simple_close, };
/* * Initializations from here! */ static int simple_start(void) { /* register device */ if(devfs_register_blkdev(MAJOR_NR, DEV_NAME, &ji_bd_op)) { printk("ERROR| Could not register major %d!\n", MAJOR_NR); return -EIO; }
return 0; }
/* * Read/Write interface function. */ static void simple_do_request(request_queue_t *q) { while(1) { INIT_REQUEST; /* do some checking on the request function */ PRINTK("request %p cmd %i sec %li (nr. %li)\n", CURRENT, CURRENT->cmd, CURRENT->sector, CURRENT->current_nr_sectors);
end_request(1); } }
/* * This is the module entry point. */ static int __init simple_init(void) { int status = 0; #ifdef MODULE printk(version); #endif /* device/driver init */ if((status=simple_start()) != 0) return status;
/* register request queue */ blk_init_queue(BLK_DEFAULT_QUEUE(MAJOR_NR), simple_do_request); return 0; }
/* * This is the module exit point. */ static void __exit simple_exit(void) { /* unregister device */ devfs_unregister_blkdev(MAJOR_NR, DEV_NAME);
blk_cleanup_queue(BLK_DEFAULT_QUEUE(MAJOR_NR)); }
/* module entry/exit points */ module_init(simple_init); module_exit(simple_exit);
Compiling is done using the following command. #cc -D__KERNEL__ -I/usr/src/linux-2.4/include -O2 -DMODULE -c simple.c
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |