From patchwork Fri Dec 2 16:32:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 9458873 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E28DB60515 for ; Fri, 2 Dec 2016 16:33:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1C0228568 for ; Fri, 2 Dec 2016 16:33:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C696628575; Fri, 2 Dec 2016 16:33:06 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 ED49928568 for ; Fri, 2 Dec 2016 16:33:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B90506E965; Fri, 2 Dec 2016 16:33:04 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 755F56E94D for ; Fri, 2 Dec 2016 16:33:03 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id a20so3548146wme.2 for ; Fri, 02 Dec 2016 08:33:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=TMlpDbBn4PpXAtYc3t7GeivkF9ELDhz1a26OilV68Uo=; b=TwJeURNjxGvxQvrQl5fAgN5j9ibUSHl3FryctKsriicRJYBHyhTgt06/IJ6Ecy1LAX cABInUeT6EkhL/g4WNRb/NDW9L5c9/BAUjcx4GpD3xOWvJOmJCt2JI8z4zhbPhQOfWJ4 UaR1FozgcTwOkpZyalbrmCe9ko5QvY1nSY8h1d4W5SLg4MN8Za8xbKUX+LhIPiV6HPga 6naC7WGDBAEssBuT/ScTbCrTNPUlftcCXH8kt7TzTTUVdO/P2ESGkHM1HGoSJYCNVorv IlX0LQwxmhRWuhA2q+Udb3pVIL/0hLSlTk14nRPg9Ruf7N6hkeqEeTIo+w1+9skTr7JW m1MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TMlpDbBn4PpXAtYc3t7GeivkF9ELDhz1a26OilV68Uo=; b=Y7QqDucObpSjT4n6dJiNbc9K2iN1mioiXDB6mW7UtaamU6L9GDAyEj8vGd2RC+zr3U ODIbcjqJlNGN+WA+vNtbOuzuoK+RxYEJYsEcyhaeC3uKob6KgvfyXrMbQKWZ5LzpJLSi +IVejdQTyMd38uyIniuJtzpN49siWDAepl+vmKvpiUkFvZ44za/R/uUVcJazy6IDnOES PmSTrVdSJvz7NR4d632oWg2ohzN5qwy6uRsq5aSAScT5MyRhx73SU+xFmMSrDv9SVLjV Ner8ItVydWVkD4HqCbrU3mWq0g3+s0FD5qVgqXjZlBnuj8w6fgjAJuAC1Cu4V6HZqY8c 1Iog== X-Gm-Message-State: AKaTC03cytr52/QM4/T+DzYfnsTntCawMV3wQiKBkKm/qXLY2ZLVjzJ+HZZ00qhc75T2Bg== X-Received: by 10.28.98.66 with SMTP id w63mr4031132wmb.142.1480696381901; Fri, 02 Dec 2016 08:33:01 -0800 (PST) Received: from arch-x1c3.cbg.collabora.co.uk ([2a00:1098:5:0:9665:9cff:feee:aa4d]) by smtp.gmail.com with ESMTPSA id b7sm6331517wjm.39.2016.12.02.08.33.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Dec 2016 08:33:01 -0800 (PST) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 1/5] xf86drm: use maj/min in drmParsePciDeviceInfo() Date: Fri, 2 Dec 2016 16:32:34 +0000 Message-Id: <20161202163238.15849-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.10.2 Cc: emil.l.velikov@gmail.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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 From: Emil Velikov Be consistent with drmParsePciBusInfo() and use solely the device major/minor pair. Cc: Jonathan Gray Signed-off-by: Emil Velikov --- Jonathan, please respin your patches on top of this series. --- xf86drm.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/xf86drm.c b/xf86drm.c index ed924a7..c788c93 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -2946,7 +2946,7 @@ static int drmGetMaxNodeName(void) 3 /* length of the node number */; } -static int drmParsePciDeviceInfo(const char *d_name, +static int drmParsePciDeviceInfo(int maj, int min, drmPciDeviceInfoPtr device) { #ifdef __linux__ @@ -2954,7 +2954,7 @@ static int drmParsePciDeviceInfo(const char *d_name, unsigned char config[64]; int fd, ret; - snprintf(path, PATH_MAX, "/sys/class/drm/%s/device/config", d_name); + snprintf(path, PATH_MAX, "/sys/dev/char/%d:%d/device/config", maj, min); fd = open(path, O_RDONLY); if (fd < 0) return -errno; @@ -2998,7 +2998,7 @@ void drmFreeDevices(drmDevicePtr devices[], int count) drmFreeDevice(&devices[i]); } -static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name, +static int drmProcessPciDevice(drmDevicePtr *device, const char *node, int node_type, int maj, int min, bool fetch_deviceinfo) { @@ -3039,7 +3039,7 @@ static int drmProcessPciDevice(drmDevicePtr *device, const char *d_name, addr += sizeof(drmPciBusInfo); (*device)->deviceinfo.pci = (drmPciDeviceInfoPtr)addr; - ret = drmParsePciDeviceInfo(d_name, (*device)->deviceinfo.pci); + ret = drmParsePciDeviceInfo(maj, min, (*device)->deviceinfo.pci); if (ret) goto free_device; } @@ -3142,8 +3142,7 @@ int drmGetDevice(int fd, drmDevicePtr *device) switch (subsystem_type) { case DRM_BUS_PCI: - ret = drmProcessPciDevice(&d, dent->d_name, node, node_type, - maj, min, true); + ret = drmProcessPciDevice(&d, node, node_type, maj, min, true); if (ret) goto free_devices; @@ -3251,7 +3250,7 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices) switch (subsystem_type) { case DRM_BUS_PCI: - ret = drmProcessPciDevice(&device, dent->d_name, node, node_type, + ret = drmProcessPciDevice(&device, node, node_type, maj, min, devices != NULL); if (ret) goto free_devices;