Skip to content

Commit

Permalink
configfs: make ci_type field, some pointers and function arguments const
Browse files Browse the repository at this point in the history
The ci_type field of the config_item structure do not modify the fields
of the config_item_type structure it points to. And the other pointers
initialized with ci_type do not modify the fields as well.
So, make the ci_type field and the pointers initialized with ci_type
as const.

Make the struct config_item_type *type function argument of functions
config_{item/group}_init_type_name const as the argument in both the
functions is only stored in the ci_type field of a config_item structure
which is now made const.
Make the argument of configfs_register_default_group const as it is
only passed to the argument of the function config_group_init_type_name
which is now const.

Signed-off-by: Bhumika Goyal <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
goyalbhumika authored and Christoph Hellwig committed Oct 19, 2017
1 parent 84c4367 commit aa29358
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions fs/configfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ static void detach_attrs(struct config_item * item)

static int populate_attrs(struct config_item *item)
{
struct config_item_type *t = item->ci_type;
const struct config_item_type *t = item->ci_type;
struct configfs_attribute *attr;
struct configfs_bin_attribute *bin_attr;
int error = 0;
Expand Down Expand Up @@ -901,7 +901,7 @@ static void configfs_detach_group(struct config_item *item)
static void client_disconnect_notify(struct config_item *parent_item,
struct config_item *item)
{
struct config_item_type *type;
const struct config_item_type *type;

type = parent_item->ci_type;
BUG_ON(!type);
Expand All @@ -920,7 +920,7 @@ static void client_disconnect_notify(struct config_item *parent_item,
static void client_drop_item(struct config_item *parent_item,
struct config_item *item)
{
struct config_item_type *type;
const struct config_item_type *type;

type = parent_item->ci_type;
BUG_ON(!type);
Expand Down Expand Up @@ -1260,7 +1260,7 @@ static int configfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
struct config_item *parent_item;
struct configfs_subsystem *subsys;
struct configfs_dirent *sd;
struct config_item_type *type;
const struct config_item_type *type;
struct module *subsys_owner = NULL, *new_item_owner = NULL;
char *name;

Expand Down Expand Up @@ -1810,7 +1810,7 @@ EXPORT_SYMBOL(configfs_unregister_group);
struct config_group *
configfs_register_default_group(struct config_group *parent_group,
const char *name,
struct config_item_type *item_type)
const struct config_item_type *item_type)
{
int ret;
struct config_group *group;
Expand Down
6 changes: 3 additions & 3 deletions fs/configfs/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ EXPORT_SYMBOL(config_item_set_name);

void config_item_init_type_name(struct config_item *item,
const char *name,
struct config_item_type *type)
const struct config_item_type *type)
{
config_item_set_name(item, "%s", name);
item->ci_type = type;
Expand All @@ -122,7 +122,7 @@ void config_item_init_type_name(struct config_item *item,
EXPORT_SYMBOL(config_item_init_type_name);

void config_group_init_type_name(struct config_group *group, const char *name,
struct config_item_type *type)
const struct config_item_type *type)
{
config_item_set_name(&group->cg_item, "%s", name);
group->cg_item.ci_type = type;
Expand All @@ -148,7 +148,7 @@ EXPORT_SYMBOL(config_item_get_unless_zero);

static void config_item_cleanup(struct config_item *item)
{
struct config_item_type *t = item->ci_type;
const struct config_item_type *t = item->ci_type;
struct config_group *s = item->ci_group;
struct config_item *parent = item->ci_parent;

Expand Down
4 changes: 2 additions & 2 deletions fs/configfs/symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ int configfs_symlink(struct inode *dir, struct dentry *dentry, const char *symna
struct configfs_dirent *sd;
struct config_item *parent_item;
struct config_item *target_item = NULL;
struct config_item_type *type;
const struct config_item_type *type;

sd = dentry->d_parent->d_fsdata;
/*
Expand Down Expand Up @@ -186,7 +186,7 @@ int configfs_unlink(struct inode *dir, struct dentry *dentry)
struct configfs_dirent *sd = dentry->d_fsdata;
struct configfs_symlink *sl;
struct config_item *parent_item;
struct config_item_type *type;
const struct config_item_type *type;
int ret;

ret = -EPERM; /* What lack-of-symlink returns */
Expand Down
8 changes: 4 additions & 4 deletions include/linux/configfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct config_item {
struct list_head ci_entry;
struct config_item *ci_parent;
struct config_group *ci_group;
struct config_item_type *ci_type;
const struct config_item_type *ci_type;
struct dentry *ci_dentry;
};

Expand All @@ -72,7 +72,7 @@ static inline char *config_item_name(struct config_item * item)

extern void config_item_init_type_name(struct config_item *item,
const char *name,
struct config_item_type *type);
const struct config_item_type *type);

extern struct config_item *config_item_get(struct config_item *);
extern struct config_item *config_item_get_unless_zero(struct config_item *);
Expand Down Expand Up @@ -101,7 +101,7 @@ struct config_group {
extern void config_group_init(struct config_group *group);
extern void config_group_init_type_name(struct config_group *group,
const char *name,
struct config_item_type *type);
const struct config_item_type *type);

static inline struct config_group *to_config_group(struct config_item *item)
{
Expand Down Expand Up @@ -261,7 +261,7 @@ void configfs_remove_default_groups(struct config_group *group);
struct config_group *
configfs_register_default_group(struct config_group *parent_group,
const char *name,
struct config_item_type *item_type);
const struct config_item_type *item_type);
void configfs_unregister_default_group(struct config_group *group);

/* These functions can sleep and can alloc with GFP_KERNEL */
Expand Down

0 comments on commit aa29358

Please sign in to comment.