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
6982cfc8
Commit
6982cfc8
authored
Jun 19, 2003
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Plain Diff
Merge kroah.com:/home/greg/linux/BK/bleed-2.5
into kroah.com:/home/greg/linux/BK/pci-2.5
parents
189ea5d0
4e359ed5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
221 additions
and
70 deletions
+221
-70
drivers/pci/hotplug.c
drivers/pci/hotplug.c
+23
-11
drivers/pci/pci-sysfs.c
drivers/pci/pci-sysfs.c
+11
-13
drivers/pci/pci.h
drivers/pci/pci.h
+3
-0
drivers/pci/proc.c
drivers/pci/proc.c
+29
-20
drivers/pci/search.c
drivers/pci/search.c
+135
-16
include/linux/pci.h
include/linux/pci.h
+20
-10
No files found.
drivers/pci/hotplug.c
View file @
6982cfc8
...
@@ -173,6 +173,24 @@ int pci_visit_dev (struct pci_visit *fn, struct pci_dev_wrapped *wrapped_dev,
...
@@ -173,6 +173,24 @@ int pci_visit_dev (struct pci_visit *fn, struct pci_dev_wrapped *wrapped_dev,
}
}
EXPORT_SYMBOL
(
pci_visit_dev
);
EXPORT_SYMBOL
(
pci_visit_dev
);
static
void
pci_destroy_dev
(
struct
pci_dev
*
dev
)
{
pci_proc_detach_device
(
dev
);
device_unregister
(
&
dev
->
dev
);
/* Remove the device from the device lists, and prevent any further
* list accesses from this device */
spin_lock
(
&
pci_bus_lock
);
list_del
(
&
dev
->
bus_list
);
list_del
(
&
dev
->
global_list
);
dev
->
bus_list
.
next
=
dev
->
bus_list
.
prev
=
NULL
;
dev
->
global_list
.
next
=
dev
->
global_list
.
prev
=
NULL
;
spin_unlock
(
&
pci_bus_lock
);
pci_free_resources
(
dev
);
pci_put_dev
(
dev
);
}
/**
/**
* pci_remove_device_safe - remove an unused hotplug device
* pci_remove_device_safe - remove an unused hotplug device
* @dev: the device to remove
* @dev: the device to remove
...
@@ -186,11 +204,7 @@ int pci_remove_device_safe(struct pci_dev *dev)
...
@@ -186,11 +204,7 @@ int pci_remove_device_safe(struct pci_dev *dev)
{
{
if
(
pci_dev_driver
(
dev
))
if
(
pci_dev_driver
(
dev
))
return
-
EBUSY
;
return
-
EBUSY
;
device_unregister
(
&
dev
->
dev
);
pci_destroy_dev
(
dev
);
list_del
(
&
dev
->
bus_list
);
list_del
(
&
dev
->
global_list
);
pci_free_resources
(
dev
);
pci_proc_detach_device
(
dev
);
return
0
;
return
0
;
}
}
EXPORT_SYMBOL
(
pci_remove_device_safe
);
EXPORT_SYMBOL
(
pci_remove_device_safe
);
...
@@ -237,17 +251,15 @@ void pci_remove_bus_device(struct pci_dev *dev)
...
@@ -237,17 +251,15 @@ void pci_remove_bus_device(struct pci_dev *dev)
pci_remove_behind_bridge
(
dev
);
pci_remove_behind_bridge
(
dev
);
pci_proc_detach_bus
(
b
);
pci_proc_detach_bus
(
b
);
spin_lock
(
&
pci_bus_lock
);
list_del
(
&
b
->
node
);
list_del
(
&
b
->
node
);
spin_unlock
(
&
pci_bus_lock
);
kfree
(
b
);
kfree
(
b
);
dev
->
subordinate
=
NULL
;
dev
->
subordinate
=
NULL
;
}
}
device_unregister
(
&
dev
->
dev
);
pci_destroy_dev
(
dev
);
list_del
(
&
dev
->
bus_list
);
list_del
(
&
dev
->
global_list
);
pci_free_resources
(
dev
);
pci_proc_detach_device
(
dev
);
pci_put_dev
(
dev
);
}
}
/**
/**
...
...
drivers/pci/pci-sysfs.c
View file @
6982cfc8
...
@@ -18,12 +18,6 @@
...
@@ -18,12 +18,6 @@
#include "pci.h"
#include "pci.h"
#if BITS_PER_LONG == 32
#define LONG_FORMAT "\t%08lx"
#else
#define LONG_FORMAT "\t%16lx"
#endif
/* show configuration fields */
/* show configuration fields */
#define pci_config_attr(field, format_string) \
#define pci_config_attr(field, format_string) \
static ssize_t \
static ssize_t \
...
@@ -36,11 +30,11 @@ show_##field (struct device *dev, char *buf) \
...
@@ -36,11 +30,11 @@ show_##field (struct device *dev, char *buf) \
} \
} \
static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
static DEVICE_ATTR(field, S_IRUGO, show_##field, NULL);
pci_config_attr
(
vendor
,
"%04x
\n
"
);
pci_config_attr
(
vendor
,
"
0x
%04x
\n
"
);
pci_config_attr
(
device
,
"%04x
\n
"
);
pci_config_attr
(
device
,
"
0x
%04x
\n
"
);
pci_config_attr
(
subsystem_vendor
,
"%04x
\n
"
);
pci_config_attr
(
subsystem_vendor
,
"
0x
%04x
\n
"
);
pci_config_attr
(
subsystem_device
,
"%04x
\n
"
);
pci_config_attr
(
subsystem_device
,
"
0x
%04x
\n
"
);
pci_config_attr
(
class
,
"%06x
\n
"
);
pci_config_attr
(
class
,
"
0x
%06x
\n
"
);
pci_config_attr
(
irq
,
"%u
\n
"
);
pci_config_attr
(
irq
,
"%u
\n
"
);
/* show resources */
/* show resources */
...
@@ -50,9 +44,13 @@ pci_show_resources(struct device * dev, char * buf)
...
@@ -50,9 +44,13 @@ pci_show_resources(struct device * dev, char * buf)
struct
pci_dev
*
pci_dev
=
to_pci_dev
(
dev
);
struct
pci_dev
*
pci_dev
=
to_pci_dev
(
dev
);
char
*
str
=
buf
;
char
*
str
=
buf
;
int
i
;
int
i
;
int
max
=
7
;
if
(
pci_dev
->
subordinate
)
max
=
DEVICE_COUNT_RESOURCE
;
for
(
i
=
0
;
i
<
DEVICE_COUNT_RESOURCE
&&
pci_resource_start
(
pci_dev
,
i
)
;
i
++
)
{
for
(
i
=
0
;
i
<
max
;
i
++
)
{
str
+=
sprintf
(
str
,
LONG_FORMAT
LONG_FORMAT
LONG_FORMAT
"
\n
"
,
str
+=
sprintf
(
str
,
"0x%016lx 0x%016lx 0x%016lx
\n
"
,
pci_resource_start
(
pci_dev
,
i
),
pci_resource_start
(
pci_dev
,
i
),
pci_resource_end
(
pci_dev
,
i
),
pci_resource_end
(
pci_dev
,
i
),
pci_resource_flags
(
pci_dev
,
i
));
pci_resource_flags
(
pci_dev
,
i
));
...
...
drivers/pci/pci.h
View file @
6982cfc8
...
@@ -58,3 +58,6 @@ struct pci_visit {
...
@@ -58,3 +58,6 @@ struct pci_visit {
extern
int
pci_visit_dev
(
struct
pci_visit
*
fn
,
extern
int
pci_visit_dev
(
struct
pci_visit
*
fn
,
struct
pci_dev_wrapped
*
wrapped_dev
,
struct
pci_dev_wrapped
*
wrapped_dev
,
struct
pci_bus_wrapped
*
wrapped_parent
);
struct
pci_bus_wrapped
*
wrapped_parent
);
/* Lock for read/write access to pci device and bus lists */
extern
spinlock_t
pci_bus_lock
;
drivers/pci/proc.c
View file @
6982cfc8
...
@@ -308,39 +308,45 @@ static struct file_operations proc_bus_pci_operations = {
...
@@ -308,39 +308,45 @@ static struct file_operations proc_bus_pci_operations = {
/* iterator */
/* iterator */
static
void
*
pci_seq_start
(
struct
seq_file
*
m
,
loff_t
*
pos
)
static
void
*
pci_seq_start
(
struct
seq_file
*
m
,
loff_t
*
pos
)
{
{
struct
list_head
*
p
=
&
pci_devices
;
struct
pci_dev
*
dev
=
NULL
;
loff_t
n
=
*
pos
;
loff_t
n
=
*
pos
;
/* XXX: surely we need some locking for traversing the list? */
dev
=
pci_get_device
(
PCI_ANY_ID
,
PCI_ANY_ID
,
dev
);
while
(
n
--
)
{
while
(
n
--
)
{
p
=
p
->
next
;
dev
=
pci_get_device
(
PCI_ANY_ID
,
PCI_ANY_ID
,
dev
)
;
if
(
p
==
&
pci_devices
)
if
(
dev
==
NULL
)
return
NULL
;
goto
exit
;
}
}
return
p
;
exit:
return
dev
;
}
}
static
void
*
pci_seq_next
(
struct
seq_file
*
m
,
void
*
v
,
loff_t
*
pos
)
static
void
*
pci_seq_next
(
struct
seq_file
*
m
,
void
*
v
,
loff_t
*
pos
)
{
{
struct
list_head
*
p
=
v
;
struct
pci_dev
*
dev
=
v
;
(
*
pos
)
++
;
(
*
pos
)
++
;
return
p
->
next
!=
&
pci_devices
?
(
void
*
)
p
->
next
:
NULL
;
dev
=
pci_get_device
(
PCI_ANY_ID
,
PCI_ANY_ID
,
dev
);
return
dev
;
}
}
static
void
pci_seq_stop
(
struct
seq_file
*
m
,
void
*
v
)
static
void
pci_seq_stop
(
struct
seq_file
*
m
,
void
*
v
)
{
{
/* release whatever locks we need */
if
(
v
)
{
struct
pci_dev
*
dev
=
v
;
pci_put_dev
(
dev
);
}
}
}
static
int
show_device
(
struct
seq_file
*
m
,
void
*
v
)
static
int
show_device
(
struct
seq_file
*
m
,
void
*
v
)
{
{
struct
list_head
*
p
=
v
;
const
struct
pci_dev
*
dev
=
v
;
const
struct
pci_dev
*
dev
;
const
struct
pci_driver
*
drv
;
const
struct
pci_driver
*
drv
;
int
i
;
int
i
;
if
(
p
==
&
pci_devices
)
if
(
dev
==
NULL
)
return
0
;
return
0
;
dev
=
pci_dev_g
(
p
);
drv
=
pci_dev_driver
(
dev
);
drv
=
pci_dev_driver
(
dev
);
seq_printf
(
m
,
"%02x%02x
\t
%04x%04x
\t
%x"
,
seq_printf
(
m
,
"%02x%02x
\t
%04x%04x
\t
%x"
,
dev
->
bus
->
number
,
dev
->
bus
->
number
,
...
@@ -383,7 +389,11 @@ int pci_proc_attach_device(struct pci_dev *dev)
...
@@ -383,7 +389,11 @@ int pci_proc_attach_device(struct pci_dev *dev)
return
-
EACCES
;
return
-
EACCES
;
if
(
!
(
de
=
bus
->
procdir
))
{
if
(
!
(
de
=
bus
->
procdir
))
{
if
(
pci_domain_nr
(
bus
)
==
0
)
{
sprintf
(
name
,
"%02x"
,
bus
->
number
);
sprintf
(
name
,
"%02x"
,
bus
->
number
);
}
else
{
sprintf
(
name
,
"%04x:%02x"
,
pci_domain_nr
(
bus
),
bus
->
number
);
}
de
=
bus
->
procdir
=
proc_mkdir
(
name
,
proc_bus_pci_dir
);
de
=
bus
->
procdir
=
proc_mkdir
(
name
,
proc_bus_pci_dir
);
if
(
!
de
)
if
(
!
de
)
return
-
ENOMEM
;
return
-
ENOMEM
;
...
@@ -451,19 +461,18 @@ int pci_proc_detach_bus(struct pci_bus* bus)
...
@@ -451,19 +461,18 @@ int pci_proc_detach_bus(struct pci_bus* bus)
*/
*/
static
int
show_dev_config
(
struct
seq_file
*
m
,
void
*
v
)
static
int
show_dev_config
(
struct
seq_file
*
m
,
void
*
v
)
{
{
struct
list_head
*
p
=
v
;
struct
pci_dev
*
dev
=
v
;
struct
pci_dev
*
dev
;
struct
pci_dev
*
first_
dev
;
struct
pci_driver
*
drv
;
struct
pci_driver
*
drv
;
u32
class_rev
;
u32
class_rev
;
unsigned
char
latency
,
min_gnt
,
max_lat
,
*
class
;
unsigned
char
latency
,
min_gnt
,
max_lat
,
*
class
;
int
reg
;
int
reg
;
if
(
p
==
&
pci_devices
)
{
first_dev
=
pci_get_device
(
PCI_ANY_ID
,
PCI_ANY_ID
,
NULL
);
if
(
dev
==
first_dev
)
seq_puts
(
m
,
"PCI devices found:
\n
"
);
seq_puts
(
m
,
"PCI devices found:
\n
"
);
return
0
;
pci_put_dev
(
first_dev
);
}
dev
=
pci_dev_g
(
p
);
drv
=
pci_dev_driver
(
dev
);
drv
=
pci_dev_driver
(
dev
);
pci_read_config_dword
(
dev
,
PCI_CLASS_REVISION
,
&
class_rev
);
pci_read_config_dword
(
dev
,
PCI_CLASS_REVISION
,
&
class_rev
);
...
...
drivers/pci/search.c
View file @
6982cfc8
/*
* PCI searching functions.
*
* Copyright 1993 -- 1997 Drew Eckhardt, Frederic Potter,
* David Mosberger-Tang
* Copyright 1997 -- 2000 Martin Mares <mj@ucw.cz>
* Copyright 2003 -- Greg Kroah-Hartman <greg@kroah.com>
*/
#include <linux/pci.h>
#include <linux/pci.h>
#include <linux/module.h>
#include <linux/module.h>
spinlock_t
pci_bus_lock
=
SPIN_LOCK_UNLOCKED
;
static
struct
pci_bus
*
static
struct
pci_bus
*
pci_do_find_bus
(
struct
pci_bus
*
bus
,
unsigned
char
busnr
)
pci_do_find_bus
(
struct
pci_bus
*
bus
,
unsigned
char
busnr
)
{
{
...
@@ -52,11 +63,15 @@ pci_find_bus(unsigned char busnr)
...
@@ -52,11 +63,15 @@ pci_find_bus(unsigned char busnr)
struct
pci_bus
*
struct
pci_bus
*
pci_find_next_bus
(
const
struct
pci_bus
*
from
)
pci_find_next_bus
(
const
struct
pci_bus
*
from
)
{
{
struct
list_head
*
n
=
from
?
from
->
node
.
next
:
pci_root_buses
.
next
;
struct
list_head
*
n
;
struct
pci_bus
*
b
=
NULL
;
struct
pci_bus
*
b
=
NULL
;
WARN_ON
(
irqs_disabled
());
spin_lock
(
&
pci_bus_lock
);
n
=
from
?
from
->
node
.
next
:
pci_root_buses
.
next
;
if
(
n
!=
&
pci_root_buses
)
if
(
n
!=
&
pci_root_buses
)
b
=
pci_bus_b
(
n
);
b
=
pci_bus_b
(
n
);
spin_unlock
(
&
pci_bus_lock
);
return
b
;
return
b
;
}
}
...
@@ -97,24 +112,36 @@ pci_find_slot(unsigned int bus, unsigned int devfn)
...
@@ -97,24 +112,36 @@ pci_find_slot(unsigned int bus, unsigned int devfn)
* device structure is returned. Otherwise, %NULL is returned.
* device structure is returned. Otherwise, %NULL is returned.
* A new search is initiated by passing %NULL to the @from argument.
* A new search is initiated by passing %NULL to the @from argument.
* Otherwise if @from is not %NULL, searches continue from next device on the global list.
* Otherwise if @from is not %NULL, searches continue from next device on the global list.
*
* NOTE: Do not use this function anymore, use pci_get_subsys() instead, as
* the pci device returned by this function can disappear at any moment in
* time.
*/
*/
struct
pci_dev
*
struct
pci_dev
*
pci_find_subsys
(
unsigned
int
vendor
,
unsigned
int
device
,
pci_find_subsys
(
unsigned
int
vendor
,
unsigned
int
device
,
unsigned
int
ss_vendor
,
unsigned
int
ss_device
,
unsigned
int
ss_vendor
,
unsigned
int
ss_device
,
const
struct
pci_dev
*
from
)
const
struct
pci_dev
*
from
)
{
{
struct
list_head
*
n
=
from
?
from
->
global_list
.
next
:
pci_devices
.
next
;
struct
list_head
*
n
;
struct
pci_dev
*
dev
;
WARN_ON
(
irqs_disabled
());
spin_lock
(
&
pci_bus_lock
);
n
=
from
?
from
->
global_list
.
next
:
pci_devices
.
next
;
while
(
n
!=
&
pci_devices
)
{
while
(
n
&&
(
n
!=
&
pci_devices
)
)
{
struct
pci_dev
*
dev
=
pci_dev_g
(
n
);
dev
=
pci_dev_g
(
n
);
if
((
vendor
==
PCI_ANY_ID
||
dev
->
vendor
==
vendor
)
&&
if
((
vendor
==
PCI_ANY_ID
||
dev
->
vendor
==
vendor
)
&&
(
device
==
PCI_ANY_ID
||
dev
->
device
==
device
)
&&
(
device
==
PCI_ANY_ID
||
dev
->
device
==
device
)
&&
(
ss_vendor
==
PCI_ANY_ID
||
dev
->
subsystem_vendor
==
ss_vendor
)
&&
(
ss_vendor
==
PCI_ANY_ID
||
dev
->
subsystem_vendor
==
ss_vendor
)
&&
(
ss_device
==
PCI_ANY_ID
||
dev
->
subsystem_device
==
ss_device
))
(
ss_device
==
PCI_ANY_ID
||
dev
->
subsystem_device
==
ss_device
))
return
dev
;
goto
exit
;
n
=
n
->
next
;
n
=
n
->
next
;
}
}
return
NULL
;
dev
=
NULL
;
exit:
spin_unlock
(
&
pci_bus_lock
);
return
dev
;
}
}
/**
/**
...
@@ -128,6 +155,10 @@ pci_find_subsys(unsigned int vendor, unsigned int device,
...
@@ -128,6 +155,10 @@ pci_find_subsys(unsigned int vendor, unsigned int device,
* returned. Otherwise, %NULL is returned.
* returned. Otherwise, %NULL is returned.
* A new search is initiated by passing %NULL to the @from argument.
* A new search is initiated by passing %NULL to the @from argument.
* Otherwise if @from is not %NULL, searches continue from next device on the global list.
* Otherwise if @from is not %NULL, searches continue from next device on the global list.
*
* NOTE: Do not use this function anymore, use pci_get_device() instead, as
* the pci device returned by this function can disappear at any moment in
* time.
*/
*/
struct
pci_dev
*
struct
pci_dev
*
pci_find_device
(
unsigned
int
vendor
,
unsigned
int
device
,
const
struct
pci_dev
*
from
)
pci_find_device
(
unsigned
int
vendor
,
unsigned
int
device
,
const
struct
pci_dev
*
from
)
...
@@ -135,6 +166,77 @@ pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *
...
@@ -135,6 +166,77 @@ pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *
return
pci_find_subsys
(
vendor
,
device
,
PCI_ANY_ID
,
PCI_ANY_ID
,
from
);
return
pci_find_subsys
(
vendor
,
device
,
PCI_ANY_ID
,
PCI_ANY_ID
,
from
);
}
}
/**
* pci_get_subsys - begin or continue searching for a PCI device by vendor/subvendor/device/subdevice id
* @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids
* @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
* @ss_vendor: PCI subsystem vendor id to match, or %PCI_ANY_ID to match all vendor ids
* @ss_device: PCI subsystem device id to match, or %PCI_ANY_ID to match all device ids
* @from: Previous PCI device found in search, or %NULL for new search.
*
* Iterates through the list of known PCI devices. If a PCI device is
* found with a matching @vendor, @device, @ss_vendor and @ss_device, a pointer to its
* device structure is returned, and the reference count to the device is
* incremented. Otherwise, %NULL is returned. A new search is initiated by
* passing %NULL to the @from argument. Otherwise if @from is not %NULL,
* searches continue from next device on the global list.
* The reference count for @from is always decremented if it is not %NULL.
*/
struct
pci_dev
*
pci_get_subsys
(
unsigned
int
vendor
,
unsigned
int
device
,
unsigned
int
ss_vendor
,
unsigned
int
ss_device
,
struct
pci_dev
*
from
)
{
struct
list_head
*
n
;
struct
pci_dev
*
dev
;
WARN_ON
(
irqs_disabled
());
spin_lock
(
&
pci_bus_lock
);
n
=
from
?
from
->
global_list
.
next
:
pci_devices
.
next
;
while
(
n
&&
(
n
!=
&
pci_devices
))
{
dev
=
pci_dev_g
(
n
);
if
((
vendor
==
PCI_ANY_ID
||
dev
->
vendor
==
vendor
)
&&
(
device
==
PCI_ANY_ID
||
dev
->
device
==
device
)
&&
(
ss_vendor
==
PCI_ANY_ID
||
dev
->
subsystem_vendor
==
ss_vendor
)
&&
(
ss_device
==
PCI_ANY_ID
||
dev
->
subsystem_device
==
ss_device
))
goto
exit
;
n
=
n
->
next
;
}
dev
=
NULL
;
exit:
pci_put_dev
(
from
);
dev
=
pci_get_dev
(
dev
);
spin_unlock
(
&
pci_bus_lock
);
return
dev
;
}
/**
* pci_get_device - begin or continue searching for a PCI device by vendor/device id
* @vendor: PCI vendor id to match, or %PCI_ANY_ID to match all vendor ids
* @device: PCI device id to match, or %PCI_ANY_ID to match all device ids
* @from: Previous PCI device found in search, or %NULL for new search.
*
* Iterates through the list of known PCI devices. If a PCI device is
* found with a matching @vendor and @device, a pointer to its device structure is
* returned. Otherwise, %NULL is returned.
* A new search is initiated by passing %NULL to the @from argument.
* Otherwise if @from is not %NULL, searches continue from next device on the global list.
*
* Iterates through the list of known PCI devices. If a PCI device is
* found with a matching @vendor and @device, the reference count to the
* device is incremented and a pointer to its device structure is returned.
* Otherwise, %NULL is returned. A new search is initiated by passing %NULL
* to the @from argument. Otherwise if @from is not %NULL, searches continue
* from next device on the global list. The reference count for @from is
* always decremented if it is not %NULL.
*/
struct
pci_dev
*
pci_get_device
(
unsigned
int
vendor
,
unsigned
int
device
,
struct
pci_dev
*
from
)
{
return
pci_get_subsys
(
vendor
,
device
,
PCI_ANY_ID
,
PCI_ANY_ID
,
from
);
}
/**
/**
* pci_find_device_reverse - begin or continue searching for a PCI device by vendor/device id
* pci_find_device_reverse - begin or continue searching for a PCI device by vendor/device id
...
@@ -151,16 +253,24 @@ pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *
...
@@ -151,16 +253,24 @@ pci_find_device(unsigned int vendor, unsigned int device, const struct pci_dev *
struct
pci_dev
*
struct
pci_dev
*
pci_find_device_reverse
(
unsigned
int
vendor
,
unsigned
int
device
,
const
struct
pci_dev
*
from
)
pci_find_device_reverse
(
unsigned
int
vendor
,
unsigned
int
device
,
const
struct
pci_dev
*
from
)
{
{
struct
list_head
*
n
=
from
?
from
->
global_list
.
prev
:
pci_devices
.
prev
;
struct
list_head
*
n
;
struct
pci_dev
*
dev
;
WARN_ON
(
irqs_disabled
());
spin_lock
(
&
pci_bus_lock
);
n
=
from
?
from
->
global_list
.
prev
:
pci_devices
.
prev
;
while
(
n
!=
&
pci_devices
)
{
while
(
n
&&
(
n
!=
&
pci_devices
)
)
{
struct
pci_dev
*
dev
=
pci_dev_g
(
n
);
dev
=
pci_dev_g
(
n
);
if
((
vendor
==
PCI_ANY_ID
||
dev
->
vendor
==
vendor
)
&&
if
((
vendor
==
PCI_ANY_ID
||
dev
->
vendor
==
vendor
)
&&
(
device
==
PCI_ANY_ID
||
dev
->
device
==
device
))
(
device
==
PCI_ANY_ID
||
dev
->
device
==
device
))
return
dev
;
goto
exit
;
n
=
n
->
prev
;
n
=
n
->
prev
;
}
}
return
NULL
;
dev
=
NULL
;
exit:
spin_unlock
(
&
pci_bus_lock
);
return
dev
;
}
}
...
@@ -179,15 +289,22 @@ pci_find_device_reverse(unsigned int vendor, unsigned int device, const struct p
...
@@ -179,15 +289,22 @@ pci_find_device_reverse(unsigned int vendor, unsigned int device, const struct p
struct
pci_dev
*
struct
pci_dev
*
pci_find_class
(
unsigned
int
class
,
const
struct
pci_dev
*
from
)
pci_find_class
(
unsigned
int
class
,
const
struct
pci_dev
*
from
)
{
{
struct
list_head
*
n
=
from
?
from
->
global_list
.
next
:
pci_devices
.
next
;
struct
list_head
*
n
;
struct
pci_dev
*
dev
;
spin_lock
(
&
pci_bus_lock
);
n
=
from
?
from
->
global_list
.
next
:
pci_devices
.
next
;
while
(
n
!=
&
pci_devices
)
{
while
(
n
&&
(
n
!=
&
pci_devices
)
)
{
struct
pci_dev
*
dev
=
pci_dev_g
(
n
);
dev
=
pci_dev_g
(
n
);
if
(
dev
->
class
==
class
)
if
(
dev
->
class
==
class
)
return
dev
;
goto
exit
;
n
=
n
->
next
;
n
=
n
->
next
;
}
}
return
NULL
;
dev
=
NULL
;
exit:
spin_unlock
(
&
pci_bus_lock
);
return
dev
;
}
}
EXPORT_SYMBOL
(
pci_find_bus
);
EXPORT_SYMBOL
(
pci_find_bus
);
...
@@ -196,3 +313,5 @@ EXPORT_SYMBOL(pci_find_device);
...
@@ -196,3 +313,5 @@ EXPORT_SYMBOL(pci_find_device);
EXPORT_SYMBOL
(
pci_find_device_reverse
);
EXPORT_SYMBOL
(
pci_find_device_reverse
);
EXPORT_SYMBOL
(
pci_find_slot
);
EXPORT_SYMBOL
(
pci_find_slot
);
EXPORT_SYMBOL
(
pci_find_subsys
);
EXPORT_SYMBOL
(
pci_find_subsys
);
EXPORT_SYMBOL
(
pci_get_device
);
EXPORT_SYMBOL
(
pci_get_subsys
);
include/linux/pci.h
View file @
6982cfc8
...
@@ -566,6 +566,10 @@ struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn);
...
@@ -566,6 +566,10 @@ struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn);
int
pci_find_capability
(
struct
pci_dev
*
dev
,
int
cap
);
int
pci_find_capability
(
struct
pci_dev
*
dev
,
int
cap
);
struct
pci_bus
*
pci_find_next_bus
(
const
struct
pci_bus
*
from
);
struct
pci_bus
*
pci_find_next_bus
(
const
struct
pci_bus
*
from
);
struct
pci_dev
*
pci_get_device
(
unsigned
int
vendor
,
unsigned
int
device
,
struct
pci_dev
*
from
);
struct
pci_dev
*
pci_get_subsys
(
unsigned
int
vendor
,
unsigned
int
device
,
unsigned
int
ss_vendor
,
unsigned
int
ss_device
,
struct
pci_dev
*
from
);
int
pci_bus_read_config_byte
(
struct
pci_bus
*
bus
,
unsigned
int
devfn
,
int
where
,
u8
*
val
);
int
pci_bus_read_config_byte
(
struct
pci_bus
*
bus
,
unsigned
int
devfn
,
int
where
,
u8
*
val
);
int
pci_bus_read_config_word
(
struct
pci_bus
*
bus
,
unsigned
int
devfn
,
int
where
,
u16
*
val
);
int
pci_bus_read_config_word
(
struct
pci_bus
*
bus
,
unsigned
int
devfn
,
int
where
,
u16
*
val
);
int
pci_bus_read_config_dword
(
struct
pci_bus
*
bus
,
unsigned
int
devfn
,
int
where
,
u32
*
val
);
int
pci_bus_read_config_dword
(
struct
pci_bus
*
bus
,
unsigned
int
devfn
,
int
where
,
u32
*
val
);
...
@@ -688,6 +692,13 @@ static inline struct pci_dev *pci_find_subsys(unsigned int vendor, unsigned int
...
@@ -688,6 +692,13 @@ static inline struct pci_dev *pci_find_subsys(unsigned int vendor, unsigned int
unsigned
int
ss_vendor
,
unsigned
int
ss_device
,
const
struct
pci_dev
*
from
)
unsigned
int
ss_vendor
,
unsigned
int
ss_device
,
const
struct
pci_dev
*
from
)
{
return
NULL
;
}
{
return
NULL
;
}
static
inline
struct
pci_dev
*
pci_get_device
(
unsigned
int
vendor
,
unsigned
int
device
,
struct
pci_dev
*
from
)
{
return
NULL
;
}
static
inline
struct
pci_dev
*
pci_get_subsys
(
unsigned
int
vendor
,
unsigned
int
device
,
unsigned
int
ss_vendor
,
unsigned
int
ss_device
,
struct
pci_dev
*
from
)
{
return
NULL
;
}
static
inline
void
pci_set_master
(
struct
pci_dev
*
dev
)
{
}
static
inline
void
pci_set_master
(
struct
pci_dev
*
dev
)
{
}
static
inline
int
pci_enable_device
(
struct
pci_dev
*
dev
)
{
return
-
EIO
;
}
static
inline
int
pci_enable_device
(
struct
pci_dev
*
dev
)
{
return
-
EIO
;
}
static
inline
void
pci_disable_device
(
struct
pci_dev
*
dev
)
{
}
static
inline
void
pci_disable_device
(
struct
pci_dev
*
dev
)
{
}
...
@@ -743,6 +754,15 @@ static inline int pci_module_init(struct pci_driver *drv)
...
@@ -743,6 +754,15 @@ static inline int pci_module_init(struct pci_driver *drv)
return
rc
;
return
rc
;
}
}
/*
* PCI domain support. Sometimes called PCI segment (eg by ACPI),
* a PCI domain is defined to be a set of PCI busses which share
* configuration space.
*/
#ifndef CONFIG_PCI_DOMAINS
static
inline
int
pci_domain_nr
(
struct
pci_bus
*
bus
)
{
return
0
;
}
#endif
#endif
/* !CONFIG_PCI */
#endif
/* !CONFIG_PCI */
/* these helpers provide future and backwards compatibility
/* these helpers provide future and backwards compatibility
...
@@ -800,15 +820,5 @@ extern int pci_pci_problems;
...
@@ -800,15 +820,5 @@ extern int pci_pci_problems;
#define PCIPCI_VSFX 16
#define PCIPCI_VSFX 16
#define PCIPCI_ALIMAGIK 32
#define PCIPCI_ALIMAGIK 32
/*
* PCI domain support. Sometimes called PCI segment (eg by ACPI),
* a PCI domain is defined to be a set of PCI busses which share
* configuration space.
*/
#ifndef CONFIG_PCI_DOMAINS
static
inline
int
pci_domain_nr
(
struct
pci_bus
*
bus
)
{
return
0
;
}
#endif
#endif
/* __KERNEL__ */
#endif
/* __KERNEL__ */
#endif
/* LINUX_PCI_H */
#endif
/* LINUX_PCI_H */
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