Lines Matching defs:hdev

159 	struct hid_device *hdev;
184 struct hid_device *hdev = dev->hdev;
190 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
194 hid_err(hdev, "error requesting GPIO config: %d\n", ret);
203 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
207 hid_err(hdev, "error setting GPIO config: %d\n", ret);
223 struct hid_device *hdev = dev->hdev;
233 ret = hid_hw_raw_request(hdev, CP2112_GPIO_SET, buf,
237 hid_err(hdev, "error setting GPIO values: %d\n", ret);
245 struct hid_device *hdev = dev->hdev;
251 ret = hid_hw_raw_request(hdev, CP2112_GPIO_GET, buf,
255 hid_err(hdev, "error requesting GPIO values: %d\n", ret);
283 struct hid_device *hdev = dev->hdev;
289 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
293 hid_err(hdev, "error requesting GPIO config: %d\n", ret);
300 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
304 hid_err(hdev, "error setting GPIO config: %d\n", ret);
323 static int cp2112_hid_get(struct hid_device *hdev, unsigned char report_number,
333 ret = hid_hw_raw_request(hdev, report_number, buf, count,
340 static int cp2112_hid_output(struct hid_device *hdev, u8 *data, size_t count,
351 ret = hid_hw_output_report(hdev, buf, count);
353 ret = hid_hw_raw_request(hdev, buf[0], buf, count, report_type,
385 struct hid_device *hdev = dev->hdev;
393 ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT);
395 hid_warn(hdev, "Error requesting status: %d\n", ret);
408 struct hid_device *hdev = dev->hdev;
419 ret = cp2112_hid_output(hdev, &report.report, sizeof(report),
422 hid_warn(hdev, "Error requesting data: %d\n", ret);
430 hid_dbg(hdev, "read %d of %zd bytes requested\n",
524 struct hid_device *hdev = dev->hdev;
532 hid_dbg(hdev, "I2C %d messages\n", num);
535 hid_dbg(hdev, "I2C %s %#04x len %d\n",
551 hid_dbg(hdev, "I2C write-read %#04x wlen %d rlen %d\n",
560 hid_err(hdev,
565 ret = hid_hw_power(hdev, PM_HINT_FULLON);
567 hid_err(hdev, "power management error: %d\n", ret);
571 ret = cp2112_hid_output(hdev, buf, count, HID_OUTPUT_REPORT);
573 hid_warn(hdev, "Error starting transaction: %d\n", ret);
587 hid_warn(hdev, "Transfer timed out, cancelling.\n");
591 ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT);
593 hid_warn(hdev, "Error cancelling transaction: %d\n",
605 hid_err(hdev, "read returned 0\n");
619 hid_err(hdev, "long read: %d > %zd\n",
630 hid_hw_power(hdev, PM_HINT_NORMAL);
631 hid_dbg(hdev, "I2C transfer finished: %d\n", ret);
640 struct hid_device *hdev = dev->hdev;
648 hid_dbg(hdev, "%s addr 0x%x flags 0x%x cmd 0x%x size %d\n",
723 hid_warn(hdev, "Unsupported transaction %d\n", size);
730 ret = hid_hw_power(hdev, PM_HINT_FULLON);
732 hid_err(hdev, "power management error: %d\n", ret);
736 ret = cp2112_hid_output(hdev, buf, count, HID_OUTPUT_REPORT);
738 hid_warn(hdev, "Error starting transaction: %d\n", ret);
752 hid_warn(hdev, "Transfer timed out, cancelling.\n");
756 ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT);
758 hid_warn(hdev, "Error cancelling transaction: %d\n",
777 hid_warn(hdev, "short read: %d < %zd\n", ret, read_length);
810 hid_hw_power(hdev, PM_HINT_NORMAL);
811 hid_dbg(hdev, "transfer finished: %d\n", ret);
833 static int cp2112_get_usb_config(struct hid_device *hdev,
838 ret = cp2112_hid_get(hdev, CP2112_USB_CONFIG, (u8 *)cfg, sizeof(*cfg),
841 hid_err(hdev, "error reading usb config: %d\n", ret);
850 static int cp2112_set_usb_config(struct hid_device *hdev,
857 ret = cp2112_hid_output(hdev, (u8 *)cfg, sizeof(*cfg),
860 hid_err(hdev, "error writing usb config: %d\n", ret);
869 static void chmod_sysfs_attrs(struct hid_device *hdev);
876 struct hid_device *hdev = to_hid_device(kdev); \
878 int ret = cp2112_get_usb_config(hdev, &cfg); \
882 ret = cp2112_set_usb_config(hdev, &cfg); \
885 chmod_sysfs_attrs(hdev); \
891 struct hid_device *hdev = to_hid_device(kdev); \
893 int ret = cp2112_get_usb_config(hdev, &cfg); \
950 struct hid_device *hdev = to_hid_device(kdev);
962 ret = cp2112_hid_output(hdev, &report.report, report.length + 1,
965 hid_err(hdev, "error writing %s string: %d\n", kattr->attr.name,
972 chmod_sysfs_attrs(hdev);
979 struct hid_device *hdev = to_hid_device(kdev);
984 ret = cp2112_hid_get(hdev, number, (u8 *)&report.contents,
987 hid_err(hdev, "error reading %s string: %d\n", kattr->attr.name,
995 hid_err(hdev, "invalid %s string length: %d\n",
1046 static void chmod_sysfs_attrs(struct hid_device *hdev)
1052 ret = cp2112_hid_get(hdev, CP2112_LOCK_BYTE, buf, sizeof(buf),
1055 hid_err(hdev, "error reading lock byte: %d\n", ret);
1061 ret = sysfs_chmod_file(&hdev->dev.kobj, *attr, mode);
1063 hid_err(hdev, "error chmoding sysfs file %s\n",
1193 static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
1201 dev = devm_kzalloc(&hdev->dev, sizeof(*dev), GFP_KERNEL);
1205 dev->in_out_buffer = devm_kzalloc(&hdev->dev, CP2112_REPORT_MAX_LENGTH,
1212 ret = hid_parse(hdev);
1214 hid_err(hdev, "parse failed\n");
1218 ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
1220 hid_err(hdev, "hw start failed\n");
1224 ret = hid_hw_open(hdev);
1226 hid_err(hdev, "hw open failed\n");
1230 ret = hid_hw_power(hdev, PM_HINT_FULLON);
1232 hid_err(hdev, "power management error: %d\n", ret);
1236 ret = cp2112_hid_get(hdev, CP2112_GET_VERSION_INFO, buf, sizeof(buf),
1239 hid_err(hdev, "error requesting version\n");
1245 hid_info(hdev, "Part Number: 0x%02X Device Version: 0x%02X\n",
1248 ret = cp2112_hid_get(hdev, CP2112_SMBUS_CONFIG, (u8 *)&config,
1251 hid_err(hdev, "error requesting SMBus config\n");
1259 ret = cp2112_hid_output(hdev, (u8 *)&config, sizeof(config),
1262 hid_err(hdev, "error setting SMBus config\n");
1268 hid_set_drvdata(hdev, (void *)dev);
1269 dev->hdev = hdev;
1274 dev->adap.dev.parent = &hdev->dev;
1277 ((struct hidraw *)hdev->hidraw)->minor);
1281 hid_device_io_start(hdev);
1283 hid_device_io_stop(hdev);
1286 hid_err(hdev, "error registering i2c adapter\n");
1290 hid_dbg(hdev, "adapter registered\n");
1300 dev->gc.parent = &hdev->dev;
1316 hid_err(hdev, "error registering gpio chip\n");
1320 ret = sysfs_create_group(&hdev->dev.kobj, &cp2112_attr_group);
1322 hid_err(hdev, "error creating sysfs attrs\n");
1326 chmod_sysfs_attrs(hdev);
1327 hid_hw_power(hdev, PM_HINT_NORMAL);
1336 hid_hw_power(hdev, PM_HINT_NORMAL);
1338 hid_hw_close(hdev);
1340 hid_hw_stop(hdev);
1344 static void cp2112_remove(struct hid_device *hdev)
1346 struct cp2112_device *dev = hid_get_drvdata(hdev);
1348 sysfs_remove_group(&hdev->dev.kobj, &cp2112_attr_group);
1363 hid_hw_close(hdev);
1364 hid_hw_stop(hdev);
1367 static int cp2112_raw_event(struct hid_device *hdev, struct hid_report *report,
1370 struct cp2112_device *dev = hid_get_drvdata(hdev);
1375 hid_dbg(hdev, "xfer status: %02x %02x %04x %04x\n",
1408 hid_dbg(hdev, "read response: %02x %02x\n", data[1], data[2]);
1418 hid_err(hdev, "unknown report\n");