Lines Matching +full:i2c +full:- +full:hid
2 * HID over I2C protocol implementation
8 * This code is partly based on "USB HID support for Linux":
11 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
12 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
13 * Copyright (c) 2007-2008 Oliver Neukum
14 * Copyright (c) 2006-2010 Jiri Kosina
22 #include <linux/i2c.h>
37 #include <linux/hid.h>
43 #include "../hid-ids.h"
44 #include "i2c-hid.h"
72 #define i2c_hid_dbg(ihid, ...) dev_dbg(&(ihid)->client->dev, __VA_ARGS__)
93 struct i2c_client *client; /* i2c client */
94 struct hid_device *hid; /* pointer to corresponding HID dev */ member
95 struct i2c_hid_desc hdesc; /* the HID Descriptor */
96 __le16 wHIDDescRegister; /* location of the i2c
97 * register of the HID
99 unsigned int bufsize; /* i2c buffer size */
150 * i2c_hid_lookup_quirk: return any quirks associated with a I2C HID device
151 * @idVendor: the 16-bit vendor ID
152 * @idProduct: the 16-bit product ID
175 * Some STM-based devices need 400µs after a rising clock edge to wake in i2c_hid_probe_address()
180 ret = i2c_smbus_read_byte(ihid->client); in i2c_hid_probe_address()
183 ret = i2c_smbus_read_byte(ihid->client); in i2c_hid_probe_address()
191 struct i2c_client *client = ihid->client; in i2c_hid_xfer()
200 msgs[n].addr = client->addr; in i2c_hid_xfer()
201 msgs[n].flags = (client->flags & I2C_M_TEN) | I2C_M_DMA_SAFE; in i2c_hid_xfer()
208 msgs[n].addr = client->addr; in i2c_hid_xfer()
209 msgs[n].flags = (client->flags & I2C_M_TEN) | in i2c_hid_xfer()
216 ret = i2c_transfer(client->adapter, msgs, n); in i2c_hid_xfer()
219 return ret < 0 ? ret : -EIO; in i2c_hid_xfer()
227 guard(mutex)(&ihid->cmd_lock); in i2c_hid_read_register()
229 *(__le16 *)ihid->cmdbuf = reg; in i2c_hid_read_register()
231 return i2c_hid_xfer(ihid, ihid->cmdbuf, sizeof(__le16), buf, len); in i2c_hid_read_register()
261 guard(mutex)(&ihid->cmd_lock); in i2c_hid_get_report()
264 *(__le16 *)ihid->cmdbuf = ihid->hdesc.wCommandRegister; in i2c_hid_get_report()
267 length += i2c_hid_encode_command(ihid->cmdbuf + length, in i2c_hid_get_report()
275 put_unaligned_le16(le16_to_cpu(ihid->hdesc.wDataRegister), in i2c_hid_get_report()
276 ihid->cmdbuf + length); in i2c_hid_get_report()
283 error = i2c_hid_xfer(ihid, ihid->cmdbuf, length, in i2c_hid_get_report()
284 ihid->rawbuf, recv_len + sizeof(__le16)); in i2c_hid_get_report()
286 dev_err(&ihid->client->dev, in i2c_hid_get_report()
292 ret_count = le16_to_cpup((__le16 *)ihid->rawbuf); in i2c_hid_get_report()
298 recv_len = min(recv_len, ret_count - sizeof(__le16)); in i2c_hid_get_report()
299 memcpy(recv_buf, ihid->rawbuf + sizeof(__le16), recv_len); in i2c_hid_get_report()
302 dev_err(&ihid->client->dev, in i2c_hid_get_report()
305 return -EINVAL; in i2c_hid_get_report()
330 * @ihid: the i2c hid device
335 * @do_set: true: use SET_REPORT HID command, false: send plain OUTPUT report
347 if (data_len > ihid->bufsize) in i2c_hid_set_or_send_report()
348 return -EINVAL; in i2c_hid_set_or_send_report()
350 if (!do_set && le16_to_cpu(ihid->hdesc.wMaxOutputLength) == 0) in i2c_hid_set_or_send_report()
351 return -ENOSYS; in i2c_hid_set_or_send_report()
353 guard(mutex)(&ihid->cmd_lock); in i2c_hid_set_or_send_report()
357 *(__le16 *)ihid->cmdbuf = ihid->hdesc.wCommandRegister; in i2c_hid_set_or_send_report()
360 length += i2c_hid_encode_command(ihid->cmdbuf + length, in i2c_hid_set_or_send_report()
368 put_unaligned_le16(le16_to_cpu(ihid->hdesc.wDataRegister), in i2c_hid_set_or_send_report()
369 ihid->cmdbuf + length); in i2c_hid_set_or_send_report()
376 *(__le16 *)ihid->cmdbuf = ihid->hdesc.wOutputRegister; in i2c_hid_set_or_send_report()
380 length += i2c_hid_format_report(ihid->cmdbuf + length, in i2c_hid_set_or_send_report()
383 error = i2c_hid_xfer(ihid, ihid->cmdbuf, length, NULL, 0); in i2c_hid_set_or_send_report()
385 dev_err(&ihid->client->dev, in i2c_hid_set_or_send_report()
397 guard(mutex)(&ihid->cmd_lock); in i2c_hid_set_power_command()
400 *(__le16 *)ihid->cmdbuf = ihid->hdesc.wCommandRegister; in i2c_hid_set_power_command()
404 length += i2c_hid_encode_command(ihid->cmdbuf + length, in i2c_hid_set_power_command()
408 return i2c_hid_xfer(ihid, ihid->cmdbuf, length, NULL, 0); in i2c_hid_set_power_command()
419 dev_err(&ihid->client->dev, in i2c_hid_set_power()
423 * The HID over I2C specification states that if a DEVICE needs time in i2c_hid_set_power()
449 lockdep_assert_held(&ihid->reset_lock); in i2c_hid_start_hwreset()
455 scoped_guard(mutex, &ihid->cmd_lock) { in i2c_hid_start_hwreset()
457 *(__le16 *)ihid->cmdbuf = ihid->hdesc.wCommandRegister; in i2c_hid_start_hwreset()
460 length += i2c_hid_encode_command(ihid->cmdbuf + length, in i2c_hid_start_hwreset()
463 set_bit(I2C_HID_RESET_PENDING, &ihid->flags); in i2c_hid_start_hwreset()
465 ret = i2c_hid_xfer(ihid, ihid->cmdbuf, length, NULL, 0); in i2c_hid_start_hwreset()
467 dev_err(&ihid->client->dev, in i2c_hid_start_hwreset()
476 clear_bit(I2C_HID_RESET_PENDING, &ihid->flags); in i2c_hid_start_hwreset()
487 if (ihid->quirks & I2C_HID_QUIRK_NO_IRQ_AFTER_RESET) { in i2c_hid_finish_hwreset()
489 clear_bit(I2C_HID_RESET_PENDING, &ihid->flags); in i2c_hid_finish_hwreset()
490 } else if (!wait_event_timeout(ihid->wait, in i2c_hid_finish_hwreset()
491 !test_bit(I2C_HID_RESET_PENDING, &ihid->flags), in i2c_hid_finish_hwreset()
493 dev_warn(&ihid->client->dev, "device did not ack reset within 1000 ms\n"); in i2c_hid_finish_hwreset()
494 clear_bit(I2C_HID_RESET_PENDING, &ihid->flags); in i2c_hid_finish_hwreset()
499 if (!(ihid->quirks & I2C_HID_QUIRK_NO_WAKEUP_AFTER_RESET)) in i2c_hid_finish_hwreset()
507 u16 size = le16_to_cpu(ihid->hdesc.wMaxInputLength); in i2c_hid_get_input()
511 if (size > ihid->bufsize) in i2c_hid_get_input()
512 size = ihid->bufsize; in i2c_hid_get_input()
514 ret = i2c_master_recv(ihid->client, ihid->inbuf, size); in i2c_hid_get_input()
519 dev_err(&ihid->client->dev, "%s: got %d data instead of %d\n", in i2c_hid_get_input()
525 ret_size = le16_to_cpup((__le16 *)ihid->inbuf); in i2c_hid_get_input()
528 if (test_and_clear_bit(I2C_HID_RESET_PENDING, &ihid->flags)) in i2c_hid_get_input()
529 wake_up(&ihid->wait); in i2c_hid_get_input()
533 if ((ihid->quirks & I2C_HID_QUIRK_BOGUS_IRQ) && ret_size == 0xffff) { in i2c_hid_get_input()
534 dev_warn_once(&ihid->client->dev, in i2c_hid_get_input()
541 if (ihid->quirks & I2C_HID_QUIRK_BAD_INPUT_SIZE) { in i2c_hid_get_input()
542 *(__le16 *)ihid->inbuf = cpu_to_le16(size); in i2c_hid_get_input()
545 dev_err(&ihid->client->dev, in i2c_hid_get_input()
552 i2c_hid_dbg(ihid, "input: %*ph\n", ret_size, ihid->inbuf); in i2c_hid_get_input()
554 if (test_bit(I2C_HID_STARTED, &ihid->flags)) { in i2c_hid_get_input()
555 if (ihid->hid->group != HID_GROUP_RMI) in i2c_hid_get_input()
556 pm_wakeup_event(&ihid->client->dev, 0); in i2c_hid_get_input()
558 hid_input_report(ihid->hid, HID_INPUT_REPORT, in i2c_hid_get_input()
559 ihid->inbuf + sizeof(__le16), in i2c_hid_get_input()
560 ret_size - sizeof(__le16), 1); in i2c_hid_get_input()
577 return ((report->size - 1) >> 3) + 1 + in i2c_hid_get_report_length()
578 report->device->report_enum[report->type].numbered + 2; in i2c_hid_get_report_length()
584 static void i2c_hid_find_max_report(struct hid_device *hid, unsigned int type, in i2c_hid_find_max_report() argument
592 list_for_each_entry(report, &hid->report_enum[type].report_list, list) { in i2c_hid_find_max_report()
601 kfree(ihid->inbuf); in i2c_hid_free_buffers()
602 kfree(ihid->rawbuf); in i2c_hid_free_buffers()
603 kfree(ihid->cmdbuf); in i2c_hid_free_buffers()
604 ihid->inbuf = NULL; in i2c_hid_free_buffers()
605 ihid->rawbuf = NULL; in i2c_hid_free_buffers()
606 ihid->cmdbuf = NULL; in i2c_hid_free_buffers()
607 ihid->bufsize = 0; in i2c_hid_free_buffers()
625 ihid->inbuf = kzalloc(report_size, GFP_KERNEL); in i2c_hid_alloc_buffers()
626 ihid->rawbuf = kzalloc(report_size, GFP_KERNEL); in i2c_hid_alloc_buffers()
627 ihid->cmdbuf = kzalloc(cmd_len, GFP_KERNEL); in i2c_hid_alloc_buffers()
629 if (!ihid->inbuf || !ihid->rawbuf || !ihid->cmdbuf) { in i2c_hid_alloc_buffers()
631 return -ENOMEM; in i2c_hid_alloc_buffers()
634 ihid->bufsize = report_size; in i2c_hid_alloc_buffers()
639 static int i2c_hid_get_raw_report(struct hid_device *hid, in i2c_hid_get_raw_report() argument
643 struct i2c_client *client = hid->driver_data; in i2c_hid_get_raw_report()
648 return -EINVAL; in i2c_hid_get_raw_report()
658 count--; in i2c_hid_get_raw_report()
671 static int i2c_hid_output_raw_report(struct hid_device *hid, u8 report_type, in i2c_hid_output_raw_report() argument
674 struct i2c_client *client = hid->driver_data; in i2c_hid_output_raw_report()
680 return -EINVAL; in i2c_hid_output_raw_report()
682 mutex_lock(&ihid->reset_lock); in i2c_hid_output_raw_report()
693 report_id, buf + 1, count - 1, do_set); in i2c_hid_output_raw_report()
698 mutex_unlock(&ihid->reset_lock); in i2c_hid_output_raw_report()
703 static int i2c_hid_output_report(struct hid_device *hid, u8 *buf, size_t count) in i2c_hid_output_report() argument
705 return i2c_hid_output_raw_report(hid, HID_OUTPUT_REPORT, buf, count, in i2c_hid_output_report()
709 static int i2c_hid_raw_request(struct hid_device *hid, unsigned char reportnum, in i2c_hid_raw_request() argument
715 return i2c_hid_get_raw_report(hid, rtype, reportnum, buf, len); in i2c_hid_raw_request()
718 return -EINVAL; in i2c_hid_raw_request()
719 return i2c_hid_output_raw_report(hid, rtype, buf, len, true); in i2c_hid_raw_request()
721 return -EIO; in i2c_hid_raw_request()
725 static int i2c_hid_parse(struct hid_device *hid) in i2c_hid_parse() argument
727 struct i2c_client *client = hid->driver_data; in i2c_hid_parse()
729 struct i2c_hid_desc *hdesc = &ihid->hdesc; in i2c_hid_parse()
737 rsize = le16_to_cpu(hdesc->wReportDescLength); in i2c_hid_parse()
740 return -EINVAL; in i2c_hid_parse()
743 mutex_lock(&ihid->reset_lock); in i2c_hid_parse()
750 } while (tries-- > 0 && ret); in i2c_hid_parse()
751 mutex_unlock(&ihid->reset_lock); in i2c_hid_parse()
756 use_override = i2c_hid_get_dmi_hid_report_desc_override(client->name, in i2c_hid_parse()
761 i2c_hid_dbg(ihid, "Using a HID report descriptor override\n"); in i2c_hid_parse()
765 return -ENOMEM; in i2c_hid_parse()
767 i2c_hid_dbg(ihid, "asking HID report descriptor\n"); in i2c_hid_parse()
770 ihid->hdesc.wReportDescRegister, in i2c_hid_parse()
773 hid_err(hid, "reading report descriptor failed\n"); in i2c_hid_parse()
780 ret = hid_parse_report(hid, rdesc, rsize); in i2c_hid_parse()
791 static int i2c_hid_start(struct hid_device *hid) in i2c_hid_start() argument
793 struct i2c_client *client = hid->driver_data; in i2c_hid_start()
798 i2c_hid_find_max_report(hid, HID_INPUT_REPORT, &bufsize); in i2c_hid_start()
799 i2c_hid_find_max_report(hid, HID_OUTPUT_REPORT, &bufsize); in i2c_hid_start()
800 i2c_hid_find_max_report(hid, HID_FEATURE_REPORT, &bufsize); in i2c_hid_start()
802 if (bufsize > ihid->bufsize) { in i2c_hid_start()
803 disable_irq(client->irq); in i2c_hid_start()
807 enable_irq(client->irq); in i2c_hid_start()
816 static void i2c_hid_stop(struct hid_device *hid) in i2c_hid_stop() argument
818 hid->claimed = 0; in i2c_hid_stop()
821 static int i2c_hid_open(struct hid_device *hid) in i2c_hid_open() argument
823 struct i2c_client *client = hid->driver_data; in i2c_hid_open()
826 set_bit(I2C_HID_STARTED, &ihid->flags); in i2c_hid_open()
830 static void i2c_hid_close(struct hid_device *hid) in i2c_hid_close() argument
832 struct i2c_client *client = hid->driver_data; in i2c_hid_close()
835 clear_bit(I2C_HID_STARTED, &ihid->flags); in i2c_hid_close()
854 i2c_hid_dbg(ihid, "Requesting IRQ: %d\n", client->irq); in i2c_hid_init_irq()
856 if (!irq_get_trigger_type(client->irq)) in i2c_hid_init_irq()
859 ret = request_threaded_irq(client->irq, NULL, i2c_hid_irq, in i2c_hid_init_irq()
861 client->name, ihid); in i2c_hid_init_irq()
863 dev_warn(&client->dev, in i2c_hid_init_irq()
866 client->name, client->irq, ret); in i2c_hid_init_irq()
876 struct i2c_client *client = ihid->client; in i2c_hid_fetch_hid_descriptor()
877 struct i2c_hid_desc *hdesc = &ihid->hdesc; in i2c_hid_fetch_hid_descriptor()
881 /* i2c hid fetch using a fixed descriptor size (30 bytes) */ in i2c_hid_fetch_hid_descriptor()
882 if (i2c_hid_get_dmi_i2c_hid_desc_override(client->name)) { in i2c_hid_fetch_hid_descriptor()
883 i2c_hid_dbg(ihid, "Using a HID descriptor override\n"); in i2c_hid_fetch_hid_descriptor()
884 ihid->hdesc = in i2c_hid_fetch_hid_descriptor()
885 *i2c_hid_get_dmi_i2c_hid_desc_override(client->name); in i2c_hid_fetch_hid_descriptor()
887 i2c_hid_dbg(ihid, "Fetching the HID descriptor\n"); in i2c_hid_fetch_hid_descriptor()
889 ihid->wHIDDescRegister, in i2c_hid_fetch_hid_descriptor()
890 &ihid->hdesc, in i2c_hid_fetch_hid_descriptor()
891 sizeof(ihid->hdesc)); in i2c_hid_fetch_hid_descriptor()
893 dev_err(&ihid->client->dev, in i2c_hid_fetch_hid_descriptor()
894 "failed to fetch HID descriptor: %d\n", in i2c_hid_fetch_hid_descriptor()
896 return -ENODEV; in i2c_hid_fetch_hid_descriptor()
900 /* Validate the length of HID descriptor, the 4 first bytes: in i2c_hid_fetch_hid_descriptor()
901 * bytes 0-1 -> length in i2c_hid_fetch_hid_descriptor()
902 * bytes 2-3 -> bcdVersion (has to be 1.00) */ in i2c_hid_fetch_hid_descriptor()
904 if (le16_to_cpu(hdesc->bcdVersion) != 0x0100) { in i2c_hid_fetch_hid_descriptor()
905 dev_err(&ihid->client->dev, in i2c_hid_fetch_hid_descriptor()
906 "unexpected HID descriptor bcdVersion (0x%04hx)\n", in i2c_hid_fetch_hid_descriptor()
907 le16_to_cpu(hdesc->bcdVersion)); in i2c_hid_fetch_hid_descriptor()
908 return -ENODEV; in i2c_hid_fetch_hid_descriptor()
912 dsize = le16_to_cpu(hdesc->wHIDDescLength); in i2c_hid_fetch_hid_descriptor()
914 dev_err(&ihid->client->dev, in i2c_hid_fetch_hid_descriptor()
915 "weird size of HID descriptor (%u)\n", dsize); in i2c_hid_fetch_hid_descriptor()
916 return -ENODEV; in i2c_hid_fetch_hid_descriptor()
918 i2c_hid_dbg(ihid, "HID Descriptor: %*ph\n", dsize, &ihid->hdesc); in i2c_hid_fetch_hid_descriptor()
924 if (!ihid->ops->power_up) in i2c_hid_core_power_up()
927 return ihid->ops->power_up(ihid->ops); in i2c_hid_core_power_up()
932 if (!ihid->ops->power_down) in i2c_hid_core_power_down()
935 ihid->ops->power_down(ihid->ops); in i2c_hid_core_power_down()
940 if (!ihid->ops->shutdown_tail) in i2c_hid_core_shutdown_tail()
943 ihid->ops->shutdown_tail(ihid->ops); in i2c_hid_core_shutdown_tail()
948 struct i2c_client *client = ihid->client; in i2c_hid_core_suspend()
949 struct hid_device *hid = ihid->hid; in i2c_hid_core_suspend() local
952 ret = hid_driver_suspend(hid, PMSG_SUSPEND); in i2c_hid_core_suspend()
957 if (!(ihid->quirks & I2C_HID_QUIRK_NO_SLEEP_ON_SUSPEND)) in i2c_hid_core_suspend()
960 disable_irq(client->irq); in i2c_hid_core_suspend()
962 if (force_poweroff || !device_may_wakeup(&client->dev)) in i2c_hid_core_suspend()
970 struct i2c_client *client = ihid->client; in i2c_hid_core_resume()
971 struct hid_device *hid = ihid->hid; in i2c_hid_core_resume() local
974 if (!device_may_wakeup(&client->dev)) in i2c_hid_core_resume()
977 enable_irq(client->irq); in i2c_hid_core_resume()
982 dev_err(&client->dev, "nothing at address after resume: %d\n", in i2c_hid_core_resume()
984 return -ENXIO; in i2c_hid_core_resume()
991 if (ihid->quirks & I2C_HID_QUIRK_DELAY_WAKEUP_AFTER_RESUME) in i2c_hid_core_resume()
1002 if (ihid->quirks & I2C_HID_QUIRK_RESET_ON_RESUME) { in i2c_hid_core_resume()
1003 mutex_lock(&ihid->reset_lock); in i2c_hid_core_resume()
1007 mutex_unlock(&ihid->reset_lock); in i2c_hid_core_resume()
1015 return hid_driver_reset_resume(hid); in i2c_hid_core_resume()
1019 * Check that the device exists and parse the HID descriptor.
1023 struct i2c_client *client = ihid->client; in __i2c_hid_core_probe()
1024 struct hid_device *hid = ihid->hid; in __i2c_hid_core_probe() local
1030 return -ENXIO; in __i2c_hid_core_probe()
1035 dev_err(&client->dev, in __i2c_hid_core_probe()
1036 "Failed to fetch the HID Descriptor\n"); in __i2c_hid_core_probe()
1040 hid->version = le16_to_cpu(ihid->hdesc.bcdVersion); in __i2c_hid_core_probe()
1041 hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID); in __i2c_hid_core_probe()
1042 hid->product = le16_to_cpu(ihid->hdesc.wProductID); in __i2c_hid_core_probe()
1044 hid->initial_quirks |= i2c_hid_get_dmi_quirks(hid->vendor, in __i2c_hid_core_probe()
1045 hid->product); in __i2c_hid_core_probe()
1047 snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X", in __i2c_hid_core_probe()
1048 client->name, (u16)hid->vendor, (u16)hid->product); in __i2c_hid_core_probe()
1049 strscpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys)); in __i2c_hid_core_probe()
1051 ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product); in __i2c_hid_core_probe()
1058 struct i2c_client *client = ihid->client; in i2c_hid_core_register_hid()
1059 struct hid_device *hid = ihid->hid; in i2c_hid_core_register_hid() local
1062 enable_irq(client->irq); in i2c_hid_core_register_hid()
1064 ret = hid_add_device(hid); in i2c_hid_core_register_hid()
1066 if (ret != -ENODEV) in i2c_hid_core_register_hid()
1067 hid_err(client, "can't add hid device: %d\n", ret); in i2c_hid_core_register_hid()
1068 disable_irq(client->irq); in i2c_hid_core_register_hid()
1103 struct hid_device *hid = ihid->hid; in ihid_core_panel_prepare_work() local
1107 * hid->version is set on the first power up. If it's still zero then in ihid_core_panel_prepare_work()
1111 if (!hid->version) in ihid_core_panel_prepare_work()
1117 dev_warn(&ihid->client->dev, "Power on failed: %d\n", ret); in ihid_core_panel_prepare_work()
1119 WRITE_ONCE(ihid->prepare_work_finished, true); in ihid_core_panel_prepare_work()
1141 WRITE_ONCE(ihid->prepare_work_finished, false); in i2c_hid_core_panel_prepared()
1142 schedule_work(&ihid->panel_follower_prepare_work); in i2c_hid_core_panel_prepared()
1151 cancel_work_sync(&ihid->panel_follower_prepare_work); in i2c_hid_core_panel_unpreparing()
1155 if (!READ_ONCE(ihid->prepare_work_finished)) in i2c_hid_core_panel_unpreparing()
1168 struct device *dev = &ihid->client->dev; in i2c_hid_core_register_panel_follower()
1171 ihid->panel_follower.funcs = &i2c_hid_core_panel_follower_funcs; in i2c_hid_core_register_panel_follower()
1183 ret = drm_panel_add_follower(dev, &ihid->panel_follower); in i2c_hid_core_register_panel_follower()
1195 struct hid_device *hid; in i2c_hid_core_probe() local
1197 dbg_hid("HID probe called for i2c 0x%02x\n", client->addr); in i2c_hid_core_probe()
1199 if (!client->irq) { in i2c_hid_core_probe()
1200 dev_err(&client->dev, in i2c_hid_core_probe()
1201 "HID over i2c has not been provided an Int IRQ\n"); in i2c_hid_core_probe()
1202 return -EINVAL; in i2c_hid_core_probe()
1205 if (client->irq < 0) { in i2c_hid_core_probe()
1206 if (client->irq != -EPROBE_DEFER) in i2c_hid_core_probe()
1207 dev_err(&client->dev, in i2c_hid_core_probe()
1208 "HID over i2c doesn't have a valid IRQ\n"); in i2c_hid_core_probe()
1209 return client->irq; in i2c_hid_core_probe()
1212 ihid = devm_kzalloc(&client->dev, sizeof(*ihid), GFP_KERNEL); in i2c_hid_core_probe()
1214 return -ENOMEM; in i2c_hid_core_probe()
1218 ihid->ops = ops; in i2c_hid_core_probe()
1219 ihid->client = client; in i2c_hid_core_probe()
1220 ihid->wHIDDescRegister = cpu_to_le16(hid_descriptor_address); in i2c_hid_core_probe()
1221 ihid->is_panel_follower = drm_is_panel_follower(&client->dev); in i2c_hid_core_probe()
1223 init_waitqueue_head(&ihid->wait); in i2c_hid_core_probe()
1224 mutex_init(&ihid->cmd_lock); in i2c_hid_core_probe()
1225 mutex_init(&ihid->reset_lock); in i2c_hid_core_probe()
1226 INIT_WORK(&ihid->panel_follower_prepare_work, ihid_core_panel_prepare_work); in i2c_hid_core_probe()
1234 device_enable_async_suspend(&client->dev); in i2c_hid_core_probe()
1236 hid = hid_allocate_device(); in i2c_hid_core_probe()
1237 if (IS_ERR(hid)) { in i2c_hid_core_probe()
1238 ret = PTR_ERR(hid); in i2c_hid_core_probe()
1242 ihid->hid = hid; in i2c_hid_core_probe()
1244 hid->driver_data = client; in i2c_hid_core_probe()
1245 hid->ll_driver = &i2c_hid_ll_driver; in i2c_hid_core_probe()
1246 hid->dev.parent = &client->dev; in i2c_hid_core_probe()
1247 hid->bus = BUS_I2C; in i2c_hid_core_probe()
1248 hid->initial_quirks = quirks; in i2c_hid_core_probe()
1251 if (!ihid->is_panel_follower) { in i2c_hid_core_probe()
1269 if (ihid->is_panel_follower) in i2c_hid_core_probe()
1279 free_irq(client->irq, ihid); in i2c_hid_core_probe()
1281 if (!ihid->is_panel_follower) in i2c_hid_core_probe()
1284 hid_destroy_device(hid); in i2c_hid_core_probe()
1295 struct hid_device *hid; in i2c_hid_core_remove() local
1301 if (ihid->is_panel_follower) in i2c_hid_core_remove()
1302 drm_panel_remove_follower(&ihid->panel_follower); in i2c_hid_core_remove()
1306 hid = ihid->hid; in i2c_hid_core_remove()
1307 hid_destroy_device(hid); in i2c_hid_core_remove()
1309 free_irq(client->irq, ihid); in i2c_hid_core_remove()
1311 if (ihid->bufsize) in i2c_hid_core_remove()
1321 free_irq(client->irq, ihid); in i2c_hid_core_shutdown()
1332 if (ihid->is_panel_follower) in i2c_hid_core_pm_suspend()
1343 if (ihid->is_panel_follower) in i2c_hid_core_pm_resume()
1354 MODULE_DESCRIPTION("HID over I2C core driver");