aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2010-04-25 23:41:00 -0400
committerDavid S. Miller <davem@davemloft.net>2010-04-26 14:18:44 -0400
commit0db3f0f49a99db33a411af1c4352839c0296eff3 (patch)
tree41312a7ead1039d2919b1946b95949ca895766d7
parentb3c981d2bbbe889125169bd0bb482e64d3c028a1 (diff)
phonet: use phonet_pernet instead of directly net_generic
As in for example pppoe introduce phonet_pernet and use it instead of calling net_generic directly. Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/phonet/pn_dev.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index 9b4ced6e0968..c33da6576942 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -46,9 +46,16 @@ struct phonet_net {
46 46
47int phonet_net_id __read_mostly; 47int phonet_net_id __read_mostly;
48 48
49static struct phonet_net *phonet_pernet(struct net *net)
50{
51 BUG_ON(!net);
52
53 return net_generic(net, phonet_net_id);
54}
55
49struct phonet_device_list *phonet_device_list(struct net *net) 56struct phonet_device_list *phonet_device_list(struct net *net)
50{ 57{
51 struct phonet_net *pnn = net_generic(net, phonet_net_id); 58 struct phonet_net *pnn = phonet_pernet(net);
52 return &pnn->pndevs; 59 return &pnn->pndevs;
53} 60}
54 61
@@ -261,7 +268,7 @@ static int phonet_device_autoconf(struct net_device *dev)
261 268
262static void phonet_route_autodel(struct net_device *dev) 269static void phonet_route_autodel(struct net_device *dev)
263{ 270{
264 struct phonet_net *pnn = net_generic(dev_net(dev), phonet_net_id); 271 struct phonet_net *pnn = phonet_pernet(dev_net(dev));
265 unsigned i; 272 unsigned i;
266 DECLARE_BITMAP(deleted, 64); 273 DECLARE_BITMAP(deleted, 64);
267 274
@@ -313,7 +320,7 @@ static struct notifier_block phonet_device_notifier = {
313/* Per-namespace Phonet devices handling */ 320/* Per-namespace Phonet devices handling */
314static int __net_init phonet_init_net(struct net *net) 321static int __net_init phonet_init_net(struct net *net)
315{ 322{
316 struct phonet_net *pnn = net_generic(net, phonet_net_id); 323 struct phonet_net *pnn = phonet_pernet(net);
317 324
318 if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops)) 325 if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops))
319 return -ENOMEM; 326 return -ENOMEM;
@@ -326,7 +333,7 @@ static int __net_init phonet_init_net(struct net *net)
326 333
327static void __net_exit phonet_exit_net(struct net *net) 334static void __net_exit phonet_exit_net(struct net *net)
328{ 335{
329 struct phonet_net *pnn = net_generic(net, phonet_net_id); 336 struct phonet_net *pnn = phonet_pernet(net);
330 struct net_device *dev; 337 struct net_device *dev;
331 unsigned i; 338 unsigned i;
332 339
@@ -376,7 +383,7 @@ void phonet_device_exit(void)
376 383
377int phonet_route_add(struct net_device *dev, u8 daddr) 384int phonet_route_add(struct net_device *dev, u8 daddr)
378{ 385{
379 struct phonet_net *pnn = net_generic(dev_net(dev), phonet_net_id); 386 struct phonet_net *pnn = phonet_pernet(dev_net(dev));
380 struct phonet_routes *routes = &pnn->routes; 387 struct phonet_routes *routes = &pnn->routes;
381 int err = -EEXIST; 388 int err = -EEXIST;
382 389
@@ -393,7 +400,7 @@ int phonet_route_add(struct net_device *dev, u8 daddr)
393 400
394int phonet_route_del(struct net_device *dev, u8 daddr) 401int phonet_route_del(struct net_device *dev, u8 daddr)
395{ 402{
396 struct phonet_net *pnn = net_generic(dev_net(dev), phonet_net_id); 403 struct phonet_net *pnn = phonet_pernet(dev_net(dev));
397 struct phonet_routes *routes = &pnn->routes; 404 struct phonet_routes *routes = &pnn->routes;
398 405
399 daddr = daddr >> 2; 406 daddr = daddr >> 2;
@@ -413,7 +420,7 @@ int phonet_route_del(struct net_device *dev, u8 daddr)
413 420
414struct net_device *phonet_route_get(struct net *net, u8 daddr) 421struct net_device *phonet_route_get(struct net *net, u8 daddr)
415{ 422{
416 struct phonet_net *pnn = net_generic(net, phonet_net_id); 423 struct phonet_net *pnn = phonet_pernet(net);
417 struct phonet_routes *routes = &pnn->routes; 424 struct phonet_routes *routes = &pnn->routes;
418 struct net_device *dev; 425 struct net_device *dev;
419 426
@@ -428,7 +435,7 @@ struct net_device *phonet_route_get(struct net *net, u8 daddr)
428 435
429struct net_device *phonet_route_output(struct net *net, u8 daddr) 436struct net_device *phonet_route_output(struct net *net, u8 daddr)
430{ 437{
431 struct phonet_net *pnn = net_generic(net, phonet_net_id); 438 struct phonet_net *pnn = phonet_pernet(net);
432 struct phonet_routes *routes = &pnn->routes; 439 struct phonet_routes *routes = &pnn->routes;
433 struct net_device *dev; 440 struct net_device *dev;
434 441