From patchwork Fri Dec 2 16:32:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 9458881 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 6248560515 for ; Fri, 2 Dec 2016 16:33:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5060F28568 for ; Fri, 2 Dec 2016 16:33:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4374028575; Fri, 2 Dec 2016 16:33:16 +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 C281328568 for ; Fri, 2 Dec 2016 16:33:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7A5CF6E9A1; Fri, 2 Dec 2016 16:33:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x244.google.com (mail-wm0-x244.google.com [IPv6:2a00:1450:400c:c09::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4C4656E976 for ; Fri, 2 Dec 2016 16:33:08 +0000 (UTC) Received: by mail-wm0-x244.google.com with SMTP id m203so3515285wma.3 for ; Fri, 02 Dec 2016 08:33:08 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kn5FctyotSOFiY2j3lHP7uDRjAg4qOUWkgogFjsjZQo=; b=enYO0b24PeusL6FtxSv1JGXEQhgalyO2KimIoGY9O8v46QaKIEvdDl1pU5aLsSXsUU NkfATm/6H5pFB4BMNLSt8aBUfnQabhN7sPdw+85RgSmpNt3L7qZU55OJQp0n9Kj1Hynp ClXp+vsJPP8o1kBjqfxtQgbBwGB41tbgUmYYoLOIvd88G37HI8Po4wNyrWF1hYi7SIeE 5qy/QE8XMJKnwMmpWBPPq/ggzKnvvRJf1d8vlbZDBhlbrvilq3oYNoxe2cnpaEw+4hpM 9KhLc4wc9cenDn8rFqD0xrcsRLhsQRXOmUzrFzbNaCKC46gEXIxLcF7cTUnJmowLRZdO ierQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kn5FctyotSOFiY2j3lHP7uDRjAg4qOUWkgogFjsjZQo=; b=F6JPFzbQx0YJp7AfYjJlGGMWIc3noZ4GO2dmjeIhw1EZ0BC97J9aZDUb1o9KK+uImM o8NdoHqoRItar7VZgZTTzi/wXWPr1jN8xr0WKQxMOvOCzJqOLHNdfZKjNtBKRbugg/aJ elYBFDvS1gJMcNcDriNM842zUGt+Zkfks5n5WkF6h55IvwE1RKqHs58kFgDm4/7LQNnA HtjckfrKV0hVICE957OyQHwb9BryEt0gt45L9vo1rZo162cymoAq2J93WEHkcFP2IBIk VSqeHoqsEZgRCS7KdX1i5EYnJgZiAZlbL5zQzXktdyVjCTSCLcZQJIIn0SdwUSCBsrWj V6sQ== X-Gm-Message-State: AKaTC01vUjHwyhfZk7Ncv6s5UfE6xKuqjlF9N3ggFdhZWGDT0Szgj9WMcIzn1oa9gIQSXA== X-Received: by 10.28.226.139 with SMTP id z133mr3997867wmg.139.1480696386725; Fri, 02 Dec 2016 08:33:06 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Dec 2016 08:33:05 -0800 (PST) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 5/5] tests/drmdevice: use drmGetDevice[s]2 Date: Fri, 2 Dec 2016 16:32:38 +0000 Message-Id: <20161202163238.15849-5-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: <20161202163238.15849-1-emil.l.velikov@gmail.com> References: <20161202163238.15849-1-emil.l.velikov@gmail.com> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov Pass along DRM_DEVICE_GET_PCI_REVISION only when the individual nodes are opened and update the printed messages accordingly. v2: Attribute for the flag rename, call drmGetDevices2 w/o the flag. Signed-off-by: Emil Velikov Reviewed-by: Michel Dänzer --- tests/drmdevice.c | 23 ++++++++++++++--------- xf86drm.c | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/drmdevice.c b/tests/drmdevice.c index 72e7066..8c4f091 100644 --- a/tests/drmdevice.c +++ b/tests/drmdevice.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -32,7 +33,7 @@ static void -print_device_info(drmDevicePtr device, int i) +print_device_info(drmDevicePtr device, int i, bool print_revision) { printf("device[%i]\n", i); printf("\tavailable_nodes %04x\n", device->available_nodes); @@ -56,7 +57,11 @@ print_device_info(drmDevicePtr device, int i) printf("\t\t\tdevice_id\t%04x\n", device->deviceinfo.pci->device_id); printf("\t\t\tsubvendor_id\t%04x\n", device->deviceinfo.pci->subvendor_id); printf("\t\t\tsubdevice_id\t%04x\n", device->deviceinfo.pci->subdevice_id); - printf("\t\t\trevision_id\t%02x\n", device->deviceinfo.pci->revision_id); + if (print_revision) + printf("\t\t\trevision_id\t%02x\n", device->deviceinfo.pci->revision_id); + else + printf("\t\t\trevision_id\tIGNORED\n"); + } else { printf("Unknown/unhandled bustype\n"); } @@ -70,10 +75,10 @@ main(void) drmDevicePtr device; int fd, ret, max_devices; - max_devices = drmGetDevices(NULL, 0); + max_devices = drmGetDevices2(0, NULL, 0); if (max_devices <= 0) { - printf("drmGetDevices() has returned %d\n", max_devices); + printf("drmGetDevices2() has returned %d\n", max_devices); return -1; } @@ -83,15 +88,15 @@ main(void) return -1; } - ret = drmGetDevices(devices, max_devices); + ret = drmGetDevices2(0, devices, max_devices); if (ret < 0) { - printf("drmGetDevices() returned an error %d\n", ret); + printf("drmGetDevices2() returned an error %d\n", ret); free(devices); return -1; } for (int i = 0; i < ret; i++) { - print_device_info(devices[i], i); + print_device_info(devices[i], i, false); for (int j = 0; j < DRM_NODE_MAX; j++) { if (devices[i]->available_nodes & 1 << j) { @@ -102,8 +107,8 @@ main(void) continue; } - if (drmGetDevice(fd, &device) == 0) { - print_device_info(device, i); + if (drmGetDevice2(fd, DRM_DEVICE_GET_PCI_REVISION, &device) == 0) { + print_device_info(device, i, true); drmFreeDevice(&device); } close(fd); diff --git a/xf86drm.c b/xf86drm.c index 52e9b9f..a886768 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -3019,7 +3019,7 @@ static int drmParsePciDeviceInfo(int maj, int min, uint32_t flags) { #ifdef __linux__ - if (flags & DRM_DEVICE_GET_PCI_REVISION == 0) + if (!(flags & DRM_DEVICE_GET_PCI_REVISION)) return parse_separate_sysfs_files(maj, min, device, true); if (parse_separate_sysfs_files(maj, min, device, false))