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
f8df510e
Commit
f8df510e
authored
Jan 13, 2004
by
Chas Williams
Committed by
Stephen Hemminger
Jan 13, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ATM]: [nicstar] convert to new style pci module (by "Jorge Boncompte [DTI2]" <jorge@dti2.net>)
parent
8bc49a7e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
129 additions
and
130 deletions
+129
-130
drivers/atm/atmdev_init.c
drivers/atm/atmdev_init.c
+0
-6
drivers/atm/nicstar.c
drivers/atm/nicstar.c
+129
-124
No files found.
drivers/atm/atmdev_init.c
View file @
f8df510e
...
@@ -10,9 +10,6 @@
...
@@ -10,9 +10,6 @@
#ifdef CONFIG_ATM_ZATM
#ifdef CONFIG_ATM_ZATM
extern
int
zatm_detect
(
void
);
extern
int
zatm_detect
(
void
);
#endif
#endif
#ifdef CONFIG_ATM_NICSTAR
extern
int
nicstar_detect
(
void
);
#endif
#ifdef CONFIG_ATM_AMBASSADOR
#ifdef CONFIG_ATM_AMBASSADOR
extern
int
amb_detect
(
void
);
extern
int
amb_detect
(
void
);
#endif
#endif
...
@@ -41,9 +38,6 @@ int __init atmdev_init(void)
...
@@ -41,9 +38,6 @@ int __init atmdev_init(void)
#ifdef CONFIG_ATM_ZATM
#ifdef CONFIG_ATM_ZATM
devs
+=
zatm_detect
();
devs
+=
zatm_detect
();
#endif
#endif
#ifdef CONFIG_ATM_NICSTAR
devs
+=
nicstar_detect
();
#endif
#ifdef CONFIG_ATM_AMBASSADOR
#ifdef CONFIG_ATM_AMBASSADOR
devs
+=
amb_detect
();
devs
+=
amb_detect
();
#endif
#endif
...
...
drivers/atm/nicstar.c
View file @
f8df510e
...
@@ -214,8 +214,8 @@
...
@@ -214,8 +214,8 @@
static
u32
ns_read_sram
(
ns_dev
*
card
,
u32
sram_address
);
static
u32
ns_read_sram
(
ns_dev
*
card
,
u32
sram_address
);
static
void
ns_write_sram
(
ns_dev
*
card
,
u32
sram_address
,
u32
*
value
,
int
count
);
static
void
ns_write_sram
(
ns_dev
*
card
,
u32
sram_address
,
u32
*
value
,
int
count
);
static
int
__init
ns_init_card
(
int
i
,
struct
pci_dev
*
pcidev
);
static
int
__
dev
init
ns_init_card
(
int
i
,
struct
pci_dev
*
pcidev
);
static
void
__init
ns_init_card_error
(
ns_dev
*
card
,
int
error
);
static
void
__
dev
init
ns_init_card_error
(
ns_dev
*
card
,
int
error
);
static
scq_info
*
get_scq
(
int
size
,
u32
scd
);
static
scq_info
*
get_scq
(
int
size
,
u32
scd
);
static
void
free_scq
(
scq_info
*
scq
,
struct
atm_vcc
*
vcc
);
static
void
free_scq
(
scq_info
*
scq
,
struct
atm_vcc
*
vcc
);
static
void
push_rxbufs
(
ns_dev
*
card
,
u32
type
,
u32
handle1
,
u32
addr1
,
static
void
push_rxbufs
(
ns_dev
*
card
,
u32
type
,
u32
handle1
,
u32
addr1
,
...
@@ -276,136 +276,151 @@ MODULE_LICENSE("GPL");
...
@@ -276,136 +276,151 @@ MODULE_LICENSE("GPL");
/* Functions*******************************************************************/
/* Functions*******************************************************************/
static
int
__init
nicstar_module_init
(
void
)
static
int
__devinit
nicstar_init_one
(
struct
pci_dev
*
pcidev
,
const
struct
pci_device_id
*
ent
)
{
{
int
i
;
static
int
index
=
-
1
;
unsigned
error
=
0
;
/* Initialized to remove compile warning */
unsigned
int
error
;
struct
pci_dev
*
pcidev
;
XPRINTK
(
"nicstar: nicstar_module_init() called.
\n
"
);
index
++
;
cards
[
index
]
=
NULL
;
for
(
i
=
0
;
i
<
NS_MAX_CARDS
;
i
++
)
error
=
ns_init_card
(
index
,
pcidev
);
cards
[
i
]
=
NULL
;
if
(
error
)
{
cards
[
index
--
]
=
NULL
;
/* don't increment index */
pcidev
=
NULL
;
goto
err_out
;
for
(
i
=
0
;
i
<
NS_MAX_CARDS
;
i
++
)
{
if
((
pcidev
=
pci_find_device
(
PCI_VENDOR_ID_IDT
,
PCI_DEVICE_ID_IDT_IDT77201
,
pcidev
))
==
NULL
)
break
;
error
=
ns_init_card
(
i
,
pcidev
);
if
(
error
)
cards
[
i
--
]
=
NULL
;
/* Try to find another card but don't increment index */
}
}
if
(
i
==
0
)
{
if
(
!
error
)
{
printk
(
"nicstar: no cards found.
\n
"
);
return
-
ENXIO
;
}
else
return
-
EIO
;
}
TXPRINTK
(
"nicstar: TX debug enabled.
\n
"
);
RXPRINTK
(
"nicstar: RX debug enabled.
\n
"
);
PRINTK
(
"nicstar: General debug enabled.
\n
"
);
#ifdef PHY_LOOPBACK
printk
(
"nicstar: using PHY loopback.
\n
"
);
#endif
/* PHY_LOOPBACK */
XPRINTK
(
"nicstar: nicstar_module_init() returned.
\n
"
);
init_timer
(
&
ns_timer
);
ns_timer
.
expires
=
jiffies
+
NS_POLL_PERIOD
;
ns_timer
.
data
=
0UL
;
ns_timer
.
function
=
ns_poll
;
add_timer
(
&
ns_timer
);
return
0
;
return
0
;
err_out:
return
-
ENODEV
;
}
}
static
void
__
exit
nicstar_module_exit
(
void
)
static
void
__
devexit
nicstar_remove_one
(
struct
pci_dev
*
pcidev
)
{
{
int
i
,
j
;
int
i
,
j
;
unsigned
short
pci_command
;
ns_dev
*
card
=
pci_get_drvdata
(
pcidev
);
ns_dev
*
card
;
struct
sk_buff
*
hb
;
struct
sk_buff
*
hb
;
struct
sk_buff
*
iovb
;
struct
sk_buff
*
iovb
;
struct
sk_buff
*
lb
;
struct
sk_buff
*
lb
;
struct
sk_buff
*
sb
;
struct
sk_buff
*
sb
;
XPRINTK
(
"nicstar: cleanup_module() called.
\n
"
)
;
i
=
card
->
index
;
del_timer
(
&
ns_timer
);
if
(
cards
[
i
]
==
NULL
)
return
;
for
(
i
=
0
;
i
<
NS_MAX_CARDS
;
i
++
)
if
(
card
->
atmdev
->
phy
&&
card
->
atmdev
->
phy
->
stop
)
card
->
atmdev
->
phy
->
stop
(
card
->
atmdev
);
/* Stop everything */
writel
(
0x00000000
,
card
->
membase
+
CFG
);
/* De-register device */
atm_dev_deregister
(
card
->
atmdev
);
/* Disable PCI device */
pci_disable_device
(
pcidev
);
/* Free up resources */
j
=
0
;
PRINTK
(
"nicstar%d: freeing %d huge buffers.
\n
"
,
i
,
card
->
hbpool
.
count
);
while
((
hb
=
skb_dequeue
(
&
card
->
hbpool
.
queue
))
!=
NULL
)
{
{
if
(
cards
[
i
]
==
NULL
)
dev_kfree_skb_any
(
hb
);
continue
;
j
++
;
}
PRINTK
(
"nicstar%d: %d huge buffers freed.
\n
"
,
i
,
j
);
j
=
0
;
PRINTK
(
"nicstar%d: freeing %d iovec buffers.
\n
"
,
i
,
card
->
iovpool
.
count
);
while
((
iovb
=
skb_dequeue
(
&
card
->
iovpool
.
queue
))
!=
NULL
)
{
dev_kfree_skb_any
(
iovb
);
j
++
;
}
PRINTK
(
"nicstar%d: %d iovec buffers freed.
\n
"
,
i
,
j
);
while
((
lb
=
skb_dequeue
(
&
card
->
lbpool
.
queue
))
!=
NULL
)
dev_kfree_skb_any
(
lb
);
while
((
sb
=
skb_dequeue
(
&
card
->
sbpool
.
queue
))
!=
NULL
)
dev_kfree_skb_any
(
sb
);
free_scq
(
card
->
scq0
,
NULL
);
for
(
j
=
0
;
j
<
NS_FRSCD_NUM
;
j
++
)
{
if
(
card
->
scd2vc
[
j
]
!=
NULL
)
free_scq
(
card
->
scd2vc
[
j
]
->
scq
,
card
->
scd2vc
[
j
]
->
tx_vcc
);
}
kfree
(
card
->
rsq
.
org
);
kfree
(
card
->
tsq
.
org
);
free_irq
(
card
->
pcidev
->
irq
,
card
);
iounmap
((
void
*
)
card
->
membase
);
kfree
(
card
);
}
card
=
cards
[
i
];
if
(
card
->
atmdev
->
phy
&&
card
->
atmdev
->
phy
->
stop
)
card
->
atmdev
->
phy
->
stop
(
card
->
atmdev
);
/* Stop everything */
static
struct
pci_device_id
nicstar_pci_tbl
[]
__devinitdata
=
writel
(
0x00000000
,
card
->
membase
+
CFG
);
{
{
PCI_VENDOR_ID_IDT
,
PCI_DEVICE_ID_IDT_IDT77201
,
PCI_ANY_ID
,
PCI_ANY_ID
,
0
,
0
,
0
},
{
0
,}
/* terminate list */
};
MODULE_DEVICE_TABLE
(
pci
,
nicstar_pci_tbl
);
/* De-register device */
atm_dev_deregister
(
card
->
atmdev
);
/* Disable memory mapping and busmastering */
if
(
pci_read_config_word
(
card
->
pcidev
,
PCI_COMMAND
,
&
pci_command
)
!=
0
)
static
struct
pci_driver
nicstar_driver
=
{
{
.
name
=
"nicstar"
,
printk
(
"nicstar%d: can't read PCI_COMMAND.
\n
"
,
i
);
.
id_table
=
nicstar_pci_tbl
,
}
.
probe
=
nicstar_init_one
,
pci_command
&=
~
(
PCI_COMMAND_MEMORY
|
PCI_COMMAND_MASTER
);
.
remove
=
__devexit_p
(
nicstar_remove_one
),
if
(
pci_write_config_word
(
card
->
pcidev
,
PCI_COMMAND
,
pci_command
)
!=
0
)
};
{
printk
(
"nicstar%d: can't write PCI_COMMAND.
\n
"
,
i
);
}
static
int
__init
nicstar_init
(
void
)
/* Free up resources */
{
j
=
0
;
unsigned
error
=
0
;
/* Initialized to remove compile warning */
PRINTK
(
"nicstar%d: freeing %d huge buffers.
\n
"
,
i
,
card
->
hbpool
.
count
);
while
((
hb
=
skb_dequeue
(
&
card
->
hbpool
.
queue
))
!=
NULL
)
XPRINTK
(
"nicstar: nicstar_init() called.
\n
"
);
{
dev_kfree_skb_any
(
hb
);
error
=
pci_module_init
(
&
nicstar_driver
);
j
++
;
}
TXPRINTK
(
"nicstar: TX debug enabled.
\n
"
);
PRINTK
(
"nicstar%d: %d huge buffers freed.
\n
"
,
i
,
j
);
RXPRINTK
(
"nicstar: RX debug enabled.
\n
"
);
j
=
0
;
PRINTK
(
"nicstar: General debug enabled.
\n
"
);
PRINTK
(
"nicstar%d: freeing %d iovec buffers.
\n
"
,
i
,
card
->
iovpool
.
count
);
#ifdef PHY_LOOPBACK
while
((
iovb
=
skb_dequeue
(
&
card
->
iovpool
.
queue
))
!=
NULL
)
printk
(
"nicstar: using PHY loopback.
\n
"
);
{
#endif
/* PHY_LOOPBACK */
dev_kfree_skb_any
(
iovb
);
XPRINTK
(
"nicstar: nicstar_init() returned.
\n
"
);
j
++
;
}
if
(
!
error
)
{
PRINTK
(
"nicstar%d: %d iovec buffers freed.
\n
"
,
i
,
j
);
init_timer
(
&
ns_timer
);
while
((
lb
=
skb_dequeue
(
&
card
->
lbpool
.
queue
))
!=
NULL
)
ns_timer
.
expires
=
jiffies
+
NS_POLL_PERIOD
;
dev_kfree_skb_any
(
lb
);
ns_timer
.
data
=
0UL
;
while
((
sb
=
skb_dequeue
(
&
card
->
sbpool
.
queue
))
!=
NULL
)
ns_timer
.
function
=
ns_poll
;
dev_kfree_skb_any
(
sb
);
add_timer
(
&
ns_timer
);
free_scq
(
card
->
scq0
,
NULL
);
for
(
j
=
0
;
j
<
NS_FRSCD_NUM
;
j
++
)
{
if
(
card
->
scd2vc
[
j
]
!=
NULL
)
free_scq
(
card
->
scd2vc
[
j
]
->
scq
,
card
->
scd2vc
[
j
]
->
tx_vcc
);
}
kfree
(
card
->
rsq
.
org
);
kfree
(
card
->
tsq
.
org
);
free_irq
(
card
->
pcidev
->
irq
,
card
);
iounmap
((
void
*
)
card
->
membase
);
kfree
(
card
);
}
}
XPRINTK
(
"nicstar: cleanup_module() returned.
\n
"
);
return
error
;
}
static
void
__exit
nicstar_cleanup
(
void
)
{
XPRINTK
(
"nicstar: nicstar_cleanup() called.
\n
"
);
del_timer
(
&
ns_timer
);
pci_unregister_driver
(
&
nicstar_driver
);
XPRINTK
(
"nicstar: nicstar_cleanup() returned.
\n
"
);
}
}
static
u32
ns_read_sram
(
ns_dev
*
card
,
u32
sram_address
)
static
u32
ns_read_sram
(
ns_dev
*
card
,
u32
sram_address
)
{
{
unsigned
long
flags
;
unsigned
long
flags
;
...
@@ -445,11 +460,10 @@ static void ns_write_sram(ns_dev *card, u32 sram_address, u32 *value, int count)
...
@@ -445,11 +460,10 @@ static void ns_write_sram(ns_dev *card, u32 sram_address, u32 *value, int count)
}
}
static
int
__init
ns_init_card
(
int
i
,
struct
pci_dev
*
pcidev
)
static
int
__
dev
init
ns_init_card
(
int
i
,
struct
pci_dev
*
pcidev
)
{
{
int
j
;
int
j
;
struct
ns_dev
*
card
=
NULL
;
struct
ns_dev
*
card
=
NULL
;
unsigned
short
pci_command
;
unsigned
char
pci_latency
;
unsigned
char
pci_latency
;
unsigned
error
;
unsigned
error
;
u32
data
;
u32
data
;
...
@@ -478,6 +492,8 @@ static int __init ns_init_card(int i, struct pci_dev *pcidev)
...
@@ -478,6 +492,8 @@ static int __init ns_init_card(int i, struct pci_dev *pcidev)
spin_lock_init
(
&
card
->
int_lock
);
spin_lock_init
(
&
card
->
int_lock
);
spin_lock_init
(
&
card
->
res_lock
);
spin_lock_init
(
&
card
->
res_lock
);
pci_set_drvdata
(
pcidev
,
card
);
card
->
index
=
i
;
card
->
index
=
i
;
card
->
atmdev
=
NULL
;
card
->
atmdev
=
NULL
;
card
->
pcidev
=
pcidev
;
card
->
pcidev
=
pcidev
;
...
@@ -492,21 +508,7 @@ static int __init ns_init_card(int i, struct pci_dev *pcidev)
...
@@ -492,21 +508,7 @@ static int __init ns_init_card(int i, struct pci_dev *pcidev)
}
}
PRINTK
(
"nicstar%d: membase at 0x%x.
\n
"
,
i
,
card
->
membase
);
PRINTK
(
"nicstar%d: membase at 0x%x.
\n
"
,
i
,
card
->
membase
);
if
(
pci_read_config_word
(
pcidev
,
PCI_COMMAND
,
&
pci_command
)
!=
0
)
pci_set_master
(
pcidev
);
{
printk
(
"nicstar%d: can't read PCI_COMMAND.
\n
"
,
i
);
error
=
4
;
ns_init_card_error
(
card
,
error
);
return
error
;
}
pci_command
|=
(
PCI_COMMAND_MEMORY
|
PCI_COMMAND_MASTER
);
if
(
pci_write_config_word
(
pcidev
,
PCI_COMMAND
,
pci_command
)
!=
0
)
{
printk
(
"nicstar%d: can't write PCI_COMMAND.
\n
"
,
i
);
error
=
5
;
ns_init_card_error
(
card
,
error
);
return
error
;
}
if
(
pci_read_config_byte
(
pcidev
,
PCI_LATENCY_TIMER
,
&
pci_latency
)
!=
0
)
if
(
pci_read_config_byte
(
pcidev
,
PCI_LATENCY_TIMER
,
&
pci_latency
)
!=
0
)
{
{
...
@@ -932,7 +934,7 @@ static int __init ns_init_card(int i, struct pci_dev *pcidev)
...
@@ -932,7 +934,7 @@ static int __init ns_init_card(int i, struct pci_dev *pcidev)
static
void
__init
ns_init_card_error
(
ns_dev
*
card
,
int
error
)
static
void
__
dev
init
ns_init_card_error
(
ns_dev
*
card
,
int
error
)
{
{
if
(
error
>=
17
)
if
(
error
>=
17
)
{
{
...
@@ -981,6 +983,7 @@ static void __init ns_init_card_error(ns_dev *card, int error)
...
@@ -981,6 +983,7 @@ static void __init ns_init_card_error(ns_dev *card, int error)
}
}
if
(
error
>=
3
)
if
(
error
>=
3
)
{
{
pci_disable_device
(
card
->
pcidev
);
kfree
(
card
);
kfree
(
card
);
}
}
}
}
...
@@ -3099,5 +3102,7 @@ static unsigned char ns_phy_get(struct atm_dev *dev, unsigned long addr)
...
@@ -3099,5 +3102,7 @@ static unsigned char ns_phy_get(struct atm_dev *dev, unsigned long addr)
return
(
unsigned
char
)
data
;
return
(
unsigned
char
)
data
;
}
}
module_init
(
nicstar_module_init
);
module_exit
(
nicstar_module_exit
);
module_init
(
nicstar_init
);
module_exit
(
nicstar_cleanup
);
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