Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: tidspbridge: fix uuid strings

Commit 8cb05f4b54535cb91d7a5f9f8eb230bd4fa86e4e (staging:
tidspbridge: eliminate uuid_uuid_to_string), not only broke
compilation but also functionality for tidspbridge driver.

So:
- Replace remaining instances of uuid_uuid_to_string with snprintf
to fix compilation.
- Fix the format from %pU to %pUL.
- Since these UUIDs are used in the firmware to reference section
names, the firmware doesn't follow the standard uuid delimiter '-'
it uses '_' instead. The driver can follow the standard convention
however for dsp sections we must transform the uuid to what is
expected by the firmware. E.g.:

tidspbridge sees: 24BC8D90-BB45-11D4-B756-006008BDB66F
firmware expects: .24BC8D90_BB45_11D4_B756_006008BDB66F

Signed-off-by: Omar Ramirez Luna <omar.ramirez@copitl.com>
CC: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Omar Ramirez Luna and committed by
Greg Kroah-Hartman
424d56ec 1021bb5c

+23 -7
+22 -5
drivers/staging/tidspbridge/rmgr/dbdcd.c
··· 346 346 struct dcd_manager *dcd_mgr_obj = hdcd_mgr; /* ptr to DCD mgr */ 347 347 struct cod_libraryobj *lib = NULL; 348 348 int status = 0; 349 + int len; 349 350 u32 ul_addr = 0; /* Used by cod_get_section */ 350 351 u32 ul_len = 0; /* Used by cod_get_section */ 351 352 u32 dw_buf_size; /* Used by REG functions */ 352 353 char sz_reg_key[DCD_MAXPATHLENGTH]; 353 354 char *sz_uuid; /*[MAXUUIDLEN]; */ 355 + char *tmp; 354 356 struct dcd_key_elem *dcd_key = NULL; 355 357 char sz_sect_name[MAXUUIDLEN + 2]; /* ".[UUID]\0" */ 356 358 char *psz_coff_buf; ··· 397 395 } 398 396 399 397 /* Create UUID value to set in registry. */ 400 - snprintf(sz_uuid, MAXUUIDLEN, "%pU", obj_uuid); 398 + snprintf(sz_uuid, MAXUUIDLEN, "%pUL", obj_uuid); 401 399 402 400 if ((strlen(sz_reg_key) + MAXUUIDLEN) < DCD_MAXPATHLENGTH) 403 401 strncat(sz_reg_key, sz_uuid, MAXUUIDLEN); ··· 431 429 } 432 430 433 431 /* Ensure sz_uuid + 1 is not greater than sizeof sz_sect_name. */ 432 + len = strlen(sz_uuid); 433 + if (len + 1 > sizeof(sz_sect_name)) { 434 + status = -EPERM; 435 + goto func_end; 436 + } 434 437 435 438 /* Create section name based on node UUID. A period is 436 439 * pre-pended to the UUID string to form the section name. 437 440 * I.e. ".24BC8D90_BB45_11d4_B756_006008BDB66F" */ 441 + 442 + len -= 4; /* uuid has 4 delimiters '-' */ 443 + tmp = sz_uuid; 444 + 438 445 strncpy(sz_sect_name, ".", 2); 439 - strncat(sz_sect_name, sz_uuid, strlen(sz_uuid)); 446 + do { 447 + char *uuid = strsep(&tmp, "-"); 448 + if (!uuid) 449 + break; 450 + len -= strlen(uuid); 451 + strncat(sz_sect_name, uuid, strlen(uuid) + 1); 452 + } while (len && strncat(sz_sect_name, "_", 2)); 440 453 441 454 /* Get section information. */ 442 455 status = cod_get_section(lib, sz_sect_name, &ul_addr, &ul_len); ··· 683 666 status = -EPERM; 684 667 } 685 668 /* Create UUID value to find match in registry. */ 686 - uuid_uuid_to_string(uuid_obj, sz_uuid, MAXUUIDLEN); 669 + snprintf(sz_uuid, MAXUUIDLEN, "%pUL", uuid_obj); 687 670 if ((strlen(sz_reg_key) + MAXUUIDLEN) < DCD_MAXPATHLENGTH) 688 671 strncat(sz_reg_key, sz_uuid, MAXUUIDLEN); 689 672 else ··· 723 706 } else { 724 707 status = -EPERM; 725 708 } 726 - uuid_uuid_to_string(uuid_obj, sz_uuid, MAXUUIDLEN); 709 + snprintf(sz_uuid, MAXUUIDLEN, "%pUL", uuid_obj); 727 710 if ((strlen(sz_reg_key) + MAXUUIDLEN) < DCD_MAXPATHLENGTH) 728 711 strncat(sz_reg_key, sz_uuid, MAXUUIDLEN); 729 712 else ··· 814 797 status = -EPERM; 815 798 816 799 /* Create UUID value to set in registry. */ 817 - uuid_uuid_to_string(uuid_obj, sz_uuid, MAXUUIDLEN); 800 + snprintf(sz_uuid, MAXUUIDLEN, "%pUL", uuid_obj); 818 801 if ((strlen(sz_reg_key) + MAXUUIDLEN) < DCD_MAXPATHLENGTH) 819 802 strncat(sz_reg_key, sz_uuid, MAXUUIDLEN); 820 803 else
+1 -2
drivers/staging/tidspbridge/rmgr/node.c
··· 2714 2714 hnode->ntype = node_type = pndb_props->ntype; 2715 2715 2716 2716 /* Create UUID value to set in registry. */ 2717 - uuid_uuid_to_string((struct dsp_uuid *)node_uuid, sz_uuid, 2718 - MAXUUIDLEN); 2717 + snprintf(sz_uuid, MAXUUIDLEN, "%pUL", node_uuid); 2719 2718 dev_dbg(bridge, "(node) UUID: %s\n", sz_uuid); 2720 2719 2721 2720 /* Fill in message args that come from NDB */