* [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper
@ 2013-12-01 17:07 Ivaylo DImitrov
2013-12-01 19:06 ` Joe Perches
2013-12-06 6:05 ` Ivajlo Dimitrov
0 siblings, 2 replies; 14+ messages in thread
From: Ivaylo DImitrov @ 2013-12-01 17:07 UTC (permalink / raw)
To: omar.ramirez
Cc: gregkh, pali.rohar, pavel, linux-kernel, devel, Ivaylo Dimitrov
From: Ivaylo Dimitrov <freemangordon@abv.bg>
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: Ivaylo Dimitrov <freemangordon@abv.bg>
---
drivers/staging/tidspbridge/Makefile | 2 +-
drivers/staging/tidspbridge/gen/uuidutil.c | 85 --------------------
.../tidspbridge/include/dspbridge/uuidutil.h | 18 ----
drivers/staging/tidspbridge/rmgr/dbdcd.c | 42 +++++++++-
4 files changed, 39 insertions(+), 108 deletions(-)
delete mode 100644 drivers/staging/tidspbridge/gen/uuidutil.c
diff --git a/drivers/staging/tidspbridge/Makefile b/drivers/staging/tidspbridge/Makefile
index 230e3e6..2e77734 100644
--- a/drivers/staging/tidspbridge/Makefile
+++ b/drivers/staging/tidspbridge/Makefile
@@ -1,6 +1,6 @@
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
diff --git a/drivers/staging/tidspbridge/gen/uuidutil.c b/drivers/staging/tidspbridge/gen/uuidutil.c
deleted file mode 100644
index b7d8313..0000000
--- a/drivers/staging/tidspbridge/gen/uuidutil.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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;
- }
-}
diff --git a/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h b/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h
index 414bf71..b4951a1 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h
@@ -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_ */
diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c
index 3d2a26f..d640794 100644
--- a/drivers/staging/tidspbridge/rmgr/dbdcd.c
+++ b/drivers/staging/tidspbridge/rmgr/dbdcd.c
@@ -74,6 +74,40 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
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:
+ * 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 void dcd_uuid_from_string(char *sz_uuid, struct dsp_uuid *uuid_obj)
+{
+ char c;
+ u64 t;
+
+ /*
+ * 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
+ */
+ sscanf(sz_uuid, "%8x%c%4hx%c%4hx%c%2hhx%2hhx%c%llx",
+ &uuid_obj->data1, &c, &uuid_obj->data2, &c,
+ &uuid_obj->data3, &c, &uuid_obj->data4,
+ &uuid_obj->data5, &c, &t);
+
+ t = cpu_to_be64(t);
+ memcpy(&uuid_obj->data6[0], ((char*)&t) + 2, 6);
+}
+
+/*
* ======== dcd_auto_register ========
* Purpose:
* Parses the supplied image and resigsters with DCD.
@@ -253,7 +287,7 @@ 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);
+ dcd_uuid_from_string(sz_value, &dsp_uuid_obj);
*uuid_obj = dsp_uuid_obj;
@@ -581,7 +615,7 @@ 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);
+ dcd_uuid_from_string(token, &dsp_uuid_obj);
/* Retrieve object type */
token = strsep(&psz_cur, seps);
@@ -1001,7 +1035,7 @@ 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,
+ dcd_uuid_from_string(token,
&gen_obj->obj_data.node_obj.ndb_props.
ui_node_id);
token = strsep(&psz_cur, seps);
@@ -1400,7 +1434,7 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
break;
} else {
/* Retrieve UUID string. */
- uuid_uuid_from_string(token,
+ dcd_uuid_from_string(token,
&(dep_lib_uuids
[dep_libs]));
/* Is this library persistent? */
--
1.5.6.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-01 17:07 [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper Ivaylo DImitrov
@ 2013-12-01 19:06 ` Joe Perches
2013-12-01 23:26 ` Ivajlo Dimitrov
2013-12-06 6:05 ` Ivajlo Dimitrov
1 sibling, 1 reply; 14+ messages in thread
From: Joe Perches @ 2013-12-01 19:06 UTC (permalink / raw)
To: Ivaylo DImitrov
Cc: omar.ramirez, gregkh, pali.rohar, pavel, linux-kernel, devel,
Ivaylo Dimitrov
On Sun, 2013-12-01 at 19:07 +0200, Ivaylo DImitrov wrote:
> From: Ivaylo Dimitrov <freemangordon@abv.bg>
>
> 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.
[]
> diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c
[]
> @@ -74,6 +74,40 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
> 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:
> + * 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 void dcd_uuid_from_string(char *sz_uuid, struct dsp_uuid *uuid_obj)
> +{
> + char c;
> + u64 t;
> +
> + /*
> + * 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
> + */
> + sscanf(sz_uuid, "%8x%c%4hx%c%4hx%c%2hhx%2hhx%c%llx",
> + &uuid_obj->data1, &c, &uuid_obj->data2, &c,
> + &uuid_obj->data3, &c, &uuid_obj->data4,
> + &uuid_obj->data5, &c, &t);
> +
> + t = cpu_to_be64(t);
> + memcpy(&uuid_obj->data6[0], ((char*)&t) + 2, 6);
> +}
It'd probably be better to return true or false on
successful conversion, use a temporary struct dsp_uuid,
check the sscanf return is 10 and only copy to uuid_obj
on success.
Something like:
static bool dcd_uuid_from_string(char *sz_uuid, struct dsp_uuid *uuid_obj)
{
char c;
u64 t;
struct dsp_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",
&tmp.data1, &c, &tmp.data2, &c,
&tmp.data3, &c, &tmp.data4,
&tmp.data5, &c, &t) != 10)
return false;
t = cpu_to_be64(t);
memcpy(&tmp.data6[0], ((char*)&t) + 2, 6);
*uuid_obj = tmp;
return true;
}
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-01 19:06 ` Joe Perches
@ 2013-12-01 23:26 ` Ivajlo Dimitrov
0 siblings, 0 replies; 14+ messages in thread
From: Ivajlo Dimitrov @ 2013-12-01 23:26 UTC (permalink / raw)
To: Joe Perches, Ivaylo DImitrov
Cc: omar.ramirez, gregkh, pali.rohar, pavel, linux-kernel, devel,
Ivaylo Dimitrov
On 01.12.2013 21:06, Joe Perches wrote:
> On Sun, 2013-12-01 at 19:07 +0200, Ivaylo DImitrov wrote:
>> From: Ivaylo Dimitrov <freemangordon@abv.bg>
>>
>> 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.
> []
>> diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c
> []
>> @@ -74,6 +74,40 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
>> 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:
>> + * 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 void dcd_uuid_from_string(char *sz_uuid, struct dsp_uuid *uuid_obj)
>> +{
>> + char c;
>> + u64 t;
>> +
>> + /*
>> + * 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
>> + */
>> + sscanf(sz_uuid, "%8x%c%4hx%c%4hx%c%2hhx%2hhx%c%llx",
>> + &uuid_obj->data1, &c, &uuid_obj->data2, &c,
>> + &uuid_obj->data3, &c, &uuid_obj->data4,
>> + &uuid_obj->data5, &c, &t);
>> +
>> + t = cpu_to_be64(t);
>> + memcpy(&uuid_obj->data6[0], ((char*)&t) + 2, 6);
>> +}
> It'd probably be better to return true or false on
> successful conversion, use a temporary struct dsp_uuid,
> check the sscanf return is 10 and only copy to uuid_obj
> on success.
>
> Something like:
>
> static bool dcd_uuid_from_string(char *sz_uuid, struct dsp_uuid *uuid_obj)
> {
> char c;
> u64 t;
> struct dsp_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",
> &tmp.data1, &c, &tmp.data2, &c,
> &tmp.data3, &c, &tmp.data4,
> &tmp.data5, &c, &t) != 10)
> return false;
>
> t = cpu_to_be64(t);
> memcpy(&tmp.data6[0], ((char*)&t) + 2, 6);
> *uuid_obj = tmp;
>
> return true;
> }
>
>
If there is to be a return value from that function, it is better to be
int (-EINVAL/0), IMO. And I am not sure that makes much of a sense, as
(afaik) uuids are read from baseimage.dof and codec nodes, if those are
broken I suspect wrong uuids will be our least problem.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-01 17:07 [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper Ivaylo DImitrov
2013-12-01 19:06 ` Joe Perches
@ 2013-12-06 6:05 ` Ivajlo Dimitrov
2013-12-06 7:32 ` Dan Carpenter
2013-12-06 15:10 ` gregkh
1 sibling, 2 replies; 14+ messages in thread
From: Ivajlo Dimitrov @ 2013-12-06 6:05 UTC (permalink / raw)
To: Ivaylo DImitrov, gregkh@linuxfoundation.org
Cc: omar.ramirez@copitl.com, pali.rohar, pavel, linux-kernel, devel,
Ivaylo Dimitrov
Hi Greg,
On 01.12.2013 19:07, Ivaylo DImitrov wrote:
> From: Ivaylo Dimitrov <freemangordon@abv.bg>
>
> 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: Ivaylo Dimitrov <freemangordon@abv.bg>
> ---
> drivers/staging/tidspbridge/Makefile | 2 +-
> drivers/staging/tidspbridge/gen/uuidutil.c | 85 --------------------
> .../tidspbridge/include/dspbridge/uuidutil.h | 18 ----
> drivers/staging/tidspbridge/rmgr/dbdcd.c | 42 +++++++++-
> 4 files changed, 39 insertions(+), 108 deletions(-)
> delete mode 100644 drivers/staging/tidspbridge/gen/uuidutil.c
>
I guess the initial mail somehow didn't make it through your spam filter:
https://lkml.org/lkml/2013/12/1/70
Regards,
Ivo
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-06 6:05 ` Ivajlo Dimitrov
@ 2013-12-06 7:32 ` Dan Carpenter
2013-12-06 7:41 ` Ivajlo Dimitrov
2013-12-06 15:10 ` gregkh
1 sibling, 1 reply; 14+ messages in thread
From: Dan Carpenter @ 2013-12-06 7:32 UTC (permalink / raw)
To: Ivajlo Dimitrov
Cc: gregkh@linuxfoundation.org, devel, linux-kernel, Ivaylo Dimitrov,
pavel, pali.rohar
On Fri, Dec 06, 2013 at 08:05:38AM +0200, Ivajlo Dimitrov wrote:
> Hi Greg,
>
> On 01.12.2013 19:07, Ivaylo DImitrov wrote:
> >From: Ivaylo Dimitrov <freemangordon@abv.bg>
> >
> >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: Ivaylo Dimitrov <freemangordon@abv.bg>
> >---
> > drivers/staging/tidspbridge/Makefile | 2 +-
> > drivers/staging/tidspbridge/gen/uuidutil.c | 85 --------------------
> > .../tidspbridge/include/dspbridge/uuidutil.h | 18 ----
> > drivers/staging/tidspbridge/rmgr/dbdcd.c | 42 +++++++++-
> > 4 files changed, 39 insertions(+), 108 deletions(-)
> > delete mode 100644 drivers/staging/tidspbridge/gen/uuidutil.c
> >
>
> I guess the initial mail somehow didn't make it through your spam filter:
> https://lkml.org/lkml/2013/12/1/70
>
It's too early to start resending. Wait for another week at least.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-06 7:32 ` Dan Carpenter
@ 2013-12-06 7:41 ` Ivajlo Dimitrov
0 siblings, 0 replies; 14+ messages in thread
From: Ivajlo Dimitrov @ 2013-12-06 7:41 UTC (permalink / raw)
To: Dan Carpenter, Ivajlo Dimitrov
Cc: gregkh@linuxfoundation.org, devel, linux-kernel, Ivaylo Dimitrov,
pavel, pali.rohar
My other patch (the one that fixes the security issue) was already
applied, albeit it was sent after this one, see
https://git.kernel.org/cgit/linux/kernel/git/gregkh/staging.git/commit/?h=staging-linus&id=559c71fe5dc3bf2ecc55afb336145db7f0abf810
, that is why I think there is some problem with the mail itself.
Sure I will wait :)
regards,
Ivo
On 06.12.2013 09:32, Dan Carpenter wrote:
> On Fri, Dec 06, 2013 at 08:05:38AM +0200, Ivajlo Dimitrov wrote:
>> Hi Greg,
>>
>> On 01.12.2013 19:07, Ivaylo DImitrov wrote:
>>> From: Ivaylo Dimitrov <freemangordon@abv.bg>
>>>
>>> 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: Ivaylo Dimitrov <freemangordon@abv.bg>
>>> ---
>>> drivers/staging/tidspbridge/Makefile | 2 +-
>>> drivers/staging/tidspbridge/gen/uuidutil.c | 85 --------------------
>>> .../tidspbridge/include/dspbridge/uuidutil.h | 18 ----
>>> drivers/staging/tidspbridge/rmgr/dbdcd.c | 42 +++++++++-
>>> 4 files changed, 39 insertions(+), 108 deletions(-)
>>> delete mode 100644 drivers/staging/tidspbridge/gen/uuidutil.c
>>>
>> I guess the initial mail somehow didn't make it through your spam filter:
>> https://lkml.org/lkml/2013/12/1/70
>>
> It's too early to start resending. Wait for another week at least.
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-06 6:05 ` Ivajlo Dimitrov
2013-12-06 7:32 ` Dan Carpenter
@ 2013-12-06 15:10 ` gregkh
2013-12-07 8:41 ` Ivajlo Dimitrov
1 sibling, 1 reply; 14+ messages in thread
From: gregkh @ 2013-12-06 15:10 UTC (permalink / raw)
To: Ivajlo Dimitrov; +Cc: devel, linux-kernel, Ivaylo Dimitrov, pavel, pali.rohar
On Fri, Dec 06, 2013 at 08:05:38AM +0200, Ivajlo Dimitrov wrote:
> Hi Greg,
>
> On 01.12.2013 19:07, Ivaylo DImitrov wrote:
> > From: Ivaylo Dimitrov <freemangordon@abv.bg>
> >
> > 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: Ivaylo Dimitrov <freemangordon@abv.bg>
> > ---
> > drivers/staging/tidspbridge/Makefile | 2 +-
> > drivers/staging/tidspbridge/gen/uuidutil.c | 85 --------------------
> > .../tidspbridge/include/dspbridge/uuidutil.h | 18 ----
> > drivers/staging/tidspbridge/rmgr/dbdcd.c | 42 +++++++++-
> > 4 files changed, 39 insertions(+), 108 deletions(-)
> > delete mode 100644 drivers/staging/tidspbridge/gen/uuidutil.c
> >
>
> I guess the initial mail somehow didn't make it through your spam filter:
> https://lkml.org/lkml/2013/12/1/70
It did, but I thought that people asked for it to be changed in the
thread afterwards, so I was expecting an updated version from you.
Care to fix things up and resend it?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-06 15:10 ` gregkh
@ 2013-12-07 8:41 ` Ivajlo Dimitrov
2013-12-08 7:18 ` gregkh
0 siblings, 1 reply; 14+ messages in thread
From: Ivajlo Dimitrov @ 2013-12-07 8:41 UTC (permalink / raw)
To: gregkh@linuxfoundation.org
Cc: devel, linux-kernel, Ivaylo Dimitrov, pavel, pali.rohar,
Joe Perches
On 06.12.2013 17:10, gregkh@linuxfoundation.org wrote:
> On Fri, Dec 06, 2013 at 08:05:38AM +0200, Ivajlo Dimitrov wrote:
>> Hi Greg,
>>
>> On 01.12.2013 19:07, Ivaylo DImitrov wrote:
>>> From: Ivaylo Dimitrov <freemangordon@abv.bg>
>>>
>>> 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: Ivaylo Dimitrov <freemangordon@abv.bg>
>>> ---
>>> drivers/staging/tidspbridge/Makefile | 2 +-
>>> drivers/staging/tidspbridge/gen/uuidutil.c | 85 --------------------
>>> .../tidspbridge/include/dspbridge/uuidutil.h | 18 ----
>>> drivers/staging/tidspbridge/rmgr/dbdcd.c | 42 +++++++++-
>>> 4 files changed, 39 insertions(+), 108 deletions(-)
>>> delete mode 100644 drivers/staging/tidspbridge/gen/uuidutil.c
>>>
>> I guess the initial mail somehow didn't make it through your spam filter:
>> https://lkml.org/lkml/2013/12/1/70
> It did, but I thought that people asked for it to be changed in the
> thread afterwards, so I was expecting an updated version from you.
>
> Care to fix things up and resend it?
>
> thanks,
>
> greg k-h
Sure, the change I was asked for is trivial, but I didn't get the reason
why it is needed. Neither there is a reply to my follow-up comment [0].
Sorry, I am pretty much new on LKML and could miss things that are
supposed to be clear from the start, but my impression is that when
someone says "it is better", he/she should explain why it is better or
at least what is wrong with the patch he/she wants to be changed.
However, I don't want to enter some arguing loop, so if you think I
should change the code as per Joe's comment, just confirm it and I'll do it.
Thanks,
Ivo
[0] https://lkml.org/lkml/2013/12/1/113
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-07 8:41 ` Ivajlo Dimitrov
@ 2013-12-08 7:18 ` gregkh
2013-12-08 12:32 ` Pavel Machek
2013-12-09 10:13 ` [PATCH v2] " Ivaylo DImitrov
0 siblings, 2 replies; 14+ messages in thread
From: gregkh @ 2013-12-08 7:18 UTC (permalink / raw)
To: Ivajlo Dimitrov
Cc: devel, linux-kernel, Ivaylo Dimitrov, pavel, pali.rohar,
Joe Perches
On Sat, Dec 07, 2013 at 10:41:36AM +0200, Ivajlo Dimitrov wrote:
>
> On 06.12.2013 17:10, gregkh@linuxfoundation.org wrote:
> > On Fri, Dec 06, 2013 at 08:05:38AM +0200, Ivajlo Dimitrov wrote:
> >> Hi Greg,
> >>
> >> On 01.12.2013 19:07, Ivaylo DImitrov wrote:
> >>> From: Ivaylo Dimitrov <freemangordon@abv.bg>
> >>>
> >>> 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: Ivaylo Dimitrov <freemangordon@abv.bg>
> >>> ---
> >>> drivers/staging/tidspbridge/Makefile | 2 +-
> >>> drivers/staging/tidspbridge/gen/uuidutil.c | 85 --------------------
> >>> .../tidspbridge/include/dspbridge/uuidutil.h | 18 ----
> >>> drivers/staging/tidspbridge/rmgr/dbdcd.c | 42 +++++++++-
> >>> 4 files changed, 39 insertions(+), 108 deletions(-)
> >>> delete mode 100644 drivers/staging/tidspbridge/gen/uuidutil.c
> >>>
> >> I guess the initial mail somehow didn't make it through your spam filter:
> >> https://lkml.org/lkml/2013/12/1/70
> > It did, but I thought that people asked for it to be changed in the
> > thread afterwards, so I was expecting an updated version from you.
> >
> > Care to fix things up and resend it?
> >
> > thanks,
> >
> > greg k-h
>
> Sure, the change I was asked for is trivial, but I didn't get the reason
> why it is needed. Neither there is a reply to my follow-up comment [0].
> Sorry, I am pretty much new on LKML and could miss things that are
> supposed to be clear from the start, but my impression is that when
> someone says "it is better", he/she should explain why it is better or
> at least what is wrong with the patch he/she wants to be changed.
>
> However, I don't want to enter some arguing loop, so if you think I
> should change the code as per Joe's comment, just confirm it and I'll do it.
Please try.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-08 7:18 ` gregkh
@ 2013-12-08 12:32 ` Pavel Machek
2013-12-09 10:13 ` [PATCH v2] " Ivaylo DImitrov
1 sibling, 0 replies; 14+ messages in thread
From: Pavel Machek @ 2013-12-08 12:32 UTC (permalink / raw)
To: gregkh@linuxfoundation.org
Cc: Ivajlo Dimitrov, devel, linux-kernel, Ivaylo Dimitrov, pali.rohar,
Joe Perches
Hi!
> > >> I guess the initial mail somehow didn't make it through your spam filter:
> > >> https://lkml.org/lkml/2013/12/1/70
> > > It did, but I thought that people asked for it to be changed in the
> > > thread afterwards, so I was expecting an updated version from you.
> > >
> > > Care to fix things up and resend it?
> > >
> > > thanks,
> > >
> > > greg k-h
> >
> > Sure, the change I was asked for is trivial, but I didn't get the reason
> > why it is needed. Neither there is a reply to my follow-up comment [0].
> > Sorry, I am pretty much new on LKML and could miss things that are
> > supposed to be clear from the start, but my impression is that when
> > someone says "it is better", he/she should explain why it is better or
> > at least what is wrong with the patch he/she wants to be changed.
> >
> > However, I don't want to enter some arguing loop, so if you think I
> > should change the code as per Joe's comment, just confirm it and I'll do it.
>
> Please try.
Not checking sscanf() return is un-nice, so yes, it would be nice to
fix it, even if it will not happen in practice. 0 / -EINVAL is
acceptable return value.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-08 7:18 ` gregkh
2013-12-08 12:32 ` Pavel Machek
@ 2013-12-09 10:13 ` Ivaylo DImitrov
2013-12-09 14:40 ` Pavel Machek
2013-12-09 18:34 ` Joe Perches
1 sibling, 2 replies; 14+ messages in thread
From: Ivaylo DImitrov @ 2013-12-09 10:13 UTC (permalink / raw)
To: gregkh
Cc: joe, omar.ramirez, pali.rohar, pavel, linux-kernel, devel,
Ivaylo Dimitrov
From: Ivaylo Dimitrov <freemangordon@abv.bg>
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: Ivaylo Dimitrov <freemangordon@abv.bg>
---
drivers/staging/tidspbridge/Makefile | 2 +-
drivers/staging/tidspbridge/gen/uuidutil.c | 85 --------------------
.../tidspbridge/include/dspbridge/uuidutil.h | 18 ----
drivers/staging/tidspbridge/rmgr/dbdcd.c | 49 ++++++++++-
4 files changed, 46 insertions(+), 108 deletions(-)
delete mode 100644 drivers/staging/tidspbridge/gen/uuidutil.c
diff --git a/drivers/staging/tidspbridge/Makefile b/drivers/staging/tidspbridge/Makefile
index 230e3e6..2e77734 100644
--- a/drivers/staging/tidspbridge/Makefile
+++ b/drivers/staging/tidspbridge/Makefile
@@ -1,6 +1,6 @@
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
diff --git a/drivers/staging/tidspbridge/gen/uuidutil.c b/drivers/staging/tidspbridge/gen/uuidutil.c
deleted file mode 100644
index b7d8313..0000000
--- a/drivers/staging/tidspbridge/gen/uuidutil.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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;
- }
-}
diff --git a/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h b/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h
index 414bf71..b4951a1 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h
@@ -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_ */
diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c
index 3d2a26f..11b13af 100644
--- a/drivers/staging/tidspbridge/rmgr/dbdcd.c
+++ b/drivers/staging/tidspbridge/rmgr/dbdcd.c
@@ -74,6 +74,47 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
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:
* Parses the supplied image and resigsters with DCD.
@@ -253,7 +294,7 @@ 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);
+ dcd_uuid_from_string(sz_value, &dsp_uuid_obj);
*uuid_obj = dsp_uuid_obj;
@@ -581,7 +622,7 @@ 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);
+ dcd_uuid_from_string(token, &dsp_uuid_obj);
/* Retrieve object type */
token = strsep(&psz_cur, seps);
@@ -1001,7 +1042,7 @@ 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,
+ dcd_uuid_from_string(token,
&gen_obj->obj_data.node_obj.ndb_props.
ui_node_id);
token = strsep(&psz_cur, seps);
@@ -1400,7 +1441,7 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
break;
} else {
/* Retrieve UUID string. */
- uuid_uuid_from_string(token,
+ dcd_uuid_from_string(token,
&(dep_lib_uuids
[dep_libs]));
/* Is this library persistent? */
--
1.5.6.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH v2] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-09 10:13 ` [PATCH v2] " Ivaylo DImitrov
@ 2013-12-09 14:40 ` Pavel Machek
2013-12-09 18:34 ` Joe Perches
1 sibling, 0 replies; 14+ messages in thread
From: Pavel Machek @ 2013-12-09 14:40 UTC (permalink / raw)
To: Ivaylo DImitrov
Cc: gregkh, joe, omar.ramirez, pali.rohar, linux-kernel, devel,
Ivaylo Dimitrov
On Mon 2013-12-09 12:13:16, Ivaylo DImitrov wrote:
> From: Ivaylo Dimitrov <freemangordon@abv.bg>
>
> 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: Ivaylo Dimitrov <freemangordon@abv.bg>
Reviewed-by: Pavel Machek <pavel@ucw.cz>
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-09 10:13 ` [PATCH v2] " Ivaylo DImitrov
2013-12-09 14:40 ` Pavel Machek
@ 2013-12-09 18:34 ` Joe Perches
2013-12-10 22:03 ` [PATCH v3] " Ivaylo DImitrov
1 sibling, 1 reply; 14+ messages in thread
From: Joe Perches @ 2013-12-09 18:34 UTC (permalink / raw)
To: Ivaylo DImitrov
Cc: gregkh, omar.ramirez, pali.rohar, pavel, linux-kernel, devel,
Ivaylo Dimitrov
On Mon, 2013-12-09 at 12:13 +0200, Ivaylo DImitrov wrote:
> From: Ivaylo Dimitrov <freemangordon@abv.bg>
>
> 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.
Hi Ivaylo.
Trivial notes:
The function name change in dbcdc.c from
uuid_uuid_from_string to dcd_uuid_from_string
seems unnecessary.
If you are going to change the name, please
also reindent the multi-line statements to the
open parenthesis as the rest of the file has
that style.
> diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c
[]
> @@ -1001,7 +1042,7 @@ 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,
> + dcd_uuid_from_string(token,
> &gen_obj->obj_data.node_obj.ndb_props.
> ui_node_id);
> token = strsep(&psz_cur, seps);
The 2nd and 3rd lines of dcd_uuid_from_string
should be moved 1 left.
> @@ -1400,7 +1441,7 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
> break;
> } else {
> /* Retrieve UUID string. */
> - uuid_uuid_from_string(token,
> + dcd_uuid_from_string(token,
> &(dep_lib_uuids
> [dep_libs]));
> /* Is this library persistent? */
here too.
It also appears as if these could set status
to the from_string return value and error-out
when non-zero.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3] Staging: TIDSPBRIDGE: Remove UUID helper
2013-12-09 18:34 ` Joe Perches
@ 2013-12-10 22:03 ` Ivaylo DImitrov
0 siblings, 0 replies; 14+ messages in thread
From: Ivaylo DImitrov @ 2013-12-10 22:03 UTC (permalink / raw)
To: gregkh
Cc: joe, omar.ramirez, pali.rohar, pavel, linux-kernel, devel,
Ivaylo Dimitrov
From: Ivaylo Dimitrov <freemangordon@abv.bg>
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: Ivaylo Dimitrov <freemangordon@abv.bg>
---
drivers/staging/tidspbridge/Makefile | 2 +-
drivers/staging/tidspbridge/gen/uuidutil.c | 85 ---------------
.../tidspbridge/include/dspbridge/uuidutil.h | 18 ----
drivers/staging/tidspbridge/rmgr/dbdcd.c | 108 +++++++++++++++-----
4 files changed, 81 insertions(+), 132 deletions(-)
delete mode 100644 drivers/staging/tidspbridge/gen/uuidutil.c
diff --git a/drivers/staging/tidspbridge/Makefile b/drivers/staging/tidspbridge/Makefile
index 230e3e6..2e77734 100644
--- a/drivers/staging/tidspbridge/Makefile
+++ b/drivers/staging/tidspbridge/Makefile
@@ -1,6 +1,6 @@
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
diff --git a/drivers/staging/tidspbridge/gen/uuidutil.c b/drivers/staging/tidspbridge/gen/uuidutil.c
deleted file mode 100644
index b7d8313..0000000
--- a/drivers/staging/tidspbridge/gen/uuidutil.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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;
- }
-}
diff --git a/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h b/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h
index 414bf71..b4951a1 100644
--- a/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h
+++ b/drivers/staging/tidspbridge/include/dspbridge/uuidutil.h
@@ -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_ */
diff --git a/drivers/staging/tidspbridge/rmgr/dbdcd.c b/drivers/staging/tidspbridge/rmgr/dbdcd.c
index 3d2a26f..190ca3f 100644
--- a/drivers/staging/tidspbridge/rmgr/dbdcd.c
+++ b/drivers/staging/tidspbridge/rmgr/dbdcd.c
@@ -74,6 +74,47 @@ static int get_dep_lib_info(struct dcd_manager *hdcd_mgr,
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:
* Parses the supplied image and resigsters with DCD.
@@ -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);
--
1.5.6.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2013-12-10 22:05 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-01 17:07 [PATCH] Staging: TIDSPBRIDGE: Remove UUID helper Ivaylo DImitrov
2013-12-01 19:06 ` Joe Perches
2013-12-01 23:26 ` Ivajlo Dimitrov
2013-12-06 6:05 ` Ivajlo Dimitrov
2013-12-06 7:32 ` Dan Carpenter
2013-12-06 7:41 ` Ivajlo Dimitrov
2013-12-06 15:10 ` gregkh
2013-12-07 8:41 ` Ivajlo Dimitrov
2013-12-08 7:18 ` gregkh
2013-12-08 12:32 ` Pavel Machek
2013-12-09 10:13 ` [PATCH v2] " Ivaylo DImitrov
2013-12-09 14:40 ` Pavel Machek
2013-12-09 18:34 ` Joe Perches
2013-12-10 22:03 ` [PATCH v3] " Ivaylo DImitrov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox