On Wed, Jun 23, 2010 at 4:02 PM, Ohad Ben-Cohen <o...@wizery.com> wrote:
> Add TI's DSP Bridge generic utilities driver sources
> Signed-off-by: Andy Shevchenko <ext-andriy.shevche...@nokia.com>


> +++ b/drivers/staging/tidspbridge/gen/uuidutil.c

Following part could be significantly simplified

> +/*
> + *  ======== htoi ========
> + *  Purpose:
> + *      Converts a hex value to a decimal integer.
> + */

> +/*
> + *  ======== uuid_uuid_from_string ========
> + *  Purpose:
> + *      Converts a string to a struct dsp_uuid.
> + */


There is a code (because I am already in s-o-b list I just put here
the excerpts, however, I could prepare patch in standard form, if you
want to)

static s32 uuid_hex_to_bin(char *buf, s32 len)
{
        s32 i;
        s32 result = 0;

        for (i = 0; i < len; i++) {
                value = hex_to_bin(*buf++);
                result *= 16;
                if (value > 0)
                        result += value;
        }

        return result;
}

void uuid_uuid_from_string(IN char *pszUuid, OUT struct dsp_uuid *uuid_obj)
{
        s32 j;

        uuid_obj->ul_data1 = uuid_hex_to_bin(pszUuid, 8);
        pszUuid += 8;

        /* Step over underscore */
        pszUuid++;

        uuid_obj->us_data2 = (u16) uuid_hex_to_bin(pszUuid, 4);
        pszUuid += 4;

        /* Step over underscore */
        pszUuid++;

        uuid_obj->us_data3 = (u16) uuid_hex_to_bin(pszUuid, 4);
        pszUuid += 4;

        /* Step over underscore */
        pszUuid++;

        uuid_obj->uc_data4 = (u8) uuid_hex_to_bin(pszUuid, 2);
        pszUuid += 2;

        uuid_obj->uc_data5 = (u8) uuid_hex_to_bin(pszUuid, 2);
        pszUuid += 2;

        /* Step over underscore */
        pszUuid++;

        for (j = 0; j < 6; j++) {
                uuid_obj->uc_data6[j] = (u8) uuid_hex_to_bin(pszUuid, 2);
                pszUuid += 2;
        }
}



-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to