Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/chrome: sensorhub: Support devices without FIFO_INT_ENABLE

Some devices (such as Smaug) report having MOTION_SENSE_FIFO but do not
support controlling the behaviour of the FIFO interrupt via the
FIFO_INT_ENABLE command and in these cases the interrupt is always
enabled. However, currently the code assumes that if MOTION_SENSE_FIFO
is supported then so is FIFO_INT_ENABLE, and when it tries to enable
the interrupt via this command and an unsupported device reports a
failure it then propagates this into failing the sensors probe.

Interpret the return value -EINVAL as a device where FIFO_INT_ENABLE is
not present and the interrupt is always enabled.

Signed-off-by: Diogo Ivo <diogo.ivo@tecnico.ulisboa.pt>
Link: https://lore.kernel.org/r/20251112-diogo-smaug_ec_sensorhub-v1-1-f71d4e9eb9d4@tecnico.ulisboa.pt
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>

authored by

Diogo Ivo and committed by
Tzung-Bi Shih
52075d2c 944edca8

+11
+11
drivers/platform/chrome/cros_ec_sensorhub_ring.c
··· 129 129 /* We expect to receive a payload of 4 bytes, ignore. */ 130 130 if (ret > 0) 131 131 ret = 0; 132 + /* 133 + * Some platforms (such as Smaug) don't support the FIFO_INT_ENABLE 134 + * command and the interrupt is always enabled. In the case, it 135 + * returns -EINVAL. 136 + * 137 + * N.B: there is no danger of -EINVAL meaning any other invalid 138 + * parameter since fifo_int_enable.enable is a bool and can never 139 + * be in an invalid range. 140 + */ 141 + else if (ret == -EINVAL) 142 + ret = 0; 132 143 133 144 return ret; 134 145 }