Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/pcictl add -N option to print the driver name as re...



details:   https://anonhg.NetBSD.org/src/rev/48ccec79e516
branches:  trunk
changeset: 331923:48ccec79e516
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Aug 31 09:16:54 2014 +0000

description:
add -N option to print the driver name as returned by pci_drvname(3).

diffstat:

 usr.sbin/pcictl/pcictl.8 |   9 +++++++--
 usr.sbin/pcictl/pcictl.c |  20 +++++++++++++++-----
 2 files changed, 22 insertions(+), 7 deletions(-)

diffs (101 lines):

diff -r fbe9afa42dfb -r 48ccec79e516 usr.sbin/pcictl/pcictl.8
--- a/usr.sbin/pcictl/pcictl.8  Sun Aug 31 08:54:40 2014 +0000
+++ b/usr.sbin/pcictl/pcictl.8  Sun Aug 31 09:16:54 2014 +0000
@@ -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 @@
 .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 @@
 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
diff -r fbe9afa42dfb -r 48ccec79e516 usr.sbin/pcictl/pcictl.c
--- a/usr.sbin/pcictl/pcictl.c  Sun Aug 31 08:54:40 2014 +0000
+++ b/usr.sbin/pcictl/pcictl.c  Sun Aug 31 09:16:54 2014 +0000
@@ -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 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 @@
        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 @@
                case 'n':
                        print_numbers = 1;
                        break;
+               case 'N':
+                       print_names = 1;
+                       break;
                default:
                        usage();
                }
@@ -318,11 +322,17 @@
 
        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



Home | Main Index | Thread Index | Old Index