Module Name: src
Committed By: mrg
Date: Sun Aug 31 09:16:54 UTC 2014
Modified Files:
src/usr.sbin/pcictl: pcictl.8 pcictl.c
Log Message:
add -N option to print the driver name as returned by pci_drvname(3).
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/pcictl/pcictl.8
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/pcictl/pcictl.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/pcictl/pcictl.8
diff -u src/usr.sbin/pcictl/pcictl.8:1.11 src/usr.sbin/pcictl/pcictl.8:1.12
--- src/usr.sbin/pcictl/pcictl.8:1.11 Tue Aug 26 16:21:15 2014
+++ src/usr.sbin/pcictl/pcictl.8 Sun Aug 31 09:16:54 2014
@@ -1,4 +1,4 @@
-.\" $NetBSD: pcictl.8,v 1.11 2014/08/26 16:21:15 wiz Exp $
+.\" $NetBSD: pcictl.8,v 1.12 2014/08/31 09:16:54 mrg Exp $
.\"
.\" Copyright 2001 Wasabi Systems, Inc.
.\" All rights reserved.
@@ -33,7 +33,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd February 25, 2011
+.Dd August 31, 2014
.Dt PCICTL 8
.Os
.Sh NAME
@@ -56,6 +56,7 @@ The following commands are available:
.Pp
.Cm list
.Op Fl n
+.Op Fl N
.Op Fl b Ar bus
.Op Fl d Ar device
.Op Fl f Ar function
@@ -68,6 +69,10 @@ numbers may be specified by flags.
Any locator not specified defaults
to a wildcard, or may be explicitly wildcarded by specifying
.Dq any .
+If
+.Fl N
+is given, the driver name for this PCI device will be listed
+if any driver is attached.
.Pp
.Cm dump
.Op Fl b Ar bus
Index: src/usr.sbin/pcictl/pcictl.c
diff -u src/usr.sbin/pcictl/pcictl.c:1.18 src/usr.sbin/pcictl/pcictl.c:1.19
--- src/usr.sbin/pcictl/pcictl.c:1.18 Tue Aug 30 20:08:38 2011
+++ src/usr.sbin/pcictl/pcictl.c Sun Aug 31 09:16:54 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: pcictl.c,v 1.18 2011/08/30 20:08:38 joerg Exp $ */
+/* $NetBSD: pcictl.c,v 1.19 2014/08/31 09:16:54 mrg Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@@ -73,13 +73,14 @@ static const char *dvname;
static char dvname_store[MAXPATHLEN];
static const char *cmdname;
static int print_numbers = 0;
+static int print_names = 0;
static void cmd_list(int, char *[]);
static void cmd_dump(int, char *[]);
static const struct command commands[] = {
{ "list",
- "[-n] [-b bus] [-d device] [-f function]",
+ "[-nN] [-b bus] [-d device] [-f function]",
cmd_list,
O_RDONLY },
@@ -162,7 +163,7 @@ cmd_list(int argc, char *argv[])
bus = -1;
dev = func = -1;
- while ((ch = getopt(argc, argv, "nb:d:f:")) != -1) {
+ while ((ch = getopt(argc, argv, "nNb:d:f:")) != -1) {
switch (ch) {
case 'b':
bus = parse_bdf(optarg);
@@ -176,6 +177,9 @@ cmd_list(int argc, char *argv[])
case 'n':
print_numbers = 1;
break;
+ case 'N':
+ print_names = 1;
+ break;
default:
usage();
}
@@ -318,11 +322,17 @@ scan_pci_list(u_int bus, u_int dev, u_in
printf("%03u:%02u:%01u: ", bus, dev, func);
if (print_numbers) {
- printf("0x%08x (0x%08x)\n", id, class);
+ printf("0x%08x (0x%08x)", id, class);
} else {
pci_devinfo(id, class, 1, devinfo, sizeof(devinfo));
- printf("%s\n", devinfo);
+ printf("%s", devinfo);
+ }
+ if (print_names) {
+ char drvname[16];
+ if (pci_drvname(pcifd, dev, func, drvname, sizeof drvname) == 0)
+ printf(" [%s]", drvname);
}
+ printf("\n");
}
static void