All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Hinko Kočevar" <hinko.kocevar@cetrtapot.si>
To: linux-kernel@vger.kernel.org
Subject: register_chrdev vs. cdev_add
Date: Wed, 14 May 2008 14:31:49 +0200	[thread overview]
Message-ID: <482ADBB5.8050608@cetrtapot.si> (raw)

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


             reply	other threads:[~2008-05-14 12:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-14 12:31 Hinko Kočevar [this message]
2008-05-14 14:01 ` register_chrdev vs. cdev_add Jonathan Corbet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=482ADBB5.8050608@cetrtapot.si \
    --to=hinko.kocevar@cetrtapot.si \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.