static void warn_poll_past_due(struct mcp2210_device *dev, unsigned long now, long how_late) { mcp2210_warn("Next poll is past due by %ums.\n", jiffies_to_msecs(how_late)); if (!poll_delay_warn_secs) return; /* If result ends up zero then it'll just repeat once */ dev->suppress_poll_warn = now + msecs_to_jiffies(1000 * poll_delay_warn_secs); mcp2210_warn("...suppressing for %u seconds.\n", poll_delay_warn_secs); }
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 */ }