aboutsummaryrefslogtreecommitdiffstats
path: root/net/phonet
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2009-11-29 10:46:12 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-01 19:15:57 -0500
commitd2b3eb630767f0b0ae21566b1b88cb512f40c647 (patch)
treedf07b861166cde19c2eecdfd0c87f39ca7cc673f /net/phonet
parentaaab3405e03e91d0e8d30c9d327a2265a7121854 (diff)
net: Simplify phonet pernet operations.
Take advantage of the new pernet automatic storage management, and stop using compatibility network namespace functions. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/phonet')
-rw-r--r--net/phonet/pn_dev.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index d87388c94b00..bc4a33bf2d3d 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -313,19 +313,14 @@ static struct notifier_block phonet_device_notifier = {
313/* Per-namespace Phonet devices handling */ 313/* Per-namespace Phonet devices handling */
314static int phonet_init_net(struct net *net) 314static int phonet_init_net(struct net *net)
315{ 315{
316 struct phonet_net *pnn = kzalloc(sizeof(*pnn), GFP_KERNEL); 316 struct phonet_net *pnn = net_generic(net, phonet_net_id);
317 if (!pnn)
318 return -ENOMEM;
319 317
320 if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops)) { 318 if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops))
321 kfree(pnn);
322 return -ENOMEM; 319 return -ENOMEM;
323 }
324 320
325 INIT_LIST_HEAD(&pnn->pndevs.list); 321 INIT_LIST_HEAD(&pnn->pndevs.list);
326 mutex_init(&pnn->pndevs.lock); 322 mutex_init(&pnn->pndevs.lock);
327 mutex_init(&pnn->routes.lock); 323 mutex_init(&pnn->routes.lock);
328 net_assign_generic(net, phonet_net_id, pnn);
329 return 0; 324 return 0;
330} 325}
331 326
@@ -349,18 +344,19 @@ static void phonet_exit_net(struct net *net)
349 rtnl_unlock(); 344 rtnl_unlock();
350 345
351 proc_net_remove(net, "phonet"); 346 proc_net_remove(net, "phonet");
352 kfree(pnn);
353} 347}
354 348
355static struct pernet_operations phonet_net_ops = { 349static struct pernet_operations phonet_net_ops = {
356 .init = phonet_init_net, 350 .init = phonet_init_net,
357 .exit = phonet_exit_net, 351 .exit = phonet_exit_net,
352 .id = &phonet_net_id,
353 .size = sizeof(struct phonet_net),
358}; 354};
359 355
360/* Initialize Phonet devices list */ 356/* Initialize Phonet devices list */
361int __init phonet_device_init(void) 357int __init phonet_device_init(void)
362{ 358{
363 int err = register_pernet_gen_device(&phonet_net_id, &phonet_net_ops); 359 int err = register_pernet_device(&phonet_net_ops);
364 if (err) 360 if (err)
365 return err; 361 return err;
366 362
@@ -375,7 +371,7 @@ void phonet_device_exit(void)
375{ 371{
376 rtnl_unregister_all(PF_PHONET); 372 rtnl_unregister_all(PF_PHONET);
377 unregister_netdevice_notifier(&phonet_device_notifier); 373 unregister_netdevice_notifier(&phonet_device_notifier);
378 unregister_pernet_gen_device(phonet_net_id, &phonet_net_ops); 374 unregister_pernet_device(&phonet_net_ops);
379} 375}
380 376
381int phonet_route_add(struct net_device *dev, u8 daddr) 377int phonet_route_add(struct net_device *dev, u8 daddr)