summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-nvidia-shield.c
AgeCommit message (Collapse)Author
2024-01-23HID: nvidia-shield: Add missing null pointer checks to LED initializationKunwu Chan
devm_kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Ensure the allocation was successful by checking the pointer validity. [jkosina@suse.com: tweak changelog a bit] Signed-off-by: Kunwu Chan <chentao@kylinos.cn> Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Signed-off-by: Jiri Kosina <jkosina@suse.com>
2023-10-04HID: nvidia-shield: Introduce thunderstrike_destroy()Christophe JAILLET
In order to simplify some error handling paths and avoid code duplication, introduce thunderstrike_destroy() which undoes thunderstrike_create(). Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-10-04HID: nvidia-shield: Fix some missing function calls() in the probe error ↵Christophe JAILLET
handling path The commit in Fixes updated the error handling path of thunderstrike_create() and the remove function but not the error handling path of shield_probe(), should an error occur after a successful thunderstrike_create() call. Add the missing calls. Fixes: 3ab196f88237 ("HID: nvidia-shield: Add battery support for Thunderstrike") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-10-04HID: nvidia-shield: Fix a missing led_classdev_unregister() in the probe ↵Christophe JAILLET
error handling path The commit in Fixes updated the error handling path of thunderstrike_create() and the remove function but not the error handling path of shield_probe(), should an error occur after a successful thunderstrike_create() call. Add the missing call. Make sure it is safe to call in the probe error handling path by preventing the led_classdev from attempting to set the LED brightness to the off state on unregister. Fixes: f88af60e74a5 ("HID: nvidia-shield: Support LED functionality for Thunderstrike") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-08-31Merge branch 'for-6.6/nvidia' into for-linusBenjamin Tissoires
LED fixes and Battery support for the Nvidia Shield by Rahul Rameshbabu
2023-08-24HID: nvidia-shield: Reference hid_device devm allocation of input_dev nameRahul Rameshbabu
Use hid_device for devm allocation of the input_dev name to avoid a use-after-free. input_unregister_device would trigger devres cleanup of all resources associated with the input_dev, free-ing the name. The name would subsequently be used in a uevent fired at the end of unregistering the input_dev. Reported-by: Maxime Ripard <mripard@kernel.org> Closes: https://lore.kernel.org/linux-input/ZOZIZCND+L0P1wJc@penguin/T/#m443f3dce92520f74b6cf6ffa8653f9c92643d4ae Fixes: 09308562d4af ("HID: nvidia-shield: Initial driver implementation with Thunderstrike support") Suggested-by: Maxime Ripard <mripard@kernel.org> Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Reviewed-by: Maxime Ripard <mripard@kernel.org> Link: https://lore.kernel.org/r/20230824061308.222021-4-sergeantsagara@protonmail.com Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
2023-08-14HID: nvidia-shield: Update Thunderstrike LED instance name to use idRahul Rameshbabu
Previously would let led_classdev handle renaming when name collision occurred. Now that an ID allocator is used to uniquely identify multiple Thunderstrike controllers, generate unique led device names. Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-08-14HID: nvidia-shield: Add battery support for ThunderstrikeRahul Rameshbabu
Use power supply API to expose battery information about connected Thunderstrike controllers to the system. Provide information on battery capacity, charge status, charger type, voltage, and temperature. Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-08-14HID: nvidia-shield: Remove led_classdev_unregister in thunderstrike_createRahul Rameshbabu
Avoid calling thunderstrike_led_set_brightness from thunderstrike_create when led_classdev_unregister is called. led_classdev_unregister was called from thunderstrike_create in the error path. Calling thunderstrike_led_set_brightness in this situation is unsafe. Fixes: f88af60e74a5 ("HID: nvidia-shield: Support LED functionality for Thunderstrike") Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-07-09HID: nvidia-shield: Pack inner/related declarations in HOSTCMD reportsRahul Rameshbabu
Match alignment information in composite type declarations used by packed HOSTCMD report structures. Compiler packing attribute is not recursive for inner declarations. Mismatched alignment information can cause undefined behavior in code generated for accessing composite type members. struct pointers passed to thunderstrike_parse_board_info_payload and thunderstrike_parse_haptics_payload are an example of this being potentially problematic since alignment information from the packed HOSTCMD report is lost. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202307041500.6bKn7nCl-lkp@intel.com/ Link: https://github.com/llvm/llvm-project/issues/55520#issuecomment-1128617570 Link: https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Common-Type-Attributes.html#index-packed-type-attribute Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Link: https://lore.kernel.org/r/20230705060414.581468-1-rrameshbabu@nvidia.com Signed-off-by: Benjamin Tissoires <bentiss@kernel.org>
2023-06-09HID: nvidia-shield: Support LED functionality for ThunderstrikeRahul Rameshbabu
Expose the 2017 SHIELD controller (Thunderstrike) LED through the kernel LED API. Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-06-09HID: nvidia-shield: Add mappings for consumer HID USAGE buttonsRahul Rameshbabu
Map Android Home, Back, Search, VolumeUp, VolumeDown, and PlayPause buttons to the appropriate input event codes. Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-06-09HID: nvidia-shield: Initial driver implementation with Thunderstrike supportRahul Rameshbabu
Supports the Thunderstrike (SHIELD 2017) controller. Implements support for the Thunderstrike HOSTCMD firmware interface. Adds sysfs attributes about a SHIELD device and introduces haptics support for controllers. Signed-off-by: Rahul Rameshbabu <rrameshbabu@nvidia.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>