* [1/1] connector: export cn_already_initialized.
@ 2006-05-04 12:24 Evgeniy Polyakov
2006-05-06 0:16 ` David S. Miller
0 siblings, 1 reply; 7+ messages in thread
From: Evgeniy Polyakov @ 2006-05-04 12:24 UTC (permalink / raw)
To: David Miller; +Cc: netdev
Some modules depend on that value, although it was initially introduced
for in-kernel static build.
No in-kernel users require it to be exported, so if you do think it
should not be exported I will force external module changes.
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -486,3 +486,4 @@ module_exit(cn_fini);
EXPORT_SYMBOL_GPL(cn_add_callback);
EXPORT_SYMBOL_GPL(cn_del_callback);
EXPORT_SYMBOL_GPL(cn_netlink_send);
+EXPORT_SYMBOL_GPL(cn_already_initialized);
--
Evgeniy Polyakov
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [1/1] connector: export cn_already_initialized.
2006-05-04 12:24 [1/1] connector: export cn_already_initialized Evgeniy Polyakov
@ 2006-05-06 0:16 ` David S. Miller
2006-05-06 8:40 ` Evgeniy Polyakov
0 siblings, 1 reply; 7+ messages in thread
From: David S. Miller @ 2006-05-06 0:16 UTC (permalink / raw)
To: johnpol; +Cc: netdev
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Date: Thu, 4 May 2006 16:24:22 +0400
> No in-kernel users require it to be exported, so if you do think it
> should not be exported I will force external module changes.
What are the alternatives?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [1/1] connector: export cn_already_initialized.
2006-05-06 0:16 ` David S. Miller
@ 2006-05-06 8:40 ` Evgeniy Polyakov
2006-05-16 23:14 ` David S. Miller
0 siblings, 1 reply; 7+ messages in thread
From: Evgeniy Polyakov @ 2006-05-06 8:40 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
On Fri, May 05, 2006 at 05:16:46PM -0700, David S. Miller (davem@davemloft.net) wrote:
> From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
> Date: Thu, 4 May 2006 16:24:22 +0400
>
> > No in-kernel users require it to be exported, so if you do think it
> > should not be exported I will force external module changes.
>
> What are the alternatives?
This flag shows that connector has finished it's initialization and now
it's calbacks can be safely added. In-kernel users (like various
accountings) which are initialized first (like fs) use that flag to
check if connector can be added or not.
Some external patches, which can be built both as static build and as
module just check that value, and thus will fail with unresolved symbol
when cn and module are built as modules.
The right set of operations should be following:
If external module is loaded and cn is not loaded or compiled into the
kernel, insmod will just fail with unresolved symbol (cn_add_callback and others),
if cn is already loaded or was built into the tree, then it has been
initialized already and there is no need to check that value, external
module should be just loaded.
I think the right solution is to call external init functions after cn
init function, but it's ordering is not always known.
While writing this I've thought another solution, when
cn_add_callback() will just return -EINPROGRESS or other special error,
which means that it is too early to call it and it must be run later.
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 3589707..f852e68 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -308,6 +308,9 @@ int cn_add_callback(struct cb_id *id, ch
int err;
struct cn_dev *dev = &cdev;
+ if (!cn_already_initialized)
+ return -EINPROGRESS;
+
err = cn_queue_add_callback(dev->cbdev, name, id, callback);
if (err)
return err;
@@ -456,6 +459,8 @@ static int __init cn_init(void)
sock_release(dev->nls->sk_socket);
return -EINVAL;
}
+
+ cn_already_initialized = 1;
err = cn_add_callback(&dev->id, "connector", &cn_callback);
if (err) {
@@ -465,8 +470,6 @@ static int __init cn_init(void)
return -EINVAL;
}
- cn_already_initialized = 1;
-
return 0;
}
--
Evgeniy Polyakov
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [1/1] connector: export cn_already_initialized.
2006-05-06 8:40 ` Evgeniy Polyakov
@ 2006-05-16 23:14 ` David S. Miller
2006-05-24 8:38 ` Evgeniy Polyakov
2006-06-19 5:30 ` Evgeniy Polyakov
0 siblings, 2 replies; 7+ messages in thread
From: David S. Miller @ 2006-05-16 23:14 UTC (permalink / raw)
To: johnpol; +Cc: netdev
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Date: Sat, 6 May 2006 12:40:45 +0400
> Some external patches, which can be built both as static build and as
> module just check that value, and thus will fail with unresolved symbol
> when cn and module are built as modules.
>
> The right set of operations should be following:
> If external module is loaded and cn is not loaded or compiled into the
> kernel, insmod will just fail with unresolved symbol (cn_add_callback and others),
> if cn is already loaded or was built into the tree, then it has been
> initialized already and there is no need to check that value, external
> module should be just loaded.
>
> I think the right solution is to call external init functions after cn
> init function, but it's ordering is not always known.
In-kernel build of connector subsystem can be handled by
making cn_init a "subsystem_init()", it will then be setup
before any possible static or modular reference as long as
those modules use module_init().
For modular case of connector, dependency of module on connector
module should handle all ordering issues, making any ordering
issue take care of itself.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [1/1] connector: export cn_already_initialized.
2006-05-16 23:14 ` David S. Miller
@ 2006-05-24 8:38 ` Evgeniy Polyakov
2006-06-19 5:30 ` Evgeniy Polyakov
1 sibling, 0 replies; 7+ messages in thread
From: Evgeniy Polyakov @ 2006-05-24 8:38 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
On Tue, May 16, 2006 at 04:14:06PM -0700, David S. Miller (davem@davemloft.net) wrote:
> From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
> Date: Sat, 6 May 2006 12:40:45 +0400
> > I think the right solution is to call external init functions after cn
> > init function, but it's ordering is not always known.
>
> In-kernel build of connector subsystem can be handled by
> making cn_init a "subsystem_init()", it will then be setup
> before any possible static or modular reference as long as
> those modules use module_init().
subsystem_init() seems to be kobject related initilizator.
Maybe subsys_initcall()?
I will cook up a patch if it works.
Thank you.
--
Evgeniy Polyakov
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [1/1] connector: export cn_already_initialized.
2006-05-16 23:14 ` David S. Miller
2006-05-24 8:38 ` Evgeniy Polyakov
@ 2006-06-19 5:30 ` Evgeniy Polyakov
2006-06-20 6:43 ` David Miller
1 sibling, 1 reply; 7+ messages in thread
From: Evgeniy Polyakov @ 2006-06-19 5:30 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev
On Tue, May 16, 2006 at 04:14:06PM -0700, David S. Miller (davem@davemloft.net) wrote:
> From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
> Date: Sat, 6 May 2006 12:40:45 +0400
>
> > Some external patches, which can be built both as static build and as
> > module just check that value, and thus will fail with unresolved symbol
> > when cn and module are built as modules.
> >
> > The right set of operations should be following:
> > If external module is loaded and cn is not loaded or compiled into the
> > kernel, insmod will just fail with unresolved symbol (cn_add_callback and others),
> > if cn is already loaded or was built into the tree, then it has been
> > initialized already and there is no need to check that value, external
> > module should be just loaded.
> >
> > I think the right solution is to call external init functions after cn
> > init function, but it's ordering is not always known.
>
> In-kernel build of connector subsystem can be handled by
> making cn_init a "subsystem_init()", it will then be setup
> before any possible static or modular reference as long as
> those modules use module_init().
>
> For modular case of connector, dependency of module on connector
> module should handle all ordering issues, making any ordering
> issue take care of itself.
Attached patch declares connector init function as subsys_init()
and returns -EAGAIN in case connector is not initialized yet.
Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c
index 505677f..d1d964f 100644
--- a/drivers/connector/connector.c
+++ b/drivers/connector/connector.c
@@ -306,6 +306,9 @@ int cn_add_callback(struct cb_id *id, ch
int err;
struct cn_dev *dev = &cdev;
+ if (!cn_already_initialized)
+ return -EAGAIN;
+
err = cn_queue_add_callback(dev->cbdev, name, id, callback);
if (err)
return err;
@@ -433,7 +436,7 @@ static void cn_callback(void *data)
up(¬ify_lock);
}
-static int __init cn_init(void)
+static int __devinit cn_init(void)
{
struct cn_dev *dev = &cdev;
int err;
@@ -454,21 +458,22 @@ static int __init cn_init(void)
sock_release(dev->nls->sk_socket);
return -EINVAL;
}
+
+ cn_already_initialized = 1;
err = cn_add_callback(&dev->id, "connector", &cn_callback);
if (err) {
+ cn_already_initialized = 0;
cn_queue_free_dev(dev->cbdev);
if (dev->nls->sk_socket)
sock_release(dev->nls->sk_socket);
return -EINVAL;
}
- cn_already_initialized = 1;
-
return 0;
}
-static void __exit cn_fini(void)
+static void __devexit cn_fini(void)
{
struct cn_dev *dev = &cdev;
@@ -480,7 +485,7 @@ static void __exit cn_fini(void)
sock_release(dev->nls->sk_socket);
}
-module_init(cn_init);
+subsys_initcall(cn_init);
module_exit(cn_fini);
EXPORT_SYMBOL_GPL(cn_add_callback);
--
Evgeniy Polyakov
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [1/1] connector: export cn_already_initialized.
2006-06-19 5:30 ` Evgeniy Polyakov
@ 2006-06-20 6:43 ` David Miller
0 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2006-06-20 6:43 UTC (permalink / raw)
To: johnpol; +Cc: netdev
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Date: Mon, 19 Jun 2006 09:30:35 +0400
> Attached patch declares connector init function as subsys_init()
> and returns -EAGAIN in case connector is not initialized yet.
>
> Signed-off-by: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Applied, but I had to fixup something by hand:
> @@ -433,7 +436,7 @@ static void cn_callback(void *data)
> up(¬ify_lock);
> }
>
> -static int __init cn_init(void)
> +static int __devinit cn_init(void)
notify_lock is now a mutex.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-06-20 6:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-04 12:24 [1/1] connector: export cn_already_initialized Evgeniy Polyakov
2006-05-06 0:16 ` David S. Miller
2006-05-06 8:40 ` Evgeniy Polyakov
2006-05-16 23:14 ` David S. Miller
2006-05-24 8:38 ` Evgeniy Polyakov
2006-06-19 5:30 ` Evgeniy Polyakov
2006-06-20 6:43 ` David Miller
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).