From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Subject: [PATCH i-g-t v2 2/4] lib/kms: Adjust forced_connectors[] traversal
Date: Thu, 11 Apr 2024 21:34:48 +0300 [thread overview]
Message-ID: <20240411183450.6417-2-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20240411183450.6417-1-ville.syrjala@linux.intel.com>
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Get rid of the sentinel in forced_comnectors[] and just
use ARRAY_SIZE() to determine the limits.
The sentinel stuff actually looks broken due to the use of
ARRAY_SIZE() in forced_connector_free_index(), which was
apparently my doing in
commit ed6539ced33e ("lib/igt_kms: Rework forced connector handling")
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
lib/igt_kms.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index d20a93372540..86651e3de348 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -98,7 +98,7 @@ struct igt_forced_connector {
int dir;
};
-static struct igt_forced_connector forced_connectors[MAX_CONNECTORS + 1];
+static struct igt_forced_connector forced_connectors[MAX_CONNECTORS];
/**
* igt_kms_get_base_edid:
@@ -1499,7 +1499,7 @@ static bool connector_is_forced(int idx, drmModeConnector *connector)
{
igt_assert(connector->connector_type != 0);
- for (int i = 0; forced_connectors[i].connector_type; i++) {
+ for (int i = 0; i < ARRAY_SIZE(forced_connectors); i++) {
struct igt_forced_connector *c = &forced_connectors[i];
if (c->idx == idx &&
@@ -1513,15 +1513,14 @@ static bool connector_is_forced(int idx, drmModeConnector *connector)
static struct igt_forced_connector *forced_connector_alloc(void)
{
- int i;
+ for (int i = 0; i < ARRAY_SIZE(forced_connectors); i++) {
+ struct igt_forced_connector *c = &forced_connectors[i];
- for (i = 0; forced_connectors[i].connector_type; i++)
- ;
+ if (!c->connector_type)
+ return c;
+ }
- if (i >= ARRAY_SIZE(forced_connectors))
- return NULL;
-
- return &forced_connectors[i];
+ return NULL;
}
static bool force_connector(int drm_fd,
@@ -1578,9 +1577,12 @@ static void dump_forced_connectors(void)
igt_debug("Current forced connectors:\n");
- for (int i = 0; forced_connectors[i].connector_type; i++) {
+ for (int i = 0; i < ARRAY_SIZE(forced_connectors); i++) {
struct igt_forced_connector *c = &forced_connectors[i];
+ if (!c->connector_type)
+ continue;
+
kmstest_connector_dirname(c->idx, c->connector_type,
c->connector_type_id,
name, sizeof(name));
@@ -5311,9 +5313,12 @@ void igt_reset_connectors(void)
{
/* reset the connectors stored in forced_connectors, avoiding any
* functions that are not safe to call in signal handlers */
- for (int i = 0; i < forced_connectors[i].connector_type; i++) {
+ for (int i = 0; i < ARRAY_SIZE(forced_connectors); i++) {
struct igt_forced_connector *c = &forced_connectors[i];
+ if (!c->connector_type)
+ continue;
+
igt_sysfs_set(c->dir, "status", "detect");
}
}
--
2.43.2
next prev parent reply other threads:[~2024-04-11 18:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-11 18:34 [PATCH i-g-t v2 1/4] lib/kms: Introduce struct igt_forced_connector Ville Syrjala
2024-04-11 18:34 ` Ville Syrjala [this message]
2024-04-14 5:56 ` [PATCH i-g-t v2 2/4] lib/kms: Adjust forced_connectors[] traversal Joshi, Kunal1
2024-04-11 18:34 ` [PATCH i-g-t v2 3/4] lib/kms: Generalize forced_connectors[] to handle arbitrary attributes Ville Syrjala
2024-04-14 5:57 ` Joshi, Kunal1
2024-04-11 18:34 ` [PATCH i-g-t v2 4/4] lib/kms: Clear connector_attrs[] upon setting the reset value Ville Syrjala
2024-04-14 5:59 ` Joshi, Kunal1
2024-04-16 12:33 ` Ville Syrjälä
2024-04-11 19:17 ` ✓ CI.xeBAT: success for series starting with [i-g-t,v2,1/4] lib/kms: Introduce struct igt_forced_connector Patchwork
2024-04-11 19:26 ` ✓ Fi.CI.BAT: " Patchwork
2024-04-12 1:49 ` ✗ CI.xeFULL: failure " Patchwork
2024-04-12 5:17 ` ✗ Fi.CI.IGT: " Patchwork
2024-04-14 5:55 ` [PATCH i-g-t v2 1/4] " Joshi, Kunal1
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=20240411183450.6417-2-ville.syrjala@linux.intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kunal1.joshi@intel.com \
/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