usbip_host_driver.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
  3. * 2005-2007 Takahiro Hirofuchi
  4. * Copyright (C) 2015-2016 Samsung Electronics
  5. * Igor Kotrasinski <i.kotrasinsk@samsung.com>
  6. * Krzysztof Opasiak <k.opasiak@samsung.com>
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <unistd.h>
  22. #include <libudev.h>
  23. #include "usbip_host_common.h"
  24. #include "usbip_host_driver.h"
  25. #undef PROGNAME
  26. #define PROGNAME "libusbip"
  27. static int is_my_device(struct udev_device *dev)
  28. {
  29. const char *driver;
  30. driver = udev_device_get_driver(dev);
  31. return driver != NULL && !strcmp(driver, USBIP_HOST_DRV_NAME);
  32. }
  33. static int usbip_host_driver_open(struct usbip_host_driver *hdriver)
  34. {
  35. int ret;
  36. hdriver->ndevs = 0;
  37. INIT_LIST_HEAD(&hdriver->edev_list);
  38. ret = usbip_generic_driver_open(hdriver);
  39. if (ret)
  40. err("please load " USBIP_CORE_MOD_NAME ".ko and "
  41. USBIP_HOST_DRV_NAME ".ko!");
  42. return ret;
  43. }
  44. struct usbip_host_driver host_driver = {
  45. .edev_list = LIST_HEAD_INIT(host_driver.edev_list),
  46. .udev_subsystem = "usb",
  47. .ops = {
  48. .open = usbip_host_driver_open,
  49. .close = usbip_generic_driver_close,
  50. .refresh_device_list = usbip_generic_refresh_device_list,
  51. .get_device = usbip_generic_get_device,
  52. .read_device = read_usb_device,
  53. .read_interface = read_usb_interface,
  54. .is_my_device = is_my_device,
  55. },
  56. };