netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next-2.6 PATCH] can: rename can_try_module_get to can_get_proto
@ 2011-05-04  4:42 Kurt Van Dijck
  2011-05-04 20:35 ` Oliver Hartkopp
  0 siblings, 1 reply; 3+ messages in thread
From: Kurt Van Dijck @ 2011-05-04  4:42 UTC (permalink / raw)
  To: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
	netdev-u79uwXL29TY76Z2rM5mHXA

can: rename can_try_module_get to can_get_proto

can_try_module_get does return a struct can_proto.
The name explains what is done in so much detail that a caller
may not notice that a struct can_proto is locked/unlocked.

Signed-off-by: Kurt Van Dijck <kurt.van.dijck-/BeEPy95v10@public.gmane.org>

diff --git a/net/can/af_can.c b/net/can/af_can.c
index 5b52762..094fc53 100644
--- a/net/can/af_can.c
+++ b/net/can/af_can.c
@@ -115,7 +115,7 @@ static void can_sock_destruct(struct sock *sk)
 	skb_queue_purge(&sk->sk_receive_queue);
 }
 
-static const struct can_proto *can_try_module_get(int protocol)
+static const struct can_proto *can_get_proto(int protocol)
 {
 	const struct can_proto *cp;
 
@@ -128,6 +128,11 @@ static const struct can_proto *can_try_module_get(int protocol)
 	return cp;
 }
 
+static inline void can_put_proto(const struct can_proto *cp)
+{
+	module_put(cp->prot->owner);
+}
+
 static int can_create(struct net *net, struct socket *sock, int protocol,
 		      int kern)
 {
@@ -143,7 +148,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
 	if (!net_eq(net, &init_net))
 		return -EAFNOSUPPORT;
 
-	cp = can_try_module_get(protocol);
+	cp = can_get_proto(protocol);
 
 #ifdef CONFIG_MODULES
 	if (!cp) {
@@ -160,7 +165,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
 			printk(KERN_ERR "can: request_module "
 			       "(can-proto-%d) failed.\n", protocol);
 
-		cp = can_try_module_get(protocol);
+		cp = can_get_proto(protocol);
 	}
 #endif
 
@@ -195,7 +200,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
 	}
 
  errout:
-	module_put(cp->prot->owner);
+	can_put_proto(cp);
 	return err;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [net-next-2.6 PATCH] can: rename can_try_module_get to can_get_proto
  2011-05-04  4:42 [net-next-2.6 PATCH] can: rename can_try_module_get to can_get_proto Kurt Van Dijck
@ 2011-05-04 20:35 ` Oliver Hartkopp
       [not found]   ` <4DC1B89A.3080904-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Oliver Hartkopp @ 2011-05-04 20:35 UTC (permalink / raw)
  To: socketcan-core, netdev

On 04.05.2011 06:42, Kurt Van Dijck wrote:
> can: rename can_try_module_get to can_get_proto
> 
> can_try_module_get does return a struct can_proto.
> The name explains what is done in so much detail that a caller
> may not notice that a struct can_proto is locked/unlocked.
> 
> Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>

> 
> diff --git a/net/can/af_can.c b/net/can/af_can.c
> index 5b52762..094fc53 100644
> --- a/net/can/af_can.c
> +++ b/net/can/af_can.c
> @@ -115,7 +115,7 @@ static void can_sock_destruct(struct sock *sk)
>  	skb_queue_purge(&sk->sk_receive_queue);
>  }
>  
> -static const struct can_proto *can_try_module_get(int protocol)
> +static const struct can_proto *can_get_proto(int protocol)
>  {
>  	const struct can_proto *cp;
>  
> @@ -128,6 +128,11 @@ static const struct can_proto *can_try_module_get(int protocol)
>  	return cp;
>  }
>  
> +static inline void can_put_proto(const struct can_proto *cp)
> +{
> +	module_put(cp->prot->owner);
> +}
> +
>  static int can_create(struct net *net, struct socket *sock, int protocol,
>  		      int kern)
>  {
> @@ -143,7 +148,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
>  	if (!net_eq(net, &init_net))
>  		return -EAFNOSUPPORT;
>  
> -	cp = can_try_module_get(protocol);
> +	cp = can_get_proto(protocol);
>  
>  #ifdef CONFIG_MODULES
>  	if (!cp) {
> @@ -160,7 +165,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
>  			printk(KERN_ERR "can: request_module "
>  			       "(can-proto-%d) failed.\n", protocol);
>  
> -		cp = can_try_module_get(protocol);
> +		cp = can_get_proto(protocol);
>  	}
>  #endif
>  
> @@ -195,7 +200,7 @@ static int can_create(struct net *net, struct socket *sock, int protocol,
>  	}
>  
>   errout:
> -	module_put(cp->prot->owner);
> +	can_put_proto(cp);
>  	return err;
>  }
>  
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [net-next-2.6 PATCH] can: rename can_try_module_get to can_get_proto
       [not found]   ` <4DC1B89A.3080904-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
@ 2011-05-04 21:08     ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2011-05-04 21:08 UTC (permalink / raw)
  To: socketcan-fJ+pQTUTwRTk1uMJSBkQmQ
  Cc: socketcan-core-0fE9KPoRgkgATYTw5x5z8w,
	netdev-u79uwXL29TY76Z2rM5mHXA

From: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
Date: Wed, 04 May 2011 22:35:38 +0200

> On 04.05.2011 06:42, Kurt Van Dijck wrote:
>> can: rename can_try_module_get to can_get_proto
>> 
>> can_try_module_get does return a struct can_proto.
>> The name explains what is done in so much detail that a caller
>> may not notice that a struct can_proto is locked/unlocked.
>> 
>> Signed-off-by: Kurt Van Dijck <kurt.van.dijck-/BeEPy95v10@public.gmane.org>
> 
> Acked-by: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-05-04 21:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-04  4:42 [net-next-2.6 PATCH] can: rename can_try_module_get to can_get_proto Kurt Van Dijck
2011-05-04 20:35 ` Oliver Hartkopp
     [not found]   ` <4DC1B89A.3080904-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
2011-05-04 21:08     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).