Lines Matching refs:hdev
155 struct hid_device *hdev; member
174 struct hid_device *hdev = dev->hdev; in cp2112_gpio_direction_input() local
178 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, in cp2112_gpio_direction_input()
182 hid_err(hdev, "error requesting GPIO config: %d\n", ret); in cp2112_gpio_direction_input()
189 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, sizeof(buf), in cp2112_gpio_direction_input()
192 hid_err(hdev, "error setting GPIO config: %d\n", ret); in cp2112_gpio_direction_input()
203 struct hid_device *hdev = dev->hdev; in cp2112_gpio_set() local
211 ret = hid_hw_raw_request(hdev, CP2112_GPIO_SET, buf, sizeof(buf), in cp2112_gpio_set()
214 hid_err(hdev, "error setting GPIO values: %d\n", ret); in cp2112_gpio_set()
221 struct hid_device *hdev = dev->hdev; in cp2112_gpio_get() local
225 ret = hid_hw_raw_request(hdev, CP2112_GPIO_GET, buf, sizeof(buf), in cp2112_gpio_get()
228 hid_err(hdev, "error requesting GPIO values: %d\n", ret); in cp2112_gpio_get()
240 struct hid_device *hdev = dev->hdev; in cp2112_gpio_direction_output() local
244 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, in cp2112_gpio_direction_output()
248 hid_err(hdev, "error requesting GPIO config: %d\n", ret); in cp2112_gpio_direction_output()
255 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, sizeof(buf), in cp2112_gpio_direction_output()
258 hid_err(hdev, "error setting GPIO config: %d\n", ret); in cp2112_gpio_direction_output()
271 static int cp2112_hid_get(struct hid_device *hdev, unsigned char report_number, in cp2112_hid_get() argument
281 ret = hid_hw_raw_request(hdev, report_number, buf, count, in cp2112_hid_get()
288 static int cp2112_hid_output(struct hid_device *hdev, u8 *data, size_t count, in cp2112_hid_output() argument
299 ret = hid_hw_output_report(hdev, buf, count); in cp2112_hid_output()
301 ret = hid_hw_raw_request(hdev, buf[0], buf, count, report_type, in cp2112_hid_output()
333 struct hid_device *hdev = dev->hdev; in cp2112_xfer_status() local
341 ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT); in cp2112_xfer_status()
343 hid_warn(hdev, "Error requesting status: %d\n", ret); in cp2112_xfer_status()
356 struct hid_device *hdev = dev->hdev; in cp2112_read() local
367 ret = cp2112_hid_output(hdev, &report.report, sizeof(report), in cp2112_read()
370 hid_warn(hdev, "Error requesting data: %d\n", ret); in cp2112_read()
378 hid_dbg(hdev, "read %d of %zd bytes requested\n", in cp2112_read()
472 struct hid_device *hdev = dev->hdev; in cp2112_i2c_xfer() local
480 hid_dbg(hdev, "I2C %d messages\n", num); in cp2112_i2c_xfer()
484 hid_dbg(hdev, "I2C read %#04x len %d\n", in cp2112_i2c_xfer()
490 hid_dbg(hdev, "I2C write %#04x len %d\n", in cp2112_i2c_xfer()
501 hid_dbg(hdev, "I2C write-read %#04x wlen %d rlen %d\n", in cp2112_i2c_xfer()
510 hid_err(hdev, in cp2112_i2c_xfer()
515 ret = hid_hw_power(hdev, PM_HINT_FULLON); in cp2112_i2c_xfer()
517 hid_err(hdev, "power management error: %d\n", ret); in cp2112_i2c_xfer()
521 ret = cp2112_hid_output(hdev, buf, count, HID_OUTPUT_REPORT); in cp2112_i2c_xfer()
523 hid_warn(hdev, "Error starting transaction: %d\n", ret); in cp2112_i2c_xfer()
537 hid_warn(hdev, "Transfer timed out, cancelling.\n"); in cp2112_i2c_xfer()
541 ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT); in cp2112_i2c_xfer()
543 hid_warn(hdev, "Error cancelling transaction: %d\n", in cp2112_i2c_xfer()
555 hid_err(hdev, "read returned 0\n"); in cp2112_i2c_xfer()
569 hid_err(hdev, "long read: %d > %zd\n", in cp2112_i2c_xfer()
580 hid_hw_power(hdev, PM_HINT_NORMAL); in cp2112_i2c_xfer()
581 hid_dbg(hdev, "I2C transfer finished: %d\n", ret); in cp2112_i2c_xfer()
590 struct hid_device *hdev = dev->hdev; in cp2112_xfer() local
598 hid_dbg(hdev, "%s addr 0x%x flags 0x%x cmd 0x%x size %d\n", in cp2112_xfer()
665 hid_warn(hdev, "Unsupported transaction %d\n", size); in cp2112_xfer()
672 ret = hid_hw_power(hdev, PM_HINT_FULLON); in cp2112_xfer()
674 hid_err(hdev, "power management error: %d\n", ret); in cp2112_xfer()
678 ret = cp2112_hid_output(hdev, buf, count, HID_OUTPUT_REPORT); in cp2112_xfer()
680 hid_warn(hdev, "Error starting transaction: %d\n", ret); in cp2112_xfer()
694 hid_warn(hdev, "Transfer timed out, cancelling.\n"); in cp2112_xfer()
698 ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT); in cp2112_xfer()
700 hid_warn(hdev, "Error cancelling transaction: %d\n", in cp2112_xfer()
719 hid_warn(hdev, "short read: %d < %zd\n", ret, read_length); in cp2112_xfer()
744 hid_hw_power(hdev, PM_HINT_NORMAL); in cp2112_xfer()
745 hid_dbg(hdev, "transfer finished: %d\n", ret); in cp2112_xfer()
767 static int cp2112_get_usb_config(struct hid_device *hdev, in cp2112_get_usb_config() argument
772 ret = cp2112_hid_get(hdev, CP2112_USB_CONFIG, (u8 *)cfg, sizeof(*cfg), in cp2112_get_usb_config()
775 hid_err(hdev, "error reading usb config: %d\n", ret); in cp2112_get_usb_config()
784 static int cp2112_set_usb_config(struct hid_device *hdev, in cp2112_set_usb_config() argument
791 ret = cp2112_hid_output(hdev, (u8 *)cfg, sizeof(*cfg), in cp2112_set_usb_config()
794 hid_err(hdev, "error writing usb config: %d\n", ret); in cp2112_set_usb_config()
803 static void chmod_sysfs_attrs(struct hid_device *hdev);
810 struct hid_device *hdev = container_of(kdev, struct hid_device, dev); \
812 int ret = cp2112_get_usb_config(hdev, &cfg); \
816 ret = cp2112_set_usb_config(hdev, &cfg); \
819 chmod_sysfs_attrs(hdev); \
825 struct hid_device *hdev = container_of(kdev, struct hid_device, dev); \
827 int ret = cp2112_get_usb_config(hdev, &cfg); \
890 struct hid_device *hdev = container_of(kdev, struct hid_device, dev); in pstr_store() local
904 ret = cp2112_hid_output(hdev, &report.report, report.length + 1, in pstr_store()
907 hid_err(hdev, "error writing %s string: %d\n", kattr->attr.name, in pstr_store()
914 chmod_sysfs_attrs(hdev); in pstr_store()
921 struct hid_device *hdev = container_of(kdev, struct hid_device, dev); in pstr_show() local
928 ret = cp2112_hid_get(hdev, attr->report, &report.report, in pstr_show()
931 hid_err(hdev, "error reading %s string: %d\n", kattr->attr.name, in pstr_show()
939 hid_err(hdev, "invalid %s string length: %d\n", in pstr_show()
984 static void chmod_sysfs_attrs(struct hid_device *hdev) in chmod_sysfs_attrs() argument
990 ret = cp2112_hid_get(hdev, CP2112_LOCK_BYTE, buf, sizeof(buf), in chmod_sysfs_attrs()
993 hid_err(hdev, "error reading lock byte: %d\n", ret); in chmod_sysfs_attrs()
999 ret = sysfs_chmod_file(&hdev->dev.kobj, *attr, mode); in chmod_sysfs_attrs()
1001 hid_err(hdev, "error chmoding sysfs file %s\n", in chmod_sysfs_attrs()
1007 static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) in cp2112_probe() argument
1014 ret = hid_parse(hdev); in cp2112_probe()
1016 hid_err(hdev, "parse failed\n"); in cp2112_probe()
1020 ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); in cp2112_probe()
1022 hid_err(hdev, "hw start failed\n"); in cp2112_probe()
1026 ret = hid_hw_open(hdev); in cp2112_probe()
1028 hid_err(hdev, "hw open failed\n"); in cp2112_probe()
1032 ret = hid_hw_power(hdev, PM_HINT_FULLON); in cp2112_probe()
1034 hid_err(hdev, "power management error: %d\n", ret); in cp2112_probe()
1038 ret = cp2112_hid_get(hdev, CP2112_GET_VERSION_INFO, buf, sizeof(buf), in cp2112_probe()
1041 hid_err(hdev, "error requesting version\n"); in cp2112_probe()
1047 hid_info(hdev, "Part Number: 0x%02X Device Version: 0x%02X\n", in cp2112_probe()
1050 ret = cp2112_hid_get(hdev, CP2112_SMBUS_CONFIG, (u8 *)&config, in cp2112_probe()
1053 hid_err(hdev, "error requesting SMBus config\n"); in cp2112_probe()
1061 ret = cp2112_hid_output(hdev, (u8 *)&config, sizeof(config), in cp2112_probe()
1064 hid_err(hdev, "error setting SMBus config\n"); in cp2112_probe()
1076 hid_set_drvdata(hdev, (void *)dev); in cp2112_probe()
1077 dev->hdev = hdev; in cp2112_probe()
1082 dev->adap.dev.parent = &hdev->dev; in cp2112_probe()
1084 "CP2112 SMBus Bridge on hiddev%d", hdev->minor); in cp2112_probe()
1088 hid_device_io_start(hdev); in cp2112_probe()
1090 hid_device_io_stop(hdev); in cp2112_probe()
1093 hid_err(hdev, "error registering i2c adapter\n"); in cp2112_probe()
1097 hid_dbg(hdev, "adapter registered\n"); in cp2112_probe()
1107 dev->gc.dev = &hdev->dev; in cp2112_probe()
1111 hid_err(hdev, "error registering gpio chip\n"); in cp2112_probe()
1115 ret = sysfs_create_group(&hdev->dev.kobj, &cp2112_attr_group); in cp2112_probe()
1117 hid_err(hdev, "error creating sysfs attrs\n"); in cp2112_probe()
1121 chmod_sysfs_attrs(hdev); in cp2112_probe()
1122 hid_hw_power(hdev, PM_HINT_NORMAL); in cp2112_probe()
1133 hid_hw_power(hdev, PM_HINT_NORMAL); in cp2112_probe()
1135 hid_hw_close(hdev); in cp2112_probe()
1137 hid_hw_stop(hdev); in cp2112_probe()
1141 static void cp2112_remove(struct hid_device *hdev) in cp2112_remove() argument
1143 struct cp2112_device *dev = hid_get_drvdata(hdev); in cp2112_remove()
1145 sysfs_remove_group(&hdev->dev.kobj, &cp2112_attr_group); in cp2112_remove()
1154 hid_hw_close(hdev); in cp2112_remove()
1155 hid_hw_stop(hdev); in cp2112_remove()
1159 static int cp2112_raw_event(struct hid_device *hdev, struct hid_report *report, in cp2112_raw_event() argument
1162 struct cp2112_device *dev = hid_get_drvdata(hdev); in cp2112_raw_event()
1167 hid_dbg(hdev, "xfer status: %02x %02x %04x %04x\n", in cp2112_raw_event()
1200 hid_dbg(hdev, "read response: %02x %02x\n", data[1], data[2]); in cp2112_raw_event()
1210 hid_err(hdev, "unknown report\n"); in cp2112_raw_event()