Skip to content

Commit

Permalink
kobject: modify kobject_get_path() to take a const *
Browse files Browse the repository at this point in the history
kobject_get_path() does not modify the kobject passed to it, so make the
pointer constant.

Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Link: https://lore.kernel.org/r/20221001165315.2690141-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Greg Kroah-Hartman committed Oct 22, 2022
1 parent 92b5784 commit 33a0a1e
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/linux/kobject.h
Original file line number Diff line number Diff line change
@@ -115,7 +115,7 @@ extern void kobject_put(struct kobject *kobj);
extern const void *kobject_namespace(struct kobject *kobj);
extern void kobject_get_ownership(struct kobject *kobj,
kuid_t *uid, kgid_t *gid);
extern char *kobject_get_path(struct kobject *kobj, gfp_t flag);
extern char *kobject_get_path(const struct kobject *kobj, gfp_t flag);

struct kobj_type {
void (*release)(struct kobject *kobj);
10 changes: 5 additions & 5 deletions lib/kobject.c
Original file line number Diff line number Diff line change
@@ -94,10 +94,10 @@ static int create_dir(struct kobject *kobj)
return 0;
}

static int get_kobj_path_length(struct kobject *kobj)
static int get_kobj_path_length(const struct kobject *kobj)
{
int length = 1;
struct kobject *parent = kobj;
const struct kobject *parent = kobj;

/* walk up the ancestors until we hit the one pointing to the
* root.
@@ -112,9 +112,9 @@ static int get_kobj_path_length(struct kobject *kobj)
return length;
}

static void fill_kobj_path(struct kobject *kobj, char *path, int length)
static void fill_kobj_path(const struct kobject *kobj, char *path, int length)
{
struct kobject *parent;
const struct kobject *parent;

--length;
for (parent = kobj; parent; parent = parent->parent) {
@@ -136,7 +136,7 @@ static void fill_kobj_path(struct kobject *kobj, char *path, int length)
*
* Return: The newly allocated memory, caller must free with kfree().
*/
char *kobject_get_path(struct kobject *kobj, gfp_t gfp_mask)
char *kobject_get_path(const struct kobject *kobj, gfp_t gfp_mask)
{
char *path;
int len;

0 comments on commit 33a0a1e

Please sign in to comment.