net/atm/lec.c: checkpatch cleanups
[safe/jmp/linux-2.6] / net / llc / llc_c_ac.c
index 8f7b46d..019c780 100644 (file)
@@ -27,7 +27,6 @@
 #include <net/llc_pdu.h>
 #include <net/llc.h>
 
-#include "llc_output.h"
 
 static int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb);
 static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb);
@@ -60,24 +59,10 @@ int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb)
 
 int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb)
 {
-       int rc = -ENOTCONN;
-       u8 dsap;
-       struct llc_sap *sap;
-
-       llc_pdu_decode_dsap(skb, &dsap);
-       sap = llc_sap_find(dsap);
-       if (sap) {
-               struct llc_conn_state_ev *ev = llc_conn_ev(skb);
-               struct llc_sock *llc = llc_sk(sk);
+       struct llc_conn_state_ev *ev = llc_conn_ev(skb);
 
-               llc_pdu_decode_sa(skb, llc->daddr.mac);
-               llc_pdu_decode_da(skb, llc->laddr.mac);
-               llc->dev = skb->dev;
-               ev->ind_prim = LLC_CONN_PRIM;
-               rc = 0;
-               llc_sap_put(sap);
-       }
-       return rc;
+       ev->ind_prim = LLC_CONN_PRIM;
+       return 0;
 }
 
 int llc_conn_ac_conn_confirm(struct sock *sk, struct sk_buff *skb)
@@ -213,7 +198,7 @@ int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -238,7 +223,7 @@ int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -264,7 +249,7 @@ int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -297,7 +282,8 @@ int llc_conn_ac_send_frmr_rsp_f_set_x(struct sock *sk, struct sk_buff *skb)
                llc_pdu_decode_pf_bit(skb, &f_bit);
        else
                f_bit = 0;
-       nskb = llc_alloc_frame(llc->dev);
+       nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
+                              sizeof(struct llc_frmr_info));
        if (nskb) {
                struct llc_sap *sap = llc->sap;
 
@@ -321,7 +307,8 @@ int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
+                                              sizeof(struct llc_frmr_info));
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -351,7 +338,8 @@ int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
        struct llc_sock *llc = llc_sk(sk);
 
        llc_pdu_decode_pf_bit(skb, &f_bit);
-       nskb = llc_alloc_frame(llc->dev);
+       nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
+                              sizeof(struct llc_frmr_info));
        if (nskb) {
                struct llc_sap *sap = llc->sap;
                struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
@@ -439,7 +427,7 @@ int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk,
        struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -474,7 +462,7 @@ int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -498,7 +486,7 @@ int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -522,7 +510,7 @@ int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -546,7 +534,7 @@ int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -570,7 +558,7 @@ int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -594,7 +582,7 @@ int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -630,7 +618,7 @@ int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -654,7 +642,7 @@ int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -678,7 +666,7 @@ int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -703,7 +691,7 @@ int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -727,7 +715,7 @@ int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -751,7 +739,7 @@ int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -785,7 +773,7 @@ int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -814,7 +802,7 @@ int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
        u8 f_bit;
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        llc_pdu_decode_pf_bit(skb, &f_bit);
        if (nskb) {
@@ -880,7 +868,8 @@ int llc_conn_ac_send_ack_if_needed(struct sock *sk, struct sk_buff *skb)
                llc->ack_must_be_send = 1;
                llc->ack_pf = pf_bit & 1;
        }
-       if (((llc->vR - llc->first_pdu_Ns + 129) % 128) >= llc->npta) {
+       if (((llc->vR - llc->first_pdu_Ns + 1 + LLC_2_SEQ_NBR_MODULO)
+                       % LLC_2_SEQ_NBR_MODULO) >= llc->npta) {
                llc_conn_ac_send_rr_rsp_f_set_ackpf(sk, skb);
                llc->ack_must_be_send   = 0;
                llc->ack_pf             = 0;
@@ -970,7 +959,7 @@ static int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk,
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -1008,8 +997,8 @@ static int llc_conn_ac_inc_npta_value(struct sock *sk, struct sk_buff *skb)
                llc->dec_step = 0;
                llc->dec_cntr = llc->inc_cntr = 2;
                ++llc->npta;
-               if (llc->npta > 127)
-                       llc->npta = 127 ;
+               if (llc->npta > (u8) ~LLC_2_SEQ_NBR_MODULO)
+                       llc->npta = (u8) ~LLC_2_SEQ_NBR_MODULO;
        } else
                --llc->inc_cntr;
        return 0;
@@ -1079,9 +1068,10 @@ int llc_conn_ac_dec_tx_win_size(struct sock *sk, struct sk_buff *skb)
        struct llc_sock *llc = llc_sk(sk);
        u8 unacked_pdu = skb_queue_len(&llc->pdu_unack_q);
 
-       llc->k -= unacked_pdu;
-       if (llc->k < 2)
-               llc->k = 2;
+       if (llc->k - unacked_pdu < 1)
+               llc->k = 1;
+       else
+               llc->k -= unacked_pdu;
        return 0;
 }
 
@@ -1098,8 +1088,8 @@ int llc_conn_ac_inc_tx_win_size(struct sock *sk, struct sk_buff *skb)
        struct llc_sock *llc = llc_sk(sk);
 
        llc->k += 1;
-       if (llc->k > 128)
-               llc->k = 128 ;
+       if (llc->k > (u8) ~LLC_2_SEQ_NBR_MODULO)
+               llc->k = (u8) ~LLC_2_SEQ_NBR_MODULO;
        return 0;
 }
 
@@ -1323,7 +1313,7 @@ int llc_conn_ac_set_vs_nr(struct sock *sk, struct sk_buff *skb)
 
 static int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb)
 {
-       llc_sk(sk)->vS = (llc_sk(sk)->vS + 1) % 128;
+       llc_sk(sk)->vS = (llc_sk(sk)->vS + 1) % LLC_2_SEQ_NBR_MODULO;
        return 0;
 }
 
@@ -1440,7 +1430,7 @@ static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb)
 {
        if (llc_sk(sk)->state == LLC_CONN_OUT_OF_SVC) {
                printk(KERN_WARNING "%s: timer called on closed connection\n",
-                      __FUNCTION__);
+                      __func__);
                kfree_skb(skb);
        } else {
                if (!sock_owned_by_user(sk))