Merge branch 'for-6.3/multitouch' into for-linus
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>
Wed, 22 Feb 2023 09:39:05 +0000 (10:39 +0100)
committerBenjamin Tissoires <benjamin.tissoires@redhat.com>
Wed, 22 Feb 2023 09:39:05 +0000 (10:39 +0100)
Allow to pass quirks from i2c-hid to hid-multitouch (Allen Ballway &
Dmitry Torokhov)

1  2 
drivers/hid/hid-quirks.c
drivers/hid/i2c-hid/i2c-hid-core.c
include/linux/hid.h

diff --combined drivers/hid/hid-quirks.c
@@@ -54,6 -54,7 +54,6 @@@ static const struct hid_device_id hid_q
        { HID_USB_DEVICE(USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE), HID_QUIRK_NOGET },
        { HID_USB_DEVICE(USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_PEDALS), HID_QUIRK_NOGET },
        { HID_USB_DEVICE(USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_PRO_THROTTLE), HID_QUIRK_NOGET },
 -      { HID_USB_DEVICE(USB_VENDOR_ID_CHERRY, USB_DEVICE_ID_CHERRY_MOUSE_000C), HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K65RGB), HID_QUIRK_NO_INIT_REPORTS },
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K65RGB_RAPIDFIRE), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K70RGB), HID_QUIRK_NO_INIT_REPORTS },
@@@ -393,8 -394,7 +393,8 @@@ static const struct hid_device_id hid_h
        { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1URBK) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1DRBK) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1URBK) },
 -      { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1DRBK) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1DRBK_010D) },
 +      { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1DRBK_011C) },
  #endif
  #if IS_ENABLED(CONFIG_HID_ELO)
        { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) },
@@@ -1237,7 -1237,7 +1237,7 @@@ EXPORT_SYMBOL_GPL(hid_quirks_exit)
  static unsigned long hid_gets_squirk(const struct hid_device *hdev)
  {
        const struct hid_device_id *bl_entry;
-       unsigned long quirks = 0;
+       unsigned long quirks = hdev->initial_quirks;
  
        if (hid_match_id(hdev, hid_ignore_list))
                quirks |= HID_QUIRK_IGNORE;
  #define I2C_HID_PWR_ON                0x00
  #define I2C_HID_PWR_SLEEP     0x01
  
 -/* debug option */
 -static bool debug;
 -module_param(debug, bool, 0444);
 -MODULE_PARM_DESC(debug, "print a lot of debug information");
 -
 -#define i2c_hid_dbg(ihid, fmt, arg...)                                          \
 -do {                                                                    \
 -      if (debug)                                                        \
 -              dev_printk(KERN_DEBUG, &(ihid)->client->dev, fmt, ##arg); \
 -} while (0)
 +#define i2c_hid_dbg(ihid, ...) dev_dbg(&(ihid)->client->dev, __VA_ARGS__)
  
  struct i2c_hid_desc {
        __le16 wHIDDescLength;
@@@ -833,7 -842,7 +833,7 @@@ static void i2c_hid_close(struct hid_de
        clear_bit(I2C_HID_STARTED, &ihid->flags);
  }
  
 -struct hid_ll_driver i2c_hid_ll_driver = {
 +static const struct hid_ll_driver i2c_hid_ll_driver = {
        .parse = i2c_hid_parse,
        .start = i2c_hid_start,
        .stop = i2c_hid_stop,
        .output_report = i2c_hid_output_report,
        .raw_request = i2c_hid_raw_request,
  };
 -EXPORT_SYMBOL_GPL(i2c_hid_ll_driver);
  
  static int i2c_hid_init_irq(struct i2c_client *client)
  {
        unsigned long irqflags = 0;
        int ret;
  
 -      dev_dbg(&client->dev, "Requesting IRQ: %d\n", client->irq);
 +      i2c_hid_dbg(ihid, "Requesting IRQ: %d\n", client->irq);
  
        if (!irq_get_trigger_type(client->irq))
                irqflags = IRQF_TRIGGER_LOW;
@@@ -993,7 -1003,7 +993,7 @@@ int i2c_hid_core_probe(struct i2c_clien
        /* Make sure there is something at this address */
        ret = i2c_smbus_read_byte(client);
        if (ret < 0) {
 -              dev_dbg(&client->dev, "nothing at this address: %d\n", ret);
 +              i2c_hid_dbg(ihid, "nothing at this address: %d\n", ret);
                ret = -ENXIO;
                goto err_powered;
        }
        hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID);
        hid->product = le16_to_cpu(ihid->hdesc.wProductID);
  
+       hid->initial_quirks = quirks;
+       hid->initial_quirks |= i2c_hid_get_dmi_quirks(hid->vendor,
+                                                     hid->product);
        snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X",
                 client->name, (u16)hid->vendor, (u16)hid->product);
        strscpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
                goto err_mem_free;
        }
  
-       hid->quirks |= quirks;
        return 0;
  
  err_mem_free:
diff --combined include/linux/hid.h
@@@ -312,7 -312,6 +312,7 @@@ struct hid_item 
  #define HID_DG_LATENCYMODE    0x000d0060
  
  #define HID_BAT_ABSOLUTESTATEOFCHARGE 0x00850065
 +#define HID_BAT_CHARGING              0x00850044
  
  #define HID_VD_ASUS_CUSTOM_MEDIA_KEYS 0xff310076
  
@@@ -596,7 -595,7 +596,7 @@@ struct hid_device {                                                        /* device rep
        struct device dev;                                              /* device */
        struct hid_driver *driver;
  
 -      struct hid_ll_driver *ll_driver;
 +      const struct hid_ll_driver *ll_driver;
        struct mutex ll_open_lock;
        unsigned int ll_open_count;
  
        __s32 battery_max;
        __s32 battery_report_type;
        __s32 battery_report_id;
 +      __s32 battery_charge_status;
        enum hid_battery_status battery_status;
        bool battery_avoid_query;
        ktime_t battery_ratelimit_time;
        unsigned long status;                                           /* see STAT flags above */
        unsigned claimed;                                               /* Claimed by hidinput, hiddev? */
        unsigned quirks;                                                /* Various quirks the device can pull on us */
+       unsigned initial_quirks;                                        /* Initial set of quirks supplied when creating device */
        bool io_started;                                                /* If IO has started */
  
        struct list_head inputs;                                        /* The list of inputs */
@@@ -855,7 -854,21 +856,7 @@@ struct hid_ll_driver 
        bool (*may_wakeup)(struct hid_device *hdev);
  };
  
 -extern struct hid_ll_driver i2c_hid_ll_driver;
 -extern struct hid_ll_driver hidp_hid_driver;
 -extern struct hid_ll_driver uhid_hid_driver;
 -extern struct hid_ll_driver usb_hid_driver;
 -
 -static inline bool hid_is_using_ll_driver(struct hid_device *hdev,
 -              struct hid_ll_driver *driver)
 -{
 -      return hdev->ll_driver == driver;
 -}
 -
 -static inline bool hid_is_usb(struct hid_device *hdev)
 -{
 -      return hid_is_using_ll_driver(hdev, &usb_hid_driver);
 -}
 +extern bool hid_is_usb(const struct hid_device *hdev);
  
  #define       PM_HINT_FULLON  1<<5
  #define PM_HINT_NORMAL        1<<1
  
  /* HID core API */
  
 -extern int hid_debug;
 -
  extern bool hid_ignore(struct hid_device *);
  extern int hid_add_device(struct hid_device *);
  extern void hid_destroy_device(struct hid_device *);
@@@ -1177,7 -1192,11 +1178,7 @@@ int hid_pidff_init(struct hid_device *h
  #define hid_pidff_init NULL
  #endif
  
 -#define dbg_hid(fmt, ...)                                             \
 -do {                                                                  \
 -      if (hid_debug)                                                  \
 -              printk(KERN_DEBUG "%s: " fmt, __FILE__, ##__VA_ARGS__); \
 -} while (0)
 +#define dbg_hid(fmt, ...) pr_debug("%s: " fmt, __FILE__, ##__VA_ARGS__)
  
  #define hid_err(hid, fmt, ...)                                \
        dev_err(&(hid)->dev, fmt, ##__VA_ARGS__)