~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/usb/usbip/libsrc/usbip_host_common.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-or-later */
  2 /*
  3  * Copyright (C) 2015-2016 Samsung Electronics
  4  *               Igor Kotrasinski <i.kotrasinsk@samsung.com>
  5  *               Krzysztof Opasiak <k.opasiak@samsung.com>
  6  *
  7  * Refactored from usbip_host_driver.c, which is:
  8  * Copyright (C) 2011 matt mooney <mfm@muteddisk.com>
  9  *               2005-2007 Takahiro Hirofuchi
 10  */
 11 
 12 #ifndef __USBIP_HOST_COMMON_H
 13 #define __USBIP_HOST_COMMON_H
 14 
 15 #include <stdint.h>
 16 #include <libudev.h>
 17 #include <errno.h>
 18 #include "list.h"
 19 #include "usbip_common.h"
 20 #include "sysfs_utils.h"
 21 
 22 struct usbip_host_driver;
 23 
 24 struct usbip_host_driver_ops {
 25         int (*open)(struct usbip_host_driver *hdriver);
 26         void (*close)(struct usbip_host_driver *hdriver);
 27         int (*refresh_device_list)(struct usbip_host_driver *hdriver);
 28         struct usbip_exported_device * (*get_device)(
 29                 struct usbip_host_driver *hdriver, int num);
 30 
 31         int (*read_device)(struct udev_device *sdev,
 32                            struct usbip_usb_device *dev);
 33         int (*read_interface)(struct usbip_usb_device *udev, int i,
 34                               struct usbip_usb_interface *uinf);
 35         int (*is_my_device)(struct udev_device *udev);
 36 };
 37 
 38 struct usbip_host_driver {
 39         int ndevs;
 40         /* list of exported device */
 41         struct list_head edev_list;
 42         const char *udev_subsystem;
 43         struct usbip_host_driver_ops ops;
 44 };
 45 
 46 struct usbip_exported_device {
 47         struct udev_device *sudev;
 48         int32_t status;
 49         struct usbip_usb_device udev;
 50         struct list_head node;
 51         struct usbip_usb_interface uinf[];
 52 };
 53 
 54 /* External API to access the driver */
 55 static inline int usbip_driver_open(struct usbip_host_driver *hdriver)
 56 {
 57         if (!hdriver->ops.open)
 58                 return -EOPNOTSUPP;
 59         return hdriver->ops.open(hdriver);
 60 }
 61 
 62 static inline void usbip_driver_close(struct usbip_host_driver *hdriver)
 63 {
 64         if (!hdriver->ops.close)
 65                 return;
 66         hdriver->ops.close(hdriver);
 67 }
 68 
 69 static inline int usbip_refresh_device_list(struct usbip_host_driver *hdriver)
 70 {
 71         if (!hdriver->ops.refresh_device_list)
 72                 return -EOPNOTSUPP;
 73         return hdriver->ops.refresh_device_list(hdriver);
 74 }
 75 
 76 static inline struct usbip_exported_device *
 77 usbip_get_device(struct usbip_host_driver *hdriver, int num)
 78 {
 79         if (!hdriver->ops.get_device)
 80                 return NULL;
 81         return hdriver->ops.get_device(hdriver, num);
 82 }
 83 
 84 /* Helper functions for implementing driver backend */
 85 int usbip_generic_driver_open(struct usbip_host_driver *hdriver);
 86 void usbip_generic_driver_close(struct usbip_host_driver *hdriver);
 87 int usbip_generic_refresh_device_list(struct usbip_host_driver *hdriver);
 88 int usbip_export_device(struct usbip_exported_device *edev, int sockfd);
 89 struct usbip_exported_device *usbip_generic_get_device(
 90                 struct usbip_host_driver *hdriver, int num);
 91 
 92 #endif /* __USBIP_HOST_COMMON_H */
 93 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php