Commit f3b4f3c6 authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Greg Kroah-Hartman

[PATCH] Make kobject's name be const char *

kobject: make kobject's name const char * since users should not
	 attempt to change it (except by calling kobject_rename).
Signed-off-by: default avatarDmitry Torokhov <dtor@mail.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent e3a15db2
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
extern u64 hotplug_seqnum; extern u64 hotplug_seqnum;
struct kobject { struct kobject {
char * k_name; const char * k_name;
char name[KOBJ_NAME_LEN]; char name[KOBJ_NAME_LEN];
struct kref kref; struct kref kref;
struct list_head entry; struct list_head entry;
...@@ -46,7 +46,7 @@ struct kobject { ...@@ -46,7 +46,7 @@ struct kobject {
extern int kobject_set_name(struct kobject *, const char *, ...) extern int kobject_set_name(struct kobject *, const char *, ...)
__attribute__((format(printf,2,3))); __attribute__((format(printf,2,3)));
static inline char * kobject_name(struct kobject * kobj) static inline const char * kobject_name(const struct kobject * kobj)
{ {
return kobj->k_name; return kobj->k_name;
} }
...@@ -57,7 +57,7 @@ extern void kobject_cleanup(struct kobject *); ...@@ -57,7 +57,7 @@ extern void kobject_cleanup(struct kobject *);
extern int kobject_add(struct kobject *); extern int kobject_add(struct kobject *);
extern void kobject_del(struct kobject *); extern void kobject_del(struct kobject *);
extern int kobject_rename(struct kobject *, char *new_name); extern int kobject_rename(struct kobject *, const char *new_name);
extern int kobject_register(struct kobject *); extern int kobject_register(struct kobject *);
extern void kobject_unregister(struct kobject *); extern void kobject_unregister(struct kobject *);
......
...@@ -279,7 +279,7 @@ EXPORT_SYMBOL(kobject_set_name); ...@@ -279,7 +279,7 @@ EXPORT_SYMBOL(kobject_set_name);
* @new_name: object's new name * @new_name: object's new name
*/ */
int kobject_rename(struct kobject * kobj, char *new_name) int kobject_rename(struct kobject * kobj, const char *new_name)
{ {
int error = 0; int error = 0;
......
...@@ -197,7 +197,7 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) ...@@ -197,7 +197,7 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
int i = 0; int i = 0;
int retval; int retval;
char *kobj_path = NULL; char *kobj_path = NULL;
char *name = NULL; const char *name = NULL;
char *action_string; char *action_string;
u64 seq; u64 seq;
struct kobject *top_kobj = kobj; struct kobject *top_kobj = kobj;
...@@ -249,7 +249,7 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action) ...@@ -249,7 +249,7 @@ void kobject_hotplug(struct kobject *kobj, enum kobject_action action)
name = kobject_name(&kset->kobj); name = kobject_name(&kset->kobj);
argv [0] = hotplug_path; argv [0] = hotplug_path;
argv [1] = name; argv [1] = (char *)name; /* won't be changed but 'const' has to go */
argv [2] = NULL; argv [2] = NULL;
/* minimal command environment */ /* minimal command environment */
......
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