* [patch 1/3] CAN: Clean up module auto loading
2008-02-06 22:07 [patch 0/3] CAN: Some updates for 2.6.25 urs.thuermann
@ 2008-02-06 22:07 ` urs.thuermann
2008-02-06 22:07 ` [patch 2/3] CAN: Move proto_{,un}register() out of spin-locked region urs.thuermann
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: urs.thuermann @ 2008-02-06 22:07 UTC (permalink / raw)
To: David Miller, netdev; +Cc: Urs Thuermann, Oliver Hartkopp, Oliver Hartkopp
[-- Attachment #1: module-load --]
[-- Type: text/plain, Size: 1705 bytes --]
Remove local char array to construct module name.
Don't call request_module() when CONFIG_KMOD is not set.
Signed-off-by: Urs Thuermann <urs.thuermann@volkswagen.de>
Signed-off-by: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
---
net/can/af_can.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
Index: net-2.6/net/can/af_can.c
===================================================================
--- net-2.6.orig/net/can/af_can.c 2008-02-06 22:17:58.000000000 +0100
+++ net-2.6/net/can/af_can.c 2008-02-06 22:20:46.000000000 +0100
@@ -118,7 +118,6 @@
{
struct sock *sk;
struct can_proto *cp;
- char module_name[sizeof("can-proto-000")];
int err = 0;
sock->state = SS_UNCONNECTED;
@@ -129,26 +128,21 @@
if (net != &init_net)
return -EAFNOSUPPORT;
+#ifdef CONFIG_KMOD
/* try to load protocol module, when CONFIG_KMOD is defined */
if (!proto_tab[protocol]) {
- sprintf(module_name, "can-proto-%d", protocol);
- err = request_module(module_name);
+ err = request_module("can-proto-%d", protocol);
/*
* In case of error we only print a message but don't
* return the error code immediately. Below we will
* return -EPROTONOSUPPORT
*/
- if (err == -ENOSYS) {
- if (printk_ratelimit())
- printk(KERN_INFO "can: request_module(%s)"
- " not implemented.\n", module_name);
- } else if (err) {
- if (printk_ratelimit())
- printk(KERN_ERR "can: request_module(%s)"
- " failed.\n", module_name);
- }
+ if (err && printk_ratelimit())
+ printk(KERN_ERR "can: request_module "
+ "(can-proto-%d) failed.\n", protocol);
}
+#endif
spin_lock(&proto_tab_lock);
cp = proto_tab[protocol];
--
^ permalink raw reply [flat|nested] 5+ messages in thread* [patch 2/3] CAN: Move proto_{,un}register() out of spin-locked region
2008-02-06 22:07 [patch 0/3] CAN: Some updates for 2.6.25 urs.thuermann
2008-02-06 22:07 ` [patch 1/3] CAN: Clean up module auto loading urs.thuermann
@ 2008-02-06 22:07 ` urs.thuermann
2008-02-06 22:07 ` [patch 3/3] CAN: Minor clean-ups urs.thuermann
2008-02-08 2:05 ` [patch 0/3] CAN: Some updates for 2.6.25 David Miller
3 siblings, 0 replies; 5+ messages in thread
From: urs.thuermann @ 2008-02-06 22:07 UTC (permalink / raw)
To: David Miller, netdev; +Cc: Urs Thuermann, Oliver Hartkopp, Oliver Hartkopp
[-- Attachment #1: proto_register --]
[-- Type: text/plain, Size: 1688 bytes --]
The implementation of proto_register() has changed so that it can now
sleep. The call to proto_register() must be moved out of the
spin-locked region.
Signed-off-by: Urs Thuermann <urs.thuermann@volkswagen.de>
Signed-off-by: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
---
net/can/af_can.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
Index: net-2.6/net/can/af_can.c
===================================================================
--- net-2.6.orig/net/can/af_can.c 2008-02-06 22:20:46.000000000 +0100
+++ net-2.6/net/can/af_can.c 2008-02-06 22:22:51.000000000 +0100
@@ -656,26 +656,26 @@
return -EINVAL;
}
+ err = proto_register(cp->prot, 0);
+ if (err < 0)
+ return err;
+
spin_lock(&proto_tab_lock);
if (proto_tab[proto]) {
printk(KERN_ERR "can: protocol %d already registered\n",
proto);
err = -EBUSY;
- goto errout;
+ } else {
+ proto_tab[proto] = cp;
+
+ /* use generic ioctl function if not defined by module */
+ if (!cp->ops->ioctl)
+ cp->ops->ioctl = can_ioctl;
}
+ spin_unlock(&proto_tab_lock);
- err = proto_register(cp->prot, 0);
if (err < 0)
- goto errout;
-
- proto_tab[proto] = cp;
-
- /* use generic ioctl function if the module doesn't bring its own */
- if (!cp->ops->ioctl)
- cp->ops->ioctl = can_ioctl;
-
- errout:
- spin_unlock(&proto_tab_lock);
+ proto_unregister(cp->prot);
return err;
}
@@ -694,9 +694,10 @@
printk(KERN_ERR "BUG: can: protocol %d is not registered\n",
proto);
}
- proto_unregister(cp->prot);
proto_tab[proto] = NULL;
spin_unlock(&proto_tab_lock);
+
+ proto_unregister(cp->prot);
}
EXPORT_SYMBOL(can_proto_unregister);
--
^ permalink raw reply [flat|nested] 5+ messages in thread* [patch 3/3] CAN: Minor clean-ups
2008-02-06 22:07 [patch 0/3] CAN: Some updates for 2.6.25 urs.thuermann
2008-02-06 22:07 ` [patch 1/3] CAN: Clean up module auto loading urs.thuermann
2008-02-06 22:07 ` [patch 2/3] CAN: Move proto_{,un}register() out of spin-locked region urs.thuermann
@ 2008-02-06 22:07 ` urs.thuermann
2008-02-08 2:05 ` [patch 0/3] CAN: Some updates for 2.6.25 David Miller
3 siblings, 0 replies; 5+ messages in thread
From: urs.thuermann @ 2008-02-06 22:07 UTC (permalink / raw)
To: David Miller, netdev; +Cc: Urs Thuermann, Oliver Hartkopp, Oliver Hartkopp
[-- Attachment #1: cosmetics --]
[-- Type: text/plain, Size: 2361 bytes --]
Remove unneeded variable.
Rename local variable error to err like in all other places.
Some white-space changes.
Signed-off-by: Urs Thuermann <urs.thuermann@volkswagen.de>
Signed-off-by: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
---
net/can/raw.c | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
Index: net-2.6/net/can/raw.c
===================================================================
--- net-2.6.orig/net/can/raw.c 2008-02-06 22:17:58.000000000 +0100
+++ net-2.6/net/can/raw.c 2008-02-06 22:30:55.000000000 +0100
@@ -98,7 +98,6 @@
struct sock *sk = (struct sock *)data;
struct raw_sock *ro = raw_sk(sk);
struct sockaddr_can *addr;
- int error;
if (!ro->recv_own_msgs) {
/* check the received tx sock reference */
@@ -121,14 +120,12 @@
addr->can_family = AF_CAN;
addr->can_ifindex = skb->dev->ifindex;
- error = sock_queue_rcv_skb(sk, skb);
- if (error < 0)
+ if (sock_queue_rcv_skb(sk, skb) < 0)
kfree_skb(skb);
}
static int raw_enable_filters(struct net_device *dev, struct sock *sk,
- struct can_filter *filter,
- int count)
+ struct can_filter *filter, int count)
{
int err = 0;
int i;
@@ -163,8 +160,7 @@
}
static void raw_disable_filters(struct net_device *dev, struct sock *sk,
- struct can_filter *filter,
- int count)
+ struct can_filter *filter, int count)
{
int i;
@@ -353,7 +349,6 @@
/* filters set by default/setsockopt */
err = raw_enable_allfilters(dev, sk);
dev_put(dev);
-
} else {
ifindex = 0;
@@ -466,7 +461,6 @@
if (err) {
if (count > 1)
kfree(filter);
-
goto out_fil;
}
@@ -673,25 +667,25 @@
{
struct sock *sk = sock->sk;
struct sk_buff *skb;
- int error = 0;
+ int err = 0;
int noblock;
noblock = flags & MSG_DONTWAIT;
flags &= ~MSG_DONTWAIT;
- skb = skb_recv_datagram(sk, flags, noblock, &error);
+ skb = skb_recv_datagram(sk, flags, noblock, &err);
if (!skb)
- return error;
+ return err;
if (size < skb->len)
msg->msg_flags |= MSG_TRUNC;
else
size = skb->len;
- error = memcpy_toiovec(msg->msg_iov, skb->data, size);
- if (error < 0) {
+ err = memcpy_toiovec(msg->msg_iov, skb->data, size);
+ if (err < 0) {
skb_free_datagram(sk, skb);
- return error;
+ return err;
}
sock_recv_timestamp(msg, sk, skb);
--
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [patch 0/3] CAN: Some updates for 2.6.25
2008-02-06 22:07 [patch 0/3] CAN: Some updates for 2.6.25 urs.thuermann
` (2 preceding siblings ...)
2008-02-06 22:07 ` [patch 3/3] CAN: Minor clean-ups urs.thuermann
@ 2008-02-08 2:05 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2008-02-08 2:05 UTC (permalink / raw)
To: urs.thuermann; +Cc: netdev, urs.thuermann, oliver.hartkopp, oliver
From: urs.thuermann@gmx.de
Date: Wed, 6 Feb 2008 23:07:49 +0100
> The following patches are intended for 2.6.25.
Applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread