knewbies project? - updating LDD3 source
Robert P. J. Day
rpjday at crashcourse.ca
Tue May 24 16:26:18 EDT 2011
On Tue, 24 May 2011, Javier Martinez Canillas wrote:
> On Tue, May 24, 2011 at 8:14 PM, DG <dangets at gmail.com> wrote:
> > On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day
> > <rpjday at crashcourse.ca> wrote:
> >> On Tue, 24 May 2011, Jim Cromie wrote:
> >>
> >>> over at http://code.google.com/p/ldd3/
> >>> it says:
> >>> The famous "Linux Device Drivers" released the sample code. but the
> >>> code does not reflect the latest kernel updates, some of code cannot
> >>> even compile. This project is to make it compatible with the current
> >>> kernel.
> >>>
> >>> http://lwn.net/Kernel/LDD3/
> >>> http://examples.oreilly.com/9780596005900/
> >>
> >> the one caution i would give here is that quite a bit of code in
> >> LDD3 shouldn't be updated, anyway, since it reflects features that
> >> have been deprecated for quite some time.
> >>
> >> for instance, no one should be writing proc files anymore. also,
> >> ioctl()s are also discouraged for the most part. so i would be
> >> selective about what parts of LDD3 code *should* be updated as
> >> examples of good kernel programming.
> >>
> >> rday
> >
>
> Robert is right, the drivers are quite old. As Robert says proc files
> are deprecated in favor of sysfs and ioctl are discouraged in favor of
> netlink sockets. Another example is that most LDD3 driver modules are
> loaded with a script that create the device nodes. Unless your system
> is a embedded device (an even in that case) you should let udev do
> this). So instead of having drivers that just compile cleanly and
> works, it would be better to update the APIs the drivers use and how
> they interact with userspace.
there are also other drivers that simplify things immensely for you
that aren't mentioned in LDD3, such as the "misc" character driver,
that lets you register a character driver that needs only one minor
number at major number 10 and some randomly chosen and available minor
number. you can then get the minor number from the file /proc/misc
but you don't need to as the /dev file is (as far as i understand it)
created for you automatically.
in other words, you can avoid a lot of the work involved in writing
a character driver if you take advantage of that misc driver.
rday
--
========================================================================
Robert P. J. Day Ottawa, Ontario, CANADA
http://crashcourse.ca
Twitter: http://twitter.com/rpjday
LinkedIn: http://ca.linkedin.com/in/rpjday
========================================================================
More information about the Kernelnewbies
mailing list