usb/gadget: Replace the old USB audio FU definitions in f_audio.c
[safe/jmp/linux-2.6] / net / rxrpc / ar-connection.c
index 43cb3e0..4106ca9 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/net.h>
 #include <linux/skbuff.h>
 #include <linux/crypto.h>
@@ -71,7 +72,7 @@ struct rxrpc_conn_bundle *rxrpc_get_bundle(struct rxrpc_sock *rx,
        struct rb_node *p, *parent, **pp;
 
        _enter("%p{%x},%x,%hx,",
-              rx, key_serial(key), trans->debug_id, ntohl(service_id));
+              rx, key_serial(key), trans->debug_id, ntohs(service_id));
 
        if (rx->trans == trans && rx->bundle) {
                atomic_inc(&rx->bundle->usage);
@@ -211,7 +212,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
                conn->header_size = sizeof(struct rxrpc_header);
        }
 
-       _leave(" = %p{%d}", conn, conn->debug_id);
+       _leave(" = %p{%d}", conn, conn ? conn->debug_id : 0);
        return conn;
 }
 
@@ -343,9 +344,9 @@ static int rxrpc_connect_exclusive(struct rxrpc_sock *rx,
                /* not yet present - create a candidate for a new connection
                 * and then redo the check */
                conn = rxrpc_alloc_connection(gfp);
-               if (IS_ERR(conn)) {
-                       _leave(" = %ld", PTR_ERR(conn));
-                       return PTR_ERR(conn);
+               if (!conn) {
+                       _leave(" = -ENOMEM");
+                       return -ENOMEM;
                }
 
                conn->trans = trans;
@@ -444,6 +445,11 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,
                        conn = list_entry(bundle->avail_conns.next,
                                          struct rxrpc_connection,
                                          bundle_link);
+                       if (conn->state >= RXRPC_CONN_REMOTELY_ABORTED) {
+                               list_del_init(&conn->bundle_link);
+                               bundle->num_conns--;
+                               continue;
+                       }
                        if (--conn->avail_calls == 0)
                                list_move(&conn->bundle_link,
                                          &bundle->busy_conns);
@@ -461,6 +467,11 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,
                        conn = list_entry(bundle->unused_conns.next,
                                          struct rxrpc_connection,
                                          bundle_link);
+                       if (conn->state >= RXRPC_CONN_REMOTELY_ABORTED) {
+                               list_del_init(&conn->bundle_link);
+                               bundle->num_conns--;
+                               continue;
+                       }
                        ASSERTCMP(conn->avail_calls, ==, RXRPC_MAXCALLS);
                        conn->avail_calls = RXRPC_MAXCALLS - 1;
                        ASSERT(conn->channels[0] == NULL &&
@@ -508,9 +519,9 @@ int rxrpc_connect_call(struct rxrpc_sock *rx,
                /* not yet present - create a candidate for a new connection and then
                 * redo the check */
                candidate = rxrpc_alloc_connection(gfp);
-               if (IS_ERR(candidate)) {
-                       _leave(" = %ld", PTR_ERR(candidate));
-                       return PTR_ERR(candidate);
+               if (!candidate) {
+                       _leave(" = -ENOMEM");
+                       return -ENOMEM;
                }
 
                candidate->trans = trans;
@@ -651,7 +662,7 @@ rxrpc_incoming_connection(struct rxrpc_transport *trans,
 
        candidate->trans = trans;
        candidate->epoch = hdr->epoch;
-       candidate->cid = hdr->cid & __constant_cpu_to_be32(RXRPC_CIDMASK);
+       candidate->cid = hdr->cid & cpu_to_be32(RXRPC_CIDMASK);
        candidate->service_id = hdr->serviceId;
        candidate->security_ix = hdr->securityIndex;
        candidate->in_clientflag = RXRPC_CLIENT_INITIATED;
@@ -791,7 +802,7 @@ void rxrpc_put_connection(struct rxrpc_connection *conn)
 
        ASSERTCMP(atomic_read(&conn->usage), >, 0);
 
-       conn->put_time = xtime.tv_sec;
+       conn->put_time = get_seconds();
        if (atomic_dec_and_test(&conn->usage)) {
                _debug("zombie");
                rxrpc_queue_delayed_work(&rxrpc_connection_reap, 0);
@@ -826,7 +837,7 @@ static void rxrpc_destroy_connection(struct rxrpc_connection *conn)
 /*
  * reap dead connections
  */
-void rxrpc_connection_reaper(struct work_struct *work)
+static void rxrpc_connection_reaper(struct work_struct *work)
 {
        struct rxrpc_connection *conn, *_p;
        unsigned long now, earliest, reap_time;
@@ -835,7 +846,7 @@ void rxrpc_connection_reaper(struct work_struct *work)
 
        _enter("");
 
-       now = xtime.tv_sec;
+       now = get_seconds();
        earliest = ULONG_MAX;
 
        write_lock_bh(&rxrpc_connection_lock);