[PATCH] sata_sil: update device hotplug handling, take #2
[powerpc.git] / net / tipc / subscr.c
index 6f651a2..c5f026c 100644 (file)
@@ -1,33 +1,36 @@
 /*
  * net/tipc/subscr.c: TIPC subscription service
  * 
- * Copyright (c) 2003-2005, Ericsson Research Canada
+ * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2005, Wind River Systems
- * Copyright (c) 2005-2006, Ericsson AB
  * 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
  * modification, are permitted provided that the following conditions are met:
  *
- * Redistributions of source code must retain the above copyright notice, this 
- * list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, 
- * this list of conditions and the following disclaimer in the documentation 
- * and/or other materials provided with the distribution.
- * Neither the names of the copyright holders nor the names of its 
- * contributors may be used to endorse or promote products derived from this 
- * software without specific prior written permission.
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the names of the copyright holders nor the names of its
+ *    contributors may be used to endorse or promote products derived from
+ *    this software without specific prior written permission.
  *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
+ * Alternatively, this software may be distributed under the terms of the
+ * GNU General Public License ("GPL") version 2 as published by the Free
+ * Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
@@ -83,7 +86,7 @@ static struct top_srv topsrv = { 0 };
  * Returns converted value
  */
 
-static inline u32 htohl(u32 in, int swap)
+static u32 htohl(u32 in, int swap)
 {
        char *c = (char *)∈
 
@@ -115,14 +118,14 @@ static void subscr_send_event(struct subscription *sub,
 }
 
 /**
- * subscr_overlap - test for subscription overlap with the given values
+ * tipc_subscr_overlap - test for subscription overlap with the given values
  *
  * Returns 1 if there is overlap, otherwise 0.
  */
 
-int subscr_overlap(struct subscription *sub, 
-                  u32 found_lower, 
-                  u32 found_upper)
+int tipc_subscr_overlap(struct subscription *sub, 
+                       u32 found_lower, 
+                       u32 found_upper)
 
 {
        if (found_lower < sub->seq.lower)
@@ -135,22 +138,22 @@ int subscr_overlap(struct subscription *sub,
 }
 
 /**
- * subscr_report_overlap - issue event if there is subscription overlap
+ * tipc_subscr_report_overlap - issue event if there is subscription overlap
  * 
  * Protected by nameseq.lock in name_table.c
  */
 
-void subscr_report_overlap(struct subscription *sub, 
-                          u32 found_lower, 
-                          u32 found_upper,
-                          u32 event, 
-                          u32 port_ref, 
-                          u32 node,
-                          int must)
+void tipc_subscr_report_overlap(struct subscription *sub, 
+                               u32 found_lower, 
+                               u32 found_upper,
+                               u32 event, 
+                               u32 port_ref, 
+                               u32 node,
+                               int must)
 {
        dbg("Rep overlap %u:%u,%u<->%u,%u\n", sub->seq.type, sub->seq.lower,
            sub->seq.upper, found_lower, found_upper);
-       if (!subscr_overlap(sub, found_lower, found_upper))
+       if (!tipc_subscr_overlap(sub, found_lower, found_upper))
                return;
        if (!must && (sub->filter != TIPC_SUB_PORTS))
                return;
@@ -169,13 +172,13 @@ static void subscr_timeout(struct subscription *sub)
        /* Validate subscriber reference (in case subscriber is terminating) */
 
        subscriber_ref = sub->owner->ref;
-       subscriber = (struct subscriber *)ref_lock(subscriber_ref);
+       subscriber = (struct subscriber *)tipc_ref_lock(subscriber_ref);
        if (subscriber == NULL)
                return;
 
        /* Unlink subscription from name table */
 
-       nametbl_unsubscribe(sub);
+       tipc_nametbl_unsubscribe(sub);
 
        /* Notify subscriber of timeout, then unlink subscription */
 
@@ -189,7 +192,7 @@ static void subscr_timeout(struct subscription *sub)
 
        /* Now destroy subscription */
 
-       ref_unlock(subscriber_ref);
+       tipc_ref_unlock(subscriber_ref);
        k_term_timer(&sub->timer);
        kfree(sub);
        atomic_dec(&topsrv.subscription_count);
@@ -213,7 +216,7 @@ static void subscr_terminate(struct subscriber *subscriber)
 
        /* Invalidate subscriber reference */
 
-       ref_discard(subscriber->ref);
+       tipc_ref_discard(subscriber->ref);
        spin_unlock_bh(subscriber->lock);
 
        /* Destroy any existing subscriptions for subscriber */
@@ -224,7 +227,7 @@ static void subscr_terminate(struct subscriber *subscriber)
                        k_cancel_timer(&sub->timer);
                        k_term_timer(&sub->timer);
                }
-               nametbl_unsubscribe(sub);
+               tipc_nametbl_unsubscribe(sub);
                list_del(&sub->subscription_list);
                dbg("Term: Removed sub %u,%u,%u from subscriber %x list\n",
                    sub->seq.type, sub->seq.lower, sub->seq.upper, subscriber);
@@ -312,7 +315,7 @@ static void subscr_subscribe(struct tipc_subscr *s,
                k_start_timer(&sub->timer, sub->timeout);
        }
        sub->owner = subscriber;
-       nametbl_subscribe(sub);
+       tipc_nametbl_subscribe(sub);
 }
 
 /**
@@ -326,9 +329,10 @@ static void subscr_conn_shutdown_event(void *usr_handle,
                                       unsigned int size,
                                       int reason)
 {
-       struct subscriber *subscriber = ref_lock((u32)usr_handle);
+       struct subscriber *subscriber;
        spinlock_t *subscriber_lock;
 
+       subscriber = tipc_ref_lock((u32)(unsigned long)usr_handle);
        if (subscriber == NULL)
                return;
 
@@ -347,9 +351,10 @@ static void subscr_conn_msg_event(void *usr_handle,
                                  const unchar *data,
                                  u32 size)
 {
-       struct subscriber *subscriber = ref_lock((u32)usr_handle);
+       struct subscriber *subscriber;
        spinlock_t *subscriber_lock;
 
+       subscriber = tipc_ref_lock((u32)(unsigned long)usr_handle);
        if (subscriber == NULL)
                return;
 
@@ -376,7 +381,7 @@ static void subscr_named_msg_event(void *usr_handle,
                                   struct tipc_name_seq const *dest)
 {
        struct subscriber *subscriber;
-       struct iovec msg_sect = {0, 0};
+       struct iovec msg_sect = {NULL, 0};
        spinlock_t *subscriber_lock;
 
        dbg("subscr_named_msg_event: orig = %x own = %x,\n",
@@ -396,7 +401,7 @@ static void subscr_named_msg_event(void *usr_handle,
        memset(subscriber, 0, sizeof(struct subscriber));
        INIT_LIST_HEAD(&subscriber->subscription_list);
        INIT_LIST_HEAD(&subscriber->subscriber_list);
-       subscriber->ref = ref_acquire(subscriber, &subscriber->lock);
+       subscriber->ref = tipc_ref_acquire(subscriber, &subscriber->lock);
        if (subscriber->ref == 0) {
                warn("Failed to acquire subscriber reference\n");
                kfree(subscriber);
@@ -406,19 +411,19 @@ static void subscr_named_msg_event(void *usr_handle,
        /* Establish a connection to subscriber */
 
        tipc_createport(topsrv.user_ref,
-                       (void *)subscriber->ref,
+                       (void *)(unsigned long)subscriber->ref,
                        importance,
-                       0,
-                       0,
+                       NULL,
+                       NULL,
                        subscr_conn_shutdown_event,
-                       0,
-                       0,
+                       NULL,
+                       NULL,
                        subscr_conn_msg_event,
-                       0,
+                       NULL,
                        &subscriber->port_ref);
        if (subscriber->port_ref == 0) {
                warn("Memory squeeze; failed to create subscription port\n");
-               ref_discard(subscriber->ref);
+               tipc_ref_discard(subscriber->ref);
                kfree(subscriber);
                return;
        }
@@ -427,7 +432,7 @@ static void subscr_named_msg_event(void *usr_handle,
 
        /* Add subscriber to topology server's subscriber list */
 
-       ref_lock(subscriber->ref);
+       tipc_ref_lock(subscriber->ref);
        spin_lock_bh(&topsrv.lock);
        list_add(&subscriber->subscriber_list, &topsrv.subscriber_list);
        spin_unlock_bh(&topsrv.lock);
@@ -446,7 +451,7 @@ static void subscr_named_msg_event(void *usr_handle,
        spin_unlock_bh(subscriber_lock);
 }
 
-int subscr_start(void)
+int tipc_subscr_start(void)
 {
        struct tipc_name_seq seq = {TIPC_TOP_SRV, TIPC_TOP_SRV, TIPC_TOP_SRV};
        int res = -1;
@@ -456,27 +461,27 @@ int subscr_start(void)
        INIT_LIST_HEAD(&topsrv.subscriber_list);
 
        spin_lock_bh(&topsrv.lock);
-       res = tipc_attach(&topsrv.user_ref, 0, 0);
+       res = tipc_attach(&topsrv.user_ref, NULL, NULL);
        if (res) {
                spin_unlock_bh(&topsrv.lock);
                return res;
        }
 
        res = tipc_createport(topsrv.user_ref,
-                             0,
+                             NULL,
                              TIPC_CRITICAL_IMPORTANCE,
-                             0,
-                             0,
-                             0,
-                             0,
+                             NULL,
+                             NULL,
+                             NULL,
+                             NULL,
                              subscr_named_msg_event,
-                             0,
-                             0,
+                             NULL,
+                             NULL,
                              &topsrv.setup_port);
        if (res)
                goto failed;
 
-       res = nametbl_publish_rsv(topsrv.setup_port, TIPC_NODE_SCOPE, &seq);
+       res = tipc_nametbl_publish_rsv(topsrv.setup_port, TIPC_NODE_SCOPE, &seq);
        if (res)
                goto failed;
 
@@ -484,14 +489,14 @@ int subscr_start(void)
        return 0;
 
 failed:
-       err("Unable to create subscription service\n");
+       err("Failed to create subscription service\n");
        tipc_detach(topsrv.user_ref);
        topsrv.user_ref = 0;
        spin_unlock_bh(&topsrv.lock);
        return res;
 }
 
-void subscr_stop(void)
+void tipc_subscr_stop(void)
 {
        struct subscriber *subscriber;
        struct subscriber *subscriber_temp;
@@ -502,7 +507,7 @@ void subscr_stop(void)
                list_for_each_entry_safe(subscriber, subscriber_temp, 
                                         &topsrv.subscriber_list,
                                         subscriber_list) {
-                       ref_lock(subscriber->ref);
+                       tipc_ref_lock(subscriber->ref);
                        subscriber_lock = subscriber->lock;
                        subscr_terminate(subscriber);
                        spin_unlock_bh(subscriber_lock);
@@ -517,6 +522,6 @@ int tipc_ispublished(struct tipc_name const *name)
 {
        u32 domain = 0;
 
-       return(nametbl_translate(name->type, name->instance,&domain) != 0);
+       return(tipc_nametbl_translate(name->type, name->instance,&domain) != 0);
 }