From patchwork Wed Nov 30 20:35:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 9454873 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 4A3386074E for ; Wed, 30 Nov 2016 20:35:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F0B228484 for ; Wed, 30 Nov 2016 20:35:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33E7C284A2; Wed, 30 Nov 2016 20:35:39 +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 BBE8028484 for ; Wed, 30 Nov 2016 20:35:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AD4376E52E; Wed, 30 Nov 2016 20:35:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x242.google.com (mail-wm0-x242.google.com [IPv6:2a00:1450:400c:c09::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 832196E522 for ; Wed, 30 Nov 2016 20:35:34 +0000 (UTC) Received: by mail-wm0-x242.google.com with SMTP id a20so31195169wme.2 for ; Wed, 30 Nov 2016 12:35:34 -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=YmAL6CQ9c/jMRsdcptn2GH8KoUxPL2f4T9l/otUAaLTjnFK3CvZe1yKQur/OfaV892 dBJbbheTllidQSYgJODjzvd1OfsS3br6Gy+QGO34kuhckJQTDA81l4TKF2tqA04eUVKy NMtGB1D4S8SnjY0oxYCg1JkeNa132MmNGECoohxPtVeZBW3nZZU1iT6LKbZdDqUruKpO QIRJSD5H2aVUqq+1zRfewwFSmuMjbuFdsV1nV9MeqYOu9k2XMoWkfDRs8RF8F0iLvg/l j4fYPoBS4ydQNRL4C0xAkmHKa6sfrtK5du2DbJlzuSm6rhXv5BzNqhjAfuTYSQ/MEhCK yzTQ== 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=DQtKxkEjdQJtdCr38USlTawf+WGQlNipqUl3q71PHIbl8yBUoDZJoCo/wGpVLd7ecY l+vZPLlqv6Yuwhe87zx0x9+MOhkKbHSXIRfSdNQPIBCBzDouMXf5CurOQOt+bh//rQRM jCC1mDpzlf/fmH0Uati6/hcm9AZvN7kBvjukCfaaoXy+kGfEQihzwlizig0AG9s2sAUW LM86nndLulIOERbtTRMInru6jRW/igssHGtl9G6QhYPcZPMn3bhvqEx3nmDbU5qC09zu d/4hw8KmMhUBrmCytJCaZW7w6SmjnoXo0bKTkEEtNOl8wNspcjR9boa5N+x+yiCnRy5I aOAw== X-Gm-Message-State: AKaTC02sSbwKWqUuEhsBwhmmvuWxv5Ceq1/f+d7yR3NQuQf9v1R7WIli0HDjDJNke/fB4g== X-Received: by 10.28.152.137 with SMTP id a131mr28461482wme.56.1480538132488; Wed, 30 Nov 2016 12:35:32 -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 ei2sm74572607wjd.47.2016.11.30.12.35.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Nov 2016 12:35:31 -0800 (PST) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm 1/5] xf86drm: use maj/min in drmParsePciDeviceInfo() Date: Wed, 30 Nov 2016 20:35:07 +0000 Message-Id: <20161130203511.18910-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;