Commit e374a2bf authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 79a6ee42
...@@ -18,58 +18,57 @@ ...@@ -18,58 +18,57 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/slab.h> #include <linux/slab.h>
/** /*
* populate_dir - populate directory with attributes. * populate_dir - populate directory with attributes.
* @kobj: object we're working on. * @kobj: object we're working on.
*
* Most subsystems have a set of default attributes that
* are associated with an object that registers with them.
* This is a helper called during object registration that
* loops through the default attributes of the subsystem
* and creates attributes files for them in sysfs.
* *
* Most subsystems have a set of default attributes that are associated
* with an object that registers with them. This is a helper called during
* object registration that loops through the default attributes of the
* subsystem and creates attributes files for them in sysfs.
*/ */
static int populate_dir(struct kobject *kobj)
static int populate_dir(struct kobject * kobj)
{ {
struct kobj_type * t = get_ktype(kobj); struct kobj_type *t = get_ktype(kobj);
struct attribute * attr; struct attribute *attr;
int error = 0; int error = 0;
int i; int i;
if (t && t->default_attrs) { if (t && t->default_attrs) {
for (i = 0; (attr = t->default_attrs[i]) != NULL; i++) { for (i = 0; (attr = t->default_attrs[i]) != NULL; i++) {
if ((error = sysfs_create_file(kobj,attr))) error = sysfs_create_file(kobj, attr);
if (error)
break; break;
} }
} }
return error; return error;
} }
static int create_dir(struct kobject * kobj) static int create_dir(struct kobject *kobj)
{ {
int error = 0; int error = 0;
if (kobject_name(kobj)) { if (kobject_name(kobj)) {
error = sysfs_create_dir(kobj); error = sysfs_create_dir(kobj);
if (!error) { if (!error) {
if ((error = populate_dir(kobj))) error = populate_dir(kobj);
if (error)
sysfs_remove_dir(kobj); sysfs_remove_dir(kobj);
} }
} }
return error; return error;
} }
static inline struct kobject * to_kobj(struct list_head * entry) static inline struct kobject *to_kobj(struct list_head *entry)
{ {
return container_of(entry,struct kobject,entry); return container_of(entry, struct kobject, entry);
} }
static int get_kobj_path_length(struct kobject *kobj) static int get_kobj_path_length(struct kobject *kobj)
{ {
int length = 1; int length = 1;
struct kobject * parent = kobj; struct kobject *parent = kobj;
/* walk up the ancestors until we hit the one pointing to the /* walk up the ancestors until we hit the one pointing to the
* root. * root.
* Add 1 to strlen for leading '/' of each level. * Add 1 to strlen for leading '/' of each level.
*/ */
...@@ -84,19 +83,19 @@ static int get_kobj_path_length(struct kobject *kobj) ...@@ -84,19 +83,19 @@ static int get_kobj_path_length(struct kobject *kobj)
static void fill_kobj_path(struct kobject *kobj, char *path, int length) static void fill_kobj_path(struct kobject *kobj, char *path, int length)
{ {
struct kobject * parent; struct kobject *parent;
--length; --length;
for (parent = kobj; parent; parent = parent->parent) { for (parent = kobj; parent; parent = parent->parent) {
int cur = strlen(kobject_name(parent)); int cur = strlen(kobject_name(parent));
/* back up enough to print this name with '/' */ /* back up enough to print this name with '/' */
length -= cur; length -= cur;
strncpy (path + length, kobject_name(parent), cur); strncpy(path + length, kobject_name(parent), cur);
*(path + --length) = '/'; *(path + --length) = '/';
} }
pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj), pr_debug("kobject: '%s' (%p): %s: path = '%s'\n", kobject_name(kobj),
kobj, __FUNCTION__,path); kobj, __FUNCTION__, path);
} }
/** /**
...@@ -148,7 +147,7 @@ static void kobj_kset_leave(struct kobject *kobj) ...@@ -148,7 +147,7 @@ static void kobj_kset_leave(struct kobject *kobj)
kset_put(kobj->kset); kset_put(kobj->kset);
} }
static void kobject_init_internal(struct kobject * kobj) static void kobject_init_internal(struct kobject *kobj)
{ {
if (!kobj) if (!kobj)
return; return;
...@@ -160,7 +159,7 @@ static void kobject_init_internal(struct kobject * kobj) ...@@ -160,7 +159,7 @@ static void kobject_init_internal(struct kobject * kobj)
static int kobject_add_internal(struct kobject *kobj) static int kobject_add_internal(struct kobject *kobj)
{ {
int error = 0; int error = 0;
struct kobject * parent; struct kobject *parent;
if (!kobj) if (!kobj)
return -ENOENT; return -ENOENT;
...@@ -185,7 +184,7 @@ static int kobject_add_internal(struct kobject *kobj) ...@@ -185,7 +184,7 @@ static int kobject_add_internal(struct kobject *kobj)
pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n", pr_debug("kobject: '%s' (%p): %s: parent: '%s', set: '%s'\n",
kobject_name(kobj), kobj, __FUNCTION__, kobject_name(kobj), kobj, __FUNCTION__,
parent ? kobject_name(parent) : "<NULL>", parent ? kobject_name(parent) : "<NULL>",
kobj->kset ? kobject_name(&kobj->kset->kobj) : "<NULL>" ); kobj->kset ? kobject_name(&kobj->kset->kobj) : "<NULL>");
error = create_dir(kobj); error = create_dir(kobj);
if (error) { if (error) {
...@@ -399,12 +398,11 @@ int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype, ...@@ -399,12 +398,11 @@ int kobject_init_and_add(struct kobject *kobj, struct kobj_type *ktype,
EXPORT_SYMBOL_GPL(kobject_init_and_add); EXPORT_SYMBOL_GPL(kobject_init_and_add);
/** /**
* kobject_rename - change the name of an object * kobject_rename - change the name of an object
* @kobj: object in question. * @kobj: object in question.
* @new_name: object's new name * @new_name: object's new name
*/ */
int kobject_rename(struct kobject *kobj, const char *new_name)
int kobject_rename(struct kobject * kobj, const char *new_name)
{ {
int error = 0; int error = 0;
const char *devpath = NULL; const char *devpath = NULL;
...@@ -461,11 +459,10 @@ int kobject_rename(struct kobject * kobj, const char *new_name) ...@@ -461,11 +459,10 @@ int kobject_rename(struct kobject * kobj, const char *new_name)
} }
/** /**
* kobject_move - move object to another parent * kobject_move - move object to another parent
* @kobj: object in question. * @kobj: object in question.
* @new_parent: object's new parent (can be NULL) * @new_parent: object's new parent (can be NULL)
*/ */
int kobject_move(struct kobject *kobj, struct kobject *new_parent) int kobject_move(struct kobject *kobj, struct kobject *new_parent)
{ {
int error; int error;
...@@ -513,11 +510,10 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent) ...@@ -513,11 +510,10 @@ int kobject_move(struct kobject *kobj, struct kobject *new_parent)
} }
/** /**
* kobject_del - unlink kobject from hierarchy. * kobject_del - unlink kobject from hierarchy.
* @kobj: object. * @kobj: object.
*/ */
void kobject_del(struct kobject *kobj)
void kobject_del(struct kobject * kobj)
{ {
if (!kobj) if (!kobj)
return; return;
...@@ -530,11 +526,10 @@ void kobject_del(struct kobject * kobj) ...@@ -530,11 +526,10 @@ void kobject_del(struct kobject * kobj)
} }
/** /**
* kobject_get - increment refcount for object. * kobject_get - increment refcount for object.
* @kobj: object. * @kobj: object.
*/ */
struct kobject *kobject_get(struct kobject *kobj)
struct kobject * kobject_get(struct kobject * kobj)
{ {
if (kobj) if (kobj)
kref_get(&kobj->kref); kref_get(&kobj->kref);
...@@ -591,12 +586,12 @@ static void kobject_release(struct kref *kref) ...@@ -591,12 +586,12 @@ static void kobject_release(struct kref *kref)
} }
/** /**
* kobject_put - decrement refcount for object. * kobject_put - decrement refcount for object.
* @kobj: object. * @kobj: object.
* *
* Decrement the refcount, and if 0, call kobject_cleanup(). * Decrement the refcount, and if 0, call kobject_cleanup().
*/ */
void kobject_put(struct kobject * kobj) void kobject_put(struct kobject *kobj)
{ {
if (kobj) if (kobj)
kref_put(&kobj->kref, kobject_release); kref_put(&kobj->kref, kobject_release);
...@@ -670,11 +665,10 @@ struct kobject *kobject_create_and_add(const char *name, struct kobject *parent) ...@@ -670,11 +665,10 @@ struct kobject *kobject_create_and_add(const char *name, struct kobject *parent)
EXPORT_SYMBOL_GPL(kobject_create_and_add); EXPORT_SYMBOL_GPL(kobject_create_and_add);
/** /**
* kset_init - initialize a kset for use * kset_init - initialize a kset for use
* @k: kset * @k: kset
*/ */
void kset_init(struct kset *k)
void kset_init(struct kset * k)
{ {
kobject_init_internal(&k->kobj); kobject_init_internal(&k->kobj);
INIT_LIST_HEAD(&k->list); INIT_LIST_HEAD(&k->list);
...@@ -712,11 +706,10 @@ struct sysfs_ops kobj_sysfs_ops = { ...@@ -712,11 +706,10 @@ struct sysfs_ops kobj_sysfs_ops = {
}; };
/** /**
* kset_register - initialize and add a kset. * kset_register - initialize and add a kset.
* @k: kset. * @k: kset.
*/ */
int kset_register(struct kset *k)
int kset_register(struct kset * k)
{ {
int err; int err;
...@@ -731,39 +724,35 @@ int kset_register(struct kset * k) ...@@ -731,39 +724,35 @@ int kset_register(struct kset * k)
return 0; return 0;
} }
/** /**
* kset_unregister - remove a kset. * kset_unregister - remove a kset.
* @k: kset. * @k: kset.
*/ */
void kset_unregister(struct kset *k)
void kset_unregister(struct kset * k)
{ {
if (!k) if (!k)
return; return;
kobject_put(&k->kobj); kobject_put(&k->kobj);
} }
/** /**
* kset_find_obj - search for object in kset. * kset_find_obj - search for object in kset.
* @kset: kset we're looking in. * @kset: kset we're looking in.
* @name: object's name. * @name: object's name.
* *
* Lock kset via @kset->subsys, and iterate over @kset->list, * Lock kset via @kset->subsys, and iterate over @kset->list,
* looking for a matching kobject. If matching object is found * looking for a matching kobject. If matching object is found
* take a reference and return the object. * take a reference and return the object.
*/ */
struct kobject *kset_find_obj(struct kset *kset, const char *name)
struct kobject * kset_find_obj(struct kset * kset, const char * name)
{ {
struct list_head * entry; struct list_head *entry;
struct kobject * ret = NULL; struct kobject *ret = NULL;
spin_lock(&kset->list_lock); spin_lock(&kset->list_lock);
list_for_each(entry,&kset->list) { list_for_each(entry, &kset->list) {
struct kobject * k = to_kobj(entry); struct kobject *k = to_kobj(entry);
if (kobject_name(k) && !strcmp(kobject_name(k),name)) { if (kobject_name(k) && !strcmp(kobject_name(k), name)) {
ret = kobject_get(k); ret = kobject_get(k);
break; break;
} }
......
...@@ -238,11 +238,12 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, ...@@ -238,11 +238,12 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
retval = add_uevent_var(env, "HOME=/"); retval = add_uevent_var(env, "HOME=/");
if (retval) if (retval)
goto exit; goto exit;
retval = add_uevent_var(env, "PATH=/sbin:/bin:/usr/sbin:/usr/bin"); retval = add_uevent_var(env,
"PATH=/sbin:/bin:/usr/sbin:/usr/bin");
if (retval) if (retval)
goto exit; goto exit;
call_usermodehelper (argv[0], argv, env->envp, UMH_WAIT_EXEC); call_usermodehelper(argv[0], argv, env->envp, UMH_WAIT_EXEC);
} }
exit: exit:
...@@ -250,7 +251,6 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action, ...@@ -250,7 +251,6 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
kfree(env); kfree(env);
return retval; return retval;
} }
EXPORT_SYMBOL_GPL(kobject_uevent_env); EXPORT_SYMBOL_GPL(kobject_uevent_env);
/** /**
...@@ -266,7 +266,6 @@ int kobject_uevent(struct kobject *kobj, enum kobject_action action) ...@@ -266,7 +266,6 @@ int kobject_uevent(struct kobject *kobj, enum kobject_action action)
{ {
return kobject_uevent_env(kobj, action, NULL); return kobject_uevent_env(kobj, action, NULL);
} }
EXPORT_SYMBOL_GPL(kobject_uevent); EXPORT_SYMBOL_GPL(kobject_uevent);
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment