All of lore.kernel.org
 help / color / mirror / Atom feed
From: cujomalainey@chromium.org
To: alsa-devel@alsa-project.org
Cc: Curtis Malainey <cujomalainey@chromium.org>, tiwai@suse.com
Subject: [PATCH v2] ucm: add existence checks to geti calls
Date: Fri, 13 Jan 2023 10:50:19 -0800	[thread overview]
Message-ID: <20230113185019.1500147-1-cujomalainey@chromium.org> (raw)
In-Reply-To: <20230112234426.1714071-1-cujomalainey@chromium.org>

From: Curtis Malainey <cujomalainey@chromium.org>

Right now in snd_use_case_geti you cannot tell if the item being queried
exists or not when being checked. This also means the only way to check
for the existence of something in the client of the library is to
iterate over the list of mods/devs even if we know exactly the name we
are looking for. We have functions that do exactly this internally so
lets return this information in a logical fashion through geti.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
---
 src/ucm/main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/ucm/main.c b/src/ucm/main.c
index 2ff4d3f3..adbddc26 100644
--- a/src/ucm/main.c
+++ b/src/ucm/main.c
@@ -1321,6 +1321,9 @@ long device_status(snd_use_case_mgr_t *uc_mgr,
 		if (strcmp(dev->name, device_name) == 0)
 			return 1;
 	}
+	dev = find_device(uc_mgr, uc_mgr->active_verb, device_name, 0);
+	if (!dev)
+		return -ENOENT;
 	return 0;
 }
 
@@ -1335,6 +1338,9 @@ long modifier_status(snd_use_case_mgr_t *uc_mgr,
 		if (strcmp(mod->name, modifier_name) == 0)
 			return 1;
 	}
+	mod = find_modifier(uc_mgr, uc_mgr->active_verb, modifier_name, 0);
+	if (!mod)
+		return -ENOENT;
 	return 0;
 }
 
-- 
2.39.0.314.g84b9a713c41-goog


  reply	other threads:[~2023-01-13 18:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12 23:44 [PATCH] ucm: add existence checks to geti calls cujomalainey
2023-01-13 18:50 ` cujomalainey [this message]
2023-01-13 19:32   ` [PATCH v2] " Jaroslav Kysela
2023-01-13 19:36     ` Curtis Malainey
2023-01-13 21:21   ` [PATCH v3] " cujomalainey
2023-01-15 17:40     ` Jaroslav Kysela
2023-01-15 18:00       ` Jaroslav Kysela

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=20230113185019.1500147-1-cujomalainey@chromium.org \
    --to=cujomalainey@chromium.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.