From patchwork Sun Feb 8 04:35:52 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 22562 X-Patchwork-Delegate: jk@ozlabs.org Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id E8BD8DDE19 for ; Sun, 8 Feb 2009 15:39:29 +1100 (EST) X-Original-To: cbe-oss-dev@ozlabs.org Delivered-To: cbe-oss-dev@ozlabs.org Received: from hera.kernel.org (hera.kernel.org [140.211.167.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EB876DDE1D; Sun, 8 Feb 2009 15:39:06 +1100 (EST) Received: from hera.kernel.org (IDENT:U2FsdGVkX18Jsg/vKyibdlqMBclih1Wjf7g7GyOItug@localhost [127.0.0.1]) by hera.kernel.org (8.14.2/8.14.2) with ESMTP id n184d04f011752 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 8 Feb 2009 04:39:00 GMT Received: (from geoff@localhost) by hera.kernel.org (8.14.2/8.13.1/Submit) id n184d0o5011751; Sun, 8 Feb 2009 04:39:00 GMT Message-Id: <20090208043550.833584087@am.sony.com> References: <20090208043550.681477743@am.sony.com> In-Reply-To: <20090208043550.681477743@am.sony.com> User-Agent: quilt/0.46-1 Date: Sat, 07 Feb 2009 20:35:52 -0800 From: Geoff Levand To: Jeremy Kerr Content-Disposition: inline; filename=add-protocol-cmp.diff X-Virus-Scanned: ClamAV 0.93.3/8963/Sat Feb 7 05:53:02 2009 on hera.kernel.org X-Virus-Status: Clean X-Spam-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on hera.kernel.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0 (hera.kernel.org [127.0.0.1]); Sun, 08 Feb 2009 04:39:02 +0000 (UTC) Cc: cbe-oss-dev@ozlabs.org Subject: [Cbe-oss-dev] [patch 2/4] petitboot: Add protocol object compare routines X-BeenThere: cbe-oss-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Discussion about Open Source Software for the Cell Broadband Engine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org 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 --- lib/pb-protocol/pb-protocol.c | 11 +++++++++++ lib/pb-protocol/pb-protocol.h | 4 ++++ 2 files changed, 15 insertions(+) --- 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,