Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
linux
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
linux
Commits
4a513ec1
Commit
4a513ec1
authored
Aug 19, 2003
by
Stephen Hemminger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[IRDA]: Convert irlan to use alloc_netdev().
parent
8eff18f1
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
63 deletions
+35
-63
include/net/irda/irlan_common.h
include/net/irda/irlan_common.h
+1
-1
include/net/irda/irlan_eth.h
include/net/irda/irlan_eth.h
+1
-1
net/irda/irlan/irlan_client.c
net/irda/irlan/irlan_client.c
+1
-1
net/irda/irlan/irlan_common.c
net/irda/irlan/irlan_common.c
+27
-53
net/irda/irlan/irlan_eth.c
net/irda/irlan/irlan_eth.c
+5
-7
No files found.
include/net/irda/irlan_common.h
View file @
4a513ec1
...
@@ -162,7 +162,7 @@ struct irlan_provider_cb {
...
@@ -162,7 +162,7 @@ struct irlan_provider_cb {
struct
irlan_cb
{
struct
irlan_cb
{
int
magic
;
int
magic
;
struct
list_head
dev_list
;
struct
list_head
dev_list
;
struct
net_device
dev
;
/* Ethernet device structure*/
struct
net_device
*
dev
;
/* Ethernet device structure*/
struct
net_device_stats
stats
;
struct
net_device_stats
stats
;
__u32
saddr
;
/* Source device address */
__u32
saddr
;
/* Source device address */
...
...
include/net/irda/irlan_eth.h
View file @
4a513ec1
...
@@ -25,7 +25,7 @@
...
@@ -25,7 +25,7 @@
#ifndef IRLAN_ETH_H
#ifndef IRLAN_ETH_H
#define IRLAN_ETH_H
#define IRLAN_ETH_H
int
irlan_eth_init
(
struct
net_device
*
dev
);
void
irlan_eth_setup
(
struct
net_device
*
dev
);
int
irlan_eth_open
(
struct
net_device
*
dev
);
int
irlan_eth_open
(
struct
net_device
*
dev
);
int
irlan_eth_close
(
struct
net_device
*
dev
);
int
irlan_eth_close
(
struct
net_device
*
dev
);
int
irlan_eth_receive
(
void
*
instance
,
void
*
sap
,
struct
sk_buff
*
skb
);
int
irlan_eth_receive
(
void
*
instance
,
void
*
sap
,
struct
sk_buff
*
skb
);
...
...
net/irda/irlan/irlan_client.c
View file @
4a513ec1
...
@@ -512,7 +512,7 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
...
@@ -512,7 +512,7 @@ static void irlan_check_response_param(struct irlan_cb *self, char *param,
bytes
[
0
],
bytes
[
1
],
bytes
[
2
],
bytes
[
3
],
bytes
[
4
],
bytes
[
0
],
bytes
[
1
],
bytes
[
2
],
bytes
[
3
],
bytes
[
4
],
bytes
[
5
]);
bytes
[
5
]);
for
(
i
=
0
;
i
<
6
;
i
++
)
for
(
i
=
0
;
i
<
6
;
i
++
)
self
->
dev
.
dev_addr
[
i
]
=
bytes
[
i
];
self
->
dev
->
dev_addr
[
i
]
=
bytes
[
i
];
}
}
}
}
...
...
net/irda/irlan/irlan_common.c
View file @
4a513ec1
...
@@ -173,33 +173,6 @@ void __exit irlan_cleanup(void)
...
@@ -173,33 +173,6 @@ void __exit irlan_cleanup(void)
rtnl_unlock
();
rtnl_unlock
();
}
}
/*
* Function irlan_register_netdev (self)
*
* Registers the network device to be used. We should don't register until
* we have been binded to a particular provider or client.
*/
int
irlan_register_netdev
(
struct
irlan_cb
*
self
)
{
int
i
=
0
;
IRDA_DEBUG
(
0
,
"%s()
\n
"
,
__FUNCTION__
);
/* Check if we should call the device eth<x> or irlan<x> */
if
(
!
eth
)
{
/* Get the first free irlan<x> name */
do
{
sprintf
(
self
->
dev
.
name
,
"%s%d"
,
"irlan"
,
i
++
);
}
while
(
dev_get
(
self
->
dev
.
name
));
}
if
(
register_netdev
(
&
self
->
dev
)
!=
0
)
{
IRDA_DEBUG
(
2
,
"%s(), register_netdev() failed!
\n
"
,
__FUNCTION__
);
return
-
1
;
}
return
0
;
}
/*
/*
* Function irlan_open (void)
* Function irlan_open (void)
*
*
...
@@ -208,30 +181,25 @@ int irlan_register_netdev(struct irlan_cb *self)
...
@@ -208,30 +181,25 @@ int irlan_register_netdev(struct irlan_cb *self)
*/
*/
struct
irlan_cb
*
irlan_open
(
__u32
saddr
,
__u32
daddr
)
struct
irlan_cb
*
irlan_open
(
__u32
saddr
,
__u32
daddr
)
{
{
struct
net_device
*
dev
;
struct
irlan_cb
*
self
;
struct
irlan_cb
*
self
;
IRDA_DEBUG
(
2
,
"%s()
\n
"
,
__FUNCTION__
);
IRDA_DEBUG
(
2
,
"%s()
\n
"
,
__FUNCTION__
);
/*
/*
Create network device with irlan */
* Initialize the irlan structure.
dev
=
alloc_netdev
(
sizeof
(
*
self
),
*/
eth
?
"eth%d"
:
"irlan%d"
,
self
=
kmalloc
(
sizeof
(
struct
irlan_cb
),
GFP_ATOMIC
);
irlan_eth_setup
);
if
(
self
==
NULL
)
if
(
!
dev
)
return
NULL
;
return
NULL
;
memset
(
self
,
0
,
sizeof
(
struct
irlan_cb
));
self
=
dev
->
priv
;
self
->
dev
=
dev
;
/*
/*
* Initialize local device structure
* Initialize local device structure
*/
*/
self
->
magic
=
IRLAN_MAGIC
;
self
->
magic
=
IRLAN_MAGIC
;
sprintf
(
self
->
dev
.
name
,
"%s"
,
"unknown"
);
self
->
dev
.
priv
=
(
void
*
)
self
;
self
->
dev
.
next
=
NULL
;
self
->
dev
.
init
=
irlan_eth_init
;
self
->
saddr
=
saddr
;
self
->
saddr
=
saddr
;
self
->
daddr
=
daddr
;
self
->
daddr
=
daddr
;
...
@@ -243,14 +211,21 @@ struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
...
@@ -243,14 +211,21 @@ struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
init_timer
(
&
self
->
client
.
kick_timer
);
init_timer
(
&
self
->
client
.
kick_timer
);
init_waitqueue_head
(
&
self
->
open_wait
);
init_waitqueue_head
(
&
self
->
open_wait
);
list_add_rcu
(
&
self
->
dev_list
,
&
irlans
);
skb_queue_head_init
(
&
self
->
client
.
txq
);
skb_queue_head_init
(
&
self
->
client
.
txq
);
irlan_next_client_state
(
self
,
IRLAN_IDLE
);
irlan_next_client_state
(
self
,
IRLAN_IDLE
);
irlan_next_provider_state
(
self
,
IRLAN_IDLE
);
irlan_next_provider_state
(
self
,
IRLAN_IDLE
);
irlan_register_netdev
(
self
);
if
(
register_netdev
(
dev
))
{
IRDA_DEBUG
(
2
,
"%s(), register_netdev() failed!
\n
"
,
__FUNCTION__
);
self
=
NULL
;
kfree
(
dev
);
}
else
{
rtnl_lock
();
list_add_rcu
(
&
self
->
dev_list
,
&
irlans
);
rtnl_unlock
();
}
return
self
;
return
self
;
}
}
...
@@ -258,7 +233,8 @@ struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
...
@@ -258,7 +233,8 @@ struct irlan_cb *irlan_open(__u32 saddr, __u32 daddr)
* Function __irlan_close (self)
* Function __irlan_close (self)
*
*
* This function closes and deallocates the IrLAN client instances. Be
* This function closes and deallocates the IrLAN client instances. Be
* aware that other functions which calles client_close()
* aware that other functions which calls client_close() must
* remove self from irlans list first.
*/
*/
static
void
__irlan_close
(
struct
irlan_cb
*
self
)
static
void
__irlan_close
(
struct
irlan_cb
*
self
)
{
{
...
@@ -283,10 +259,8 @@ static void __irlan_close(struct irlan_cb *self)
...
@@ -283,10 +259,8 @@ static void __irlan_close(struct irlan_cb *self)
while
((
skb
=
skb_dequeue
(
&
self
->
client
.
txq
)))
while
((
skb
=
skb_dequeue
(
&
self
->
client
.
txq
)))
dev_kfree_skb
(
skb
);
dev_kfree_skb
(
skb
);
unregister_netdevice
(
&
self
->
dev
);
/* Unregister and free self via destructor */
unregister_netdevice
(
self
->
dev
);
self
->
magic
=
0
;
kfree
(
self
);
}
}
/* Find any instance of irlan, used for client discovery wakeup */
/* Find any instance of irlan, used for client discovery wakeup */
...
@@ -348,7 +322,7 @@ void irlan_connect_indication(void *instance, void *sap, struct qos_info *qos,
...
@@ -348,7 +322,7 @@ void irlan_connect_indication(void *instance, void *sap, struct qos_info *qos,
irlan_open_unicast_addr
(
self
);
irlan_open_unicast_addr
(
self
);
}
}
/* Ready to transfer Ethernet frames (at last) */
/* Ready to transfer Ethernet frames (at last) */
netif_start_queue
(
&
self
->
dev
);
/* Clear reason */
netif_start_queue
(
self
->
dev
);
/* Clear reason */
}
}
void
irlan_connect_confirm
(
void
*
instance
,
void
*
sap
,
struct
qos_info
*
qos
,
void
irlan_connect_confirm
(
void
*
instance
,
void
*
sap
,
struct
qos_info
*
qos
,
...
@@ -382,7 +356,7 @@ void irlan_connect_confirm(void *instance, void *sap, struct qos_info *qos,
...
@@ -382,7 +356,7 @@ void irlan_connect_confirm(void *instance, void *sap, struct qos_info *qos,
irlan_set_multicast_filter
(
self
,
TRUE
);
irlan_set_multicast_filter
(
self
,
TRUE
);
/* Ready to transfer Ethernet frames */
/* Ready to transfer Ethernet frames */
netif_start_queue
(
&
self
->
dev
);
netif_start_queue
(
self
->
dev
);
self
->
disconnect_reason
=
0
;
/* Clear reason */
self
->
disconnect_reason
=
0
;
/* Clear reason */
#ifdef CONFIG_IRLAN_SEND_GRATUITOUS_ARP
#ifdef CONFIG_IRLAN_SEND_GRATUITOUS_ARP
irlan_eth_send_gratuitous_arp
(
&
self
->
dev
);
irlan_eth_send_gratuitous_arp
(
&
self
->
dev
);
...
@@ -1110,7 +1084,7 @@ static int irlan_proc_read(char *buf, char **start, off_t offset, int len)
...
@@ -1110,7 +1084,7 @@ static int irlan_proc_read(char *buf, char **start, off_t offset, int len)
ASSERT
(
self
->
magic
==
IRLAN_MAGIC
,
break
;);
ASSERT
(
self
->
magic
==
IRLAN_MAGIC
,
break
;);
len
+=
sprintf
(
buf
+
len
,
"ifname: %s,
\n
"
,
len
+=
sprintf
(
buf
+
len
,
"ifname: %s,
\n
"
,
self
->
dev
.
name
);
self
->
dev
->
name
);
len
+=
sprintf
(
buf
+
len
,
"client state: %s, "
,
len
+=
sprintf
(
buf
+
len
,
"client state: %s, "
,
irlan_state
[
self
->
client
.
state
]);
irlan_state
[
self
->
client
.
state
]);
len
+=
sprintf
(
buf
+
len
,
"provider state: %s,
\n
"
,
len
+=
sprintf
(
buf
+
len
,
"provider state: %s,
\n
"
,
...
@@ -1132,7 +1106,7 @@ static int irlan_proc_read(char *buf, char **start, off_t offset, int len)
...
@@ -1132,7 +1106,7 @@ static int irlan_proc_read(char *buf, char **start, off_t offset, int len)
buf
+
len
);
buf
+
len
);
len
+=
sprintf
(
buf
+
len
,
"tx busy: %s
\n
"
,
len
+=
sprintf
(
buf
+
len
,
"tx busy: %s
\n
"
,
netif_queue_stopped
(
&
self
->
dev
)
?
"TRUE"
:
"FALSE"
);
netif_queue_stopped
(
self
->
dev
)
?
"TRUE"
:
"FALSE"
);
len
+=
sprintf
(
buf
+
len
,
"
\n
"
);
len
+=
sprintf
(
buf
+
len
,
"
\n
"
);
}
}
...
...
net/irda/irlan/irlan_eth.c
View file @
4a513ec1
...
@@ -47,14 +47,12 @@
...
@@ -47,14 +47,12 @@
* The network device initialization function.
* The network device initialization function.
*
*
*/
*/
int
irlan_eth_init
(
struct
net_device
*
dev
)
void
irlan_eth_setup
(
struct
net_device
*
dev
)
{
{
struct
irlan_cb
*
self
;
struct
irlan_cb
*
self
;
IRDA_DEBUG
(
2
,
"%s()
\n
"
,
__FUNCTION__
);
IRDA_DEBUG
(
2
,
"%s()
\n
"
,
__FUNCTION__
);
ASSERT
(
dev
!=
NULL
,
return
-
1
;);
self
=
(
struct
irlan_cb
*
)
dev
->
priv
;
self
=
(
struct
irlan_cb
*
)
dev
->
priv
;
dev
->
open
=
irlan_eth_open
;
dev
->
open
=
irlan_eth_open
;
...
@@ -62,6 +60,8 @@ int irlan_eth_init(struct net_device *dev)
...
@@ -62,6 +60,8 @@ int irlan_eth_init(struct net_device *dev)
dev
->
hard_start_xmit
=
irlan_eth_xmit
;
dev
->
hard_start_xmit
=
irlan_eth_xmit
;
dev
->
get_stats
=
irlan_eth_get_stats
;
dev
->
get_stats
=
irlan_eth_get_stats
;
dev
->
set_multicast_list
=
irlan_eth_set_multicast_list
;
dev
->
set_multicast_list
=
irlan_eth_set_multicast_list
;
dev
->
destructor
=
(
void
(
*
)(
struct
net_device
*
))
kfree
;
SET_MODULE_OWNER
(
dev
);
SET_MODULE_OWNER
(
dev
);
ether_setup
(
dev
);
ether_setup
(
dev
);
...
@@ -85,8 +85,6 @@ int irlan_eth_init(struct net_device *dev)
...
@@ -85,8 +85,6 @@ int irlan_eth_init(struct net_device *dev)
get_random_bytes
(
dev
->
dev_addr
+
4
,
1
);
get_random_bytes
(
dev
->
dev_addr
+
4
,
1
);
get_random_bytes
(
dev
->
dev_addr
+
5
,
1
);
get_random_bytes
(
dev
->
dev_addr
+
5
,
1
);
}
}
return
0
;
}
}
/*
/*
...
@@ -237,7 +235,7 @@ int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb)
...
@@ -237,7 +235,7 @@ int irlan_eth_receive(void *instance, void *sap, struct sk_buff *skb)
* might have been previously set by the low level IrDA network
* might have been previously set by the low level IrDA network
* device driver
* device driver
*/
*/
skb
->
dev
=
&
self
->
dev
;
skb
->
dev
=
self
->
dev
;
skb
->
protocol
=
eth_type_trans
(
skb
,
skb
->
dev
);
/* Remove eth header */
skb
->
protocol
=
eth_type_trans
(
skb
,
skb
->
dev
);
/* Remove eth header */
self
->
stats
.
rx_packets
++
;
self
->
stats
.
rx_packets
++
;
...
@@ -264,7 +262,7 @@ void irlan_eth_flow_indication(void *instance, void *sap, LOCAL_FLOW flow)
...
@@ -264,7 +262,7 @@ void irlan_eth_flow_indication(void *instance, void *sap, LOCAL_FLOW flow)
ASSERT
(
self
!=
NULL
,
return
;);
ASSERT
(
self
!=
NULL
,
return
;);
ASSERT
(
self
->
magic
==
IRLAN_MAGIC
,
return
;);
ASSERT
(
self
->
magic
==
IRLAN_MAGIC
,
return
;);
dev
=
&
self
->
dev
;
dev
=
self
->
dev
;
ASSERT
(
dev
!=
NULL
,
return
;);
ASSERT
(
dev
!=
NULL
,
return
;);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment