diff options
| author | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-25 00:59:04 -0500 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-01-25 00:59:04 -0500 |
| commit | e374a2bfebf359f846216336de91670be40499da (patch) | |
| tree | 809347b4814c63feb06409a7fe9ddfa9d631896b | |
| parent | 79a6ee42fd81be9abc6bdab08f932875924b26a5 (diff) | |
Kobject: fix coding style issues in kobject c files
Clean up the kobject.c and kobject_uevent.c files to follow the
proper coding style rules.
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | lib/kobject.c | 139 | ||||
| -rw-r--r-- | lib/kobject_uevent.c | 7 |
2 files changed, 67 insertions, 79 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index 8dc32454661d..1d63ead1815e 100644 --- a/lib/kobject.c +++ b/lib/kobject.c | |||
| @@ -18,58 +18,57 @@ | |||
| 18 | #include <linux/stat.h> | 18 | #include <linux/stat.h> |
| 19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
| 20 | 20 | ||
| 21 | /** | 21 | /* |
| 22 | * populate_dir - populate directory with attributes. | 22 | * populate_dir - populate directory with attributes. |
| 23 | * @kobj: object we're working on. | 23 | * @kobj: object we're working on. |
| 24 | * | ||
| 25 | * Most subsystems have a set of default attributes that | ||
| 26 | * are associated with an object that registers with them. | ||
| 27 | * This is a helper called during object registration that | ||
| 28 | * loops through the default attributes of the subsystem | ||
| 29 | * and creates attributes files for them in sysfs. | ||
| 30 | * | 24 | * |
| 25 | * Most subsystems have a set of default attributes that are associated | ||
| 26 | * with an object that registers with them. This is a helper called during | ||
| 27 | * object registration that loops through the default attributes of the | ||
| 28 | * subsystem and creates attributes files for them in sysfs. | ||
| 31 | */ | 29 | */ |
| 32 | 30 | static int populate_dir(struct kobject *kobj) | |
| 33 | static int populate_dir(struct kobject * kobj) | ||
| 34 | { | 31 | { |
| 35 | struct kobj_type * t = get_ktype(kobj); | 32 | struct kobj_type *t = get_ktype(kobj); |
| 36 | struct attribute * attr; | 33 | struct attribute *attr; |
| 37 | int error = 0; | 34 | int error = 0; |
| 38 | int i; | 35 | int i; |
| 39 | 36 | ||
| 40 | if (t && t->default_attrs) { | 37 | if (t && t->default_attrs) { |
| 41 | for (i = 0; (attr = t->default_attrs[i]) != NULL; i++) { | 38 | for (i = 0; (attr = t->default_attrs[i]) != NULL; i++) { |
| 42 | if ((error = sysfs_create_file(kobj,attr))) | 39 | error = sysfs_create_file(kobj, attr); |
| 40 | if (error) | ||
| 43 | break; | 41 | break; |
| 44 | } | 42 | } |
| 45 | } | 43 | } |
| 46 | return error; | 44 | return error; |
| 47 | } | 45 | } |
| 48 | 46 | ||
| 49 | static int create_dir(struct kobject * kobj) | 47 | static int create_dir(struct kobject *kobj) |
| 50 | { | 48 | { |
| 51 | int error = 0; | 49 | int error = 0; |
| 52 | if (kobject_name(kobj)) { | 50 | if (kobject_name(kobj)) { |
| 53 | error = sysfs_create_dir(kobj); | 51 | error = sysfs_create_dir(kobj); |
| 54 | if (!error) { | 52 | if (!error) { |
| 55 | if ((error = populate_dir(kobj))) | 53 | error = populate_dir(kobj); |
| 54 | if (error) | ||
| 56 | sysfs_remove_dir(kobj); | 55 | sysfs_remove_dir(kobj); |
| 57 | } | 56 | } |
| 58 | } | 57 | } |
| 59 | return error; | 58 | return error; |
| 60 | } | 59 | } |
| 61 | 60 | ||
| 62 | static inline struct kobject * to_kobj(struct list_head * entry) | 61 | static inline struct kobject *to_kobj(struct list_head *entry) |
| 63 | { | 62 | { |
| 64 | return container_of(entry,struct kobject,entry); | 63 | return container_of(entry, struct kobject, entry); |
| 65 | } | 64 | } |
| 66 | 65 | ||
| 67 | static int get_kobj_path_length(struct kobject *kobj) | 66 | static int get_kobj_path_length(struct kobject *kobj) |
| 68 | { | 67 | { |
| 69 | int length = 1; | 68 | int length = 1; |
| 70 | struct kobject * parent = kobj; | 69 | struct kobject *parent = kobj; |
| 71 | 70 | ||
| 72 | /* walk up the ancestors until we hit the one pointing to the | 71 | /* walk up the ancestors until we hit the one pointing to the |
| 73 | * root. | 72 | * root. |
| 74 | * Add 1 to strlen for leading '/' of each level. | 73 | * Add 1 to strlen for leading '/' of each level. |
| 75 | */ | 74 | */ |
| @@ -84,19 +83,19 @@ static int get_kobj_path_length(struct kobject *kobj) | |||
| 84 | 83 | ||
| 85 | static void fill_kobj_path(struct kobject *kobj, char *path, int length) | 84 | static void fill_kobj_path(struct kobject *kobj, char *path, int length) |
| 86 | { | 85 | { |
| 87 | struct kobject * parent; | 86 | struct kobject *parent; |
| 88 | 87 | ||
| 89 | --length; | 88 | --length; |
| 90 | for (parent = kobj; parent; parent = parent->parent) { | 89 | for (parent = kobj; parent; parent = parent->parent) { |
| 91 | int cur = strlen(kobject_name(parent)); | 90 | int cur = strlen(kobject_name(parent)); |
| 92 | /* back up enough to print this name with '/' */ | 91 | /* back up enough to print this name with '/' */ |
| 93 | length -= cur; | 92 | length -= cur; |
| 94 | strncpy (path + length, kobject_name(parent), cur); | 93 | strncpy(path + length, kobject_name(parent), cur); |
| 95 | *(path + --length) = '/'; | 94 | *(path + --length) = '/'; |
| 96 | } | 95 | } |
| 97 | 96 | ||
| 98 | pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj), | 97 | pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj), |
| 99 | kobj, __FUNCTION__,path); | 98 | kobj, __FUNCTION__, path); |
| 100 | } | 99 | } |
| 101 | 100 | ||
| 102 | /** | 101 | /** |
| @@ -148,7 +147,7 @@ static void kobj_kset_leave(struct kobject *kobj) | |||
| 148 | kset_put(kobj->kset); | 147 | kset_put(kobj->kset); |
| 149 | } | 148 | } |
| 150 | 149 | ||
| 151 | static void kobject_init_internal(struct kobject * kobj) | 150 | static void kobject_init_internal(struct kobject *kobj) |
| 152 | { | 151 | { |
| 153 | if (!kobj) | 152 | if (!kobj) |
| 154 | return; | 153 | return; |
| @@ -160,7 +159,7 @@ static void kobject_init_internal(struct kobject * kobj) | |||
| 160 | static int kobject_add_internal(struct kobject *kobj) | 159 | static int kobject_add_internal(struct kobject *kobj) |
| 161 | { | 160 | { |
| 162 | int error = 0; | 161 | int error = 0; |
| 163 | struct kobject * parent; | 162 | struct kobject *parent; |
| 164 | 163 | ||
| 165 | if (!kobj) | 164 | if (!kobj) |
| 166 | return -ENOENT; | 165 | return -ENOENT; |
| @@ -185,7 +184,7 @@ static int kobject_add_internal(struct kobject *kobj) | |||
| 185 | pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n", | 184 | pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n", |
| 186 | kobject_name(kobj), kobj, __FUNCTION__, | 185 | kobject_name(kobj), kobj, __FUNCTION__, |
| 187 | parent ? kobject_name(parent) : "<NULL>", | 186 | parent ? kobject_name(parent) : "<NULL>", |
| 188 | kobj->kset ? kobject_name(&kobj->kset->kobj) : "<NULL>" ); | 187 | kobj->kset ? kobject_name(&kobj->kset->kobj) : "<NULL>"); |
| 189 | 188 | ||
| 190 | error = create_dir(kobj); | 189 | error = create_dir(kobj); |
| 191 | if (error) { | 190 | if (error) { |
| @@ -399,12 +398,11 @@ int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype, | |||
| 399 | EXPORT_SYMBOL_GPL(kobject_init_and_add); | 398 | EXPORT_SYMBOL_GPL(kobject_init_and_add); |
| 400 | 399 | ||
| 401 | /** | 400 | /** |
| 402 | * kobject_rename - change the name of an object | 401 | * kobject_rename - change the name of an object |
| 403 | * @kobj: object in question. | 402 | * @kobj: object in question. |
| 404 | * @new_name: object's new name | 403 | * @new_name: object's new name |
| 405 | */ | 404 | */ |
| 406 | 405 | int kobject_rename(struct kobject *kobj, const char *new_name) | |
| 407 | int kobject_rename(struct kobject * kobj, const char *new_name) | ||
| 408 | { | 406 | { |
| 409 | int error = 0; | 407 | int error = 0; |
| 410 | const char *devpath = NULL; | 408 | const char *devpath = NULL; |
| @@ -461,11 +459,10 @@ out: | |||
| 461 | } | 459 | } |
| 462 | 460 | ||
| 463 | /** | 461 | /** |
| 464 | * kobject_move - move object to another parent | 462 | * kobject_move - move object to another parent |
| 465 | * @kobj: object in question. | 463 | * @kobj: object in question. |
| 466 | * @new_parent: object's new parent (can be NULL) | 464 | * @new_parent: object's new parent (can be NULL) |
| 467 | */ | 465 | */ |
| 468 | |||
| 469 | int kobject_move(struct kobject *kobj, struct kobject *new_parent) | 466 | int kobject_move(struct kobject *kobj, struct kobject *new_parent) |
| 470 | { | 467 | { |
| 471 | int error; | 468 | int error; |
| @@ -513,11 +510,10 @@ out: | |||
| 513 | } | 510 | } |
| 514 | 511 | ||
| 515 | /** | 512 | /** |
| 516 | * kobject_del - unlink kobject from hierarchy. | 513 | * kobject_del - unlink kobject from hierarchy. |
| 517 | * @kobj: object. | 514 | * @kobj: object. |
| 518 | */ | 515 | */ |
| 519 | 516 | void kobject_del(struct kobject *kobj) | |
| 520 | void kobject_del(struct kobject * kobj) | ||
| 521 | { | 517 | { |
| 522 | if (!kobj) | 518 | if (!kobj) |
| 523 | return; | 519 | return; |
| @@ -530,11 +526,10 @@ void kobject_del(struct kobject * kobj) | |||
| 530 | } | 526 | } |
| 531 | 527 | ||
| 532 | /** | 528 | /** |
| 533 | * kobject_get - increment refcount for object. | 529 | * kobject_get - increment refcount for object. |
| 534 | * @kobj: object. | 530 | * @kobj: object. |
| 535 | */ | 531 | */ |
| 536 | 532 | struct kobject *kobject_get(struct kobject *kobj) | |
| 537 | struct kobject * kobject_get(struct kobject * kobj) | ||
| 538 | { | 533 | { |
| 539 | if (kobj) | 534 | if (kobj) |
| 540 | kref_get(&kobj->kref); | 535 | kref_get(&kobj->kref); |
| @@ -591,12 +586,12 @@ static void kobject_release(struct kref *kref) | |||
| 591 | } | 586 | } |
| 592 | 587 | ||
| 593 | /** | 588 | /** |
| 594 | * kobject_put - decrement refcount for object. | 589 | * kobject_put - decrement refcount for object. |
| 595 | * @kobj: object. | 590 | * @kobj: object. |
| 596 | * | 591 | * |
| 597 | * Decrement the refcount, and if 0, call kobject_cleanup(). | 592 | * Decrement the refcount, and if 0, call kobject_cleanup(). |
| 598 | */ | 593 | */ |
| 599 | void kobject_put(struct kobject * kobj) | 594 | void kobject_put(struct kobject *kobj) |
| 600 | { | 595 | { |
| 601 | if (kobj) | 596 | if (kobj) |
| 602 | kref_put(&kobj->kref, kobject_release); | 597 | kref_put(&kobj->kref, kobject_release); |
| @@ -670,11 +665,10 @@ struct kobject *kobject_create_and_add(const char *name, struct kobject *parent) | |||
| 670 | EXPORT_SYMBOL_GPL(kobject_create_and_add); | 665 | EXPORT_SYMBOL_GPL(kobject_create_and_add); |
| 671 | 666 | ||
| 672 | /** | 667 | /** |
| 673 | * kset_init - initialize a kset for use | 668 | * kset_init - initialize a kset for use |
| 674 | * @k: kset | 669 | * @k: kset |
| 675 | */ | 670 | */ |
| 676 | 671 | void kset_init(struct kset *k) | |
| 677 | void kset_init(struct kset * k) | ||
| 678 | { | 672 | { |
| 679 | kobject_init_internal(&k->kobj); | 673 | kobject_init_internal(&k->kobj); |
| 680 | INIT_LIST_HEAD(&k->list); | 674 | INIT_LIST_HEAD(&k->list); |
| @@ -712,11 +706,10 @@ struct sysfs_ops kobj_sysfs_ops = { | |||
| 712 | }; | 706 | }; |
| 713 | 707 | ||
| 714 | /** | 708 | /** |
| 715 | * kset_register - initialize and add a kset. | 709 | * kset_register - initialize and add a kset. |
| 716 | * @k: kset. | 710 | * @k: kset. |
| 717 | */ | 711 | */ |
| 718 | 712 | int kset_register(struct kset *k) | |
| 719 | int kset_register(struct kset * k) | ||
| 720 | { | 713 | { |
| 721 | int err; | 714 | int err; |
| 722 | 715 | ||
| @@ -731,39 +724,35 @@ int kset_register(struct kset * k) | |||
| 731 | return 0; | 724 | return 0; |
| 732 | } | 725 | } |
| 733 | 726 | ||
| 734 | |||
| 735 | /** | 727 | /** |
| 736 | * kset_unregister - remove a kset. | 728 | * kset_unregister - remove a kset. |
| 737 | * @k: kset. | 729 | * @k: kset. |
| 738 | */ | 730 | */ |
| 739 | 731 | void kset_unregister(struct kset *k) | |
| 740 | void kset_unregister(struct kset * k) | ||
| 741 | { | 732 | { |
| 742 | if (!k) | 733 | if (!k) |
| 743 | return; | 734 | return; |
| 744 | kobject_put(&k->kobj); | 735 | kobject_put(&k->kobj); |
| 745 | } | 736 | } |
| 746 | 737 | ||
| 747 | |||
| 748 | /** | 738 | /** |
| 749 | * kset_find_obj - search for object in kset. | 739 | * kset_find_obj - search for object in kset. |
| 750 | * @kset: kset we're looking in. | 740 | * @kset: kset we're looking in. |
| 751 | * @name: object's name. | 741 | * @name: object's name. |
| 752 | * | 742 | * |
| 753 | * Lock kset via @kset->subsys, and iterate over @kset->list, | 743 | * Lock kset via @kset->subsys, and iterate over @kset->list, |
| 754 | * looking for a matching kobject. If matching object is found | 744 | * looking for a matching kobject. If matching object is found |
| 755 | * take a reference and return the object. | 745 | * take a reference and return the object. |
| 756 | */ | 746 | */ |
| 757 | 747 | struct kobject *kset_find_obj(struct kset *kset, const char *name) | |
| 758 | struct kobject * kset_find_obj(struct kset * kset, const char * name) | ||
| 759 | { | 748 | { |
| 760 | struct list_head * entry; | 749 | struct list_head *entry; |
| 761 | struct kobject * ret = NULL; | 750 | struct kobject *ret = NULL; |
| 762 | 751 | ||
| 763 | spin_lock(&kset->list_lock); | 752 | spin_lock(&kset->list_lock); |
| 764 | list_for_each(entry,&kset->list) { | 753 | list_for_each(entry, &kset->list) { |
| 765 | struct kobject * k = to_kobj(entry); | 754 | struct kobject *k = to_kobj(entry); |
| 766 | if (kobject_name(k) && !strcmp(kobject_name(k),name)) { | 755 | if (kobject_name(k) && !strcmp(kobject_name(k), name)) { |
| 767 | ret = kobject_get(k); | 756 | ret = kobject_get(k); |
| 768 | break; | 757 | break; |
| 769 | } | 758 | } |
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c index b021e67c4294..5a402e2982af 100644 --- a/lib/kobject_uevent.c +++ b/lib/kobject_uevent.c | |||
| @@ -238,11 +238,12 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, | |||
| 238 | retval = add_uevent_var(env, "HOME=/"); | 238 | retval = add_uevent_var(env, "HOME=/"); |
| 239 | if (retval) | 239 | if (retval) |
| 240 | goto exit; | 240 | goto exit; |
| 241 | retval = add_uevent_var(env, "PATH=/sbin:/bin:/usr/sbin:/usr/bin"); | 241 | retval = add_uevent_var(env, |
| 242 | "PATH=/sbin:/bin:/usr/sbin:/usr/bin"); | ||
| 242 | if (retval) | 243 | if (retval) |
| 243 | goto exit; | 244 | goto exit; |
| 244 | 245 | ||
| 245 | call_usermodehelper (argv[0], argv, env->envp, UMH_WAIT_EXEC); | 246 | call_usermodehelper(argv[0], argv, env->envp, UMH_WAIT_EXEC); |
| 246 | } | 247 | } |
| 247 | 248 | ||
| 248 | exit: | 249 | exit: |
| @@ -250,7 +251,6 @@ exit: | |||
| 250 | kfree(env); | 251 | kfree(env); |
| 251 | return retval; | 252 | return retval; |
| 252 | } | 253 | } |
| 253 | |||
| 254 | EXPORT_SYMBOL_GPL(kobject_uevent_env); | 254 | EXPORT_SYMBOL_GPL(kobject_uevent_env); |
| 255 | 255 | ||
| 256 | /** | 256 | /** |
| @@ -266,7 +266,6 @@ int kobject_uevent(struct kobject *kobj, enum kobject_action action) | |||
| 266 | { | 266 | { |
| 267 | return kobject_uevent_env(kobj, action, NULL); | 267 | return kobject_uevent_env(kobj, action, NULL); |
| 268 | } | 268 | } |
| 269 | |||
| 270 | EXPORT_SYMBOL_GPL(kobject_uevent); | 269 | EXPORT_SYMBOL_GPL(kobject_uevent); |
| 271 | 270 | ||
| 272 | /** | 271 | /** |
