usbip_host_driver.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
  4. * 2005-2007 Takahiro Hirofuchi
  5. * Copyright (C) 2015-2016 Samsung Electronics
  6. * Igor Kotrasinski <i.kotrasinsk@samsung.com>
  7. * Krzysztof Opasiak <k.opasiak@samsung.com>
  8. */
  9. #include <unistd.h>
  10. #include <libudev.h>
  11. #include "usbip_host_common.h"
  12. #include "usbip_host_driver.h"
  13. #undef PROGNAME
  14. #define PROGNAME "libusbip"
  15. static int is_my_device(struct udev_device *dev)
  16. {
  17. const char *driver;
  18. driver = udev_device_get_driver(dev);
  19. return driver != NULL && !strcmp(driver, USBIP_HOST_DRV_NAME);
  20. }
  21. static int usbip_host_driver_open(struct usbip_host_driver *hdriver)
  22. {
  23. int ret;
  24. hdriver->ndevs = 0;
  25. INIT_LIST_HEAD(&hdriver->edev_list);
  26. ret = usbip_generic_driver_open(hdriver);
  27. if (ret)
  28. err("please load " USBIP_CORE_MOD_NAME ".ko and "
  29. USBIP_HOST_DRV_NAME ".ko!");
  30. return ret;
  31. }
  32. struct usbip_host_driver host_driver = {
  33. .edev_list = LIST_HEAD_INIT(host_driver.edev_list),
  34. .udev_subsystem = "usb",
  35. .ops = {
  36. .open = usbip_host_driver_open,
  37. .close = usbip_generic_driver_close,
  38. .refresh_device_list = usbip_generic_refresh_device_list,
  39. .get_device = usbip_generic_get_device,
  40. .read_device = read_usb_device,
  41. .read_interface = read_usb_interface,
  42. .is_my_device = is_my_device,
  43. },
  44. };