--- usbip-0.1.7.orig/drivers/head/stub_rx.c
+++ usbip-0.1.7/drivers/head/stub_rx.c
@@ -1,9 +1,6 @@
 /*
- * $Id: stub_rx.c 66 2008-04-20 13:19:42Z hirofuchi $
- *
  * Copyright (C) 2003-2008 Takahiro Hirofuchi
  *
- *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -22,8 +19,7 @@
 
 #include "usbip_common.h"
 #include "stub.h"
-
-#include HCD_HEADER
+#include "headers/hcd.h"
 
 
 static int is_clear_halt_cmd(struct urb *urb)
@@ -68,11 +64,11 @@
 	index = le16_to_cpu(req->wIndex);
 
 	if ((req->bRequest == USB_REQ_SET_FEATURE) &&
-	    	(req->bRequestType == USB_RT_PORT) &&
-		(value = USB_PORT_FEAT_RESET)) {
+			(req->bRequestType == USB_RT_PORT) &&
+			(value = USB_PORT_FEAT_RESET)) {
 		dbg_stub_rx("reset_device_cmd, port %u\n", index);
 		return 1;
-	} else 
+	} else
 		return 0;
 }
 
@@ -93,7 +89,7 @@
 	 */
 	target_endp = le16_to_cpu(req->wIndex) & 0x000f;
 
-	/* the stalled endpoint direction is IN or OUT?. USB_DIR_IN is 0x80. */
+	/* the stalled endpoint direction is IN or OUT?. USB_DIR_IN is 0x80.  */
 	target_dir = le16_to_cpu(req->wIndex) & 0x0080;
 
 	if (target_dir)
@@ -130,7 +126,9 @@
 		uinfo("set_interface error: inf %u alt %u, %d\n",
 				interface, alternate, ret);
 	else
-		uinfo("set_interface done: inf %u alt %u\n", interface, alternate);
+		uinfo("set_interface done: inf %u alt %u\n",
+							interface,
+							alternate);
 
 	return ret;
 }
@@ -163,7 +161,7 @@
 	uinfo("but, skip!\n");
 
 	return 0;
-	//return usb_driver_set_configuration(urb->dev, config);
+	/* return usb_driver_set_configuration(urb->dev, config); */
 }
 
 static int tweak_reset_device_cmd(struct urb *urb)
@@ -179,17 +177,17 @@
 
 	uinfo("reset_device (port %d) to %s\n", index, urb->dev->dev.bus_id);
 
-	/* all interfaces should be owned by usbip driver, so just reset it. */
+	/* all interfaces should be owned by usbip driver, so just reset it.  */
 	ret = usb_lock_device_for_reset(urb->dev, NULL);
 	if (ret < 0) {
-		uerr("lock for reset\n");
+		dev_err(&urb->dev->dev, "lock for reset\n");
 		return ret;
 	}
 
 	/* try to reset the device */
-	ret = usb_reset_composite_device(urb->dev, NULL);
+	ret = usb_reset_device(urb->dev);
 	if (ret < 0)
-		uerr("device reset\n");
+		dev_err(&urb->dev->dev, "device reset\n");
 
 	usb_unlock_device(urb->dev);
 
@@ -233,7 +231,8 @@
  *
  * See also comments about unlinking strategy in vhci_hcd.c.
  */
-static int stub_recv_cmd_unlink(struct stub_device *sdev, struct usbip_header *pdu)
+static int stub_recv_cmd_unlink(struct stub_device *sdev,
+						struct usbip_header *pdu)
 {
 	struct list_head *listhead = &sdev->priv_init;
 	struct list_head *ptr;
@@ -249,7 +248,8 @@
 		if (priv->seqnum == pdu->u.cmd_unlink.seqnum) {
 			int ret;
 
-			uinfo("unlink urb %p\n", priv->urb);
+			dev_info(&priv->urb->dev->dev, "unlink urb %p\n",
+				 priv->urb);
 
 			/*
 			 * This matched urb is not completed yet (i.e., be in
@@ -288,8 +288,9 @@
 			 */
 			ret = usb_unlink_urb(priv->urb);
 			if (ret != -EINPROGRESS)
-				uerr("faild to unlink a urb %p, ret %d\n", priv->urb, ret);
-
+				dev_err(&priv->urb->dev->dev,
+					"failed to unlink a urb %p, ret %d\n",
+					priv->urb, ret);
 			return 0;
 		}
 	}
@@ -328,7 +329,7 @@
 }
 
 static struct stub_priv *stub_priv_alloc(struct stub_device *sdev,
-		struct usbip_header *pdu)
+					 struct usbip_header *pdu)
 {
 	struct stub_priv *priv;
 	struct usbip_device *ud = &sdev->ud;
@@ -338,7 +339,7 @@
 
 	priv = kmem_cache_alloc(stub_priv_cache, GFP_ATOMIC);
 	if (!priv) {
-		uerr("alloc stub_priv\n");
+		dev_err(&sdev->interface->dev, "alloc stub_priv\n");
 		spin_unlock_irqrestore(&sdev->priv_lock, flags);
 		usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC);
 		return NULL;
@@ -387,7 +388,7 @@
 			epnum = (ep->desc.bEndpointAddress & 0x7f);
 
 			if (epnum == epnum0) {
-				//uinfo("found epnum %d\n", epnum0);
+				/* uinfo("found epnum %d\n", epnum0); */
 				found = 1;
 				break;
 			}
@@ -409,7 +410,8 @@
 
 	ep = get_ep_from_epnum(udev, epnum);
 	if (!ep) {
-		uerr("no such endpoint?, %d", epnum);
+		dev_err(&sdev->interface->dev, "no such endpoint?, %d\n",
+			epnum);
 		BUG();
 	}
 
@@ -455,12 +457,12 @@
 	}
 
 	/* NOT REACHED */
-	uerr("get pipe, epnum %d\n", epnum);
+	dev_err(&sdev->interface->dev, "get pipe, epnum %d\n", epnum);
 	return 0;
 }
 
-
-static void stub_recv_cmd_submit(struct stub_device *sdev, struct usbip_header *pdu)
+static void stub_recv_cmd_submit(struct stub_device *sdev,
+				 struct usbip_header *pdu)
 {
 	int ret;
 	struct stub_priv *priv;
@@ -475,12 +477,13 @@
 
 	/* setup a urb */
 	if (usb_pipeisoc(pipe))
-		priv->urb = usb_alloc_urb(pdu->u.cmd_submit.number_of_packets, GFP_KERNEL);
+		priv->urb = usb_alloc_urb(pdu->u.cmd_submit.number_of_packets,
+								GFP_KERNEL);
 	else
 		priv->urb = usb_alloc_urb(0, GFP_KERNEL);
 
 	if (!priv->urb) {
-		uerr("malloc urb\n");
+		dev_err(&sdev->interface->dev, "malloc urb\n");
 		usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC);
 		return;
 	}
@@ -488,9 +491,10 @@
 	/* set priv->urb->transfer_buffer */
 	if (pdu->u.cmd_submit.transfer_buffer_length > 0) {
 		priv->urb->transfer_buffer =
-			kzalloc(pdu->u.cmd_submit.transfer_buffer_length, GFP_KERNEL);
+			kzalloc(pdu->u.cmd_submit.transfer_buffer_length,
+								GFP_KERNEL);
 		if (!priv->urb->transfer_buffer) {
-			uerr("malloc x_buff\n");
+			dev_err(&sdev->interface->dev, "malloc x_buff\n");
 			usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC);
 			return;
 		}
@@ -499,7 +503,7 @@
 	/* set priv->urb->setup_packet */
 	priv->urb->setup_packet = kzalloc(8, GFP_KERNEL);
 	if (!priv->urb->setup_packet) {
-		uerr("allocate setup_packet\n");
+		dev_err(&sdev->interface->dev, "allocate setup_packet\n");
 		usbip_event_add(ud, SDEV_EVENT_ERROR_MALLOC);
 		return;
 	}
@@ -529,7 +533,7 @@
 	if (ret == 0)
 		dbg_stub_rx("submit urb ok, seqnum %u\n", pdu->base.seqnum);
 	else {
-		uerr("submit_urb error, %d\n", ret);
+		dev_err(&sdev->interface->dev, "submit_urb error, %d\n", ret);
 		usbip_dump_header(pdu);
 		usbip_dump_urb(priv->urb);
 
@@ -550,17 +554,16 @@
 	int ret;
 	struct usbip_header pdu;
 	struct stub_device *sdev = container_of(ud, struct stub_device, ud);
-
+	struct device *dev = &sdev->interface->dev;
 
 	dbg_stub_rx("Enter\n");
 
 	memset(&pdu, 0, sizeof(pdu));
 
-
 	/* 1. receive a pdu header */
-	ret = usbip_xmit(0, ud->tcp_socket, (char *) &pdu, sizeof(pdu),0);
+	ret = usbip_xmit(0, ud->tcp_socket, (char *) &pdu, sizeof(pdu), 0);
 	if (ret != sizeof(pdu)) {
-		uerr("recv a header, %d\n", ret);
+		dev_err(dev, "recv a header, %d\n", ret);
 		usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
 		return;
 	}
@@ -571,25 +574,25 @@
 		usbip_dump_header(&pdu);
 
 	if (!valid_request(sdev, &pdu)) {
-		uerr("recv invalid request\n");
+		dev_err(dev, "recv invalid request\n");
 		usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
 		return;
 	}
 
 	switch (pdu.base.command) {
-		case USBIP_CMD_UNLINK:
-			stub_recv_cmd_unlink(sdev, &pdu);
-			break;
-
-		case USBIP_CMD_SUBMIT:
-			stub_recv_cmd_submit(sdev, &pdu);
-			break;
-
-		default:
-			/* NOTREACHED */
-			uerr("unknown pdu\n");
-			usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
-			return;
+	case USBIP_CMD_UNLINK:
+		stub_recv_cmd_unlink(sdev, &pdu);
+		break;
+
+	case USBIP_CMD_SUBMIT:
+		stub_recv_cmd_submit(sdev, &pdu);
+		break;
+
+	default:
+		/* NOTREACHED */
+		dev_err(dev, "unknown pdu\n");
+		usbip_event_add(ud, SDEV_EVENT_ERROR_TCP);
+		return;
 	}
 
 }
@@ -610,4 +613,3 @@
 		stub_rx_pdu(ud);
 	}
 }
-
