Path: blob/master/tools/usb/usbip/libsrc/usbip_host_driver.c
26292 views
// SPDX-License-Identifier: GPL-2.0-or-later1/*2* Copyright (C) 2011 matt mooney <[email protected]>3* 2005-2007 Takahiro Hirofuchi4* Copyright (C) 2015-2016 Samsung Electronics5* Igor Kotrasinski <[email protected]>6* Krzysztof Opasiak <[email protected]>7*/89#include <unistd.h>10#include <libudev.h>1112#include "usbip_host_common.h"13#include "usbip_host_driver.h"1415#undef PROGNAME16#define PROGNAME "libusbip"1718static int is_my_device(struct udev_device *dev)19{20const char *driver;2122driver = udev_device_get_driver(dev);23return driver != NULL && !strcmp(driver, USBIP_HOST_DRV_NAME);24}2526static int usbip_host_driver_open(struct usbip_host_driver *hdriver)27{28int ret;2930hdriver->ndevs = 0;31INIT_LIST_HEAD(&hdriver->edev_list);3233ret = usbip_generic_driver_open(hdriver);34if (ret)35err("please load " USBIP_CORE_MOD_NAME ".ko and "36USBIP_HOST_DRV_NAME ".ko!");37return ret;38}3940struct usbip_host_driver host_driver = {41.edev_list = LIST_HEAD_INIT(host_driver.edev_list),42.udev_subsystem = "usb",43.ops = {44.open = usbip_host_driver_open,45.close = usbip_generic_driver_close,46.refresh_device_list = usbip_generic_refresh_device_list,47.get_device = usbip_generic_get_device,48.read_device = read_usb_device,49.read_interface = read_usb_interface,50.is_my_device = is_my_device,51},52};535455