Commit a3b22220 authored by Ivaylo Dimitrov's avatar Ivaylo Dimitrov Committed by Greg Kroah-Hartman

Staging: TIDSPBRIDGE: Remove UUID helper

Custom uuid helper function is needed only in rmgr/dbdcd.c and doesn't
need to be exported. It can also be made way simpler by using sscanf.
Signed-off-by: default avatarIvaylo Dimitrov <freemangordon@abv.bg>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 1fd4f55b
obj-$(CONFIG_TIDSPBRIDGE) += tidspbridge.o
libgen = gen/gh.o gen/uuidutil.o
libgen = gen/gh.o
libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
core/tiomap3430_pwr.o core/tiomap_io.o \
core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
......
/*
* uuidutil.c
*
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
*
* This file contains the implementation of UUID helper functions.
*
* Copyright (C) 2005-2006 Texas Instruments, Inc.
*
* This package is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <linux/types.h>
/* ----------------------------------- Host OS */
#include <dspbridge/host_os.h>
/* ----------------------------------- DSP/BIOS Bridge */
#include <dspbridge/dbdefs.h>
/* ----------------------------------- This */
#include <dspbridge/uuidutil.h>
static s32 uuid_hex_to_bin(char *buf, s32 len)
{
s32 i;
s32 result = 0;
int value;
for (i = 0; i < len; i++) {
value = hex_to_bin(*buf++);
result *= 16;
if (value > 0)
result += value;
}
return result;
}
/*
* ======== uuid_uuid_from_string ========
* Purpose:
* Converts a string to a struct dsp_uuid.
*/
void uuid_uuid_from_string(char *sz_uuid, struct dsp_uuid *uuid_obj)
{
s32 j;
uuid_obj->data1 = uuid_hex_to_bin(sz_uuid, 8);
sz_uuid += 8;
/* Step over underscore */
sz_uuid++;
uuid_obj->data2 = (u16) uuid_hex_to_bin(sz_uuid, 4);
sz_uuid += 4;
/* Step over underscore */
sz_uuid++;
uuid_obj->data3 = (u16) uuid_hex_to_bin(sz_uuid, 4);
sz_uuid += 4;
/* Step over underscore */
sz_uuid++;
uuid_obj->data4 = (u8) uuid_hex_to_bin(sz_uuid, 2);
sz_uuid += 2;
uuid_obj->data5 = (u8) uuid_hex_to_bin(sz_uuid, 2);
sz_uuid += 2;
/* Step over underscore */
sz_uuid++;
for (j = 0; j < 6; j++) {
uuid_obj->data6[j] = (u8) uuid_hex_to_bin(sz_uuid, 2);
sz_uuid += 2;
}
}
......@@ -21,22 +21,4 @@
#define MAXUUIDLEN 37
/*
* ======== uuid_uuid_from_string ========
* Purpose:
* Converts an ANSI string to a dsp_uuid.
* Parameters:
* sz_uuid: Pointer to a string that represents a dsp_uuid object.
* uuid_obj: Pointer to a dsp_uuid object.
* Returns:
* Requires:
* uuid_obj & sz_uuid are non-NULL values.
* Ensures:
* Details:
* We assume the string representation of a UUID has the following format:
* "12345678_1234_1234_1234_123456789abc".
*/
extern void uuid_uuid_from_string(char *sz_uuid,
struct dsp_uuid *uuid_obj);
#endif /* UUIDUTIL_ */
......@@ -73,6 +73,47 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
bool *prstnt_dep_libs,
enum nldr_phase phase);
/*
* ======== dcd_uuid_from_string ========
* Purpose:
* Converts an ANSI string to a dsp_uuid.
* Parameters:
* sz_uuid: Pointer to a string that represents a dsp_uuid object.
* uuid_obj: Pointer to a dsp_uuid object.
* Returns:
* 0: Success.
* -EINVAL: Coversion failed
* Requires:
* uuid_obj & sz_uuid are non-NULL values.
* Ensures:
* Details:
* We assume the string representation of a UUID has the following format:
* "12345678_1234_1234_1234_123456789abc".
*/
static int dcd_uuid_from_string(char *sz_uuid, struct dsp_uuid *uuid_obj)
{
char c;
u64 t;
struct dsp_uuid uuid_tmp;
/*
* sscanf implementation cannot deal with hh format modifier
* if the converted value doesn't fit in u32. So, convert the
* last six bytes to u64 and memcpy what is needed
*/
if(sscanf(sz_uuid, "%8x%c%4hx%c%4hx%c%2hhx%2hhx%c%llx",
&uuid_tmp.data1, &c, &uuid_tmp.data2, &c,
&uuid_tmp.data3, &c, &uuid_tmp.data4,
&uuid_tmp.data5, &c, &t) != 10)
return -EINVAL;
t = cpu_to_be64(t);
memcpy(&uuid_tmp.data6[0], ((char*)&t) + 2, 6);
*uuid_obj = uuid_tmp;
return 0;
}
/*
* ======== dcd_auto_register ========
* Purpose:
......@@ -253,14 +294,15 @@ int dcd_enumerate_object(s32 index, enum dsp_dcdobjtype obj_type,
if (!status) {
/* Create UUID value using string retrieved from
* registry. */
uuid_uuid_from_string(sz_value, &dsp_uuid_obj);
*uuid_obj = dsp_uuid_obj;
status = dcd_uuid_from_string(sz_value, &dsp_uuid_obj);
/* Increment enum_refs to update reference count. */
enum_refs++;
if (!status) {
*uuid_obj = dsp_uuid_obj;
status = 0;
/* Increment enum_refs to update reference
* count. */
enum_refs++;
}
} else if (status == -ENODATA) {
/* At the end of enumeration. Reset enum_refs. */
enum_refs = 0;
......@@ -581,24 +623,28 @@ int dcd_get_objects(struct dcd_manager *hdcd_mgr,
psz_cur = psz_coff_buf;
while ((token = strsep(&psz_cur, seps)) && *token != '\0') {
/* Retrieve UUID string. */
uuid_uuid_from_string(token, &dsp_uuid_obj);
/* Retrieve object type */
token = strsep(&psz_cur, seps);
status = dcd_uuid_from_string(token, &dsp_uuid_obj);
/* Retrieve object type */
object_type = atoi(token);
if (!status) {
/* Retrieve object type */
token = strsep(&psz_cur, seps);
/*
* Apply register_fxn to the found DCD object.
* Possible actions include:
*
* 1) Register found DCD object.
* 2) Unregister found DCD object (when handle == NULL)
* 3) Add overlay node.
*/
status =
register_fxn(&dsp_uuid_obj, object_type, handle);
/* Retrieve object type */
object_type = atoi(token);
/*
* Apply register_fxn to the found DCD object.
* Possible actions include:
*
* 1) Register found DCD object.
* 2) Unregister found DCD object
* (when handle == NULL)
* 3) Add overlay node.
*/
status =
register_fxn(&dsp_uuid_obj, object_type,
handle);
}
if (status) {
/* if error occurs, break from while loop. */
break;
......@@ -1001,9 +1047,12 @@ static int get_attrs_from_buf(char *psz_buf, u32 ul_buf_size,
token = strsep(&psz_cur, seps);
/* dsp_uuid ui_node_id */
uuid_uuid_from_string(token,
&gen_obj->obj_data.node_obj.ndb_props.
ui_node_id);
status = dcd_uuid_from_string(token,
&gen_obj->obj_data.node_obj.
ndb_props.ui_node_id);
if (status)
break;
token = strsep(&psz_cur, seps);
/* ac_name */
......@@ -1400,9 +1449,12 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
break;
} else {
/* Retrieve UUID string. */
uuid_uuid_from_string(token,
&(dep_lib_uuids
[dep_libs]));
status = dcd_uuid_from_string(token,
&(dep_lib_uuids
[dep_libs]));
if (status)
break;
/* Is this library persistent? */
token = strsep(&psz_cur, seps);
prstnt_dep_libs[dep_libs] = atoi(token);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment