pn_dev.c (bd072111e7319d90a7b8127f91c2806b9a6f279e) | pn_dev.c (c1dc13e9d0bc35a8d85bf4238c48c1b627d48f35) |
---|---|
1/* 2 * File: pn_dev.c 3 * 4 * Phonet network device 5 * 6 * Copyright (C) 2008 Nokia Corporation. 7 * 8 * Contact: Remi Denis-Courmont <remi.denis-courmont@nokia.com> --- 204 unchanged lines hidden (view full) --- 213 214/* Per-namespace Phonet devices handling */ 215static int phonet_init_net(struct net *net) 216{ 217 struct phonet_net *pnn = kmalloc(sizeof(*pnn), GFP_KERNEL); 218 if (!pnn) 219 return -ENOMEM; 220 | 1/* 2 * File: pn_dev.c 3 * 4 * Phonet network device 5 * 6 * Copyright (C) 2008 Nokia Corporation. 7 * 8 * Contact: Remi Denis-Courmont <remi.denis-courmont@nokia.com> --- 204 unchanged lines hidden (view full) --- 213 214/* Per-namespace Phonet devices handling */ 215static int phonet_init_net(struct net *net) 216{ 217 struct phonet_net *pnn = kmalloc(sizeof(*pnn), GFP_KERNEL); 218 if (!pnn) 219 return -ENOMEM; 220 |
221 if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops)) { 222 kfree(pnn); 223 return -ENOMEM; 224 } 225 |
|
221 INIT_LIST_HEAD(&pnn->pndevs.list); 222 spin_lock_init(&pnn->pndevs.lock); 223 net_assign_generic(net, phonet_net_id, pnn); 224 return 0; 225} 226 227static void phonet_exit_net(struct net *net) 228{ 229 struct phonet_net *pnn = net_generic(net, phonet_net_id); 230 struct net_device *dev; 231 232 rtnl_lock(); 233 for_each_netdev(net, dev) 234 phonet_device_destroy(dev); 235 rtnl_unlock(); | 226 INIT_LIST_HEAD(&pnn->pndevs.list); 227 spin_lock_init(&pnn->pndevs.lock); 228 net_assign_generic(net, phonet_net_id, pnn); 229 return 0; 230} 231 232static void phonet_exit_net(struct net *net) 233{ 234 struct phonet_net *pnn = net_generic(net, phonet_net_id); 235 struct net_device *dev; 236 237 rtnl_lock(); 238 for_each_netdev(net, dev) 239 phonet_device_destroy(dev); 240 rtnl_unlock(); |
241 242 proc_net_remove(net, "phonet"); |
|
236 kfree(pnn); 237} 238 239static struct pernet_operations phonet_net_ops = { 240 .init = phonet_init_net, 241 .exit = phonet_exit_net, 242}; 243 --- 20 unchanged lines hidden --- | 243 kfree(pnn); 244} 245 246static struct pernet_operations phonet_net_ops = { 247 .init = phonet_init_net, 248 .exit = phonet_exit_net, 249}; 250 --- 20 unchanged lines hidden --- |