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
adc093b2
Commit
adc093b2
authored
Jan 10, 2004
by
Alexander Viro
Committed by
Stephen Hemminger
Jan 10, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[netdrvr au1000_eth] alloc_etherdev, SET_MODULE_OWNER, fix leaks/small bugs
parent
4f75fe2d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
34 deletions
+27
-34
drivers/net/au1000_eth.c
drivers/net/au1000_eth.c
+27
-34
No files found.
drivers/net/au1000_eth.c
View file @
adc093b2
...
@@ -56,7 +56,7 @@ static void *dma_alloc(size_t, dma_addr_t *);
...
@@ -56,7 +56,7 @@ static void *dma_alloc(size_t, dma_addr_t *);
static
void
dma_free
(
void
*
,
size_t
);
static
void
dma_free
(
void
*
,
size_t
);
static
void
hard_stop
(
struct
net_device
*
);
static
void
hard_stop
(
struct
net_device
*
);
static
void
enable_rx_tx
(
struct
net_device
*
dev
);
static
void
enable_rx_tx
(
struct
net_device
*
dev
);
static
int
__init
au1000_probe1
(
struct
net_device
*
,
long
,
int
,
int
);
static
int
__init
au1000_probe1
(
long
,
int
,
int
);
static
int
au1000_init
(
struct
net_device
*
);
static
int
au1000_init
(
struct
net_device
*
);
static
int
au1000_open
(
struct
net_device
*
);
static
int
au1000_open
(
struct
net_device
*
);
static
int
au1000_close
(
struct
net_device
*
);
static
int
au1000_close
(
struct
net_device
*
);
...
@@ -644,17 +644,17 @@ static int __init au1000_init_module(void)
...
@@ -644,17 +644,17 @@ static int __init au1000_init_module(void)
}
}
// check for valid entries, au1100 only has one entry
// check for valid entries, au1100 only has one entry
if
(
base_addr
&&
irq
)
{
if
(
base_addr
&&
irq
)
{
if
(
au1000_probe1
(
NULL
,
base_addr
,
irq
,
i
)
!=
0
)
{
if
(
au1000_probe1
(
base_addr
,
irq
,
i
)
!=
0
)
return
-
ENODEV
;
return
-
ENODEV
;
}
}
}
}
}
return
0
;
return
0
;
}
}
static
int
__init
static
int
__init
au1000_probe1
(
struct
net_device
*
dev
,
long
ioaddr
,
int
irq
,
int
port_num
)
au1000_probe1
(
long
ioaddr
,
int
irq
,
int
port_num
)
{
{
struct
net_device
*
dev
;
static
unsigned
version_printed
=
0
;
static
unsigned
version_printed
=
0
;
struct
au1000_private
*
aup
=
NULL
;
struct
au1000_private
*
aup
=
NULL
;
int
i
,
retval
=
0
;
int
i
,
retval
=
0
;
...
@@ -668,15 +668,16 @@ au1000_probe1(struct net_device *dev, long ioaddr, int irq, int port_num)
...
@@ -668,15 +668,16 @@ au1000_probe1(struct net_device *dev, long ioaddr, int irq, int port_num)
if
(
version_printed
++
==
0
)
if
(
version_printed
++
==
0
)
printk
(
version
);
printk
(
version
);
if
(
!
dev
)
retval
=
-
ENOMEM
;
dev
=
init_etherdev
(
NULL
,
sizeof
(
struct
au1000_private
));
dev
=
alloc_etherdev
(
sizeof
(
struct
au1000_private
));
if
(
!
dev
)
{
if
(
!
dev
)
{
printk
(
KERN_ERR
"au1000 eth: init_etherdev failed
\n
"
);
printk
(
KERN_ERR
"au1000 eth: alloc_etherdev failed
\n
"
);
release_region
(
ioaddr
,
MAC_IOSIZE
);
goto
out
;
return
-
ENODEV
;
}
}
SET_MODULE_OWNER
(
dev
);
printk
(
"%s: Au1xxx ethernet found at 0x%lx, irq %d
\n
"
,
printk
(
"%s: Au1xxx ethernet found at 0x%lx, irq %d
\n
"
,
dev
->
name
,
ioaddr
,
irq
);
dev
->
name
,
ioaddr
,
irq
);
...
@@ -685,10 +686,8 @@ au1000_probe1(struct net_device *dev, long ioaddr, int irq, int port_num)
...
@@ -685,10 +686,8 @@ au1000_probe1(struct net_device *dev, long ioaddr, int irq, int port_num)
/* Allocate the data buffers */
/* Allocate the data buffers */
aup
->
vaddr
=
(
u32
)
dma_alloc
(
MAX_BUF_SIZE
*
aup
->
vaddr
=
(
u32
)
dma_alloc
(
MAX_BUF_SIZE
*
(
NUM_TX_BUFFS
+
NUM_RX_BUFFS
),
&
aup
->
dma_addr
);
(
NUM_TX_BUFFS
+
NUM_RX_BUFFS
),
&
aup
->
dma_addr
);
if
(
!
aup
->
vaddr
)
{
if
(
!
aup
->
vaddr
)
retval
=
-
ENOMEM
;
goto
out1
;
goto
free_region
;
}
/* aup->mac is the base address of the MAC's registers */
/* aup->mac is the base address of the MAC's registers */
aup
->
mac
=
(
volatile
mac_reg_t
*
)((
unsigned
long
)
ioaddr
);
aup
->
mac
=
(
volatile
mac_reg_t
*
)((
unsigned
long
)
ioaddr
);
...
@@ -749,10 +748,11 @@ au1000_probe1(struct net_device *dev, long ioaddr, int irq, int port_num)
...
@@ -749,10 +748,11 @@ au1000_probe1(struct net_device *dev, long ioaddr, int irq, int port_num)
MAC_EN_RESET2
|
MAC_EN_CLOCK_ENABLE
;
MAC_EN_RESET2
|
MAC_EN_CLOCK_ENABLE
;
au_sync_delay
(
2
);
au_sync_delay
(
2
);
if
(
mii_probe
(
dev
)
!=
0
)
{
retval
=
mii_probe
(
dev
);
goto
free_region
;
if
(
retval
)
}
goto
out2
;
retval
=
-
EINVAL
;
pDBfree
=
NULL
;
pDBfree
=
NULL
;
/* setup the data buffer descriptors and attach a buffer to each one */
/* setup the data buffer descriptors and attach a buffer to each one */
pDB
=
aup
->
db
;
pDB
=
aup
->
db
;
...
@@ -767,13 +767,13 @@ au1000_probe1(struct net_device *dev, long ioaddr, int irq, int port_num)
...
@@ -767,13 +767,13 @@ au1000_probe1(struct net_device *dev, long ioaddr, int irq, int port_num)
for
(
i
=
0
;
i
<
NUM_RX_DMA
;
i
++
)
{
for
(
i
=
0
;
i
<
NUM_RX_DMA
;
i
++
)
{
pDB
=
GetFreeDB
(
aup
);
pDB
=
GetFreeDB
(
aup
);
if
(
!
pDB
)
goto
free_region
;
if
(
!
pDB
)
goto
out2
;
aup
->
rx_dma_ring
[
i
]
->
buff_stat
=
(
unsigned
)
pDB
->
dma_addr
;
aup
->
rx_dma_ring
[
i
]
->
buff_stat
=
(
unsigned
)
pDB
->
dma_addr
;
aup
->
rx_db_inuse
[
i
]
=
pDB
;
aup
->
rx_db_inuse
[
i
]
=
pDB
;
}
}
for
(
i
=
0
;
i
<
NUM_TX_DMA
;
i
++
)
{
for
(
i
=
0
;
i
<
NUM_TX_DMA
;
i
++
)
{
pDB
=
GetFreeDB
(
aup
);
pDB
=
GetFreeDB
(
aup
);
if
(
!
pDB
)
goto
free_region
;
if
(
!
pDB
)
goto
out2
;
aup
->
tx_dma_ring
[
i
]
->
buff_stat
=
(
unsigned
)
pDB
->
dma_addr
;
aup
->
tx_dma_ring
[
i
]
->
buff_stat
=
(
unsigned
)
pDB
->
dma_addr
;
aup
->
tx_dma_ring
[
i
]
->
len
=
0
;
aup
->
tx_dma_ring
[
i
]
->
len
=
0
;
aup
->
tx_db_inuse
[
i
]
=
pDB
;
aup
->
tx_db_inuse
[
i
]
=
pDB
;
...
@@ -792,26 +792,25 @@ au1000_probe1(struct net_device *dev, long ioaddr, int irq, int port_num)
...
@@ -792,26 +792,25 @@ au1000_probe1(struct net_device *dev, long ioaddr, int irq, int port_num)
dev
->
tx_timeout
=
au1000_tx_timeout
;
dev
->
tx_timeout
=
au1000_tx_timeout
;
dev
->
watchdog_timeo
=
ETH_TX_TIMEOUT
;
dev
->
watchdog_timeo
=
ETH_TX_TIMEOUT
;
/* Fill in the fields of the device structure with ethernet values. */
ether_setup
(
dev
);
/*
/*
* The boot code uses the ethernet controller, so reset it to start
* The boot code uses the ethernet controller, so reset it to start
* fresh. au1000_init() expects that the device is in reset state.
* fresh. au1000_init() expects that the device is in reset state.
*/
*/
reset_mac
(
dev
);
reset_mac
(
dev
);
retval
=
register_netdev
(
dev
);
if
(
retval
)
goto
out2
;
return
0
;
return
0
;
free_region:
out2:
dma_free
(
aup
->
vaddr
,
MAX_BUF_SIZE
*
(
NUM_TX_BUFFS
+
NUM_RX_BUFFS
));
out1:
free_netdev
(
dev
);
out:
release_region
(
PHYSADDR
(
ioaddr
),
MAC_IOSIZE
);
release_region
(
PHYSADDR
(
ioaddr
),
MAC_IOSIZE
);
unregister_netdev
(
dev
);
if
(
aup
->
vaddr
)
dma_free
((
void
*
)
aup
->
vaddr
,
MAX_BUF_SIZE
*
(
NUM_TX_BUFFS
+
NUM_RX_BUFFS
));
printk
(
KERN_ERR
"%s: au1000_probe1 failed. Returns %d
\n
"
,
printk
(
KERN_ERR
"%s: au1000_probe1 failed. Returns %d
\n
"
,
dev
->
name
,
retval
);
dev
->
name
,
retval
);
free_netdev
(
dev
);
return
retval
;
return
retval
;
}
}
...
@@ -933,15 +932,12 @@ static int au1000_open(struct net_device *dev)
...
@@ -933,15 +932,12 @@ static int au1000_open(struct net_device *dev)
int
retval
;
int
retval
;
struct
au1000_private
*
aup
=
(
struct
au1000_private
*
)
dev
->
priv
;
struct
au1000_private
*
aup
=
(
struct
au1000_private
*
)
dev
->
priv
;
MOD_INC_USE_COUNT
;
if
(
au1000_debug
>
4
)
if
(
au1000_debug
>
4
)
printk
(
"%s: open: dev=%p
\n
"
,
dev
->
name
,
dev
);
printk
(
"%s: open: dev=%p
\n
"
,
dev
->
name
,
dev
);
if
((
retval
=
au1000_init
(
dev
)))
{
if
((
retval
=
au1000_init
(
dev
)))
{
printk
(
KERN_ERR
"%s: error in au1000_init
\n
"
,
dev
->
name
);
printk
(
KERN_ERR
"%s: error in au1000_init
\n
"
,
dev
->
name
);
free_irq
(
dev
->
irq
,
dev
);
free_irq
(
dev
->
irq
,
dev
);
MOD_DEC_USE_COUNT
;
return
retval
;
return
retval
;
}
}
netif_start_queue
(
dev
);
netif_start_queue
(
dev
);
...
@@ -950,7 +946,6 @@ static int au1000_open(struct net_device *dev)
...
@@ -950,7 +946,6 @@ static int au1000_open(struct net_device *dev)
dev
->
name
,
dev
)))
{
dev
->
name
,
dev
)))
{
printk
(
KERN_ERR
"%s: unable to get IRQ %d
\n
"
,
printk
(
KERN_ERR
"%s: unable to get IRQ %d
\n
"
,
dev
->
name
,
dev
->
irq
);
dev
->
name
,
dev
->
irq
);
MOD_DEC_USE_COUNT
;
return
retval
;
return
retval
;
}
}
...
@@ -984,8 +979,6 @@ static int au1000_close(struct net_device *dev)
...
@@ -984,8 +979,6 @@ static int au1000_close(struct net_device *dev)
spin_unlock_irqrestore
(
&
aup
->
lock
,
flags
);
spin_unlock_irqrestore
(
&
aup
->
lock
,
flags
);
reset_mac
(
dev
);
reset_mac
(
dev
);
kfree
(
dev
);
MOD_DEC_USE_COUNT
;
return
0
;
return
0
;
}
}
...
...
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