Exemplo n.º 1
0
static int complete_poll(struct mcp2210_cmd *cmd_head, void *context)
{
	struct mcp2210_device *dev = cmd_head->dev;
	struct mcp2210_cmd_ctl *cmd = (void*)cmd_head;
	unsigned long now = jiffies;
	int enabled;
	unsigned long interval;
	unsigned long interval_j;
	unsigned long next;
	long next_diff;

	mcp2210_debug();

	if (dev->dead)
		return -EINPROGRESS;

	if (cmd->req.cmd == MCP2210_CMD_GET_PIN_VALUE) {
		enabled = dev->poll_gpio;
		interval = dev->config->poll_gpio_usecs;
		dev->last_poll_gpio = now;
	} else {
		enabled = dev->poll_intr;
		interval = dev->config->poll_intr_usecs;
		dev->last_poll_intr = now;
	}

	if (dev->suppress_poll_warn && jiffdiff(dev->suppress_poll_warn, now) <= 0)
		dev->suppress_poll_warn = 0;

	if (!enabled)
		return -EINPROGRESS;

	interval_j = usecs_to_jiffies(interval);
	next = dev->eps[EP_OUT].submit_time + interval_j;
	next_diff = jiffdiff(next, now);
	cmd->head.delayed = 1;

	if (next_diff < 0) {
		next = now + interval_j;
		if (!dev->suppress_poll_warn)
			warn_poll_past_due(dev, now, -next_diff);
	}
	cmd->head.delay_until = next;

#if 0
	mcp2210_debug("interval_j: %lu, submit_time: %lu, next: %lu, jiffies: %lu",
		      interval_j, dev->eps[EP_OUT].submit_time, next, jiffies);
#endif

	cmd->head.state = MCP2210_STATE_NEW;

	mcp2210_add_cmd(cmd_head, false);

	return -EINPROGRESS; /* tell process_commands not to free us */
}
Exemplo n.º 2
0
static int complete_poll(struct mcp2210_cmd *cmd_head, void *context)
{
    struct mcp2210_device *dev = cmd_head->dev;
    struct mcp2210_cmd_ctl *cmd = (void*)cmd_head;
    int enabled;
    unsigned long interval;
    unsigned long now = jiffies;

    mcp2210_debug();

    if (dev->dead)
        return -EINPROGRESS;

    if (cmd->req.cmd == MCP2210_CMD_GET_PIN_VALUE) {
        enabled = dev->s.poll_gpio;
        interval = dev->config->poll_gpio_usecs;
        dev->s.last_poll_gpio = now;
    } else {
        enabled = dev->s.poll_intr;
        interval = dev->config->poll_intr_usecs;
        dev->s.last_poll_intr = now;
    }

    if (!enabled)
        return -EINPROGRESS;

    if (1) {
        unsigned long interval_j = usecs_to_jiffies(interval);
        unsigned long next = dev->eps[EP_OUT].submit_time + interval_j;
        cmd->head.delayed = 1;

        if (jiffdiff(next, now) < 0) {
            mcp2210_warn("poll interval collapse, restarting universe");
            next = jiffies + interval_j;
        }
        cmd->head.delay_until = next;

#if 0
        mcp2210_debug("interval_j: %lu, submit_time: %lu, next: %lu, jiffies: %lu",
                      interval_j, dev->eps[EP_OUT].submit_time, next, jiffies);
#endif
    }

    cmd->head.state = MCP2210_STATE_NEW;

    mcp2210_add_cmd(cmd_head, false);

    return -EINPROGRESS; /* tell process_commands not to free us */
}
Exemplo n.º 3
0
static int mcp2210_irq_set_type(struct irq_data *data, unsigned int type)
{
    struct mcp2210_device *dev = irq_data_get_irq_chip_data(data);

    mcp2210_debug();
#if 0
    if (type & IRQ_TYPE_EDGE_RISING)
        adnp->irq_rise[reg] |= BIT(pos);
    else
        adnp->irq_rise[reg] &= ~BIT(pos);

    if (type & IRQ_TYPE_EDGE_FALLING)
        adnp->irq_fall[reg] |= BIT(pos);
    else
        adnp->irq_fall[reg] &= ~BIT(pos);

    if (type & IRQ_TYPE_LEVEL_HIGH)
        adnp->irq_high[reg] |= BIT(pos);
    else
        adnp->irq_high[reg] &= ~BIT(pos);

    if (type & IRQ_TYPE_LEVEL_LOW)
        adnp->irq_low[reg] |= BIT(pos);
    else
        adnp->irq_low[reg] &= ~BIT(pos);
#endif
    return 0;
}
Exemplo n.º 4
0
static void mcp2210_irq_bus_unlock(struct irq_data *data)
{
    struct mcp2210_device *dev = irq_data_get_irq_chip_data(data);

    mcp2210_debug();
    mutex_unlock(&dev->irq_lock);
}
Exemplo n.º 5
0
static void mcp2210_irq_unmask(struct irq_data *data)
{
    struct mcp2210_device *dev = irq_data_get_irq_chip_data(data);

    mcp2210_debug();
}