aboutsummaryrefslogtreecommitdiffstats
path: root/tools/power/cpupower/utils/helpers/pci.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-29 16:03:12 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-29 16:03:12 -0700
commit1c036588772d01655d851f75dffc27c971e072e2 (patch)
treeee35c5ecc726d4fdb77c462cccbe499d1c3292b7 /tools/power/cpupower/utils/helpers/pci.c
parentMerge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/pcmcia (diff)
parentcpupower tools: add install target to the debug tools' makefiles (diff)
downloadlinux-dev-1c036588772d01655d851f75dffc27c971e072e2.tar.xz
linux-dev-1c036588772d01655d851f75dffc27c971e072e2.zip
Merge git://git.kernel.org/pub/scm/linux/kernel/git/brodo/cpupowerutils
Pull cpupower updates from Dominik Brodowski. * git://git.kernel.org/pub/scm/linux/kernel/git/brodo/cpupowerutils: cpupower tools: add install target to the debug tools' makefiles cpupower tools: allow to build debug tools in a separate directory too cpupower: Fix broken mask values cpupower tool: allow to build in a separate directory cpupower tool: makefile: simplify the recipe used to generate cpupower.pot target cpupower tool: remove use of undefined variables from the clean target of the top makefile cpupower: Fix linking with --as-needed cpupower: Remove unneeded code and by that fix a memleak cpupower: Fix number of idle states cpupower: Unify cpupower-frequency-* manpages cpupower: Add cpupower-idle-info manpage cpupower: AMD fam14h/Ontario monitor can also be used by fam12h cpus cpupower: Better interface for accessing AMD pci registers
Diffstat (limited to 'tools/power/cpupower/utils/helpers/pci.c')
-rw-r--r--tools/power/cpupower/utils/helpers/pci.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/tools/power/cpupower/utils/helpers/pci.c b/tools/power/cpupower/utils/helpers/pci.c
index cd2eb6fe41c4..9690798e6446 100644
--- a/tools/power/cpupower/utils/helpers/pci.c
+++ b/tools/power/cpupower/utils/helpers/pci.c
@@ -10,19 +10,24 @@
* **pacc : if a valid pci_dev is returned
* *pacc must be passed to pci_acc_cleanup to free it
*
- * vendor_id : the pci vendor id matching the pci device to access
- * dev_ids : device ids matching the pci device to access
+ * domain: domain
+ * bus: bus
+ * slot: slot
+ * func: func
+ * vendor: vendor
+ * device: device
+ * Pass -1 for one of the six above to match any
*
* Returns :
* struct pci_dev which can be used with pci_{read,write}_* functions
* to access the PCI config space of matching pci devices
*/
-struct pci_dev *pci_acc_init(struct pci_access **pacc, int vendor_id,
- int *dev_ids)
+struct pci_dev *pci_acc_init(struct pci_access **pacc, int domain, int bus,
+ int slot, int func, int vendor, int dev)
{
- struct pci_filter filter_nb_link = { -1, -1, -1, -1, vendor_id, 0};
+ struct pci_filter filter_nb_link = { domain, bus, slot, func,
+ vendor, dev };
struct pci_dev *device;
- unsigned int i;
*pacc = pci_alloc();
if (*pacc == NULL)
@@ -31,14 +36,20 @@ struct pci_dev *pci_acc_init(struct pci_access **pacc, int vendor_id,
pci_init(*pacc);
pci_scan_bus(*pacc);
- for (i = 0; dev_ids[i] != 0; i++) {
- filter_nb_link.device = dev_ids[i];
- for (device = (*pacc)->devices; device; device = device->next) {
- if (pci_filter_match(&filter_nb_link, device))
- return device;
- }
+ for (device = (*pacc)->devices; device; device = device->next) {
+ if (pci_filter_match(&filter_nb_link, device))
+ return device;
}
pci_cleanup(*pacc);
return NULL;
}
+
+/* Typically one wants to get a specific slot(device)/func of the root domain
+ and bus */
+struct pci_dev *pci_slot_func_init(struct pci_access **pacc, int slot,
+ int func)
+{
+ return pci_acc_init(pacc, 0, 0, slot, func, -1, -1);
+}
+
#endif /* defined(__i386__) || defined(__x86_64__) */