History

Input: cyapa - fix for losing events during device power transitions

When changing the scan rate as part of runtime-resume process we may lose some of the events, because: 1) for gen3 trackpads, the driver must msleep() some time to ensure that the device is ready to accept next command; 2) for gen5 and later trackpads, the queue dumping function will simply ignore the events when waiting for the set power mode command response. The solution is to keep polling and report those valid events when the set power mode command is in progress.

Dudley Du committed 10 years ago

Commit 3cd47861 parent 5186b8c5 files · +188 −59Browse files

Unified · Split

5 files
  1. drivers/input/mouse/cyapa.c +12 −10
  2. drivers/input/mouse/cyapa.h +13 −1
  3. drivers/input/mouse/cyapa_gen3.c +79 −29
  4. drivers/input/mouse/cyapa_gen5.c +82 −17
  5. drivers/input/mouse/cyapa_gen6.c +2 −2
drivers/input/mouse/cyapa.c+12−10
@@ -383,7 +383,7 @@ static int cyapa_open(struct input_dev *input) · 382 unmodified lines
383383 * when in operational mode.
384384 */
385385 error = cyapa->ops->set_power_mode(cyapa,
386− PWR_MODE_FULL_ACTIVE, 0, false);
386+ PWR_MODE_FULL_ACTIVE, 0, CYAPA_PM_ACTIVE);
387387 if (error) {
388388 dev_warn(dev, "set active power failed: %d\n", error);
389389 goto out;
@@ -424,7 +424,8 @@ static void cyapa_close(struct input_dev *input) · 34 unmodified lines
424424 pm_runtime_set_suspended(dev);
425425
426426 if (cyapa->operational)
427− cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0, false);
427+ cyapa->ops->set_power_mode(cyapa,
428+ PWR_MODE_OFF, 0, CYAPA_PM_DEACTIVE);
428429
429430 mutex_unlock(&cyapa->state_sync_lock);
430431 }
@@ -534,7 +535,7 @@ static void cyapa_enable_irq_for_cmd(struct cyapa *cyapa) · 103 unmodified lines
534535 */
535536 if (!input || cyapa->operational)
536537 cyapa->ops->set_power_mode(cyapa,
537− PWR_MODE_FULL_ACTIVE, 0, false);
538+ PWR_MODE_FULL_ACTIVE, 0, CYAPA_PM_ACTIVE);
538539 /* Gen3 always using polling mode for command. */
539540 if (cyapa->gen >= CYAPA_GEN5)
540541 enable_irq(cyapa->client->irq);
@@ -550,7 +551,7 @@ static void cyapa_disable_irq_for_cmd(struct cyapa *cyapa) · 9 unmodified lines
550551 disable_irq(cyapa->client->irq);
551552 if (!input || cyapa->operational)
552553 cyapa->ops->set_power_mode(cyapa,
553− PWR_MODE_OFF, 0, false);
554+ PWR_MODE_OFF, 0, CYAPA_PM_ACTIVE);
554555 }
555556 }
556557
@@ -617,7 +618,8 @@ static int cyapa_initialize(struct cyapa *cyapa) · 60 unmodified lines
617618
618619 /* Power down the device until we need it. */
619620 if (cyapa->operational)
620− cyapa->ops->set_power_mode(cyapa, PWR_MODE_OFF, 0, false);
621+ cyapa->ops->set_power_mode(cyapa,
622+ PWR_MODE_OFF, 0, CYAPA_PM_ACTIVE);
621623
622624 return 0;
623625 }
@@ -634,7 +636,7 @@ static int cyapa_reinitialize(struct cyapa *cyapa) · 10 unmodified lines
634636 /* Avoid command failures when TP was in OFF state. */
635637 if (cyapa->operational)
636638 cyapa->ops->set_power_mode(cyapa,
637− PWR_MODE_FULL_ACTIVE, 0, false);
639+ PWR_MODE_FULL_ACTIVE, 0, CYAPA_PM_ACTIVE);
638640
639641 error = cyapa_detect(cyapa);
640642 if (error)
@@ -654,7 +656,7 @@ out: · 13 unmodified lines
654656 /* Reset to power OFF state to save power when no user open. */
655657 if (cyapa->operational)
656658 cyapa->ops->set_power_mode(cyapa,
657− PWR_MODE_OFF, 0, false);
659+ PWR_MODE_OFF, 0, CYAPA_PM_DEACTIVE);
658660 } else if (!error && cyapa->operational) {
659661 /*
660662 * Make sure only enable runtime PM when device is
@@ -1392,7 +1394,7 @@ static int __maybe_unused cyapa_suspend(struct device *dev) · 731 unmodified lines
13921394 power_mode = device_may_wakeup(dev) ? cyapa->suspend_power_mode
13931395 : PWR_MODE_OFF;
13941396 error = cyapa->ops->set_power_mode(cyapa, power_mode,
1395− cyapa->suspend_sleep_time, true);
1397+ cyapa->suspend_sleep_time, CYAPA_PM_SUSPEND);
13961398 if (error)
13971399 dev_err(dev, "suspend set power mode failed: %d\n",
13981400 error);
@@ -1447,7 +1449,7 @@ static int __maybe_unused cyapa_runtime_suspend(struct device *dev) · 48 unmodified lines
14471449 error = cyapa->ops->set_power_mode(cyapa,
14481450 cyapa->runtime_suspend_power_mode,
14491451 cyapa->runtime_suspend_sleep_time,
1450− false);
1452+ CYAPA_PM_RUNTIME_SUSPEND);
14511453 if (error)
14521454 dev_warn(dev, "runtime suspend failed: %d\n", error);
14531455
@@ -1460,7 +1462,7 @@ static int __maybe_unused cyapa_runtime_resume(struct device *dev) · 6 unmodified lines
14601462 int error;
14611463
14621464 error = cyapa->ops->set_power_mode(cyapa,
1463− PWR_MODE_FULL_ACTIVE, 0, false);
1465+ PWR_MODE_FULL_ACTIVE, 0, CYAPA_PM_RUNTIME_RESUME);
14641466 if (error)
14651467 dev_warn(dev, "runtime resume failed: %d\n", error);
14661468
drivers/input/mouse/cyapa.h+13−1
@@ -250,6 +250,15 @@ struct cyapa; · 249 unmodified lines
250250
251251 typedef bool (*cb_sort)(struct cyapa *, u8 *, int);
252252
253+enum cyapa_pm_stage {
254+ CYAPA_PM_DEACTIVE,
255+ CYAPA_PM_ACTIVE,
256+ CYAPA_PM_SUSPEND,
257+ CYAPA_PM_RESUME,
258+ CYAPA_PM_RUNTIME_SUSPEND,
259+ CYAPA_PM_RUNTIME_RESUME,
260+};
261+
253262 struct cyapa_dev_ops {
254263 int (*check_fw)(struct cyapa *, const struct firmware *);
255264 int (*bl_enter)(struct cyapa *);
@@ -273,7 +282,7 @@ struct cyapa_dev_ops { · 17 unmodified lines
273282 int (*sort_empty_output_data)(struct cyapa *,
274283 u8 *, int *, cb_sort);
275284
276− int (*set_power_mode)(struct cyapa *, u8, u16, bool);
285+ int (*set_power_mode)(struct cyapa *, u8, u16, enum cyapa_pm_stage);
277286
278287 int (*set_proximity)(struct cyapa *, bool);
279288 };
@@ -289,6 +298,9 @@ struct cyapa_pip_cmd_states { · 9 unmodified lines
289298 u8 *resp_data;
290299 int *resp_len;
291300
301+ enum cyapa_pm_stage pm_stage;
302+ struct mutex pm_stage_lock;
303+
292304 u8 irq_cmd_buf[CYAPA_REG_MAP_SIZE];
293305 u8 empty_buf[CYAPA_REG_MAP_SIZE];
294306 };
drivers/input/mouse/cyapa_gen3.c+79−29
@@ -269,6 +269,7 @@ static const struct cyapa_cmd_len cyapa_smbus_cmds[] = { · 268 unmodified lines
269269 { CYAPA_SMBUS_MIN_BASELINE, 1 }, /* CYAPA_CMD_MIN_BASELINE */
270270 };
271271
272+static int cyapa_gen3_try_poll_handler(struct cyapa *cyapa);
272273
273274 /*
274275 * cyapa_smbus_read_block - perform smbus block read command
@@ -950,12 +951,14 @@ static u16 cyapa_get_wait_time_for_pwr_cmd(u8 pwr_mode) · 675 unmodified lines
950951 * Device power mode can only be set when device is in operational mode.
951952 */
952953 static int cyapa_gen3_set_power_mode(struct cyapa *cyapa, u8 power_mode,
953− u16 always_unused, bool is_suspend_unused)
954+ u16 always_unused, enum cyapa_pm_stage pm_stage)
954955 {
955− int ret;
956+ struct input_dev *input = cyapa->input;
956957 u8 power;
957958 int tries;
958− u16 sleep_time;
959+ int sleep_time;
960+ int interval;
961+ int ret;
959962
960963 if (cyapa->state != CYAPA_STATE_OP)
961964 return 0;
@@ -977,7 +980,7 @@ static int cyapa_gen3_set_power_mode(struct cyapa *cyapa, u8 power_mode, · 15 unmodified lines
977980 if ((ret & PWR_MODE_MASK) == power_mode)
978981 return 0;
979982
980− sleep_time = cyapa_get_wait_time_for_pwr_cmd(ret & PWR_MODE_MASK);
983+ sleep_time = (int)cyapa_get_wait_time_for_pwr_cmd(ret & PWR_MODE_MASK);
981984 power = ret;
982985 power &= ~PWR_MODE_MASK;
983986 power |= power_mode & PWR_MODE_MASK;
@@ -995,7 +998,23 @@ static int cyapa_gen3_set_power_mode(struct cyapa *cyapa, u8 power_mode, · 11 unmodified lines
995998 * doing so before issuing the next command may result in errors
996999 * depending on the command's content.
9971000 */
998− msleep(sleep_time);
1001+ if (cyapa->operational && input && input->users &&
1002+ (pm_stage == CYAPA_PM_RUNTIME_SUSPEND ||
1003+ pm_stage == CYAPA_PM_RUNTIME_RESUME)) {
1004+ /* Try to polling in 120Hz, read may fail, just ignore it. */
1005+ interval = 1000 / 120;
1006+ while (sleep_time > 0) {
1007+ if (sleep_time > interval)
1008+ msleep(interval);
1009+ else
1010+ msleep(sleep_time);
1011+ sleep_time -= interval;
1012+ cyapa_gen3_try_poll_handler(cyapa);
1013+ }
1014+ } else {
1015+ msleep(sleep_time);
1016+ }
1017+
9991018 return ret;
10001019 }
10011020
@@ -1112,7 +1131,7 @@ static int cyapa_gen3_do_operational_check(struct cyapa *cyapa) · 110 unmodified lines
11121131 * may cause problems, so we set the power mode first here.
11131132 */
11141133 error = cyapa_gen3_set_power_mode(cyapa,
1115− PWR_MODE_FULL_ACTIVE, 0, false);
1134+ PWR_MODE_FULL_ACTIVE, 0, CYAPA_PM_ACTIVE);
11161135 if (error)
11171136 dev_err(dev, "%s: set full power mode failed: %d\n",
11181137 __func__, error);
@@ -1168,32 +1187,16 @@ static bool cyapa_gen3_irq_cmd_handler(struct cyapa *cyapa) · 49 unmodified lines
11681187 return false;
11691188 }
11701189
1171−static int cyapa_gen3_irq_handler(struct cyapa *cyapa)
1190+static int cyapa_gen3_event_process(struct cyapa *cyapa,
1191+ struct cyapa_reg_data *data)
11721192 {
11731193 struct input_dev *input = cyapa->input;
1174− struct device *dev = &cyapa->client->dev;
1175− struct cyapa_reg_data data;
11761194 int num_fingers;
1177− int ret;
11781195 int i;
11791196
1180− ret = cyapa_read_block(cyapa, CYAPA_CMD_GROUP_DATA, (u8 *)&data);
1181− if (ret != sizeof(data)) {
1182− dev_err(dev, "failed to read report data, (%d)\n", ret);
1183− return -EINVAL;
1184− }
1185−
1186− if ((data.device_status & OP_STATUS_SRC) != OP_STATUS_SRC ||
1187− (data.device_status & OP_STATUS_DEV) != CYAPA_DEV_NORMAL ||
1188− (data.finger_btn & OP_DATA_VALID) != OP_DATA_VALID) {
1189− dev_err(dev, "invalid device state bytes, %02x %02x\n",
1190− data.device_status, data.finger_btn);
1191− return -EINVAL;
1192− }
1193−
1194− num_fingers = (data.finger_btn >> 4) & 0x0f;
1197+ num_fingers = (data->finger_btn >> 4) & 0x0f;
11951198 for (i = 0; i < num_fingers; i++) {
1196− const struct cyapa_touch *touch = &data.touches[i];
1199+ const struct cyapa_touch *touch = &data->touches[i];
11971200 /* Note: touch->id range is 1 to 15; slots are 0 to 14. */
11981201 int slot = touch->id - 1;
11991202
@@ -1210,18 +1213,65 @@ static int cyapa_gen3_irq_handler(struct cyapa *cyapa) · 10 unmodified lines
12101213
12111214 if (cyapa->btn_capability & CAPABILITY_LEFT_BTN_MASK)
12121215 input_report_key(input, BTN_LEFT,
1213− !!(data.finger_btn & OP_DATA_LEFT_BTN));
1216+ !!(data->finger_btn & OP_DATA_LEFT_BTN));
12141217 if (cyapa->btn_capability & CAPABILITY_MIDDLE_BTN_MASK)
12151218 input_report_key(input, BTN_MIDDLE,
1216− !!(data.finger_btn & OP_DATA_MIDDLE_BTN));
1219+ !!(data->finger_btn & OP_DATA_MIDDLE_BTN));
12171220 if (cyapa->btn_capability & CAPABILITY_RIGHT_BTN_MASK)
12181221 input_report_key(input, BTN_RIGHT,
1219− !!(data.finger_btn & OP_DATA_RIGHT_BTN));
1222+ !!(data->finger_btn & OP_DATA_RIGHT_BTN));
12201223 input_sync(input);
12211224
12221225 return 0;
12231226 }
12241227
1228+static int cyapa_gen3_irq_handler(struct cyapa *cyapa)
1229+{
1230+ struct device *dev = &cyapa->client->dev;
1231+ struct cyapa_reg_data data;
1232+ int ret;
1233+
1234+ ret = cyapa_read_block(cyapa, CYAPA_CMD_GROUP_DATA, (u8 *)&data);
1235+ if (ret != sizeof(data)) {
1236+ dev_err(dev, "failed to read report data, (%d)\n", ret);
1237+ return -EINVAL;
1238+ }
1239+
1240+ if ((data.device_status & OP_STATUS_SRC) != OP_STATUS_SRC ||
1241+ (data.device_status & OP_STATUS_DEV) != CYAPA_DEV_NORMAL ||
1242+ (data.finger_btn & OP_DATA_VALID) != OP_DATA_VALID) {
1243+ dev_err(dev, "invalid device state bytes: %02x %02x\n",
1244+ data.device_status, data.finger_btn);
1245+ return -EINVAL;
1246+ }
1247+
1248+ return cyapa_gen3_event_process(cyapa, &data);
1249+}
1250+
1251+/*
1252+ * This function will be called in the cyapa_gen3_set_power_mode function,
1253+ * and it's known that it may failed in some situation after the set power
1254+ * mode command was sent. So this function is aimed to avoid the knwon
1255+ * and unwanted output I2C and data parse error messages.
1256+ */
1257+static int cyapa_gen3_try_poll_handler(struct cyapa *cyapa)
1258+{
1259+ struct cyapa_reg_data data;
1260+ int ret;
1261+
1262+ ret = cyapa_read_block(cyapa, CYAPA_CMD_GROUP_DATA, (u8 *)&data);
1263+ if (ret != sizeof(data))
1264+ return -EINVAL;
1265+
1266+ if ((data.device_status & OP_STATUS_SRC) != OP_STATUS_SRC ||
1267+ (data.device_status & OP_STATUS_DEV) != CYAPA_DEV_NORMAL ||
1268+ (data.finger_btn & OP_DATA_VALID) != OP_DATA_VALID)
1269+ return -EINVAL;
1270+
1271+ return cyapa_gen3_event_process(cyapa, &data);
1272+
1273+}
1274+
12251275 static int cyapa_gen3_initialize(struct cyapa *cyapa) { return 0; }
12261276 static int cyapa_gen3_bl_initiate(struct cyapa *cyapa,
12271277 const struct firmware *fw) { return 0; }
drivers/input/mouse/cyapa_gen5.c+82−17
@@ -342,6 +342,9 @@ u8 pip_bl_read_app_info[] = { 0x04, 0x00, 0x0b, 0x00, 0x40, 0x00, · 341 unmodified lines
342342 static u8 cyapa_pip_bl_cmd_key[] = { 0xa5, 0x01, 0x02, 0x03,
343343 0xff, 0xfe, 0xfd, 0x5a };
344344
345+static int cyapa_pip_event_process(struct cyapa *cyapa,
346+ struct cyapa_pip_report_data *report_data);
347+
345348 int cyapa_pip_cmd_state_initialize(struct cyapa *cyapa)
346349 {
347350 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip;
@@ -350,6 +353,9 @@ int cyapa_pip_cmd_state_initialize(struct cyapa *cyapa) · 2 unmodified lines
350353 atomic_set(&pip->cmd_issued, 0);
351354 mutex_init(&pip->cmd_lock);
352355
356+ mutex_init(&pip->pm_stage_lock);
357+ pip->pm_stage = CYAPA_PM_DEACTIVE;
358+
353359 pip->resp_sort_func = NULL;
354360 pip->in_progress_cmd = PIP_INVALID_CMD;
355361 pip->resp_data = NULL;
@@ -397,6 +403,38 @@ ssize_t cyapa_i2c_pip_write(struct cyapa *cyapa, u8 *buf, size_t size) · 41 unmodified lines
397403 return 0;
398404 }
399405
406+static void cyapa_set_pip_pm_state(struct cyapa *cyapa,
407+ enum cyapa_pm_stage pm_stage)
408+{
409+ struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip;
410+
411+ mutex_lock(&pip->pm_stage_lock);
412+ pip->pm_stage = pm_stage;
413+ mutex_unlock(&pip->pm_stage_lock);
414+}
415+
416+static void cyapa_reset_pip_pm_state(struct cyapa *cyapa)
417+{
418+ struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip;
419+
420+ /* Indicates the pip->pm_stage is not valid. */
421+ mutex_lock(&pip->pm_stage_lock);
422+ pip->pm_stage = CYAPA_PM_DEACTIVE;
423+ mutex_unlock(&pip->pm_stage_lock);
424+}
425+
426+static enum cyapa_pm_stage cyapa_get_pip_pm_state(struct cyapa *cyapa)
427+{
428+ struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip;
429+ enum cyapa_pm_stage pm_stage;
430+
431+ mutex_lock(&pip->pm_stage_lock);
432+ pm_stage = pip->pm_stage;
433+ mutex_unlock(&pip->pm_stage_lock);
434+
435+ return pm_stage;
436+}
437+
400438 /**
401439 * This function is aimed to dump all not read data in Gen5 trackpad
402440 * before send any command, otherwise, the interrupt line will be blocked.
@@ -404,7 +442,9 @@ ssize_t cyapa_i2c_pip_write(struct cyapa *cyapa, u8 *buf, size_t size) · 1 unmodified line
404442 int cyapa_empty_pip_output_data(struct cyapa *cyapa,
405443 u8 *buf, int *len, cb_sort func)
406444 {
445+ struct input_dev *input = cyapa->input;
407446 struct cyapa_pip_cmd_states *pip = &cyapa->cmd_states.pip;
447+ enum cyapa_pm_stage pm_stage = cyapa_get_pip_pm_state(cyapa);
408448 int length;
409449 int report_count;
410450 int empty_count;
@@ -478,6 +518,12 @@ int cyapa_empty_pip_output_data(struct cyapa *cyapa, · 67 unmodified lines
478518 *len = length;
479519 /* Response found, success. */
480520 return 0;
521+ } else if (cyapa->operational && input && input->users &&
522+ (pm_stage == CYAPA_PM_RUNTIME_RESUME ||
523+ pm_stage == CYAPA_PM_RUNTIME_SUSPEND)) {
524+ /* Parse the data and report it if it's valid. */
525+ cyapa_pip_event_process(cyapa,
526+ (struct cyapa_pip_report_data *)pip->empty_buf);
481527 }
482528
483529 error = -EINVAL;
@@ -1566,15 +1612,17 @@ int cyapa_pip_deep_sleep(struct cyapa *cyapa, u8 state) · 1082 unmodified lines
15661612 }
15671613
15681614 static int cyapa_gen5_set_power_mode(struct cyapa *cyapa,
1569− u8 power_mode, u16 sleep_time, bool is_suspend)
1615+ u8 power_mode, u16 sleep_time, enum cyapa_pm_stage pm_stage)
15701616 {
15711617 struct device *dev = &cyapa->client->dev;
15721618 u8 power_state;
1573− int error;
1619+ int error = 0;
15741620
15751621 if (cyapa->state != CYAPA_STATE_GEN5_APP)
15761622 return 0;
15771623
1624+ cyapa_set_pip_pm_state(cyapa, pm_stage);
1625+
15781626 if (PIP_DEV_GET_PWR_STATE(cyapa) == UNINIT_PWR_MODE) {
15791627 /*
15801628 * Assume TP in deep sleep mode when driver is loaded,
@@ -1597,7 +1645,7 @@ static int cyapa_gen5_set_power_mode(struct cyapa *cyapa, · 16 unmodified lines
15971645 power_mode == PWR_MODE_BTN_ONLY ||
15981646 PIP_DEV_GET_SLEEP_TIME(cyapa) == sleep_time) {
15991647 /* Has in correct power mode state, early return. */
1600− return 0;
1648+ goto out;
16011649 }
16021650 }
16031651
@@ -1605,11 +1653,11 @@ static int cyapa_gen5_set_power_mode(struct cyapa *cyapa, · 1 unmodified line
16051653 error = cyapa_pip_deep_sleep(cyapa, PIP_DEEP_SLEEP_STATE_OFF);
16061654 if (error) {
16071655 dev_err(dev, "enter deep sleep fail: %d\n", error);
1608− return error;
1656+ goto out;
16091657 }
16101658
16111659 PIP_DEV_SET_PWR_STATE(cyapa, PWR_MODE_OFF);
1612− return 0;
1660+ goto out;
16131661 }
16141662
16151663 /*
@@ -1621,7 +1669,7 @@ static int cyapa_gen5_set_power_mode(struct cyapa *cyapa, · 5 unmodified lines
16211669 error = cyapa_pip_deep_sleep(cyapa, PIP_DEEP_SLEEP_STATE_ON);
16221670 if (error) {
16231671 dev_err(dev, "deep sleep wake fail: %d\n", error);
1624− return error;
1672+ goto out;
16251673 }
16261674 }
16271675
@@ -1630,7 +1678,7 @@ static int cyapa_gen5_set_power_mode(struct cyapa *cyapa, · 2 unmodified lines
16301678 GEN5_POWER_STATE_ACTIVE);
16311679 if (error) {
16321680 dev_err(dev, "change to active fail: %d\n", error);
1633− return error;
1681+ goto out;
16341682 }
16351683
16361684 PIP_DEV_SET_PWR_STATE(cyapa, PWR_MODE_FULL_ACTIVE);
@@ -1639,7 +1687,7 @@ static int cyapa_gen5_set_power_mode(struct cyapa *cyapa, · 2 unmodified lines
16391687 GEN5_POWER_STATE_BTN_ONLY);
16401688 if (error) {
16411689 dev_err(dev, "fail to button only mode: %d\n", error);
1642− return error;
1690+ goto out;
16431691 }
16441692
16451693 PIP_DEV_SET_PWR_STATE(cyapa, PWR_MODE_BTN_ONLY);
@@ -1664,7 +1712,7 @@ static int cyapa_gen5_set_power_mode(struct cyapa *cyapa, · 18 unmodified lines
16641712 if (error) {
16651713 dev_err(dev, "set power state to 0x%02x failed: %d\n",
16661714 power_state, error);
1667− return error;
1715+ goto out;
16681716 }
16691717
16701718 /*
@@ -1677,14 +1725,16 @@ static int cyapa_gen5_set_power_mode(struct cyapa *cyapa, · 6 unmodified lines
16771725 * is suspending which may cause interrupt line unable to be
16781726 * asserted again.
16791727 */
1680− if (is_suspend)
1728+ if (pm_stage == CYAPA_PM_SUSPEND)
16811729 cyapa_gen5_disable_pip_report(cyapa);
16821730
16831731 PIP_DEV_SET_PWR_STATE(cyapa,
16841732 cyapa_sleep_time_to_pwr_cmd(sleep_time));
16851733 }
16861734
1687− return 0;
1735+out:
1736+ cyapa_reset_pip_pm_state(cyapa);
1737+ return error;
16881738 }
16891739
16901740 int cyapa_pip_resume_scanning(struct cyapa *cyapa)
@@ -2513,7 +2563,7 @@ static int cyapa_gen5_do_operational_check(struct cyapa *cyapa) · 822 unmodified lines
25132563 * the device state is required.
25142564 */
25152565 error = cyapa_gen5_set_power_mode(cyapa,
2516− PWR_MODE_FULL_ACTIVE, 0, false);
2566+ PWR_MODE_FULL_ACTIVE, 0, CYAPA_PM_ACTIVE);
25172567 if (error)
25182568 dev_warn(dev, "%s: failed to set power active mode.\n",
25192569 __func__);
@@ -2715,7 +2765,6 @@ int cyapa_pip_irq_handler(struct cyapa *cyapa) · 195 unmodified lines
27152765 struct device *dev = &cyapa->client->dev;
27162766 struct cyapa_pip_report_data report_data;
27172767 unsigned int report_len;
2718− u8 report_id;
27192768 int ret;
27202769
27212770 if (!cyapa_is_pip_app_mode(cyapa)) {
@@ -2752,7 +2801,23 @@ int cyapa_pip_irq_handler(struct cyapa *cyapa) · 30 unmodified lines
27522801 return -EINVAL;
27532802 }
27542803
2755− report_id = report_data.report_head[PIP_RESP_REPORT_ID_OFFSET];
2804+ return cyapa_pip_event_process(cyapa, &report_data);
2805+}
2806+
2807+static int cyapa_pip_event_process(struct cyapa *cyapa,
2808+ struct cyapa_pip_report_data *report_data)
2809+{
2810+ struct device *dev = &cyapa->client->dev;
2811+ unsigned int report_len;
2812+ u8 report_id;
2813+
2814+ report_len = get_unaligned_le16(
2815+ &report_data->report_head[PIP_RESP_LENGTH_OFFSET]);
2816+ /* Idle, no data for report. */
2817+ if (report_len == PIP_RESP_LENGTH_SIZE)
2818+ return 0;
2819+
2820+ report_id = report_data->report_head[PIP_RESP_REPORT_ID_OFFSET];
27562821 if (report_id == PIP_WAKEUP_EVENT_REPORT_ID &&
27572822 report_len == PIP_WAKEUP_EVENT_SIZE) {
27582823 /*
@@ -2805,11 +2870,11 @@ int cyapa_pip_irq_handler(struct cyapa *cyapa) · 46 unmodified lines
28052870 }
28062871
28072872 if (report_id == PIP_TOUCH_REPORT_ID)
2808− cyapa_pip_report_touches(cyapa, &report_data);
2873+ cyapa_pip_report_touches(cyapa, report_data);
28092874 else if (report_id == PIP_PROXIMITY_REPORT_ID)
2810− cyapa_pip_report_proximity(cyapa, &report_data);
2875+ cyapa_pip_report_proximity(cyapa, report_data);
28112876 else
2812− cyapa_pip_report_buttons(cyapa, &report_data);
2877+ cyapa_pip_report_buttons(cyapa, report_data);
28132878
28142879 return 0;
28152880 }
drivers/input/mouse/cyapa_gen6.c+2−2
@@ -425,7 +425,7 @@ static int cyapa_gen6_deep_sleep(struct cyapa *cyapa, u8 state) · 424 unmodified lines
425425 }
426426
427427 static int cyapa_gen6_set_power_mode(struct cyapa *cyapa,
428− u8 power_mode, u16 sleep_time, bool is_suspend)
428+ u8 power_mode, u16 sleep_time, enum cyapa_pm_stage pm_stage)
429429 {
430430 struct device *dev = &cyapa->client->dev;
431431 struct gen6_interval_setting *interval_setting =
@@ -689,7 +689,7 @@ static int cyapa_gen6_operational_check(struct cyapa *cyapa) · 257 unmodified lines
689689 * the device state is required.
690690 */
691691 error = cyapa_gen6_set_power_mode(cyapa,
692− PWR_MODE_FULL_ACTIVE, 0, false);
692+ PWR_MODE_FULL_ACTIVE, 0, CYAPA_PM_ACTIVE);
693693 if (error)
694694 dev_warn(dev, "%s: failed to set power active mode.\n",
695695 __func__);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t