LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 06-11-2012, 12:30 AM   #1
zaffer
LQ Newbie
 
Registered: Mar 2012
Posts: 6

Rep: Reputation: Disabled
problem with character driver


hi,
i have written a character driver..i have done trimming in open call...when i run an application i do like follows
[char_driver]# make
[char_driver]# insmod ./modules/lkm.c
[char_driver]# gcc app.c //my appliaction
[char_driver]# mknod node c 250 0
[char_driver]# ./a.out node
........it works fine......
however if i make another node i.e after instruction
[char_driver]# mknod node c 250 0
i type
[char_driver]# mknod node1 c 250 0
and then
[char_driver]# ./a.out node
it works
and if i type
[char_driver]# ./a.out node1
it crashes
please help....
i think it is trimming problem.....plz tell where to trim in read or open....
regards
zaffer
 
Old 06-11-2012, 11:56 PM   #2
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
You can not have two devices with the same minor number, if you want to handle two devices from your driver make sure your driver is registered to handle two devices and you create the devices with different minor numbers.
 
Old 06-12-2012, 01:05 AM   #3
zaffer
LQ Newbie
 
Registered: Mar 2012
Posts: 6

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bsat View Post
You can not have two devices with the same minor number, if you want to handle two devices from your driver make sure your driver is registered to handle two devices and you create the devices with different minor numbers.
thanks dear.....can u tell me how can we have two different minor numbers......wat i think is that we have use two character devices with two minor nos e.g mknod node c 250 0 ,mknod node1 c 250 1.......like that
 
Old 06-13-2012, 12:41 AM   #4
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
Yes that is how you give two different minor numbers.
your driver should also be registered to handle two devices and there should be separate cdev structures to handle the devices.
 
  


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
linux kernel character driver xinren Linux - Newbie 2 06-26-2012 02:53 AM
Simple character driver sukhdham Linux - Newbie 2 09-25-2010 09:51 AM
Newbie character driver questions kamputty Linux - Kernel 2 04-06-2007 01:39 AM
Character Device driver: How to load it automatically ? shendeswanand Linux - Software 0 02-09-2006 09:59 PM
Character device driver calsoft_pg Linux - Software 0 01-03-2006 12:17 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:52 AM.

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