]> rtime.felk.cvut.cz Git - socketcan-devel.git/blobdiff - kernel/2.6/net/can/isotp.c
Add missinf includes for tasklet usage.
[socketcan-devel.git] / kernel / 2.6 / net / can / isotp.c
index 4d7f98b0e6ffae9b2f81c4e1cbb4e230c87198b3..f15f788a34d113e42efd8732fa3c858e297cb2ed 100644 (file)
@@ -54,6 +54,8 @@
 #include <linux/module.h>
 #include <linux/version.h>
 #include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/hrtimer.h>
 #include <linux/wait.h>
 #include <linux/uio.h>
 #include <linux/net.h>
@@ -132,7 +134,7 @@ struct isotp_sock {
        canid_t txid;
        canid_t rxid;
        ktime_t tx_gap;
-       ktime_t last_cf_tstamp;
+       ktime_t lastrxcf_tstamp;
        struct hrtimer rxtimer, txtimer;
        struct tasklet_struct txtsklet;
        struct can_isotp_options opt;
@@ -214,6 +216,9 @@ static int isotp_send_fc(struct sock *sk, int ae)
        /* reset blocksize counter */
        so->rx.bs = 0;
 
+       /* reset last CF frame rx timestamp for rx stmin enforcement */
+       so->lastrxcf_tstamp = ktime_set(0,0);
+
        /* start rx timeout watchdog */
        hrtimer_start(&so->rxtimer, ktime_set(1,0), HRTIMER_MODE_REL);
        return 0;
@@ -279,9 +284,6 @@ static int isotp_rcv_fc(struct isotp_sock *so, struct can_frame *cf, int ae)
                    ((so->txfc.stmin < 0xF1) || (so->txfc.stmin > 0xF9)))
                        so->txfc.stmin = 0x7F;
 
-               /* reset CF frame rx timestamp for rx stmin enforcement */
-               so->last_cf_tstamp = ktime_set(0,0);
-
                so->tx_gap = ktime_set(0,0);
                /* add transmission time for CAN frame N_As */
                so->tx_gap = ktime_add_ns(so->tx_gap, so->opt.frame_txtime);
@@ -409,11 +411,11 @@ static int isotp_rcv_cf(struct sock *sk, struct can_frame *cf, int ae,
        /* drop if timestamp gap is less than force_rx_stmin nano secs */
        if (so->opt.flags & CAN_ISOTP_FORCE_RXSTMIN) {
 
-               if (ktime_to_ns(ktime_sub(skb->tstamp, so->last_cf_tstamp)) <
+               if (ktime_to_ns(ktime_sub(skb->tstamp, so->lastrxcf_tstamp)) <
                    so->force_rx_stmin)
                        return 0;
 
-               so->last_cf_tstamp = skb->tstamp; 
+               so->lastrxcf_tstamp = skb->tstamp; 
        }
 
        hrtimer_cancel(&so->rxtimer);
@@ -795,7 +797,12 @@ static int isotp_recvmsg(struct kiocb *iocb, struct socket *sock,
 static int isotp_release(struct socket *sock)
 {
        struct sock *sk = sock->sk;
-       struct isotp_sock *so = isotp_sk(sk);
+       struct isotp_sock *so;
+
+       if (!sk)
+               return 0;
+
+       so = isotp_sk(sk);
 
        /* wait for complete transmission of current pdu */
        wait_event_interruptible(so->wait, so->tx.state == ISOTP_IDLE);
@@ -1126,7 +1133,7 @@ static int isotp_init(struct sock *sk)
 }
 
 
-static struct proto_ops isotp_ops __read_mostly = {
+static const struct proto_ops isotp_ops = {
        .family        = PF_CAN,
        .release       = isotp_release,
        .bind          = isotp_bind,
@@ -1135,7 +1142,7 @@ static struct proto_ops isotp_ops __read_mostly = {
        .accept        = sock_no_accept,
        .getname       = isotp_getname,
        .poll          = datagram_poll,
-       .ioctl         = NULL,          /* use can_ioctl() from af_can.c */
+       .ioctl         = can_ioctl,     /* use can_ioctl() from af_can.c */
        .listen        = sock_no_listen,
        .shutdown      = sock_no_shutdown,
        .setsockopt    = isotp_setsockopt,
@@ -1153,10 +1160,12 @@ static struct proto isotp_proto __read_mostly = {
        .init       = isotp_init,
 };
 
-static struct can_proto isotp_can_proto __read_mostly = {
+static const struct can_proto isotp_can_proto = {
        .type       = SOCK_DGRAM,
        .protocol   = CAN_ISOTP,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
        .capability = -1,
+#endif
        .ops        = &isotp_ops,
        .prot       = &isotp_proto,
 };