diff options
author | Evgeniy Polyakov <johnpol@2ka.mipt.ru> | 2006-06-20 02:42:53 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2006-06-20 02:42:53 -0400 |
commit | d6cc7f1a3b33c89c91b3dfce1ff053178893470e (patch) | |
tree | 8eb8796588b53648c42378a19a6089a5b8790308 /drivers/connector | |
parent | d3dcd4efe2ad1ad1865b2fe5c863c1ebd9482a84 (diff) |
[CONNECTOR]: Initialize subsystem earlier.
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/connector')
-rw-r--r-- | drivers/connector/connector.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/connector/connector.c b/drivers/connector/connector.c index 35897079a78d..79d581c86520 100644 --- a/drivers/connector/connector.c +++ b/drivers/connector/connector.c | |||
@@ -308,6 +308,9 @@ int cn_add_callback(struct cb_id *id, char *name, void (*callback)(void *)) | |||
308 | int err; | 308 | int err; |
309 | struct cn_dev *dev = &cdev; | 309 | struct cn_dev *dev = &cdev; |
310 | 310 | ||
311 | if (!cn_already_initialized) | ||
312 | return -EAGAIN; | ||
313 | |||
311 | err = cn_queue_add_callback(dev->cbdev, name, id, callback); | 314 | err = cn_queue_add_callback(dev->cbdev, name, id, callback); |
312 | if (err) | 315 | if (err) |
313 | return err; | 316 | return err; |
@@ -435,7 +438,7 @@ static void cn_callback(void *data) | |||
435 | mutex_unlock(¬ify_lock); | 438 | mutex_unlock(¬ify_lock); |
436 | } | 439 | } |
437 | 440 | ||
438 | static int __init cn_init(void) | 441 | static int __devinit cn_init(void) |
439 | { | 442 | { |
440 | struct cn_dev *dev = &cdev; | 443 | struct cn_dev *dev = &cdev; |
441 | int err; | 444 | int err; |
@@ -456,21 +459,22 @@ static int __init cn_init(void) | |||
456 | sock_release(dev->nls->sk_socket); | 459 | sock_release(dev->nls->sk_socket); |
457 | return -EINVAL; | 460 | return -EINVAL; |
458 | } | 461 | } |
462 | |||
463 | cn_already_initialized = 1; | ||
459 | 464 | ||
460 | err = cn_add_callback(&dev->id, "connector", &cn_callback); | 465 | err = cn_add_callback(&dev->id, "connector", &cn_callback); |
461 | if (err) { | 466 | if (err) { |
467 | cn_already_initialized = 0; | ||
462 | cn_queue_free_dev(dev->cbdev); | 468 | cn_queue_free_dev(dev->cbdev); |
463 | if (dev->nls->sk_socket) | 469 | if (dev->nls->sk_socket) |
464 | sock_release(dev->nls->sk_socket); | 470 | sock_release(dev->nls->sk_socket); |
465 | return -EINVAL; | 471 | return -EINVAL; |
466 | } | 472 | } |
467 | 473 | ||
468 | cn_already_initialized = 1; | ||
469 | |||
470 | return 0; | 474 | return 0; |
471 | } | 475 | } |
472 | 476 | ||
473 | static void __exit cn_fini(void) | 477 | static void __devexit cn_fini(void) |
474 | { | 478 | { |
475 | struct cn_dev *dev = &cdev; | 479 | struct cn_dev *dev = &cdev; |
476 | 480 | ||
@@ -482,7 +486,7 @@ static void __exit cn_fini(void) | |||
482 | sock_release(dev->nls->sk_socket); | 486 | sock_release(dev->nls->sk_socket); |
483 | } | 487 | } |
484 | 488 | ||
485 | module_init(cn_init); | 489 | subsys_initcall(cn_init); |
486 | module_exit(cn_fini); | 490 | module_exit(cn_fini); |
487 | 491 | ||
488 | EXPORT_SYMBOL_GPL(cn_add_callback); | 492 | EXPORT_SYMBOL_GPL(cn_add_callback); |