lkml.org 
[lkml]   [2008]   [May]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectregister_chrdev vs. cdev_add
Hi,

Testing 2.6.26 (GIT) on cris architecture shown that old style of registering
char devices with register_chrdev() vs. new style with cdev_init() and
cdev_add() does not produce the same results.

static unsigned int htrc110_major = 123;
static unsigned int htrc110_minor = 2;

CODE:
dev = MKDEV(htrc110_major, htrc110_minor);
ret = register_chrdev_region(dev, 1, mod_name);
ret = register_chrdev(dev, mod_name, &htrc110_fops);

Using char driver with 123 major and 2 minor and registering it with
register_chrdev() shows this in /proc/devices:
# cat /proc/devices
Character devices:
1 mem
2 pty
3 ttyp
4 ttyS
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/ptmx
10 misc
29 fb
90 mtd
123 carneol-htrc110
128 ptm
136 pts
180 usb
128974850 carneol-htrc110
189 usb_device
253 usb_endpoint
254 usbmon

CODE:
dev = MKDEV(htrc110_major, htrc110_minor);
ret = register_chrdev_region(dev, 1, mod_name);
cdev_init(&htrc110_dev->cdev, &htrc110_fops);
htrc110_dev->cdev.owner = THIS_MODULE;
htrc110_dev->cdev.ops = &htrc110_fops;
ret = cdev_add(&htrc110_dev->cdev, dev, 1);

While using cdev_init() and cdev_add():
# cat /proc/devices
Character devices:
1 mem
2 pty
3 ttyp
4 ttyS
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/ptmx
10 misc
29 fb
90 mtd
123 carneol-htrc110
128 ptm
136 pts
180 usb
189 usb_device
253 usb_endpoint
254 usbmon

This is just heads up, I know that the old interface to registering char devices
will be dropped, but when...

regards,
Hinko

--
ČETRTA POT, d.o.o., Kranj
Planina 3
4000 Kranj
Slovenia, Europe
Tel. +386 (0) 4 280 66 03
E-mail: hinko.kocevar@cetrtapot.si
Http: www.cetrtapot.si

--
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/

\
 
 \ /
  Last update: 2008-05-14 14:35    [from the cache]
©2003-2011 Jasper Spaans