LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-24-2003, 11:14 PM   #1
aditya
Member
 
Registered: Aug 2002
Distribution: RH 7.x
Posts: 71

Rep: Reputation: 15
Unhappy Why doesn't this driver work


Hi guys,

this things got the hell out of me. I've built a very small character driver but it doesn't compile. Sinc it's small I'm pasting the code here. Could someone hep me out. The site unixworldonline didn't help, it's got some functions mentioned that don't in my kernel source code.

My kernel version is 2.4


Program:

///////////////////////////////////////////////////////////////////////////////////

#define __KERNEL__
#define __NO_VERSION__
#include <linux/config.h>
#include <asm/io.h>
#include <linux/ioport.h>
#include <linux/fs.h>
#ifdef CONFIG_SMP
#define __SMP__
#endif


#define TEST_MAJOR 244

struct file_operations test_fops = {
write: write_driver,
open: open_driver,
release: release_driver,
};

int init_module(void)
{
int result1,result2;

result1=register_chrdev(TEST_MAJOR,"test_driver",&test_fops);
if(result1 < 0)
{
printk(KERN_WARNING "test: can't get major %d \n",TEST_MAJOR);
return result1;
} //END OF REGISTRY


result2=check_region(0x378,0x100);

if(result2 < 0)
{
printk(KERN_WARNING "test: can't get requested region");
return result2;
}

request_region(0x378,0x100,"test_driver");
return 0;

}

int open_driver(struct inode *inode, struct file *filp)
{

MOD_INC_USE_COUNT;
return 0;
}

int release_driver(struct inode *inode, struct file *filp)
{
MOD_DEC_USE_COUNT;
return 0;
}

ssize_t write_driver(struct file *filp, char *buff, size_t count, loff_t *offp)
{
while(count--)
{
outb( *(buff++), offp++);
wmb();
}
}

void cleanup_module(void)
{
release_region(0x378,0x100);
unregister_chrdev(TEST_MAJOR,"test_driver");
}


///////////////////////////////////////////////////////////////////////////////////


ASSUME THE FILENAME IS TEST_DRV.C FOR EASY EXPLANATION :-0

I AM NOT BUILDING IT AS A MODULE, I WANT TO INTEGRATE IT WITH MY KERNEL CODE DIRECTLY.

THANKS EVERYBODY.

aditya
 
Old 02-25-2003, 01:36 AM   #2
mcleodnine
Senior Member
 
Registered: May 2001
Location: Left Coast - Canada
Distribution: s l a c k w a r e
Posts: 2,731

Rep: Reputation: 45
Moved this thread to Programming forum.
 
Old 09-22-2003, 02:32 AM   #3
pessanimahi
LQ Newbie
 
Registered: Sep 2003
Posts: 18

Rep: Reputation: 0
Even I also tried to build a simple module like this but i got the error that kernel version is mismatched ...

can any one help....question is there in this forum

Bulid module....pessanimahi
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Still not getting nvidia driver to work.. GardarS Linux - Hardware 14 06-27-2005 04:41 AM
Nvidia driver doesn't work very well Trkdz Slackware 1 05-25-2005 09:35 PM
nvidia driver doesn't work valueduser Mandriva 21 10-30-2003 09:59 AM
got the driver to work now what? SnowSurfAir Linux - Software 5 07-28-2003 08:56 PM
getting alsa driver to work kudos Slackware 4 04-19-2003 11:34 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration