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
Kirill Smelkov
linux
Commits
be0b01c4
Commit
be0b01c4
authored
Jun 04, 2003
by
Alexander Viro
Committed by
David S. Miller
Jun 04, 2003
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[NET]: Convert USB drivers away from init_etherdev().
parent
750b8c7c
Changes
7
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
148 additions
and
137 deletions
+148
-137
drivers/usb/net/catc.c
drivers/usb/net/catc.c
+12
-1
drivers/usb/net/cdc-ether.c
drivers/usb/net/cdc-ether.c
+13
-1
drivers/usb/net/kaweth.c
drivers/usb/net/kaweth.c
+8
-4
drivers/usb/net/pegasus.c
drivers/usb/net/pegasus.c
+29
-39
drivers/usb/net/pegasus.h
drivers/usb/net/pegasus.h
+0
-1
drivers/usb/net/rtl8150.c
drivers/usb/net/rtl8150.c
+16
-23
drivers/usb/net/usbnet.c
drivers/usb/net/usbnet.c
+70
-68
No files found.
drivers/usb/net/catc.c
View file @
be0b01c4
...
...
@@ -795,7 +795,7 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
memset
(
catc
,
0
,
sizeof
(
struct
catc
));
netdev
=
init_etherdev
(
0
,
0
);
netdev
=
alloc_etherdev
(
0
);
if
(
!
netdev
)
{
kfree
(
catc
);
return
-
EIO
;
...
...
@@ -933,6 +933,17 @@ static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id
for
(
i
=
0
;
i
<
5
;
i
++
)
printk
(
"%2.2x:"
,
netdev
->
dev_addr
[
i
]);
printk
(
"%2.2x.
\n
"
,
netdev
->
dev_addr
[
i
]);
usb_set_intfdata
(
intf
,
catc
);
if
(
register_netdev
(
netdev
)
!=
0
)
{
usb_set_intfdata
(
intf
,
NULL
);
usb_free_urb
(
catc
->
ctrl_urb
);
usb_free_urb
(
catc
->
tx_urb
);
usb_free_urb
(
catc
->
rx_urb
);
usb_free_urb
(
catc
->
irq_urb
);
kfree
(
netdev
);
kfree
(
catc
);
return
-
EIO
;
}
return
0
;
}
...
...
drivers/usb/net/cdc-ether.c
View file @
be0b01c4
...
...
@@ -1216,7 +1216,7 @@ static int CDCEther_probe( struct usb_interface *intf,
}
// Now we need to get a kernel Ethernet interface.
net
=
init_etherdev
(
NULL
,
0
);
net
=
alloc_etherdev
(
0
);
if
(
!
net
)
{
// Hmm... The kernel is not sharing today...
// Fine, we didn't want it anyway...
...
...
@@ -1263,6 +1263,11 @@ static int CDCEther_probe( struct usb_interface *intf,
// TODO - last minute HACK
ether_dev
->
comm_ep_in
=
5
;
if
(
register_netdev
(
net
)
!=
0
)
{
usb_put_dev
(
usb
);
goto
out
;
}
/* FIXME!!! This driver needs to be fixed to work with the new USB interface logic
* this is not the correct thing to be doing here, we need to set the interface
* driver specific data field.
...
...
@@ -1270,6 +1275,13 @@ static int CDCEther_probe( struct usb_interface *intf,
// Okay, we are finally done...
return
0
;
out:
usb_driver_release_interface
(
&
CDCEther_driver
,
&
(
usb
->
config
[
ether_dev
->
configuration_num
].
interface
[
ether_dev
->
comm_interface
])
);
usb_driver_release_interface
(
&
CDCEther_driver
,
&
(
usb
->
config
[
ether_dev
->
configuration_num
].
interface
[
ether_dev
->
data_interface
])
);
// bailing out with our tail between our knees
error_all:
usb_free_urb
(
ether_dev
->
tx_urb
);
...
...
drivers/usb/net/kaweth.c
View file @
be0b01c4
...
...
@@ -1016,7 +1016,7 @@ static int kaweth_probe(
kaweth_dbg
(
"Initializing net device."
);
if
(
!
(
netdev
=
kmalloc
(
sizeof
(
struct
net_device
),
GFP_KERNEL
)))
{
if
(
!
(
netdev
=
alloc_etherdev
(
0
)))
{
kfree
(
kaweth
);
return
-
ENOMEM
;
}
...
...
@@ -1054,18 +1054,21 @@ static int kaweth_probe(
SET_MODULE_OWNER
(
netdev
);
if
(
!
init_etherdev
(
netdev
,
0
))
{
usb_set_intfdata
(
intf
,
kaweth
);
if
(
register_netdev
(
netdev
)
!=
0
)
{
kaweth_err
(
"Error calling init_etherdev."
);
goto
err_
tx_and_rx
;
goto
err_
intfdata
;
}
kaweth_info
(
"kaweth interface created at %s"
,
kaweth
->
net
->
name
);
kaweth_dbg
(
"Kaweth probe returning."
);
usb_set_intfdata
(
intf
,
kaweth
);
return
0
;
err_intfdata:
usb_set_intfdata
(
intf
,
NULL
);
err_tx_and_rx:
usb_free_urb
(
kaweth
->
rx_urb
);
err_only_tx:
...
...
@@ -1113,6 +1116,7 @@ static void kaweth_disconnect(struct usb_interface *intf)
kaweth_dbg
(
"Unregistering net device"
);
unregister_netdev
(
kaweth
->
net
);
kfree
(
kaweth
->
net
);
}
usb_free_urb
(
kaweth
->
rx_urb
);
...
...
drivers/usb/net/pegasus.c
View file @
be0b01c4
...
...
@@ -865,8 +865,6 @@ static int pegasus_open(struct net_device *net)
if
(
!
pegasus
->
rx_skb
)
return
-
ENOMEM
;
down
(
&
pegasus
->
sem
);
set_registers
(
pegasus
,
EthID
,
6
,
net
->
dev_addr
);
usb_fill_bulk_urb
(
pegasus
->
rx_urb
,
pegasus
->
usb
,
...
...
@@ -894,8 +892,6 @@ static int pegasus_open(struct net_device *net)
set_carrier
(
net
);
res
=
0
;
exit:
up
(
&
pegasus
->
sem
);
return
res
;
}
...
...
@@ -903,13 +899,11 @@ static int pegasus_close(struct net_device *net)
{
pegasus_t
*
pegasus
=
net
->
priv
;
down
(
&
pegasus
->
sem
);
pegasus
->
flags
&=
~
PEGASUS_RUNNING
;
netif_stop_queue
(
net
);
if
(
!
(
pegasus
->
flags
&
PEGASUS_UNPLUG
))
disable_net_traffic
(
pegasus
);
unlink_all_urbs
(
pegasus
);
up
(
&
pegasus
->
sem
);
return
0
;
}
...
...
@@ -1068,7 +1062,6 @@ static int pegasus_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
pegasus_t
*
pegasus
=
net
->
priv
;
int
res
;
down
(
&
pegasus
->
sem
);
switch
(
cmd
)
{
case
SIOCETHTOOL
:
res
=
pegasus_ethtool_ioctl
(
net
,
rq
->
ifr_data
);
...
...
@@ -1080,17 +1073,14 @@ static int pegasus_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
res
=
0
;
break
;
case
SIOCDEVPRIVATE
+
2
:
if
(
!
capable
(
CAP_NET_ADMIN
))
{
up
(
&
pegasus
->
sem
);
if
(
!
capable
(
CAP_NET_ADMIN
))
return
-
EPERM
;
}
write_mii_word
(
pegasus
,
pegasus
->
phy
,
data
[
1
]
&
0x1f
,
data
[
2
]);
res
=
0
;
break
;
default:
res
=
-
EOPNOTSUPP
;
}
up
(
&
pegasus
->
sem
);
return
res
;
}
...
...
@@ -1170,33 +1160,27 @@ static int pegasus_probe(struct usb_interface *intf,
struct
net_device
*
net
;
pegasus_t
*
pegasus
;
int
dev_index
=
id
-
pegasus_ids
;
int
res
=
-
ENOMEM
;
usb_get_dev
(
dev
);
if
(
!
(
pegasus
=
kmalloc
(
sizeof
(
struct
pegasus
),
GFP_KERNEL
)))
{
err
(
"out of memory allocating device structure"
);
return
-
ENOMEM
;
goto
out
;
}
usb_get_dev
(
dev
);
memset
(
pegasus
,
0
,
sizeof
(
struct
pegasus
));
pegasus
->
dev_index
=
dev_index
;
init_waitqueue_head
(
&
pegasus
->
ctrl_wait
);
if
(
!
alloc_urbs
(
pegasus
))
{
kfree
(
pegasus
);
return
-
ENOMEM
;
}
if
(
!
alloc_urbs
(
pegasus
))
goto
out1
;
net
=
init_etherdev
(
NULL
,
0
);
if
(
!
net
)
{
free_all_urbs
(
pegasus
);
kfree
(
pegasus
);
return
-
ENODEV
;
}
net
=
alloc_etherdev
(
0
);
if
(
!
net
)
goto
out2
;
init_MUTEX
(
&
pegasus
->
sem
);
tasklet_init
(
&
pegasus
->
rx_tl
,
rx_fixup
,
(
unsigned
long
)
pegasus
);
down
(
&
pegasus
->
sem
);
pegasus
->
usb
=
dev
;
pegasus
->
net
=
net
;
SET_MODULE_OWNER
(
net
);
...
...
@@ -1221,12 +1205,8 @@ static int pegasus_probe(struct usb_interface *intf,
get_interrupt_interval
(
pegasus
);
if
(
reset_mac
(
pegasus
))
{
err
(
"can't reset MAC"
);
unregister_netdev
(
pegasus
->
net
);
free_all_urbs
(
pegasus
);
kfree
(
pegasus
->
net
);
kfree
(
pegasus
);
pegasus
=
NULL
;
goto
exit
;
res
=
-
EIO
;
goto
out3
;
}
set_ethernet_addr
(
pegasus
);
fill_skb_pool
(
pegasus
);
...
...
@@ -1240,13 +1220,24 @@ static int pegasus_probe(struct usb_interface *intf,
warn
(
"can't locate MII phy, using default"
);
pegasus
->
phy
=
1
;
}
exit:
up
(
&
pegasus
->
sem
);
if
(
pegasus
)
{
usb_set_intfdata
(
intf
,
pegasus
);
res
=
register_netdev
(
net
);
if
(
res
)
goto
out4
;
return
0
;
}
return
-
EIO
;
out4:
usb_set_intfdata
(
intf
,
NULL
);
free_skb_pool
(
pegasus
);
out3:
kfree
(
net
);
out2:
free_all_urbs
(
pegasus
);
out1:
kfree
(
pegasus
);
out:
usb_put_dev
(
dev
);
return
res
;
}
static
void
pegasus_disconnect
(
struct
usb_interface
*
intf
)
...
...
@@ -1269,7 +1260,6 @@ static void pegasus_disconnect(struct usb_interface *intf)
dev_kfree_skb
(
pegasus
->
rx_skb
);
kfree
(
pegasus
->
net
);
kfree
(
pegasus
);
pegasus
=
NULL
;
}
static
struct
usb_driver
pegasus_driver
=
{
...
...
drivers/usb/net/pegasus.h
View file @
be0b01c4
...
...
@@ -98,7 +98,6 @@ typedef struct pegasus {
struct
sk_buff
*
rx_skb
;
struct
usb_ctrlrequest
dr
;
wait_queue_head_t
ctrl_wait
;
struct
semaphore
sem
;
spinlock_t
rx_pool_lock
;
int
chip
;
unsigned
char
intr_buff
[
8
];
...
...
drivers/usb/net/rtl8150.c
View file @
be0b01c4
...
...
@@ -88,7 +88,6 @@ MODULE_DEVICE_TABLE(usb, rtl8150_table);
struct
rtl8150
{
unsigned
long
flags
;
struct
usb_device
*
udev
;
struct
semaphore
sem
;
struct
tasklet_struct
tl
;
struct
net_device_stats
stats
;
struct
net_device
*
netdev
;
...
...
@@ -638,8 +637,6 @@ static int rtl8150_open(struct net_device *netdev)
if
(
!
dev
->
rx_skb
)
return
-
ENOMEM
;
down
(
&
dev
->
sem
);
set_registers
(
dev
,
IDR
,
6
,
netdev
->
dev_addr
);
usb_fill_bulk_urb
(
dev
->
rx_urb
,
dev
->
udev
,
usb_rcvbulkpipe
(
dev
->
udev
,
1
),
...
...
@@ -653,7 +650,6 @@ static int rtl8150_open(struct net_device *netdev)
warn
(
"%s: intr_urb submit failed: %d"
,
__FUNCTION__
,
res
);
netif_start_queue
(
netdev
);
enable_net_traffic
(
dev
);
up
(
&
dev
->
sem
);
return
res
;
}
...
...
@@ -667,12 +663,10 @@ static int rtl8150_close(struct net_device *netdev)
if
(
!
dev
)
return
-
ENODEV
;
down
(
&
dev
->
sem
);
netif_stop_queue
(
netdev
);
if
(
!
test_bit
(
RTL8150_UNPLUG
,
&
dev
->
flags
))
disable_net_traffic
(
dev
);
unlink_all_urbs
(
dev
);
up
(
&
dev
->
sem
);
return
res
;
}
...
...
@@ -760,7 +754,6 @@ static int rtl8150_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
data
=
(
u16
*
)
&
rq
->
ifr_data
;
res
=
0
;
down
(
&
dev
->
sem
);
switch
(
cmd
)
{
case
SIOCETHTOOL
:
res
=
rtl8150_ethtool_ioctl
(
netdev
,
rq
->
ifr_data
);
...
...
@@ -771,16 +764,13 @@ static int rtl8150_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd)
read_mii_word
(
dev
,
dev
->
phy
,
(
data
[
1
]
&
0x1f
),
&
data
[
3
]);
break
;
case
SIOCDEVPRIVATE
+
2
:
if
(
!
capable
(
CAP_NET_ADMIN
))
{
up
(
&
dev
->
sem
);
if
(
!
capable
(
CAP_NET_ADMIN
))
return
-
EPERM
;
}
write_mii_word
(
dev
,
dev
->
phy
,
(
data
[
1
]
&
0x1f
),
data
[
2
]);
break
;
default:
res
=
-
EOPNOTSUPP
;
}
up
(
&
dev
->
sem
);
return
res
;
}
...
...
@@ -798,18 +788,16 @@ static int rtl8150_probe(struct usb_interface *intf,
}
else
memset
(
dev
,
0
,
sizeof
(
rtl8150_t
));
netdev
=
init_etherdev
(
NULL
,
0
);
netdev
=
alloc_etherdev
(
0
);
if
(
!
netdev
)
{
kfree
(
dev
);
err
(
"Oh boy, out of memory again?!?"
);
return
-
ENOMEM
;
}
init_MUTEX
(
&
dev
->
sem
);
tasklet_init
(
&
dev
->
tl
,
rx_fixup
,
(
unsigned
long
)
dev
);
spin_lock_init
(
&
dev
->
rx_pool_lock
);
down
(
&
dev
->
sem
);
dev
->
udev
=
udev
;
dev
->
netdev
=
netdev
;
SET_MODULE_OWNER
(
netdev
);
...
...
@@ -828,23 +816,30 @@ static int rtl8150_probe(struct usb_interface *intf,
if
(
!
alloc_all_urbs
(
dev
))
{
err
(
"out of memory"
);
goto
err
;
goto
out
;
}
if
(
!
rtl8150_reset
(
dev
))
{
err
(
"couldn't reset the device"
);
free_all_urbs
(
dev
);
goto
err
;
goto
out1
;
}
fill_skb_pool
(
dev
);
set_ethernet_addr
(
dev
);
info
(
"%s: rtl8150 is detected"
,
netdev
->
name
);
up
(
&
dev
->
sem
);
usb_set_intfdata
(
intf
,
dev
);
if
(
register_netdev
(
netdev
)
!=
0
)
{
err
(
"couldn't register the device"
);
goto
out2
;
}
return
0
;
err:
unregister_netdev
(
dev
->
netdev
);
up
(
&
dev
->
sem
);
out2:
usb_set_intfdata
(
intf
,
NULL
);
free_skb_pool
(
dev
);
out1:
free_all_urbs
(
dev
);
out:
kfree
(
netdev
);
kfree
(
dev
);
return
-
EIO
;
...
...
@@ -865,8 +860,6 @@ static void rtl8150_disconnect(struct usb_interface *intf)
dev_kfree_skb
(
dev
->
rx_skb
);
kfree
(
dev
->
netdev
);
kfree
(
dev
);
dev
->
netdev
=
NULL
;
dev
=
NULL
;
}
}
...
...
drivers/usb/net/usbnet.c
View file @
be0b01c4
This diff is collapsed.
Click to expand it.
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