*/
+#include <ctype.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
static int pass_parse_resource_data(struct parse_result *result,
void *user_data, int id)
{
+ char buf[BUFF_MAX];
struct pass *pass = user_data;
struct pass_conf_data *conf_data = &(pass->res[id].cdata);
return 0;
if (MATCH(result->name, "pass_res_type")) {
- conf_data->res_type = atoi(result->value);
+ int i;
+
+ memset(buf, 0, BUFF_MAX);
+ for (i = 0; i < strlen(result->value); i++)
+ buf[i] = tolower(result->value[i]);
+
+ if (!strncmp(buf, PASS_RESOURCE_CPU_NAME, strlen(buf)))
+ conf_data->res_type = PASS_RESOURCE_CPU_ID;
+ else if (!strncmp(buf, PASS_RESOURCE_GPU_NAME, strlen(buf)))
+ conf_data->res_type = PASS_RESOURCE_GPU_ID;
+ else if (!strncmp(buf, PASS_RESOURCE_BUS_NAME, strlen(buf)))
+ conf_data->res_type = PASS_RESOURCE_BUS_ID;
+ else
+ return -EINVAL;
} else if (MATCH(result->name, "pass_res_name")) {
int len = strlen(result->value);
snprintf(conf_data->res_name, len + 1, "%s", result->value);