Commit 1a4b6f66 authored by matt mooney's avatar matt mooney Committed by Greg Kroah-Hartman

staging: usbip: replace usbip_u{dbg,err,info} and printk with dev_ and pr_

This switches all of the usbip_u{dbg,err,info} and printk statements to
dev_<level>, if possible, or pr_<level> macros. And removes a few
unnecessary debug statements.
Signed-off-by: default avatarmatt mooney <mfm@muteddisk.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent db60697a
......@@ -196,7 +196,8 @@ static void stub_shutdown_connection(struct usbip_device *ud)
* step 1?
*/
if (ud->tcp_socket) {
usbip_udbg("shutdown tcp_socket %p\n", ud->tcp_socket);
dev_dbg(&sdev->udev->dev, "shutdown tcp_socket %p\n",
ud->tcp_socket);
kernel_sock_shutdown(ud->tcp_socket, SHUT_RDWR);
}
......@@ -244,12 +245,11 @@ static void stub_device_reset(struct usbip_device *ud)
struct usb_device *udev = sdev->udev;
int ret;
usbip_udbg("device reset");
dev_dbg(&udev->dev, "device reset");
ret = usb_lock_device_for_reset(udev, sdev->interface);
if (ret < 0) {
dev_err(&udev->dev, "lock for reset\n");
spin_lock(&ud->lock);
ud->status = SDEV_ST_ERROR;
spin_unlock(&ud->lock);
......@@ -336,7 +336,8 @@ static struct stub_device *stub_device_alloc(struct usb_device *udev,
usbip_start_eh(&sdev->ud);
usbip_udbg("register new interface\n");
dev_dbg(&interface->dev, "register new interface\n");
return sdev;
}
......@@ -346,7 +347,7 @@ static int stub_device_free(struct stub_device *sdev)
return -EINVAL;
kfree(sdev);
usbip_udbg("kfree udev ok\n");
pr_debug("kfree udev ok\n");
return 0;
}
......@@ -376,9 +377,8 @@ static int stub_probe(struct usb_interface *interface,
busid_priv = get_busid_priv(udev_busid);
if (!busid_priv || (busid_priv->status == STUB_BUSID_REMOV) ||
(busid_priv->status == STUB_BUSID_OTHER)) {
dev_info(&interface->dev,
"this device %s is not in match_busid table. skip!\n",
udev_busid);
dev_info(&interface->dev, "%s is not in match_busid table... "
"skip!\n", udev_busid);
/*
* Return value should be ENODEV or ENOXIO to continue trying
......@@ -388,15 +388,15 @@ static int stub_probe(struct usb_interface *interface,
return -ENODEV;
}
if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) {
usbip_udbg("this device %s is a usb hub device. skip!\n",
udev_busid);
if (udev->descriptor.bDeviceClass == USB_CLASS_HUB) {
dev_dbg(&udev->dev, "%s is a usb hub device... skip!\n",
udev_busid);
return -ENODEV;
}
if (!strcmp(udev->bus->bus_name, "vhci_hcd")) {
usbip_udbg("this device %s is attached on vhci_hcd. skip!\n",
udev_busid);
dev_dbg(&udev->dev, "%s is attached on vhci_hcd... skip!\n",
udev_busid);
return -ENODEV;
}
......@@ -406,8 +406,7 @@ static int stub_probe(struct usb_interface *interface,
return -ENODEV;
busid_priv->interf_count++;
dev_info(&interface->dev,
"USB/IP Stub: register a new interface "
dev_info(&interface->dev, "usbip-host: register new interface "
"(bus %u dev %u ifn %u)\n",
udev->bus->busnum, udev->devnum,
interface->cur_altsetting->desc.bInterfaceNumber);
......@@ -417,7 +416,7 @@ static int stub_probe(struct usb_interface *interface,
err = stub_add_files(&interface->dev);
if (err) {
dev_err(&interface->dev, "create sysfs files for %s\n",
dev_err(&interface->dev, "stub_add_files for %s\n",
udev_busid);
usb_set_intfdata(interface, NULL);
busid_priv->interf_count--;
......@@ -434,7 +433,7 @@ static int stub_probe(struct usb_interface *interface,
if (!sdev)
return -ENOMEM;
dev_info(&interface->dev, "USB/IP Stub: register a new device "
dev_info(&interface->dev, "usbip-host: register new device "
"(bus %u dev %u ifn %u)\n", udev->bus->busnum, udev->devnum,
interface->cur_altsetting->desc.bInterfaceNumber);
......@@ -449,8 +448,7 @@ static int stub_probe(struct usb_interface *interface,
err = stub_add_files(&interface->dev);
if (err) {
dev_err(&interface->dev, "create sysfs files for %s\n",
udev_busid);
dev_err(&interface->dev, "stub_add_files for %s\n", udev_busid);
usb_set_intfdata(interface, NULL);
usb_put_intf(interface);
......@@ -486,10 +484,9 @@ static void stub_disconnect(struct usb_interface *interface)
const char *udev_busid = dev_name(interface->dev.parent);
struct bus_id_priv *busid_priv;
busid_priv = get_busid_priv(udev_busid);
usbip_udbg("Enter\n");
dev_dbg(&interface->dev, "Enter\n");
busid_priv = get_busid_priv(udev_busid);
if (!busid_priv) {
BUG();
return;
......@@ -499,7 +496,7 @@ static void stub_disconnect(struct usb_interface *interface)
/* get stub_device */
if (!sdev) {
err(" could not get device from inteface data");
dev_err(&interface->dev, "could not get device");
/* BUG(); */
return;
}
......@@ -543,5 +540,4 @@ static void stub_disconnect(struct usb_interface *interface)
busid_priv->status = STUB_BUSID_OTHER;
del_match_busid((char *)udev_busid);
}
usbip_udbg("bye\n");
}
......@@ -178,14 +178,14 @@ static ssize_t store_match_busid(struct device_driver *dev, const char *buf,
if (add_match_busid(busid) < 0)
return -ENOMEM;
else {
usbip_udbg("add busid %s\n", busid);
pr_debug("add busid %s\n", busid);
return count;
}
} else if (!strncmp(buf, "del ", 4)) {
if (del_match_busid(busid) < 0)
return -ENODEV;
else {
usbip_udbg("del busid %s\n", busid);
pr_debug("del busid %s\n", busid);
return count;
}
} else
......@@ -239,12 +239,12 @@ void stub_device_cleanup_urbs(struct stub_device *sdev)
{
struct stub_priv *priv;
usbip_udbg("free sdev %p\n", sdev);
dev_dbg(&sdev->udev->dev, "free sdev %p\n", sdev);
while ((priv = stub_priv_pop(sdev))) {
struct urb *urb = priv->urb;
usbip_udbg(" free urb %p\n", urb);
dev_dbg(&sdev->udev->dev, "free urb %p\n", urb);
usb_kill_urb(urb);
kmem_cache_free(stub_priv_cache, priv);
......@@ -265,20 +265,17 @@ static int __init usb_stub_init(void)
SLAB_HWCACHE_ALIGN, NULL);
if (!stub_priv_cache) {
printk(KERN_ERR KBUILD_MODNAME
": create stub_priv_cache error\n");
pr_err("create stub_priv_cache error\n");
return -ENOMEM;
}
ret = usb_register(&stub_driver);
if (ret) {
printk(KERN_ERR KBUILD_MODNAME ": usb_register failed %d\n",
ret);
pr_err("usb_register failed %d\n", ret);
goto error_usb_register;
}
printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC " " USBIP_VERSION
"\n");
pr_info(DRIVER_DESC " " USBIP_VERSION "\n");
init_busid_table();
......@@ -286,7 +283,7 @@ static int __init usb_stub_init(void)
&driver_attr_match_busid);
if (ret) {
printk(KERN_ERR KBUILD_MODNAME ": create driver sysfs\n");
pr_err("create driver sysfs\n");
goto error_create_file;
}
......
......@@ -102,11 +102,11 @@ static int tweak_clear_halt_cmd(struct urb *urb)
ret = usb_clear_halt(urb->dev, target_pipe);
if (ret < 0)
usbip_uinfo("clear_halt error: devnum %d endp %d, %d\n",
urb->dev->devnum, target_endp, ret);
dev_err(&urb->dev->dev, "usb_clear_halt error: devnum %d endp "
"%d ret %d\n", urb->dev->devnum, target_endp, ret);
else
usbip_uinfo("clear_halt done: devnum %d endp %d\n",
urb->dev->devnum, target_endp);
dev_info(&urb->dev->dev, "usb_clear_halt done: devnum %d endp "
"%d\n", urb->dev->devnum, target_endp);
return ret;
}
......@@ -127,11 +127,11 @@ static int tweak_set_interface_cmd(struct urb *urb)
ret = usb_set_interface(urb->dev, interface, alternate);
if (ret < 0)
usbip_uinfo("set_interface error: inf %u alt %u, %d\n",
interface, alternate, ret);
dev_err(&urb->dev->dev, "usb_set_interface error: inf %u alt "
"%u ret %d\n", interface, alternate, ret);
else
usbip_uinfo("set_interface done: inf %u alt %u\n",
interface, alternate);
dev_info(&urb->dev->dev, "usb_set_interface done: inf %u alt "
"%u\n", interface, alternate);
return ret;
}
......@@ -160,9 +160,8 @@ static int tweak_set_configuration_cmd(struct urb *urb)
* A user may need to set a special configuration value before
* exporting the device.
*/
usbip_uinfo("set_configuration %d to %s\n",
config, dev_name(&urb->dev->dev));
usbip_uinfo("but, skip!\n");
dev_info(&urb->dev->dev, "usb_set_configuration %d to %s... skip!\n",
config, dev_name(&urb->dev->dev));
return 0;
/* return usb_driver_set_configuration(urb->dev, config); */
......@@ -173,7 +172,7 @@ static int tweak_reset_device_cmd(struct urb *urb)
struct stub_priv *priv = (struct stub_priv *) urb->context;
struct stub_device *sdev = priv->sdev;
usbip_uinfo("reset_device %s\n", dev_name(&urb->dev->dev));
dev_info(&urb->dev->dev, "usb_queue_reset_device\n");
/*
* usb_lock_device_for_reset caused a deadlock: it causes the driver
......
......@@ -75,22 +75,23 @@ void stub_complete(struct urb *urb)
/* OK */
break;
case -ENOENT:
usbip_uinfo("stopped by a call of usb_kill_urb() because of"
"cleaning up a virtual connection\n");
dev_info(&urb->dev->dev, "stopped by a call to usb_kill_urb() "
"because of cleaning up a virtual connection\n");
return;
case -ECONNRESET:
usbip_uinfo("unlinked by a call of usb_unlink_urb()\n");
dev_info(&urb->dev->dev, "unlinked by a call to "
"usb_unlink_urb()\n");
break;
case -EPIPE:
usbip_uinfo("endpoint %d is stalled\n",
usb_pipeendpoint(urb->pipe));
dev_info(&urb->dev->dev, "endpoint %d is stalled\n",
usb_pipeendpoint(urb->pipe));
break;
case -ESHUTDOWN:
usbip_uinfo("device removed?\n");
dev_info(&urb->dev->dev, "device removed?\n");
break;
default:
usbip_uinfo("urb completion with non-zero status %d\n",
urb->status);
dev_info(&urb->dev->dev, "urb completion with non-zero status "
"%d\n", urb->status);
break;
}
......
This diff is collapsed.
......@@ -32,25 +32,13 @@
#define USBIP_VERSION "1.0.0"
/**
* usbip_udbg - print debug messages if CONFIG_USB_IP_DEBUG is defined
* @fmt:
* @args:
*/
#ifdef CONFIG_USB_IP_DEBUG
#define usbip_udbg(fmt, args...) \
do { \
printk(KERN_DEBUG "%-10s:(%s,%d) %s: " fmt, \
(in_interrupt() ? "interrupt" : (current)->comm),\
__FILE__, __LINE__, __func__, ##args); \
} while (0)
#undef pr_fmt
#ifdef DEBUG
#define pr_fmt(fmt) KBUILD_MODNAME ": %s:%d: " fmt, __func__, __LINE__
#else
#define usbip_udbg(fmt, args...) do { } while (0)
#endif /* CONFIG_USB_IP_DEBUG */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#endif
enum {
usbip_debug_xmit = (1 << 0),
......@@ -85,7 +73,7 @@ extern struct device_attribute dev_attr_usbip_debug;
#define usbip_dbg_with_flag(flag, fmt, args...) \
do { \
if (flag & usbip_debug_flag) \
usbip_udbg(fmt , ##args); \
pr_debug(fmt, ##args); \
} while (0)
#define usbip_dbg_sysfs(fmt, args...) \
......@@ -115,28 +103,6 @@ extern struct device_attribute dev_attr_usbip_debug;
#define usbip_dbg_stub_tx(fmt, args...) \
usbip_dbg_with_flag(usbip_debug_stub_tx, fmt , ##args)
/**
* usbip_uerr - print error messages
* @fmt:
* @args:
*/
#define usbip_uerr(fmt, args...) \
do { \
printk(KERN_ERR "%-10s: ***ERROR*** (%s,%d) %s: " fmt, \
(in_interrupt() ? "interrupt" : (current)->comm),\
__FILE__, __LINE__, __func__, ##args); \
} while (0)
/**
* usbip_uinfo - print information messages
* @fmt:
* @args:
*/
#define usbip_uinfo(fmt, args...) \
do { \
printk(KERN_INFO "usbip: " fmt , ## args); \
} while (0)
/*
* USB/IP request headers.
* Currently, we define 4 request types:
......
......@@ -84,8 +84,7 @@ int usbip_start_eh(struct usbip_device *ud)
ud->eh = kthread_run(event_handler_loop, ud, "usbip_eh");
if (IS_ERR(ud->eh)) {
printk(KERN_WARNING
"Unable to start control thread\n");
pr_warning("Unable to start control thread\n");
return PTR_ERR(ud->eh);
}
......
This diff is collapsed.
......@@ -74,10 +74,9 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
spin_unlock(&vdev->priv_lock);
if (!urb) {
usbip_uerr("cannot find a urb of seqnum %u\n",
pdu->base.seqnum);
usbip_uinfo("max seqnum %d\n",
atomic_read(&the_controller->seqnum));
pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
pr_info("max seqnum %d\n",
atomic_read(&the_controller->seqnum));
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return;
}
......@@ -121,7 +120,7 @@ static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev,
spin_lock(&vdev->priv_lock);
list_for_each_entry_safe(unlink, tmp, &vdev->unlink_rx, list) {
usbip_uinfo("unlink->seqnum %lu\n", unlink->seqnum);
pr_info("unlink->seqnum %lu\n", unlink->seqnum);
if (unlink->seqnum == pdu->base.seqnum) {
usbip_dbg_vhci_rx("found pending unlink, %lu\n",
unlink->seqnum);
......@@ -147,8 +146,8 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
unlink = dequeue_pending_unlink(vdev, pdu);
if (!unlink) {
usbip_uinfo("cannot find the pending unlink %u\n",
pdu->base.seqnum);
pr_info("cannot find the pending unlink %u\n",
pdu->base.seqnum);
return;
}
......@@ -162,14 +161,14 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
* already received the result of its submit result and gave
* back the URB.
*/
usbip_uinfo("the urb (seqnum %d) was already given backed\n",
pdu->base.seqnum);
pr_info("the urb (seqnum %d) was already given backed\n",
pdu->base.seqnum);
} else {
usbip_dbg_vhci_rx("now giveback urb %p\n", urb);
/* If unlink is succeed, status is -ECONNRESET */
urb->status = pdu->u.ret_unlink.status;
usbip_uinfo("%d\n", urb->status);
pr_info("urb->status %d\n", urb->status);
spin_lock(&the_controller->lock);
usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
......@@ -210,26 +209,26 @@ static void vhci_rx_pdu(struct usbip_device *ud)
ret = usbip_xmit(0, ud->tcp_socket, (char *) &pdu, sizeof(pdu), 0);
if (ret < 0) {
if (ret == -ECONNRESET)
usbip_uinfo("connection reset by peer\n");
pr_info("connection reset by peer\n");
else if (ret == -EAGAIN) {
/* ignore if connection was idle */
if (vhci_priv_tx_empty(vdev))
return;
usbip_uinfo("connection timed out with pending urbs\n");
pr_info("connection timed out with pending urbs\n");
} else if (ret != -ERESTARTSYS)
usbip_uinfo("xmit failed %d\n", ret);
pr_info("xmit failed %d\n", ret);
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return;
}
if (ret == 0) {
usbip_uinfo("connection closed");
pr_info("connection closed");
usbip_event_add(ud, VDEV_EVENT_DOWN);
return;
}
if (ret != sizeof(pdu)) {
usbip_uerr("received pdu size is %d, should be %d\n",
ret, (unsigned int)sizeof(pdu));
pr_err("received pdu size is %d, should be %d\n", ret,
(unsigned int)sizeof(pdu));
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
return;
}
......@@ -248,7 +247,7 @@ static void vhci_rx_pdu(struct usbip_device *ud)
break;
default:
/* NOT REACHED */
usbip_uerr("unknown pdu %u\n", pdu.base.command);
pr_err("unknown pdu %u\n", pdu.base.command);
usbip_dump_header(&pdu);
usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
break;
......
......@@ -89,7 +89,7 @@ static int vhci_port_disconnect(__u32 rhport)
spin_lock(&vdev->ud.lock);
if (vdev->ud.status == VDEV_ST_NULL) {
usbip_uerr("not connected %d\n", vdev->ud.status);
pr_err("not connected %d\n", vdev->ud.status);
/* unlock */
spin_unlock(&vdev->ud.lock);
......@@ -117,7 +117,7 @@ static ssize_t store_detach(struct device *dev, struct device_attribute *attr,
/* check rhport */
if (rhport >= VHCI_NPORTS) {
usbip_uerr("invalid port %u\n", rhport);
dev_err(dev, "invalid port %u\n", rhport);
return -EINVAL;
}
......@@ -136,7 +136,7 @@ static int valid_args(__u32 rhport, enum usb_device_speed speed)
{
/* check rhport */
if ((rhport < 0) || (rhport >= VHCI_NPORTS)) {
usbip_uerr("port %u\n", rhport);
pr_err("port %u\n", rhport);
return -EINVAL;
}
......@@ -148,7 +148,7 @@ static int valid_args(__u32 rhport, enum usb_device_speed speed)
case USB_SPEED_WIRELESS:
break;
default:
usbip_uerr("speed %d\n", speed);
pr_err("speed %d\n", speed);
return -EINVAL;
}
......@@ -206,12 +206,12 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
spin_unlock(&vdev->ud.lock);
spin_unlock(&the_controller->lock);
usbip_uerr("port %d already used\n", rhport);
dev_err(dev, "port %d already used\n", rhport);
return -EINVAL;
}
usbip_uinfo("rhport(%u) sockfd(%d) devid(%u) speed(%u)\n",
rhport, sockfd, devid, speed);
dev_info(dev, "rhport(%u) sockfd(%d) devid(%u) speed(%u)\n",
rhport, sockfd, devid, speed);
vdev->devid = devid;
vdev->speed = speed;
......
......@@ -118,8 +118,8 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev)
ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, iov, 3, txsize);
if (ret != txsize) {
usbip_uerr("sendmsg failed!, retval %d for %zd\n", ret,
txsize);
pr_err("sendmsg failed!, ret=%d for %zd\n", ret,
txsize);
kfree(iso_buffer);
usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_TCP);
return -1;
......@@ -188,8 +188,8 @@ static int vhci_send_cmd_unlink(struct vhci_device *vdev)
ret = kernel_sendmsg(vdev->ud.tcp_socket, &msg, iov, 1, txsize);
if (ret != txsize) {
usbip_uerr("sendmsg failed!, retval %d for %zd\n", ret,
txsize);
pr_err("sendmsg failed!, ret=%d for %zd\n", ret,
txsize);
usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_TCP);
return -1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment