aboutsummaryrefslogtreecommitdiffstats
path: root/net/irda
diff options
context:
space:
mode:
Diffstat (limited to 'net/irda')
-rw-r--r--net/irda/af_irda.c341
-rw-r--r--net/irda/discovery.c1
-rw-r--r--net/irda/ircomm/ircomm_core.c1
-rw-r--r--net/irda/ircomm/ircomm_lmp.c1
-rw-r--r--net/irda/ircomm/ircomm_param.c1
-rw-r--r--net/irda/ircomm/ircomm_tty.c7
-rw-r--r--net/irda/irda_device.c1
-rw-r--r--net/irda/iriap.c1
-rw-r--r--net/irda/iriap_event.c2
-rw-r--r--net/irda/irias_object.c1
-rw-r--r--net/irda/irlan/irlan_client.c1
-rw-r--r--net/irda/irlan/irlan_common.c29
-rw-r--r--net/irda/irlan/irlan_eth.c5
-rw-r--r--net/irda/irlan/irlan_provider.c1
-rw-r--r--net/irda/irlap.c14
-rw-r--r--net/irda/irlap_event.c3
-rw-r--r--net/irda/irlap_frame.c1
-rw-r--r--net/irda/irlmp.c4
-rw-r--r--net/irda/irnet/irnet.h1
-rw-r--r--net/irda/irnet/irnet_irda.c5
-rw-r--r--net/irda/irnet/irnet_ppp.c14
-rw-r--r--net/irda/irnetlink.c3
-rw-r--r--net/irda/irqueue.c1
-rw-r--r--net/irda/irsysctl.c31
-rw-r--r--net/irda/irttp.c1
25 files changed, 281 insertions, 190 deletions
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index dd35641835f4..2a4efcea3423 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -48,6 +48,7 @@
48#include <linux/smp_lock.h> 48#include <linux/smp_lock.h>
49#include <linux/socket.h> 49#include <linux/socket.h>
50#include <linux/sockios.h> 50#include <linux/sockios.h>
51#include <linux/slab.h>
51#include <linux/init.h> 52#include <linux/init.h>
52#include <linux/net.h> 53#include <linux/net.h>
53#include <linux/irda.h> 54#include <linux/irda.h>
@@ -61,7 +62,7 @@
61 62
62#include <net/irda/af_irda.h> 63#include <net/irda/af_irda.h>
63 64
64static int irda_create(struct net *net, struct socket *sock, int protocol); 65static int irda_create(struct net *net, struct socket *sock, int protocol, int kern);
65 66
66static const struct proto_ops irda_stream_ops; 67static const struct proto_ops irda_stream_ops;
67static const struct proto_ops irda_seqpacket_ops; 68static const struct proto_ops irda_seqpacket_ops;
@@ -714,11 +715,14 @@ static int irda_getname(struct socket *sock, struct sockaddr *uaddr,
714 struct sockaddr_irda saddr; 715 struct sockaddr_irda saddr;
715 struct sock *sk = sock->sk; 716 struct sock *sk = sock->sk;
716 struct irda_sock *self = irda_sk(sk); 717 struct irda_sock *self = irda_sk(sk);
718 int err;
717 719
720 lock_kernel();
718 memset(&saddr, 0, sizeof(saddr)); 721 memset(&saddr, 0, sizeof(saddr));
719 if (peer) { 722 if (peer) {
723 err = -ENOTCONN;
720 if (sk->sk_state != TCP_ESTABLISHED) 724 if (sk->sk_state != TCP_ESTABLISHED)
721 return -ENOTCONN; 725 goto out;
722 726
723 saddr.sir_family = AF_IRDA; 727 saddr.sir_family = AF_IRDA;
724 saddr.sir_lsap_sel = self->dtsap_sel; 728 saddr.sir_lsap_sel = self->dtsap_sel;
@@ -735,8 +739,10 @@ static int irda_getname(struct socket *sock, struct sockaddr *uaddr,
735 /* uaddr_len come to us uninitialised */ 739 /* uaddr_len come to us uninitialised */
736 *uaddr_len = sizeof (struct sockaddr_irda); 740 *uaddr_len = sizeof (struct sockaddr_irda);
737 memcpy(uaddr, &saddr, *uaddr_len); 741 memcpy(uaddr, &saddr, *uaddr_len);
738 742 err = 0;
739 return 0; 743out:
744 unlock_kernel();
745 return err;
740} 746}
741 747
742/* 748/*
@@ -748,21 +754,25 @@ static int irda_getname(struct socket *sock, struct sockaddr *uaddr,
748static int irda_listen(struct socket *sock, int backlog) 754static int irda_listen(struct socket *sock, int backlog)
749{ 755{
750 struct sock *sk = sock->sk; 756 struct sock *sk = sock->sk;
757 int err = -EOPNOTSUPP;
751 758
752 IRDA_DEBUG(2, "%s()\n", __func__); 759 IRDA_DEBUG(2, "%s()\n", __func__);
753 760
761 lock_kernel();
754 if ((sk->sk_type != SOCK_STREAM) && (sk->sk_type != SOCK_SEQPACKET) && 762 if ((sk->sk_type != SOCK_STREAM) && (sk->sk_type != SOCK_SEQPACKET) &&
755 (sk->sk_type != SOCK_DGRAM)) 763 (sk->sk_type != SOCK_DGRAM))
756 return -EOPNOTSUPP; 764 goto out;
757 765
758 if (sk->sk_state != TCP_LISTEN) { 766 if (sk->sk_state != TCP_LISTEN) {
759 sk->sk_max_ack_backlog = backlog; 767 sk->sk_max_ack_backlog = backlog;
760 sk->sk_state = TCP_LISTEN; 768 sk->sk_state = TCP_LISTEN;
761 769
762 return 0; 770 err = 0;
763 } 771 }
772out:
773 unlock_kernel();
764 774
765 return -EOPNOTSUPP; 775 return err;
766} 776}
767 777
768/* 778/*
@@ -783,36 +793,40 @@ static int irda_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
783 if (addr_len != sizeof(struct sockaddr_irda)) 793 if (addr_len != sizeof(struct sockaddr_irda))
784 return -EINVAL; 794 return -EINVAL;
785 795
796 lock_kernel();
786#ifdef CONFIG_IRDA_ULTRA 797#ifdef CONFIG_IRDA_ULTRA
787 /* Special care for Ultra sockets */ 798 /* Special care for Ultra sockets */
788 if ((sk->sk_type == SOCK_DGRAM) && 799 if ((sk->sk_type == SOCK_DGRAM) &&
789 (sk->sk_protocol == IRDAPROTO_ULTRA)) { 800 (sk->sk_protocol == IRDAPROTO_ULTRA)) {
790 self->pid = addr->sir_lsap_sel; 801 self->pid = addr->sir_lsap_sel;
802 err = -EOPNOTSUPP;
791 if (self->pid & 0x80) { 803 if (self->pid & 0x80) {
792 IRDA_DEBUG(0, "%s(), extension in PID not supp!\n", __func__); 804 IRDA_DEBUG(0, "%s(), extension in PID not supp!\n", __func__);
793 return -EOPNOTSUPP; 805 goto out;
794 } 806 }
795 err = irda_open_lsap(self, self->pid); 807 err = irda_open_lsap(self, self->pid);
796 if (err < 0) 808 if (err < 0)
797 return err; 809 goto out;
798 810
799 /* Pretend we are connected */ 811 /* Pretend we are connected */
800 sock->state = SS_CONNECTED; 812 sock->state = SS_CONNECTED;
801 sk->sk_state = TCP_ESTABLISHED; 813 sk->sk_state = TCP_ESTABLISHED;
814 err = 0;
802 815
803 return 0; 816 goto out;
804 } 817 }
805#endif /* CONFIG_IRDA_ULTRA */ 818#endif /* CONFIG_IRDA_ULTRA */
806 819
807 self->ias_obj = irias_new_object(addr->sir_name, jiffies); 820 self->ias_obj = irias_new_object(addr->sir_name, jiffies);
821 err = -ENOMEM;
808 if (self->ias_obj == NULL) 822 if (self->ias_obj == NULL)
809 return -ENOMEM; 823 goto out;
810 824
811 err = irda_open_tsap(self, addr->sir_lsap_sel, addr->sir_name); 825 err = irda_open_tsap(self, addr->sir_lsap_sel, addr->sir_name);
812 if (err < 0) { 826 if (err < 0) {
813 kfree(self->ias_obj->name); 827 kfree(self->ias_obj->name);
814 kfree(self->ias_obj); 828 kfree(self->ias_obj);
815 return err; 829 goto out;
816 } 830 }
817 831
818 /* Register with LM-IAS */ 832 /* Register with LM-IAS */
@@ -820,7 +834,10 @@ static int irda_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
820 self->stsap_sel, IAS_KERNEL_ATTR); 834 self->stsap_sel, IAS_KERNEL_ATTR);
821 irias_insert_object(self->ias_obj); 835 irias_insert_object(self->ias_obj);
822 836
823 return 0; 837 err = 0;
838out:
839 unlock_kernel();
840 return err;
824} 841}
825 842
826/* 843/*
@@ -839,22 +856,26 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
839 856
840 IRDA_DEBUG(2, "%s()\n", __func__); 857 IRDA_DEBUG(2, "%s()\n", __func__);
841 858
842 err = irda_create(sock_net(sk), newsock, sk->sk_protocol); 859 lock_kernel();
860 err = irda_create(sock_net(sk), newsock, sk->sk_protocol, 0);
843 if (err) 861 if (err)
844 return err; 862 goto out;
845 863
864 err = -EINVAL;
846 if (sock->state != SS_UNCONNECTED) 865 if (sock->state != SS_UNCONNECTED)
847 return -EINVAL; 866 goto out;
848 867
849 if ((sk = sock->sk) == NULL) 868 if ((sk = sock->sk) == NULL)
850 return -EINVAL; 869 goto out;
851 870
871 err = -EOPNOTSUPP;
852 if ((sk->sk_type != SOCK_STREAM) && (sk->sk_type != SOCK_SEQPACKET) && 872 if ((sk->sk_type != SOCK_STREAM) && (sk->sk_type != SOCK_SEQPACKET) &&
853 (sk->sk_type != SOCK_DGRAM)) 873 (sk->sk_type != SOCK_DGRAM))
854 return -EOPNOTSUPP; 874 goto out;
855 875
876 err = -EINVAL;
856 if (sk->sk_state != TCP_LISTEN) 877 if (sk->sk_state != TCP_LISTEN)
857 return -EINVAL; 878 goto out;
858 879
859 /* 880 /*
860 * The read queue this time is holding sockets ready to use 881 * The read queue this time is holding sockets ready to use
@@ -875,18 +896,20 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
875 break; 896 break;
876 897
877 /* Non blocking operation */ 898 /* Non blocking operation */
899 err = -EWOULDBLOCK;
878 if (flags & O_NONBLOCK) 900 if (flags & O_NONBLOCK)
879 return -EWOULDBLOCK; 901 goto out;
880 902
881 err = wait_event_interruptible(*(sk->sk_sleep), 903 err = wait_event_interruptible(*(sk->sk_sleep),
882 skb_peek(&sk->sk_receive_queue)); 904 skb_peek(&sk->sk_receive_queue));
883 if (err) 905 if (err)
884 return err; 906 goto out;
885 } 907 }
886 908
887 newsk = newsock->sk; 909 newsk = newsock->sk;
910 err = -EIO;
888 if (newsk == NULL) 911 if (newsk == NULL)
889 return -EIO; 912 goto out;
890 913
891 newsk->sk_state = TCP_ESTABLISHED; 914 newsk->sk_state = TCP_ESTABLISHED;
892 915
@@ -894,10 +917,11 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
894 917
895 /* Now attach up the new socket */ 918 /* Now attach up the new socket */
896 new->tsap = irttp_dup(self->tsap, new); 919 new->tsap = irttp_dup(self->tsap, new);
920 err = -EPERM; /* value does not seem to make sense. -arnd */
897 if (!new->tsap) { 921 if (!new->tsap) {
898 IRDA_DEBUG(0, "%s(), dup failed!\n", __func__); 922 IRDA_DEBUG(0, "%s(), dup failed!\n", __func__);
899 kfree_skb(skb); 923 kfree_skb(skb);
900 return -1; 924 goto out;
901 } 925 }
902 926
903 new->stsap_sel = new->tsap->stsap_sel; 927 new->stsap_sel = new->tsap->stsap_sel;
@@ -921,8 +945,10 @@ static int irda_accept(struct socket *sock, struct socket *newsock, int flags)
921 newsock->state = SS_CONNECTED; 945 newsock->state = SS_CONNECTED;
922 946
923 irda_connect_response(new); 947 irda_connect_response(new);
924 948 err = 0;
925 return 0; 949out:
950 unlock_kernel();
951 return err;
926} 952}
927 953
928/* 954/*
@@ -955,28 +981,34 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr,
955 981
956 IRDA_DEBUG(2, "%s(%p)\n", __func__, self); 982 IRDA_DEBUG(2, "%s(%p)\n", __func__, self);
957 983
984 lock_kernel();
958 /* Don't allow connect for Ultra sockets */ 985 /* Don't allow connect for Ultra sockets */
986 err = -ESOCKTNOSUPPORT;
959 if ((sk->sk_type == SOCK_DGRAM) && (sk->sk_protocol == IRDAPROTO_ULTRA)) 987 if ((sk->sk_type == SOCK_DGRAM) && (sk->sk_protocol == IRDAPROTO_ULTRA))
960 return -ESOCKTNOSUPPORT; 988 goto out;
961 989
962 if (sk->sk_state == TCP_ESTABLISHED && sock->state == SS_CONNECTING) { 990 if (sk->sk_state == TCP_ESTABLISHED && sock->state == SS_CONNECTING) {
963 sock->state = SS_CONNECTED; 991 sock->state = SS_CONNECTED;
964 return 0; /* Connect completed during a ERESTARTSYS event */ 992 err = 0;
993 goto out; /* Connect completed during a ERESTARTSYS event */
965 } 994 }
966 995
967 if (sk->sk_state == TCP_CLOSE && sock->state == SS_CONNECTING) { 996 if (sk->sk_state == TCP_CLOSE && sock->state == SS_CONNECTING) {
968 sock->state = SS_UNCONNECTED; 997 sock->state = SS_UNCONNECTED;
969 return -ECONNREFUSED; 998 err = -ECONNREFUSED;
999 goto out;
970 } 1000 }
971 1001
1002 err = -EISCONN; /* No reconnect on a seqpacket socket */
972 if (sk->sk_state == TCP_ESTABLISHED) 1003 if (sk->sk_state == TCP_ESTABLISHED)
973 return -EISCONN; /* No reconnect on a seqpacket socket */ 1004 goto out;
974 1005
975 sk->sk_state = TCP_CLOSE; 1006 sk->sk_state = TCP_CLOSE;
976 sock->state = SS_UNCONNECTED; 1007 sock->state = SS_UNCONNECTED;
977 1008
1009 err = -EINVAL;
978 if (addr_len != sizeof(struct sockaddr_irda)) 1010 if (addr_len != sizeof(struct sockaddr_irda))
979 return -EINVAL; 1011 goto out;
980 1012
981 /* Check if user supplied any destination device address */ 1013 /* Check if user supplied any destination device address */
982 if ((!addr->sir_addr) || (addr->sir_addr == DEV_ADDR_ANY)) { 1014 if ((!addr->sir_addr) || (addr->sir_addr == DEV_ADDR_ANY)) {
@@ -984,7 +1016,7 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr,
984 err = irda_discover_daddr_and_lsap_sel(self, addr->sir_name); 1016 err = irda_discover_daddr_and_lsap_sel(self, addr->sir_name);
985 if (err) { 1017 if (err) {
986 IRDA_DEBUG(0, "%s(), auto-connect failed!\n", __func__); 1018 IRDA_DEBUG(0, "%s(), auto-connect failed!\n", __func__);
987 return err; 1019 goto out;
988 } 1020 }
989 } else { 1021 } else {
990 /* Use the one provided by the user */ 1022 /* Use the one provided by the user */
@@ -1000,7 +1032,7 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr,
1000 err = irda_find_lsap_sel(self, addr->sir_name); 1032 err = irda_find_lsap_sel(self, addr->sir_name);
1001 if (err) { 1033 if (err) {
1002 IRDA_DEBUG(0, "%s(), connect failed!\n", __func__); 1034 IRDA_DEBUG(0, "%s(), connect failed!\n", __func__);
1003 return err; 1035 goto out;
1004 } 1036 }
1005 } else { 1037 } else {
1006 /* Directly connect to the remote LSAP 1038 /* Directly connect to the remote LSAP
@@ -1025,29 +1057,35 @@ static int irda_connect(struct socket *sock, struct sockaddr *uaddr,
1025 self->max_sdu_size_rx, NULL); 1057 self->max_sdu_size_rx, NULL);
1026 if (err) { 1058 if (err) {
1027 IRDA_DEBUG(0, "%s(), connect failed!\n", __func__); 1059 IRDA_DEBUG(0, "%s(), connect failed!\n", __func__);
1028 return err; 1060 goto out;
1029 } 1061 }
1030 1062
1031 /* Now the loop */ 1063 /* Now the loop */
1064 err = -EINPROGRESS;
1032 if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK)) 1065 if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK))
1033 return -EINPROGRESS; 1066 goto out;
1034 1067
1068 err = -ERESTARTSYS;
1035 if (wait_event_interruptible(*(sk->sk_sleep), 1069 if (wait_event_interruptible(*(sk->sk_sleep),
1036 (sk->sk_state != TCP_SYN_SENT))) 1070 (sk->sk_state != TCP_SYN_SENT)))
1037 return -ERESTARTSYS; 1071 goto out;
1038 1072
1039 if (sk->sk_state != TCP_ESTABLISHED) { 1073 if (sk->sk_state != TCP_ESTABLISHED) {
1040 sock->state = SS_UNCONNECTED; 1074 sock->state = SS_UNCONNECTED;
1041 err = sock_error(sk); 1075 err = sock_error(sk);
1042 return err? err : -ECONNRESET; 1076 if (!err)
1077 err = -ECONNRESET;
1078 goto out;
1043 } 1079 }
1044 1080
1045 sock->state = SS_CONNECTED; 1081 sock->state = SS_CONNECTED;
1046 1082
1047 /* At this point, IrLMP has assigned our source address */ 1083 /* At this point, IrLMP has assigned our source address */
1048 self->saddr = irttp_get_saddr(self->tsap); 1084 self->saddr = irttp_get_saddr(self->tsap);
1049 1085 err = 0;
1050 return 0; 1086out:
1087 unlock_kernel();
1088 return err;
1051} 1089}
1052 1090
1053static struct proto irda_proto = { 1091static struct proto irda_proto = {
@@ -1062,7 +1100,8 @@ static struct proto irda_proto = {
1062 * Create IrDA socket 1100 * Create IrDA socket
1063 * 1101 *
1064 */ 1102 */
1065static int irda_create(struct net *net, struct socket *sock, int protocol) 1103static int irda_create(struct net *net, struct socket *sock, int protocol,
1104 int kern)
1066{ 1105{
1067 struct sock *sk; 1106 struct sock *sk;
1068 struct irda_sock *self; 1107 struct irda_sock *self;
@@ -1192,6 +1231,7 @@ static int irda_release(struct socket *sock)
1192 if (sk == NULL) 1231 if (sk == NULL)
1193 return 0; 1232 return 0;
1194 1233
1234 lock_kernel();
1195 lock_sock(sk); 1235 lock_sock(sk);
1196 sk->sk_state = TCP_CLOSE; 1236 sk->sk_state = TCP_CLOSE;
1197 sk->sk_shutdown |= SEND_SHUTDOWN; 1237 sk->sk_shutdown |= SEND_SHUTDOWN;
@@ -1210,6 +1250,7 @@ static int irda_release(struct socket *sock)
1210 /* Destroy networking socket if we are the last reference on it, 1250 /* Destroy networking socket if we are the last reference on it,
1211 * i.e. if(sk->sk_refcnt == 0) -> sk_free(sk) */ 1251 * i.e. if(sk->sk_refcnt == 0) -> sk_free(sk) */
1212 sock_put(sk); 1252 sock_put(sk);
1253 unlock_kernel();
1213 1254
1214 /* Notes on socket locking and deallocation... - Jean II 1255 /* Notes on socket locking and deallocation... - Jean II
1215 * In theory we should put pairs of sock_hold() / sock_put() to 1256 * In theory we should put pairs of sock_hold() / sock_put() to
@@ -1257,28 +1298,37 @@ static int irda_sendmsg(struct kiocb *iocb, struct socket *sock,
1257 1298
1258 IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len); 1299 IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len);
1259 1300
1301 lock_kernel();
1260 /* Note : socket.c set MSG_EOR on SEQPACKET sockets */ 1302 /* Note : socket.c set MSG_EOR on SEQPACKET sockets */
1261 if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_EOR | MSG_CMSG_COMPAT | 1303 if (msg->msg_flags & ~(MSG_DONTWAIT | MSG_EOR | MSG_CMSG_COMPAT |
1262 MSG_NOSIGNAL)) 1304 MSG_NOSIGNAL)) {
1263 return -EINVAL; 1305 err = -EINVAL;
1306 goto out;
1307 }
1264 1308
1265 if (sk->sk_shutdown & SEND_SHUTDOWN) 1309 if (sk->sk_shutdown & SEND_SHUTDOWN)
1266 goto out_err; 1310 goto out_err;
1267 1311
1268 if (sk->sk_state != TCP_ESTABLISHED) 1312 if (sk->sk_state != TCP_ESTABLISHED) {
1269 return -ENOTCONN; 1313 err = -ENOTCONN;
1314 goto out;
1315 }
1270 1316
1271 self = irda_sk(sk); 1317 self = irda_sk(sk);
1272 1318
1273 /* Check if IrTTP is wants us to slow down */ 1319 /* Check if IrTTP is wants us to slow down */
1274 1320
1275 if (wait_event_interruptible(*(sk->sk_sleep), 1321 if (wait_event_interruptible(*(sk->sk_sleep),
1276 (self->tx_flow != FLOW_STOP || sk->sk_state != TCP_ESTABLISHED))) 1322 (self->tx_flow != FLOW_STOP || sk->sk_state != TCP_ESTABLISHED))) {
1277 return -ERESTARTSYS; 1323 err = -ERESTARTSYS;
1324 goto out;
1325 }
1278 1326
1279 /* Check if we are still connected */ 1327 /* Check if we are still connected */
1280 if (sk->sk_state != TCP_ESTABLISHED) 1328 if (sk->sk_state != TCP_ESTABLISHED) {
1281 return -ENOTCONN; 1329 err = -ENOTCONN;
1330 goto out;
1331 }
1282 1332
1283 /* Check that we don't send out too big frames */ 1333 /* Check that we don't send out too big frames */
1284 if (len > self->max_data_size) { 1334 if (len > self->max_data_size) {
@@ -1310,11 +1360,16 @@ static int irda_sendmsg(struct kiocb *iocb, struct socket *sock,
1310 IRDA_DEBUG(0, "%s(), err=%d\n", __func__, err); 1360 IRDA_DEBUG(0, "%s(), err=%d\n", __func__, err);
1311 goto out_err; 1361 goto out_err;
1312 } 1362 }
1363
1364 unlock_kernel();
1313 /* Tell client how much data we actually sent */ 1365 /* Tell client how much data we actually sent */
1314 return len; 1366 return len;
1315 1367
1316 out_err: 1368out_err:
1317 return sk_stream_error(sk, msg->msg_flags, err); 1369 err = sk_stream_error(sk, msg->msg_flags, err);
1370out:
1371 unlock_kernel();
1372 return err;
1318 1373
1319} 1374}
1320 1375
@@ -1335,13 +1390,14 @@ static int irda_recvmsg_dgram(struct kiocb *iocb, struct socket *sock,
1335 1390
1336 IRDA_DEBUG(4, "%s()\n", __func__); 1391 IRDA_DEBUG(4, "%s()\n", __func__);
1337 1392
1393 lock_kernel();
1338 if ((err = sock_error(sk)) < 0) 1394 if ((err = sock_error(sk)) < 0)
1339 return err; 1395 goto out;
1340 1396
1341 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT, 1397 skb = skb_recv_datagram(sk, flags & ~MSG_DONTWAIT,
1342 flags & MSG_DONTWAIT, &err); 1398 flags & MSG_DONTWAIT, &err);
1343 if (!skb) 1399 if (!skb)
1344 return err; 1400 goto out;
1345 1401
1346 skb_reset_transport_header(skb); 1402 skb_reset_transport_header(skb);
1347 copied = skb->len; 1403 copied = skb->len;
@@ -1369,8 +1425,12 @@ static int irda_recvmsg_dgram(struct kiocb *iocb, struct socket *sock,
1369 irttp_flow_request(self->tsap, FLOW_START); 1425 irttp_flow_request(self->tsap, FLOW_START);
1370 } 1426 }
1371 } 1427 }
1372 1428 unlock_kernel();
1373 return copied; 1429 return copied;
1430
1431out:
1432 unlock_kernel();
1433 return err;
1374} 1434}
1375 1435
1376/* 1436/*
@@ -1388,15 +1448,19 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock,
1388 1448
1389 IRDA_DEBUG(3, "%s()\n", __func__); 1449 IRDA_DEBUG(3, "%s()\n", __func__);
1390 1450
1451 lock_kernel();
1391 if ((err = sock_error(sk)) < 0) 1452 if ((err = sock_error(sk)) < 0)
1392 return err; 1453 goto out;
1393 1454
1455 err = -EINVAL;
1394 if (sock->flags & __SO_ACCEPTCON) 1456 if (sock->flags & __SO_ACCEPTCON)
1395 return(-EINVAL); 1457 goto out;
1396 1458
1459 err =-EOPNOTSUPP;
1397 if (flags & MSG_OOB) 1460 if (flags & MSG_OOB)
1398 return -EOPNOTSUPP; 1461 goto out;
1399 1462
1463 err = 0;
1400 target = sock_rcvlowat(sk, flags & MSG_WAITALL, size); 1464 target = sock_rcvlowat(sk, flags & MSG_WAITALL, size);
1401 timeo = sock_rcvtimeo(sk, noblock); 1465 timeo = sock_rcvtimeo(sk, noblock);
1402 1466
@@ -1408,7 +1472,7 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock,
1408 1472
1409 if (skb == NULL) { 1473 if (skb == NULL) {
1410 DEFINE_WAIT(wait); 1474 DEFINE_WAIT(wait);
1411 int ret = 0; 1475 err = 0;
1412 1476
1413 if (copied >= target) 1477 if (copied >= target)
1414 break; 1478 break;
@@ -1418,25 +1482,25 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock,
1418 /* 1482 /*
1419 * POSIX 1003.1g mandates this order. 1483 * POSIX 1003.1g mandates this order.
1420 */ 1484 */
1421 ret = sock_error(sk); 1485 err = sock_error(sk);
1422 if (ret) 1486 if (err)
1423 ; 1487 ;
1424 else if (sk->sk_shutdown & RCV_SHUTDOWN) 1488 else if (sk->sk_shutdown & RCV_SHUTDOWN)
1425 ; 1489 ;
1426 else if (noblock) 1490 else if (noblock)
1427 ret = -EAGAIN; 1491 err = -EAGAIN;
1428 else if (signal_pending(current)) 1492 else if (signal_pending(current))
1429 ret = sock_intr_errno(timeo); 1493 err = sock_intr_errno(timeo);
1430 else if (sk->sk_state != TCP_ESTABLISHED) 1494 else if (sk->sk_state != TCP_ESTABLISHED)
1431 ret = -ENOTCONN; 1495 err = -ENOTCONN;
1432 else if (skb_peek(&sk->sk_receive_queue) == NULL) 1496 else if (skb_peek(&sk->sk_receive_queue) == NULL)
1433 /* Wait process until data arrives */ 1497 /* Wait process until data arrives */
1434 schedule(); 1498 schedule();
1435 1499
1436 finish_wait(sk->sk_sleep, &wait); 1500 finish_wait(sk->sk_sleep, &wait);
1437 1501
1438 if (ret) 1502 if (err)
1439 return ret; 1503 goto out;
1440 if (sk->sk_shutdown & RCV_SHUTDOWN) 1504 if (sk->sk_shutdown & RCV_SHUTDOWN)
1441 break; 1505 break;
1442 1506
@@ -1489,7 +1553,9 @@ static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock,
1489 } 1553 }
1490 } 1554 }
1491 1555
1492 return copied; 1556out:
1557 unlock_kernel();
1558 return err ? : copied;
1493} 1559}
1494 1560
1495/* 1561/*
@@ -1507,18 +1573,23 @@ static int irda_sendmsg_dgram(struct kiocb *iocb, struct socket *sock,
1507 struct sk_buff *skb; 1573 struct sk_buff *skb;
1508 int err; 1574 int err;
1509 1575
1576 lock_kernel();
1577
1510 IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len); 1578 IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len);
1511 1579
1580 err = -EINVAL;
1512 if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT)) 1581 if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT))
1513 return -EINVAL; 1582 goto out;
1514 1583
1515 if (sk->sk_shutdown & SEND_SHUTDOWN) { 1584 if (sk->sk_shutdown & SEND_SHUTDOWN) {
1516 send_sig(SIGPIPE, current, 0); 1585 send_sig(SIGPIPE, current, 0);
1517 return -EPIPE; 1586 err = -EPIPE;
1587 goto out;
1518 } 1588 }
1519 1589
1590 err = -ENOTCONN;
1520 if (sk->sk_state != TCP_ESTABLISHED) 1591 if (sk->sk_state != TCP_ESTABLISHED)
1521 return -ENOTCONN; 1592 goto out;
1522 1593
1523 self = irda_sk(sk); 1594 self = irda_sk(sk);
1524 1595
@@ -1535,8 +1606,9 @@ static int irda_sendmsg_dgram(struct kiocb *iocb, struct socket *sock,
1535 1606
1536 skb = sock_alloc_send_skb(sk, len + self->max_header_size, 1607 skb = sock_alloc_send_skb(sk, len + self->max_header_size,
1537 msg->msg_flags & MSG_DONTWAIT, &err); 1608 msg->msg_flags & MSG_DONTWAIT, &err);
1609 err = -ENOBUFS;
1538 if (!skb) 1610 if (!skb)
1539 return -ENOBUFS; 1611 goto out;
1540 1612
1541 skb_reserve(skb, self->max_header_size); 1613 skb_reserve(skb, self->max_header_size);
1542 skb_reset_transport_header(skb); 1614 skb_reset_transport_header(skb);
@@ -1546,7 +1618,7 @@ static int irda_sendmsg_dgram(struct kiocb *iocb, struct socket *sock,
1546 err = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len); 1618 err = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len);
1547 if (err) { 1619 if (err) {
1548 kfree_skb(skb); 1620 kfree_skb(skb);
1549 return err; 1621 goto out;
1550 } 1622 }
1551 1623
1552 /* 1624 /*
@@ -1556,9 +1628,13 @@ static int irda_sendmsg_dgram(struct kiocb *iocb, struct socket *sock,
1556 err = irttp_udata_request(self->tsap, skb); 1628 err = irttp_udata_request(self->tsap, skb);
1557 if (err) { 1629 if (err) {
1558 IRDA_DEBUG(0, "%s(), err=%d\n", __func__, err); 1630 IRDA_DEBUG(0, "%s(), err=%d\n", __func__, err);
1559 return err; 1631 goto out;
1560 } 1632 }
1633 unlock_kernel();
1561 return len; 1634 return len;
1635out:
1636 unlock_kernel();
1637 return err;
1562} 1638}
1563 1639
1564/* 1640/*
@@ -1580,12 +1656,15 @@ static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock,
1580 1656
1581 IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len); 1657 IRDA_DEBUG(4, "%s(), len=%zd\n", __func__, len);
1582 1658
1659 lock_kernel();
1660 err = -EINVAL;
1583 if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT)) 1661 if (msg->msg_flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT))
1584 return -EINVAL; 1662 goto out;
1585 1663
1664 err = -EPIPE;
1586 if (sk->sk_shutdown & SEND_SHUTDOWN) { 1665 if (sk->sk_shutdown & SEND_SHUTDOWN) {
1587 send_sig(SIGPIPE, current, 0); 1666 send_sig(SIGPIPE, current, 0);
1588 return -EPIPE; 1667 goto out;
1589 } 1668 }
1590 1669
1591 self = irda_sk(sk); 1670 self = irda_sk(sk);
@@ -1593,16 +1672,18 @@ static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock,
1593 /* Check if an address was specified with sendto. Jean II */ 1672 /* Check if an address was specified with sendto. Jean II */
1594 if (msg->msg_name) { 1673 if (msg->msg_name) {
1595 struct sockaddr_irda *addr = (struct sockaddr_irda *) msg->msg_name; 1674 struct sockaddr_irda *addr = (struct sockaddr_irda *) msg->msg_name;
1675 err = -EINVAL;
1596 /* Check address, extract pid. Jean II */ 1676 /* Check address, extract pid. Jean II */
1597 if (msg->msg_namelen < sizeof(*addr)) 1677 if (msg->msg_namelen < sizeof(*addr))
1598 return -EINVAL; 1678 goto out;
1599 if (addr->sir_family != AF_IRDA) 1679 if (addr->sir_family != AF_IRDA)
1600 return -EINVAL; 1680 goto out;
1601 1681
1602 pid = addr->sir_lsap_sel; 1682 pid = addr->sir_lsap_sel;
1603 if (pid & 0x80) { 1683 if (pid & 0x80) {
1604 IRDA_DEBUG(0, "%s(), extension in PID not supp!\n", __func__); 1684 IRDA_DEBUG(0, "%s(), extension in PID not supp!\n", __func__);
1605 return -EOPNOTSUPP; 1685 err = -EOPNOTSUPP;
1686 goto out;
1606 } 1687 }
1607 } else { 1688 } else {
1608 /* Check that the socket is properly bound to an Ultra 1689 /* Check that the socket is properly bound to an Ultra
@@ -1611,7 +1692,8 @@ static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock,
1611 (sk->sk_state != TCP_ESTABLISHED)) { 1692 (sk->sk_state != TCP_ESTABLISHED)) {
1612 IRDA_DEBUG(0, "%s(), socket not bound to Ultra PID.\n", 1693 IRDA_DEBUG(0, "%s(), socket not bound to Ultra PID.\n",
1613 __func__); 1694 __func__);
1614 return -ENOTCONN; 1695 err = -ENOTCONN;
1696 goto out;
1615 } 1697 }
1616 /* Use PID from socket */ 1698 /* Use PID from socket */
1617 bound = 1; 1699 bound = 1;
@@ -1630,8 +1712,9 @@ static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock,
1630 1712
1631 skb = sock_alloc_send_skb(sk, len + self->max_header_size, 1713 skb = sock_alloc_send_skb(sk, len + self->max_header_size,
1632 msg->msg_flags & MSG_DONTWAIT, &err); 1714 msg->msg_flags & MSG_DONTWAIT, &err);
1715 err = -ENOBUFS;
1633 if (!skb) 1716 if (!skb)
1634 return -ENOBUFS; 1717 goto out;
1635 1718
1636 skb_reserve(skb, self->max_header_size); 1719 skb_reserve(skb, self->max_header_size);
1637 skb_reset_transport_header(skb); 1720 skb_reset_transport_header(skb);
@@ -1641,16 +1724,16 @@ static int irda_sendmsg_ultra(struct kiocb *iocb, struct socket *sock,
1641 err = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len); 1724 err = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len);
1642 if (err) { 1725 if (err) {
1643 kfree_skb(skb); 1726 kfree_skb(skb);
1644 return err; 1727 goto out;
1645 } 1728 }
1646 1729
1647 err = irlmp_connless_data_request((bound ? self->lsap : NULL), 1730 err = irlmp_connless_data_request((bound ? self->lsap : NULL),
1648 skb, pid); 1731 skb, pid);
1649 if (err) { 1732 if (err)
1650 IRDA_DEBUG(0, "%s(), err=%d\n", __func__, err); 1733 IRDA_DEBUG(0, "%s(), err=%d\n", __func__, err);
1651 return err; 1734out:
1652 } 1735 unlock_kernel();
1653 return len; 1736 return err ? : len;
1654} 1737}
1655#endif /* CONFIG_IRDA_ULTRA */ 1738#endif /* CONFIG_IRDA_ULTRA */
1656 1739
@@ -1664,6 +1747,8 @@ static int irda_shutdown(struct socket *sock, int how)
1664 1747
1665 IRDA_DEBUG(1, "%s(%p)\n", __func__, self); 1748 IRDA_DEBUG(1, "%s(%p)\n", __func__, self);
1666 1749
1750 lock_kernel();
1751
1667 sk->sk_state = TCP_CLOSE; 1752 sk->sk_state = TCP_CLOSE;
1668 sk->sk_shutdown |= SEND_SHUTDOWN; 1753 sk->sk_shutdown |= SEND_SHUTDOWN;
1669 sk->sk_state_change(sk); 1754 sk->sk_state_change(sk);
@@ -1684,6 +1769,8 @@ static int irda_shutdown(struct socket *sock, int how)
1684 self->daddr = DEV_ADDR_ANY; /* Until we get re-connected */ 1769 self->daddr = DEV_ADDR_ANY; /* Until we get re-connected */
1685 self->saddr = 0x0; /* so IrLMP assign us any link */ 1770 self->saddr = 0x0; /* so IrLMP assign us any link */
1686 1771
1772 unlock_kernel();
1773
1687 return 0; 1774 return 0;
1688} 1775}
1689 1776
@@ -1699,6 +1786,7 @@ static unsigned int irda_poll(struct file * file, struct socket *sock,
1699 1786
1700 IRDA_DEBUG(4, "%s()\n", __func__); 1787 IRDA_DEBUG(4, "%s()\n", __func__);
1701 1788
1789 lock_kernel();
1702 poll_wait(file, sk->sk_sleep, wait); 1790 poll_wait(file, sk->sk_sleep, wait);
1703 mask = 0; 1791 mask = 0;
1704 1792
@@ -1746,18 +1834,34 @@ static unsigned int irda_poll(struct file * file, struct socket *sock,
1746 default: 1834 default:
1747 break; 1835 break;
1748 } 1836 }
1837 unlock_kernel();
1749 return mask; 1838 return mask;
1750} 1839}
1751 1840
1841static unsigned int irda_datagram_poll(struct file *file, struct socket *sock,
1842 poll_table *wait)
1843{
1844 int err;
1845
1846 lock_kernel();
1847 err = datagram_poll(file, sock, wait);
1848 unlock_kernel();
1849
1850 return err;
1851}
1852
1752/* 1853/*
1753 * Function irda_ioctl (sock, cmd, arg) 1854 * Function irda_ioctl (sock, cmd, arg)
1754 */ 1855 */
1755static int irda_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) 1856static int irda_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1756{ 1857{
1757 struct sock *sk = sock->sk; 1858 struct sock *sk = sock->sk;
1859 int err;
1758 1860
1759 IRDA_DEBUG(4, "%s(), cmd=%#x\n", __func__, cmd); 1861 IRDA_DEBUG(4, "%s(), cmd=%#x\n", __func__, cmd);
1760 1862
1863 lock_kernel();
1864 err = -EINVAL;
1761 switch (cmd) { 1865 switch (cmd) {
1762 case TIOCOUTQ: { 1866 case TIOCOUTQ: {
1763 long amount; 1867 long amount;
@@ -1765,9 +1869,8 @@ static int irda_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1765 amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk); 1869 amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
1766 if (amount < 0) 1870 if (amount < 0)
1767 amount = 0; 1871 amount = 0;
1768 if (put_user(amount, (unsigned int __user *)arg)) 1872 err = put_user(amount, (unsigned int __user *)arg);
1769 return -EFAULT; 1873 break;
1770 return 0;
1771 } 1874 }
1772 1875
1773 case TIOCINQ: { 1876 case TIOCINQ: {
@@ -1776,15 +1879,14 @@ static int irda_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1776 /* These two are safe on a single CPU system as only user tasks fiddle here */ 1879 /* These two are safe on a single CPU system as only user tasks fiddle here */
1777 if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL) 1880 if ((skb = skb_peek(&sk->sk_receive_queue)) != NULL)
1778 amount = skb->len; 1881 amount = skb->len;
1779 if (put_user(amount, (unsigned int __user *)arg)) 1882 err = put_user(amount, (unsigned int __user *)arg);
1780 return -EFAULT; 1883 break;
1781 return 0;
1782 } 1884 }
1783 1885
1784 case SIOCGSTAMP: 1886 case SIOCGSTAMP:
1785 if (sk != NULL) 1887 if (sk != NULL)
1786 return sock_get_timestamp(sk, (struct timeval __user *)arg); 1888 err = sock_get_timestamp(sk, (struct timeval __user *)arg);
1787 return -EINVAL; 1889 break;
1788 1890
1789 case SIOCGIFADDR: 1891 case SIOCGIFADDR:
1790 case SIOCSIFADDR: 1892 case SIOCSIFADDR:
@@ -1796,14 +1898,14 @@ static int irda_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1796 case SIOCSIFNETMASK: 1898 case SIOCSIFNETMASK:
1797 case SIOCGIFMETRIC: 1899 case SIOCGIFMETRIC:
1798 case SIOCSIFMETRIC: 1900 case SIOCSIFMETRIC:
1799 return -EINVAL; 1901 break;
1800 default: 1902 default:
1801 IRDA_DEBUG(1, "%s(), doing device ioctl!\n", __func__); 1903 IRDA_DEBUG(1, "%s(), doing device ioctl!\n", __func__);
1802 return -ENOIOCTLCMD; 1904 err = -ENOIOCTLCMD;
1803 } 1905 }
1906 unlock_kernel();
1804 1907
1805 /*NOTREACHED*/ 1908 return err;
1806 return 0;
1807} 1909}
1808 1910
1809#ifdef CONFIG_COMPAT 1911#ifdef CONFIG_COMPAT
@@ -1825,7 +1927,7 @@ static int irda_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned lon
1825 * Set some options for the socket 1927 * Set some options for the socket
1826 * 1928 *
1827 */ 1929 */
1828static int irda_setsockopt(struct socket *sock, int level, int optname, 1930static int __irda_setsockopt(struct socket *sock, int level, int optname,
1829 char __user *optval, unsigned int optlen) 1931 char __user *optval, unsigned int optlen)
1830{ 1932{
1831 struct sock *sk = sock->sk; 1933 struct sock *sk = sock->sk;
@@ -2083,6 +2185,18 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
2083 return 0; 2185 return 0;
2084} 2186}
2085 2187
2188static int irda_setsockopt(struct socket *sock, int level, int optname,
2189 char __user *optval, unsigned int optlen)
2190{
2191 int err;
2192
2193 lock_kernel();
2194 err = __irda_setsockopt(sock, level, optname, optval, optlen);
2195 unlock_kernel();
2196
2197 return err;
2198}
2199
2086/* 2200/*
2087 * Function irda_extract_ias_value(ias_opt, ias_value) 2201 * Function irda_extract_ias_value(ias_opt, ias_value)
2088 * 2202 *
@@ -2135,7 +2249,7 @@ static int irda_extract_ias_value(struct irda_ias_set *ias_opt,
2135/* 2249/*
2136 * Function irda_getsockopt (sock, level, optname, optval, optlen) 2250 * Function irda_getsockopt (sock, level, optname, optval, optlen)
2137 */ 2251 */
2138static int irda_getsockopt(struct socket *sock, int level, int optname, 2252static int __irda_getsockopt(struct socket *sock, int level, int optname,
2139 char __user *optval, int __user *optlen) 2253 char __user *optval, int __user *optlen)
2140{ 2254{
2141 struct sock *sk = sock->sk; 2255 struct sock *sk = sock->sk;
@@ -2463,13 +2577,25 @@ bed:
2463 return 0; 2577 return 0;
2464} 2578}
2465 2579
2466static struct net_proto_family irda_family_ops = { 2580static int irda_getsockopt(struct socket *sock, int level, int optname,
2581 char __user *optval, int __user *optlen)
2582{
2583 int err;
2584
2585 lock_kernel();
2586 err = __irda_getsockopt(sock, level, optname, optval, optlen);
2587 unlock_kernel();
2588
2589 return err;
2590}
2591
2592static const struct net_proto_family irda_family_ops = {
2467 .family = PF_IRDA, 2593 .family = PF_IRDA,
2468 .create = irda_create, 2594 .create = irda_create,
2469 .owner = THIS_MODULE, 2595 .owner = THIS_MODULE,
2470}; 2596};
2471 2597
2472static const struct proto_ops SOCKOPS_WRAPPED(irda_stream_ops) = { 2598static const struct proto_ops irda_stream_ops = {
2473 .family = PF_IRDA, 2599 .family = PF_IRDA,
2474 .owner = THIS_MODULE, 2600 .owner = THIS_MODULE,
2475 .release = irda_release, 2601 .release = irda_release,
@@ -2493,7 +2619,7 @@ static const struct proto_ops SOCKOPS_WRAPPED(irda_stream_ops) = {
2493 .sendpage = sock_no_sendpage, 2619 .sendpage = sock_no_sendpage,
2494}; 2620};
2495 2621
2496static const struct proto_ops SOCKOPS_WRAPPED(irda_seqpacket_ops) = { 2622static const struct proto_ops irda_seqpacket_ops = {
2497 .family = PF_IRDA, 2623 .family = PF_IRDA,
2498 .owner = THIS_MODULE, 2624 .owner = THIS_MODULE,
2499 .release = irda_release, 2625 .release = irda_release,
@@ -2502,7 +2628,7 @@ static const struct proto_ops SOCKOPS_WRAPPED(irda_seqpacket_ops) = {
2502 .socketpair = sock_no_socketpair, 2628 .socketpair = sock_no_socketpair,
2503 .accept = irda_accept, 2629 .accept = irda_accept,
2504 .getname = irda_getname, 2630 .getname = irda_getname,
2505 .poll = datagram_poll, 2631 .poll = irda_datagram_poll,
2506 .ioctl = irda_ioctl, 2632 .ioctl = irda_ioctl,
2507#ifdef CONFIG_COMPAT 2633#ifdef CONFIG_COMPAT
2508 .compat_ioctl = irda_compat_ioctl, 2634 .compat_ioctl = irda_compat_ioctl,
@@ -2517,7 +2643,7 @@ static const struct proto_ops SOCKOPS_WRAPPED(irda_seqpacket_ops) = {
2517 .sendpage = sock_no_sendpage, 2643 .sendpage = sock_no_sendpage,
2518}; 2644};
2519 2645
2520static const struct proto_ops SOCKOPS_WRAPPED(irda_dgram_ops) = { 2646static const struct proto_ops irda_dgram_ops = {
2521 .family = PF_IRDA, 2647 .family = PF_IRDA,
2522 .owner = THIS_MODULE, 2648 .owner = THIS_MODULE,
2523 .release = irda_release, 2649 .release = irda_release,
@@ -2526,7 +2652,7 @@ static const struct proto_ops SOCKOPS_WRAPPED(irda_dgram_ops) = {
2526 .socketpair = sock_no_socketpair, 2652 .socketpair = sock_no_socketpair,
2527 .accept = irda_accept, 2653 .accept = irda_accept,
2528 .getname = irda_getname, 2654 .getname = irda_getname,
2529 .poll = datagram_poll, 2655 .poll = irda_datagram_poll,
2530 .ioctl = irda_ioctl, 2656 .ioctl = irda_ioctl,
2531#ifdef CONFIG_COMPAT 2657#ifdef CONFIG_COMPAT
2532 .compat_ioctl = irda_compat_ioctl, 2658 .compat_ioctl = irda_compat_ioctl,
@@ -2542,7 +2668,7 @@ static const struct proto_ops SOCKOPS_WRAPPED(irda_dgram_ops) = {
2542}; 2668};
2543 2669
2544#ifdef CONFIG_IRDA_ULTRA 2670#ifdef CONFIG_IRDA_ULTRA
2545static const struct proto_ops SOCKOPS_WRAPPED(irda_ultra_ops) = { 2671static const struct proto_ops irda_ultra_ops = {
2546 .family = PF_IRDA, 2672 .family = PF_IRDA,
2547 .owner = THIS_MODULE, 2673 .owner = THIS_MODULE,
2548 .release = irda_release, 2674 .release = irda_release,
@@ -2551,7 +2677,7 @@ static const struct proto_ops SOCKOPS_WRAPPED(irda_ultra_ops) = {
2551 .socketpair = sock_no_socketpair, 2677 .socketpair = sock_no_socketpair,
2552 .accept = sock_no_accept, 2678 .accept = sock_no_accept,
2553 .getname = irda_getname, 2679 .getname = irda_getname,
2554 .poll = datagram_poll, 2680 .poll = irda_datagram_poll,
2555 .ioctl = irda_ioctl, 2681 .ioctl = irda_ioctl,
2556#ifdef CONFIG_COMPAT 2682#ifdef CONFIG_COMPAT
2557 .compat_ioctl = irda_compat_ioctl, 2683 .compat_ioctl = irda_compat_ioctl,
@@ -2567,13 +2693,6 @@ static const struct proto_ops SOCKOPS_WRAPPED(irda_ultra_ops) = {
2567}; 2693};
2568#endif /* CONFIG_IRDA_ULTRA */ 2694#endif /* CONFIG_IRDA_ULTRA */
2569 2695
2570SOCKOPS_WRAP(irda_stream, PF_IRDA);
2571SOCKOPS_WRAP(irda_seqpacket, PF_IRDA);
2572SOCKOPS_WRAP(irda_dgram, PF_IRDA);
2573#ifdef CONFIG_IRDA_ULTRA
2574SOCKOPS_WRAP(irda_ultra, PF_IRDA);
2575#endif /* CONFIG_IRDA_ULTRA */
2576
2577/* 2696/*
2578 * Function irsock_init (pro) 2697 * Function irsock_init (pro)
2579 * 2698 *
diff --git a/net/irda/discovery.c b/net/irda/discovery.c
index a6f99b5a1499..c1c8ae939126 100644
--- a/net/irda/discovery.c
+++ b/net/irda/discovery.c
@@ -34,6 +34,7 @@
34#include <linux/socket.h> 34#include <linux/socket.h>
35#include <linux/fs.h> 35#include <linux/fs.h>
36#include <linux/seq_file.h> 36#include <linux/seq_file.h>
37#include <linux/slab.h>
37 38
38#include <net/irda/irda.h> 39#include <net/irda/irda.h>
39#include <net/irda/irlmp.h> 40#include <net/irda/irlmp.h>
diff --git a/net/irda/ircomm/ircomm_core.c b/net/irda/ircomm/ircomm_core.c
index 018c92941aba..e97082017f4f 100644
--- a/net/irda/ircomm/ircomm_core.c
+++ b/net/irda/ircomm/ircomm_core.c
@@ -33,6 +33,7 @@
33#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
34#include <linux/seq_file.h> 34#include <linux/seq_file.h>
35#include <linux/init.h> 35#include <linux/init.h>
36#include <linux/slab.h>
36 37
37#include <net/irda/irda.h> 38#include <net/irda/irda.h>
38#include <net/irda/irmod.h> 39#include <net/irda/irmod.h>
diff --git a/net/irda/ircomm/ircomm_lmp.c b/net/irda/ircomm/ircomm_lmp.c
index 7ba96618660e..08fb54dc8c41 100644
--- a/net/irda/ircomm/ircomm_lmp.c
+++ b/net/irda/ircomm/ircomm_lmp.c
@@ -31,6 +31,7 @@
31 ********************************************************************/ 31 ********************************************************************/
32 32
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/gfp.h>
34 35
35#include <net/irda/irda.h> 36#include <net/irda/irda.h>
36#include <net/irda/irlmp.h> 37#include <net/irda/irlmp.h>
diff --git a/net/irda/ircomm/ircomm_param.c b/net/irda/ircomm/ircomm_param.c
index d57aefd9fe77..e2e893b474e9 100644
--- a/net/irda/ircomm/ircomm_param.c
+++ b/net/irda/ircomm/ircomm_param.c
@@ -28,6 +28,7 @@
28 * 28 *
29 ********************************************************************/ 29 ********************************************************************/
30 30
31#include <linux/gfp.h>
31#include <linux/workqueue.h> 32#include <linux/workqueue.h>
32#include <linux/interrupt.h> 33#include <linux/interrupt.h>
33 34
diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
index 811984d9324b..faa82ca2dfdc 100644
--- a/net/irda/ircomm/ircomm_tty.c
+++ b/net/irda/ircomm/ircomm_tty.c
@@ -33,6 +33,7 @@
33#include <linux/init.h> 33#include <linux/init.h>
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/fs.h> 35#include <linux/fs.h>
36#include <linux/slab.h>
36#include <linux/sched.h> 37#include <linux/sched.h>
37#include <linux/seq_file.h> 38#include <linux/seq_file.h>
38#include <linux/termios.h> 39#include <linux/termios.h>
@@ -496,9 +497,6 @@ static void ircomm_tty_close(struct tty_struct *tty, struct file *filp)
496 497
497 IRDA_DEBUG(0, "%s()\n", __func__ ); 498 IRDA_DEBUG(0, "%s()\n", __func__ );
498 499
499 if (!tty)
500 return;
501
502 IRDA_ASSERT(self != NULL, return;); 500 IRDA_ASSERT(self != NULL, return;);
503 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 501 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
504 502
@@ -1007,9 +1005,6 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
1007 IRDA_ASSERT(self != NULL, return;); 1005 IRDA_ASSERT(self != NULL, return;);
1008 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;); 1006 IRDA_ASSERT(self->magic == IRCOMM_TTY_MAGIC, return;);
1009 1007
1010 if (!tty)
1011 return;
1012
1013 /* ircomm_tty_flush_buffer(tty); */ 1008 /* ircomm_tty_flush_buffer(tty); */
1014 ircomm_tty_shutdown(self); 1009 ircomm_tty_shutdown(self);
1015 1010
diff --git a/net/irda/irda_device.c b/net/irda/irda_device.c
index bf92e1473447..25cc2e695158 100644
--- a/net/irda/irda_device.c
+++ b/net/irda/irda_device.c
@@ -41,6 +41,7 @@
41#include <linux/tty.h> 41#include <linux/tty.h>
42#include <linux/kmod.h> 42#include <linux/kmod.h>
43#include <linux/spinlock.h> 43#include <linux/spinlock.h>
44#include <linux/slab.h>
44 45
45#include <asm/ioctls.h> 46#include <asm/ioctls.h>
46#include <asm/uaccess.h> 47#include <asm/uaccess.h>
diff --git a/net/irda/iriap.c b/net/irda/iriap.c
index 294e34d3517c..79a1e5a23e10 100644
--- a/net/irda/iriap.c
+++ b/net/irda/iriap.c
@@ -31,6 +31,7 @@
31#include <linux/string.h> 31#include <linux/string.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/seq_file.h> 33#include <linux/seq_file.h>
34#include <linux/slab.h>
34 35
35#include <asm/byteorder.h> 36#include <asm/byteorder.h>
36#include <asm/unaligned.h> 37#include <asm/unaligned.h>
diff --git a/net/irda/iriap_event.c b/net/irda/iriap_event.c
index a301cbd93785..703774e29e32 100644
--- a/net/irda/iriap_event.c
+++ b/net/irda/iriap_event.c
@@ -24,6 +24,8 @@
24 * 24 *
25 ********************************************************************/ 25 ********************************************************************/
26 26
27#include <linux/slab.h>
28
27#include <net/irda/irda.h> 29#include <net/irda/irda.h>
28#include <net/irda/irlmp.h> 30#include <net/irda/irlmp.h>
29#include <net/irda/iriap.h> 31#include <net/irda/iriap.h>
diff --git a/net/irda/irias_object.c b/net/irda/irias_object.c
index 99ebb96f1386..f07ed9fd5792 100644
--- a/net/irda/irias_object.c
+++ b/net/irda/irias_object.c
@@ -22,6 +22,7 @@
22 * 22 *
23 ********************************************************************/ 23 ********************************************************************/
24 24
25#include <linux/slab.h>
25#include <linux/string.h> 26#include <linux/string.h>
26#include <linux/socket.h> 27#include <linux/socket.h>
27#include <linux/module.h> 28#include <linux/module.h>
diff --git a/net/irda/irlan/irlan_client.c b/net/irda/irlan/irlan_client.c
index 42f7d960d055..7ed3af957935 100644
--- a/net/irda/irlan/irlan_client.c
+++ b/net/irda/irlan/irlan_client.c
@@ -28,6 +28,7 @@
28 28
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/string.h> 30#include <linux/string.h>
31#include <linux/slab.h>
31#include <linux/errno.h> 32#include <linux/errno.h>
32#include <linux/init.h> 33#include <linux/init.h>
33#include <linux/netdevice.h> 34#include <linux/netdevice.h>
diff --git a/net/irda/irlan/irlan_common.c b/net/irda/irlan/irlan_common.c
index 315ead3cb926..a788f9e9427d 100644
--- a/net/irda/irlan/irlan_common.c
+++ b/net/irda/irlan/irlan_common.c
@@ -27,6 +27,7 @@
27 27
28#include <linux/kernel.h> 28#include <linux/kernel.h>
29#include <linux/string.h> 29#include <linux/string.h>
30#include <linux/gfp.h>
30#include <linux/init.h> 31#include <linux/init.h>
31#include <linux/errno.h> 32#include <linux/errno.h>
32#include <linux/proc_fs.h> 33#include <linux/proc_fs.h>
@@ -1128,34 +1129,14 @@ int irlan_extract_param(__u8 *buf, char *name, char *value, __u16 *len)
1128 */ 1129 */
1129static void *irlan_seq_start(struct seq_file *seq, loff_t *pos) 1130static void *irlan_seq_start(struct seq_file *seq, loff_t *pos)
1130{ 1131{
1131 int i = 1;
1132 struct irlan_cb *self;
1133
1134 rcu_read_lock(); 1132 rcu_read_lock();
1135 if (*pos == 0) 1133 return seq_list_start_head(&irlans, *pos);
1136 return SEQ_START_TOKEN;
1137
1138 list_for_each_entry(self, &irlans, dev_list) {
1139 if (*pos == i)
1140 return self;
1141 ++i;
1142 }
1143 return NULL;
1144} 1134}
1145 1135
1146/* Return entry after v, and increment pos */ 1136/* Return entry after v, and increment pos */
1147static void *irlan_seq_next(struct seq_file *seq, void *v, loff_t *pos) 1137static void *irlan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1148{ 1138{
1149 struct list_head *nxt; 1139 return seq_list_next(v, &irlans, pos);
1150
1151 ++*pos;
1152 if (v == SEQ_START_TOKEN)
1153 nxt = irlans.next;
1154 else
1155 nxt = ((struct irlan_cb *)v)->dev_list.next;
1156
1157 return (nxt == &irlans) ? NULL
1158 : list_entry(nxt, struct irlan_cb, dev_list);
1159} 1140}
1160 1141
1161/* End of reading /proc file */ 1142/* End of reading /proc file */
@@ -1170,10 +1151,10 @@ static void irlan_seq_stop(struct seq_file *seq, void *v)
1170 */ 1151 */
1171static int irlan_seq_show(struct seq_file *seq, void *v) 1152static int irlan_seq_show(struct seq_file *seq, void *v)
1172{ 1153{
1173 if (v == SEQ_START_TOKEN) 1154 if (v == &irlans)
1174 seq_puts(seq, "IrLAN instances:\n"); 1155 seq_puts(seq, "IrLAN instances:\n");
1175 else { 1156 else {
1176 struct irlan_cb *self = v; 1157 struct irlan_cb *self = list_entry(v, struct irlan_cb, dev_list);
1177 1158
1178 IRDA_ASSERT(self != NULL, return -1;); 1159 IRDA_ASSERT(self != NULL, return -1;);
1179 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;); 1160 IRDA_ASSERT(self->magic == IRLAN_MAGIC, return -1;);
diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c
index d340110f5c0c..9616c32d1076 100644
--- a/net/irda/irlan/irlan_eth.c
+++ b/net/irda/irlan/irlan_eth.c
@@ -321,14 +321,15 @@ static void irlan_eth_set_multicast_list(struct net_device *dev)
321 /* Enable promiscuous mode */ 321 /* Enable promiscuous mode */
322 IRDA_WARNING("Promiscuous mode not implemented by IrLAN!\n"); 322 IRDA_WARNING("Promiscuous mode not implemented by IrLAN!\n");
323 } 323 }
324 else if ((dev->flags & IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS) { 324 else if ((dev->flags & IFF_ALLMULTI) ||
325 netdev_mc_count(dev) > HW_MAX_ADDRS) {
325 /* Disable promiscuous mode, use normal mode. */ 326 /* Disable promiscuous mode, use normal mode. */
326 IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ ); 327 IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ );
327 /* hardware_set_filter(NULL); */ 328 /* hardware_set_filter(NULL); */
328 329
329 irlan_set_multicast_filter(self, TRUE); 330 irlan_set_multicast_filter(self, TRUE);
330 } 331 }
331 else if (dev->mc_count) { 332 else if (!netdev_mc_empty(dev)) {
332 IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ ); 333 IRDA_DEBUG(4, "%s(), Setting multicast filter\n", __func__ );
333 /* Walk the address list, and load the filter */ 334 /* Walk the address list, and load the filter */
334 /* hardware_set_filter(dev->mc_list); */ 335 /* hardware_set_filter(dev->mc_list); */
diff --git a/net/irda/irlan/irlan_provider.c b/net/irda/irlan/irlan_provider.c
index 3f81f81b2dfa..5cf5e6c872bb 100644
--- a/net/irda/irlan/irlan_provider.c
+++ b/net/irda/irlan/irlan_provider.c
@@ -34,6 +34,7 @@
34#include <linux/init.h> 34#include <linux/init.h>
35#include <linux/random.h> 35#include <linux/random.h>
36#include <linux/bitops.h> 36#include <linux/bitops.h>
37#include <linux/slab.h>
37 38
38#include <asm/system.h> 39#include <asm/system.h>
39#include <asm/byteorder.h> 40#include <asm/byteorder.h>
diff --git a/net/irda/irlap.c b/net/irda/irlap.c
index 356e65b1dc42..783c5f367d29 100644
--- a/net/irda/irlap.c
+++ b/net/irda/irlap.c
@@ -450,10 +450,10 @@ void irlap_disconnect_request(struct irlap_cb *self)
450 450
451 /* Check if we are in the right state for disconnecting */ 451 /* Check if we are in the right state for disconnecting */
452 switch (self->state) { 452 switch (self->state) {
453 case LAP_XMIT_P: /* FALLTROUGH */ 453 case LAP_XMIT_P: /* FALLTHROUGH */
454 case LAP_XMIT_S: /* FALLTROUGH */ 454 case LAP_XMIT_S: /* FALLTHROUGH */
455 case LAP_CONN: /* FALLTROUGH */ 455 case LAP_CONN: /* FALLTHROUGH */
456 case LAP_RESET_WAIT: /* FALLTROUGH */ 456 case LAP_RESET_WAIT: /* FALLTHROUGH */
457 case LAP_RESET_CHECK: 457 case LAP_RESET_CHECK:
458 irlap_do_event(self, DISCONNECT_REQUEST, NULL, NULL); 458 irlap_do_event(self, DISCONNECT_REQUEST, NULL, NULL);
459 break; 459 break;
@@ -485,9 +485,9 @@ void irlap_disconnect_indication(struct irlap_cb *self, LAP_REASON reason)
485 IRDA_DEBUG(1, "%s(), Sending reset request!\n", __func__); 485 IRDA_DEBUG(1, "%s(), Sending reset request!\n", __func__);
486 irlap_do_event(self, RESET_REQUEST, NULL, NULL); 486 irlap_do_event(self, RESET_REQUEST, NULL, NULL);
487 break; 487 break;
488 case LAP_NO_RESPONSE: /* FALLTROUGH */ 488 case LAP_NO_RESPONSE: /* FALLTHROUGH */
489 case LAP_DISC_INDICATION: /* FALLTROUGH */ 489 case LAP_DISC_INDICATION: /* FALLTHROUGH */
490 case LAP_FOUND_NONE: /* FALLTROUGH */ 490 case LAP_FOUND_NONE: /* FALLTHROUGH */
491 case LAP_MEDIA_BUSY: 491 case LAP_MEDIA_BUSY:
492 irlmp_link_disconnect_indication(self->notify.instance, self, 492 irlmp_link_disconnect_indication(self->notify.instance, self,
493 reason, NULL); 493 reason, NULL);
diff --git a/net/irda/irlap_event.c b/net/irda/irlap_event.c
index c5c51959e3ce..d434c8880745 100644
--- a/net/irda/irlap_event.c
+++ b/net/irda/irlap_event.c
@@ -29,6 +29,7 @@
29#include <linux/kernel.h> 29#include <linux/kernel.h>
30#include <linux/delay.h> 30#include <linux/delay.h>
31#include <linux/skbuff.h> 31#include <linux/skbuff.h>
32#include <linux/slab.h>
32 33
33#include <net/irda/irda.h> 34#include <net/irda/irda.h>
34#include <net/irda/irlap_event.h> 35#include <net/irda/irlap_event.h>
@@ -1741,7 +1742,7 @@ static int irlap_state_reset(struct irlap_cb *self, IRLAP_EVENT event,
1741 * Function irlap_state_xmit_s (event, skb, info) 1742 * Function irlap_state_xmit_s (event, skb, info)
1742 * 1743 *
1743 * XMIT_S, The secondary station has been given the right to transmit, 1744 * XMIT_S, The secondary station has been given the right to transmit,
1744 * and we therefor do not expect to receive any transmissions from other 1745 * and we therefore do not expect to receive any transmissions from other
1745 * stations. 1746 * stations.
1746 */ 1747 */
1747static int irlap_state_xmit_s(struct irlap_cb *self, IRLAP_EVENT event, 1748static int irlap_state_xmit_s(struct irlap_cb *self, IRLAP_EVENT event,
diff --git a/net/irda/irlap_frame.c b/net/irda/irlap_frame.c
index 7af2e74deda8..688222cbf55b 100644
--- a/net/irda/irlap_frame.c
+++ b/net/irda/irlap_frame.c
@@ -29,6 +29,7 @@
29#include <linux/if_ether.h> 29#include <linux/if_ether.h>
30#include <linux/netdevice.h> 30#include <linux/netdevice.h>
31#include <linux/irda.h> 31#include <linux/irda.h>
32#include <linux/slab.h>
32 33
33#include <net/pkt_sched.h> 34#include <net/pkt_sched.h>
34#include <net/sock.h> 35#include <net/sock.h>
diff --git a/net/irda/irlmp.c b/net/irda/irlmp.c
index 7bf5b913828b..0e7d8bde145d 100644
--- a/net/irda/irlmp.c
+++ b/net/irda/irlmp.c
@@ -105,7 +105,7 @@ int __init irlmp_init(void)
105 105
106 init_timer(&irlmp->discovery_timer); 106 init_timer(&irlmp->discovery_timer);
107 107
108 /* Do discovery every 3 seconds, conditionaly */ 108 /* Do discovery every 3 seconds, conditionally */
109 if (sysctl_discovery) 109 if (sysctl_discovery)
110 irlmp_start_discovery_timer(irlmp, 110 irlmp_start_discovery_timer(irlmp,
111 sysctl_discovery_timeout*HZ); 111 sysctl_discovery_timeout*HZ);
@@ -1842,7 +1842,7 @@ LM_REASON irlmp_convert_lap_reason( LAP_REASON lap_reason)
1842 reason = LM_CONNECT_FAILURE; 1842 reason = LM_CONNECT_FAILURE;
1843 break; 1843 break;
1844 default: 1844 default:
1845 IRDA_DEBUG(1, "%s(), Unknow IrLAP disconnect reason %d!\n", 1845 IRDA_DEBUG(1, "%s(), Unknown IrLAP disconnect reason %d!\n",
1846 __func__, lap_reason); 1846 __func__, lap_reason);
1847 reason = LM_LAP_DISCONNECT; 1847 reason = LM_LAP_DISCONNECT;
1848 break; 1848 break;
diff --git a/net/irda/irnet/irnet.h b/net/irda/irnet/irnet.h
index b001c361ad30..4300df35d37d 100644
--- a/net/irda/irnet/irnet.h
+++ b/net/irda/irnet/irnet.h
@@ -249,6 +249,7 @@
249#include <linux/poll.h> 249#include <linux/poll.h>
250#include <linux/capability.h> 250#include <linux/capability.h>
251#include <linux/ctype.h> /* isspace() */ 251#include <linux/ctype.h> /* isspace() */
252#include <linux/string.h> /* skip_spaces() */
252#include <asm/uaccess.h> 253#include <asm/uaccess.h>
253#include <linux/init.h> 254#include <linux/init.h>
254 255
diff --git a/net/irda/irnet/irnet_irda.c b/net/irda/irnet/irnet_irda.c
index cccc2e93234f..df18ab4b6c5e 100644
--- a/net/irda/irnet/irnet_irda.c
+++ b/net/irda/irnet/irnet_irda.c
@@ -11,6 +11,7 @@
11#include "irnet_irda.h" /* Private header */ 11#include "irnet_irda.h" /* Private header */
12#include <linux/sched.h> 12#include <linux/sched.h>
13#include <linux/seq_file.h> 13#include <linux/seq_file.h>
14#include <linux/slab.h>
14#include <asm/unaligned.h> 15#include <asm/unaligned.h>
15 16
16/* 17/*
@@ -1403,8 +1404,8 @@ irnet_connect_indication(void * instance,
1403 /* Socket already connecting ? On primary ? */ 1404 /* Socket already connecting ? On primary ? */
1404 if(0 1405 if(0
1405#ifdef ALLOW_SIMULT_CONNECT 1406#ifdef ALLOW_SIMULT_CONNECT
1406 || ((irttp_is_primary(server->tsap) == 1) /* primary */ 1407 || ((irttp_is_primary(server->tsap) == 1) && /* primary */
1407 && (test_and_clear_bit(0, &new->ttp_connect))) 1408 (test_and_clear_bit(0, &new->ttp_connect)))
1408#endif /* ALLOW_SIMULT_CONNECT */ 1409#endif /* ALLOW_SIMULT_CONNECT */
1409 ) 1410 )
1410 { 1411 {
diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c
index 7dea882dbb75..6a1a202710c5 100644
--- a/net/irda/irnet/irnet_ppp.c
+++ b/net/irda/irnet/irnet_ppp.c
@@ -14,6 +14,7 @@
14 */ 14 */
15 15
16#include <linux/sched.h> 16#include <linux/sched.h>
17#include <linux/slab.h>
17#include <linux/smp_lock.h> 18#include <linux/smp_lock.h>
18#include "irnet_ppp.h" /* Private header */ 19#include "irnet_ppp.h" /* Private header */
19/* Please put other headers in irnet.h - Thanks */ 20/* Please put other headers in irnet.h - Thanks */
@@ -76,9 +77,8 @@ irnet_ctrl_write(irnet_socket * ap,
76 /* Look at the next command */ 77 /* Look at the next command */
77 start = next; 78 start = next;
78 79
79 /* Scrap whitespaces before the command */ 80 /* Scrap whitespaces before the command */
80 while(isspace(*start)) 81 start = skip_spaces(start);
81 start++;
82 82
83 /* ',' is our command separator */ 83 /* ',' is our command separator */
84 next = strchr(start, ','); 84 next = strchr(start, ',');
@@ -133,8 +133,7 @@ irnet_ctrl_write(irnet_socket * ap,
133 char * endp; 133 char * endp;
134 134
135 /* Scrap whitespaces before the command */ 135 /* Scrap whitespaces before the command */
136 while(isspace(*begp)) 136 begp = skip_spaces(begp);
137 begp++;
138 137
139 /* Convert argument to a number (last arg is the base) */ 138 /* Convert argument to a number (last arg is the base) */
140 addr = simple_strtoul(begp, &endp, 16); 139 addr = simple_strtoul(begp, &endp, 16);
@@ -700,15 +699,18 @@ dev_irnet_ioctl(
700 699
701 /* Query PPP channel and unit number */ 700 /* Query PPP channel and unit number */
702 case PPPIOCGCHAN: 701 case PPPIOCGCHAN:
702 lock_kernel();
703 if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan), 703 if(ap->ppp_open && !put_user(ppp_channel_index(&ap->chan),
704 (int __user *)argp)) 704 (int __user *)argp))
705 err = 0; 705 err = 0;
706 unlock_kernel();
706 break; 707 break;
707 case PPPIOCGUNIT: 708 case PPPIOCGUNIT:
708 lock_kernel(); 709 lock_kernel();
709 if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan), 710 if(ap->ppp_open && !put_user(ppp_unit_number(&ap->chan),
710 (int __user *)argp)) 711 (int __user *)argp))
711 err = 0; 712 err = 0;
713 unlock_kernel();
712 break; 714 break;
713 715
714 /* All these ioctls can be passed both directly and from ppp_generic, 716 /* All these ioctls can be passed both directly and from ppp_generic,
diff --git a/net/irda/irnetlink.c b/net/irda/irnetlink.c
index 476b307bd801..6c7c4b92e4f8 100644
--- a/net/irda/irnetlink.c
+++ b/net/irda/irnetlink.c
@@ -15,6 +15,7 @@
15 15
16#include <linux/socket.h> 16#include <linux/socket.h>
17#include <linux/irda.h> 17#include <linux/irda.h>
18#include <linux/gfp.h>
18#include <net/net_namespace.h> 19#include <net/net_namespace.h>
19#include <net/sock.h> 20#include <net/sock.h>
20#include <net/irda/irda.h> 21#include <net/irda/irda.h>
@@ -124,7 +125,7 @@ static int irda_nl_get_mode(struct sk_buff *skb, struct genl_info *info)
124 return ret; 125 return ret;
125} 126}
126 127
127static struct nla_policy irda_nl_policy[IRDA_NL_ATTR_MAX + 1] = { 128static const struct nla_policy irda_nl_policy[IRDA_NL_ATTR_MAX + 1] = {
128 [IRDA_NL_ATTR_IFNAME] = { .type = NLA_NUL_STRING, 129 [IRDA_NL_ATTR_IFNAME] = { .type = NLA_NUL_STRING,
129 .len = IFNAMSIZ-1 }, 130 .len = IFNAMSIZ-1 },
130 [IRDA_NL_ATTR_MODE] = { .type = NLA_U32 }, 131 [IRDA_NL_ATTR_MODE] = { .type = NLA_U32 },
diff --git a/net/irda/irqueue.c b/net/irda/irqueue.c
index ba01938becb5..849aaf0dabb5 100644
--- a/net/irda/irqueue.c
+++ b/net/irda/irqueue.c
@@ -192,6 +192,7 @@
192 * Jean II 192 * Jean II
193 */ 193 */
194#include <linux/module.h> 194#include <linux/module.h>
195#include <linux/slab.h>
195 196
196#include <net/irda/irda.h> 197#include <net/irda/irda.h>
197#include <net/irda/irqueue.h> 198#include <net/irda/irqueue.h>
diff --git a/net/irda/irsysctl.c b/net/irda/irsysctl.c
index 5c86567e5a78..d0b70dadf73b 100644
--- a/net/irda/irsysctl.c
+++ b/net/irda/irsysctl.c
@@ -113,26 +113,21 @@ static int do_discovery(ctl_table *table, int write,
113/* One file */ 113/* One file */
114static ctl_table irda_table[] = { 114static ctl_table irda_table[] = {
115 { 115 {
116 .ctl_name = NET_IRDA_DISCOVERY,
117 .procname = "discovery", 116 .procname = "discovery",
118 .data = &sysctl_discovery, 117 .data = &sysctl_discovery,
119 .maxlen = sizeof(int), 118 .maxlen = sizeof(int),
120 .mode = 0644, 119 .mode = 0644,
121 .proc_handler = do_discovery, 120 .proc_handler = do_discovery,
122 .strategy = sysctl_intvec
123 }, 121 },
124 { 122 {
125 .ctl_name = NET_IRDA_DEVNAME,
126 .procname = "devname", 123 .procname = "devname",
127 .data = sysctl_devname, 124 .data = sysctl_devname,
128 .maxlen = 65, 125 .maxlen = 65,
129 .mode = 0644, 126 .mode = 0644,
130 .proc_handler = do_devname, 127 .proc_handler = do_devname,
131 .strategy = sysctl_string
132 }, 128 },
133#ifdef CONFIG_IRDA_DEBUG 129#ifdef CONFIG_IRDA_DEBUG
134 { 130 {
135 .ctl_name = NET_IRDA_DEBUG,
136 .procname = "debug", 131 .procname = "debug",
137 .data = &irda_debug, 132 .data = &irda_debug,
138 .maxlen = sizeof(int), 133 .maxlen = sizeof(int),
@@ -142,7 +137,6 @@ static ctl_table irda_table[] = {
142#endif 137#endif
143#ifdef CONFIG_IRDA_FAST_RR 138#ifdef CONFIG_IRDA_FAST_RR
144 { 139 {
145 .ctl_name = NET_IRDA_FAST_POLL,
146 .procname = "fast_poll_increase", 140 .procname = "fast_poll_increase",
147 .data = &sysctl_fast_poll_increase, 141 .data = &sysctl_fast_poll_increase,
148 .maxlen = sizeof(int), 142 .maxlen = sizeof(int),
@@ -151,18 +145,15 @@ static ctl_table irda_table[] = {
151 }, 145 },
152#endif 146#endif
153 { 147 {
154 .ctl_name = NET_IRDA_DISCOVERY_SLOTS,
155 .procname = "discovery_slots", 148 .procname = "discovery_slots",
156 .data = &sysctl_discovery_slots, 149 .data = &sysctl_discovery_slots,
157 .maxlen = sizeof(int), 150 .maxlen = sizeof(int),
158 .mode = 0644, 151 .mode = 0644,
159 .proc_handler = proc_dointvec_minmax, 152 .proc_handler = proc_dointvec_minmax,
160 .strategy = sysctl_intvec,
161 .extra1 = &min_discovery_slots, 153 .extra1 = &min_discovery_slots,
162 .extra2 = &max_discovery_slots 154 .extra2 = &max_discovery_slots
163 }, 155 },
164 { 156 {
165 .ctl_name = NET_IRDA_DISCOVERY_TIMEOUT,
166 .procname = "discovery_timeout", 157 .procname = "discovery_timeout",
167 .data = &sysctl_discovery_timeout, 158 .data = &sysctl_discovery_timeout,
168 .maxlen = sizeof(int), 159 .maxlen = sizeof(int),
@@ -170,99 +161,83 @@ static ctl_table irda_table[] = {
170 .proc_handler = proc_dointvec 161 .proc_handler = proc_dointvec
171 }, 162 },
172 { 163 {
173 .ctl_name = NET_IRDA_SLOT_TIMEOUT,
174 .procname = "slot_timeout", 164 .procname = "slot_timeout",
175 .data = &sysctl_slot_timeout, 165 .data = &sysctl_slot_timeout,
176 .maxlen = sizeof(int), 166 .maxlen = sizeof(int),
177 .mode = 0644, 167 .mode = 0644,
178 .proc_handler = proc_dointvec_minmax, 168 .proc_handler = proc_dointvec_minmax,
179 .strategy = sysctl_intvec,
180 .extra1 = &min_slot_timeout, 169 .extra1 = &min_slot_timeout,
181 .extra2 = &max_slot_timeout 170 .extra2 = &max_slot_timeout
182 }, 171 },
183 { 172 {
184 .ctl_name = NET_IRDA_MAX_BAUD_RATE,
185 .procname = "max_baud_rate", 173 .procname = "max_baud_rate",
186 .data = &sysctl_max_baud_rate, 174 .data = &sysctl_max_baud_rate,
187 .maxlen = sizeof(int), 175 .maxlen = sizeof(int),
188 .mode = 0644, 176 .mode = 0644,
189 .proc_handler = proc_dointvec_minmax, 177 .proc_handler = proc_dointvec_minmax,
190 .strategy = sysctl_intvec,
191 .extra1 = &min_max_baud_rate, 178 .extra1 = &min_max_baud_rate,
192 .extra2 = &max_max_baud_rate 179 .extra2 = &max_max_baud_rate
193 }, 180 },
194 { 181 {
195 .ctl_name = NET_IRDA_MIN_TX_TURN_TIME,
196 .procname = "min_tx_turn_time", 182 .procname = "min_tx_turn_time",
197 .data = &sysctl_min_tx_turn_time, 183 .data = &sysctl_min_tx_turn_time,
198 .maxlen = sizeof(int), 184 .maxlen = sizeof(int),
199 .mode = 0644, 185 .mode = 0644,
200 .proc_handler = proc_dointvec_minmax, 186 .proc_handler = proc_dointvec_minmax,
201 .strategy = sysctl_intvec,
202 .extra1 = &min_min_tx_turn_time, 187 .extra1 = &min_min_tx_turn_time,
203 .extra2 = &max_min_tx_turn_time 188 .extra2 = &max_min_tx_turn_time
204 }, 189 },
205 { 190 {
206 .ctl_name = NET_IRDA_MAX_TX_DATA_SIZE,
207 .procname = "max_tx_data_size", 191 .procname = "max_tx_data_size",
208 .data = &sysctl_max_tx_data_size, 192 .data = &sysctl_max_tx_data_size,
209 .maxlen = sizeof(int), 193 .maxlen = sizeof(int),
210 .mode = 0644, 194 .mode = 0644,
211 .proc_handler = proc_dointvec_minmax, 195 .proc_handler = proc_dointvec_minmax,
212 .strategy = sysctl_intvec,
213 .extra1 = &min_max_tx_data_size, 196 .extra1 = &min_max_tx_data_size,
214 .extra2 = &max_max_tx_data_size 197 .extra2 = &max_max_tx_data_size
215 }, 198 },
216 { 199 {
217 .ctl_name = NET_IRDA_MAX_TX_WINDOW,
218 .procname = "max_tx_window", 200 .procname = "max_tx_window",
219 .data = &sysctl_max_tx_window, 201 .data = &sysctl_max_tx_window,
220 .maxlen = sizeof(int), 202 .maxlen = sizeof(int),
221 .mode = 0644, 203 .mode = 0644,
222 .proc_handler = proc_dointvec_minmax, 204 .proc_handler = proc_dointvec_minmax,
223 .strategy = sysctl_intvec,
224 .extra1 = &min_max_tx_window, 205 .extra1 = &min_max_tx_window,
225 .extra2 = &max_max_tx_window 206 .extra2 = &max_max_tx_window
226 }, 207 },
227 { 208 {
228 .ctl_name = NET_IRDA_MAX_NOREPLY_TIME,
229 .procname = "max_noreply_time", 209 .procname = "max_noreply_time",
230 .data = &sysctl_max_noreply_time, 210 .data = &sysctl_max_noreply_time,
231 .maxlen = sizeof(int), 211 .maxlen = sizeof(int),
232 .mode = 0644, 212 .mode = 0644,
233 .proc_handler = proc_dointvec_minmax, 213 .proc_handler = proc_dointvec_minmax,
234 .strategy = sysctl_intvec,
235 .extra1 = &min_max_noreply_time, 214 .extra1 = &min_max_noreply_time,
236 .extra2 = &max_max_noreply_time 215 .extra2 = &max_max_noreply_time
237 }, 216 },
238 { 217 {
239 .ctl_name = NET_IRDA_WARN_NOREPLY_TIME,
240 .procname = "warn_noreply_time", 218 .procname = "warn_noreply_time",
241 .data = &sysctl_warn_noreply_time, 219 .data = &sysctl_warn_noreply_time,
242 .maxlen = sizeof(int), 220 .maxlen = sizeof(int),
243 .mode = 0644, 221 .mode = 0644,
244 .proc_handler = proc_dointvec_minmax, 222 .proc_handler = proc_dointvec_minmax,
245 .strategy = sysctl_intvec,
246 .extra1 = &min_warn_noreply_time, 223 .extra1 = &min_warn_noreply_time,
247 .extra2 = &max_warn_noreply_time 224 .extra2 = &max_warn_noreply_time
248 }, 225 },
249 { 226 {
250 .ctl_name = NET_IRDA_LAP_KEEPALIVE_TIME,
251 .procname = "lap_keepalive_time", 227 .procname = "lap_keepalive_time",
252 .data = &sysctl_lap_keepalive_time, 228 .data = &sysctl_lap_keepalive_time,
253 .maxlen = sizeof(int), 229 .maxlen = sizeof(int),
254 .mode = 0644, 230 .mode = 0644,
255 .proc_handler = proc_dointvec_minmax, 231 .proc_handler = proc_dointvec_minmax,
256 .strategy = sysctl_intvec,
257 .extra1 = &min_lap_keepalive_time, 232 .extra1 = &min_lap_keepalive_time,
258 .extra2 = &max_lap_keepalive_time 233 .extra2 = &max_lap_keepalive_time
259 }, 234 },
260 { .ctl_name = 0 } 235 { }
261}; 236};
262 237
263static struct ctl_path irda_path[] = { 238static struct ctl_path irda_path[] = {
264 { .procname = "net", .ctl_name = CTL_NET, }, 239 { .procname = "net", },
265 { .procname = "irda", .ctl_name = NET_IRDA, }, 240 { .procname = "irda", },
266 { } 241 { }
267}; 242};
268 243
diff --git a/net/irda/irttp.c b/net/irda/irttp.c
index 9cb79f95bf63..47db1d8a0d92 100644
--- a/net/irda/irttp.c
+++ b/net/irda/irttp.c
@@ -28,6 +28,7 @@
28#include <linux/init.h> 28#include <linux/init.h>
29#include <linux/fs.h> 29#include <linux/fs.h>
30#include <linux/seq_file.h> 30#include <linux/seq_file.h>
31#include <linux/slab.h>
31 32
32#include <asm/byteorder.h> 33#include <asm/byteorder.h>
33#include <asm/unaligned.h> 34#include <asm/unaligned.h>