Ejemplo n.º 1
0
static void process(void)
{
    int val;
    switch(touch_state)
    {
    case TOUCH_STATE_WAIT:
        /* a touch has happened, check if it's still valid */
        if(imx233_lradc_read_touch_detect())
            enter_state(TOUCH_STATE_MEASURE_X);
        else
        {
            old_touch_detect = false;
            /* clear detect interrupt */
            imx233_lradc_clear_touch_detect_irq();
        }
        break;
    case TOUCH_STATE_MEASURE_X:
        /* read value */
        val = imx233_lradc_read_channel(touch_chan);
        /* if value is too far from average, restart */
        if(nr_samples > 0 && abs(val - touch_x) > DEBOUNCE_THRESHOLD)
            nr_samples = 0;
        touch_x = (touch_x * nr_samples + val) / (nr_samples + 1);
        nr_samples++;
        /* if we have enough samples, measure Y */
        if(nr_samples > SAMPLES_THRESHOLD)
            enter_state(TOUCH_STATE_MEASURE_Y);
        else
            imx233_lradc_kick_delay(touch_delay);
        break;
    case TOUCH_STATE_MEASURE_Y:
        /* read value */
        val = imx233_lradc_read_channel(touch_chan);
        /* if value is too far from average, restart */
        if(nr_samples > 0 && abs(val - touch_y) > DEBOUNCE_THRESHOLD)
            nr_samples = 0;
        touch_y = (touch_y * nr_samples + val) / (nr_samples + 1);
        nr_samples++;
        /* if we have enough samples, verify touch */
        if(nr_samples > SAMPLES_THRESHOLD)
            enter_state(TOUCH_STATE_VERIFY);
        else
            imx233_lradc_kick_delay(touch_delay);
        break;
    case TOUCH_STATE_VERIFY:
        if(imx233_lradc_read_touch_detect())
        {
            old_touch_detect = true;
            old_touch_x = touch_x;
            old_touch_y = touch_y;
            enter_state(TOUCH_STATE_MEASURE_X);
        }
        else
        {
            old_touch_detect = false;
            enter_state(TOUCH_STATE_WAIT);
        }
        break;
    }
}
Ejemplo n.º 2
0
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
			   const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
#ifdef CONFIG_EARLYSUSPEND
	suspend_state_t state = PM_SUSPEND_ON;
#else
	suspend_state_t state = PM_SUSPEND_STANDBY;
#endif
	const char * const *s;
#endif
	char *p;
	int len;
	int error = -EINVAL;

	p = memchr(buf, '\n', n);
	len = p ? p - buf : n;

	/* First, check if we are requested to hibernate */
	if (len == 4 && !strncmp(buf, "disk", len)) {
		error = hibernate();
  goto Exit;
	}
#if defined(CONFIG_MP_MSTAR_STR_BASE)
    // for mstar str, we skip wakelock
    // and earlysuspend/lateresume to speedup suspend
    if (len == 4 && !strncmp(buf, "mstr", len)) {
        state = PM_SUSPEND_MEM;
        pm_is_mstar_str = 1;
        error = enter_state(state);
        pm_is_mstar_str = 0;
        goto Exit;
    }
#endif

#ifdef CONFIG_SUSPEND
	for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
		if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
			break;
	}
	if (state < PM_SUSPEND_MAX && *s)
#ifdef CONFIG_EARLYSUSPEND
		if (state == PM_SUSPEND_ON || valid_state(state)) {
			error = 0;
			request_suspend_state(state);
		}
#else
		error = enter_state(state);
#endif
#endif

 Exit:
	return error ? error : n;
}
Ejemplo n.º 3
0
static void path(parser_context *context)
{
    enter_state(context, ST_START);
    skip_ws(context);

    absolute_path(context);

    if(ERR_UNEXPECTED_VALUE == context->result.code && '$' == context->result.expected_char)
    {
        enter_state(context, ST_START);
        context->current_step_kind = SINGLE;
        relative_path(context);
    }
}
Ejemplo n.º 4
0
void imx233_touchscreen_enable(bool enable)
{
    enter_state(TOUCH_STATE_WAIT);
    imx233_lradc_set_channel_irq_callback(touch_chan, &touch_channel_irq);
    imx233_icoll_enable_interrupt(INT_SRC_LRADC_CHx(touch_chan), enable);
    imx233_icoll_enable_interrupt(INT_SRC_TOUCH_DETECT, enable);
}
Ejemplo n.º 5
0
static void step_predicate_parser(parser_context *context)
{
    enter_state(context, ST_PREDICATE);

    skip_ws(context);
    if('[' == get_char(context))
    {
        consume_char(context);
        if(!look_for(context, "]"))
        {
            context->result.code = ERR_UNBALANCED_PRED_DELIM;
            return;
        }
        skip_ws(context);
        if(']' == get_char(context))
        {
            context->result.code = ERR_EMPTY_PREDICATE;
            return;
        }

        try_predicate_parser(wildcard_predicate);
        try_predicate_parser(subscript_predicate);
        try_predicate_parser(slice_predicate);

        if(JSONPATH_SUCCESS != context->result.code && ERR_PARSER_OUT_OF_MEMORY != context->result.code)
        {
            context->result.code = ERR_UNSUPPORTED_PRED_TYPE;
        }
    }
    else
    {
        unexpected_value(context, '[');
    }
}
/**
 * pm_suspend - Externally visible function for suspending the system.
 * @state: System sleep state to enter.
 *
 * Check if the value of @state represents one of the supported states,
 * execute enter_state() and update system suspend statistics.
 */
int pm_suspend(suspend_state_t state)
{
	int error;
	int s3_state = mid_state_to_sys_state(MID_S3_STATE);

	if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
		return -EINVAL;

	/* time stamp for start of s3 entry */
	if (state == PM_SUSPEND_MEM)
		time_stamp_for_sleep_state_latency(s3_state, true, true);

	pm_suspend_marker("entry");
	error = enter_state(state);
	if (error) {
		suspend_stats.fail++;
		dpm_save_failed_errno(error);
	} else {
		suspend_stats.success++;
		/* time stamp for end of s3 exit */
		if (state == PM_SUSPEND_MEM)
			time_stamp_for_sleep_state_latency(s3_state,
							false, false);
	}
	pm_suspend_marker("exit");
	return error;
}
Ejemplo n.º 7
0
static void step_parser(parser_context *context)
{
    if(look_for(context, "()"))
    {
        node_type_test(context);
        if(JSONPATH_SUCCESS == context->result.code && has_more_input(context))
        {
            consume_char(context);
            consume_char(context);
        }
    }
    else
    {
        name_test(context);
    }

    if(JSONPATH_SUCCESS == context->result.code && has_more_input(context))
    {
        step_predicate_parser(context);
    }

    if(ERR_UNEXPECTED_VALUE == context->result.code && '[' == context->result.expected_char)
    {
        enter_state(context, ST_STEP);
        context->result.code = JSONPATH_SUCCESS;
    }
}
Ejemplo n.º 8
0
static void absolute_path(parser_context *context)
{
    enter_state(context, ST_ABSOLUTE_PATH);

    if('$' == get_char(context))
    {
        context->result.code = JSONPATH_SUCCESS;
        context->path->kind = ABSOLUTE_PATH;
        context->current_step_kind = ROOT;
        consume_char(context);

        step *root = make_root_step();
        if(NULL == root)
        {
            context->result.code = ERR_PARSER_OUT_OF_MEMORY;
            return;
        }
        if(!push_step(context, root))
        {
            return;
        }

        if(has_more_input(context))
        {
            qualified_path(context);
        }
    }
    else
    {
        unexpected_value(context, '$');
    }
}
Ejemplo n.º 9
0
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
			   const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
	suspend_state_t state = PM_SUSPEND_STANDBY;
	const char * const *s;
#endif
	char *p;
	int len;
	int error = -EINVAL;

	p = memchr(buf, '\n', n);
	len = p ? p - buf : n;

	/* First, check if we are requested to hibernate */
	if (len == 4 && !strncmp(buf, "disk", len)) {
		error = hibernate();
  goto Exit;
	}

#ifdef CONFIG_SUSPEND
	for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
		if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
			break;
	}
	if (state < PM_SUSPEND_MAX && *s)
		error = enter_state(state);
#endif

 Exit:
	return error ? error : n;
}
Ejemplo n.º 10
0
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
			   const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
#ifdef CONFIG_EARLYSUSPEND
	suspend_state_t state = PM_SUSPEND_ON;
#else
	suspend_state_t state = PM_SUSPEND_STANDBY;
#endif
	const char * const *s;
#endif
	char *p;
	int len;
	int error = -EINVAL;

	p = memchr(buf, '\n', n);
	len = p ? p - buf : n;

	/* First, check if we are requested to hibernate */
	if (len == 4 && !strncmp(buf, "disk", len)) {
		error = hibernate();
  goto Exit;
	}

#ifdef CONFIG_SUSPEND
	for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
		if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
			break;
	}
	if (state < PM_SUSPEND_MAX && *s)
#ifdef CONFIG_EARLYSUSPEND && CONFIG_HAS_WAKELOCK
		if (state == PM_SUSPEND_ON || valid_state(state)) {
			error = 0;
                request_suspend_state(state);
		}
#elif defined CONFIG_HAS_WAKELOCK
        wake_unlock(&main_wake_lock);  //Release main lock in the hope of going to sleep
        
        if (!has_wake_lock(WAKE_LOCK_SUSPEND)) {
            wake_timer.data = current;
            mod_timer(&wake_timer, jiffies + HZ * 5); //To prevent us from freezing indefinitely
            
            set_freeze_flag(current);
            try_to_freeze();
            
            del_timer(&wake_timer);
        }
      
        wake_lock(&main_wake_lock);  //Re-grab the main lock so that we do not go into sleep again
#else         
        error = enter_state(state);
#endif
#endif

 Exit:
	return error ? error : n;
}
Ejemplo n.º 11
0
static int to_state(struct state_t* state,void* input)
{
	int ret;
	do{
		ret=enter_state(state,input);
	}while( state->owner->isrunning && do_transition(state,input) < 0 );

	return exit_state(state,input);
}
Ejemplo n.º 12
0
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
			   const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
#ifdef CONFIG_EARLYSUSPEND
	suspend_state_t state = PM_SUSPEND_ON;
#else
	suspend_state_t state = PM_SUSPEND_MIN;
#endif
	const char * const *s;
#endif
	char *p;
	int len;
	int error = -EINVAL;

	p = memchr(buf, '\n', n);
	len = p ? p - buf : n;

	/* First, check if we are requested to hibernate */
	if (len == 4 && !strncmp(buf, "disk", len)) {
		error = hibernate();
  goto Exit;
	}

#ifdef CONFIG_SUSPEND
	for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
		if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
			break;
	}

#ifdef CONFIG_FAST_BOOT
	if (len == 4 && !strncmp(buf, "dmem", len)) {
		pr_info("%s: fake shut down!!!\n", __func__);
		fake_shut_down = true;
		state = PM_SUSPEND_MEM;
	}
#endif

	if (state < PM_SUSPEND_MAX && *s) {
#ifdef CONFIG_EARLYSUSPEND
		if (state == PM_SUSPEND_ON || valid_state(state)) {
			error = 0;
			request_suspend_state(state);
		}
#ifdef CONFIG_FAST_BOOT
		if (fake_shut_down)
			wakelock_force_suspend();
#endif
#else
		error = enter_state(state);
#endif
	}
#endif

 Exit:
	return error ? error : n;
}
Ejemplo n.º 13
0
void
fn_leave_tag(char **args)
{
    if (binding_state != bs_tag) {
	disp_status(DISP_STATUS, "not in <tag> mode");
	return;
    }

    enter_state(leave_tag);
}
Ejemplo n.º 14
0
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
			   const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
#ifdef CONFIG_EARLYSUSPEND
	suspend_state_t state = PM_SUSPEND_ON;
#else
	suspend_state_t state = PM_SUSPEND_STANDBY;
#endif
	const char * const *s;
#endif
	char *p;
	int len;
	int error = -EINVAL;

	p = memchr(buf, '\n', n);
	len = p ? p - buf : n;

	/* First, check if we are requested to hibernate */
	if (len == 4 && !strncmp(buf, "disk", len)) {
		do_hibernation = 1;	//B090162
		do_hibernation_codec = 1;	//B090162
      //sensor driver to early suspend
#ifdef      CONFIG_TCC_SENSOR_DRV
                tcc_sensor_early_suspend();
#endif
		error = hibernate();

#ifdef CONFIG_TCC_SENSOR_DRV
                tcc_sensor_late_resume();
#endif
  goto Exit;
	} else if (len == 5 && !strncmp(buf, "reset", len)) {
		tcc_usb_notification();
	}

#ifdef CONFIG_SUSPEND
	for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
		if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
			break;
	}
	if (state < PM_SUSPEND_MAX && *s)
#ifdef CONFIG_EARLYSUSPEND
		if (state == PM_SUSPEND_ON || valid_state(state)) {
			error = 0;
			request_suspend_state(state);
		}
#else
		error = enter_state(state);
#endif
#endif

 Exit:
	return error ? error : n;
}
Ejemplo n.º 15
0
/**
 *	pm_suspend - Externally visible function for suspending system.
 *	@state:		Enumerated value of state to enter.
 *
 *	Determine whether or not value is within range, get state
 *	structure, and enter (above).
 */
int pm_suspend(suspend_state_t state)
{
	int error;

	if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
		return -EINVAL;

	pm_suspend_marker("entry");
	error = enter_state(state);
	pm_suspend_marker("exit");

	return error;
}
Ejemplo n.º 16
0
	void DispatcherPrivate::task_main_imp(volatile PROCESS_ENTRY_STATE* process)
	{
		const PROCESS_ENTRY_DATA* pdata = process->data;
		PROCESS_ENTRY* pcb = process->process;

		TRACE(("[%s] task_main_imp(): starting\r\n", process->data->name));
		process->thread->mutex.lock();
		if (pcb->process_start != NULL)
			pcb->process_start(pcb);

		STATE_ENTRY* state = pdata->initstate;
		enter_state(process, state);
		process->state = ProcessRunning;
		process->thread->mutex.unlock();
		osSignalSet(_dispid, SIGNAL_CHANGED);

		for (;;)
		{
			//TRACE(("[%s] task_main_imp(): waiting for signal.\r\n", process->data->name));
			process->state = ProcessWaiting;
			DelayedThread::signal_wait(SIGNAL_RUN_TASKS);
			process->state = ProcessRunning;
			//TRACE(("[%s] task_main_imp(): woken up.\r\n", process->data->name));

			process->thread->mutex.lock();
			//TRACE(("DispatcherPrivate::run_tasks(): locked\r\n"));

			do
			{
				//TRACE(("[%s:%s] task_main_imp(): current state type is %i.\r\n", process->data->name, process->current->data->name, process->current->data->mode));
				TRANSITION_ENTRY* transition = find_valid_transition(process);
				if (transition != NULL)
				{
					take_transition(process, transition);
				}
				else
				{
					process->stepped = false;
					//TRACE(("[%s:%s] task_main_imp(): no transitions found.\r\n", process->data->name, process->current->data->name));
					break;
				}

			} while (process->current->data->mode == StateCommited);

			//TRACE(("DispatcherPrivate::run_tasks(): unlocking\r\n"));
			process->thread->mutex.unlock();
			osSignalSet(_dispid, SIGNAL_CHANGED);
		}

	}
Ejemplo n.º 17
0
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
			   const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
#ifdef CONFIG_EARLYSUSPEND
	suspend_state_t state = PM_SUSPEND_ON;
#else
	suspend_state_t state = PM_SUSPEND_STANDBY;
#endif
	const char * const *s;
#endif
	char *p;
	int len;
	int error = -EINVAL;

	p = memchr(buf, '\n', n);
	len = p ? p - buf : n;

	/* First, check if we are requested to hibernate */
	if (len == 4 && !strncmp(buf, "disk", len)) {
		printk(KERN_ERR "entering hibernate");
		error = hibernate();
  goto Exit;
	}

#ifdef CONFIG_SUSPEND
	for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
		if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
			break;
	}
	printk(KERN_ERR "entering sleep state = %d\n", state);

	if (state < PM_SUSPEND_MAX && *s)
	{
#ifdef CONFIG_EARLYSUSPEND
		if (state == PM_SUSPEND_ON || valid_state(state)) {
			error = 0;
			request_suspend_state(state);
		} else {
			printk(KERN_ERR "not valid state with state = %d", state);
		}
#else
		error = enter_state(state);
#endif
	}
#endif

 Exit:
	return error ? error : n;
}
Ejemplo n.º 18
0
/**
 *	pm_suspend - Externally visible function for suspending system.
 *	@state:		Enumerated value of state to enter.
 *
 *	Determine whether or not value is within range, get state
 *	structure, and enter (above).
 */
int pm_suspend(suspend_state_t state)
{
	int ret;
	if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX) {
		ret = enter_state(state);
		if (ret) {
			suspend_stats.fail++;
			dpm_save_failed_errno(ret);
		} else
			suspend_stats.success++;
		return ret;
	}
	return -EINVAL;
}
Ejemplo n.º 19
0
static ssize_t state_store(struct kobject *kobj, struct kobj_attribute *attr,
			   const char *buf, size_t n)
{
#ifdef CONFIG_SUSPEND
#ifdef CONFIG_EARLYSUSPEND
	suspend_state_t state = PM_SUSPEND_ON;
#else
	suspend_state_t state = PM_SUSPEND_STANDBY;
#endif
	const char * const *s;
#endif
	char *p;
	int len;
	int error = -EINVAL;

	p = memchr(buf, '\n', n);
	len = p ? p - buf : n;

	/* First, check if we are requested to hibernate */
	if (len == 4 && !strncmp(buf, "disk", len)) {
		error = hibernate();
  goto Exit;
	}

#ifdef CONFIG_SUSPEND
	for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
		if (*s && len == strlen(*s) && !strncmp(buf, *s, len))
			break;
	}
	if (state < PM_SUSPEND_MAX && *s) {
#ifdef CONFIG_EARLYSUSPEND
		if (state == PM_SUSPEND_ON || valid_state(state)) {
			error = 0;
			request_suspend_state(state);
		}
#else
		error = enter_state(state);
		if (error) {
			suspend_stats.fail++;
			dpm_save_failed_errno(error);
		} else
			suspend_stats.success++;
#endif
	}
#endif

 Exit:
	return error ? error : n;
}
Ejemplo n.º 20
0
static void wildcard_name(parser_context *context)
{
    enter_state(context, ST_WILDCARD_NAME_TEST);

    step *current = make_step(context->current_step_kind, WILDCARD_TEST);
    if(NULL == current)
    {
        context->result.code = ERR_PARSER_OUT_OF_MEMORY;
        return;
    }
    push_step(context, current);

    consume_char(context);
    context->result.code = JSONPATH_SUCCESS;
}
Ejemplo n.º 21
0
/**
 * pm_suspend - Externally visible function for suspending the system.
 * @state: System sleep state to enter.
 *
 * Check if the value of @state represents one of the supported states,
 * execute enter_state() and update system suspend statistics.
 */
int pm_suspend(suspend_state_t state)
{
	int error;

	if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
		return -EINVAL;

	error = enter_state(state);
	if (error) {
		suspend_stats.fail++;
		dpm_save_failed_errno(error);
	} else {
		suspend_stats.success++;
	}
	return error;
}
Ejemplo n.º 22
0
/**
 *	pm_suspend - Externally visible function for suspending system.
 *	@state:		Enumerated value of state to enter.
 *
 *	Determine whether or not value is within range, get state
 *	structure, and enter (above).
 */
int pm_suspend(suspend_state_t state)
{
//LGE_CHANGE_S, [[email protected]] , 2012-04-10, SuspendEarlySuspend debugfs
    int ret;
    if (state > PM_SUSPEND_ON && state < PM_SUSPEND_MAX) {
        ret = enter_state(state);
        if (ret) {
            suspend_stats.fail++;
            dpm_save_failed_errno(ret);
        } else
            suspend_stats.success++;
        return ret;
    }
//LGE_CHANGE_E, [[email protected]] , 2012-04-10, SuspendEarlySuspend debugfs
    return -EINVAL;
}
Ejemplo n.º 23
0
static void wildcard_predicate(parser_context *context)
{
    enter_state(context, ST_WILDCARD_PREDICATE);

    skip_ws(context);
    if('*' == get_char(context))
    {
        context->result.code = JSONPATH_SUCCESS;
        consume_char(context);
        add_predicate(context, WILDCARD);
    }
    else
    {
        unexpected_value(context, '*');
    }
}
Ejemplo n.º 24
0
/**
 * pm_suspend - Externally visible function for suspending the system.
 * @state: System sleep state to enter.
 *
 * Check if the value of @state represents one of the supported states,
 * execute enter_state() and update system suspend statistics.
 */
int pm_suspend(suspend_state_t state)
{
	int error;

	if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
		return -EINVAL;

	pr_info("suspend entry (%s)\n", mem_sleep_labels[state]);
	error = enter_state(state);
	if (error) {
		suspend_stats.fail++;
		dpm_save_failed_errno(error);
	} else {
		suspend_stats.success++;
	}
	pr_info("suspend exit\n");
	return error;
}
Ejemplo n.º 25
0
void
fn_state(char **args)
{
    char *state, *line;
    enum state st;
    int freestatep;

    freestatep = 0;
    line = NULL;

    if (args) {
	if (args[0][0] != '<') {
	    if ((state=(char *)malloc(strlen(args[0])+3)) == NULL)
		return;
	    sprintf(state, "<%s>", args[0]);
	    freestatep = 1;
	}
	else
	    state = args[0];
    }
    else {
	line = read_string("State: ", 1);
	if (line == NULL || line[0] == '\0')
	    return;
	if (line[0] != '<') {
	    if ((state=(char *)malloc(strlen(line)+3)) == NULL)
		return;
	    sprintf(state, "<%s>", line);
	    freestatep = 1;
	}
	else
	    state = line;
    }

    st = parse_state(state);
    if (st == binding_state)
	return;
    
    enter_state(st);

    if (freestatep)
	free(state);
    free(line);
}	
Ejemplo n.º 26
0
static void name(parser_context *context, step *name_step)
{
    enter_state(context, ST_NAME);
    size_t offset = context->cursor;

    while(offset < context->length)
    {
        if('.' == context->input[offset] || '[' == context->input[offset])
        {
            break;
        }
        offset++;
    }
    while(isspace(context->input[offset - 1]))
    {
        offset--;
    }
    bool quoted = false;
    if('\'' == get_char(context) && '\'' == context->input[offset - 1])
    {
        consume_char(context);
        offset--;
        quoted = true;
    }
    name_step->test.name.length = offset - context->cursor;
    if(0 == name_step->test.name.length)
    {
        context->result.code = ERR_EXPECTED_NAME_CHAR;
        return;
    }
    name_step->test.name.value = (uint8_t *)calloc(1, name_step->test.name.length);
    if(NULL == name_step->test.name.value)
    {
        context->result.code = ERR_PARSER_OUT_OF_MEMORY;
        return;
    }
    memcpy(name_step->test.name.value, context->input + context->cursor, name_step->test.name.length);
    consume_chars(context, name_step->test.name.length);
    if(quoted)
    {
        consume_char(context);
    }
    skip_ws(context);
}
Ejemplo n.º 27
0
/**
 * pm_suspend - Externally visible function for suspending the system.
 * @state: System sleep state to enter.
 *
 * Check if the value of @state represents one of the supported states,
 * execute enter_state() and update system suspend statistics.
 */
int pm_suspend(suspend_state_t state)
{
	int error;

	if (state <= PM_SUSPEND_ON || state >= PM_SUSPEND_MAX)
		return -EINVAL;

	pm_suspend_marker("entry");
	suspend_stats.entry++;//20130313, Add check total_try_suspend_count. If total_try_suspend_count == 0, it means wakelock does not unlock. 
	error = enter_state(state);
	if (error) {
		suspend_stats.fail++;
		dpm_save_failed_errno(error);
	} else {
		suspend_stats.success++;
	}
	pm_suspend_marker("exit");
	return error;
}
Ejemplo n.º 28
0
static void name_test(parser_context *context)
{
    enter_state(context, ST_NAME_TEST);
    if('*' == get_char(context))
    {
        wildcard_name(context);
        return;
    }

    step *current = make_step(context->current_step_kind, NAME_TEST);
    if(NULL == current)
    {
        context->result.code = ERR_PARSER_OUT_OF_MEMORY;
        return;
    }
    push_step(context, current);

    context->result.code = JSONPATH_SUCCESS;
    name(context, current);
}
Ejemplo n.º 29
0
static ssize_t state_store(struct kset *kset, const char *buf, size_t n)
{
	suspend_state_t state = PM_SUSPEND_STANDBY;
	const char * const *s;
	char *p;
	int error;
	int len;

	p = memchr(buf, '\n', n);
	len = p ? p - buf : n;

	for (s = &pm_states[state]; state < PM_SUSPEND_MAX; s++, state++) {
		if (*s && !strncmp(buf, *s, len))
			break;
	}
	if (state < PM_SUSPEND_MAX && *s)
		error = enter_state(state);
	else
		error = -EINVAL;
	return error ? error : n;
}
Ejemplo n.º 30
0
static void subscript_predicate(parser_context *context)
{
    enter_state(context, ST_SUBSCRIPT_PREDICATE);

    size_t mark = context->cursor;
    uint_fast32_t subscript = integer(context);
    if(JSONPATH_SUCCESS != context->result.code)
    {
        reset(context, mark);
        return;
    }
    skip_ws(context);
    if(']' != get_char(context))
    {
        reset(context, mark);
        context->result.code = ERR_EXTRA_JUNK_AFTER_PREDICATE;
        return;
    }
    predicate *pred = add_predicate(context, SUBSCRIPT);
    pred->subscript.index = (size_t)subscript;
}