Commit 071d1d47 authored by matt mooney's avatar matt mooney Committed by Greg Kroah-Hartman
Browse files

staging: usbip: vhci_hcd.c: coding style cleanup



Fix alignment for consistency and remove extraneous lines.
Move MODULE_ macros to the end of file.
Make bit_desc[] an array of const pointers.
Add KERN_ level to a couple of printks.

Signed-off-by: default avatarmatt mooney <mfm@muteddisk.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent ddbc9bc9
Loading
Loading
Loading
Loading
+76 −111
Original line number Diff line number Diff line
@@ -27,11 +27,6 @@
#define DRIVER_AUTHOR "Takahiro Hirofuchi"
#define DRIVER_DESC "Virtual Host Controller Interface Driver for USB/IP"
#define DRIVER_LICENCE "GPL"
MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE(DRIVER_LICENCE);



/*
 * TODO
@@ -43,10 +38,8 @@ MODULE_LICENSE(DRIVER_LICENCE);
 *	- clean up everything
 */


/* See usb gadget dummy hcd */


static int vhci_hub_status(struct usb_hcd *hcd, char *buff);
static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
			    u16 wIndex, char *buff, u16 wLength);
@@ -62,7 +55,7 @@ static const char driver_desc[] = "USB/IP Virtual Host Controller";

struct vhci_hcd *the_controller;

static const char *bit_desc[] = {
static const char * const bit_desc[] = {
	"CONNECTION",		/*0*/
	"ENABLE",		/*1*/
	"SUSPEND",		/*2*/
@@ -97,7 +90,6 @@ static const char *bit_desc[] = {
	"R31",			/*31*/
};


static void dump_port_status(u32 status)
{
	int i = 0;
@@ -105,14 +97,11 @@ static void dump_port_status(u32 status)
	printk(KERN_DEBUG "status %08x:", status);
	for (i = 0; i < 32; i++) {
		if (status & (1 << i))
			printk(" %s", bit_desc[i]);
			printk(KERN_DEBUG " %s", bit_desc[i]);
	}

	printk("\n");
	printk(KERN_DEBUG "\n");
}



void rh_port_connect(int rhport, enum usb_device_speed speed)
{
	unsigned long	flags;
@@ -156,19 +145,15 @@ void rh_port_disconnect(int rhport)
	the_controller->port_status[rhport] |=
					(1 << USB_PORT_FEAT_C_CONNECTION);


	/* not yet complete the disconnection
	 * spin_lock(&vdev->ud.lock);
	 * vdev->ud.status = VHC_ST_DISCONNECT;
	 * spin_unlock(&vdev->ud.lock); */

	spin_unlock_irqrestore(&the_controller->lock, flags);

	usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
}



/*----------------------------------------------------------------------*/

#define PORT_C_MASK				\
@@ -210,7 +195,6 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
	int		rhport;
	int		changed = 0;


	*event_bits = 0;

	vhci = hcd_to_vhci(hcd);
@@ -393,7 +377,6 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
			}
#if 0
			if (dum->driver) {

				dum->port_status[rhport] |=
					USB_PORT_STAT_ENABLE;
				/* give it the best speed we agree on */
@@ -415,11 +398,9 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
				}
			}
#endif

		}
		((u16 *) buf)[0] = cpu_to_le16(dum->port_status[rhport]);
		((u16 *) buf)[1] =
				cpu_to_le16(dum->port_status[rhport] >> 16);
		((u16 *) buf)[1] = cpu_to_le16(dum->port_status[rhport] >> 16);

		usbip_dbg_vhci_rh(" GetPortStatus bye %x %x\n", ((u16 *)buf)[0],
				  ((u16 *)buf)[1]);
@@ -545,7 +526,6 @@ static void vhci_tx_urb(struct urb *urb)

	urb->hcpriv = (void *) priv;


	list_add_tail(&priv->list, &vdev->priv_tx);

	wake_up(&vdev->waitq_tx);
@@ -578,7 +558,8 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,

	/* refuse enqueue for dead connection */
	spin_lock(&vdev->ud.lock);
	if (vdev->ud.status == VDEV_ST_NULL || vdev->ud.status == VDEV_ST_ERROR) {
	if (vdev->ud.status == VDEV_ST_NULL ||
	    vdev->ud.status == VDEV_ST_ERROR) {
		usbip_uerr("enqueue for inactive port %d\n", vdev->rhport);
		spin_unlock(&vdev->ud.lock);
		spin_unlock_irqrestore(&the_controller->lock, flags);
@@ -599,7 +580,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
	 *  2. Set_Address request to DevAddr(0) EndPoint(0)
	 *
	 */

	if (usb_pipedevice(urb->pipe) == 0) {
		__u8 type = usb_pipetype(urb->pipe);
		struct usb_ctrlrequest *ctrlreq =
@@ -657,7 +637,6 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,

out:
	vhci_tx_urb(urb);

	spin_unlock_irqrestore(&the_controller->lock, flags);

	return 0;
@@ -726,7 +705,6 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)

	usbip_uinfo("vhci_hcd: dequeue a urb %p\n", urb);


	spin_lock_irqsave(&the_controller->lock, flags);

	priv = urb->hcpriv;
@@ -838,8 +816,8 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)

		urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
		if (!urb) {
			usbip_uinfo("the urb (seqnum %lu) was already given back\n",
							unlink->unlink_seqnum);
			usbip_uinfo("the urb (seqnum %lu) was already given "
				    "back\n", unlink->unlink_seqnum);
			list_del(&unlink->list);
			kfree(unlink);
			continue;
@@ -851,7 +829,8 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
		usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
		spin_unlock(&the_controller->lock);

		usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);
		usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
				     urb->status);

		list_del(&unlink->list);
		kfree(unlink);
@@ -930,7 +909,6 @@ static void vhci_device_reset(struct usbip_device *ud)
	vdev->udev = NULL;

	ud->tcp_socket = NULL;

	ud->status = VDEV_ST_NULL;

	spin_unlock(&ud->lock);
@@ -939,9 +917,7 @@ static void vhci_device_reset(struct usbip_device *ud)
static void vhci_device_unusable(struct usbip_device *ud)
{
	spin_lock(&ud->lock);

	ud->status = VDEV_ST_ERROR;

	spin_unlock(&ud->lock);
}

@@ -984,7 +960,6 @@ static int vhci_start(struct usb_hcd *hcd)

	usbip_dbg_vhci_hc("enter vhci_start\n");


	/* initialize private data of usb_hcd */

	for (rhport = 0; rhport < VHCI_NPORTS; rhport++) {
@@ -996,13 +971,10 @@ static int vhci_start(struct usb_hcd *hcd)
	atomic_set(&vhci->seqnum, 0);
	spin_lock_init(&vhci->lock);



	hcd->power_budget = 0; /* no limit */
	hcd->state  = HC_STATE_RUNNING;
	hcd->uses_new_polling = 1;


	/* vhci_hcd is now ready to be controlled through sysfs */
	err = sysfs_create_group(&vhci_dev(vhci)->kobj, &dev_attr_group);
	if (err) {
@@ -1020,7 +992,6 @@ static void vhci_stop(struct usb_hcd *hcd)

	usbip_dbg_vhci_hc("stop VHCI controller\n");


	/* 1. remove the userland interface of vhci_hcd */
	sysfs_remove_group(&vhci_dev(vhci)->kobj, &dev_attr_group);

@@ -1032,7 +1003,6 @@ static void vhci_stop(struct usb_hcd *hcd)
		usbip_stop_eh(&vdev->ud);
	}


	usbip_uinfo("vhci_stop done\n");
}

@@ -1044,7 +1014,6 @@ static int vhci_get_frame_number(struct usb_hcd *hcd)
	return 0;
}


#ifdef CONFIG_PM

/* FIXME: suspend/resume */
@@ -1092,8 +1061,6 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
#define vhci_bus_resume       NULL
#endif



static struct hc_driver vhci_hc_driver = {
	.description	= driver_name,
	.product_desc	= driver_desc,
@@ -1156,12 +1123,10 @@ static int vhci_hcd_probe(struct platform_device *pdev)
		return ret;
	}


	usbip_dbg_vhci_hc("bye\n");
	return 0;
}


static int vhci_hcd_remove(struct platform_device *pdev)
{
	struct usb_hcd	*hcd;
@@ -1179,12 +1144,9 @@ static int vhci_hcd_remove(struct platform_device *pdev)
	usb_put_hcd(hcd);
	the_controller = NULL;


	return 0;
}



#ifdef CONFIG_PM

/* what should happen for USB/IP under suspend/resume? */
@@ -1240,7 +1202,6 @@ static int vhci_hcd_resume(struct platform_device *pdev)

#endif


static struct platform_driver vhci_driver = {
	.probe	= vhci_hcd_probe,
	.remove	= __devexit_p(vhci_hcd_remove),
@@ -1299,12 +1260,10 @@ static int __init vhci_init(void)
	/* error occurred */
err_platform_device_register:
	platform_driver_unregister(&vhci_driver);

err_driver_register:
	usbip_dbg_vhci_hc("bye\n");
	return ret;
}
module_init(vhci_init);

static void __exit vhci_cleanup(void)
{
@@ -1315,4 +1274,10 @@ static void __exit vhci_cleanup(void)

	usbip_dbg_vhci_hc("bye\n");
}

module_init(vhci_init);
module_exit(vhci_cleanup);

MODULE_AUTHOR(DRIVER_AUTHOR);
MODULE_DESCRIPTION(DRIVER_DESC);
MODULE_LICENSE(DRIVER_LICENCE);