From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:54404 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753853AbdDJPSX (ORCPT ); Mon, 10 Apr 2017 11:18:23 -0400 Subject: Patch "HID: i2c-hid: add a simple quirk to fix device defects" has been added to the 4.9-stable tree To: gregkh@linuxfoundation.org, alexander.levin@verizon.com, benjamin.tissoires@redhat.com, hn.chen@weidahitech.com, jkosina@suse.cz, stable@vger.kernel.org Cc: , From: Date: Mon, 10 Apr 2017 17:18:03 +0200 In-Reply-To: <20170404193158.19041-5-alexander.levin@verizon.com> Message-ID: <14918374831695@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled HID: i2c-hid: add a simple quirk to fix device defects to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: hid-i2c-hid-add-a-simple-quirk-to-fix-device-defects.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From foo@baz Mon Apr 10 17:14:09 CEST 2017 From: alexander.levin@verizon.com Date: Tue, 4 Apr 2017 19:32:03 +0000 Subject: HID: i2c-hid: add a simple quirk to fix device defects To: "gregkh@linuxfoundation.org" Cc: "stable@vger.kernel.org" Message-ID: <20170404193158.19041-5-alexander.levin@verizon.com> From: HungNien Chen [ Upstream commit 71af01a8c85ad89449209594133bdfdfaa9f1e2a ] Certain devices produced by Weida Tech need to have a wakeup command sent to them before powering on. The call itself will come back with error, but the device can be powered on afterwards. [jkosina@suse.cz: rewrite changelog] [jkosina@suse.cz: remove unused device ID addition] Signed-off-by: HungNien Chen Reviewed-by: Benjamin Tissoires Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-ids.h | 4 ++ drivers/hid/i2c-hid/i2c-hid.c | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h @@ -1039,6 +1039,10 @@ #define USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH 0x0500 #define USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET 0x0502 +#define USB_VENDOR_ID_WEIDA 0x2575 +#define USB_DEVICE_ID_WEIDA_8752 0xC300 +#define USB_DEVICE_ID_WEIDA_8755 0xC301 + #define USB_VENDOR_ID_WISEGROUP 0x0925 #define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005 #define USB_DEVICE_ID_SUPER_JOY_BOX_3 0x8888 --- a/drivers/hid/i2c-hid/i2c-hid.c +++ b/drivers/hid/i2c-hid/i2c-hid.c @@ -41,6 +41,11 @@ #include +#include "../hid-ids.h" + +/* quirks to control the device */ +#define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV BIT(0) + /* flags */ #define I2C_HID_STARTED 0 #define I2C_HID_RESET_PENDING 1 @@ -143,6 +148,7 @@ struct i2c_hid { char *argsbuf; /* Command arguments buffer */ unsigned long flags; /* device flags */ + unsigned long quirks; /* Various quirks */ wait_queue_head_t wait; /* For waiting the interrupt */ struct gpio_desc *desc; @@ -154,6 +160,39 @@ struct i2c_hid { struct mutex reset_lock; }; +static const struct i2c_hid_quirks { + __u16 idVendor; + __u16 idProduct; + __u32 quirks; +} i2c_hid_quirks[] = { + { USB_VENDOR_ID_WEIDA, USB_DEVICE_ID_WEIDA_8752, + I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, + { USB_VENDOR_ID_WEIDA, USB_DEVICE_ID_WEIDA_8755, + I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, + { 0, 0 } +}; + +/* + * i2c_hid_lookup_quirk: return any quirks associated with a I2C HID device + * @idVendor: the 16-bit vendor ID + * @idProduct: the 16-bit product ID + * + * Returns: a u32 quirks value. + */ +static u32 i2c_hid_lookup_quirk(const u16 idVendor, const u16 idProduct) +{ + u32 quirks = 0; + int n; + + for (n = 0; i2c_hid_quirks[n].idVendor; n++) + if (i2c_hid_quirks[n].idVendor == idVendor && + (i2c_hid_quirks[n].idProduct == (__u16)HID_ANY_ID || + i2c_hid_quirks[n].idProduct == idProduct)) + quirks = i2c_hid_quirks[n].quirks; + + return quirks; +} + static int __i2c_hid_command(struct i2c_client *client, const struct i2c_hid_cmd *command, u8 reportID, u8 reportType, u8 *args, int args_len, @@ -346,11 +385,27 @@ static int i2c_hid_set_power(struct i2c_ i2c_hid_dbg(ihid, "%s\n", __func__); + /* + * Some devices require to send a command to wakeup before power on. + * The call will get a return value (EREMOTEIO) but device will be + * triggered and activated. After that, it goes like a normal device. + */ + if (power_state == I2C_HID_PWR_ON && + ihid->quirks & I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV) { + ret = i2c_hid_command(client, &hid_set_power_cmd, NULL, 0); + + /* Device was already activated */ + if (!ret) + goto set_pwr_exit; + } + ret = __i2c_hid_command(client, &hid_set_power_cmd, power_state, 0, NULL, 0, NULL, 0); + if (ret) dev_err(&client->dev, "failed to change power setting.\n"); +set_pwr_exit: return ret; } @@ -1050,6 +1105,8 @@ static int i2c_hid_probe(struct i2c_clie client->name, hid->vendor, hid->product); strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys)); + ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product); + ret = hid_add_device(hid); if (ret) { if (ret != -ENODEV) Patches currently in stable-queue which might be from gregkh@linuxfoundation.org are queue-4.9/staging-android-ashmem-lseek-failed-due-to-no-fmode_lseek.patch queue-4.9/sysfs-be-careful-of-error-returns-from-ops-show.patch queue-4.9/mips-flush-wrong-invalid-ftlb-entry-for-huge-page.patch queue-4.9/mips-end-spinlocks-with-.insn.patch queue-4.9/kvm-arm-arm64-fix-locking-for-kvm_free_stage2_pgd.patch queue-4.9/powerpc-disable-hfscr-if-tm-is-not-supported.patch queue-4.9/metag-usercopy-add-missing-fixups.patch queue-4.9/nios2-reserve-boot-memory-for-device-tree.patch queue-4.9/ring-buffer-fix-return-value-check-in-test_ringbuffer.patch queue-4.9/ppdev-check-before-attaching-port.patch queue-4.9/powerpc-64-fix-flush_-d-i-cache_range-called-from-modules.patch queue-4.9/drm-sun4i-tcon-move-soc-specific-quirks-to-a-dt-matched-data-structure.patch queue-4.9/acpi-gpio-do-not-fall-back-to-parsing-_crs-when-we-get-a-deferral.patch queue-4.9/metag-usercopy-add-early-abort-to-copy_to_user.patch queue-4.9/powerpc-crypto-crc32c-vpmsum-fix-missing-preempt_disable.patch queue-4.9/arm-arm64-kvm-take-mmap_sem-in-kvm_arch_prepare_memory_region.patch queue-4.9/mips-ralink-fix-typos-in-rt3883-pinctrl.patch queue-4.9/cfg80211-check-rdev-resume-callback-only-for-registered-wiphy.patch queue-4.9/metag-usercopy-set-flags-before-addz.patch queue-4.9/metag-usercopy-fix-src-fixup-in-from-user-rapf-loops.patch queue-4.9/drm-sun4i-add-compatible-string-for-a31-a31s-tcon-timing-controller.patch queue-4.9/xtensa-make-__pa-work-with-uncached-kseg-addresses.patch queue-4.9/clk-lpc32xx-add-a-quirk-for-pwm-and-ms-clock-dividers.patch queue-4.9/powerpc-mm-add-missing-global-tlb-invalidate-if-cxl-is-active.patch queue-4.9/brcmfmac-use-local-iftype-avoiding-use-after-free-of-virtual-interface.patch queue-4.9/drm-vmwgfx-remove-getparam-error-message.patch queue-4.9/mac80211-unconditionally-start-new-netdev-queues-with-itxq-support.patch queue-4.9/dm-verity-fec-fix-bufio-leaks.patch queue-4.9/drm-vmwgfx-type-check-lookups-of-fence-objects.patch queue-4.9/drm-sun4i-add-compatible-strings-for-a31-a31s-display-pipelines.patch queue-4.9/dm-verity-fec-limit-error-correction-recursion.patch queue-4.9/s390-uaccess-get_user-should-zero-on-failure-again.patch queue-4.9/dm-raid-fix-null-pointer-dereference-for-raid1-without-bitmap.patch queue-4.9/random-use-chacha20-for-get_random_int-long.patch queue-4.9/ptrace-fix-ptrace_listen-race-corrupting-task-state.patch queue-4.9/drm-vmwgfx-fix-integer-overflow-in-vmw_surface_define_ioctl.patch queue-4.9/hid-i2c-hid-add-a-simple-quirk-to-fix-device-defects.patch queue-4.9/s390-decompressor-fix-initrd-corruption-caused-by-bss-clear.patch queue-4.9/mips-check-tlb-before-handle_ri_rdhwr-for-loongson-3.patch queue-4.9/metag-usercopy-drop-unused-macros.patch queue-4.9/iio-bmg160-reset-chip-when-probing.patch queue-4.9/orangefs-move-features-validation-to-fix-filesystem-hang.patch queue-4.9/arm64-mm-unaligned-access-by-user-land-should-be-received-as-sigbus.patch queue-4.9/powerpc-don-t-try-to-fix-up-misaligned-load-with-reservation-instructions.patch queue-4.9/mips-lantiq-fix-missing-xbar-kernel-panic.patch queue-4.9/metag-usercopy-zero-rest-of-buffer-from-copy_from_user.patch queue-4.9/xfs-honor-falloc_fl_keep_size-when-punching-ends-of-files.patch queue-4.9/metag-usercopy-fix-alignment-error-checking.patch queue-4.9/reset-treeid-to-zero-on-smb2-tree_connect.patch queue-4.9/documentation-stable-kernel-rules-fix-stable-tag-format.patch queue-4.9/mm-mempolicy.c-fix-error-handling-in-set_mempolicy-and-mbind.patch queue-4.9/arm-arm64-kvm-take-mmap_sem-in-stage2_unmap_vm.patch queue-4.9/mm-page_alloc.c-fix-print-order-in-show_free_areas.patch queue-4.9/hid-usbhid-add-quirks-for-mayflash-dragonrise-gamecube-and-ps3-adapters.patch queue-4.9/mips-c-r4k-fix-loongson-3-s-vcache-scache-waysize-calculation.patch queue-4.9/drm-vmwgfx-avoid-calling-vzalloc-with-a-0-size-in-vmw_get_cap_3d_ioctl.patch queue-4.9/mips-force-o32-fp64-support-on-32bit-mips64r6-kernels.patch queue-4.9/mips-add-mips_cpu_ftlb-for-loongson-3a-r2.patch queue-4.9/kbuild-use-cc-disable-warning-consistently-for-maybe-uninitialized.patch queue-4.9/ppdev-fix-registering-same-device-name.patch queue-4.9/drm-ttm-drm-vmwgfx-relax-permission-checking-when-opening-surfaces.patch queue-4.9/drm-vmwgfx-null-pointer-dereference-in-vmw_surface_define_ioctl.patch