From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55EBEC433E9 for ; Thu, 18 Mar 2021 16:24:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1CC3164E98 for ; Thu, 18 Mar 2021 16:24:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1CC3164E98 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=intel-gfx-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E922D6E91D; Thu, 18 Mar 2021 16:24:14 +0000 (UTC) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0C24A6E91E; Thu, 18 Mar 2021 16:24:13 +0000 (UTC) IronPort-SDR: dn7aJGpH0SB8HOo1BYoyMUB4JuWFmXJhpT2Ob8Ks6T6DI5a+hwuHWgkRfPx9an8wkqc48l+2M3 0IUEZ67vZG7w== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="189760742" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="189760742" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 09:24:12 -0700 IronPort-SDR: kQZA/rdLhgSwtV118K1ko8jc2yrFJIl9xXVAR9WhrV8R0yMsAORZavxoMUrO49vM1o/2eReEFA VxWYXcmOsXgA== X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="413149655" Received: from syeghiay-mobl.ger.corp.intel.com (HELO localhost.localdomain) ([10.252.51.182]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 09:24:11 -0700 From: Tvrtko Ursulin To: igt-dev@lists.freedesktop.org Date: Thu, 18 Mar 2021 16:23:58 +0000 Message-Id: <20210318162400.2065097-2-tvrtko.ursulin@linux.intel.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210318162400.2065097-1-tvrtko.ursulin@linux.intel.com> References: <20210318162400.2065097-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 1/3] lib: Add helper for reading modparam values X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Intel-gfx@lists.freedesktop.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Tvrtko Ursulin Add __igt_params_get for simple reading of modparams. Signed-off-by: Tvrtko Ursulin --- lib/igt_params.c | 26 ++++++++++++++++++++++++++ lib/igt_params.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/lib/igt_params.c b/lib/igt_params.c index c06416988baa..1dc6de77b2e0 100644 --- a/lib/igt_params.c +++ b/lib/igt_params.c @@ -156,6 +156,32 @@ int igt_params_open(int device) return params; } +/** + * __igt_params_get: + * @device: fd of the device + * @parameter: the name of the parameter to set + * + * This reads the value of the modparam. + * + * Returns: + * A nul-terminated string, must be freed by caller after use, or NULL + * on failure. + */ +char *__igt_params_get(int device, const char *parameter) +{ + char *str; + int dir; + + dir = igt_params_open(device); + if (dir < 0) + return NULL; + + str = igt_sysfs_get(dir, parameter); + close(dir); + + return str; +} + __attribute__((format(printf, 3, 0))) static bool __igt_params_set(int device, const char *parameter, const char *fmt, va_list ap, bool save) diff --git a/lib/igt_params.h b/lib/igt_params.h index bbd6f3ee6582..6494786f0696 100644 --- a/lib/igt_params.h +++ b/lib/igt_params.h @@ -28,6 +28,8 @@ int igt_params_open(int device); +char *__igt_params_get(int device, const char *parameter); + __attribute__((format(printf, 3, 4))) bool igt_params_set(int device, const char *parameter, const char *fmt, ...); -- 2.27.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Tvrtko Ursulin Date: Thu, 18 Mar 2021 16:23:58 +0000 Message-Id: <20210318162400.2065097-2-tvrtko.ursulin@linux.intel.com> In-Reply-To: <20210318162400.2065097-1-tvrtko.ursulin@linux.intel.com> References: <20210318162400.2065097-1-tvrtko.ursulin@linux.intel.com> MIME-Version: 1.0 Subject: [igt-dev] [PATCH i-g-t 1/3] lib: Add helper for reading modparam values List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" To: igt-dev@lists.freedesktop.org Cc: Intel-gfx@lists.freedesktop.org List-ID: From: Tvrtko Ursulin Add __igt_params_get for simple reading of modparams. Signed-off-by: Tvrtko Ursulin --- lib/igt_params.c | 26 ++++++++++++++++++++++++++ lib/igt_params.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/lib/igt_params.c b/lib/igt_params.c index c06416988baa..1dc6de77b2e0 100644 --- a/lib/igt_params.c +++ b/lib/igt_params.c @@ -156,6 +156,32 @@ int igt_params_open(int device) return params; } +/** + * __igt_params_get: + * @device: fd of the device + * @parameter: the name of the parameter to set + * + * This reads the value of the modparam. + * + * Returns: + * A nul-terminated string, must be freed by caller after use, or NULL + * on failure. + */ +char *__igt_params_get(int device, const char *parameter) +{ + char *str; + int dir; + + dir = igt_params_open(device); + if (dir < 0) + return NULL; + + str = igt_sysfs_get(dir, parameter); + close(dir); + + return str; +} + __attribute__((format(printf, 3, 0))) static bool __igt_params_set(int device, const char *parameter, const char *fmt, va_list ap, bool save) diff --git a/lib/igt_params.h b/lib/igt_params.h index bbd6f3ee6582..6494786f0696 100644 --- a/lib/igt_params.h +++ b/lib/igt_params.h @@ -28,6 +28,8 @@ int igt_params_open(int device); +char *__igt_params_get(int device, const char *parameter); + __attribute__((format(printf, 3, 4))) bool igt_params_set(int device, const char *parameter, const char *fmt, ...); -- 2.27.0 _______________________________________________ igt-dev mailing list igt-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/igt-dev