*/
static int thermal_parse_scenario(json_object *obj, struct scenario *scenario)
{
- const char *name;
+ char name[BUFF_MAX] = {};
int support;
+ int ret = 0;
/* Get property values */
- name = get_string_from_object(obj, "name");
- support = get_boolean_from_object(obj, "support");
-
- /* Check the mandatory property values are valid or not */
- if (!name) {
- _E("Failed to get 'name' property of scenario section\n");
+ ret += get_property(obj, "name", DATA_TYPE_STRING, true,
+ (void *)name);
+ ret += get_property(obj, "support", DATA_TYPE_BOOLEAN, false,
+ (void *)&support);
+
+ /* Check whether the mandatory properties are included or not */
+ if (ret < 0) {
+ _E("Failed to get the mandatory properties in thermal scenario\n");
return -EINVAL;
}
{
int thermal_support;
json_object *thermal_scenario_list = NULL;
- int num_scenarios = 0, ret, i;
+ int num_scenarios = 0, ret = 0, i;
/* Get property values */
- thermal_support = get_boolean_from_object(obj, "thermal_support");
+ ret = get_property(obj, "thermal_support", DATA_TYPE_BOOLEAN, false,
+ (void *)&thermal_support);
if (json_object_object_get_ex(obj, "thermal_scenario_list",
&thermal_scenario_list))
num_scenarios = json_object_array_length(thermal_scenario_list);
- /* Check the mandatory property values are valid or not */
+ /* Check whether the mandatory properties are included or not */
+ if (ret < 0) {
+ _E("Failed to get the mandatory properties in thermal config\n");
+ return -EINVAL;
+ }
+
+ /* Check the validation of property value */
if (thermal_support <= 0 || num_scenarios <= 0) {
_I("Disable thermal module\n");
return 0;