Lines Matching refs:hdev
155 struct hid_device *hdev; member
173 struct hid_device *hdev = dev->hdev; in cp2112_gpio_direction_input() local
177 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, in cp2112_gpio_direction_input()
181 hid_err(hdev, "error requesting GPIO config: %d\n", ret); in cp2112_gpio_direction_input()
188 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, sizeof(buf), in cp2112_gpio_direction_input()
191 hid_err(hdev, "error setting GPIO config: %d\n", ret); in cp2112_gpio_direction_input()
202 struct hid_device *hdev = dev->hdev; in cp2112_gpio_set() local
210 ret = hid_hw_raw_request(hdev, CP2112_GPIO_SET, buf, sizeof(buf), in cp2112_gpio_set()
213 hid_err(hdev, "error setting GPIO values: %d\n", ret); in cp2112_gpio_set()
220 struct hid_device *hdev = dev->hdev; in cp2112_gpio_get() local
224 ret = hid_hw_raw_request(hdev, CP2112_GPIO_GET, buf, sizeof(buf), in cp2112_gpio_get()
227 hid_err(hdev, "error requesting GPIO values: %d\n", ret); in cp2112_gpio_get()
239 struct hid_device *hdev = dev->hdev; in cp2112_gpio_direction_output() local
243 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, in cp2112_gpio_direction_output()
247 hid_err(hdev, "error requesting GPIO config: %d\n", ret); in cp2112_gpio_direction_output()
254 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf, sizeof(buf), in cp2112_gpio_direction_output()
257 hid_err(hdev, "error setting GPIO config: %d\n", ret); in cp2112_gpio_direction_output()
270 static int cp2112_hid_get(struct hid_device *hdev, unsigned char report_number, in cp2112_hid_get() argument
280 ret = hid_hw_raw_request(hdev, report_number, buf, count, in cp2112_hid_get()
287 static int cp2112_hid_output(struct hid_device *hdev, u8 *data, size_t count, in cp2112_hid_output() argument
298 ret = hid_hw_output_report(hdev, buf, count); in cp2112_hid_output()
300 ret = hid_hw_raw_request(hdev, buf[0], buf, count, report_type, in cp2112_hid_output()
332 struct hid_device *hdev = dev->hdev; in cp2112_xfer_status() local
340 ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT); in cp2112_xfer_status()
342 hid_warn(hdev, "Error requesting status: %d\n", ret); in cp2112_xfer_status()
355 struct hid_device *hdev = dev->hdev; in cp2112_read() local
366 ret = cp2112_hid_output(hdev, &report.report, sizeof(report), in cp2112_read()
369 hid_warn(hdev, "Error requesting data: %d\n", ret); in cp2112_read()
377 hid_dbg(hdev, "read %d of %zd bytes requested\n", in cp2112_read()
453 struct hid_device *hdev = dev->hdev; in cp2112_i2c_xfer() local
459 hid_dbg(hdev, "I2C %d messages\n", num); in cp2112_i2c_xfer()
462 hid_err(hdev, in cp2112_i2c_xfer()
476 ret = hid_hw_power(hdev, PM_HINT_FULLON); in cp2112_i2c_xfer()
478 hid_err(hdev, "power management error: %d\n", ret); in cp2112_i2c_xfer()
482 ret = cp2112_hid_output(hdev, buf, count, HID_OUTPUT_REPORT); in cp2112_i2c_xfer()
484 hid_warn(hdev, "Error starting transaction: %d\n", ret); in cp2112_i2c_xfer()
498 hid_warn(hdev, "Transfer timed out, cancelling.\n"); in cp2112_i2c_xfer()
502 ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT); in cp2112_i2c_xfer()
504 hid_warn(hdev, "Error cancelling transaction: %d\n", in cp2112_i2c_xfer()
518 hid_warn(hdev, "short read: %d < %d\n", ret, msgs->len); in cp2112_i2c_xfer()
528 hid_hw_power(hdev, PM_HINT_NORMAL); in cp2112_i2c_xfer()
529 hid_dbg(hdev, "I2C transfer finished: %d\n", ret); in cp2112_i2c_xfer()
538 struct hid_device *hdev = dev->hdev; in cp2112_xfer() local
546 hid_dbg(hdev, "%s addr 0x%x flags 0x%x cmd 0x%x size %d\n", in cp2112_xfer()
613 hid_warn(hdev, "Unsupported transaction %d\n", size); in cp2112_xfer()
620 ret = hid_hw_power(hdev, PM_HINT_FULLON); in cp2112_xfer()
622 hid_err(hdev, "power management error: %d\n", ret); in cp2112_xfer()
626 ret = cp2112_hid_output(hdev, buf, count, HID_OUTPUT_REPORT); in cp2112_xfer()
628 hid_warn(hdev, "Error starting transaction: %d\n", ret); in cp2112_xfer()
642 hid_warn(hdev, "Transfer timed out, cancelling.\n"); in cp2112_xfer()
646 ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT); in cp2112_xfer()
648 hid_warn(hdev, "Error cancelling transaction: %d\n", in cp2112_xfer()
667 hid_warn(hdev, "short read: %d < %zd\n", ret, read_length); in cp2112_xfer()
692 hid_hw_power(hdev, PM_HINT_NORMAL); in cp2112_xfer()
693 hid_dbg(hdev, "transfer finished: %d\n", ret); in cp2112_xfer()
715 static int cp2112_get_usb_config(struct hid_device *hdev, in cp2112_get_usb_config() argument
720 ret = cp2112_hid_get(hdev, CP2112_USB_CONFIG, (u8 *)cfg, sizeof(*cfg), in cp2112_get_usb_config()
723 hid_err(hdev, "error reading usb config: %d\n", ret); in cp2112_get_usb_config()
732 static int cp2112_set_usb_config(struct hid_device *hdev, in cp2112_set_usb_config() argument
739 ret = cp2112_hid_output(hdev, (u8 *)cfg, sizeof(*cfg), in cp2112_set_usb_config()
742 hid_err(hdev, "error writing usb config: %d\n", ret); in cp2112_set_usb_config()
751 static void chmod_sysfs_attrs(struct hid_device *hdev);
758 struct hid_device *hdev = container_of(kdev, struct hid_device, dev); \
760 int ret = cp2112_get_usb_config(hdev, &cfg); \
764 ret = cp2112_set_usb_config(hdev, &cfg); \
767 chmod_sysfs_attrs(hdev); \
773 struct hid_device *hdev = container_of(kdev, struct hid_device, dev); \
775 int ret = cp2112_get_usb_config(hdev, &cfg); \
838 struct hid_device *hdev = container_of(kdev, struct hid_device, dev); in pstr_store() local
852 ret = cp2112_hid_output(hdev, &report.report, report.length + 1, in pstr_store()
855 hid_err(hdev, "error writing %s string: %d\n", kattr->attr.name, in pstr_store()
862 chmod_sysfs_attrs(hdev); in pstr_store()
869 struct hid_device *hdev = container_of(kdev, struct hid_device, dev); in pstr_show() local
876 ret = cp2112_hid_get(hdev, attr->report, &report.report, in pstr_show()
879 hid_err(hdev, "error reading %s string: %d\n", kattr->attr.name, in pstr_show()
887 hid_err(hdev, "invalid %s string length: %d\n", in pstr_show()
932 static void chmod_sysfs_attrs(struct hid_device *hdev) in chmod_sysfs_attrs() argument
938 ret = cp2112_hid_get(hdev, CP2112_LOCK_BYTE, buf, sizeof(buf), in chmod_sysfs_attrs()
941 hid_err(hdev, "error reading lock byte: %d\n", ret); in chmod_sysfs_attrs()
947 ret = sysfs_chmod_file(&hdev->dev.kobj, *attr, mode); in chmod_sysfs_attrs()
949 hid_err(hdev, "error chmoding sysfs file %s\n", in chmod_sysfs_attrs()
955 static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) in cp2112_probe() argument
962 ret = hid_parse(hdev); in cp2112_probe()
964 hid_err(hdev, "parse failed\n"); in cp2112_probe()
968 ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); in cp2112_probe()
970 hid_err(hdev, "hw start failed\n"); in cp2112_probe()
974 ret = hid_hw_open(hdev); in cp2112_probe()
976 hid_err(hdev, "hw open failed\n"); in cp2112_probe()
980 ret = hid_hw_power(hdev, PM_HINT_FULLON); in cp2112_probe()
982 hid_err(hdev, "power management error: %d\n", ret); in cp2112_probe()
986 ret = cp2112_hid_get(hdev, CP2112_GET_VERSION_INFO, buf, sizeof(buf), in cp2112_probe()
989 hid_err(hdev, "error requesting version\n"); in cp2112_probe()
995 hid_info(hdev, "Part Number: 0x%02X Device Version: 0x%02X\n", in cp2112_probe()
998 ret = cp2112_hid_get(hdev, CP2112_SMBUS_CONFIG, (u8 *)&config, in cp2112_probe()
1001 hid_err(hdev, "error requesting SMBus config\n"); in cp2112_probe()
1009 ret = cp2112_hid_output(hdev, (u8 *)&config, sizeof(config), in cp2112_probe()
1012 hid_err(hdev, "error setting SMBus config\n"); in cp2112_probe()
1024 hid_set_drvdata(hdev, (void *)dev); in cp2112_probe()
1025 dev->hdev = hdev; in cp2112_probe()
1030 dev->adap.dev.parent = &hdev->dev; in cp2112_probe()
1032 "CP2112 SMBus Bridge on hiddev%d", hdev->minor); in cp2112_probe()
1035 hid_device_io_start(hdev); in cp2112_probe()
1037 hid_device_io_stop(hdev); in cp2112_probe()
1040 hid_err(hdev, "error registering i2c adapter\n"); in cp2112_probe()
1044 hid_dbg(hdev, "adapter registered\n"); in cp2112_probe()
1054 dev->gc.dev = &hdev->dev; in cp2112_probe()
1058 hid_err(hdev, "error registering gpio chip\n"); in cp2112_probe()
1062 ret = sysfs_create_group(&hdev->dev.kobj, &cp2112_attr_group); in cp2112_probe()
1064 hid_err(hdev, "error creating sysfs attrs\n"); in cp2112_probe()
1068 chmod_sysfs_attrs(hdev); in cp2112_probe()
1069 hid_hw_power(hdev, PM_HINT_NORMAL); in cp2112_probe()
1080 hid_hw_power(hdev, PM_HINT_NORMAL); in cp2112_probe()
1082 hid_hw_close(hdev); in cp2112_probe()
1084 hid_hw_stop(hdev); in cp2112_probe()
1088 static void cp2112_remove(struct hid_device *hdev) in cp2112_remove() argument
1090 struct cp2112_device *dev = hid_get_drvdata(hdev); in cp2112_remove()
1092 sysfs_remove_group(&hdev->dev.kobj, &cp2112_attr_group); in cp2112_remove()
1101 hid_hw_close(hdev); in cp2112_remove()
1102 hid_hw_stop(hdev); in cp2112_remove()
1106 static int cp2112_raw_event(struct hid_device *hdev, struct hid_report *report, in cp2112_raw_event() argument
1109 struct cp2112_device *dev = hid_get_drvdata(hdev); in cp2112_raw_event()
1114 hid_dbg(hdev, "xfer status: %02x %02x %04x %04x\n", in cp2112_raw_event()
1147 hid_dbg(hdev, "read response: %02x %02x\n", data[1], data[2]); in cp2112_raw_event()
1157 hid_err(hdev, "unknown report\n"); in cp2112_raw_event()