Skip to content

Commit ca5387e

Browse files
committed
Merge tag 'configfs-5.10' of git://git.infradead.org/users/hch/configfs
Pull configfs updates from Christoph Hellwig: "Various cleanups for the configfs samples (Bartosz Golaszewski)" * tag 'configfs-5.10' of git://git.infradead.org/users/hch/configfs: samples: configfs: prefer pr_err() over bare printk(KERN_ERR samples: configfs: don't use spaces before tabs samples: configfs: consolidate local variables of the same type samples: configfs: don't reinitialize variables which are already zeroed samples: configfs: replace simple_strtoul() with kstrtoint() samples: configfs: fix alignment in item struct samples: configfs: drop unnecessary ternary operators samples: configfs: remove redundant newlines MAINTAINERS: add the sample directory to the configfs entry
2 parents 5a32c34 + 76ecfcb commit ca5387e

File tree

2 files changed

+20
-40
lines changed

2 files changed

+20
-40
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4415,6 +4415,7 @@ S: Supported
44154415
T: git git://git.infradead.org/users/hch/configfs.git
44164416
F: fs/configfs/
44174417
F: include/linux/configfs.h
4418+
F: samples/configfs/
44184419

44194420
CONSOLE SUBSYSTEM
44204421
M: Greg Kroah-Hartman <[email protected]>

samples/configfs/configfs_sample.c

Lines changed: 19 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@
77
* macros defined by configfs.h
88
*
99
* Based on sysfs:
10-
* sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel
10+
* sysfs is Copyright (C) 2001, 2002, 2003 Patrick Mochel
1111
*
1212
* configfs Copyright (C) 2005 Oracle. All rights reserved.
1313
*/
1414

1515
#include <linux/init.h>
16+
#include <linux/kernel.h>
1617
#include <linux/module.h>
1718
#include <linux/slab.h>
18-
1919
#include <linux/configfs.h>
2020

21-
22-
2321
/*
2422
* 01-childless
2523
*
@@ -40,8 +38,8 @@ struct childless {
4038

4139
static inline struct childless *to_childless(struct config_item *item)
4240
{
43-
return item ? container_of(to_configfs_subsystem(to_config_group(item)),
44-
struct childless, subsys) : NULL;
41+
return container_of(to_configfs_subsystem(to_config_group(item)),
42+
struct childless, subsys);
4543
}
4644

4745
static ssize_t childless_showme_show(struct config_item *item, char *page)
@@ -64,17 +62,11 @@ static ssize_t childless_storeme_store(struct config_item *item,
6462
const char *page, size_t count)
6563
{
6664
struct childless *childless = to_childless(item);
67-
unsigned long tmp;
68-
char *p = (char *) page;
69-
70-
tmp = simple_strtoul(p, &p, 10);
71-
if (!p || (*p && (*p != '\n')))
72-
return -EINVAL;
73-
74-
if (tmp > INT_MAX)
75-
return -ERANGE;
65+
int ret;
7666

77-
childless->storeme = tmp;
67+
ret = kstrtoint(page, 10, &childless->storeme);
68+
if (ret)
69+
return ret;
7870

7971
return count;
8072
}
@@ -117,7 +109,6 @@ static struct childless childless_subsys = {
117109
},
118110
};
119111

120-
121112
/* ----------------------------------------------------------------- */
122113

123114
/*
@@ -136,7 +127,7 @@ struct simple_child {
136127

137128
static inline struct simple_child *to_simple_child(struct config_item *item)
138129
{
139-
return item ? container_of(item, struct simple_child, item) : NULL;
130+
return container_of(item, struct simple_child, item);
140131
}
141132

142133
static ssize_t simple_child_storeme_show(struct config_item *item, char *page)
@@ -148,17 +139,11 @@ static ssize_t simple_child_storeme_store(struct config_item *item,
148139
const char *page, size_t count)
149140
{
150141
struct simple_child *simple_child = to_simple_child(item);
151-
unsigned long tmp;
152-
char *p = (char *) page;
153-
154-
tmp = simple_strtoul(p, &p, 10);
155-
if (!p || (*p && (*p != '\n')))
156-
return -EINVAL;
157-
158-
if (tmp > INT_MAX)
159-
return -ERANGE;
142+
int ret;
160143

161-
simple_child->storeme = tmp;
144+
ret = kstrtoint(page, 10, &simple_child->storeme);
145+
if (ret)
146+
return ret;
162147

163148
return count;
164149
}
@@ -176,7 +161,7 @@ static void simple_child_release(struct config_item *item)
176161
}
177162

178163
static struct configfs_item_operations simple_child_item_ops = {
179-
.release = simple_child_release,
164+
.release = simple_child_release,
180165
};
181166

182167
static const struct config_item_type simple_child_type = {
@@ -185,15 +170,14 @@ static const struct config_item_type simple_child_type = {
185170
.ct_owner = THIS_MODULE,
186171
};
187172

188-
189173
struct simple_children {
190174
struct config_group group;
191175
};
192176

193177
static inline struct simple_children *to_simple_children(struct config_item *item)
194178
{
195-
return item ? container_of(to_config_group(item),
196-
struct simple_children, group) : NULL;
179+
return container_of(to_config_group(item),
180+
struct simple_children, group);
197181
}
198182

199183
static struct config_item *simple_children_make_item(struct config_group *group,
@@ -208,8 +192,6 @@ static struct config_item *simple_children_make_item(struct config_group *group,
208192
config_item_init_type_name(&simple_child->item, name,
209193
&simple_child_type);
210194

211-
simple_child->storeme = 0;
212-
213195
return &simple_child->item;
214196
}
215197

@@ -263,7 +245,6 @@ static struct configfs_subsystem simple_children_subsys = {
263245
},
264246
};
265247

266-
267248
/* ----------------------------------------------------------------- */
268249

269250
/*
@@ -350,9 +331,8 @@ static struct configfs_subsystem *example_subsys[] = {
350331

351332
static int __init configfs_example_init(void)
352333
{
353-
int ret;
354-
int i;
355334
struct configfs_subsystem *subsys;
335+
int ret, i;
356336

357337
for (i = 0; example_subsys[i]; i++) {
358338
subsys = example_subsys[i];
@@ -361,9 +341,8 @@ static int __init configfs_example_init(void)
361341
mutex_init(&subsys->su_mutex);
362342
ret = configfs_register_subsystem(subsys);
363343
if (ret) {
364-
printk(KERN_ERR "Error %d while registering subsystem %s\n",
365-
ret,
366-
subsys->su_group.cg_item.ci_namebuf);
344+
pr_err("Error %d while registering subsystem %s\n",
345+
ret, subsys->su_group.cg_item.ci_namebuf);
367346
goto out_unregister;
368347
}
369348
}

0 commit comments

Comments
 (0)