bug-hurd
[Top][All Lists]
Advanced

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

[PATCH 1/2] pci-arbiter: Rename command line options


From: Joan Lledó
Subject: [PATCH 1/2] pci-arbiter: Rename command line options
Date: Sat, 15 Feb 2020 12:38:52 +0100 (CET)

From: Joan Lledó <address@hidden>

Rename some CLI options in order to add the new -d --device arg.

Replace -s by -c for subclasses.
Replace -D by -d for domains.
        Domains are optional from now on, default to 0.
Replace -b by -B for buses.
        Bus now creates a new permission scope if the current one
        already has a value for the bus.
Replace -d by -s for devices.
        The formerly called "devices" are now called "slots", and
        "device" will refer to a combination of
        Domain + Bus + Slot + Function

* pci-arbiter/options.c: parse_opts(): Rename options
* pci-arbiter/options.h: struct argp_option options[]: Likewise
---
 pci-arbiter/options.c | 19 +++++++++++--------
 pci-arbiter/options.h | 12 ++++++------
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/pci-arbiter/options.c b/pci-arbiter/options.c
index 76ce6460..085a2299 100644
--- a/pci-arbiter/options.c
+++ b/pci-arbiter/options.c
@@ -120,19 +120,22 @@ parse_opt (int opt, char *arg, struct argp_state *state)
 
       h->curset->d_class = strtol (arg, 0, 16);
       break;
-    case 's':
+    case 'c':
       h->curset->d_subclass = strtol (arg, 0, 16);
       break;
-    case 'D':
-      if (h->curset->domain >= 0)
-       parse_hook_add_set (h);
-
+    case 'd':
       h->curset->domain = strtol (arg, 0, 16);
       break;
-    case 'b':
+    case 'B':
+      if (h->curset->bus >= 0)
+       parse_hook_add_set (h);
+
+      if (h->curset->domain < 0)
+       h->curset->domain = 0;
+
       h->curset->bus = strtol (arg, 0, 16);
       break;
-    case 'd':
+    case 's':
       h->curset->dev = strtol (arg, 0, 16);
       break;
     case 'f':
@@ -261,7 +264,7 @@ netfs_append_args (char **argz, size_t * argz_len)
       if (p->bus >= 0)
        ADD_OPT ("--bus=0x%02x", p->bus);
       if (p->dev >= 0)
-       ADD_OPT ("--dev=0x%02x", p->dev);
+       ADD_OPT ("--slot=0x%02x", p->dev);
       if (p->func >= 0)
        ADD_OPT ("--func=%01u", p->func);
       if (p->uid >= 0)
diff --git a/pci-arbiter/options.h b/pci-arbiter/options.h
index 814f81ad..bdb6be78 100644
--- a/pci-arbiter/options.h
+++ b/pci-arbiter/options.h
@@ -51,12 +51,12 @@ struct parse_hook
 static const struct argp_option options[] = {
   {0, 0, 0, 0, "Permission scope:", 1},
   {"class", 'C', "CLASS", 0, "Device class in hexadecimal"},
-  {"subclass", 's', "SUBCLASS", 0,
-   "Device subclass in hexadecimal, only valid with -c"},
-  {"domain", 'D', "DOMAIN", 0, "Device domain in hexadecimal"},
-  {"bus", 'b', "BUS", 0, "Device bus in hexadecimal, only valid with -D"},
-  {"dev", 'd', "DEV", 0, "Device dev in hexadecimal, only valid with -b"},
-  {"func", 'f', "FUNC", 0, "Device func in hexadecimal, only valid with -d"},
+  {"subclass", 'c', "SUBCLASS", 0,
+   "Device subclass in hexadecimal, requires -C"},
+  {"domain", 'd', "DOMAIN", 0, "Device domain in hexadecimal"},
+  {"bus", 'B', "BUS", 0, "Device bus in hexadecimal, requires -D"},
+  {"slot", 's', "SLOT", 0, "Device slot in hexadecimal, requires -b"},
+  {"func", 'f', "FUNC", 0, "Device func in hexadecimal, requires -d"},
   {0, 0, 0, 0, "These apply to a given permission scope:", 2},
   {"uid", 'U', "UID", 0, "User ID to give permissions to"},
   {"gid", 'G', "GID", 0, "Group ID to give permissions to"},
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]