linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Use of __init in asus_acpi.c + sony_acpi.c?
@ 2006-02-26  9:42 Sam Ravnborg
  2006-03-01 19:15 ` Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Sam Ravnborg @ 2006-02-26  9:42 UTC (permalink / raw)
  To: len.brown, LKML, linux-acpi

When running the section mismatch check on latest -mm I see:

WARNING: drivers/acpi/asus_acpi.o - Section mismatch: reference to \
.init.text:asus_hotk_add from .data between 'asus_hotk_driver' (at \
offset 0xe0) and 'model_conf'
WARNING: drivers/acpi/sony_acpi.o - Section mismatch: reference to \
.init.text:sony_acpi_add from .data between 'sony_acpi_driver' (at \
offset 0xe0) and 'sony_acpi_values'
WARNING: drivers/acpi/sony_acpi.o - Section mismatch: reference to    \
.exit.text:sony_acpi_remove from .data between 'sony_acpi_driver' (at \
offset 0xe8) and 'sony_acpi_values'

Browsing the source I see that this is assignments to struct acpi_driver
structure:

static struct acpi_driver asus_hotk_driver = {
	.name = ACPI_HOTK_NAME,
	.class = ACPI_HOTK_CLASS,
	.ids = ACPI_HOTK_HID,
	.ops = {
		.add = asus_hotk_add,          <==== __init
		.remove	= asus_hotk_remove,
	},
};


>From browsing the code I cannot see when this happens.
In asus_acpi.c and sony_acpi.c the .add and .remove methods are
declared __init/__exit indicating that the add method is solely used
during early init of the module.

Is it correct that acpi_bus_register_driver() is only called during the
early init phase of a drivers and so we can discard the .add methods
after first usage?

Likewise for .remove that this is only used when a module is unloaded
and so can be discarded when builtin?

Either asus_acpi.c and sony_acpi.c needs updates or the rest of
acpi_driver needs an update (fails to use __init, __exit).

	Sam



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

* Re: Use of __init in asus_acpi.c + sony_acpi.c?
  2006-02-26  9:42 Use of __init in asus_acpi.c + sony_acpi.c? Sam Ravnborg
@ 2006-03-01 19:15 ` Bjorn Helgaas
  2006-03-01 20:51   ` [PATCH] ACPI: remove __init/__exit from Asus and Sony .add()/.remove() methods Bjorn Helgaas
  0 siblings, 1 reply; 3+ messages in thread
From: Bjorn Helgaas @ 2006-03-01 19:15 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: len.brown, LKML, linux-acpi, Karol Kozimor, Julien Lerouge,
	acpi4asus-user, Stelian Pop

On Sunday 26 February 2006 02:42, Sam Ravnborg wrote:
> WARNING: drivers/acpi/asus_acpi.o - Section mismatch: reference to \
> .init.text:asus_hotk_add from .data between 'asus_hotk_driver' (at \
> offset 0xe0) and 'model_conf'
> WARNING: drivers/acpi/sony_acpi.o - Section mismatch: reference to \
> .init.text:sony_acpi_add from .data between 'sony_acpi_driver' (at \
> offset 0xe0) and 'sony_acpi_values'
> ...
> From browsing the code I cannot see when this happens.
> In asus_acpi.c and sony_acpi.c the .add and .remove methods are
> declared __init/__exit indicating that the add method is solely used
> during early init of the module.
> 
> Is it correct that acpi_bus_register_driver() is only called during the
> early init phase of a drivers and so we can discard the .add methods
> after first usage?

I think this is a bug in asus_acpi.c and sony_acpi.c.  They assume
that their devices can not be hot-plugged, so if they aren't found
at the time of acpi_bus_register_driver(), they can discard the
.add() methods.

It is true that these particular devices can't be hot-plugged, but
there's no way to tell that to acpi_bus_register_driver(), so we have
to assume .add() could be called as long as the driver remains
registered.

I'll cook up a patch for asus_acpi.c and sony_acpi.c.  Thanks for
finding this.

Bjorn

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

* [PATCH] ACPI: remove __init/__exit from Asus and Sony .add()/.remove() methods
  2006-03-01 19:15 ` Bjorn Helgaas
@ 2006-03-01 20:51   ` Bjorn Helgaas
  0 siblings, 0 replies; 3+ messages in thread
From: Bjorn Helgaas @ 2006-03-01 20:51 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: len.brown, LKML, linux-acpi, Karol Kozimor, Julien Lerouge,
	acpi4asus-user, Stelian Pop, Andrew Morton

Even though the devices claimed by asus_acpi.c and sony_acpi.c can not
be hot-plugged, the driver registration infrastructure allows the .add()
and .remove() methods to be called at any time while the driver is
registered.  So remove __init and __exit from them.

Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>

Index: work-mm4/drivers/acpi/asus_acpi.c
===================================================================
--- work-mm4.orig/drivers/acpi/asus_acpi.c	2006-02-22 09:55:50.000000000 -0700
+++ work-mm4/drivers/acpi/asus_acpi.c	2006-03-01 12:17:50.000000000 -0700
@@ -817,7 +817,7 @@
 			      unsigned long count, void *data);
 
 static int
-__init asus_proc_add(char *name, proc_writefunc * writefunc,
+asus_proc_add(char *name, proc_writefunc * writefunc,
 		     proc_readfunc * readfunc, mode_t mode,
 		     struct acpi_device *device)
 {
@@ -836,7 +836,7 @@
 	return 0;
 }
 
-static int __init asus_hotk_add_fs(struct acpi_device *device)
+static int asus_hotk_add_fs(struct acpi_device *device)
 {
 	struct proc_dir_entry *proc;
 	mode_t mode;
@@ -954,7 +954,7 @@
  * This function is used to initialize the hotk with right values. In this
  * method, we can make all the detection we want, and modify the hotk struct
  */
-static int __init asus_hotk_get_info(void)
+static int asus_hotk_get_info(void)
 {
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
 	struct acpi_buffer dsdt = { ACPI_ALLOCATE_BUFFER, NULL };
@@ -1101,7 +1101,7 @@
 	return AE_OK;
 }
 
-static int __init asus_hotk_check(void)
+static int asus_hotk_check(void)
 {
 	int result = 0;
 
@@ -1121,7 +1121,7 @@
 
 static int asus_hotk_found;
 
-static int __init asus_hotk_add(struct acpi_device *device)
+static int asus_hotk_add(struct acpi_device *device)
 {
 	acpi_status status = AE_OK;
 	int result;
Index: work-mm4/drivers/acpi/sony_acpi.c
===================================================================
--- work-mm4.orig/drivers/acpi/sony_acpi.c	2006-02-22 09:55:50.000000000 -0700
+++ work-mm4/drivers/acpi/sony_acpi.c	2006-03-01 12:18:24.000000000 -0700
@@ -258,7 +258,7 @@
 	return AE_OK;
 }
 
-static int __init sony_acpi_add(struct acpi_device *device)
+static int sony_acpi_add(struct acpi_device *device)
 {
 	acpi_status status;
 	int result;
@@ -340,7 +340,7 @@
 }
 
 
-static int __exit sony_acpi_remove(struct acpi_device *device, int type)
+static int sony_acpi_remove(struct acpi_device *device, int type)
 {
 	acpi_status status;
 	struct sony_acpi_value *item;

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

end of thread, other threads:[~2006-03-01 20:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-26  9:42 Use of __init in asus_acpi.c + sony_acpi.c? Sam Ravnborg
2006-03-01 19:15 ` Bjorn Helgaas
2006-03-01 20:51   ` [PATCH] ACPI: remove __init/__exit from Asus and Sony .add()/.remove() methods Bjorn Helgaas

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).