Bluetooth: change bt_sock_unregister() to return void
authorDavid Herrmann <dh.herrmann@gmail.com>
Sun, 24 Feb 2013 18:36:52 +0000 (19:36 +0100)
committerGustavo Padovan <gustavo.padovan@collabora.co.uk>
Fri, 8 Mar 2013 13:38:44 +0000 (10:38 -0300)
There is no reason a caller ever wants to check the return type of this
call. _Iff_ a user successfully called bt_sock_register(), they're allowed
to call bt_sock_unregister().
All other calls in the kernel (device_del, device_unregister, kfree(), ..)
that are logically equivalent return void. Lets not make callers think
they have to check the return type of this call and instead simply return
void.

We guarantee that after bt_sock_unregister() is called, the socket type
_is_ unregistered. If that is not what the caller wants, they're using the
wrong function, anyway.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
include/net/bluetooth/bluetooth.h
net/bluetooth/af_bluetooth.c

index 9531bee..5f51bef 100644 (file)
@@ -232,7 +232,7 @@ struct bt_sock_list {
 };
 
 int  bt_sock_register(int proto, const struct net_proto_family *ops);
-int  bt_sock_unregister(int proto);
+void bt_sock_unregister(int proto);
 void bt_sock_link(struct bt_sock_list *l, struct sock *s);
 void bt_sock_unlink(struct bt_sock_list *l, struct sock *s);
 int  bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
index d3ee69b..81598e5 100644 (file)
@@ -92,23 +92,14 @@ int bt_sock_register(int proto, const struct net_proto_family *ops)
 }
 EXPORT_SYMBOL(bt_sock_register);
 
-int bt_sock_unregister(int proto)
+void bt_sock_unregister(int proto)
 {
-       int err = 0;
-
        if (proto < 0 || proto >= BT_MAX_PROTO)
-               return -EINVAL;
+               return;
 
        write_lock(&bt_proto_lock);
-
-       if (!bt_proto[proto])
-               err = -ENOENT;
-       else
-               bt_proto[proto] = NULL;
-
+       bt_proto[proto] = NULL;
        write_unlock(&bt_proto_lock);
-
-       return err;
 }
 EXPORT_SYMBOL(bt_sock_unregister);