diff options
Diffstat (limited to 'net/phonet/pn_dev.c')
| -rw-r--r-- | net/phonet/pn_dev.c | 61 | 
1 files changed, 16 insertions, 45 deletions
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c index 947038ddd04..56a6146ac94 100644 --- a/net/phonet/pn_dev.c +++ b/net/phonet/pn_dev.c @@ -5,8 +5,8 @@   *   * Copyright (C) 2008 Nokia Corporation.   * - * Contact: Remi Denis-Courmont <remi.denis-courmont@nokia.com> - * Original author: Sakari Ailus <sakari.ailus@nokia.com> + * Authors: Sakari Ailus <sakari.ailus@nokia.com> + *          Rémi Denis-Courmont   *   * This program is free software; you can redistribute it and/or   * modify it under the terms of the GNU General Public License @@ -44,7 +44,7 @@ struct phonet_net {  	struct phonet_routes routes;  }; -int phonet_net_id __read_mostly; +static int phonet_net_id __read_mostly;  static struct phonet_net *phonet_pernet(struct net *net)  { @@ -162,14 +162,6 @@ int phonet_address_add(struct net_device *dev, u8 addr)  	return err;  } -static void phonet_device_rcu_free(struct rcu_head *head) -{ -	struct phonet_device *pnd; - -	pnd = container_of(head, struct phonet_device, rcu); -	kfree(pnd); -} -  int phonet_address_del(struct net_device *dev, u8 addr)  {  	struct phonet_device_list *pndevs = phonet_device_list(dev_net(dev)); @@ -188,7 +180,7 @@ int phonet_address_del(struct net_device *dev, u8 addr)  	mutex_unlock(&pndevs->lock);  	if (pnd) -		call_rcu(&pnd->rcu, phonet_device_rcu_free); +		kfree_rcu(pnd, rcu);  	return err;  } @@ -276,7 +268,7 @@ static int phonet_device_autoconf(struct net_device *dev)  static void phonet_route_autodel(struct net_device *dev)  {  	struct phonet_net *pnn = phonet_pernet(dev_net(dev)); -	unsigned i; +	unsigned int i;  	DECLARE_BITMAP(deleted, 64);  	/* Remove left-over Phonet routes */ @@ -284,7 +276,7 @@ static void phonet_route_autodel(struct net_device *dev)  	mutex_lock(&pnn->routes.lock);  	for (i = 0; i < 64; i++)  		if (dev == pnn->routes.table[i]) { -			rcu_assign_pointer(pnn->routes.table[i], NULL); +			RCU_INIT_POINTER(pnn->routes.table[i], NULL);  			set_bit(i, deleted);  		}  	mutex_unlock(&pnn->routes.lock); @@ -300,9 +292,9 @@ static void phonet_route_autodel(struct net_device *dev)  /* notify Phonet of device events */  static int phonet_device_notify(struct notifier_block *me, unsigned long what, -				void *arg) +				void *ptr)  { -	struct net_device *dev = arg; +	struct net_device *dev = netdev_notifier_info_to_dev(ptr);  	switch (what) {  	case NETDEV_REGISTER: @@ -328,7 +320,7 @@ static int __net_init phonet_init_net(struct net *net)  {  	struct phonet_net *pnn = phonet_pernet(net); -	if (!proc_net_fops_create(net, "phonet", 0, &pn_sock_seq_fops)) +	if (!proc_create("phonet", 0, net->proc_net, &pn_sock_seq_fops))  		return -ENOMEM;  	INIT_LIST_HEAD(&pnn->pndevs.list); @@ -339,24 +331,7 @@ static int __net_init phonet_init_net(struct net *net)  static void __net_exit phonet_exit_net(struct net *net)  { -	struct phonet_net *pnn = phonet_pernet(net); -	struct net_device *dev; -	unsigned i; - -	rtnl_lock(); -	for_each_netdev(net, dev) -		phonet_device_destroy(dev); - -	for (i = 0; i < 64; i++) { -		dev = pnn->routes.table[i]; -		if (dev) { -			rtm_phonet_notify(RTM_DELROUTE, dev, i); -			dev_put(dev); -		} -	} -	rtnl_unlock(); - -	proc_net_remove(net, "phonet"); +	remove_proc_entry("phonet", net->proc_net);  }  static struct pernet_operations phonet_net_ops = { @@ -369,11 +344,11 @@ static struct pernet_operations phonet_net_ops = {  /* Initialize Phonet devices list */  int __init phonet_device_init(void)  { -	int err = register_pernet_device(&phonet_net_ops); +	int err = register_pernet_subsys(&phonet_net_ops);  	if (err)  		return err; -	proc_net_fops_create(&init_net, "pnresource", 0, &pn_res_seq_fops); +	proc_create("pnresource", 0, init_net.proc_net, &pn_res_seq_fops);  	register_netdevice_notifier(&phonet_device_notifier);  	err = phonet_netlink_register();  	if (err) @@ -385,8 +360,8 @@ void phonet_device_exit(void)  {  	rtnl_unregister_all(PF_PHONET);  	unregister_netdevice_notifier(&phonet_device_notifier); -	unregister_pernet_device(&phonet_net_ops); -	proc_net_remove(&init_net, "pnresource"); +	unregister_pernet_subsys(&phonet_net_ops); +	remove_proc_entry("pnresource", init_net.proc_net);  }  int phonet_route_add(struct net_device *dev, u8 daddr) @@ -414,7 +389,7 @@ int phonet_route_del(struct net_device *dev, u8 daddr)  	daddr = daddr >> 2;  	mutex_lock(&routes->lock);  	if (dev == routes->table[daddr]) -		rcu_assign_pointer(routes->table[daddr], NULL); +		RCU_INIT_POINTER(routes->table[daddr], NULL);  	else  		dev = NULL;  	mutex_unlock(&routes->lock); @@ -426,18 +401,14 @@ int phonet_route_del(struct net_device *dev, u8 daddr)  	return 0;  } -struct net_device *phonet_route_get(struct net *net, u8 daddr) +struct net_device *phonet_route_get_rcu(struct net *net, u8 daddr)  {  	struct phonet_net *pnn = phonet_pernet(net);  	struct phonet_routes *routes = &pnn->routes;  	struct net_device *dev; -	ASSERT_RTNL(); /* no need to hold the device */ -  	daddr >>= 2; -	rcu_read_lock();  	dev = rcu_dereference(routes->table[daddr]); -	rcu_read_unlock();  	return dev;  }  | 
