From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH i-g-t 1/3] lib: Add helper for reading modparam values
Date: Thu, 18 Mar 2021 16:23:58 +0000 [thread overview]
Message-ID: <20210318162400.2065097-2-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <20210318162400.2065097-1-tvrtko.ursulin@linux.intel.com>
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Add __igt_params_get for simple reading of modparams.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
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
next prev parent reply other threads:[~2021-03-18 16:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-18 16:23 [Intel-gfx] [PATCH i-g-t 0/3] Default fence expiration test Tvrtko Ursulin
2021-03-18 16:23 ` Tvrtko Ursulin [this message]
2021-03-30 10:49 ` [Intel-gfx] [igt-dev] [PATCH i-g-t 1/3] lib: Add helper for reading modparam values Matthew Auld
2021-03-18 16:23 ` [Intel-gfx] [PATCH i-g-t 2/3] tests/i915: Default fence expiry test Tvrtko Ursulin
2021-03-30 12:53 ` Matthew Auld
2021-03-18 16:24 ` [Intel-gfx] [PATCH i-g-t 3/3] tests/i915/gem_watchdog: Exercise long rendering chains Tvrtko Ursulin
2021-03-30 15:40 ` [Intel-gfx] [igt-dev] " Matthew Auld
-- strict thread matches above, loose matches on Subject: below --
2021-03-31 11:02 [Intel-gfx] [PATCH i-g-t 1/3] lib: Add helper for reading modparam values Tvrtko Ursulin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210318162400.2065097-2-tvrtko.ursulin@linux.intel.com \
--to=tvrtko.ursulin@linux.intel.com \
--cc=Intel-gfx@lists.freedesktop.org \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox