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
35f1f308
Commit
35f1f308
authored
Oct 05, 2004
by
Greg Kroah-Hartman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PATCH] PCI: add pci_get_class() to make a safe pci_find_class() like call.
Signed-off-by:
Greg Kroah-Hartman
<
greg@kroah.com
>
parent
bbe92ead
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
2 deletions
+45
-2
Documentation/pci.txt
Documentation/pci.txt
+3
-2
drivers/pci/search.c
drivers/pci/search.c
+38
-0
include/linux/pci.h
include/linux/pci.h
+4
-0
No files found.
Documentation/pci.txt
View file @
35f1f308
...
...
@@ -146,7 +146,7 @@ Searching by vendor and device ID:
Searching by class ID (iterate in a similar way):
pci_
find
_class(CLASS_ID, dev)
pci_
get
_class(CLASS_ID, dev)
Searching by both vendor/device and subsystem vendor/device ID:
...
...
@@ -281,5 +281,6 @@ pci_for_each_dev_reverse() Superseded by pci_find_device_reverse()
pci_for_each_bus() Superseded by pci_find_next_bus()
pci_find_device() Superseded by pci_get_device()
pci_find_subsys() Superseded by pci_get_subsys()
pcibios_find_class() Superseded by pci_find_class()
pcibios_find_class() Superseded by pci_get_class()
pci_find_class() Superseded by pci_get_class()
pci_(read|write)_*_nodev() Superseded by pci_bus_(read|write)_*()
drivers/pci/search.c
View file @
35f1f308
...
...
@@ -348,6 +348,43 @@ pci_find_class(unsigned int class, const struct pci_dev *from)
return
dev
;
}
/**
* pci_get_class - begin or continue searching for a PCI device by class
* @class: search for a PCI device with this class designation
* @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 @class, 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_class
(
unsigned
int
class
,
struct
pci_dev
*
from
)
{
struct
list_head
*
n
;
struct
pci_dev
*
dev
;
WARN_ON
(
in_interrupt
());
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
(
dev
->
class
==
class
)
goto
exit
;
n
=
n
->
next
;
}
dev
=
NULL
;
exit:
pci_dev_put
(
from
);
dev
=
pci_dev_get
(
dev
);
spin_unlock
(
&
pci_bus_lock
);
return
dev
;
}
EXPORT_SYMBOL
(
pci_find_bus
);
EXPORT_SYMBOL
(
pci_find_class
);
EXPORT_SYMBOL
(
pci_find_device
);
...
...
@@ -356,3 +393,4 @@ EXPORT_SYMBOL(pci_find_slot);
EXPORT_SYMBOL
(
pci_get_device
);
EXPORT_SYMBOL
(
pci_get_subsys
);
EXPORT_SYMBOL
(
pci_get_slot
);
EXPORT_SYMBOL
(
pci_get_class
);
include/linux/pci.h
View file @
35f1f308
...
...
@@ -730,6 +730,7 @@ 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
pci_dev
*
pci_get_slot
(
struct
pci_bus
*
bus
,
unsigned
int
devfn
);
struct
pci_dev
*
pci_get_class
(
unsigned
int
class
,
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_word
(
struct
pci_bus
*
bus
,
unsigned
int
devfn
,
int
where
,
u16
*
val
);
...
...
@@ -892,6 +893,9 @@ static inline struct pci_dev *pci_get_subsys (unsigned int vendor, unsigned int
unsigned
int
ss_vendor
,
unsigned
int
ss_device
,
struct
pci_dev
*
from
)
{
return
NULL
;
}
static
inline
struct
pci_dev
*
pci_get_class
(
unsigned
int
class
,
struct
pci_dev
*
from
)
{
return
NULL
;
}
static
inline
void
pci_set_master
(
struct
pci_dev
*
dev
)
{
}
static
inline
int
pci_enable_device
(
struct
pci_dev
*
dev
)
{
return
-
EIO
;
}
static
inline
void
pci_disable_device
(
struct
pci_dev
*
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