summaryrefslogtreecommitdiffstats
path: root/net/atm
diff options
context:
space:
mode:
authorDenis V. Lunev <den@openvz.org>2008-01-10 03:52:35 -0800
committerDavid S. Miller <davem@davemloft.net>2008-01-28 15:01:36 -0800
commitae22120ad846399f6aa19c5b32f8d4c7bd068fd1 (patch)
tree578eb44774b29cbb740005d59d5d29115ccbc3ef /net/atm
parente5d69b9f4a6ce17f0d09595da45e37b870fee5ae (diff)
downloadlinux-ae22120ad846399f6aa19c5b32f8d4c7bd068fd1.tar.bz2
[ATM]: Simplify /proc/net/atm/arp opening
The iterator state->ns.neigh_sub_iter initialization is moved from arp_seq_open to clip_seq_start for convinience. This should not be a problem as the iterator will be used only after the seq_start callback. Signed-off-by: Denis V. Lunev <den@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/atm')
-rw-r--r--net/atm/clip.c42
1 files changed, 5 insertions, 37 deletions
diff --git a/net/atm/clip.c b/net/atm/clip.c
index df7d218a6827..45e08620c8ca 100644
--- a/net/atm/clip.c
+++ b/net/atm/clip.c
@@ -903,6 +903,8 @@ static void *clip_seq_sub_iter(struct neigh_seq_state *_state,
static void *clip_seq_start(struct seq_file *seq, loff_t * pos)
{
+ struct clip_seq_state *state = seq->private;
+ state->ns.neigh_sub_iter = clip_seq_sub_iter;
return neigh_seq_start(seq, pos, &clip_tbl, NEIGH_SEQ_NEIGH_ONLY);
}
@@ -932,49 +934,15 @@ static const struct seq_operations arp_seq_ops = {
static int arp_seq_open(struct inode *inode, struct file *file)
{
- struct clip_seq_state *state;
- struct seq_file *seq;
- int rc = -EAGAIN;
-
- state = kzalloc(sizeof(*state), GFP_KERNEL);
- if (!state) {
- rc = -ENOMEM;
- goto out_kfree;
- }
- state->ns.neigh_sub_iter = clip_seq_sub_iter;
-
- rc = seq_open(file, &arp_seq_ops);
- if (rc)
- goto out_kfree;
-
- seq = file->private_data;
- seq->private = state;
- state->ns.net = get_proc_net(inode);
- if (!state->ns.net) {
- seq_release_private(inode, file);
- rc = -ENXIO;
- }
-out:
- return rc;
-
-out_kfree:
- kfree(state);
- goto out;
-}
-
-static int arp_seq_release(struct inode *inode, struct file *file)
-{
- struct seq_file *seq = file->private_data;
- struct clip_seq_state *state = seq->private;
- put_net(state->ns.net);
- return seq_release_private(inode, file);
+ return seq_open_net(inode, file, &arp_seq_ops,
+ sizeof(struct clip_seq_state));
}
static const struct file_operations arp_seq_fops = {
.open = arp_seq_open,
.read = seq_read,
.llseek = seq_lseek,
- .release = arp_seq_release,
+ .release = seq_release_net,
.owner = THIS_MODULE
};
#endif