Patchwork [2/4] petitboot: Add protocol object compare routines

login
register
mail settings
Submitter Geoff Levand
Date Feb. 8, 2009, 4:35 a.m.
Message ID <20090208043550.833584087@am.sony.com>
Download mbox | patch
Permalink /patch/22562/
State Accepted
Delegated to: Jeremy Kerr
Headers show

Comments

Geoff Levand - Feb. 8, 2009, 4:35 a.m.
Add routines pb_protocol_device_cmp() and pb_protocol_boot_option_cmp()
to hide the implemention details of the device.  The implementation
of the id can be changed without effecting the users of it.

Signed-off-by: Geoff Levand <geoffrey.levand@am.sony.com>
---
 lib/pb-protocol/pb-protocol.c |   11 +++++++++++
 lib/pb-protocol/pb-protocol.h |    4 ++++
 2 files changed, 15 insertions(+)

Patch

--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -58,6 +58,17 @@  struct boot_option *boot_option_copy(voi
 	return new;
 }
 
+int pb_protocol_device_cmp(const struct device *a, const struct device *b)
+{
+	return !strcmp(a->id, b->id);
+}
+
+int pb_protocol_boot_option_cmp(const struct boot_option *a,
+	const struct boot_option *b)
+{
+	return !strcmp(a->id, b->id);
+}
+
 /* Write a string into the buffer, starting at pos.
  *
  * Returns the total length used for the write, including length header.
--- a/lib/pb-protocol/pb-protocol.h
+++ b/lib/pb-protocol/pb-protocol.h
@@ -48,6 +48,10 @@  struct boot_option {
 struct boot_option *boot_option_copy(void* ctx, const struct boot_option *opt);
 
 int pb_protocol_device_len(const struct device *dev);
+int pb_protocol_device_cmp(const struct device *a, const struct device *b);
+
+int pb_protocol_boot_option_cmp(const struct boot_option *a,
+	const struct boot_option *b);
 
 int pb_protocol_serialise_string(char *pos, const char *str);
 char *pb_protocol_deserialise_string(void *ctx,