]> git.ozlabs.org Git - petitboot/commitdiff
Add protocol object compare routines
authorGeoff Levand <geoffrey.levand@am.sony.com>
Sat, 7 Feb 2009 18:35:52 +0000 (18:35 +0000)
committerJeremy Kerr <jk@ozlabs.org>
Sat, 21 Feb 2009 00:06:22 +0000 (11:06 +1100)
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>
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
lib/pb-protocol/pb-protocol.c
lib/pb-protocol/pb-protocol.h

index 4daeb5a3bc35510a757ccf76f9e13bb3f8c12aab..69c9bfea63e5017051e9a66509c9aa9fc36c02bc 100644 (file)
@@ -58,6 +58,17 @@ struct boot_option *boot_option_copy(void* ctx, const struct boot_option *opt)
        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.
index 98f290662be0e1a71324572b1a36658c30b81871..fa5dd86a1ca80ee8824507bbad822e676a9e7b35 100644 (file)
@@ -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,