From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Christoph Hellwig <hch@lst.de>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] uuid: Add helpers for finding UUID from an array
Date: Tue, 27 Aug 2019 14:49:18 +0300 [thread overview]
Message-ID: <20190827114918.25090-1-heikki.krogerus@linux.intel.com> (raw)
Matching function that compares every UUID in an array to a
given UUID with guid_equal().
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
Hi,
I don't have a user for these helpers, but since they are pretty
trivial, I figured that might as well propose them in any case.
Though, I think there was somebody proposing of doing the same thing
that these helpers do at one point, but just the hard way in the
drivers, right Andy?
thanks,
---
include/linux/uuid.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/include/linux/uuid.h b/include/linux/uuid.h
index 0c631e2a73b6..13e4d99f26dd 100644
--- a/include/linux/uuid.h
+++ b/include/linux/uuid.h
@@ -48,6 +48,16 @@ static inline bool guid_is_null(const guid_t *guid)
return guid_equal(guid, &guid_null);
}
+static inline bool guid_match(const guid_t *guids, const guid_t *guid)
+{
+ const guid_t *id;
+
+ for (id = guids; !guid_is_null(id); id++)
+ if (guid_equal(id, guid))
+ return true;
+ return false;
+}
+
static inline bool uuid_equal(const uuid_t *u1, const uuid_t *u2)
{
return memcmp(u1, u2, sizeof(uuid_t)) == 0;
@@ -63,6 +73,16 @@ static inline bool uuid_is_null(const uuid_t *uuid)
return uuid_equal(uuid, &uuid_null);
}
+static inline bool uuid_match(const uuid_t *uuids, const uuid_t *uuid)
+{
+ const uuid_t *id;
+
+ for (id = uuids; !uuid_is_null(id); id++)
+ if (uuid_equal(id, uuid))
+ return true;
+ return false;
+}
+
void generate_random_uuid(unsigned char uuid[16]);
extern void guid_gen(guid_t *u);
--
2.23.0.rc1
next reply other threads:[~2019-08-27 11:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 11:49 Heikki Krogerus [this message]
2019-08-27 11:54 ` Christoph Hellwig
2019-08-27 12:26 ` Heikki Krogerus
2019-08-27 14:11 ` Andy Shevchenko
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=20190827114918.25090-1-heikki.krogerus@linux.intel.com \
--to=heikki.krogerus@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®