2010-01-10 11:31:29 Creating a device class (/dev entry)
Marin Bek (CROATIA)
Message: 84386
Hi,
I'm attempting to write a test driver, just to get the hang of it, and all went fine, apart from the fact i have to mknod the /dev device entry. I want to create the entry automatically, but to no avail. Relevant code snippet I wrote follows:
static struct class *led_class; CLASS_ATTR(led,S_IRUGO, NULL, NULL); ,
,
, led_class=class_create(THIS_MODULE,DRIVER_NAME);
if (class_create_file(led_class,&class_attr_led)){
printk( "led: class_create_file error\n");
goto fail_regija;
}
sprintf(nam,"led%d",led_minor);
device_create(led_class,NULL,dev,"%s",nam);
Device is created as CHAR device and it works properly. /sys/class/led/led0 and /sys/devices/virtual/led/led0 are created, but not the /dev entry.
What am I missing?
Thanks
QuoteReplyEditDelete
2010-01-10 13:54:05 Re: Creating a device class (/dev entry)
Marin Bek (CROATIA)
Message: 84387
eh, mdev -s scans the /sys and creates the device node...
Any ideas on how to make it scan automatically or sth?
QuoteReplyEditDelete
2010-01-10 15:09:40 Re: Creating a device class (/dev entry)
Mike Frysinger (UNITED STATES)
Message: 84389
you didnt say what version of software you're using. mdev is configured in all ADI default builds to run automatically since 2008R1.
QuoteReplyEditDelete
2010-01-10 15:47:59 Re: Creating a device class (/dev entry)
Marin Bek (CROATIA)
Message: 84390
2009R1 ... I saw it's supposed to run automatically, that's why I spent the afternoon thinking my code was wrong until I decided to run it myself and voila :\ is it supposed to run automatically on insmod, or only at boot?
QuoteReplyEditDelete
2010-01-10 16:20:10 Re: Creating a device class (/dev entry)
Mike Frysinger (UNITED STATES)
Message: 84392
neither. if your device driver generates the correct events, the hotplug mech is automatically called.
verify /proc/sys/kernel/hotplug is set to /bin/mdev.
QuoteReplyEditDelete
2010-01-10 17:05:25 Re: Creating a device class (/dev entry)
Marin Bek (CROATIA)
Message: 84393
Tthe kernel option wasn't even set -.- can't believe I lost an entire day on this...
Thanks a lot for your help, could've spent a lot more time on this if it weren't for you!
QuoteReplyEditDelete
2010-01-10 17:29:01 Re: Creating a device class (/dev entry)
Mike Frysinger (UNITED STATES)
Message: 84394
CONFIG_HOTPLUG should be enabled in all default ADI kernel configs too ...