HID: nintendo: check analog user calibration for plausibility
authorJohnothan King <johnothanking@protonmail.com>
Wed, 21 Sep 2022 10:55:57 +0000 (10:55 +0000)
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>
Wed, 21 Sep 2022 12:25:26 +0000 (13:25 +0100)
commit50503e360eeb968a3d00234c9cc4057d774c3e9a
tree076667767496fe4d2d2ca8d7e6bc6657c4738b4a
parent8b30fb40f8f2c5e56b7af553a398340f92d17aae
HID: nintendo: check analog user calibration for plausibility

Arne Wendt writes:
  Cheap clone controllers may (falsely) report as having a user
  calibration for the analog sticks in place, but return
  wrong/impossible values for the actual calibration data.
  In the present case at mine, the controller reports having a
  user calibration in place and successfully executes the read
  commands. The reported user calibration however is
  min = center = max = 0.

  This pull request addresses problems of this kind by checking the
  provided user calibration-data for plausibility (min < center < max)
  and falling back to the default values if implausible.

I'll note that I was experiencing a crash because of this bug when using
the GuliKit KingKong 2 controller. The crash manifests as a divide by
zero error in the kernel logs:
kernel: divide error: 0000 [#1] PREEMPT SMP NOPTI

Link: https://github.com/nicman23/dkms-hid-nintendo/pull/25
Link: https://github.com/DanielOgorchock/linux/issues/36
Co-authored-by: Arne Wendt <arne.wendt@tuhh.de>
Signed-off-by: Johnothan King <johnothanking@protonmail.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/gvpL2G6VwXGJPvxX5KRiu9pVjvTivgayug_jdKDY6zfuAaAqncP9BkKLosjwUXNlgVVTMfJSKfwPF1K79cKAkwGComyC21vCV3q9B3EXNkE=@protonmail.com
drivers/hid/hid-nintendo.c