diff options
author | Li Zefan <lizefan@huawei.com> | 2013-07-31 05:36:25 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2013-07-31 06:20:18 -0400 |
commit | e0798ce27346edb8aa369b5b39af5a47fdf2b25c (patch) | |
tree | 134ce9cfb84ea9ce96a3d7fc667c3247df837f68 /kernel/cgroup.c | |
parent | 2a4ac63333584b2791986cf2270f5ba9a4b97606 (diff) |
cgroup: remove struct cgroup_seqfile_state
We can use struct cfent instead.
v2:
- remove cgroup_seqfile_release().
Signed-off-by: Li Zefan <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 45 |
1 files changed, 13 insertions, 32 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 41b559f51502..ed2104304833 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -2397,11 +2397,6 @@ static ssize_t cgroup_file_read(struct file *file, char __user *buf, | |||
2397 | * supports string->u64 maps, but can be extended in future. | 2397 | * supports string->u64 maps, but can be extended in future. |
2398 | */ | 2398 | */ |
2399 | 2399 | ||
2400 | struct cgroup_seqfile_state { | ||
2401 | struct cftype *cft; | ||
2402 | struct cgroup *cgroup; | ||
2403 | }; | ||
2404 | |||
2405 | static int cgroup_map_add(struct cgroup_map_cb *cb, const char *key, u64 value) | 2400 | static int cgroup_map_add(struct cgroup_map_cb *cb, const char *key, u64 value) |
2406 | { | 2401 | { |
2407 | struct seq_file *sf = cb->state; | 2402 | struct seq_file *sf = cb->state; |
@@ -2410,59 +2405,45 @@ static int cgroup_map_add(struct cgroup_map_cb *cb, const char *key, u64 value) | |||
2410 | 2405 | ||
2411 | static int cgroup_seqfile_show(struct seq_file *m, void *arg) | 2406 | static int cgroup_seqfile_show(struct seq_file *m, void *arg) |
2412 | { | 2407 | { |
2413 | struct cgroup_seqfile_state *state = m->private; | 2408 | struct cfent *cfe = m->private; |
2414 | struct cftype *cft = state->cft; | 2409 | struct cftype *cft = cfe->type; |
2410 | struct cgroup *cgrp = __d_cgrp(cfe->dentry->d_parent); | ||
2411 | |||
2415 | if (cft->read_map) { | 2412 | if (cft->read_map) { |
2416 | struct cgroup_map_cb cb = { | 2413 | struct cgroup_map_cb cb = { |
2417 | .fill = cgroup_map_add, | 2414 | .fill = cgroup_map_add, |
2418 | .state = m, | 2415 | .state = m, |
2419 | }; | 2416 | }; |
2420 | return cft->read_map(state->cgroup, cft, &cb); | 2417 | return cft->read_map(cgrp, cft, &cb); |
2421 | } | 2418 | } |
2422 | return cft->read_seq_string(state->cgroup, cft, m); | 2419 | return cft->read_seq_string(cgrp, cft, m); |
2423 | } | ||
2424 | |||
2425 | static int cgroup_seqfile_release(struct inode *inode, struct file *file) | ||
2426 | { | ||
2427 | struct seq_file *seq = file->private_data; | ||
2428 | kfree(seq->private); | ||
2429 | return single_release(inode, file); | ||
2430 | } | 2420 | } |
2431 | 2421 | ||
2432 | static const struct file_operations cgroup_seqfile_operations = { | 2422 | static const struct file_operations cgroup_seqfile_operations = { |
2433 | .read = seq_read, | 2423 | .read = seq_read, |
2434 | .write = cgroup_file_write, | 2424 | .write = cgroup_file_write, |
2435 | .llseek = seq_lseek, | 2425 | .llseek = seq_lseek, |
2436 | .release = cgroup_seqfile_release, | 2426 | .release = single_release, |
2437 | }; | 2427 | }; |
2438 | 2428 | ||
2439 | static int cgroup_file_open(struct inode *inode, struct file *file) | 2429 | static int cgroup_file_open(struct inode *inode, struct file *file) |
2440 | { | 2430 | { |
2441 | int err; | 2431 | int err; |
2432 | struct cfent *cfe; | ||
2442 | struct cftype *cft; | 2433 | struct cftype *cft; |
2443 | 2434 | ||
2444 | err = generic_file_open(inode, file); | 2435 | err = generic_file_open(inode, file); |
2445 | if (err) | 2436 | if (err) |
2446 | return err; | 2437 | return err; |
2447 | cft = __d_cft(file->f_dentry); | 2438 | cfe = __d_cfe(file->f_dentry); |
2439 | cft = cfe->type; | ||
2448 | 2440 | ||
2449 | if (cft->read_map || cft->read_seq_string) { | 2441 | if (cft->read_map || cft->read_seq_string) { |
2450 | struct cgroup_seqfile_state *state; | ||
2451 | |||
2452 | state = kzalloc(sizeof(*state), GFP_USER); | ||
2453 | if (!state) | ||
2454 | return -ENOMEM; | ||
2455 | |||
2456 | state->cft = cft; | ||
2457 | state->cgroup = __d_cgrp(file->f_dentry->d_parent); | ||
2458 | file->f_op = &cgroup_seqfile_operations; | 2442 | file->f_op = &cgroup_seqfile_operations; |
2459 | err = single_open(file, cgroup_seqfile_show, state); | 2443 | err = single_open(file, cgroup_seqfile_show, cfe); |
2460 | if (err < 0) | 2444 | } else if (cft->open) { |
2461 | kfree(state); | ||
2462 | } else if (cft->open) | ||
2463 | err = cft->open(inode, file); | 2445 | err = cft->open(inode, file); |
2464 | else | 2446 | } |
2465 | err = 0; | ||
2466 | 2447 | ||
2467 | return err; | 2448 | return err; |
2468 | } | 2449 | } |