Commit graph

230 commits

Author SHA1 Message Date
Jiri Kosina
f5e3e50b7d Merge branch 'for-6.5/i2c-hid' into for-linus 2023-06-27 22:42:28 +02:00
Uwe Kleine-König
e4b880758a HID: i2c-hid: Switch i2c drivers back to use .probe()
After commit b8a1a4cd5a ("i2c: Provide a temporary .probe_new()
call-back type"), all drivers being converted to .probe_new() and then
03c835f498 ("i2c: Switch .probe() to not take an id parameter") convert
back to (the new) .probe() to be able to eventually drop .probe_new() from
struct i2c_driver.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-06-08 16:21:55 +02:00
Fei Shao
7607f12ba7 HID: i2c-hid: goodix: Add support for "goodix,no-reset-during-suspend" property
In the beginning, commit 18eeef46d3 ("HID: i2c-hid: goodix: Tie the
reset line to true state of the regulator") introduced a change to tie
the reset line of the Goodix touchscreen to the state of the regulator
to fix a power leakage issue in suspend.

After some time, the change was deemed unnecessary and was reverted in
commit 557e05fa9f ("HID: i2c-hid: goodix: Stop tying the reset line to
the regulator") due to difficulties in managing regulator notifiers for
designs like Evoker, which provides a second power rail to touchscreen.

However, the revert caused a power regression on another Chromebook
device Steelix in the field, which has a dedicated always-on regulator
for touchscreen and was covered by the workaround in the first commit.

To address both cases, this patch adds the support for the new
"goodix,no-reset-during-suspend" property in the driver:
- When set to true, the driver does not assert the reset GPIO during
  power-down.
  Instead, the GPIO will be asserted during power-up to ensure the
  touchscreen always has a clean start and consistent behavior after
  resuming.
  This is for designs with a dedicated always-on regulator.
- When set to false or unset, the driver uses the original control flow
  and asserts GPIO and disables regulators normally.
  This is for the two-regulator and shared-regulator designs.

Signed-off-by: Fei Shao <fshao@chromium.org>
Suggested-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Jeff LaBundy <jeff@labundy.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-06-08 16:19:04 +02:00
Hans de Goede
2be404486c HID: i2c-hid-of: Add reset GPIO support to i2c-hid-of
Add reset GPIO support to the generic i2c-hid-of driver

This is necessary to make the Wacom digitizer on the Lenovo Yoga Book 1
(yb1-x90f/l) work and this will also allow consolidating the 2 specialized
i2c-hid-of-elan.c and i2c-hid-of-goodix.c drivers into the generic
i2c-hid-of driver.

For now the new "post-reset-deassert-delay-ms" property is only used on
x86/ACPI (non devicetree) devs. IOW it is not used in actual devicetree
files and the same goes for the reset GPIO. The devicetree-bindings
maintainers have requested properties like these to not be added to
the devicetree-bindings, so the new property + GPIO are deliberately
not added to the existing devicetree-bindings.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20230413093625.71146-4-hdegoede@redhat.com
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-04-13 16:27:42 +02:00
Hans de Goede
728ec8b6ed HID: i2c-hid-of: Allow using i2c-hid-of on non OF platforms
There are some x86 tablets / 2-in-1s which ship with Android as their
factory OS image. These have pretty broken ACPI tables, relying on
everything being hardcoded in the factory kernel image.

platform/x86/x86-android-tablets.c manually instantiates i2c-clients for
i2c devices on these tablets to make them work with the mainline kernel.

The Lenovo Yoga Book 1 (yb1-x90f/l) is such a 2-in-1. It has 2 I2C-HID
devices its main touchscreen and a Wacom digitizer. Its main touchscreen
can alternatively also be used in HiDeep's native protocol mode but
for the Wacom digitizer we really need I2C-HID.

This patch allows using i2c-hid-of on non OF platforms so that it can
bind to a non ACPI instantiated i2c_client on x86 for the Wacom digitizer.
Note the driver already has an "i2c-over-hid" i2c_device_id (rather then
an of_device_id).

Besides enabling building on non-OF platforms this also replaces
the only of_property_read_u32() call with device_property_read_u32() note
that other properties where already read using device_property_read_...().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20230413093625.71146-3-hdegoede@redhat.com
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-04-13 16:27:42 +02:00
Hans de Goede
9d793e7c1f HID: i2c-hid-of: Consistenly use dev local variable in probe()
i2c_hid_of_probe() has a dev local variable pointing to &i2c_client->dev,
consistently use this everywhere in i2c_hid_of_probe().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20230413093625.71146-2-hdegoede@redhat.com
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-04-13 16:27:42 +02:00
Benjamin Tissoires
904e28c6de Merge branch 'for-6.3/hid-bpf' into for-linus
Initial support of HID-BPF (Benjamin Tissoires)

The history is a little long for this series, as it was intended to be
sent for v6.2. However some last minute issues forced us to postpone it
to v6.3.

Conflicts:
* drivers/hid/i2c-hid/Kconfig:
  commit bf7660dab3 ("HID: stop drivers from selecting CONFIG_HID")
  conflicts with commit 2afac81dd1 ("HID: fix I2C_HID not selected
  when I2C_HID_OF_ELAN is")
  the resolution is simple enough: just drop the "default" and "select"
  lines as the new commit from Arnd is doing
2023-02-22 10:44:31 +01:00
Benjamin Tissoires
c21c9feed4 Merge branch 'for-6.3/multitouch' into for-linus
Allow to pass quirks from i2c-hid to hid-multitouch (Allen Ballway &
Dmitry Torokhov)
2023-02-22 10:39:05 +01:00
Benjamin Tissoires
0f7566c7e5 Merge branch 'for-6.3/i2c-hid' into for-linus
- dev_dbg cleanup (Thomas Weißschuh)
- cleanup i2c-hid-acpi (Andy Shevchenko)
- goodix: revert/fixes for an actual production device compared to the
  manufacturer sample (Douglas Anderson)
2023-02-22 10:34:51 +01:00
Douglas Anderson
eb16f59e8e HID: i2c-hid: goodix: Add mainboard-vddio-supply
As talked about in the patch ("dt-bindings: HID: i2c-hid: goodix: Add
mainboard-vddio-supply") we may need to power up a 1.8V rail on the
host associated with touchscreen IO. Let's add support in the driver
for it.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Link: https://lore.kernel.org/r/20230206184744.6.Ic234b931025d1f920ce9e06fff294643943a65ad@changeid
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-02-09 14:44:15 +01:00
Douglas Anderson
557e05fa9f HID: i2c-hid: goodix: Stop tying the reset line to the regulator
In commit 18eeef46d3 ("HID: i2c-hid: goodix: Tie the reset line to
true state of the regulator"), we started tying the reset line of
Goodix touchscreens to the regulator.

The primary motivation for that patch was some pre-production hardware
(specifically sc7180-trogdor-homestar) where it was proposed to hook
the touchscreen's main 3.3V power rail to an always-on supply. In such
a case, when we turned "off" the touchscreen in Linux it was bad to
assert the "reset" GPIO because that was causing a power drain. The
patch accomplished that goal and did it in a general sort of way that
didn't require special properties to be added in the device tree for
homestar.

It turns out that the design of using an always-on power rail for the
touchscreen was rejected soon after the patch was written and long
before sc7180-trogdor-homestar went into production. The final design
of homestar actually fully separates the rail for the touchscreen and
the display panel and both can be powered off and on. That means that
the original motivation for the feature is gone.

There are 3 other users of the goodix i2c-hid driver in mainline.

I'll first talk about 2 of the other users in mainline: coachz and
mrbland. On both coachz and mrbland the touchscreen power and panel
power _are_ shared. That means that the patch to tie the reset line to
the true state of the regulator _is_ doing something on those
boards. Specifically, the patch reduced power consumption by tens of
mA in the case where we turned the touchscreen off but left the panel
on. Other than saving a small bit of power, the patch wasn't truly
necessary. That being said, even though a small bit of power was saved
in the state of "panel on + touchscreen off", that's not actually a
state we ever expect to be in, except perhaps for very short periods
of time at boot or during suspend/resume. Thus, the patch is truly not
necessary. It should be further noted that, as documented in the
original patch, the current code still didn't optimize power for every
corner case of the "shared rail" situation.

The last user in mainline was very recently added: evoker. Evoker is
actually the motivation for me removing this bit of code. It turns out
that for evoker we need to manage a second power rail for IO to the
touchscreen. Trying to fit the management of this IO rail into the
regulator notifiers turns out to be extremely hard. To avoid lockdep
splats you shouldn't enable/disable other regulators in regulator
notifiers and trying to find a way around this was going to be fairly
difficult.

Given the lack of any true motivation to tie the reset line to the
regulator, lets go back to the simpler days and remove the code. This
is, effectively, a revert of commit bdbc65eb77 ("HID: i2c-hid:
goodix: Fix a lockdep splat"), commit 25ddd7cfc5 ("HID: i2c-hid:
goodix: Use the devm variant of regulator_register_notifier()"), and
commit 18eeef46d3 ("HID: i2c-hid: goodix: Tie the reset line to true
state of the regulator").

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Link: https://lore.kernel.org/r/20230206184744.4.I085b32b6140c7d1ac4e7e97b712bff9dd5962b62@changeid
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-02-09 14:44:14 +01:00
Dmitry Torokhov
03a8610555 HID: retain initial quirks set up when creating HID devices
In certain circumstances, such as when creating I2C-connected HID
devices, we want to pass and retain some quirks (axis inversion, etc).
The source of such quirks may be device tree, or DMI data, or something
else not readily available to the HID core itself and therefore cannot
be reconstructed easily. To allow this, introduce "initial_quirks" field
in hid_device structure and use it when determining the final set of
quirks.

This fixes the problem with i2c-hid setting up device-tree sourced
quirks too late and losing them on device rebind, and also allows to
sever the tie between hid-code and i2c-hid when applying DMI-based
quirks.

Fixes: b60d3c803d ("HID: i2c-hid-of: Expose the touchscreen-inverted properties")
Fixes: a2f416bf06 ("HID: multitouch: Add quirks for flipped axes")
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Tested-by: Allen Ballway <ballway@chromium.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: Alistair Francis <alistair@alistair23.me>
Link: https://lore.kernel.org/r/Y+LYwu3Zs13hdVDy@google.com
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
2023-02-09 14:24:30 +01:00
Arnd Bergmann
bf7660dab3 HID: stop drivers from selecting CONFIG_HID
There is a mix of drivers using either 'depends on HID' or 'select HID',
which causes both circular dependencies and missed dependencies for
a 'select':

WARNING: unment direct dependencies for HID
  Depends on [m]: HID_SUPPORT [=y] && INPUT [=m]
  Selected by [y]:
  - AMD_SFH_HID [=y] && HID_SUPPORT [=y] && (X86_64 || COMPILE_TEST [=y]) && PCI [=y]
  Selected by [m]:
  - I2C_HID_CORE [=m] && HID_SUPPORT [=y]

WARNING: unmet direct dependencies detected for INPUT_FF_MEMLESS
  Depends on [m]: INPUT [=m]
  Selected by [y]:
  - DRAGONRISE_FF [=y] && HID_SUPPORT [=y] && HID [=y] && HID_DRAGONRISE [=y]
  - HID_MICROSOFT [=y] && HID_SUPPORT [=y] && HID [=y]
  - GREENASIA_FF [=y] && HID_SUPPORT [=y] && HID [=y] && HID_GREENASIA [=y]
  Selected by [m]:
  - INPUT_ARIZONA_HAPTICS [=m] && INPUT [=m] && INPUT_MISC [=y] && MFD_ARIZONA [=y] && SND_SOC [=m]
  - INPUT_PM8XXX_VIBRATOR [=m] && INPUT [=m] && INPUT_MISC [=y] && (MFD_PM8XXX [=m] || MFD_SPMI_PMIC [=n])
  - INPUT_MAX8997_HAPTIC [=m] && INPUT [=m] && INPUT_MISC [=y] && PWM [=y] && MFD_MAX8997 [=y]
  - INPUT_GPIO_VIBRA [=m] && INPUT [=m] && INPUT_MISC [=y] && (GPIOLIB [=y] || COMPILE_TEST [=y])
  - INPUT_REGULATOR_HAPTIC [=m] && INPUT [=m] && INPUT_MISC [=y] && REGULATOR [=y]
  - INPUT_TWL6040_VIBRA [=m] && INPUT [=m] && INPUT_MISC [=y] && TWL6040_CORE [=y]
  - INPUT_PWM_VIBRA [=m] && INPUT [=m] && INPUT_MISC [=y] && PWM [=y]
  - INPUT_DRV260X_HAPTICS [=m] && INPUT_MISC [=y] && INPUT [=m] && I2C [=y] && (GPIOLIB [=y] || COMPILE_TEST [=y])
  - INPUT_DRV2665_HAPTICS [=m] && INPUT_MISC [=y] && INPUT [=m] && I2C [=y]
  - INPUT_DRV2667_HAPTICS [=m] && INPUT_MISC [=y] && INPUT [=m] && I2C [=y]
  - INPUT_SC27XX_VIBRA [=m] && INPUT [=m] && INPUT_MISC [=y] && (MFD_SC27XX_PMIC [=y] || COMPILE_TEST [=y])
  - HID_MAYFLASH [=m] && HID_SUPPORT [=y] && HID [=y]

Avoid this by changing all HID client drivers to use 'depends on HID'.
For I2C_HID, this requires a larger rework of the Kconfig description,
but it hopefully becomes easier to understand without the complex
I2C_HID_CORE definition.

Fixes: 25621bcc89 ("HID: Kconfig: split HID support and hid-core compilation")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-18 16:14:04 +01:00
Allen Ballway
a2f416bf06 HID: multitouch: Add quirks for flipped axes
Certain touchscreen devices, such as the ELAN9034, are oriented
incorrectly and report touches on opposite points on the X and Y axes.
For example, a 100x200 screen touched at (10,20) would report (90, 180)
and vice versa.

This is fixed by adding device quirks to transform the touch points
into the correct spaces, from X -> MAX(X) - X, and Y -> MAX(Y) - Y.

Signed-off-by: Allen Ballway <ballway@chromium.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-18 10:08:51 +01:00
Andy Shevchenko
4122abfed2 HID: i2c-hid: acpi: Unify ACPI ID tables format
Unify ACPI ID tables format by:
- surrounding HID by spaces
- dropping unnecessary driver_data assignment to 0
- dropping comma at the terminator entry

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-18 10:06:01 +01:00
Andy Shevchenko
572eaeb7fa HID: i2c-hid: acpi: Drop unneded NULL check of adev
The driver is enumerated on ACPI platforms, so adev is valid.
Since there is no valid I²C ID table provided, there is no
possibility to bind a device to this driver via user space.
Hence, drop unneeded NULL check of adev.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-18 10:06:01 +01:00
Thomas Weißschuh
f639e0b680 HID: i2c-hid: use uniform debugging APIs
Only two locations in i2c-hid are using the standard dev_dbg() APIs.
The rest are all using the custom i2c_hid_dbg(), which in turn uses
dev_dbg().

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-18 09:40:53 +01:00
Thomas Weißschuh
34ba3657a5 HID: i2c-hid: switch to standard debugging APIs
Instead of implementing a custom form of dynamic debugging we can use
the standard debugging APIs. If the kernel is built with
CONFIG_DYNAMIC_DEBUG this will be more discoverable and featureful.

Also the previous module parameter "debug" is read-only so it can't
actually be enabled.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-18 09:40:53 +01:00
Thomas Weißschuh
52d2253469 HID: Make lowlevel driver structs const
Nothing is nor should be modifying these structs so mark them as const.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: David Rheinsberg <david.rheinsberg@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-17 13:44:02 +01:00
Thomas Weißschuh
ebb45d6bee HID: Unexport struct i2c_hid_ll_driver
As there are no external users this implementation detail does not need
to be exported.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: David Rheinsberg <david.rheinsberg@gmail.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2023-01-17 13:44:01 +01:00
Linus Torvalds
2043f9a37d for-linus-2022121301
-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2
 
 iQIVAwUAY5iCHqZi849r7WBJAQKEhRAAqy2xfeg/DSGDhQItEWggL0H+2dPK7KWD
 Rw0ZimOVdRdMENGyoDxyFQ3VFd0/FJBVF7AtALs32zW40S/eAwuds81sklMsr6D1
 9LDalDlkCCyBKDSdNfPTEVgnIhJPiSuHX7HjJdoPUXdiRzEf+TxKaEQuGuhVbizw
 cfKChyKI/o173glvGVkzmA1iqCFPY+/tM6HJCHxxL51wko47wJZ9eubdZoxFpDU7
 mHyqyJYrcjaFh7iPOda77WAIT6gqQFJi9pbH5SBP5Hs/yZPvkw9OZQLrCGx8Zehe
 Trdh0GTBXo67D0UBHiOafqQSj9CqDunBLBOOD4uf5K9CfzIBhyHS7C2rtrY85Lz2
 6/WevKgZ0MuLma87DcDkb2nNEnjQbV8OPcD10qk7k2yDl8SezoOiS+g7rOTo42P1
 80zt68znsEQCJBAqG3X8x+bU767r73FIJlFSERvRz1j0N05EpScIs5NR9cRK/iGB
 1oAxj0H04jOR0K+1mHhPWxIQpE2ypHOLhYlR9RROWbvM9ilJpaCaESHTZYMv83U/
 QuZR4ytH9uqqUIsweK9ExUiu3RK5YEC/H/GuFSORYFl40jB/iRmbRGTKiLNOGraH
 oYE/sIWYUtsPCOLFeIPGG8pd5I9spImlRUkSqBfx803I9SQPG/rx4q7rcol6YOlS
 FwnRlMSGz0Y=
 =KkQc
 -----END PGP SIGNATURE-----

Merge tag 'for-linus-2022121301' of 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-13 13:32:56 -08:00
Linus Torvalds
86a0b4255e Input updates for 6.2 merge window:
- 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.
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYIAB0WIQST2eWILY88ieB2DOtAj56VGEWXnAUCY5d+9wAKCRBAj56VGEWX
 nN9CAP9R1zCdPc5Y2PmLnE6JHc9XynPhUnVbnx4zHieMxw0nHQD/ZnHot+Cdq/+L
 433dkdX50pwK3XxRQgjRaym+efgwfQ0=
 =9m4z
 -----END PGP SIGNATURE-----

Merge tag 'input-for-v6.2-rc0' of 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-13 13:20:36 -08:00
Jiri Kosina
54dcc80e7d Merge branch 'for-6.2/rmi' into for-linus
- wakeup event handling fix for RMI driver (Dmitry Torokhov)
2022-12-13 14:37:43 +01:00
Jiri Kosina
060e4b066e Merge branch 'for-6.2/i2c' into for-linus
- conversion of I2C HID drivers to use new simplified I2C probing (Stephen Kitt)
2022-12-13 14:33:13 +01:00
Raul E Rangel
327c8b23a2 HID: i2c-hid: Don't set wake_capable and wake_irq
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-22 13:59:10 -08:00
Raul E Rangel
1796f808e4 HID: i2c-hid: acpi: Stop setting wakeup_capable
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-22 13:59:08 -08:00
Raul E Rangel
d08999cc59 HID: i2c-hid: Use PM subsystem to manage wake irq
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-22 13:58:44 -08:00
Dmitry Torokhov
9984fbf55b HID: i2c: let RMI devices decide what constitutes wakeup event
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: d951ae1ce8 ("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-21 18:56:20 +01:00
Benjamin Tissoires
2afac81dd1 HID: fix I2C_HID not selected when I2C_HID_OF_ELAN is
When I2C_HID_OF_ELAN is set, we need to turn on I2C_HID_CORE to
ensure we get all the HID requirements.

Fixes: bd3cba00dc ("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-11-15 16:27:22 +01:00
Stephen Kitt
baf34f3bbe HID: i2c: use simple i2c probe
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-18 16:13:25 +02:00
Linus Torvalds
79d11de963 Assorted HID drivers updates and fixes for 6.1
-----BEGIN PGP SIGNATURE-----
 
 iQJSBAABCAA8FiEEoEVH9lhNrxiMPSyI7MXwXhnZSjYFAmM9UhweHGJlbmphbWlu
 LnRpc3NvaXJlc0ByZWRoYXQuY29tAAoJEOzF8F4Z2Uo2pE8P/23iRM/+kO2KDeU8
 3lp6z1Ny/Hp0HPAsWCgAywgPcNoG+JaxBdAFv2YXky0RI3/OMtI+6FK36XJs63E5
 twjFwySxupY2CXLIXjSkLunAWlZUwtpRLnrBpPwgG87wKkI8IvPmv1AwkiYO9GD9
 Q0vtd+GaE7Bx33XBga4IcVx1hODL/SDeT1ozS1czhv4NNutRsR7lxCsn6qKly9WK
 zwoTHEOIJnq4oLZElmnxuJeUU1vvRXy4g+xPV+rfqbnlZUh0zQeD//1G7lRchEel
 t6l5SDR9pZ+zbWUw7gtU/KoUtf4eJ5+4fX9ejMqtEvoQLquePYQOD6Pyzjqlq7ND
 x31MjTmVHaav4GZiON7ztkbUncnERYRVRiLr5iDw9xcS5MVnMg2a07VgY6Ld5Xnl
 FQ0ZaO7T1HUxl2Lig7kRdX/kIDVNMIgfS1e0H6yJC3b5sbouwSRknu6EoumK/6tG
 nx8njAYi8t+2DN7d/82Ck1Z3CfY100WONahBAVZeyNtu0p9QH1k0b6srZiCpFTvQ
 ffl6lXboiYYx3hV/HNoDiIJPTh/zJhjEAzi1MgUKlbt5ImYWJQ0tAnhY16e3+xt5
 83ryRFdUmjwxE/0Oh0yi1Nk8VWid+40DCpay9Qm6veyRr+ECviChwoI0OUFsTrfR
 p2+2ghZHwFf4JTpUNlHdV0Kz0OJ9
 =lo26
 -----END PGP SIGNATURE-----

Merge tag 'for-linus-2022100501' of 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-10-07 11:13:42 -07:00
Wolfram Sang
eeeec27d68 HID: move from strlcpy with unused retval to strscpy
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-25 11:44:27 +02:00
Uwe Kleine-König
ed5c2f5fd1 i2c: Make remove callback return void
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-08-16 12:46:26 +02:00
Douglas Anderson
bd3cba00dc HID: i2c-hid: elan: Add support for Elan eKTH6915 i2c-hid touchscreens
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 18eeef46d3 ("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-06-08 11:46:23 +02:00
Jiri Kosina
5d3ab41394 Merge branch 'for-5.18/i2c-hid' into for-linus
- 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-03-23 10:04:40 +01:00
Yang Li
269ecc0c89 HID: i2c-hid: remove unneeded semicolon
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-16 16:30:00 +01:00
Dmitry Torokhov
1c4d6cd4cb HID: i2c-hid: note that I2C xfer buffers are DMA-safe
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-14 10:52:29 +01:00
Dmitry Torokhov
551117c522 HID: i2c-hid: no longer need raw access to HID descriptor structure
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-14 10:52:29 +01:00
Dmitry Torokhov
86fc3fd281 HID: i2c-hid: use helpers to do endian conversion in i2c_hid_get_input()
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-14 10:52:29 +01:00
Dmitry Torokhov
85df713377 HID: i2c-hid: rework i2c_hid_get_report() to use i2c_hid_xfer()
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-14 10:51:08 +01:00
Dmitry Torokhov
50c5249fca HID: i2c-hid: convert i2c_hid_execute_reset() to use i2c_hid_xfer()
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-14 10:51:08 +01:00
Dmitry Torokhov
acb8dd9597 HID: i2c-hid: create a helper for SET_POWER command
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-14 10:51:08 +01:00
Dmitry Torokhov
8399bd0102 HID: i2c-hid: define i2c_hid_read_register() and use it
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-14 10:51:07 +01:00
Dmitry Torokhov
dbe0dd5fd2 HID: i2c-hid: explicitly code setting and sending reports
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-14 10:51:07 +01:00
Dmitry Torokhov
b26fc3161b HID: i2c-hid: refactor reset command
"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-14 10:51:07 +01:00
Dmitry Torokhov
d34c610549 HID: i2c-hid: use "struct i2c_hid" as argument in most calls
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-14 10:51:07 +01:00
Dmitry Torokhov
a5e5e03e94 HID: i2c-hid: fix GET/SET_REPORT for unnumbered reports
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: 9b5a9ae885 ("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-14 10:50:55 +01:00
Angela Czubak
cf5b2fb012 HID: i2c-hid: fix handling numbered reports with IDs of 15 and above
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-14 10:50:55 +01:00
Daniel Thompson
2787710f73 HID: i2c-hid: goodix: Fix a lockdep splat
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: 18eeef46d3 ("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-02-02 14:47:46 +01:00
Jiri Kosina
906095af85 Merge branch 'for-5.17/i2c-hid' into for-linus
- PM wakeup support for i2c-hid driver (Matthias Kaehlcke)
2022-01-10 09:56:27 +01:00