From patchwork Sun Mar 16 14:02:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 3839241 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D4373BF540 for ; Sun, 16 Mar 2014 14:24:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 01432202AE for ; Sun, 16 Mar 2014 14:24:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0D58A20270 for ; Sun, 16 Mar 2014 14:24:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9F6F68969C; Sun, 16 Mar 2014 07:24:22 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ee0-f46.google.com (mail-ee0-f46.google.com [74.125.83.46]) by gabe.freedesktop.org (Postfix) with ESMTP id E4F6A8962B for ; Sun, 16 Mar 2014 07:24:19 -0700 (PDT) Received: by mail-ee0-f46.google.com with SMTP id t10so3169155eei.33 for ; Sun, 16 Mar 2014 07:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CqlSzjb1Ks7c/e3/H5ytLOQdI3Um/29NdBq0ZKAvfcQ=; b=QR7/B1BhhqJ6/14YW/n9MQmnG3bu6jQiHI2kcEk3bqJxNaHfP3TLFLEgfcHRo2SXqK 5MlI7YL9Bd+5SM2esMkwfa5xS54hXHfxja26O34YYCzUt6hkEEY7ht6irNPqVBzcNAjT v2CIY5v2tw3S8iUsLv1tMhhER/96KQXZ4iE8M= 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; bh=CqlSzjb1Ks7c/e3/H5ytLOQdI3Um/29NdBq0ZKAvfcQ=; b=gh0xBbgg4JjPSAYHffYi7iN6qqEHfhEd75tUFiyCi3UT2ywH7sW09kunSB2lIujdHd AbtwVUpiCt3hgyVyD//i0XTCkhYcZ/5BdW2tzT/M4+GRmAlX2znnIS+H1/K1zxtqrBuQ 9pePJdOr/2G0zHoJi8pWzHVVPXVI9nFLkaIuJg8z2ciUjbAqXirEX47M4IraoLqLy2GH IC/PMlETO5LEkpgMprHJRQK3dVJJKAUStydx2MYwouJI+DvqIxsT0PBY4GPqMTCcudDZ lQFQMZ89EXMrIiMMFu5+PeJ5SZMua6OeSMKRpQMINy9gjkGTLEBocnT6XIOWkX5ilGD0 hdlw== X-Gm-Message-State: ALoCoQnzDKr7qCAzYD1Rm+cuKnJpYPy0FjTJPjtWqlMvAStmJz5GQG/nmVCyo9EdKvHioRXlqUCZ X-Received: by 10.14.246.196 with SMTP id q44mr18865054eer.45.1394979859181; Sun, 16 Mar 2014 07:24:19 -0700 (PDT) Received: from wespe.ffwll.local (84-73-67-144.dclient.hispeed.ch. [84.73.67.144]) by mx.google.com with ESMTPSA id 46sm32481433ees.4.2014.03.16.07.24.17 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Mar 2014 07:24:18 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Sun, 16 Mar 2014 15:02:26 +0100 Message-Id: <1394978548-26478-3-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1394978548-26478-1-git-send-email-daniel.vetter@ffwll.ch> References: <1394978548-26478-1-git-send-email-daniel.vetter@ffwll.ch> Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 3/5] lib/igt_debugfs: Remove debugfs from igt_debugfs_fopen X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Also add a missing igt_assert to kms_fbc_crc and again add the missing Returns: section to the api doc. Signed-off-by: Daniel Vetter --- lib/igt_debugfs.c | 13 ++++++++++--- lib/igt_debugfs.h | 2 +- tests/kms_fbc_crc.c | 6 ++++-- tests/kms_pipe_crc_basic.c | 2 +- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c index 2f9c7b117aa5..16d4ffcf4b10 100644 --- a/lib/igt_debugfs.c +++ b/lib/igt_debugfs.c @@ -161,18 +161,25 @@ int igt_debugfs_open(const char *filename, int mode) /** * igt_debugfs_fopen: - * @debugfs: debugfs access structure * @filename: name of the debugfs node to open * @mode: mode string as used by fopen() * * This opens a debugfs file as a libc FILE. The filename should be * relative to the drm device's root, i.e without "drm/<minor>". + * + * Returns: + * The libc FILE pointer for the debugfs file or NULL if that didn't work out. */ -FILE *igt_debugfs_fopen(igt_debugfs_t *debugfs, const char *filename, +FILE *igt_debugfs_fopen(const char *filename, const char *mode) { char buf[1024]; + igt_debugfs_t *debugfs = __igt_debugfs_singleton(); + + if (!debugfs) + return NULL; + sprintf(buf, "%s/%s", debugfs->dri_path, filename); return fopen(buf, mode); } @@ -333,7 +340,7 @@ void igt_pipe_crc_check(igt_debugfs_t *debugfs) size_t written; int ret; - ctl = igt_debugfs_fopen(debugfs, "i915_display_crc_ctl", "r+"); + ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+"); igt_require_f(ctl, "No display_crc_ctl found, kernel too old\n"); written = fwrite(cmd, 1, strlen(cmd), ctl); diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h index 690f3dcaec41..6e9cec2b5018 100644 --- a/lib/igt_debugfs.h +++ b/lib/igt_debugfs.h @@ -43,7 +43,7 @@ typedef struct { void igt_debugfs_init(igt_debugfs_t *debugfs); int igt_debugfs_open(const char *filename, int mode); -FILE *igt_debugfs_fopen(igt_debugfs_t *debugfs, const char *filename, +FILE *igt_debugfs_fopen(const char *filename, const char *mode); /* diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c index edcba7a28670..fce3863dc9d7 100644 --- a/tests/kms_fbc_crc.c +++ b/tests/kms_fbc_crc.c @@ -239,7 +239,9 @@ static bool fbc_enabled(data_t *data) FILE *status; char str[64] = {}; - status = igt_debugfs_fopen(&data->debugfs, "i915_fbc_status", "r"); + status = igt_debugfs_fopen("i915_fbc_status", "r"); + igt_assert(status); + fread(str, sizeof(str) - 1, 1, status); fclose(status); return strstr(str, "FBC enabled") != NULL; @@ -494,7 +496,7 @@ igt_main igt_debugfs_init(&data.debugfs); igt_pipe_crc_check(&data.debugfs); - status = igt_debugfs_fopen(&data.debugfs, "i915_fbc_status", "r"); + status = igt_debugfs_fopen("i915_fbc_status", "r"); igt_require_f(status, "No i915_fbc_status found\n"); fread(buf, sizeof(buf), 1, status); fclose(status); diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c index 9aa342757793..da5597368f29 100644 --- a/tests/kms_pipe_crc_basic.c +++ b/tests/kms_pipe_crc_basic.c @@ -43,7 +43,7 @@ static void test_bad_command(data_t *data, const char *cmd) FILE *ctl; size_t written; - ctl = igt_debugfs_fopen(&data->debugfs, "i915_display_crc_ctl", "r+"); + ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+"); written = fwrite(cmd, 1, strlen(cmd), ctl); fflush(ctl); igt_assert_cmpint(written, ==, (strlen(cmd)));