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
622dc337
Commit
622dc337
authored
Oct 21, 2004
by
Chas Williams
Committed by
David S. Miller
Oct 21, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ATM]: [ambassador] eliminate pci_find_device()
Signed-off-by:
David S. Miller
<
davem@davemloft.net
>
parent
5d00f203
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
103 deletions
+58
-103
drivers/atm/ambassador.c
drivers/atm/ambassador.c
+57
-102
drivers/atm/ambassador.h
drivers/atm/ambassador.h
+1
-1
No files found.
drivers/atm/ambassador.c
View file @
622dc337
...
@@ -313,9 +313,6 @@ static u32 __initdata ucode_data[] = {
...
@@ -313,9 +313,6 @@ static u32 __initdata ucode_data[] = {
static
void
do_housekeeping
(
unsigned
long
arg
);
static
void
do_housekeeping
(
unsigned
long
arg
);
/********** globals **********/
/********** globals **********/
static
amb_dev
*
amb_devs
=
NULL
;
static
struct
timer_list
housekeeping
=
TIMER_INITIALIZER
(
do_housekeeping
,
0
,
1
);
static
unsigned
short
debug
=
0
;
static
unsigned
short
debug
=
0
;
static
unsigned
int
cmds
=
8
;
static
unsigned
int
cmds
=
8
;
static
unsigned
int
txs
=
32
;
static
unsigned
int
txs
=
32
;
...
@@ -870,7 +867,7 @@ static inline void interrupts_off (amb_dev * dev) {
...
@@ -870,7 +867,7 @@ static inline void interrupts_off (amb_dev * dev) {
static
irqreturn_t
interrupt_handler
(
int
irq
,
void
*
dev_id
,
static
irqreturn_t
interrupt_handler
(
int
irq
,
void
*
dev_id
,
struct
pt_regs
*
pt_regs
)
{
struct
pt_regs
*
pt_regs
)
{
amb_dev
*
dev
=
amb_devs
;
amb_dev
*
dev
=
(
amb_dev
*
)
dev_id
;
(
void
)
pt_regs
;
(
void
)
pt_regs
;
PRINTD
(
DBG_IRQ
|
DBG_FLOW
,
"interrupt_handler: %p"
,
dev_id
);
PRINTD
(
DBG_IRQ
|
DBG_FLOW
,
"interrupt_handler: %p"
,
dev_id
);
...
@@ -879,24 +876,6 @@ static irqreturn_t interrupt_handler(int irq, void *dev_id,
...
@@ -879,24 +876,6 @@ static irqreturn_t interrupt_handler(int irq, void *dev_id,
PRINTD
(
DBG_IRQ
|
DBG_ERR
,
"irq with NULL dev_id: %d"
,
irq
);
PRINTD
(
DBG_IRQ
|
DBG_ERR
,
"irq with NULL dev_id: %d"
,
irq
);
return
IRQ_NONE
;
return
IRQ_NONE
;
}
}
// Did one of our cards generate the interrupt?
while
(
dev
)
{
if
(
dev
==
dev_id
)
break
;
dev
=
dev
->
prev
;
}
// impossible - unless we add the device to our list after both
// registering the IRQ handler for it and enabling interrupts, AND
// the card generates an IRQ at startup - should not happen again
if
(
!
dev
)
{
PRINTD
(
DBG_IRQ
,
"irq for unknown device: %d"
,
irq
);
return
IRQ_NONE
;
}
// impossible - unless we have memory corruption of dev or kernel
if
(
irq
!=
dev
->
irq
)
{
PRINTD
(
DBG_IRQ
|
DBG_ERR
,
"irq mismatch: %d"
,
irq
);
return
IRQ_NONE
;
}
{
{
u32
interrupt
=
rd_plain
(
dev
,
offsetof
(
amb_mem
,
interrupt
));
u32
interrupt
=
rd_plain
(
dev
,
offsetof
(
amb_mem
,
interrupt
));
...
@@ -1554,22 +1533,13 @@ static const struct atmdev_ops amb_ops = {
...
@@ -1554,22 +1533,13 @@ static const struct atmdev_ops amb_ops = {
/********** housekeeping **********/
/********** housekeeping **********/
static
void
do_housekeeping
(
unsigned
long
arg
)
{
static
void
do_housekeeping
(
unsigned
long
arg
)
{
amb_dev
*
dev
=
amb_devs
;
amb_dev
*
dev
=
(
amb_dev
*
)
arg
;
// data is set to zero at module unload
(
void
)
arg
;
if
(
housekeeping
.
data
)
{
// could collect device-specific (not driver/atm-linux) stats here
while
(
dev
)
{
// could collect device-specific (not driver/atm-linux) stats here
// last resort refill once every ten seconds
fill_rx_pools
(
dev
);
// last resort refill once every ten seconds
mod_timer
(
&
dev
->
housekeeping
,
jiffies
+
10
*
HZ
);
fill_rx_pools
(
dev
);
dev
=
dev
->
prev
;
}
mod_timer
(
&
housekeeping
,
jiffies
+
10
*
HZ
);
}
return
;
return
;
}
}
...
@@ -2225,6 +2195,7 @@ static void setup_dev(amb_dev *dev, struct pci_dev *pci_dev)
...
@@ -2225,6 +2195,7 @@ static void setup_dev(amb_dev *dev, struct pci_dev *pci_dev)
// set up known dev items straight away
// set up known dev items straight away
dev
->
pci_dev
=
pci_dev
;
dev
->
pci_dev
=
pci_dev
;
pci_set_drvdata
(
pci_dev
,
dev
);
dev
->
iobase
=
pci_resource_start
(
pci_dev
,
1
);
dev
->
iobase
=
pci_resource_start
(
pci_dev
,
1
);
dev
->
irq
=
pci_dev
->
irq
;
dev
->
irq
=
pci_dev
->
irq
;
...
@@ -2284,7 +2255,7 @@ static int setup_pci_dev(struct pci_dev *pci_dev)
...
@@ -2284,7 +2255,7 @@ static int setup_pci_dev(struct pci_dev *pci_dev)
return
ret
;
return
ret
;
}
}
static
int
__
init
do_pci_device
(
struct
pci_dev
*
pci_dev
)
static
int
__
devinit
amb_probe
(
struct
pci_dev
*
pci_dev
,
const
struct
pci_device_id
*
pci_ent
)
{
{
amb_dev
*
dev
;
amb_dev
*
dev
;
int
err
;
int
err
;
...
@@ -2292,6 +2263,12 @@ static int __init do_pci_device(struct pci_dev *pci_dev)
...
@@ -2292,6 +2263,12 @@ static int __init do_pci_device(struct pci_dev *pci_dev)
// read resources from PCI configuration space
// read resources from PCI configuration space
u8
irq
=
pci_dev
->
irq
;
u8
irq
=
pci_dev
->
irq
;
if
(
pci_dev
->
device
==
PCI_DEVICE_ID_MADGE_AMBASSADOR_BAD
)
{
PRINTK
(
KERN_ERR
,
"skipped broken (PLX rev 2) card"
);
err
=
-
EINVAL
;
goto
out
;
}
PRINTD
(
DBG_INFO
,
"found Madge ATM adapter (amb) at"
PRINTD
(
DBG_INFO
,
"found Madge ATM adapter (amb) at"
" IO %lx, IRQ %u, MEM %p"
,
pci_resource_start
(
pci_dev
,
1
),
" IO %lx, IRQ %u, MEM %p"
,
pci_resource_start
(
pci_dev
,
1
),
irq
,
bus_to_virt
(
pci_resource_start
(
pci_dev
,
0
)));
irq
,
bus_to_virt
(
pci_resource_start
(
pci_dev
,
0
)));
...
@@ -2347,9 +2324,10 @@ static int __init do_pci_device(struct pci_dev *pci_dev)
...
@@ -2347,9 +2324,10 @@ static int __init do_pci_device(struct pci_dev *pci_dev)
dev
->
atm_dev
->
ci_range
.
vpi_bits
=
NUM_VPI_BITS
;
dev
->
atm_dev
->
ci_range
.
vpi_bits
=
NUM_VPI_BITS
;
dev
->
atm_dev
->
ci_range
.
vci_bits
=
NUM_VCI_BITS
;
dev
->
atm_dev
->
ci_range
.
vci_bits
=
NUM_VCI_BITS
;
// update linked list
init_timer
(
&
dev
->
housekeeping
);
dev
->
prev
=
amb_devs
;
dev
->
housekeeping
.
function
=
do_housekeeping
;
amb_devs
=
dev
;
dev
->
housekeeping
.
data
=
(
unsigned
long
)
dev
;
mod_timer
(
&
dev
->
housekeeping
,
jiffies
);
// enable host interrupts
// enable host interrupts
interrupts_on
(
dev
);
interrupts_on
(
dev
);
...
@@ -2370,29 +2348,25 @@ static int __init do_pci_device(struct pci_dev *pci_dev)
...
@@ -2370,29 +2348,25 @@ static int __init do_pci_device(struct pci_dev *pci_dev)
goto
out
;
goto
out
;
}
}
static
int
__init
amb_probe
(
void
)
{
struct
pci_dev
*
pci_dev
;
int
devs
;
PRINTD
(
DBG_FLOW
,
"amb_probe"
);
devs
=
0
;
pci_dev
=
NULL
;
while
((
pci_dev
=
pci_find_device
(
PCI_VENDOR_ID_MADGE
,
PCI_DEVICE_ID_MADGE_AMBASSADOR
,
pci_dev
)
))
{
if
(
do_pci_device
(
pci_dev
)
==
0
)
devs
++
;
}
static
void
__devexit
amb_remove_one
(
struct
pci_dev
*
pci_dev
)
pci_dev
=
NULL
;
{
while
((
pci_dev
=
pci_find_device
struct
amb_dev
*
dev
;
(
PCI_VENDOR_ID_MADGE
,
PCI_DEVICE_ID_MADGE_AMBASSADOR_BAD
,
pci_dev
)
))
dev
=
pci_get_drvdata
(
pci_dev
);
PRINTK
(
KERN_ERR
,
"skipped broken (PLX rev 2) card"
);
PRINTD
(
DBG_INFO
|
DBG_INIT
,
"closing %p (atm_dev = %p)"
,
dev
,
dev
->
atm_dev
);
return
devs
;
del_timer_sync
(
&
dev
->
housekeeping
);
// the drain should not be necessary
drain_rx_pools
(
dev
);
interrupts_off
(
dev
);
amb_reset
(
dev
,
0
);
free_irq
(
dev
->
irq
,
dev
);
pci_disable_device
(
pci_dev
);
destroy_queues
(
dev
);
atm_dev_deregister
(
dev
->
atm_dev
);
kfree
(
dev
);
pci_release_region
(
pci_dev
,
1
);
}
}
static
void
__init
amb_check_args
(
void
)
{
static
void
__init
amb_check_args
(
void
)
{
...
@@ -2457,9 +2431,23 @@ MODULE_PARM_DESC(pci_lat, "PCI latency in bus cycles");
...
@@ -2457,9 +2431,23 @@ MODULE_PARM_DESC(pci_lat, "PCI latency in bus cycles");
/********** module entry **********/
/********** module entry **********/
static
int
__init
amb_module_init
(
void
)
{
static
struct
pci_device_id
amb_pci_tbl
[]
=
{
int
devs
;
{
PCI_VENDOR_ID_MADGE
,
PCI_DEVICE_ID_MADGE_AMBASSADOR
,
PCI_ANY_ID
,
PCI_ANY_ID
,
0
,
0
,
0
},
{
PCI_VENDOR_ID_MADGE
,
PCI_DEVICE_ID_MADGE_AMBASSADOR_BAD
,
PCI_ANY_ID
,
PCI_ANY_ID
,
0
,
0
,
0
},
{
0
,
}
};
static
struct
pci_driver
amb_driver
=
{
.
name
=
"amb"
,
.
probe
=
amb_probe
,
.
remove
=
__devexit_p
(
amb_remove_one
),
.
id_table
=
amb_pci_tbl
,
};
static
int
__init
amb_module_init
(
void
)
{
PRINTD
(
DBG_FLOW
|
DBG_INIT
,
"init_module"
);
PRINTD
(
DBG_FLOW
|
DBG_INIT
,
"init_module"
);
// sanity check - cast needed as printk does not support %Zu
// sanity check - cast needed as printk does not support %Zu
...
@@ -2474,49 +2462,16 @@ static int __init amb_module_init (void) {
...
@@ -2474,49 +2462,16 @@ static int __init amb_module_init (void) {
amb_check_args
();
amb_check_args
();
// get the juice
// get the juice
devs
=
amb_probe
();
return
pci_module_init
(
&
amb_driver
);
if
(
devs
)
{
mod_timer
(
&
housekeeping
,
jiffies
);
}
else
{
PRINTK
(
KERN_INFO
,
"no (usable) adapters found"
);
}
return
devs
?
0
:
-
ENODEV
;
}
}
/********** module exit **********/
/********** module exit **********/
static
void
__exit
amb_module_exit
(
void
)
{
static
void
__exit
amb_module_exit
(
void
)
amb_dev
*
dev
;
{
PRINTD
(
DBG_FLOW
|
DBG_INIT
,
"cleanup_module"
);
PRINTD
(
DBG_FLOW
|
DBG_INIT
,
"cleanup_module"
);
// paranoia
return
pci_unregister_driver
(
&
amb_driver
);
housekeeping
.
data
=
0
;
del_timer_sync
(
&
housekeeping
);
while
(
amb_devs
)
{
struct
pci_dev
*
pdev
;
dev
=
amb_devs
;
pdev
=
dev
->
pci_dev
;
amb_devs
=
dev
->
prev
;
PRINTD
(
DBG_INFO
|
DBG_INIT
,
"closing %p (atm_dev = %p)"
,
dev
,
dev
->
atm_dev
);
// the drain should not be necessary
drain_rx_pools
(
dev
);
interrupts_off
(
dev
);
amb_reset
(
dev
,
0
);
free_irq
(
dev
->
irq
,
dev
);
pci_disable_device
(
pdev
);
destroy_queues
(
dev
);
atm_dev_deregister
(
dev
->
atm_dev
);
kfree
(
dev
);
pci_release_region
(
pdev
,
1
);
}
return
;
}
}
module_init
(
amb_module_init
);
module_init
(
amb_module_init
);
...
...
drivers/atm/ambassador.h
View file @
622dc337
...
@@ -649,7 +649,7 @@ struct amb_dev {
...
@@ -649,7 +649,7 @@ struct amb_dev {
struct
atm_dev
*
atm_dev
;
struct
atm_dev
*
atm_dev
;
struct
pci_dev
*
pci_dev
;
struct
pci_dev
*
pci_dev
;
struct
amb_dev
*
prev
;
struct
timer_list
housekeeping
;
};
};
typedef
struct
amb_dev
amb_dev
;
typedef
struct
amb_dev
amb_dev
;
...
...
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