All of lore.kernel.org
 help / color / mirror / Atom feed
* knewbies project? - updating LDD3 source
@ 2011-05-24 17:35 Jim Cromie
  2011-05-24 17:47 ` Robert P. J. Day
  0 siblings, 1 reply; 12+ messages in thread
From: Jim Cromie @ 2011-05-24 17:35 UTC (permalink / raw)
  To: kernelnewbies

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/

Neither the OReilly tarball, nor the googlecode's svn repo will compile for me
on an updated F-14 box, neither against uname -r, or a local git-tree.

So I pulled the svn-tree, and made these changes.
I got a fair way to getting things to compile.
Changes are quick-n-dirty, and some may be wrong,
esp around workqueue stuff - I pretty much did what compiler told me,
w/o any analysis.

I didnt even get compilation on the aio/iovec users, on the changes from 2003.
I havent really gotten my head around the whole conversion strategy;
I know a loop over iovec elements is probably needed,
but Im unclear where it should be.

and Im unsure whether these functions are now cluttering up things.

static void sculld_do_deferred_op(void *p)
static int sculld_defer_op(int write, struct kiocb *iocb, const struct
iovec *iov,
		size_t count, loff_t pos)

I guess the point is Ive run out of time now, and am hoping for a dose
of clarity, and further patches, to get LDD3 source compiling, up-to-date,
and reflecting current best practices.


GRUMBLING: its annoying that the googlecode web-page obfuscates the
site owner, making it impossible to reach him.

Username: guanzhi1... at gmail.com

Is there another LDD3 repo somewhere, that a google search didnt reveal to me ?
perhaps on kernel.org ??
Should there be ?

Im attaching my svndiff, in hte hopes that folks here will
apply it and improve upon it.

thanks
~jimc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ldd3-code.svndiff
Type: application/octet-stream
Size: 20910 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110524/c9441ff7/attachment-0001.obj 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* knewbies project? - updating LDD3 source
  2011-05-24 17:35 knewbies project? - updating LDD3 source Jim Cromie
@ 2011-05-24 17:47 ` Robert P. J. Day
  2011-05-24 18:14   ` DG
  0 siblings, 1 reply; 12+ messages in thread
From: Robert P. J. Day @ 2011-05-24 17:47 UTC (permalink / raw)
  To: kernelnewbies

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 P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

^ permalink raw reply	[flat|nested] 12+ messages in thread

* knewbies project? - updating LDD3 source
  2011-05-24 17:47 ` Robert P. J. Day
@ 2011-05-24 18:14   ` DG
  2011-05-24 20:17     ` Javier Martinez Canillas
  0 siblings, 1 reply; 12+ messages in thread
From: DG @ 2011-05-24 18:14 UTC (permalink / raw)
  To: kernelnewbies

On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day
<rpjday@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

There is a repo on GitHub with the same purpose.  I haven't checked it
out personally, but it's probably worth a look.

https://github.com/martinezjavier/ldd3

^ permalink raw reply	[flat|nested] 12+ messages in thread

* knewbies project? - updating LDD3 source
  2011-05-24 18:14   ` DG
@ 2011-05-24 20:17     ` Javier Martinez Canillas
  2011-05-24 20:26       ` Robert P. J. Day
  0 siblings, 1 reply; 12+ messages in thread
From: Javier Martinez Canillas @ 2011-05-24 20:17 UTC (permalink / raw)
  To: kernelnewbies

On Tue, May 24, 2011 at 8:14 PM, DG <dangets@gmail.com> wrote:
> On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day
> <rpjday@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 is a repo on GitHub with the same purpose. ?I haven't checked it
> out personally, but it's probably worth a look.
>
> https://github.com/martinezjavier/ldd3
>

As the author of the repo I can tell that the drivers compile with
kernels 2.6.32, 2.6.35 and from 2.6.37 forward (including 2.6.39 and
linux-next). I create it for academic purposes, I haven't thest all
the drivers, only the ones I needed for the students.

Best regards,

-- 
Javier Mart?nez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Aut?noma de Barcelona
Barcelona, Spain

^ permalink raw reply	[flat|nested] 12+ messages in thread

* knewbies project? - updating LDD3 source
  2011-05-24 20:17     ` Javier Martinez Canillas
@ 2011-05-24 20:26       ` Robert P. J. Day
  2011-05-24 20:32         ` Leon Woestenberg
  0 siblings, 1 reply; 12+ messages in thread
From: Robert P. J. Day @ 2011-05-24 20:26 UTC (permalink / raw)
  To: kernelnewbies

On Tue, 24 May 2011, Javier Martinez Canillas wrote:

> On Tue, May 24, 2011 at 8:14 PM, DG <dangets@gmail.com> wrote:
> > On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day
> > <rpjday@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
========================================================================

^ permalink raw reply	[flat|nested] 12+ messages in thread

* knewbies project? - updating LDD3 source
  2011-05-24 20:26       ` Robert P. J. Day
@ 2011-05-24 20:32         ` Leon Woestenberg
  2011-05-24 20:36           ` Robert P. J. Day
                             ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Leon Woestenberg @ 2011-05-24 20:32 UTC (permalink / raw)
  To: kernelnewbies

Hello all,

On Tue, May 24, 2011 at 10:26 PM, Robert P. J. Day
<rpjday@crashcourse.ca> wrote:
> On Tue, 24 May 2011, Javier Martinez Canillas wrote:
>
>> On Tue, May 24, 2011 at 8:14 PM, DG <dangets@gmail.com> wrote:
>> > On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day
>> > <rpjday@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.
>> >>>

Why not take this a little bit higher and rewrite the LDD3 book
sections that need updating, not (only) the source code examples.

This can be taken on piecewise.

I would see this identical to kernel/Documentation/* except that the
pieces are targetting device driver developers.

Regards,
-- 
Leon

^ permalink raw reply	[flat|nested] 12+ messages in thread

* knewbies project? - updating LDD3 source
  2011-05-24 20:32         ` Leon Woestenberg
@ 2011-05-24 20:36           ` Robert P. J. Day
  2011-05-24 21:02             ` Javier Martinez Canillas
  2011-05-24 20:37           ` Manohar Vanga
  2011-05-25  3:42           ` naren.mehra at gmail.com
  2 siblings, 1 reply; 12+ messages in thread
From: Robert P. J. Day @ 2011-05-24 20:36 UTC (permalink / raw)
  To: kernelnewbies

On Tue, 24 May 2011, Leon Woestenberg wrote:

> Hello all,
>
> On Tue, May 24, 2011 at 10:26 PM, Robert P. J. Day
> <rpjday@crashcourse.ca> wrote:
> > On Tue, 24 May 2011, Javier Martinez Canillas wrote:
> >
> >> On Tue, May 24, 2011 at 8:14 PM, DG <dangets@gmail.com> wrote:
> >> > On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day
> >> > <rpjday@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.
> >> >>>
>
> Why not take this a little bit higher and rewrite the LDD3 book
> sections that need updating, not (only) the source code examples.
>
> This can be taken on piecewise.
>
> I would see this identical to kernel/Documentation/* except that the
> pieces are targetting device driver developers.

  i would take a closer look at the samples/ directory in the kernel
source tree.  i am, in fact, writing a number of sample modules and
drivers to be incorporated into an introductory kernel programming
and device drivers course but i don't think i can share them all as
they're part of the official courseware.  but i'm sure there are
plenty of people who can write sample modules and drivers that would
fit nicely in that samples/ directory.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================

^ permalink raw reply	[flat|nested] 12+ messages in thread

* knewbies project? - updating LDD3 source
  2011-05-24 20:32         ` Leon Woestenberg
  2011-05-24 20:36           ` Robert P. J. Day
@ 2011-05-24 20:37           ` Manohar Vanga
  2011-05-25  3:42           ` naren.mehra at gmail.com
  2 siblings, 0 replies; 12+ messages in thread
From: Manohar Vanga @ 2011-05-24 20:37 UTC (permalink / raw)
  To: kernelnewbies

> I would see this identical to kernel/Documentation/* except that the
> pieces are targetting device driver developers.
>

Take a look at the smallsample at the link below. The examples are well
documented and it could be expanded to include more features of the kernel.

http://gnudd.com/workdoc.shtml

-- 
/manohar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110524/ffd03905/attachment.html 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* knewbies project? - updating LDD3 source
  2011-05-24 20:36           ` Robert P. J. Day
@ 2011-05-24 21:02             ` Javier Martinez Canillas
  0 siblings, 0 replies; 12+ messages in thread
From: Javier Martinez Canillas @ 2011-05-24 21:02 UTC (permalink / raw)
  To: kernelnewbies

>
> ?i would take a closer look at the samples/ directory in the kernel
> source tree. ?i am, in fact, writing a number of sample modules and
> drivers to be incorporated into an introductory kernel programming
> and device drivers course but i don't think i can share them all as
> they're part of the official courseware. ?but i'm sure there are
> plenty of people who can write sample modules and drivers that would
> fit nicely in that samples/ directory.
>
> rday
>

The samples/ directory would be an excellent place to add examples
because the code would have to be maintained.

Does anyone know what is the policy to make a sample worth its place
in samples dir an not be considered as a bloat? Looking at the dir
seems to be that is only for samples about the usage of internal
kernel API (kfifo, kprobes, kobject, etc).

Regards,

-- 
Javier Mart?nez Canillas
(+34) 682 39 81 69
PhD Student in High Performance Computing
Computer Architecture and Operating System Department (CAOS)
Universitat Aut?noma de Barcelona
Barcelona, Spain

^ permalink raw reply	[flat|nested] 12+ messages in thread

* knewbies project? - updating LDD3 source
  2011-05-24 20:32         ` Leon Woestenberg
  2011-05-24 20:36           ` Robert P. J. Day
  2011-05-24 20:37           ` Manohar Vanga
@ 2011-05-25  3:42           ` naren.mehra at gmail.com
  2011-05-25  6:27             ` Mohamed Thalib H
  2 siblings, 1 reply; 12+ messages in thread
From: naren.mehra at gmail.com @ 2011-05-25  3:42 UTC (permalink / raw)
  To: kernelnewbies

On Wed, May 25, 2011 at 2:02 AM, Leon Woestenberg
<leon.woestenberg@gmail.com> wrote:
> Hello all,
>
> On Tue, May 24, 2011 at 10:26 PM, Robert P. J. Day
> <rpjday@crashcourse.ca> wrote:
>> On Tue, 24 May 2011, Javier Martinez Canillas wrote:
>>
>>> On Tue, May 24, 2011 at 8:14 PM, DG <dangets@gmail.com> wrote:
>>> > On Tue, May 24, 2011 at 11:47 AM, Robert P. J. Day
>>> > <rpjday@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.
>>> >>>
>
> Why not take this a little bit higher and rewrite the LDD3 book
> sections that need updating, not (only) the source code examples.
>

This sounds like an excellent idea.
Can a project like that could be started in sourceforge ??
Can somebody take the ownership for the same ??
I am sure a lot of us would like to contribute.

-- Naren

> This can be taken on piecewise.
>
> I would see this identical to kernel/Documentation/* except that the
> pieces are targetting device driver developers.
>
> Regards,
> --
> Leon
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* knewbies project? - updating LDD3 source
  2011-05-25  3:42           ` naren.mehra at gmail.com
@ 2011-05-25  6:27             ` Mohamed Thalib H
  2011-05-25  7:29               ` sumeet linux
  0 siblings, 1 reply; 12+ messages in thread
From: Mohamed Thalib H @ 2011-05-25  6:27 UTC (permalink / raw)
  To: kernelnewbies

On Wednesday 25 May 2011 09:12 AM, naren.mehra at gmail.com wrote:
>> Why not take this a little bit higher and rewrite the LDD3 book
>> >  sections that need updating, not (only) the source code examples.
>> >
> This sounds like an excellent idea.
> Can a project like that could be started in sourceforge ??
> Can somebody take the ownership for the same ??
> I am sure a lot of us would like to contribute.
Small suggestion. If the book is rewritten again it will be outdated in 
some time. instead
setup a wiki and every one contributes/changes to keep it update.

Already kernelnewbies.org is setup using wiki and it is up and running 
always, so this website
can can be reused instead of creating a new one.

- Mohamed Thalib H.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* knewbies project? - updating LDD3 source
  2011-05-25  6:27             ` Mohamed Thalib H
@ 2011-05-25  7:29               ` sumeet linux
  0 siblings, 0 replies; 12+ messages in thread
From: sumeet linux @ 2011-05-25  7:29 UTC (permalink / raw)
  To: kernelnewbies

On Wed, May 25, 2011 at 11:57 AM, Mohamed Thalib H <hmthalib@gmail.com>wrote:

> On Wednesday 25 May 2011 09:12 AM, naren.mehra at gmail.com wrote:
> >> Why not take this a little bit higher and rewrite the LDD3 book
> >> >  sections that need updating, not (only) the source code examples.
> >> >
> > This sounds like an excellent idea.
> > Can a project like that could be started in sourceforge ??
> > Can somebody take the ownership for the same ??
> > I am sure a lot of us would like to contribute.
> Small suggestion. If the book is rewritten again it will be outdated in
> some time. instead
> setup a wiki and every one contributes/changes to keep it update.


> Already kernelnewbies.org is setup using wiki and it is up and running
> always, so this website
> can can be reused instead of creating a new one.
>


This is really good suggestion to use the wiki and update the info as time
goes.


Regards,
Sumeet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110525/37ee2d01/attachment.html 

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-05-25  7:29 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-24 17:35 knewbies project? - updating LDD3 source Jim Cromie
2011-05-24 17:47 ` Robert P. J. Day
2011-05-24 18:14   ` DG
2011-05-24 20:17     ` Javier Martinez Canillas
2011-05-24 20:26       ` Robert P. J. Day
2011-05-24 20:32         ` Leon Woestenberg
2011-05-24 20:36           ` Robert P. J. Day
2011-05-24 21:02             ` Javier Martinez Canillas
2011-05-24 20:37           ` Manohar Vanga
2011-05-25  3:42           ` naren.mehra at gmail.com
2011-05-25  6:27             ` Mohamed Thalib H
2011-05-25  7:29               ` sumeet linux

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.