linux/tools/usb/usbip/libsrc/usbip_host_driver.c
<<
>>
Prefs
   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
  22#include <unistd.h>
  23#include <libudev.h>
  24
  25#include "usbip_host_common.h"
  26#include "usbip_host_driver.h"
  27
  28#undef  PROGNAME
  29#define PROGNAME "libusbip"
  30
  31static int is_my_device(struct udev_device *dev)
  32{
  33        const char *driver;
  34
  35        driver = udev_device_get_driver(dev);
  36        return driver != NULL && !strcmp(driver, USBIP_HOST_DRV_NAME);
  37}
  38
  39static int usbip_host_driver_open(struct usbip_host_driver *hdriver)
  40{
  41        int ret;
  42
  43        hdriver->ndevs = 0;
  44        INIT_LIST_HEAD(&hdriver->edev_list);
  45
  46        ret = usbip_generic_driver_open(hdriver);
  47        if (ret)
  48                err("please load " USBIP_CORE_MOD_NAME ".ko and "
  49                    USBIP_HOST_DRV_NAME ".ko!");
  50        return ret;
  51}
  52
  53struct usbip_host_driver host_driver = {
  54        .edev_list = LIST_HEAD_INIT(host_driver.edev_list),
  55        .udev_subsystem = "usb",
  56        .ops = {
  57                .open = usbip_host_driver_open,
  58                .close = usbip_generic_driver_close,
  59                .refresh_device_list = usbip_generic_refresh_device_list,
  60                .get_device = usbip_generic_get_device,
  61                .read_device = read_usb_device,
  62                .read_interface = read_usb_interface,
  63                .is_my_device = is_my_device,
  64        },
  65};
  66