Skip to content

Commit

Permalink
userspace: rename usbip device and interface
Browse files Browse the repository at this point in the history
Add prefix of usbip_ to internal usb device and interface to avoid
confusion with the kernel types. This also identifies the types as
being part of the usbip library.

Signed-off-by: matt mooney <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
mfmooney authored and george-hopkins committed Sep 14, 2017
1 parent f7da8d5 commit 14a4c3c
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 43 deletions.
5 changes: 3 additions & 2 deletions userspace/libsrc/stub_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static struct sysfs_driver *open_sysfs_stub_driver(void)
#define SYSFS_OPEN_RETRIES 100

/* only the first interface value is true! */
static int32_t read_attr_usbip_status(struct usb_device *udev)
static int32_t read_attr_usbip_status(struct usbip_usb_device *udev)
{
char attrpath[SYSFS_PATH_MAX];
struct sysfs_attribute *attr;
Expand Down Expand Up @@ -148,7 +148,8 @@ static struct usbip_exported_device *usbip_exported_device_new(char *sdevpath)
goto err;

/* reallocate buffer to include usb interface data */
size_t size = sizeof(*edev) + edev->udev.bNumInterfaces * sizeof(struct usb_interface);
size_t size = sizeof(*edev) + edev->udev.bNumInterfaces *
sizeof(struct usbip_usb_interface);
edev = (struct usbip_exported_device *) realloc(edev, size);
if (!edev) {
err("alloc device");
Expand Down
4 changes: 2 additions & 2 deletions userspace/libsrc/stub_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ struct usbip_exported_device {
struct sysfs_device *sudev;

int32_t status;
struct usb_device udev;
struct usb_interface uinf[];
struct usbip_usb_device udev;
struct usbip_usb_interface uinf[];
};


Expand Down
9 changes: 5 additions & 4 deletions userspace/libsrc/usbip_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const char *usbip_speed_string(int num)
#define DBG_UINF_INTEGER(name)\
dbg("%-20s = %x", to_string(name), (int) uinf->name)

void dump_usb_interface(struct usb_interface *uinf)
void dump_usb_interface(struct usbip_usb_interface *uinf)
{
char buff[100];
usbip_names_get_class(buff, sizeof(buff),
Expand All @@ -76,7 +76,7 @@ void dump_usb_interface(struct usb_interface *uinf)
dbg("%-20s = %s", "Interface(C/SC/P)", buff);
}

void dump_usb_device(struct usb_device *udev)
void dump_usb_device(struct usbip_usb_device *udev)
{
char buff[100];

Expand Down Expand Up @@ -184,7 +184,7 @@ int read_attr_speed(struct sysfs_device *dev)
do { (object)->name = (type) read_attr_value(dev, to_string(name), format); } while (0)


int read_usb_device(struct sysfs_device *sdev, struct usb_device *udev)
int read_usb_device(struct sysfs_device *sdev, struct usbip_usb_device *udev)
{
uint32_t busnum, devnum;

Expand Down Expand Up @@ -212,7 +212,8 @@ int read_usb_device(struct sysfs_device *sdev, struct usb_device *udev)
return 0;
}

int read_usb_interface(struct usb_device *udev, int i, struct usb_interface *uinf)
int read_usb_interface(struct usbip_usb_device *udev, int i,
struct usbip_usb_interface *uinf)
{
char busid[SYSFS_BUS_ID_SIZE];
struct sysfs_device *sif;
Expand Down
13 changes: 7 additions & 6 deletions userspace/libsrc/usbip_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ extern int usbip_use_debug ;
#define BUG() do { err("sorry, it's a bug"); abort(); } while (0)


struct usb_interface {
struct usbip_usb_interface {
uint8_t bInterfaceClass;
uint8_t bInterfaceSubClass;
uint8_t bInterfaceProtocol;
Expand All @@ -128,7 +128,7 @@ struct usb_interface {



struct usb_device {
struct usbip_usb_device {
char path[SYSFS_PATH_MAX];
char busid[SYSFS_BUS_ID_SIZE];

Expand Down Expand Up @@ -276,11 +276,12 @@ struct usbip_header {

#define to_string(s) #s

void dump_usb_interface(struct usb_interface *);
void dump_usb_device(struct usb_device *);
int read_usb_device(struct sysfs_device *sdev, struct usb_device *udev);
void dump_usb_interface(struct usbip_usb_interface *);
void dump_usb_device(struct usbip_usb_device *);
int read_usb_device(struct sysfs_device *sdev, struct usbip_usb_device *udev);
int read_attr_value(struct sysfs_device *dev, const char *name, const char *format);
int read_usb_interface(struct usb_device *udev, int i, struct usb_interface *uinf);
int read_usb_interface(struct usbip_usb_device *udev, int i,
struct usbip_usb_interface *uinf);

const char *usbip_speed_string(int num);
const char *usbip_status_string(int32_t status);
Expand Down
2 changes: 1 addition & 1 deletion userspace/libsrc/vhci_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct usbip_imported_device {

/* usbip_class_device list */
struct dlist *cdev_list;
struct usb_device udev;
struct usbip_usb_device udev;
};

struct usbip_vhci_driver {
Expand Down
2 changes: 1 addition & 1 deletion userspace/src/usbip_attach.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static int record_connection(char *host, char *port, char *busid, int rhport)
return 0;
}

static int import_device(int sockfd, struct usb_device *udev)
static int import_device(int sockfd, struct usbip_usb_device *udev)
{
int rc;
int port;
Expand Down
20 changes: 10 additions & 10 deletions userspace/src/usbip_network.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ struct op_devinfo_request {
} PACKED;

struct op_devinfo_reply {
struct usb_device udev;
struct usb_interface uinf[];
struct usbip_usb_device udev;
struct usbip_usb_interface uinf[];
} PACKED;


Expand All @@ -83,8 +83,8 @@ struct op_import_request {
} PACKED;

struct op_import_reply {
struct usb_device udev;
// struct usb_interface uinf[];
struct usbip_usb_device udev;
// struct usbip_usb_interface uinf[];
} PACKED;

#define PACK_OP_IMPORT_REQUEST(pack, request) do {\
Expand All @@ -101,7 +101,7 @@ struct op_import_reply {
#define OP_REP_EXPORT (OP_REPLY | OP_EXPORT)

struct op_export_request {
struct usb_device udev;
struct usbip_usb_device udev;
} PACKED;

struct op_export_reply {
Expand All @@ -123,7 +123,7 @@ struct op_export_reply {
#define OP_REP_UNEXPORT (OP_REPLY | OP_UNEXPORT)

struct op_unexport_request {
struct usb_device udev;
struct usbip_usb_device udev;
} PACKED;

struct op_unexport_reply {
Expand Down Expand Up @@ -170,8 +170,8 @@ struct op_devlist_reply {
} PACKED;

struct op_devlist_reply_extra {
struct usb_device udev;
struct usb_interface uinf[];
struct usbip_usb_device udev;
struct usbip_usb_interface uinf[];
} PACKED;

#define PACK_OP_DEVLIST_REQUEST(pack, request) do {\
Expand All @@ -183,8 +183,8 @@ struct op_devlist_reply_extra {

void pack_uint32_t(int pack, uint32_t *num);
void pack_uint16_t(int pack, uint16_t *num);
void pack_usb_device(int pack, struct usb_device *udev);
void pack_usb_interface(int pack, struct usb_interface *uinf);
void pack_usb_device(int pack, struct usbip_usb_device *udev);
void pack_usb_interface(int pack, struct usbip_usb_interface *uinf);

ssize_t usbip_recv(int sockfd, void *buff, size_t bufflen);
ssize_t usbip_send(int sockfd, void *buff, size_t bufflen);
Expand Down
22 changes: 11 additions & 11 deletions userspace/src/usbip_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ int usbip_vbus_detach_device(HANDLE fd, int port)
return -1;
}

int usbip_vbus_attach_device(HANDLE fd, int port, struct usb_device *udev,
struct usb_interface *uinf0)
int usbip_vbus_attach_device(HANDLE fd, int port, struct usbip_usb_device *udev,
struct usbip_usb_interface *uinf0)
{
int ret;
ioctl_usbvbus_plugin plugin;
Expand Down Expand Up @@ -707,8 +707,8 @@ void usbip_vbus_forward(SOCKET sockfd, HANDLE devfd)
}


static int import_device(int sockfd, struct usb_device *udev,
struct usb_interface *uinf0,
static int import_device(int sockfd, struct usbip_usb_device *udev,
struct usbip_usb_interface *uinf0,
HANDLE *devfd)
{
HANDLE fd;
Expand Down Expand Up @@ -743,7 +743,7 @@ static int import_device(int sockfd, struct usb_device *udev,
}

static int query_import_device(int sockfd, char *busid,
struct usb_interface *uinf0, HANDLE * fd)
struct usbip_usb_interface *uinf0, HANDLE * fd)
{
int ret;
struct op_import_request request;
Expand Down Expand Up @@ -796,16 +796,16 @@ static int query_import_device(int sockfd, char *busid,
return import_device(sockfd, &reply.udev, uinf0, fd);
}

static int query_interface0(SOCKET sockfd, char * busid, struct usb_interface * uinf0)
static int query_interface0(SOCKET sockfd, char * busid, struct usbip_usb_interface * uinf0)
{
int ret;
struct op_devlist_reply rep;
uint16_t code = OP_REP_DEVLIST;
uint32_t i,j;
char product_name[100];
char class_name[100];
struct usb_device udev;
struct usb_interface uinf;
struct usbip_usb_device udev;
struct usbip_usb_interface uinf;
int found=0;

memset(&rep, 0, sizeof(rep));
Expand Down Expand Up @@ -837,7 +837,7 @@ static int query_interface0(SOCKET sockfd, char * busid, struct usb_interface *

ret = usbip_recv(sockfd, (void *) &udev, sizeof(udev));
if (ret < 0) {
err("recv usb_device[%d]", i);
err("recv usbip_usb_device[%d]", i);
return -1;
}
pack_usb_device(0, &udev);
Expand All @@ -854,7 +854,7 @@ static int query_interface0(SOCKET sockfd, char * busid, struct usb_interface *

ret = usbip_recv(sockfd, (void *) &uinf, sizeof(uinf));
if (ret < 0) {
err("recv usb_interface[%d]", j);
err("recv usbip_usb_interface[%d]", j);
return -1;
}

Expand Down Expand Up @@ -883,7 +883,7 @@ int attach_device(char * host, char * busid)
SOCKET sockfd;
int rhport;
HANDLE devfd=INVALID_HANDLE_VALUE;
struct usb_interface uinf;
struct usbip_usb_interface uinf;

sockfd = usbip_net_tcp_connect(host, USBIP_PORT_STRING);
if (INVALID_SOCKET == sockfd) {
Expand Down
6 changes: 3 additions & 3 deletions userspace/src/usbipd.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ static int send_reply_devlist(int sockfd)
}

dlist_for_each_data(stub_driver->edev_list, edev, struct usbip_exported_device) {
struct usb_device pdu_udev;
struct usbip_usb_device pdu_udev;

dump_usb_device(&edev->udev);
memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
Expand All @@ -77,7 +77,7 @@ static int send_reply_devlist(int sockfd)
}

for (i=0; i < edev->udev.bNumInterfaces; i++) {
struct usb_interface pdu_uinf;
struct usbip_usb_interface pdu_uinf;

dump_usb_interface(&edev->uinf[i]);
memcpy(&pdu_uinf, &edev->uinf[i], sizeof(pdu_uinf));
Expand Down Expand Up @@ -167,7 +167,7 @@ static int recv_request_import(int sockfd)
}

if (!error) {
struct usb_device pdu_udev;
struct usbip_usb_device pdu_udev;

memcpy(&pdu_udev, &edev->udev, sizeof(pdu_udev));
pack_usb_device(1, &pdu_udev);
Expand Down
4 changes: 2 additions & 2 deletions userspace/src/windows/usbip_vbus_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ int usbip_vbus_detach_device(HANDLE fd, int port)
return -1;
}

int usbip_vbus_attach_device(HANDLE fd, int port, struct usb_device *udev,
struct usb_interface *uinf0)
int usbip_vbus_attach_device(HANDLE fd, int port, struct usbip_usb_device *udev,
struct usbip_usb_interface *uinf0)
{
int ret;
ioctl_usbvbus_plugin plugin;
Expand Down
2 changes: 1 addition & 1 deletion userspace/src/windows/usbip_vbus_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ HANDLE usbip_vbus_open(void);
int usbip_vbus_get_free_port(HANDLE fd);
int usbip_vbus_get_ports_status(HANDLE fd, char *buf, int len);
int usbip_vbus_attach_device(HANDLE fd, int port,
struct usb_device *udev, struct usb_interface * uinf0);
struct usbip_usb_device *udev, struct usbip_usb_interface * uinf0);
int usbip_vbus_detach_device(HANDLE fd, int port);
void usbip_vbus_forward(SOCKET sockfd, HANDLE devfd);

Expand Down

0 comments on commit 14a4c3c

Please sign in to comment.