summaryrefslogtreecommitdiff
path: root/drivers/hid/i2c-hid
AgeCommit message (Collapse)AuthorFilesLines
2022-12-14Merge tag 'for-linus-2022121301' of ↵Linus Torvalds4-10/+8
git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid Pull HID updates from Jiri Kosina: - iio support for the MCP2221 HID driver (Matt Ranostay) - support for more than one hinge sensor in hid-sensor-custom (Yauhen Kharuzhy) - PS DualShock 4 controller support (Roderick Colenbrander) - XP-PEN Deco LW support (José Expósito) - other assorted code cleanups and device ID/quirk addtions * tag 'for-linus-2022121301' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (51 commits) HID: logitech HID++: Send SwID in GetProtocolVersion HID: hid-elan: use default remove for hid device HID: hid-alps: use default remove for hid device HID: hid-sensor-custom: set fixed size for custom attributes HID: i2c: let RMI devices decide what constitutes wakeup event HID: playstation: fix DualShock4 bluetooth CRC endian issue. HID: playstation: fix DualShock4 bluetooth memory corruption bug. HID: apple: Swap Control and Command keys on Apple keyboards HID: intel-ish-hid: ishtp: remove variable rb_count HID: uclogic: Standardize test name prefix HID: hid-sensor-custom: Allow more than one hinge angle sensor HID: ft260: fix 'cast to restricted' kernel CI bot warnings HID: ft260: missed NACK from busy device HID: ft260: fix a NULL pointer dereference in ft260_i2c_write HID: ft260: wake up device from power saving mode HID: ft260: missed NACK from big i2c read HID: ft260: remove SMBus Quick command support HID: ft260: skip unexpected HID input reports HID: ft260: do not populate /dev/hidraw device HID: ft260: improve i2c large reads performance ...
2022-12-14Merge tag 'input-for-v6.2-rc0' of ↵Linus Torvalds2-26/+3
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input Pull input updates from Dmitry Torokhov: - a new driver for Cypress Generation 5 touchscreens - a new driver for Hynitron cstxxx touchscreens - a new driver for Himax hx83112b touchscreen - I2C input devices have been converted to use i2c's probe_new() - a large number of input devices are now using DEFINE_SIMPLE_DEV_PM_OPS and pm_sleep_ptr() and no longer use __maybe_unused annotations - improvements to msg2638 touchscreen driver to also support msg2138 - conversion of several input deevine bindings to yaml/DT schema - changes to select touch drivers to move handling of wake irqs to the PM core - other assorted fixes and improvements. * tag 'input-for-v6.2-rc0' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (165 commits) Input: elants_i2c - delay longer with reset asserted dt-bindings: input: Convert ti,drv260x to DT schema dt-bindings: input: gpio-beeper: Convert to yaml schema Input: pxspad - fix unused data warning when force feedback not enabled Input: lpc32xx - allow building with COMPILE_TEST Input: nomadik-ske-keypad - allow building with COMPILE_TEST Input: pxa27xx-keypad - allow build with COMPILE_TEST Input: spear-keyboard - improve build coverage using COMPILE_TEST Input: tegra-kbc - allow build with COMPILE_TEST Input: tegra-kbc - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Input: tca6416-keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Input: tc3589x - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Input: st-keyscan - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Input: sh-keysc - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Input: qt1070 - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Input: pxa27x_keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Input: pmic8xxx-keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Input: nomadik-ske-keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Input: mcs-touchkey - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() Input: max7359-keypad - switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() ...
2022-12-13Merge branch 'for-6.2/rmi' into for-linusJiri Kosina1-1/+2
- wakeup event handling fix for RMI driver (Dmitry Torokhov)
2022-12-13Merge branch 'for-6.2/i2c' into for-linusJiri Kosina3-9/+6
- conversion of I2C HID drivers to use new simplified I2C probing (Stephen Kitt)
2022-11-23HID: i2c-hid: Don't set wake_capable and wake_irqRaul E Rangel1-9/+0
The i2c-core will now handle setting the wake_irq for DT and ACPI systems. Signed-off-by: Raul E Rangel <rrangel@chromium.org> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20220929093200.v6.10.Id22d056440953134d8e8fe2c2aff79c79bc78424@changeid Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2022-11-23HID: i2c-hid: acpi: Stop setting wakeup_capableRaul E Rangel1-5/+0
This is now handled by the i2c-core driver. Signed-off-by: Raul E Rangel <rrangel@chromium.org> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20220929093200.v6.9.I2efb7f551e0aa2dc4c53b5fd5bbea91a1cdd9b32@changeid Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2022-11-23HID: i2c-hid: Use PM subsystem to manage wake irqRaul E Rangel1-21/+12
The I2C hid driver is currently manually managing the wake IRQ. This change removes the explicit enable_irq_wake/disable_irq_wake and instead relies on the PM subsystem. This is done by calling dev_pm_set_wake_irq. i2c_device_probe already calls dev_pm_set_wake_irq when using device tree, and i2c_device_remove also already calls dev_pm_clear_wake_irq. There could be some device tree systems that have incorrectly declared `wake` capabilities, so this change will set the wake irq if one is missing. This matches the previous behavior. I tested this on an ACPI system that has a HID touchscreen and verified the IRQ was armed for wake on suspend. Signed-off-by: Raul E Rangel <rrangel@chromium.org> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20220929093200.v6.1.Id4b4bdfe06e2caf2d5a3c9dd4a9b1080c38b539c@changeid Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
2022-11-21HID: i2c: let RMI devices decide what constitutes wakeup eventDmitry Torokhov1-1/+2
HID-RMI is special in the sense that it does not carry HID events directly, but rather uses HID protocol as a wrapper/transport for RMI protocol. Therefore we should not assume that all data coming from the device via interrupt is associated with user activity and report wakeup event indiscriminately, but rather let HID-RMI do that when appropriate. HID-RMI devices tag responses to the commands issued by the host as RMI_READ_DATA_REPORT_ID whereas motion and other input events from the device are tagged as RMI_ATTN_REPORT_ID. Change hid-rmi to report wakeup events when receiving the latter packets. This allows ChromeOS to accurately identify wakeup source and make correct decision on the mode of the resume the system should take ("dark" where the display stays off vs normal one). Fixes: d951ae1ce803 ("HID: i2c-hid: Report wakeup events") Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-11-15HID: fix I2C_HID not selected when I2C_HID_OF_ELAN isBenjamin Tissoires1-2/+2
When I2C_HID_OF_ELAN is set, we need to turn on I2C_HID_CORE to ensure we get all the HID requirements. Fixes: bd3cba00dcc6 ("HID: i2c-hid: elan: Add support for Elan eKTH6915 i2c-hid touchscreens") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-10-18HID: i2c: use simple i2c probeStephen Kitt3-9/+6
All these drivers have an i2c probe function which doesn't use the "struct i2c_device_id *id" parameter, so they can trivially be converted to the "probe_new" style of probe with a single argument. This is part of an ongoing transition to single-argument i2c probe functions. Old-style probe functions involve a call to i2c_match_id: in drivers/i2c/i2c-core-base.c, /* * When there are no more users of probe(), * rename probe_new to probe. */ if (driver->probe_new) status = driver->probe_new(client); else if (driver->probe) status = driver->probe(client, i2c_match_id(driver->id_table, client)); else status = -EINVAL; Drivers which don't need the second parameter can be declared using probe_new instead, avoiding the call to i2c_match_id. Drivers which do can still be converted to probe_new-style, calling i2c_match_id themselves (as is done currently for of_match_id). This change was done using the following Coccinelle script, and fixed up for whitespace changes: @ rule1 @ identifier fn; identifier client, id; @@ - static int fn(struct i2c_client *client, const struct i2c_device_id *id) + static int fn(struct i2c_client *client) { ...when != id } @ rule2 depends on rule1 @ identifier rule1.fn; identifier driver; @@ struct i2c_driver driver = { - .probe + .probe_new = ( fn | - &fn + fn ) , }; Signed-off-by: Stephen Kitt <steve@sk2.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-10-07Merge tag 'for-linus-2022100501' of ↵Linus Torvalds1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid Pull HID updates from Benjamin Tissoires: - handle of all Logitech Bluetooth HID++ devices in the Logitech HID++ drivers (Bastien Nocera) - fix broken atomic checks in hid-multitouch by adding memory barriers (Andri Yngvason) - better handling of devices with AMD SFH1.1 (Basavaraj Natikar) - better support of Nintendo clone controllers (Icenowy Zheng and Johnothan King) - Support for various RC controllers (Marcus Folkesson) - Add UGEEv2 support in hid-uclogic (XP-PEN Deco Pro S and Parblo A610 PRO) (José Expósito) - some conversions to use dev_groups (Greg Kroah-Hartman) - HID-BPF preparatory patches, mostly to convert blank defines as enums (Benjamin Tissoires) * tag 'for-linus-2022100501' of git://git.kernel.org/pub/scm/linux/kernel/git/hid/hid: (38 commits) HID: wacom: add three styli to wacom_intuos_get_tool_type HID: amd_sfh: Handle condition of "no sensors" for SFH1.1 HID: amd_sfh: Change dev_err to dev_dbg for additional debug info HID: nintendo: check analog user calibration for plausibility HID: nintendo: deregister home LED when it fails HID: roccat: Fix use-after-free in roccat_read() hid: topre: Add driver fixing report descriptor HID: multitouch: Add memory barriers HID: convert defines of HID class requests into a proper enum HID: export hid_report_type to uapi HID: core: store the unique system identifier in hid_device HID: Add driver for PhoenixRC Flight Controller HID: Add driver for VRC-2 Car Controller HID: sony: Fix double word in comments hid: hid-logitech-hidpp: avoid unnecessary assignments in hidpp_connect_event HID: logitech-hidpp: Detect hi-res scrolling support HID: logitech-hidpp: Remove hard-coded "Sw. Id." for HID++ 2.0 commands HID: logitech-hidpp: Fix "Sw. Id." for HID++ 2.0 commands HID: logitech-hidpp: Remove special-casing of Bluetooth devices HID: logitech-hidpp: Enable HID++ for all the Logitech Bluetooth devices ...
2022-08-25HID: move from strlcpy with unused retval to strscpyWolfram Sang1-1/+1
Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-08-16i2c: Make remove callback return voidUwe Kleine-König2-4/+2
The value returned by an i2c driver's remove function is mostly ignored. (Only an error message is printed if the value is non-zero that the error is ignored.) So change the prototype of the remove function to return no value. This way driver authors are not tempted to assume that passing an error to the upper layer is a good idea. All drivers are adapted accordingly. There is no intended change of behaviour, all callbacks were prepared to return 0 before. Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com> Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au> Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Crt Mori <cmo@melexis.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Marek Behún <kabel@kernel.org> # for leds-turris-omnia Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Petr Machata <petrm@nvidia.com> # for mlxsw Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com> # for surface3_power Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> # for bmc150-accel-i2c + kxcjk-1013 Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> # for media/* + staging/media/* Acked-by: Miguel Ojeda <ojeda@kernel.org> # for auxdisplay/ht16k33 + auxdisplay/lcd2s Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # for versaclock5 Reviewed-by: Ajay Gupta <ajayg@nvidia.com> # for ucsi_ccg Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # for iio Acked-by: Peter Rosin <peda@axentia.se> # for i2c-mux-*, max9860 Acked-by: Adrien Grassein <adrien.grassein@gmail.com> # for lontium-lt8912b Reviewed-by: Jean Delvare <jdelvare@suse.de> # for hwmon, i2c-core and i2c/muxes Acked-by: Corey Minyard <cminyard@mvista.com> # for IPMI Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> # for drivers/power Acked-by: Krzysztof Hałasa <khalasa@piap.pl> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-06-08HID: i2c-hid: elan: Add support for Elan eKTH6915 i2c-hid touchscreensDouglas Anderson3-0/+146
Like many i2c-hid touchscreen controllers, the Elan eKTH6915 has a reset GPIO hooked up to it. According to the datasheet, the way we're supposed to turn the touchscreen on is: 1. Turn on the 3.3V supply. 2. Turn on the IO supply. It's OK if this is hardwired to the 3.3V supply, but if it's not then it must be turned on _after_ the 3.3V supply. 3. Wait >= 1 ms. 4. Deassert the reset GPIO (reset GPIO is active low, so there would be a leakage path if this was deasserted _before_ the IO supply). 5. Wait 300 ms. Much of the above can be handled by the generic i2c-hid-of driver, but the "reset" GPIO is not supported by that driver. Thus we'll do the same as we did for Goodix and add a new tiny driver that uses the i2c-hid core. NOTE: support for this new touchscreen could theorically fit into the Goodix driver. I've made it a separate driver because the Elan driver supports _two_ regulators and it's unclear exactly how that would fit in with commit 18eeef46d359 ("HID: i2c-hid: goodix: Tie the reset line to true state of the regulator"). Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-03-23Merge branch 'for-5.18/i2c-hid' into for-linusJiri Kosina1-278/+313
- fixes for handling unnumbered reports fully correctly (Angela Czubak Dmitry Torokhov) - untangling of intermingled code for sending and handling output reports in __i2c_hid_command() (Dmitry Torokhov)
2022-02-16HID: i2c-hid: remove unneeded semicolonYang Li1-1/+1
Eliminate the following coccicheck warning: ./drivers/hid/i2c-hid/i2c-hid-core.c:357:56-57: Unneeded semicolon Reported-by: Abaci Robot <abaci@linux.alibaba.com> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: note that I2C xfer buffers are DMA-safeDmitry Torokhov1-2/+3
All I2C communications in the driver use driver-private buffers that are DMA-safe, so mark them as such. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: no longer need raw access to HID descriptor structureDmitry Torokhov1-5/+2
We can stop defining a union for HID descriptor data as we now only access individual members of it by names and using proper types instead of accessing by offset from the beginning of the data structure. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: use helpers to do endian conversion in i2c_hid_get_input()Dmitry Torokhov1-13/+15
It is better to use helpers to do endian conversion as it documents and draws attention to it, and might be a bit more performant as well. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: rework i2c_hid_get_report() to use i2c_hid_xfer()Dmitry Torokhov1-91/+59
Explicitly prepare command for i2c_hid_get_report() which makes the logic clearer and allows us to get rid of __i2c_hid_command() and related command definitions. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: convert i2c_hid_execute_reset() to use i2c_hid_xfer()Dmitry Torokhov1-10/+9
This will allow us to drop i2c_hid_command() wrapper and get close to removing __i2c_hid_command(). Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: create a helper for SET_POWER commandDmitry Torokhov1-4/+18
Another case where creating a dedicated helper allows for cleaner code that shows exactly what communication happens with the device when toggling its power. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: define i2c_hid_read_register() and use itDmitry Torokhov1-23/+22
Handling simple read of device registers in __i2c_hid_command() makes it too complicated and the need of special handling for the HID descriptor register adds even more complexity. Instead, let's create simple i2c_hid_read_register() helper on base of i2c_hid_xfer() and use it. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: explicitly code setting and sending reportsDmitry Torokhov1-118/+151
Instead of relying on __i2c_hid_command() that tries to handle all commands and because of that is very complicated, let's define a new dumb helper i2c_hid_xfer() that actually transfers (write and read) data, and use it when sending and setting reports. By doing that we can save on number of copy operations we have to execute, and make logic of sending reports much clearer. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: refactor reset commandDmitry Torokhov1-25/+38
"Reset" is the only command that needs to wait for interrupt from the device before continuing, so let's factor our waiting logic from __i2c_hid_command() to make it simpler. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: use "struct i2c_hid" as argument in most callsDmitry Torokhov1-39/+36
The main object in the driver is struct i2c_hid so it makes more sense to pass it around instead of passing i2c_client and then fetching i2c_hid associated with it. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: fix GET/SET_REPORT for unnumbered reportsDmitry Torokhov1-8/+24
Internally kernel prepends all report buffers, for both numbered and unnumbered reports, with report ID, therefore to properly handle unnumbered reports we should prepend it ourselves. For the same reason we should skip the first byte of the buffer when calling i2c_hid_set_or_send_report() which then will take care of properly formatting the transfer buffer based on its separate report ID argument along with report payload. [jkosina@suse.cz: finalize trimmed sentence in changelog as spotted by Benjamin] Fixes: 9b5a9ae88573 ("HID: i2c-hid: implement ll_driver transport-layer callbacks") Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-14HID: i2c-hid: fix handling numbered reports with IDs of 15 and aboveAngela Czubak1-14/+10
Special handling of numbered reports with IDs of 15 and above is only needed when executing what HID-I2C spec is calling "Class Specific Requests", and not when simply sending output reports. Additionally, our mangling of report ID in i2c_hid_set_or_send_report() resulted in incorrect report ID being written into SET_REPORT command payload. To solve it let's move all the report ID manipulation into __i2c_hid_command() where we form the command data structure. Signed-off-by: Angela Czubak <acz@semihalf.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Tested-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-02-02HID: i2c-hid: goodix: Fix a lockdep splatDaniel Thompson1-16/+12
I'm was on the receiving end of a lockdep splat from this driver and after scratching my head I couldn't be entirely sure it was a false positive given we would also have to think about whether the regulator locking is safe (since the notifier is called whilst holding regulator locks which are also needed for regulator_is_enabled() ). Regardless of whether it is a real bug or not, the mutex isn't needed. We can use reference counting tricks instead to avoid races with the notifier calls. The observed splat follows: ------------------------------------------------------ kworker/u16:3/127 is trying to acquire lock: ffff00008021fb20 (&ihid_goodix->regulator_mutex){+.+.}-{4:4}, at: ihid_goodix_vdd_notify+0x30/0x94 but task is already holding lock: ffff0000835c60c0 (&(&rdev->notifier)->rwsem){++++}-{4:4}, at: blocking_notifier_call_chain+0x30/0x70 which lock already depends on the new lock. the existing dependency chain (in reverse order) is: -> #1 (&(&rdev->notifier)->rwsem){++++}-{4:4}: down_write+0x68/0x8c blocking_notifier_chain_register+0x54/0x70 regulator_register_notifier+0x1c/0x24 devm_regulator_register_notifier+0x58/0x98 i2c_hid_of_goodix_probe+0xdc/0x158 i2c_device_probe+0x25d/0x270 really_probe+0x174/0x2cc __driver_probe_device+0xc0/0xd8 driver_probe_device+0x50/0xe4 __device_attach_driver+0xa8/0xc0 bus_for_each_drv+0x9c/0xc0 __device_attach_async_helper+0x6c/0xbc async_run_entry_fn+0x38/0x100 process_one_work+0x294/0x438 worker_thread+0x180/0x258 kthread+0x120/0x130 ret_from_fork+0x10/0x20 -> #0 (&ihid_goodix->regulator_mutex){+.+.}-{4:4}: __lock_acquire+0xd24/0xfe8 lock_acquire+0x288/0x2f4 __mutex_lock+0xa0/0x338 mutex_lock_nested+0x3c/0x5c ihid_goodix_vdd_notify+0x30/0x94 notifier_call_chain+0x6c/0x8c blocking_notifier_call_chain+0x48/0x70 _notifier_call_chain.isra.0+0x18/0x20 _regulator_enable+0xc0/0x178 regulator_enable+0x40/0x7c goodix_i2c_hid_power_up+0x18/0x20 i2c_hid_core_power_up.isra.0+0x1c/0x2c i2c_hid_core_probe+0xd8/0x3d4 i2c_hid_of_goodix_probe+0x14c/0x158 i2c_device_probe+0x25c/0x270 really_probe+0x174/0x2cc __driver_probe_device+0xc0/0xd8 driver_probe_device+0x50/0xe4 __device_attach_driver+0xa8/0xc0 bus_for_each_drv+0x9c/0xc0 __device_attach_async_helper+0x6c/0xbc async_run_entry_fn+0x38/0x100 process_one_work+0x294/0x438 worker_thread+0x180/0x258 kthread+0x120/0x130 ret_from_fork+0x10/0x20 other info that might help us debug this: Possible unsafe locking scenario: CPU0 CPU1 ---- ---- lock(&(&rdev->notifier)->rwsem); lock(&ihid_goodix->regulator_mutex); lock(&(&rdev->notifier)->rwsem); lock(&ihid_goodix->regulator_mutex); *** DEADLOCK *** Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org> Fixes: 18eeef46d359 ("HID: i2c-hid: goodix: Tie the reset line to true state of the regulator") Reviewed-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2022-01-10Merge branch 'for-5.17/i2c-hid' into for-linusJiri Kosina1-1/+4
- PM wakeup support for i2c-hid driver (Matthias Kaehlcke)
2021-12-14HID: i2c-hid-of: Expose the touchscreen-inverted propertiesAlistair Francis5-5/+15
Allow the touchscreen-inverted-x/y device tree properties to control the HID_QUIRK_X_INVERT/HID_QUIRK_Y_INVERT quirks for the hid-input device. Signed-off-by: Alistair Francis <alistair@alistair23.me> Acked-by: Rob Herring <robh@kernel.org> [bentiss: silence checkpatch warnings] Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Link: https://lore.kernel.org/r/20211208124045.61815-3-alistair@alistair23.me
2021-12-02HID: add suspend/resume helpersBenjamin Tissoires1-11/+4
There is a lot of duplication of code in the HID low level drivers. Better have everything in one place so we can eventually extend it in a generic way. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20211202095334.14399-4-benjamin.tissoires@redhat.com
2021-11-19HID: i2c-hid: Report wakeup eventsMatthias Kaehlcke1-1/+4
The i2c-hid driver generally supports wakeup, bit it currently doesn't report wakeup events to the PM subsystem. Change that. Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-09-01Merge branch 'for-5.15/goodix' into for-linusJiri Kosina1-13/+79
- power management improvement for Goodix driver
2021-08-20HID: i2c-hid: Fix Elan touchpad regressionJim Broadus1-3/+2
A quirk was recently added for Elan devices that has same device match as an entry earlier in the list. The i2c_hid_lookup_quirk function will always return the last match in the list, so the new entry shadows the old entry. The quirk in the previous entry, I2C_HID_QUIRK_BOGUS_IRQ, silenced a flood of messages which have reappeared in the 5.13 kernel. This change moves the two quirk flags into the same entry. Fixes: ca66a6770bd9 (HID: i2c-hid: Skip ELAN power-on command after reset) Signed-off-by: Jim Broadus <jbroadus@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-07-28HID: i2c-hid: goodix: Use the devm variant of regulator_register_notifier()Douglas Anderson1-1/+1
In commit 18eeef46d359 ("HID: i2c-hid: goodix: Tie the reset line to true state of the regulator") I added a call to regulator_register_notifier() but no call to unregister. That's a bug. Let's use the devm variant to handle the unregistering. Fixes: 18eeef46d359 ("HID: i2c-hid: goodix: Tie the reset line to true state of the regulator") Signed-off-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-07-15HID: i2c-hid: goodix: Tie the reset line to true state of the regulatorDouglas Anderson1-13/+79
The regulator for the touchscreen could be: * A dedicated regulator just for the touchscreen. * A regulator shared with something else in the system. * An always-on regulator. How we want the "reset" line to behave depends a bit on which of those three cases we're in. Currently the code is written with the assumption that it has a dedicated regulator, but that's not really guaranteed to be the case. The problem we run into is that if we leave the touchscreen powered on (because someone else is requesting the regulator or it's an always-on regulator) and we assert reset then we apparently burn an extra 67 mW of power. That's not great. Let's instead tie the control of the reset line to the true state of the regulator as reported by regulator notifiers. If we have an always-on regulator our notifier will never be called. If we have a shared regulator then our notifier will be called when the touchscreen is truly turned on or truly turned off. Using notifiers like this nicely handles all the cases without resorting to hacks like pretending that there is no "reset" GPIO if we have an always-on regulator. NOTE: if the regulator is on a shared line it's still possible that things could be a little off. Specifically, this case is not handled even after this patch: 1. Suspend goodix (send "sleep", goodix stops requesting regulator on) 2. Other regulator user turns off (regulator fully turns off). 3. Goodix driver gets notified and asserts reset. 4. Other regulator user turns on. 5. Goodix driver gets notified and deasserts reset. 6. Nobody resumes goodix. With that set of steps we'll have reset deasserted but we will have lost the results of the I2C_HID_PWR_SLEEP from the suspend path. That means we might be in higher power than we could be even if the goodix driver thinks things are suspended. Presumably, however, we're still in better shape than if we were asserting "reset" the whole time. If somehow the above situation is actually affecting someone and we want to do better we can deal with it when we have a real use case. Signed-off-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-05-27HID: i2c-hid: fix format string mismatchArnd Bergmann1-2/+2
clang doesn't like printing a 32-bit integer using %hX format string: drivers/hid/i2c-hid/i2c-hid-core.c:994:18: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat] client->name, hid->vendor, hid->product); ^~~~~~~~~~~ drivers/hid/i2c-hid/i2c-hid-core.c:994:31: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat] client->name, hid->vendor, hid->product); ^~~~~~~~~~~~ Use an explicit cast to truncate it to the low 16 bits instead. Fixes: 9ee3e06610fd ("HID: i2c-hid: override HID descriptors for certain devices") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-05-07HID: i2c-hid: Skip ELAN power-on command after resetJohnny Chuang1-1/+8
For ELAN touchscreen, we found our boot code of IC was not flexible enough to receive and handle this command. Once the FW main code of our controller is crashed for some reason, the controller could not be enumerated successfully to be recognized by the system host. therefore, it lost touch functionality. Add quirk for skip send power-on command after reset. It will impact to ELAN touchscreen and touchpad on HID over I2C projects. Fixes: 43b7029f475e ("HID: i2c-hid: Send power-on command after reset"). Cc: stable@vger.kernel.org Signed-off-by: Johnny Chuang <johnny.chuang.emc@gmail.com> Reviewed-by: Harry Cutts <hcutts@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> Tested-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2021-03-08HID: i2c-hid: acpi: Drop redundant ACPI_PTR()Andy Shevchenko1-1/+1
The driver depends on ACPI, ACPI_PTR() resolution is always the same. Otherwise a compiler may produce a warning. That said, the rule of thumb either ugly ifdeffery with ACPI_PTR or none should be used in a driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-03-08HID: i2c-hid: acpi: Move GUID out of function and described itAndy Shevchenko1-3/+6
Move static GUID variable out of the function and add a comment how it looks like in the human readable representation. While at it, include uuid.h since the guid_t type is defined in it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-03-08HID: i2c-hid: acpi: Switch to new style i2c-driver probe functionAndy Shevchenko1-3/+2
Switch to the new style i2c-driver probe_new probe function. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-03-08HID: i2c-hid: acpi: Get ACPI companion only once and reuse itAndy Shevchenko1-20/+16
Currently the ACPI companion and handle are retrieved and checked a few times in different functions. Instead get ACPI companion only once and reuse it everywhere. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-02-23Merge branch 'for-5.12/i2c-hid' into for-linusJiri Kosina7-219/+510
- ACPI and OF support made more generic / decoupled. From Douglas Anderson - support for Goodix devices from Douglas Anderson
2021-02-05HID: i2c-hid: Add I2C_HID_QUIRK_NO_IRQ_AFTER_RESET for ITE8568 EC on Voyo ↵Hans de Goede1-0/+2
Winpad A15 The ITE8568 EC on the Voyo Winpad A15 presents itself as an I2C-HID attached keyboard and mouse (which seems to never send any events). This needs the I2C_HID_QUIRK_NO_IRQ_AFTER_RESET quirk, otherwise we get the following errors: [ 3688.770850] i2c_hid i2c-ITE8568:00: failed to reset device. [ 3694.915865] i2c_hid i2c-ITE8568:00: failed to reset device. [ 3701.059717] i2c_hid i2c-ITE8568:00: failed to reset device. [ 3707.205944] i2c_hid i2c-ITE8568:00: failed to reset device. [ 3708.227940] i2c_hid i2c-ITE8568:00: can't add hid device: -61 [ 3708.236518] i2c_hid: probe of i2c-ITE8568:00 failed with error -61 Which leads to a significant boot delay. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2021-01-18HID: i2c-hid: Introduce goodix-i2c-hid using i2c-hid coreDouglas Anderson3-2/+134
Goodix i2c-hid touchscreens are mostly i2c-hid compliant but have some special power sequencing requirements, including the need to drive a reset line during the sequencing. Let's use the new rejiggering of i2c-hid to support this with a thin wrapper driver to support the first Goodix i2c-hid touchscreen: GT7375P Signed-off-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2021-01-18HID: i2c-hid: Reorganize so ACPI and OF are separate modulesDouglas Anderson6-219/+378
This patch rejiggers the i2c-hid code so that the OF (Open Firmware aka Device Tree) and ACPI support is separated out a bit. The OF and ACPI drivers are now separate modules that wrap the core module. Essentially, what we're doing here: * Make "power up" and "power down" a function that can be (optionally) implemented by a given user of the i2c-hid core. * The OF and ACPI modules are drivers on their own, so they implement probe / remove / suspend / resume / shutdown. The core code provides implementations that OF and ACPI can call into. We'll organize this so that we now have 3 modules: the old i2c-hid module becomes the "core" module and two new modules will depend on it, handling probing the specific device. As part of this work, we'll remove the i2c-hid "platform data" concept since it's not needed. Signed-off-by: Douglas Anderson <dianders@chromium.org> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2020-12-16Merge branch 'for-5.11/i2c-hid' into for-linusJiri Kosina1-1/+4
- error reporting fix from Coiby Xu
2020-11-27HID: i2c-hid: add Vero K147 to descriptor overrideJulian Sax1-0/+8
This device uses the SIPODEV SP1064 touchpad, which does not supply descriptors, so it has to be added to the override list. Cc: stable@vger.kernel.org Signed-off-by: Julian Sax <jsbc@gmx.de> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2020-10-29HID: i2c-hid: show the error when failing to fetch the HID descriptorCoiby Xu1-1/+4
i2c_hid_probe() should notify the user of the error of failing to fetch the HID Descriptor instead of silently exiting. Link: https://forum.manjaro.org/t/elan-touchpad-working-in-live-but-not-in-native-os/31860/55 Cc: Barnabás Pőcze <pobrn@protonmail.com> Signed-off-by: Coiby Xu <coiby.xu@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>