From: Eric Engestrom <eric.engestrom@intel.com>
To: dri-devel@lists.freedesktop.org
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Subject: [PATCH libdrm 1/2] xf86drm: merge get_normal_pci_path() into get_real_pci_path()
Date: Wed, 5 Sep 2018 13:31:48 +0100 [thread overview]
Message-ID: <20180905123149.18117-1-eric.engestrom@intel.com> (raw)
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Eric Engestrom <eric.engestrom@intel.com>
---
xf86drm.c | 25 ++++++++-----------------
1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/xf86drm.c b/xf86drm.c
index 7807dce9c7fbba6d74f7..649d400bcbc494ac04e6 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2998,26 +2998,20 @@ static int drmParseSubsystemType(int maj, int min)
#endif
}
-static char *
+static void
get_real_pci_path(int maj, int min, char *real_path)
{
char path[PATH_MAX + 1], *term;
snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min);
- if (!realpath(path, real_path))
- return NULL;
+ if (!realpath(path, real_path)) {
+ strcpy(real_path, path);
+ return;
+ }
term = strrchr(real_path, '/');
if (term && strncmp(term, "/virtio", 7) == 0)
*term = 0;
-
- return real_path;
-}
-
-static void
-get_normal_pci_path(int maj, int min, char *normal_path)
-{
- snprintf(normal_path, PATH_MAX, "/sys/dev/char/%d:%d/device", maj, min);
}
static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
@@ -3027,8 +3021,7 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
char real_path[PATH_MAX + 1], *value;
int num;
- if (get_real_pci_path(maj, min, real_path) == NULL)
- get_normal_pci_path(maj, min, real_path);
+ get_real_pci_path(maj, min, real_path);
value = sysfs_uevent_get(real_path, "PCI_SLOT_NAME");
if (!value)
@@ -3148,8 +3141,7 @@ static int parse_separate_sysfs_files(int maj, int min,
FILE *fp;
int ret;
- if (get_real_pci_path(maj, min, real_path) == NULL)
- get_normal_pci_path(maj, min, real_path);
+ get_real_pci_path(maj, min, real_path);
for (unsigned i = ignore_revision ? 1 : 0; i < ARRAY_SIZE(attrs); i++) {
snprintf(path, PATH_MAX, "%s/%s", real_path, attrs[i]);
@@ -3180,8 +3172,7 @@ static int parse_config_sysfs_file(int maj, int min,
unsigned char config[64];
int fd, ret;
- if (get_real_pci_path(maj, min, real_path) == NULL)
- get_normal_pci_path(maj, min, real_path);
+ get_real_pci_path(maj, min, real_path);
snprintf(path, PATH_MAX, "%s/config", real_path);
fd = open(path, O_RDONLY);
--
Cheers,
Eric
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2018-09-05 12:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-05 12:31 Eric Engestrom [this message]
2018-09-05 12:31 ` [PATCH libdrm 2/2] xf86drm: rename "real_path" to "pci_path" Eric Engestrom
2018-09-05 12:58 ` [PATCH libdrm 1/2] xf86drm: merge get_normal_pci_path() into get_real_pci_path() Emil Velikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180905123149.18117-1-eric.engestrom@intel.com \
--to=eric.engestrom@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox