2009-06-23 06:19:52     Problem in Adding a new device driver to the kernel

Document created by Aaronwu Employee on Aug 15, 2013
Version 1Show Document
  • View in full screen mode

2009-06-23 06:19:52     Problem in Adding a new device driver to the kernel

Saravanan Solaiyappan (INDIA)

Message: 76183   

Hi,

 

I am trying to add a simple device driver in to the kernel build by refering the procedure given in

https://docs.blackfin.uclinux.org/doku.php?id=driver_development

 

I enabled the dynamic major number.

/* For dynamic major number */

static int scmd_major = 0;

 

I am able to get the kernel compiled.

After boot up, my device "scmd_basic" is not listed under /dev/.

Instead it is getting listed when I do "cat /proc/devices".

# cat /proc/devices

Character devices:

252 scmd_basic

 

Then from my application i am trying to open the device as below:

      

fd= open("scmd_basic",O_RDWR);      

if(fd > 0 )

{

   printf("\n device opened succesfully \n");      

}

else

{

   printf("\n not able to open device \n");

   return ENUM_IR_RET_ERROR;      

}

 

What is wrong with this open call?

What i am missing here?

 

Please help.

 

Thanks & Regards,

Saravanan.S

QuoteReplyEditDelete

 

 

2009-06-23 07:06:55     Re: Problem in Adding a new device driver to the kernel

Mike Frysinger (UNITED STATES)

Message: 76184   

 

if the device node doesnt exist, i dont see how you could possibly expect the open() to work

 

the driver example does not trigger the hotplug aspects of the kernel and so a node is not generated automatically.  simply make it yourself with `mknod`.

QuoteReplyEditDelete

 

 

2009-06-23 07:49:59     Re: Problem in Adding a new device driver to the kernel

Saravanan Solaiyappan (INDIA)

Message: 76186   

 

Mike,

 

This driver is compiled using "built-in" option. Shouldn't be listed automatically under /dev/?

 

If It is need to be done manually, Please let me know how to do it.

 

 

 

Thanks,

 

Saravanan.S

QuoteReplyEditDelete

 

 

2009-06-23 07:57:50     Re: Problem in Adding a new device driver to the kernel

Mike Frysinger (UNITED STATES)

Message: 76187   

 

how it is loaded has no bearing at all on dynamic creation of device nodes

 

i already said how to create it yourself -- use mknod.  if you dont know how to use this program, there is a man page.  you already found the major number via /proc/devices.

Attachments

    Outcomes