Lines Matching defs:hdev

155 	struct hid_device *hdev;
182 struct hid_device *hdev = dev->hdev;
188 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
192 hid_err(hdev, "error requesting GPIO config: %d\n", ret);
201 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
205 hid_err(hdev, "error setting GPIO config: %d\n", ret);
221 struct hid_device *hdev = dev->hdev;
231 ret = hid_hw_raw_request(hdev, CP2112_GPIO_SET, buf,
235 hid_err(hdev, "error setting GPIO values: %d\n", ret);
243 struct hid_device *hdev = dev->hdev;
249 ret = hid_hw_raw_request(hdev, CP2112_GPIO_GET, buf,
253 hid_err(hdev, "error requesting GPIO values: %d\n", ret);
281 struct hid_device *hdev = dev->hdev;
287 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
291 hid_err(hdev, "error requesting GPIO config: %d\n", ret);
298 ret = hid_hw_raw_request(hdev, CP2112_GPIO_CONFIG, buf,
302 hid_err(hdev, "error setting GPIO config: %d\n", ret);
321 static int cp2112_hid_get(struct hid_device *hdev, unsigned char report_number,
331 ret = hid_hw_raw_request(hdev, report_number, buf, count,
338 static int cp2112_hid_output(struct hid_device *hdev, u8 *data, size_t count,
349 ret = hid_hw_output_report(hdev, buf, count);
351 ret = hid_hw_raw_request(hdev, buf[0], buf, count, report_type,
383 struct hid_device *hdev = dev->hdev;
391 ret = cp2112_hid_output(hdev, buf, 2, HID_OUTPUT_REPORT);
393 hid_warn(hdev, "Error requesting status: %d\n", ret);
406 struct hid_device *hdev = dev->hdev;
417 ret = cp2112_hid_output(hdev, &report.report, sizeof(report),
420 hid_warn(hdev, "Error requesting data: %d\n", ret);
428 hid_dbg(hdev, "read %d of %zd bytes requested\n",
522 struct hid_device *hdev = dev->hdev;
530 hid_dbg(hdev, "I2C %d messages\n", num);
534 hid_dbg(hdev, "I2C read %#04x len %d\n",
540 hid_dbg(hdev, "I2C write %#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); \
956 struct hid_device *hdev = to_hid_device(kdev);
970 ret = cp2112_hid_output(hdev, &report.report, report.length + 1,
973 hid_err(hdev, "error writing %s string: %d\n", kattr->attr.name,
980 chmod_sysfs_attrs(hdev);
987 struct hid_device *hdev = to_hid_device(kdev);
994 ret = cp2112_hid_get(hdev, attr->report, &report.report,
997 hid_err(hdev, "error reading %s string: %d\n", kattr->attr.name,
1005 hid_err(hdev, "invalid %s string length: %d\n",
1050 static void chmod_sysfs_attrs(struct hid_device *hdev)
1056 ret = cp2112_hid_get(hdev, CP2112_LOCK_BYTE, buf, sizeof(buf),
1059 hid_err(hdev, "error reading lock byte: %d\n", ret);
1065 ret = sysfs_chmod_file(&hdev->dev.kobj, *attr, mode);
1067 hid_err(hdev, "error chmoding sysfs file %s\n",
1230 static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
1238 dev = devm_kzalloc(&hdev->dev, sizeof(*dev), GFP_KERNEL);
1242 dev->in_out_buffer = devm_kzalloc(&hdev->dev, CP2112_REPORT_MAX_LENGTH,
1249 ret = hid_parse(hdev);
1251 hid_err(hdev, "parse failed\n");
1255 ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
1257 hid_err(hdev, "hw start failed\n");
1261 ret = hid_hw_open(hdev);
1263 hid_err(hdev, "hw open failed\n");
1267 ret = hid_hw_power(hdev, PM_HINT_FULLON);
1269 hid_err(hdev, "power management error: %d\n", ret);
1273 ret = cp2112_hid_get(hdev, CP2112_GET_VERSION_INFO, buf, sizeof(buf),
1276 hid_err(hdev, "error requesting version\n");
1282 hid_info(hdev, "Part Number: 0x%02X Device Version: 0x%02X\n",
1285 ret = cp2112_hid_get(hdev, CP2112_SMBUS_CONFIG, (u8 *)&config,
1288 hid_err(hdev, "error requesting SMBus config\n");
1296 ret = cp2112_hid_output(hdev, (u8 *)&config, sizeof(config),
1299 hid_err(hdev, "error setting SMBus config\n");
1305 hid_set_drvdata(hdev, (void *)dev);
1306 dev->hdev = hdev;
1311 dev->adap.dev.parent = &hdev->dev;
1314 ((struct hidraw *)hdev->hidraw)->minor);
1318 hid_device_io_start(hdev);
1320 hid_device_io_stop(hdev);
1323 hid_err(hdev, "error registering i2c adapter\n");
1327 hid_dbg(hdev, "adapter registered\n");
1337 dev->gc.parent = &hdev->dev;
1362 hid_err(hdev, "error registering gpio chip\n");
1366 ret = sysfs_create_group(&hdev->dev.kobj, &cp2112_attr_group);
1368 hid_err(hdev, "error creating sysfs attrs\n");
1372 chmod_sysfs_attrs(hdev);
1373 hid_hw_power(hdev, PM_HINT_NORMAL);
1382 hid_hw_power(hdev, PM_HINT_NORMAL);
1384 hid_hw_close(hdev);
1386 hid_hw_stop(hdev);
1390 static void cp2112_remove(struct hid_device *hdev)
1392 struct cp2112_device *dev = hid_get_drvdata(hdev);
1395 sysfs_remove_group(&hdev->dev.kobj, &cp2112_attr_group);
1415 hid_hw_close(hdev);
1416 hid_hw_stop(hdev);
1419 static int cp2112_raw_event(struct hid_device *hdev, struct hid_report *report,
1422 struct cp2112_device *dev = hid_get_drvdata(hdev);
1427 hid_dbg(hdev, "xfer status: %02x %02x %04x %04x\n",
1460 hid_dbg(hdev, "read response: %02x %02x\n", data[1], data[2]);
1470 hid_err(hdev, "unknown report\n");