staging: ti dspbridge: fix compilation error
[linux-2.6/x86.git] / drivers / staging / tidspbridge / gen / uuidutil.c
blob070761bf62bbaf8a594becea3664fedcf281a68a
1 /*
2 * uuidutil.c
4 * DSP-BIOS Bridge driver support functions for TI OMAP processors.
6 * This file contains the implementation of UUID helper functions.
8 * Copyright (C) 2005-2006 Texas Instruments, Inc.
10 * This package is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
16 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 /* ----------------------------------- Host OS */
20 #include <dspbridge/host_os.h>
22 /* ----------------------------------- DSP/BIOS Bridge */
23 #include <dspbridge/std.h>
24 #include <dspbridge/dbdefs.h>
26 /* ----------------------------------- Trace & Debug */
27 #include <dspbridge/dbc.h>
29 /* ----------------------------------- This */
30 #include <dspbridge/uuidutil.h>
33 * ======== uuid_uuid_to_string ========
34 * Purpose:
35 * Converts a struct dsp_uuid to a string.
36 * Note: snprintf format specifier is:
37 * %[flags] [width] [.precision] [{h | l | I64 | L}]type
39 void uuid_uuid_to_string(IN struct dsp_uuid *uuid_obj, OUT char *pszUuid,
40 IN s32 size)
42 s32 i; /* return result from snprintf. */
44 DBC_REQUIRE(uuid_obj && pszUuid);
46 i = snprintf(pszUuid, size,
47 "%.8X_%.4X_%.4X_%.2X%.2X_%.2X%.2X%.2X%.2X%.2X%.2X",
48 uuid_obj->ul_data1, uuid_obj->us_data2, uuid_obj->us_data3,
49 uuid_obj->uc_data4, uuid_obj->uc_data5,
50 uuid_obj->uc_data6[0], uuid_obj->uc_data6[1],
51 uuid_obj->uc_data6[2], uuid_obj->uc_data6[3],
52 uuid_obj->uc_data6[4], uuid_obj->uc_data6[5]);
54 DBC_ENSURE(i != -1);
57 static s32 uuid_hex_to_bin(char *buf, s32 len)
59 s32 i;
60 s32 result = 0;
61 int value;
63 for (i = 0; i < len; i++) {
64 value = hex_to_bin(*buf++);
65 result *= 16;
66 if (value > 0)
67 result += value;
70 return result;
74 * ======== uuid_uuid_from_string ========
75 * Purpose:
76 * Converts a string to a struct dsp_uuid.
78 void uuid_uuid_from_string(IN char *pszUuid, OUT struct dsp_uuid *uuid_obj)
80 s32 j;
82 uuid_obj->ul_data1 = uuid_hex_to_bin(pszUuid, 8);
83 pszUuid += 8;
85 /* Step over underscore */
86 pszUuid++;
88 uuid_obj->us_data2 = (u16) uuid_hex_to_bin(pszUuid, 4);
89 pszUuid += 4;
91 /* Step over underscore */
92 pszUuid++;
94 uuid_obj->us_data3 = (u16) uuid_hex_to_bin(pszUuid, 4);
95 pszUuid += 4;
97 /* Step over underscore */
98 pszUuid++;
100 uuid_obj->uc_data4 = (u8) uuid_hex_to_bin(pszUuid, 2);
101 pszUuid += 2;
103 uuid_obj->uc_data5 = (u8) uuid_hex_to_bin(pszUuid, 2);
104 pszUuid += 2;
106 /* Step over underscore */
107 pszUuid++;
109 for (j = 0; j < 6; j++) {
110 uuid_obj->uc_data6[j] = (u8) uuid_hex_to_bin(pszUuid, 2);
111 pszUuid += 2;