aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kobject.c')
-rw-r--r--lib/kobject.c69
1 files changed, 8 insertions, 61 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index cecf2fbede3e..fc5f3f6e7329 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -582,22 +582,10 @@ void kset_init(struct kset * k)
582/** 582/**
583 * kset_add - add a kset object to the hierarchy. 583 * kset_add - add a kset object to the hierarchy.
584 * @k: kset. 584 * @k: kset.
585 *
586 * Simply, this adds the kset's embedded kobject to the
587 * hierarchy.
588 * We also try to make sure that the kset's embedded kobject
589 * has a parent before it is added. We only care if the embedded
590 * kobject is not part of a kset itself, since kobject_add()
591 * assigns a parent in that case.
592 * If that is the case, and the kset has a controlling subsystem,
593 * then we set the kset's parent to be said subsystem.
594 */ 585 */
595 586
596int kset_add(struct kset * k) 587int kset_add(struct kset * k)
597{ 588{
598 if (!k->kobj.parent && !k->kobj.kset && k->subsys)
599 k->kobj.parent = &k->subsys->kset.kobj;
600
601 return kobject_add(&k->kobj); 589 return kobject_add(&k->kobj);
602} 590}
603 591
@@ -656,53 +644,28 @@ struct kobject * kset_find_obj(struct kset * kset, const char * name)
656 return ret; 644 return ret;
657} 645}
658 646
659 647void subsystem_init(struct kset *s)
660void subsystem_init(struct subsystem * s)
661{ 648{
662 kset_init(&s->kset); 649 kset_init(s);
663} 650}
664 651
665/** 652int subsystem_register(struct kset *s)
666 * subsystem_register - register a subsystem.
667 * @s: the subsystem we're registering.
668 *
669 * Once we register the subsystem, we want to make sure that
670 * the kset points back to this subsystem.
671 */
672
673int subsystem_register(struct subsystem * s)
674{ 653{
675 int error; 654 return kset_register(s);
676
677 if (!s)
678 return -EINVAL;
679
680 subsystem_init(s);
681 pr_debug("subsystem %s: registering\n",s->kset.kobj.name);
682
683 if (!(error = kset_add(&s->kset))) {
684 if (!s->kset.subsys)
685 s->kset.subsys = s;
686 }
687 return error;
688} 655}
689 656
690void subsystem_unregister(struct subsystem * s) 657void subsystem_unregister(struct kset *s)
691{ 658{
692 if (!s) 659 kset_unregister(s);
693 return;
694 pr_debug("subsystem %s: unregistering\n",s->kset.kobj.name);
695 kset_unregister(&s->kset);
696} 660}
697 661
698
699/** 662/**
700 * subsystem_create_file - export sysfs attribute file. 663 * subsystem_create_file - export sysfs attribute file.
701 * @s: subsystem. 664 * @s: subsystem.
702 * @a: subsystem attribute descriptor. 665 * @a: subsystem attribute descriptor.
703 */ 666 */
704 667
705int subsys_create_file(struct subsystem * s, struct subsys_attribute * a) 668int subsys_create_file(struct kset *s, struct subsys_attribute *a)
706{ 669{
707 int error = 0; 670 int error = 0;
708 671
@@ -710,28 +673,12 @@ int subsys_create_file(struct subsystem * s, struct subsys_attribute * a)
710 return -EINVAL; 673 return -EINVAL;
711 674
712 if (subsys_get(s)) { 675 if (subsys_get(s)) {
713 error = sysfs_create_file(&s->kset.kobj,&a->attr); 676 error = sysfs_create_file(&s->kobj, &a->attr);
714 subsys_put(s); 677 subsys_put(s);
715 } 678 }
716 return error; 679 return error;
717} 680}
718 681
719
720/**
721 * subsystem_remove_file - remove sysfs attribute file.
722 * @s: subsystem.
723 * @a: attribute desciptor.
724 */
725#if 0
726void subsys_remove_file(struct subsystem * s, struct subsys_attribute * a)
727{
728 if (subsys_get(s)) {
729 sysfs_remove_file(&s->kset.kobj,&a->attr);
730 subsys_put(s);
731 }
732}
733#endif /* 0 */
734
735EXPORT_SYMBOL(kobject_init); 682EXPORT_SYMBOL(kobject_init);
736EXPORT_SYMBOL(kobject_register); 683EXPORT_SYMBOL(kobject_register);
737EXPORT_SYMBOL(kobject_unregister); 684EXPORT_SYMBOL(kobject_unregister);