Begin forwarded message:
Date: Mon, 26 Jun 2006 14:42:39 -0700
From: nigel <emte_at_labotomy.net>
To: familiar-dev_at_handhelds.org
Subject: [Familiar-dev] Dynamic major-minor number allocation
Looking through some of the, apm, battery, and sleeve stuff for the h3600
i've noticed that the old statically requested 2.4-style magor/minor number
system is being used.
Any objections to, or reasons against me starting to implement the
new hybrid style major-minor request? The hybrid style will accept
both styles and be future compatable if the kernel developers go
through with thier threat of only allowing dynamic allocation.
My adaptaion of this would be to dynamically allocate if the static
request fails, that way you "should" always get a device.
Basic textbook example of the hybrid style:
/* Hybrid Assign or Allocate device numbers for 2.6.10+
* Exerpt from O'Reilly Linux Device Drivers 3rd Edition
*/
if(skull_major)
{
/* Legacy support for direct assignment */
dev = MKDEV(skull_major, skull_minor);
result = register_chrdev_region(dev, scull_nr_devs, "skull");
}
else
{
/* Dynamic allocation support */
result = alloc_chrdev_region(&dev, skull_minor, skull_nr_devs, "skull");
skull_major = MAJOR(dev));
}
/* Allocatio/assignment failure notice */
(result < 0)?(printk(KERN_WARNING "skull: can't get major %d\n", skull_major);
nigel
_______________________________________________
Familiar-dev mailing list
Familiar-dev_at_handhelds.org
https://handhelds.org/mailman/listinfo/familiar-dev
Received on Mon Jun 26 2006 - 20:38:54 EDT
This archive was generated by hypermail 2.2.0 : Mon Jun 26 2006 - 20:39:02 EDT