From patchwork Wed Sep 5 12:31:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Engestrom X-Patchwork-Id: 10588839 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3AEE4920 for ; Wed, 5 Sep 2018 12:32:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26C6329C89 for ; Wed, 5 Sep 2018 12:32:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 192F729CC7; Wed, 5 Sep 2018 12:32:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0FA6629C89 for ; Wed, 5 Sep 2018 12:31:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D90EE6E127; Wed, 5 Sep 2018 12:31:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id DBA1C6E127 for ; Wed, 5 Sep 2018 12:31:55 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Sep 2018 05:31:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,333,1531810800"; d="scan'208";a="87388548" Received: from dfava-mobl.ger.corp.intel.com (HELO eengestr-dev.ger.corp.intel.com) ([10.252.9.73]) by fmsmga001.fm.intel.com with ESMTP; 05 Sep 2018 05:31:54 -0700 From: Eric Engestrom To: dri-devel@lists.freedesktop.org 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 Message-Id: <20180905123149.18117-1-eric.engestrom@intel.com> X-Mailer: git-send-email 2.18.0 Organization: Intel Corp UK X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Emil Velikov MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Cc: Emil Velikov Signed-off-by: Eric Engestrom Reviewed-by: Emil Velikov --- 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); From patchwork Wed Sep 5 12:31:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Engestrom X-Patchwork-Id: 10588841 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BF247920 for ; Wed, 5 Sep 2018 12:32:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAA6529CC7 for ; Wed, 5 Sep 2018 12:32:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A92CC29DE8; Wed, 5 Sep 2018 12:32:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 600F829CC7 for ; Wed, 5 Sep 2018 12:32:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BC6A56E461; Wed, 5 Sep 2018 12:31:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1339E6E446 for ; Wed, 5 Sep 2018 12:31:58 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Sep 2018 05:31:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,333,1531810800"; d="scan'208";a="87388555" Received: from dfava-mobl.ger.corp.intel.com (HELO eengestr-dev.ger.corp.intel.com) ([10.252.9.73]) by fmsmga001.fm.intel.com with ESMTP; 05 Sep 2018 05:31:57 -0700 From: Eric Engestrom To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 2/2] xf86drm: rename "real_path" to "pci_path" Date: Wed, 5 Sep 2018 13:31:49 +0100 Message-Id: <20180905123149.18117-2-eric.engestrom@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180905123149.18117-1-eric.engestrom@intel.com> References: <20180905123149.18117-1-eric.engestrom@intel.com> Organization: Intel Corp UK X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP "real_path" was getting confusing when there are other *paths in the same functions. Signed-off-by: Eric Engestrom --- xf86drm.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/xf86drm.c b/xf86drm.c index 649d400bcbc494ac04e6..b2388194932754dadc99 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -2999,17 +2999,17 @@ static int drmParseSubsystemType(int maj, int min) } static void -get_real_pci_path(int maj, int min, char *real_path) +get_pci_path(int maj, int min, char *pci_path) { char path[PATH_MAX + 1], *term; snprintf(path, sizeof(path), "/sys/dev/char/%d:%d/device", maj, min); - if (!realpath(path, real_path)) { - strcpy(real_path, path); + if (!realpath(path, pci_path)) { + strcpy(pci_path, path); return; } - term = strrchr(real_path, '/'); + term = strrchr(pci_path, '/'); if (term && strncmp(term, "/virtio", 7) == 0) *term = 0; } @@ -3018,12 +3018,12 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info) { #ifdef __linux__ unsigned int domain, bus, dev, func; - char real_path[PATH_MAX + 1], *value; + char pci_path[PATH_MAX + 1], *value; int num; - get_real_pci_path(maj, min, real_path); + get_pci_path(maj, min, pci_path); - value = sysfs_uevent_get(real_path, "PCI_SLOT_NAME"); + value = sysfs_uevent_get(pci_path, "PCI_SLOT_NAME"); if (!value) return -ENOENT; @@ -3136,15 +3136,15 @@ static int parse_separate_sysfs_files(int maj, int min, "subsystem_vendor", "subsystem_device", }; - char path[PATH_MAX + 1], real_path[PATH_MAX + 1]; + char path[PATH_MAX + 1], pci_path[PATH_MAX + 1]; unsigned int data[ARRAY_SIZE(attrs)]; FILE *fp; int ret; - get_real_pci_path(maj, min, real_path); + get_pci_path(maj, min, pci_path); for (unsigned i = ignore_revision ? 1 : 0; i < ARRAY_SIZE(attrs); i++) { - snprintf(path, PATH_MAX, "%s/%s", real_path, attrs[i]); + snprintf(path, PATH_MAX, "%s/%s", pci_path, attrs[i]); fp = fopen(path, "r"); if (!fp) return -errno; @@ -3168,13 +3168,13 @@ static int parse_separate_sysfs_files(int maj, int min, static int parse_config_sysfs_file(int maj, int min, drmPciDeviceInfoPtr device) { - char path[PATH_MAX + 1], real_path[PATH_MAX + 1]; + char path[PATH_MAX + 1], pci_path[PATH_MAX + 1]; unsigned char config[64]; int fd, ret; - get_real_pci_path(maj, min, real_path); + get_pci_path(maj, min, pci_path); - snprintf(path, PATH_MAX, "%s/config", real_path); + snprintf(path, PATH_MAX, "%s/config", pci_path); fd = open(path, O_RDONLY); if (fd < 0) return -errno;