static int __parse_device_str(const char *buf, size_t size, u32 *twi_id, u32 *dev_addr) { char *ptr = (char *)buf; if(NULL == strchr(ptr, ',')) { return -EINVAL; } ptr = __first_str_to_u32(ptr, ',', twi_id); if(NULL == ptr) return -EINVAL; ptr += 1; if(strict_strtoul(ptr, 16, (long unsigned int *)dev_addr)) return -EINVAL; return 0; }
/** * __parse_dump_str - parse the input string for dump attri. * @buf: the input string, eg: "0x01c20000,0x01c20300". * @size: buf size. * @start: store the start reg's addr parsed from buf, eg 0x01c20000. * @end: store the end reg's addr parsed from buf, eg 0x01c20300. * * return 0 if success, otherwise failed. */ int __parse_dump_str(const char *buf, size_t size, u32 *start, u32 *end) { char *ptr = (char *)buf; if(NULL == strchr(ptr, ',')) { /* only one reg to dump */ if(strict_strtoul(ptr, 16, (long unsigned int *)start)) return -EINVAL; *end = *start; return 0; } ptr = __first_str_to_u32(ptr, ',', start); if(NULL == ptr) return -EINVAL; ptr += 1; if(strict_strtoul(ptr, 16, (long unsigned int *)end)) return -EINVAL; return 0; }