ALSA: hda - Add support for Thinkpad Edge conexant chip
[safe/jmp/linux-2.6] / net / tipc / port.c
index 93014f9..e70d27e 100644 (file)
@@ -2,7 +2,7 @@
  * net/tipc/port.c: TIPC port code
  *
  * Copyright (c) 1992-2007, Ericsson AB
- * Copyright (c) 2004-2007, Wind River Systems
+ * Copyright (c) 2004-2008, Wind River Systems
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -213,16 +213,13 @@ exit:
 /**
  * tipc_createport_raw - create a generic TIPC port
  *
- * Returns port reference, or 0 if unable to create it
- *
- * Note: The newly created port is returned in the locked state.
+ * Returns pointer to (locked) TIPC port, or NULL if unable to create it
  */
 
-u32 tipc_createport_raw(void *usr_handle,
+struct tipc_port *tipc_createport_raw(void *usr_handle,
                        u32 (*dispatcher)(struct tipc_port *, struct sk_buff *),
                        void (*wakeup)(struct tipc_port *),
-                       const u32 importance,
-                       struct tipc_port **tp_ptr)
+                       const u32 importance)
 {
        struct port *p_ptr;
        struct tipc_msg *msg;
@@ -231,13 +228,13 @@ u32 tipc_createport_raw(void *usr_handle,
        p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC);
        if (!p_ptr) {
                warn("Port creation failed, no memory\n");
-               return 0;
+               return NULL;
        }
        ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock);
        if (!ref) {
                warn("Port creation failed, reference table exhausted\n");
                kfree(p_ptr);
-               return 0;
+               return NULL;
        }
 
        p_ptr->publ.usr_handle = usr_handle;
@@ -260,8 +257,7 @@ u32 tipc_createport_raw(void *usr_handle,
        INIT_LIST_HEAD(&p_ptr->port_list);
        list_add_tail(&p_ptr->port_list, &ports);
        spin_unlock_bh(&tipc_port_list_lock);
-       *tp_ptr = &p_ptr->publ;
-       return ref;
+       return &(p_ptr->publ);
 }
 
 int tipc_deleteport(u32 ref)
@@ -295,7 +291,7 @@ int tipc_deleteport(u32 ref)
        kfree(p_ptr);
        dbg("Deleted port %u\n", ref);
        tipc_net_route_msg(buf);
-       return TIPC_OK;
+       return 0;
 }
 
 /**
@@ -340,7 +336,7 @@ int tipc_portunreliable(u32 ref, unsigned int *isunreliable)
                return -EINVAL;
        *isunreliable = port_unreliable(p_ptr);
        tipc_port_unlock(p_ptr);
-       return TIPC_OK;
+       return 0;
 }
 
 int tipc_set_portunreliable(u32 ref, unsigned int isunreliable)
@@ -352,7 +348,7 @@ int tipc_set_portunreliable(u32 ref, unsigned int isunreliable)
                return -EINVAL;
        msg_set_src_droppable(&p_ptr->publ.phdr, (isunreliable != 0));
        tipc_port_unlock(p_ptr);
-       return TIPC_OK;
+       return 0;
 }
 
 static int port_unreturnable(struct port *p_ptr)
@@ -369,7 +365,7 @@ int tipc_portunreturnable(u32 ref, unsigned int *isunrejectable)
                return -EINVAL;
        *isunrejectable = port_unreturnable(p_ptr);
        tipc_port_unlock(p_ptr);
-       return TIPC_OK;
+       return 0;
 }
 
 int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
@@ -381,7 +377,7 @@ int tipc_set_portunreturnable(u32 ref, unsigned int isunrejectable)
                return -EINVAL;
        msg_set_dest_droppable(&p_ptr->publ.phdr, (isunrejectable != 0));
        tipc_port_unlock(p_ptr);
-       return TIPC_OK;
+       return 0;
 }
 
 /*
@@ -448,13 +444,15 @@ int tipc_reject_msg(struct sk_buff *buf, u32 err)
        msg_set_errcode(rmsg, err);
        msg_set_destport(rmsg, msg_origport(msg));
        msg_set_origport(rmsg, msg_destport(msg));
-       if (msg_short(msg))
+       if (msg_short(msg)) {
                msg_set_orignode(rmsg, tipc_own_addr);
-       else
+               /* leave name type & instance as zeroes */
+       } else {
                msg_set_orignode(rmsg, msg_destnode(msg));
+               msg_set_nametype(rmsg, msg_nametype(msg));
+               msg_set_nameinst(rmsg, msg_nameinst(msg));
+       }
        msg_set_size(rmsg, data_sz + hdr_sz);
-       msg_set_nametype(rmsg, msg_nametype(msg));
-       msg_set_nameinst(rmsg, msg_nameinst(msg));
        skb_copy_to_linear_data_offset(rbuf, hdr_sz, msg_data(msg), data_sz);
 
        /* send self-abort message when rejecting on a connected port */
@@ -965,7 +963,7 @@ static u32 port_dispatcher(struct tipc_port *dummy, struct sk_buff *buf)
                tipc_k_signal((Handler)port_dispatcher_sigh, 0);
        }
        spin_unlock_bh(&queue_lock);
-       return TIPC_OK;
+       return 0;
 }
 
 /*
@@ -1042,21 +1040,18 @@ int tipc_createport(u32 user_ref,
 {
        struct user_port *up_ptr;
        struct port *p_ptr;
-       struct tipc_port *tp_ptr;
-       u32 ref;
 
        up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
        if (!up_ptr) {
                warn("Port creation failed, no memory\n");
                return -ENOMEM;
        }
-       ref = tipc_createport_raw(NULL, port_dispatcher, port_wakeup,
-                                 importance, &tp_ptr);
-       if (ref == 0) {
+       p_ptr = (struct port *)tipc_createport_raw(NULL, port_dispatcher,
+                                                  port_wakeup, importance);
+       if (!p_ptr) {
                kfree(up_ptr);
                return -ENOMEM;
        }
-       p_ptr = (struct port *)tp_ptr;
 
        p_ptr->user_port = up_ptr;
        up_ptr->user_ref = user_ref;
@@ -1072,16 +1067,15 @@ int tipc_createport(u32 user_ref,
        INIT_LIST_HEAD(&up_ptr->uport_list);
        tipc_reg_add_port(up_ptr);
        *portref = p_ptr->publ.ref;
-       dbg(" tipc_createport: %x with ref %u\n", p_ptr, p_ptr->publ.ref);
        tipc_port_unlock(p_ptr);
-       return TIPC_OK;
+       return 0;
 }
 
 int tipc_ownidentity(u32 ref, struct tipc_portid *id)
 {
        id->ref = ref;
        id->node = tipc_own_addr;
-       return TIPC_OK;
+       return 0;
 }
 
 int tipc_portimportance(u32 ref, unsigned int *importance)
@@ -1093,7 +1087,7 @@ int tipc_portimportance(u32 ref, unsigned int *importance)
                return -EINVAL;
        *importance = (unsigned int)msg_importance(&p_ptr->publ.phdr);
        tipc_port_unlock(p_ptr);
-       return TIPC_OK;
+       return 0;
 }
 
 int tipc_set_portimportance(u32 ref, unsigned int imp)
@@ -1108,7 +1102,7 @@ int tipc_set_portimportance(u32 ref, unsigned int imp)
                return -EINVAL;
        msg_set_importance(&p_ptr->publ.phdr, (u32)imp);
        tipc_port_unlock(p_ptr);
-       return TIPC_OK;
+       return 0;
 }
 
 
@@ -1143,7 +1137,7 @@ int tipc_publish(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
                list_add(&publ->pport_list, &p_ptr->publications);
                p_ptr->pub_count++;
                p_ptr->publ.published = 1;
-               res = TIPC_OK;
+               res = 0;
        }
 exit:
        tipc_port_unlock(p_ptr);
@@ -1166,7 +1160,7 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
                        tipc_nametbl_withdraw(publ->type, publ->lower,
                                              publ->ref, publ->key);
                }
-               res = TIPC_OK;
+               res = 0;
        } else {
                list_for_each_entry_safe(publ, tpubl,
                                         &p_ptr->publications, pport_list) {
@@ -1180,7 +1174,7 @@ int tipc_withdraw(u32 ref, unsigned int scope, struct tipc_name_seq const *seq)
                                break;
                        tipc_nametbl_withdraw(publ->type, publ->lower,
                                              publ->ref, publ->key);
-                       res = TIPC_OK;
+                       res = 0;
                        break;
                }
        }
@@ -1224,7 +1218,7 @@ int tipc_connect2port(u32 ref, struct tipc_portid const *peer)
        tipc_nodesub_subscribe(&p_ptr->subscription,peer->node,
                          (void *)(unsigned long)ref,
                          (net_ev_handler)port_handle_node_down);
-       res = TIPC_OK;
+       res = 0;
 exit:
        tipc_port_unlock(p_ptr);
        p_ptr->publ.max_pkt = tipc_link_get_max_pkt(peer->node, ref);
@@ -1246,7 +1240,7 @@ int tipc_disconnect_port(struct tipc_port *tp_ptr)
                /* let timer expire on it's own to avoid deadlock! */
                tipc_nodesub_unsubscribe(
                        &((struct port *)tp_ptr)->subscription);
-               res = TIPC_OK;
+               res = 0;
        } else {
                res = -ENOTCONN;
        }
@@ -1311,7 +1305,7 @@ int tipc_isconnected(u32 ref, int *isconnected)
                return -EINVAL;
        *isconnected = p_ptr->publ.connected;
        tipc_port_unlock(p_ptr);
-       return TIPC_OK;
+       return 0;
 }
 
 int tipc_peer(u32 ref, struct tipc_portid *peer)
@@ -1325,7 +1319,7 @@ int tipc_peer(u32 ref, struct tipc_portid *peer)
        if (p_ptr->publ.connected) {
                peer->ref = port_peerport(p_ptr);
                peer->node = port_peernode(p_ptr);
-               res = TIPC_OK;
+               res = 0;
        } else
                res = -ENOTCONN;
        tipc_port_unlock(p_ptr);