blob: 199d3ea072fde382e46681ee1cc8dee3479cd95d [file] [log] [blame]
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/string.h>
#include <linux/types.h>
#include <linux/slab.h>
#include "cam_common_util.h"
#include "cam_debug_util.h"
int cam_common_util_get_string_index(const char **strings,
uint32_t num_strings, char *matching_string, uint32_t *index)
{
int i;
for (i = 0; i < num_strings; i++) {
if (strnstr(strings[i], matching_string, strlen(strings[i]))) {
CAM_DBG(CAM_UTIL, "matched %s : %d\n",
matching_string, i);
*index = i;
return 0;
}
}
return -EINVAL;
}