tipc: Remove unneeded parameter to tipc_createport_raw()

This patch eliminates an unneeded parameter when creating a low-level
TIPC port object.  Instead of returning both the pointer to the port
structure and the port's reference ID, it now returns only the pointer
since the port structure contains the reference ID as one of its fields.

Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Allan Stephens 2008-07-14 22:42:19 -07:00 коммит произвёл David S. Miller
Родитель 3cb29b1bca
Коммит 0ea522416b
3 изменённых файлов: 20 добавлений и 36 удалений

Просмотреть файл

@ -2,7 +2,7 @@
* include/net/tipc/tipc_port.h: Include file for privileged access to TIPC ports * include/net/tipc/tipc_port.h: Include file for privileged access to TIPC ports
* *
* Copyright (c) 1994-2007, Ericsson AB * Copyright (c) 1994-2007, Ericsson AB
* Copyright (c) 2005-2007, Wind River Systems * Copyright (c) 2005-2008, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -75,17 +75,10 @@ struct tipc_port {
}; };
/** struct tipc_port *tipc_createport_raw(void *usr_handle,
* tipc_createport_raw - create a native TIPC port and return it's reference
*
* Note: 'dispatcher' and 'wakeup' deliver a locked port.
*/
u32 tipc_createport_raw(void *usr_handle,
u32 (*dispatcher)(struct tipc_port *, struct sk_buff *), u32 (*dispatcher)(struct tipc_port *, struct sk_buff *),
void (*wakeup)(struct tipc_port *), void (*wakeup)(struct tipc_port *),
const u32 importance, const u32 importance);
struct tipc_port **tp_ptr);
int tipc_reject_msg(struct sk_buff *buf, u32 err); int tipc_reject_msg(struct sk_buff *buf, u32 err);

Просмотреть файл

@ -2,7 +2,7 @@
* net/tipc/port.c: TIPC port code * net/tipc/port.c: TIPC port code
* *
* Copyright (c) 1992-2007, Ericsson AB * Copyright (c) 1992-2007, Ericsson AB
* Copyright (c) 2004-2007, Wind River Systems * Copyright (c) 2004-2008, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -213,16 +213,13 @@ exit:
/** /**
* tipc_createport_raw - create a generic TIPC port * tipc_createport_raw - create a generic TIPC port
* *
* Returns port reference, or 0 if unable to create it * Returns pointer to (locked) TIPC port, or NULL if unable to create it
*
* Note: The newly created port is returned in the locked state.
*/ */
u32 tipc_createport_raw(void *usr_handle, struct tipc_port *tipc_createport_raw(void *usr_handle,
u32 (*dispatcher)(struct tipc_port *, struct sk_buff *), u32 (*dispatcher)(struct tipc_port *, struct sk_buff *),
void (*wakeup)(struct tipc_port *), void (*wakeup)(struct tipc_port *),
const u32 importance, const u32 importance)
struct tipc_port **tp_ptr)
{ {
struct port *p_ptr; struct port *p_ptr;
struct tipc_msg *msg; struct tipc_msg *msg;
@ -231,13 +228,13 @@ u32 tipc_createport_raw(void *usr_handle,
p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC); p_ptr = kzalloc(sizeof(*p_ptr), GFP_ATOMIC);
if (!p_ptr) { if (!p_ptr) {
warn("Port creation failed, no memory\n"); warn("Port creation failed, no memory\n");
return 0; return NULL;
} }
ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock); ref = tipc_ref_acquire(p_ptr, &p_ptr->publ.lock);
if (!ref) { if (!ref) {
warn("Port creation failed, reference table exhausted\n"); warn("Port creation failed, reference table exhausted\n");
kfree(p_ptr); kfree(p_ptr);
return 0; return NULL;
} }
p_ptr->publ.usr_handle = usr_handle; 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); INIT_LIST_HEAD(&p_ptr->port_list);
list_add_tail(&p_ptr->port_list, &ports); list_add_tail(&p_ptr->port_list, &ports);
spin_unlock_bh(&tipc_port_list_lock); spin_unlock_bh(&tipc_port_list_lock);
*tp_ptr = &p_ptr->publ; return &(p_ptr->publ);
return ref;
} }
int tipc_deleteport(u32 ref) int tipc_deleteport(u32 ref)
@ -1044,21 +1040,18 @@ int tipc_createport(u32 user_ref,
{ {
struct user_port *up_ptr; struct user_port *up_ptr;
struct port *p_ptr; struct port *p_ptr;
struct tipc_port *tp_ptr;
u32 ref;
up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC); up_ptr = kmalloc(sizeof(*up_ptr), GFP_ATOMIC);
if (!up_ptr) { if (!up_ptr) {
warn("Port creation failed, no memory\n"); warn("Port creation failed, no memory\n");
return -ENOMEM; return -ENOMEM;
} }
ref = tipc_createport_raw(NULL, port_dispatcher, port_wakeup, p_ptr = (struct port *)tipc_createport_raw(NULL, port_dispatcher,
importance, &tp_ptr); port_wakeup, importance);
if (ref == 0) { if (!p_ptr) {
kfree(up_ptr); kfree(up_ptr);
return -ENOMEM; return -ENOMEM;
} }
p_ptr = (struct port *)tp_ptr;
p_ptr->user_port = up_ptr; p_ptr->user_port = up_ptr;
up_ptr->user_ref = user_ref; up_ptr->user_ref = user_ref;
@ -1074,7 +1067,6 @@ int tipc_createport(u32 user_ref,
INIT_LIST_HEAD(&up_ptr->uport_list); INIT_LIST_HEAD(&up_ptr->uport_list);
tipc_reg_add_port(up_ptr); tipc_reg_add_port(up_ptr);
*portref = p_ptr->publ.ref; *portref = p_ptr->publ.ref;
dbg(" tipc_createport: %x with ref %u\n", p_ptr, p_ptr->publ.ref);
tipc_port_unlock(p_ptr); tipc_port_unlock(p_ptr);
return TIPC_OK; return TIPC_OK;
} }

Просмотреть файл

@ -2,7 +2,7 @@
* net/tipc/socket.c: TIPC socket API * net/tipc/socket.c: TIPC socket API
* *
* Copyright (c) 2001-2007, Ericsson AB * Copyright (c) 2001-2007, Ericsson AB
* Copyright (c) 2004-2007, Wind River Systems * Copyright (c) 2004-2008, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -189,7 +189,6 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol)
socket_state state; socket_state state;
struct sock *sk; struct sock *sk;
struct tipc_port *tp_ptr; struct tipc_port *tp_ptr;
u32 portref;
/* Validate arguments */ /* Validate arguments */
@ -225,9 +224,9 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol)
/* Allocate TIPC port for socket to use */ /* Allocate TIPC port for socket to use */
portref = tipc_createport_raw(sk, &dispatch, &wakeupdispatch, tp_ptr = tipc_createport_raw(sk, &dispatch, &wakeupdispatch,
TIPC_LOW_IMPORTANCE, &tp_ptr); TIPC_LOW_IMPORTANCE);
if (unlikely(portref == 0)) { if (unlikely(!tp_ptr)) {
sk_free(sk); sk_free(sk);
return -ENOMEM; return -ENOMEM;
} }
@ -240,14 +239,14 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol)
sock_init_data(sock, sk); sock_init_data(sock, sk);
sk->sk_rcvtimeo = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT); sk->sk_rcvtimeo = msecs_to_jiffies(CONN_TIMEOUT_DEFAULT);
sk->sk_backlog_rcv = backlog_rcv; sk->sk_backlog_rcv = backlog_rcv;
tipc_sk(sk)->p = tipc_get_port(portref); tipc_sk(sk)->p = tp_ptr;
spin_unlock_bh(tp_ptr->lock); spin_unlock_bh(tp_ptr->lock);
if (sock->state == SS_READY) { if (sock->state == SS_READY) {
tipc_set_portunreturnable(portref, 1); tipc_set_portunreturnable(tp_ptr->ref, 1);
if (sock->type == SOCK_DGRAM) if (sock->type == SOCK_DGRAM)
tipc_set_portunreliable(portref, 1); tipc_set_portunreliable(tp_ptr->ref, 1);
} }
atomic_inc(&tipc_user_count); atomic_inc(&tipc_user_count);