linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Writing modules for 2.5
@ 2003-04-15 11:15 Måns Rullgård
  2003-04-15 14:24 ` Jonathan Corbet
  2003-04-15 20:43 ` Sam Ravnborg
  0 siblings, 2 replies; 17+ messages in thread
From: Måns Rullgård @ 2003-04-15 11:15 UTC (permalink / raw)
  To: linux-kernel


What magic needs to be done when writing modules for linux 2.5.x?
Insmod tells me "Invalid module format" and the kernel log says "No
module found in object".  I've tried to mimic the foo.mod.c stuff in
the kernel tree, but I can't figure out the right way to do it.

-- 
Måns Rullgård
mru@users.sf.net

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

* Re: Writing modules for 2.5
  2003-04-15 11:15 Writing modules for 2.5 Måns Rullgård
@ 2003-04-15 14:24 ` Jonathan Corbet
  2003-04-15 20:43 ` Sam Ravnborg
  1 sibling, 0 replies; 17+ messages in thread
From: Jonathan Corbet @ 2003-04-15 14:24 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: linux-kernel

> What magic needs to be done when writing modules for linux 2.5.x?

May I humbly suggest LWN's "porting drivers to 2.5" series?

	http://lwn.net/Articles/driver-porting

There's 20-some articles there now on various API changes in the 2.5
kernel.  The series is getting reasonably complete at this point; hopefully
it will be helpful.

jon

Jonathan Corbet
Executive editor, LWN.net
corbet@lwn.net

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

* Re: Writing modules for 2.5
  2003-04-15 11:15 Writing modules for 2.5 Måns Rullgård
  2003-04-15 14:24 ` Jonathan Corbet
@ 2003-04-15 20:43 ` Sam Ravnborg
  1 sibling, 0 replies; 17+ messages in thread
From: Sam Ravnborg @ 2003-04-15 20:43 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: linux-kernel

On Tue, Apr 15, 2003 at 01:15:17PM +0200, Måns Rullgård wrote:
> 
> What magic needs to be done when writing modules for linux 2.5.x?

First of all you need to follow Documentation/modules.txt when
compiling modules.
If you try to make your own build system you are sure to hit problems.

	Sam

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

* Re: Writing modules for 2.5
  2003-04-15 15:42           ` Måns Rullgård
@ 2003-04-15 21:31             ` Russell King
  0 siblings, 0 replies; 17+ messages in thread
From: Russell King @ 2003-04-15 21:31 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: Alan Cox, Linux Kernel Mailing List

On Tue, Apr 15, 2003 at 05:42:07PM +0200, Måns Rullgård wrote:
> Does this work in 2.4 also

Yes.

-- 
Russell King (rmk@arm.linux.org.uk)                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html


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

* Re: Writing modules for 2.5
  2003-04-15 12:57         ` Russell King
  2003-04-15 13:24           ` Dave Jones
@ 2003-04-15 15:42           ` Måns Rullgård
  2003-04-15 21:31             ` Russell King
  1 sibling, 1 reply; 17+ messages in thread
From: Måns Rullgård @ 2003-04-15 15:42 UTC (permalink / raw)
  To: Russell King; +Cc: Alan Cox, Linux Kernel Mailing List

Russell King <rmk@arm.linux.org.uk> writes:

> > My situation is like this: I am converting a char device driver to
> > work with linux 2.5.  In the open and close functions there are
> > MOD_INC/DEC_USECOUNT calls.  The question is what they should be
> > replaced with.  Will it be handled correctly without them?
> 
> If it's a character device driver using the struct file_operations,
> set the owner field as Alan mentioned, and remove the
> MOD_{INC,DEC}_USE_COUNT macros from the open/close methods.  This
> allows chrdev_open() (in fs/char_dev.c) to increment your module use
> count automatically.

Does this work in 2.4 also, or is the owner field used for something
else there?

-- 
Måns Rullgård
mru@users.sf.net

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

* Re: Writing modules for 2.5
  2003-04-15 12:39       ` Måns Rullgård
  2003-04-15 12:57         ` Russell King
@ 2003-04-15 14:24         ` Alan Cox
  1 sibling, 0 replies; 17+ messages in thread
From: Alan Cox @ 2003-04-15 14:24 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: Linux Kernel Mailing List

On Maw, 2003-04-15 at 13:39, Måns Rullgård wrote:
> My situation is like this: I am converting a char device driver to
> work with linux 2.5.  In the open and close functions there are
> MOD_INC/DEC_USECOUNT calls.  The question is what they should be
> replaced with.  Will it be handled correctly without them?

Remove the MOD_INC/DEC counts in the open/close path and add
owner: THIS_MODULE in the file ops, and all is happy.


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

* Re: Writing modules for 2.5
  2003-04-15 12:57         ` Russell King
@ 2003-04-15 13:24           ` Dave Jones
  2003-04-15 15:42           ` Måns Rullgård
  1 sibling, 0 replies; 17+ messages in thread
From: Dave Jones @ 2003-04-15 13:24 UTC (permalink / raw)
  To: M?ns Rullg?rd, Alan Cox, Linux Kernel Mailing List

On Tue, Apr 15, 2003 at 01:57:58PM +0100, Russell King wrote:
 > On Tue, Apr 15, 2003 at 02:39:14PM +0200, M?ns Rullg?rd wrote:
 > > My situation is like this: I am converting a char device driver to
 > > work with linux 2.5.  In the open and close functions there are
 > > MOD_INC/DEC_USECOUNT calls.  The question is what they should be
 > > replaced with.  Will it be handled correctly without them?
 > 
 > If it's a character device driver using the struct file_operations,
 > set the owner field as Alan mentioned, and remove the
 > MOD_{INC,DEC}_USE_COUNT macros from the open/close methods.  This
 > allows chrdev_open() (in fs/char_dev.c) to increment your module use
 > count automatically.

Unless the open/close functions are doing funky things (like the
watchdog drivers do).

		Dave


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

* Re: Writing modules for 2.5
  2003-04-15 12:15     ` Andreas Henriksson
  2003-04-15 12:30       ` Måns Rullgård
@ 2003-04-15 12:58       ` Russell King
  1 sibling, 0 replies; 17+ messages in thread
From: Russell King @ 2003-04-15 12:58 UTC (permalink / raw)
  To: Andreas Henriksson; +Cc: Måns Rullgård, linux-kernel

On Tue, Apr 15, 2003 at 02:15:18PM +0200, Andreas Henriksson wrote:
> On Tue, Apr 15, 2003 at 02:05:48PM +0200, Måns Rullgård wrote:
> > Next question:  what is the correct replacement for MOD_INC_USE_COUNT?
> 
> "SET_MODULE_OWNER(dev);" or simply "dev->owner=THIS_MODULE;" and the
> counting should then be done automatically AFAIK.

You don't need that for char drivers.

-- 
Russell King (rmk@arm.linux.org.uk)                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html


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

* Re: Writing modules for 2.5
  2003-04-15 12:39       ` Måns Rullgård
@ 2003-04-15 12:57         ` Russell King
  2003-04-15 13:24           ` Dave Jones
  2003-04-15 15:42           ` Måns Rullgård
  2003-04-15 14:24         ` Alan Cox
  1 sibling, 2 replies; 17+ messages in thread
From: Russell King @ 2003-04-15 12:57 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: Alan Cox, Linux Kernel Mailing List

On Tue, Apr 15, 2003 at 02:39:14PM +0200, Måns Rullgård wrote:
> My situation is like this: I am converting a char device driver to
> work with linux 2.5.  In the open and close functions there are
> MOD_INC/DEC_USECOUNT calls.  The question is what they should be
> replaced with.  Will it be handled correctly without them?

If it's a character device driver using the struct file_operations,
set the owner field as Alan mentioned, and remove the
MOD_{INC,DEC}_USE_COUNT macros from the open/close methods.  This
allows chrdev_open() (in fs/char_dev.c) to increment your module use
count automatically.

-- 
Russell King (rmk@arm.linux.org.uk)                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html


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

* Re: Writing modules for 2.5
  2003-04-15 11:35     ` Alan Cox
@ 2003-04-15 12:39       ` Måns Rullgård
  2003-04-15 12:57         ` Russell King
  2003-04-15 14:24         ` Alan Cox
  0 siblings, 2 replies; 17+ messages in thread
From: Måns Rullgård @ 2003-04-15 12:39 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel Mailing List

Alan Cox <alan@lxorguk.ukuu.org.uk> writes:

> > Next question:  what is the correct replacement for MOD_INC_USE_COUNT?
> 
> If you know the use count is already one there isnt one, jut use
> MOD_INC_USE_COUNT and flame Rusty
> 
> If you can't prove the use count is already one for your own module
> you have a problem (and did in 2.4 in truth). The layers try and 
> lock the layer below. So char drivers are locked by core code,
> block drivers likewise, tty drivers and so on...
> 
> Most driver layers now have an owner: field in the file ops or other
> structure they register
> 
> 	owner: THIS_MODULE,
> 
> (THIS_MODULE comes out currently in a non modular buils too)

My situation is like this: I am converting a char device driver to
work with linux 2.5.  In the open and close functions there are
MOD_INC/DEC_USECOUNT calls.  The question is what they should be
replaced with.  Will it be handled correctly without them?

-- 
Måns Rullgård
mru@users.sf.net

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

* Re: Writing modules for 2.5
  2003-04-15 12:15     ` Andreas Henriksson
@ 2003-04-15 12:30       ` Måns Rullgård
  2003-04-15 12:58       ` Russell King
  1 sibling, 0 replies; 17+ messages in thread
From: Måns Rullgård @ 2003-04-15 12:30 UTC (permalink / raw)
  To: Andreas Henriksson; +Cc: linux-kernel

Andreas Henriksson <andreas@fjortis.info> writes:

> > Next question:  what is the correct replacement for MOD_INC_USE_COUNT?
> 
> "SET_MODULE_OWNER(dev);" or simply "dev->owner=THIS_MODULE;" and the
> counting should then be done automatically AFAIK.

OK, but what might dev be and when should this be done?  What about
MOD_DEC_USE_COUNT?

-- 
Måns Rullgård
mru@users.sf.net

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

* Re: Writing modules for 2.5
  2003-04-15 12:05   ` Måns Rullgård
  2003-04-15 11:35     ` Alan Cox
@ 2003-04-15 12:15     ` Andreas Henriksson
  2003-04-15 12:30       ` Måns Rullgård
  2003-04-15 12:58       ` Russell King
  1 sibling, 2 replies; 17+ messages in thread
From: Andreas Henriksson @ 2003-04-15 12:15 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: linux-kernel

On Tue, Apr 15, 2003 at 02:05:48PM +0200, Måns Rullgård wrote:
> Next question:  what is the correct replacement for MOD_INC_USE_COUNT?

"SET_MODULE_OWNER(dev);" or simply "dev->owner=THIS_MODULE;" and the
counting should then be done automatically AFAIK.

> -- 
> Måns Rullgård
> mru@users.sf.net

Regards,
Andreas Henriksson

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

* Re: Writing modules for 2.5
  2003-04-15 11:28 ` Andi Kleen
  2003-04-15 12:00   ` Måns Rullgård
@ 2003-04-15 12:05   ` Måns Rullgård
  2003-04-15 11:35     ` Alan Cox
  2003-04-15 12:15     ` Andreas Henriksson
  1 sibling, 2 replies; 17+ messages in thread
From: Måns Rullgård @ 2003-04-15 12:05 UTC (permalink / raw)
  To: linux-kernel

Andi Kleen <ak@suse.de> writes:

> > What magic needs to be done when writing modules for linux 2.5.x?
> > Insmod tells me "Invalid module format" and the kernel log says "No
> > module found in object".  I've tried to mimic the foo.mod.c stuff in
> > the kernel tree, but I can't figure out the right way to do it.
> 
> Welcome to the wonderful new world of in kernel module loading, finally
> with understandable error messages. Now bad error reporting is not limited
> to netlink anymore.
> 
> You need -DKBUILD_BASENAME=name
> 
> Also you need module_init/module_exit declarations.

Next question:  what is the correct replacement for MOD_INC_USE_COUNT?

-- 
Måns Rullgård
mru@users.sf.net

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

* Re: Writing modules for 2.5
  2003-04-15 12:00   ` Måns Rullgård
@ 2003-04-15 12:05     ` Andi Kleen
  0 siblings, 0 replies; 17+ messages in thread
From: Andi Kleen @ 2003-04-15 12:05 UTC (permalink / raw)
  To: M?ns Rullg?rd; +Cc: Andi Kleen, linux-kernel

On Tue, Apr 15, 2003 at 02:00:45PM +0200, M?ns Rullg?rd wrote:
> Andi Kleen <ak@suse.de> writes:
> 
> > > What magic needs to be done when writing modules for linux 2.5.x?
> > > Insmod tells me "Invalid module format" and the kernel log says "No
> > > module found in object".  I've tried to mimic the foo.mod.c stuff in
> > > the kernel tree, but I can't figure out the right way to do it.
> > 
> > Welcome to the wonderful new world of in kernel module loading, finally
> > with understandable error messages. Now bad error reporting is not limited
> > to netlink anymore.
> > 
> > You need -DKBUILD_BASENAME=name
> 
> Should I also add -DKBUILD_MODNAME=name?

Yes.

-Andi

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

* Re: Writing modules for 2.5
  2003-04-15 11:28 ` Andi Kleen
@ 2003-04-15 12:00   ` Måns Rullgård
  2003-04-15 12:05     ` Andi Kleen
  2003-04-15 12:05   ` Måns Rullgård
  1 sibling, 1 reply; 17+ messages in thread
From: Måns Rullgård @ 2003-04-15 12:00 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel

Andi Kleen <ak@suse.de> writes:

> > What magic needs to be done when writing modules for linux 2.5.x?
> > Insmod tells me "Invalid module format" and the kernel log says "No
> > module found in object".  I've tried to mimic the foo.mod.c stuff in
> > the kernel tree, but I can't figure out the right way to do it.
> 
> Welcome to the wonderful new world of in kernel module loading, finally
> with understandable error messages. Now bad error reporting is not limited
> to netlink anymore.
> 
> You need -DKBUILD_BASENAME=name

Should I also add -DKBUILD_MODNAME=name?

-- 
Måns Rullgård
mru@users.sf.net

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

* Re: Writing modules for 2.5
  2003-04-15 12:05   ` Måns Rullgård
@ 2003-04-15 11:35     ` Alan Cox
  2003-04-15 12:39       ` Måns Rullgård
  2003-04-15 12:15     ` Andreas Henriksson
  1 sibling, 1 reply; 17+ messages in thread
From: Alan Cox @ 2003-04-15 11:35 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: Linux Kernel Mailing List

On Maw, 2003-04-15 at 13:05, Måns Rullgård wrote:
> Next question:  what is the correct replacement for MOD_INC_USE_COUNT?

If you know the use count is already one there isnt one, jut use
MOD_INC_USE_COUNT and flame Rusty

If you can't prove the use count is already one for your own module
you have a problem (and did in 2.4 in truth). The layers try and 
lock the layer below. So char drivers are locked by core code,
block drivers likewise, tty drivers and so on...

Most driver layers now have an owner: field in the file ops or other
structure they register

	owner: THIS_MODULE,

(THIS_MODULE comes out currently in a non modular buils too)


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

* Re: Writing modules for 2.5
       [not found] <yw1x7k9w9flm.fsf@zaphod.guide.suse.lists.linux.kernel>
@ 2003-04-15 11:28 ` Andi Kleen
  2003-04-15 12:00   ` Måns Rullgård
  2003-04-15 12:05   ` Måns Rullgård
  0 siblings, 2 replies; 17+ messages in thread
From: Andi Kleen @ 2003-04-15 11:28 UTC (permalink / raw)
  To: Måns Rullgård; +Cc: linux-kernel

mru@users.sourceforge.net (Måns Rullgård) writes:

> What magic needs to be done when writing modules for linux 2.5.x?
> Insmod tells me "Invalid module format" and the kernel log says "No
> module found in object".  I've tried to mimic the foo.mod.c stuff in
> the kernel tree, but I can't figure out the right way to do it.

Welcome to the wonderful new world of in kernel module loading, finally
with understandable error messages. Now bad error reporting is not limited
to netlink anymore.

You need -DKBUILD_BASENAME=name

Also you need module_init/module_exit declarations.

-Andi

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

end of thread, other threads:[~2003-04-15 21:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-15 11:15 Writing modules for 2.5 Måns Rullgård
2003-04-15 14:24 ` Jonathan Corbet
2003-04-15 20:43 ` Sam Ravnborg
     [not found] <yw1x7k9w9flm.fsf@zaphod.guide.suse.lists.linux.kernel>
2003-04-15 11:28 ` Andi Kleen
2003-04-15 12:00   ` Måns Rullgård
2003-04-15 12:05     ` Andi Kleen
2003-04-15 12:05   ` Måns Rullgård
2003-04-15 11:35     ` Alan Cox
2003-04-15 12:39       ` Måns Rullgård
2003-04-15 12:57         ` Russell King
2003-04-15 13:24           ` Dave Jones
2003-04-15 15:42           ` Måns Rullgård
2003-04-15 21:31             ` Russell King
2003-04-15 14:24         ` Alan Cox
2003-04-15 12:15     ` Andreas Henriksson
2003-04-15 12:30       ` Måns Rullgård
2003-04-15 12:58       ` Russell King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).