Commit e374a2bfebf359f846216336de91670be40499da
1 parent
79a6ee42fd
Exists in
master
and in
4 other branches
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>
Showing 2 changed files with 67 additions and 79 deletions Side-by-side Diff
lib/kobject.c
... | ... | @@ -18,58 +18,57 @@ |
18 | 18 | #include <linux/stat.h> |
19 | 19 | #include <linux/slab.h> |
20 | 20 | |
21 | -/** | |
22 | - * populate_dir - populate directory with attributes. | |
23 | - * @kobj: object we're working on. | |
21 | +/* | |
22 | + * populate_dir - populate directory with attributes. | |
23 | + * @kobj: object we're working on. | |
24 | 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 | - * | |
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 | - | |
33 | -static int populate_dir(struct kobject * kobj) | |
30 | +static int populate_dir(struct kobject *kobj) | |
34 | 31 | { |
35 | - struct kobj_type * t = get_ktype(kobj); | |
36 | - struct attribute * attr; | |
32 | + struct kobj_type *t = get_ktype(kobj); | |
33 | + struct attribute *attr; | |
37 | 34 | int error = 0; |
38 | 35 | int i; |
39 | - | |
36 | + | |
40 | 37 | if (t && t->default_attrs) { |
41 | 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 | 41 | break; |
44 | 42 | } |
45 | 43 | } |
46 | 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 | 49 | int error = 0; |
52 | 50 | if (kobject_name(kobj)) { |
53 | 51 | error = sysfs_create_dir(kobj); |
54 | 52 | if (!error) { |
55 | - if ((error = populate_dir(kobj))) | |
53 | + error = populate_dir(kobj); | |
54 | + if (error) | |
56 | 55 | sysfs_remove_dir(kobj); |
57 | 56 | } |
58 | 57 | } |
59 | 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 | 66 | static int get_kobj_path_length(struct kobject *kobj) |
68 | 67 | { |
69 | 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 | 72 | * root. |
74 | 73 | * Add 1 to strlen for leading '/' of each level. |
75 | 74 | */ |
76 | 75 | |
77 | 76 | |
... | ... | @@ -84,19 +83,19 @@ |
84 | 83 | |
85 | 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 | 88 | --length; |
90 | 89 | for (parent = kobj; parent; parent = parent->parent) { |
91 | 90 | int cur = strlen(kobject_name(parent)); |
92 | 91 | /* back up enough to print this name with '/' */ |
93 | 92 | length -= cur; |
94 | - strncpy (path + length, kobject_name(parent), cur); | |
93 | + strncpy(path + length, kobject_name(parent), cur); | |
95 | 94 | *(path + --length) = '/'; |
96 | 95 | } |
97 | 96 | |
98 | 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 @@ |
148 | 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 | 152 | if (!kobj) |
154 | 153 | return; |
... | ... | @@ -160,7 +159,7 @@ |
160 | 159 | static int kobject_add_internal(struct kobject *kobj) |
161 | 160 | { |
162 | 161 | int error = 0; |
163 | - struct kobject * parent; | |
162 | + struct kobject *parent; | |
164 | 163 | |
165 | 164 | if (!kobj) |
166 | 165 | return -ENOENT; |
... | ... | @@ -185,7 +184,7 @@ |
185 | 184 | pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n", |
186 | 185 | kobject_name(kobj), kobj, __FUNCTION__, |
187 | 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 | 189 | error = create_dir(kobj); |
191 | 190 | if (error) { |
192 | 191 | |
... | ... | @@ -399,12 +398,11 @@ |
399 | 398 | EXPORT_SYMBOL_GPL(kobject_init_and_add); |
400 | 399 | |
401 | 400 | /** |
402 | - * kobject_rename - change the name of an object | |
403 | - * @kobj: object in question. | |
404 | - * @new_name: object's new name | |
401 | + * kobject_rename - change the name of an object | |
402 | + * @kobj: object in question. | |
403 | + * @new_name: object's new name | |
405 | 404 | */ |
406 | - | |
407 | -int kobject_rename(struct kobject * kobj, const char *new_name) | |
405 | +int kobject_rename(struct kobject *kobj, const char *new_name) | |
408 | 406 | { |
409 | 407 | int error = 0; |
410 | 408 | const char *devpath = NULL; |
411 | 409 | |
... | ... | @@ -461,11 +459,10 @@ |
461 | 459 | } |
462 | 460 | |
463 | 461 | /** |
464 | - * kobject_move - move object to another parent | |
465 | - * @kobj: object in question. | |
466 | - * @new_parent: object's new parent (can be NULL) | |
462 | + * kobject_move - move object to another parent | |
463 | + * @kobj: object in question. | |
464 | + * @new_parent: object's new parent (can be NULL) | |
467 | 465 | */ |
468 | - | |
469 | 466 | int kobject_move(struct kobject *kobj, struct kobject *new_parent) |
470 | 467 | { |
471 | 468 | int error; |
472 | 469 | |
... | ... | @@ -513,11 +510,10 @@ |
513 | 510 | } |
514 | 511 | |
515 | 512 | /** |
516 | - * kobject_del - unlink kobject from hierarchy. | |
517 | - * @kobj: object. | |
513 | + * kobject_del - unlink kobject from hierarchy. | |
514 | + * @kobj: object. | |
518 | 515 | */ |
519 | - | |
520 | -void kobject_del(struct kobject * kobj) | |
516 | +void kobject_del(struct kobject *kobj) | |
521 | 517 | { |
522 | 518 | if (!kobj) |
523 | 519 | return; |
524 | 520 | |
... | ... | @@ -530,11 +526,10 @@ |
530 | 526 | } |
531 | 527 | |
532 | 528 | /** |
533 | - * kobject_get - increment refcount for object. | |
534 | - * @kobj: object. | |
529 | + * kobject_get - increment refcount for object. | |
530 | + * @kobj: object. | |
535 | 531 | */ |
536 | - | |
537 | -struct kobject * kobject_get(struct kobject * kobj) | |
532 | +struct kobject *kobject_get(struct kobject *kobj) | |
538 | 533 | { |
539 | 534 | if (kobj) |
540 | 535 | kref_get(&kobj->kref); |
541 | 536 | |
542 | 537 | |
... | ... | @@ -591,12 +586,12 @@ |
591 | 586 | } |
592 | 587 | |
593 | 588 | /** |
594 | - * kobject_put - decrement refcount for object. | |
595 | - * @kobj: object. | |
589 | + * kobject_put - decrement refcount for 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 | 596 | if (kobj) |
602 | 597 | kref_put(&kobj->kref, kobject_release); |
603 | 598 | |
... | ... | @@ -670,11 +665,10 @@ |
670 | 665 | EXPORT_SYMBOL_GPL(kobject_create_and_add); |
671 | 666 | |
672 | 667 | /** |
673 | - * kset_init - initialize a kset for use | |
674 | - * @k: kset | |
668 | + * kset_init - initialize a kset for use | |
669 | + * @k: kset | |
675 | 670 | */ |
676 | - | |
677 | -void kset_init(struct kset * k) | |
671 | +void kset_init(struct kset *k) | |
678 | 672 | { |
679 | 673 | kobject_init_internal(&k->kobj); |
680 | 674 | INIT_LIST_HEAD(&k->list); |
681 | 675 | |
... | ... | @@ -712,11 +706,10 @@ |
712 | 706 | }; |
713 | 707 | |
714 | 708 | /** |
715 | - * kset_register - initialize and add a kset. | |
716 | - * @k: kset. | |
709 | + * kset_register - initialize and add a kset. | |
710 | + * @k: kset. | |
717 | 711 | */ |
718 | - | |
719 | -int kset_register(struct kset * k) | |
712 | +int kset_register(struct kset *k) | |
720 | 713 | { |
721 | 714 | int err; |
722 | 715 | |
723 | 716 | |
724 | 717 | |
725 | 718 | |
726 | 719 | |
727 | 720 | |
728 | 721 | |
729 | 722 | |
730 | 723 | |
... | ... | @@ -731,39 +724,35 @@ |
731 | 724 | return 0; |
732 | 725 | } |
733 | 726 | |
734 | - | |
735 | 727 | /** |
736 | - * kset_unregister - remove a kset. | |
737 | - * @k: kset. | |
728 | + * kset_unregister - remove a kset. | |
729 | + * @k: kset. | |
738 | 730 | */ |
739 | - | |
740 | -void kset_unregister(struct kset * k) | |
731 | +void kset_unregister(struct kset *k) | |
741 | 732 | { |
742 | 733 | if (!k) |
743 | 734 | return; |
744 | 735 | kobject_put(&k->kobj); |
745 | 736 | } |
746 | 737 | |
747 | - | |
748 | 738 | /** |
749 | - * kset_find_obj - search for object in kset. | |
750 | - * @kset: kset we're looking in. | |
751 | - * @name: object's name. | |
739 | + * kset_find_obj - search for object in kset. | |
740 | + * @kset: kset we're looking in. | |
741 | + * @name: object's name. | |
752 | 742 | * |
753 | - * Lock kset via @kset->subsys, and iterate over @kset->list, | |
754 | - * looking for a matching kobject. If matching object is found | |
755 | - * take a reference and return the object. | |
743 | + * Lock kset via @kset->subsys, and iterate over @kset->list, | |
744 | + * looking for a matching kobject. If matching object is found | |
745 | + * take a reference and return the object. | |
756 | 746 | */ |
757 | - | |
758 | -struct kobject * kset_find_obj(struct kset * kset, const char * name) | |
747 | +struct kobject *kset_find_obj(struct kset *kset, const char *name) | |
759 | 748 | { |
760 | - struct list_head * entry; | |
761 | - struct kobject * ret = NULL; | |
749 | + struct list_head *entry; | |
750 | + struct kobject *ret = NULL; | |
762 | 751 | |
763 | 752 | spin_lock(&kset->list_lock); |
764 | - list_for_each(entry,&kset->list) { | |
765 | - struct kobject * k = to_kobj(entry); | |
766 | - if (kobject_name(k) && !strcmp(kobject_name(k),name)) { | |
753 | + list_for_each(entry, &kset->list) { | |
754 | + struct kobject *k = to_kobj(entry); | |
755 | + if (kobject_name(k) && !strcmp(kobject_name(k), name)) { | |
767 | 756 | ret = kobject_get(k); |
768 | 757 | break; |
769 | 758 | } |
lib/kobject_uevent.c
... | ... | @@ -238,11 +238,12 @@ |
238 | 238 | retval = add_uevent_var(env, "HOME=/"); |
239 | 239 | if (retval) |
240 | 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 | 243 | if (retval) |
243 | 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 | 249 | exit: |
... | ... | @@ -250,7 +251,6 @@ |
250 | 251 | kfree(env); |
251 | 252 | return retval; |
252 | 253 | } |
253 | - | |
254 | 254 | EXPORT_SYMBOL_GPL(kobject_uevent_env); |
255 | 255 | |
256 | 256 | /** |
... | ... | @@ -266,7 +266,6 @@ |
266 | 266 | { |
267 | 267 | return kobject_uevent_env(kobj, action, NULL); |
268 | 268 | } |
269 | - | |
270 | 269 | EXPORT_SYMBOL_GPL(kobject_uevent); |
271 | 270 | |
272 | 271 | /** |