mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2.5] pcmcia (2/5): add bus_type pcmcia_bus_type
@ 2003-03-22 16:00 Dominik Brodowski
  2003-03-23  4:33 ` Linus Torvalds
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Brodowski @ 2003-03-22 16:00 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

Register a bus_type pcmcia_bus_type. This means the initialization of
the ds module needs to be done in two levels: one quite early
(subsys_initcall) so that drivers may use the bus_type; the other one
must stay that late (late_initcall). As only one initcall can be
specified within one module, some tweaking is needed.

	  Dominik

diff -ruN linux-original/drivers/pcmcia/ds.c linux/drivers/pcmcia/ds.c
--- linux-original/drivers/pcmcia/ds.c	2003-03-22 16:12:08.000000000 +0100
+++ linux/drivers/pcmcia/ds.c	2003-03-22 16:11:50.000000000 +0100
@@ -881,7 +881,18 @@
 
 /*====================================================================*/
 
-int __init init_pcmcia_ds(void)
+struct bus_type pcmcia_bus_type = {
+	.name = "pcmcia",
+};
+EXPORT_SYMBOL(pcmcia_bus_type);
+
+static int __init init_pcmcia_bus(void)
+{
+	bus_register(&pcmcia_bus_type);
+	return 0;
+}
+
+static int __init init_pcmcia_ds(void)
 {
     client_reg_t client_reg;
     servinfo_t serv;
@@ -967,11 +978,8 @@
     return 0;
 }
 
-late_initcall(init_pcmcia_ds);
-
-#ifdef MODULE
 
-void __exit cleanup_module(void)
+static void __exit exit_pcmcia_ds(void)
 {
     int i;
 #ifdef CONFIG_PROC_FS
@@ -984,6 +992,23 @@
 	pcmcia_deregister_client(socket_table[i].handle);
     sockets = 0;
     kfree(socket_table);
+    bus_unregister(&pcmcia_bus_type);
 }
 
+#ifdef MODULE
+
+/* init_pcmcia_bus must be done early, init_pcmcia_ds late. If we load this 
+ * as a module, we can only specify one initcall, though... 
+ */
+static int __init init_pcmcia_module(void) {
+	init_pcmcia_bus();
+	return init_pcmcia_ds();
+}
+module_init(init_pcmcia_module);
+
+#else /* !MODULE */
+subsys_initcall(init_pcmcia_bus);
+late_initcall(init_pcmcia_ds);
 #endif
+
+module_exit(exit_pcmcia_ds);
diff -ruN linux-original/include/pcmcia/ds.h linux/include/pcmcia/ds.h
--- linux-original/include/pcmcia/ds.h	2003-03-22 16:12:08.000000000 +0100
+++ linux/include/pcmcia/ds.h	2003-03-22 16:12:25.000000000 +0100
@@ -32,6 +32,7 @@
 
 #include <pcmcia/driver_ops.h>
 #include <pcmcia/bulkmem.h>
+#include <linux/device.h>
 
 typedef struct tuple_parse_t {
     tuple_t		tuple;
@@ -143,6 +144,8 @@
 #define register_pcmcia_driver register_pccard_driver
 #define unregister_pcmcia_driver unregister_pccard_driver
 
+extern struct bus_type pcmcia_bus_type;
+
 #endif /* __KERNEL__ */
 
 #endif /* _LINUX_DS_H */

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

* Re: [PATCH 2.5] pcmcia (2/5): add bus_type pcmcia_bus_type
  2003-03-22 16:00 [PATCH 2.5] pcmcia (2/5): add bus_type pcmcia_bus_type Dominik Brodowski
@ 2003-03-23  4:33 ` Linus Torvalds
  2003-03-25  3:39   ` Rusty Russell
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Torvalds @ 2003-03-23  4:33 UTC (permalink / raw)
  To: Dominik Brodowski, Rusty Russell; +Cc: linux-kernel


On Sat, 22 Mar 2003, Dominik Brodowski wrote:
>
> Register a bus_type pcmcia_bus_type. This means the initialization of
> the ds module needs to be done in two levels: one quite early
> (subsys_initcall) so that drivers may use the bus_type; the other one
> must stay that late (late_initcall). As only one initcall can be
> specified within one module, some tweaking is needed.

Hmm.. We should fix the module interface instead. 

I've applied this patch, but there's no reall reason why modules 
shouldn't be able to have multiple initcalls.

Having drivers behave differently whether they are compiled in or as
modules is not a good thing. Rusty?

		Linus


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

* Re: [PATCH 2.5] pcmcia (2/5): add bus_type pcmcia_bus_type
  2003-03-23  4:33 ` Linus Torvalds
@ 2003-03-25  3:39   ` Rusty Russell
  0 siblings, 0 replies; 3+ messages in thread
From: Rusty Russell @ 2003-03-25  3:39 UTC (permalink / raw)
  To: Linus Torvalds, Dominik Brodowski, Rusty Russell; +Cc: linux-kernel

In message <Pine.LNX.4.44.0303222030360.5588-100000@home.transmeta.com> you wri
te:
> 
> On Sat, 22 Mar 2003, Dominik Brodowski wrote:
> >
> > Register a bus_type pcmcia_bus_type. This means the initialization of
> > the ds module needs to be done in two levels: one quite early
> > (subsys_initcall) so that drivers may use the bus_type; the other one
> > must stay that late (late_initcall). As only one initcall can be
> > specified within one module, some tweaking is needed.
> 
> Hmm.. We should fix the module interface instead. 
> 
> I've applied this patch, but there's no reall reason why modules 
> shouldn't be able to have multiple initcalls.

Sure, it's been asked for before (dwmw2 IIRC).

We need a new interface though, like:

	init_and_cleanup(init1, cleanup1);

Because you have to unroll them when one fails.

But of course, you thought of that before you asked, right?
Rusty.
--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

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

end of thread, other threads:[~2003-03-25  3:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-22 16:00 [PATCH 2.5] pcmcia (2/5): add bus_type pcmcia_bus_type Dominik Brodowski
2003-03-23  4:33 ` Linus Torvalds
2003-03-25  3:39   ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®