1*1ccea77eSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2588b48caSValentina Manea /*
3588b48caSValentina Manea * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
4588b48caSValentina Manea * 2005-2007 Takahiro Hirofuchi
53391ba0eSKrzysztof Opasiak * Copyright (C) 2015-2016 Samsung Electronics
63391ba0eSKrzysztof Opasiak * Igor Kotrasinski <i.kotrasinsk@samsung.com>
73391ba0eSKrzysztof Opasiak * Krzysztof Opasiak <k.opasiak@samsung.com>
8588b48caSValentina Manea */
9588b48caSValentina Manea
10588b48caSValentina Manea #include <unistd.h>
11588b48caSValentina Manea #include <libudev.h>
12588b48caSValentina Manea
133391ba0eSKrzysztof Opasiak #include "usbip_host_common.h"
14588b48caSValentina Manea #include "usbip_host_driver.h"
15588b48caSValentina Manea
16588b48caSValentina Manea #undef PROGNAME
17588b48caSValentina Manea #define PROGNAME "libusbip"
18588b48caSValentina Manea
is_my_device(struct udev_device * dev)193391ba0eSKrzysztof Opasiak static int is_my_device(struct udev_device *dev)
20588b48caSValentina Manea {
21588b48caSValentina Manea const char *driver;
22588b48caSValentina Manea
23588b48caSValentina Manea driver = udev_device_get_driver(dev);
243391ba0eSKrzysztof Opasiak return driver != NULL && !strcmp(driver, USBIP_HOST_DRV_NAME);
25588b48caSValentina Manea }
26588b48caSValentina Manea
usbip_host_driver_open(struct usbip_host_driver * hdriver)273391ba0eSKrzysztof Opasiak static int usbip_host_driver_open(struct usbip_host_driver *hdriver)
28588b48caSValentina Manea {
29588b48caSValentina Manea int ret;
30588b48caSValentina Manea
313391ba0eSKrzysztof Opasiak hdriver->ndevs = 0;
323391ba0eSKrzysztof Opasiak INIT_LIST_HEAD(&hdriver->edev_list);
33588b48caSValentina Manea
343391ba0eSKrzysztof Opasiak ret = usbip_generic_driver_open(hdriver);
353391ba0eSKrzysztof Opasiak if (ret)
363391ba0eSKrzysztof Opasiak err("please load " USBIP_CORE_MOD_NAME ".ko and "
373391ba0eSKrzysztof Opasiak USBIP_HOST_DRV_NAME ".ko!");
38588b48caSValentina Manea return ret;
39588b48caSValentina Manea }
40588b48caSValentina Manea
413391ba0eSKrzysztof Opasiak struct usbip_host_driver host_driver = {
423391ba0eSKrzysztof Opasiak .edev_list = LIST_HEAD_INIT(host_driver.edev_list),
433391ba0eSKrzysztof Opasiak .udev_subsystem = "usb",
443391ba0eSKrzysztof Opasiak .ops = {
453391ba0eSKrzysztof Opasiak .open = usbip_host_driver_open,
463391ba0eSKrzysztof Opasiak .close = usbip_generic_driver_close,
473391ba0eSKrzysztof Opasiak .refresh_device_list = usbip_generic_refresh_device_list,
483391ba0eSKrzysztof Opasiak .get_device = usbip_generic_get_device,
493391ba0eSKrzysztof Opasiak .read_device = read_usb_device,
503391ba0eSKrzysztof Opasiak .read_interface = read_usb_interface,
513391ba0eSKrzysztof Opasiak .is_my_device = is_my_device,
523391ba0eSKrzysztof Opasiak },
533391ba0eSKrzysztof Opasiak };
54