提交 7b5cd5fe 编写于 作者: F Felipe Balbi 提交者: Greg Kroah-Hartman

USB: SisUSB2VGA: Convert printk to dev_* macros

This patch convert printk entries to dev_* macros, this provide better
debugging and better readability to the code.
Signed-off-by: NFelipe Balbi <felipe.lima@indt.org.br>
Cc: Thomas <thomas@winischhofer.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 ecb8b190
...@@ -1003,16 +1003,10 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr, ...@@ -1003,16 +1003,10 @@ static int sisusb_write_mem_bulk(struct sisusb_usb_data *sisusb, u32 addr,
if (ret) { if (ret) {
msgcount++; msgcount++;
if (msgcount < 500) if (msgcount < 500)
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Wrote %zd of %d bytes, error %d\n",
"sisusbvga[%d]: Wrote %zd of " *bytes_written, length, ret);
"%d bytes, error %d\n",
sisusb->minor, *bytes_written,
length, ret);
else if (msgcount == 500) else if (msgcount == 500)
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Too many errors, logging stopped\n");
"sisusbvga[%d]: Too many errors"
", logging stopped\n",
sisusb->minor);
} }
addr += (*bytes_written); addr += (*bytes_written);
length -= (*bytes_written); length -= (*bytes_written);
...@@ -1389,10 +1383,10 @@ sisusb_testreadwrite(struct sisusb_usb_data *sisusb) ...@@ -1389,10 +1383,10 @@ sisusb_testreadwrite(struct sisusb_usb_data *sisusb)
sisusb_copy_memory(sisusb, srcbuffer, sisusb->vrambase, 7, &dummy); sisusb_copy_memory(sisusb, srcbuffer, sisusb->vrambase, 7, &dummy);
for(i = 1; i <= 7; i++) { for(i = 1; i <= 7; i++) {
printk(KERN_DEBUG "sisusb: rwtest %d bytes\n", i); dev_dbg(&sisusb->sisusb_dev->dev, "sisusb: rwtest %d bytes\n", i);
sisusb_read_memory(sisusb, destbuffer, sisusb->vrambase, i, &dummy); sisusb_read_memory(sisusb, destbuffer, sisusb->vrambase, i, &dummy);
for(j = 0; j < i; j++) { for(j = 0; j < i; j++) {
printk(KERN_DEBUG "sisusb: rwtest read[%d] = %x\n", j, destbuffer[j]); dev_dbg(&sisusb->sisusb_dev->dev, "rwtest read[%d] = %x\n", j, destbuffer[j]);
} }
} }
} }
...@@ -2111,17 +2105,12 @@ sisusb_init_gfxcore(struct sisusb_usb_data *sisusb) ...@@ -2111,17 +2105,12 @@ sisusb_init_gfxcore(struct sisusb_usb_data *sisusb)
if (ramtype <= 1) { if (ramtype <= 1) {
ret |= sisusb_get_sdram_size(sisusb, &iret, bw, chab); ret |= sisusb_get_sdram_size(sisusb, &iret, bw, chab);
if (iret) { if (iret) {
printk(KERN_ERR "sisusbvga[%d]: RAM size " dev_err(&sisusb->sisusb_dev->dev,"RAM size detection failed, assuming 8MB video RAM\n");
"detection failed, "
"assuming 8MB video RAM\n",
sisusb->minor);
ret |= SETIREG(SISSR,0x14,0x31); ret |= SETIREG(SISSR,0x14,0x31);
/* TODO */ /* TODO */
} }
} else { } else {
printk(KERN_ERR "sisusbvga[%d]: DDR RAM device found, " dev_err(&sisusb->sisusb_dev->dev, "DDR RAM device found, assuming 8MB video RAM\n");
"assuming 8MB video RAM\n",
sisusb->minor);
ret |= SETIREG(SISSR,0x14,0x31); ret |= SETIREG(SISSR,0x14,0x31);
/* *** TODO *** */ /* *** TODO *** */
} }
...@@ -2192,8 +2181,7 @@ sisusb_get_ramconfig(struct sisusb_usb_data *sisusb) ...@@ -2192,8 +2181,7 @@ sisusb_get_ramconfig(struct sisusb_usb_data *sisusb)
break; break;
} }
printk(KERN_INFO "sisusbvga[%d]: %dMB %s %s, bus width %d\n", dev_info(&sisusb->sisusb_dev->dev, "%dMB %s %s, bus width %d\n", (sisusb->vramsize >> 20), ramtypetext1,
sisusb->minor, (sisusb->vramsize >> 20), ramtypetext1,
ramtypetext2[ramtype], bw); ramtypetext2[ramtype], bw);
} }
...@@ -2453,8 +2441,7 @@ sisusb_open(struct inode *inode, struct file *file) ...@@ -2453,8 +2441,7 @@ sisusb_open(struct inode *inode, struct file *file)
int subminor = iminor(inode); int subminor = iminor(inode);
if (!(interface = usb_find_interface(&sisusb_driver, subminor))) { if (!(interface = usb_find_interface(&sisusb_driver, subminor))) {
printk(KERN_ERR "sisusb[%d]: Failed to find interface\n", dev_err(&sisusb->sisusb_dev->dev, "Failed to find interface\n");
subminor);
return -ENODEV; return -ENODEV;
} }
...@@ -2477,18 +2464,12 @@ sisusb_open(struct inode *inode, struct file *file) ...@@ -2477,18 +2464,12 @@ sisusb_open(struct inode *inode, struct file *file)
if (sisusb->sisusb_dev->speed == USB_SPEED_HIGH) { if (sisusb->sisusb_dev->speed == USB_SPEED_HIGH) {
if (sisusb_init_gfxdevice(sisusb, 0)) { if (sisusb_init_gfxdevice(sisusb, 0)) {
mutex_unlock(&sisusb->lock); mutex_unlock(&sisusb->lock);
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Failed to initialize device\n");
"sisusbvga[%d]: Failed to initialize "
"device\n",
sisusb->minor);
return -EIO; return -EIO;
} }
} else { } else {
mutex_unlock(&sisusb->lock); mutex_unlock(&sisusb->lock);
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Device not attached to USB 2.0 hub\n");
"sisusbvga[%d]: Device not attached to "
"USB 2.0 hub\n",
sisusb->minor);
return -EIO; return -EIO;
} }
} }
...@@ -2529,7 +2510,6 @@ static int ...@@ -2529,7 +2510,6 @@ static int
sisusb_release(struct inode *inode, struct file *file) sisusb_release(struct inode *inode, struct file *file)
{ {
struct sisusb_usb_data *sisusb; struct sisusb_usb_data *sisusb;
int myminor;
if (!(sisusb = (struct sisusb_usb_data *)file->private_data)) if (!(sisusb = (struct sisusb_usb_data *)file->private_data))
return -ENODEV; return -ENODEV;
...@@ -2542,8 +2522,6 @@ sisusb_release(struct inode *inode, struct file *file) ...@@ -2542,8 +2522,6 @@ sisusb_release(struct inode *inode, struct file *file)
sisusb_kill_all_busy(sisusb); sisusb_kill_all_busy(sisusb);
} }
myminor = sisusb->minor;
sisusb->isopen = 0; sisusb->isopen = 0;
file->private_data = NULL; file->private_data = NULL;
...@@ -3126,17 +3104,13 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3126,17 +3104,13 @@ static int sisusb_probe(struct usb_interface *intf,
struct usb_device *dev = interface_to_usbdev(intf); struct usb_device *dev = interface_to_usbdev(intf);
struct sisusb_usb_data *sisusb; struct sisusb_usb_data *sisusb;
int retval = 0, i; int retval = 0, i;
const char *memfail =
KERN_ERR
"sisusbvga[%d]: Failed to allocate memory for %s buffer\n";
printk(KERN_INFO "sisusb: USB2VGA dongle found at address %d\n", dev_info(&dev->dev, "USB2VGA dongle found at address %d\n",
dev->devnum); dev->devnum);
/* Allocate memory for our private */ /* Allocate memory for our private */
if (!(sisusb = kzalloc(sizeof(*sisusb), GFP_KERNEL))) { if (!(sisusb = kzalloc(sizeof(*sisusb), GFP_KERNEL))) {
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for private data\n");
"sisusb: Failed to allocate memory for private data\n");
return -ENOMEM; return -ENOMEM;
} }
kref_init(&sisusb->kref); kref_init(&sisusb->kref);
...@@ -3145,8 +3119,7 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3145,8 +3119,7 @@ static int sisusb_probe(struct usb_interface *intf,
/* Register device */ /* Register device */
if ((retval = usb_register_dev(intf, &usb_sisusb_class))) { if ((retval = usb_register_dev(intf, &usb_sisusb_class))) {
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Failed to get a minor for device %d\n",
"sisusb: Failed to get a minor for device %d\n",
dev->devnum); dev->devnum);
retval = -ENODEV; retval = -ENODEV;
goto error_1; goto error_1;
...@@ -3164,7 +3137,7 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3164,7 +3137,7 @@ static int sisusb_probe(struct usb_interface *intf,
sisusb->ibufsize = SISUSB_IBUF_SIZE; sisusb->ibufsize = SISUSB_IBUF_SIZE;
if (!(sisusb->ibuf = usb_buffer_alloc(dev, SISUSB_IBUF_SIZE, if (!(sisusb->ibuf = usb_buffer_alloc(dev, SISUSB_IBUF_SIZE,
GFP_KERNEL, &sisusb->transfer_dma_in))) { GFP_KERNEL, &sisusb->transfer_dma_in))) {
printk(memfail, "input", sisusb->minor); dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for input buffer");
retval = -ENOMEM; retval = -ENOMEM;
goto error_2; goto error_2;
} }
...@@ -3176,7 +3149,7 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3176,7 +3149,7 @@ static int sisusb_probe(struct usb_interface *intf,
GFP_KERNEL, GFP_KERNEL,
&sisusb->transfer_dma_out[i]))) { &sisusb->transfer_dma_out[i]))) {
if (i == 0) { if (i == 0) {
printk(memfail, "output", sisusb->minor); dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for output buffer\n");
retval = -ENOMEM; retval = -ENOMEM;
goto error_3; goto error_3;
} }
...@@ -3188,9 +3161,7 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3188,9 +3161,7 @@ static int sisusb_probe(struct usb_interface *intf,
/* Allocate URBs */ /* Allocate URBs */
if (!(sisusb->sisurbin = usb_alloc_urb(0, GFP_KERNEL))) { if (!(sisusb->sisurbin = usb_alloc_urb(0, GFP_KERNEL))) {
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate URBs\n");
"sisusbvga[%d]: Failed to allocate URBs\n",
sisusb->minor);
retval = -ENOMEM; retval = -ENOMEM;
goto error_3; goto error_3;
} }
...@@ -3198,9 +3169,7 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3198,9 +3169,7 @@ static int sisusb_probe(struct usb_interface *intf,
for (i = 0; i < sisusb->numobufs; i++) { for (i = 0; i < sisusb->numobufs; i++) {
if (!(sisusb->sisurbout[i] = usb_alloc_urb(0, GFP_KERNEL))) { if (!(sisusb->sisurbout[i] = usb_alloc_urb(0, GFP_KERNEL))) {
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate URBs\n");
"sisusbvga[%d]: Failed to allocate URBs\n",
sisusb->minor);
retval = -ENOMEM; retval = -ENOMEM;
goto error_4; goto error_4;
} }
...@@ -3209,15 +3178,12 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3209,15 +3178,12 @@ static int sisusb_probe(struct usb_interface *intf,
sisusb->urbstatus[i] = 0; sisusb->urbstatus[i] = 0;
} }
printk(KERN_INFO "sisusbvga[%d]: Allocated %d output buffers\n", dev_info(&sisusb->sisusb_dev->dev, "Allocated %d output buffers\n", sisusb->numobufs);
sisusb->minor, sisusb->numobufs);
#ifdef INCL_SISUSB_CON #ifdef INCL_SISUSB_CON
/* Allocate our SiS_Pr */ /* Allocate our SiS_Pr */
if (!(sisusb->SiS_Pr = kmalloc(sizeof(struct SiS_Private), GFP_KERNEL))) { if (!(sisusb->SiS_Pr = kmalloc(sizeof(struct SiS_Private), GFP_KERNEL))) {
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate SiS_Pr\n");
"sisusbvga[%d]: Failed to allocate SiS_Pr\n",
sisusb->minor);
} }
#endif #endif
...@@ -3239,10 +3205,7 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3239,10 +3205,7 @@ static int sisusb_probe(struct usb_interface *intf,
ret |= register_ioctl32_conversion(SISUSB_GET_CONFIG, NULL); ret |= register_ioctl32_conversion(SISUSB_GET_CONFIG, NULL);
ret |= register_ioctl32_conversion(SISUSB_COMMAND, NULL); ret |= register_ioctl32_conversion(SISUSB_COMMAND, NULL);
if (ret) if (ret)
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Error registering ioctl32 translations\n");
"sisusbvga[%d]: Error registering ioctl32 "
"translations\n",
sisusb->minor);
else else
sisusb->ioctl32registered = 1; sisusb->ioctl32registered = 1;
} }
...@@ -3258,23 +3221,17 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3258,23 +3221,17 @@ static int sisusb_probe(struct usb_interface *intf,
initscreen = 0; initscreen = 0;
#endif #endif
if (sisusb_init_gfxdevice(sisusb, initscreen)) if (sisusb_init_gfxdevice(sisusb, initscreen))
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Failed to early initialize device\n");
"sisusbvga[%d]: Failed to early "
"initialize device\n",
sisusb->minor);
} else } else
printk(KERN_INFO dev_info(&sisusb->sisusb_dev->dev, "Not attached to USB 2.0 hub, deferring init\n");
"sisusbvga[%d]: Not attached to USB 2.0 hub, "
"deferring init\n",
sisusb->minor);
sisusb->ready = 1; sisusb->ready = 1;
#ifdef SISUSBENDIANTEST #ifdef SISUSBENDIANTEST
printk(KERN_DEBUG "sisusb: *** RWTEST ***\n"); dev_dbg(&sisusb->sisusb_dev->dev, "*** RWTEST ***\n");
sisusb_testreadwrite(sisusb); sisusb_testreadwrite(sisusb);
printk(KERN_DEBUG "sisusb: *** RWTEST END ***\n"); dev_dbg(&sisusb->sisusb_dev->dev, "*** RWTEST END ***\n");
#endif #endif
#ifdef INCL_SISUSB_CON #ifdef INCL_SISUSB_CON
...@@ -3297,7 +3254,6 @@ static int sisusb_probe(struct usb_interface *intf, ...@@ -3297,7 +3254,6 @@ static int sisusb_probe(struct usb_interface *intf,
static void sisusb_disconnect(struct usb_interface *intf) static void sisusb_disconnect(struct usb_interface *intf)
{ {
struct sisusb_usb_data *sisusb; struct sisusb_usb_data *sisusb;
int minor;
/* This should *not* happen */ /* This should *not* happen */
if (!(sisusb = usb_get_intfdata(intf))) if (!(sisusb = usb_get_intfdata(intf)))
...@@ -3307,8 +3263,6 @@ static void sisusb_disconnect(struct usb_interface *intf) ...@@ -3307,8 +3263,6 @@ static void sisusb_disconnect(struct usb_interface *intf)
sisusb_console_exit(sisusb); sisusb_console_exit(sisusb);
#endif #endif
minor = sisusb->minor;
usb_deregister_dev(intf, &usb_sisusb_class); usb_deregister_dev(intf, &usb_sisusb_class);
mutex_lock(&sisusb->lock); mutex_lock(&sisusb->lock);
...@@ -3327,10 +3281,7 @@ static void sisusb_disconnect(struct usb_interface *intf) ...@@ -3327,10 +3281,7 @@ static void sisusb_disconnect(struct usb_interface *intf)
ret |= unregister_ioctl32_conversion(SISUSB_GET_CONFIG); ret |= unregister_ioctl32_conversion(SISUSB_GET_CONFIG);
ret |= unregister_ioctl32_conversion(SISUSB_COMMAND); ret |= unregister_ioctl32_conversion(SISUSB_COMMAND);
if (ret) { if (ret) {
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Error unregistering ioctl32 translations\n");
"sisusbvga[%d]: Error unregistering "
"ioctl32 translations\n",
minor);
} }
} }
#endif #endif
...@@ -3343,7 +3294,7 @@ static void sisusb_disconnect(struct usb_interface *intf) ...@@ -3343,7 +3294,7 @@ static void sisusb_disconnect(struct usb_interface *intf)
/* decrement our usage count */ /* decrement our usage count */
kref_put(&sisusb->kref, sisusb_delete); kref_put(&sisusb->kref, sisusb_delete);
printk(KERN_INFO "sisusbvga[%d]: Disconnected\n", minor); dev_info(&sisusb->sisusb_dev->dev, "Disconnected\n");
} }
static struct usb_device_id sisusb_table [] = { static struct usb_device_id sisusb_table [] = {
...@@ -3368,6 +3319,7 @@ static struct usb_driver sisusb_driver = { ...@@ -3368,6 +3319,7 @@ static struct usb_driver sisusb_driver = {
static int __init usb_sisusb_init(void) static int __init usb_sisusb_init(void)
{ {
int retval; int retval;
struct sisusb_usb_data *sisusb;
#ifdef INCL_SISUSB_CON #ifdef INCL_SISUSB_CON
sisusb_init_concode(); sisusb_init_concode();
...@@ -3375,10 +3327,9 @@ static int __init usb_sisusb_init(void) ...@@ -3375,10 +3327,9 @@ static int __init usb_sisusb_init(void)
if (!(retval = usb_register(&sisusb_driver))) { if (!(retval = usb_register(&sisusb_driver))) {
printk(KERN_INFO "sisusb: Driver version %d.%d.%d\n", dev_info(&sisusb->sisusb_dev->dev, "Driver version %d.%d.%d\n", SISUSB_VERSION,
SISUSB_VERSION, SISUSB_REVISION, SISUSB_PATCHLEVEL); SISUSB_REVISION, SISUSB_PATCHLEVEL);
printk(KERN_INFO dev_info(&sisusb->sisusb_dev->dev, "sisusb: Copyright (C) 2005 Thomas Winischhofer\n");
"sisusb: Copyright (C) 2005 Thomas Winischhofer\n");
} }
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/signal.h> #include <linux/signal.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/usb.h>
#include <linux/tty.h> #include <linux/tty.h>
#include <linux/console.h> #include <linux/console.h>
#include <linux/string.h> #include <linux/string.h>
...@@ -537,7 +538,7 @@ sisusbcon_switch(struct vc_data *c) ...@@ -537,7 +538,7 @@ sisusbcon_switch(struct vc_data *c)
*/ */
if (c->vc_origin == (unsigned long)c->vc_screenbuf) { if (c->vc_origin == (unsigned long)c->vc_screenbuf) {
mutex_unlock(&sisusb->lock); mutex_unlock(&sisusb->lock);
printk(KERN_DEBUG "sisusb: ASSERT ORIGIN != SCREENBUF!\n"); dev_dbg(&sisusb->sisusb_dev->dev, "ASSERT ORIGIN != SCREENBUF!\n");
return 0; return 0;
} }
...@@ -1428,7 +1429,7 @@ static const struct consw sisusb_dummy_con = { ...@@ -1428,7 +1429,7 @@ static const struct consw sisusb_dummy_con = {
int int
sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last) sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last)
{ {
int i, ret, minor = sisusb->minor; int i, ret;
mutex_lock(&sisusb->lock); mutex_lock(&sisusb->lock);
...@@ -1461,9 +1462,7 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last) ...@@ -1461,9 +1462,7 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last)
/* Set up text mode (and upload default font) */ /* Set up text mode (and upload default font) */
if (sisusb_reset_text_mode(sisusb, 1)) { if (sisusb_reset_text_mode(sisusb, 1)) {
mutex_unlock(&sisusb->lock); mutex_unlock(&sisusb->lock);
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Failed to set up text mode\n");
"sisusbvga[%d]: Failed to set up text mode\n",
minor);
return 1; return 1;
} }
...@@ -1484,9 +1483,7 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last) ...@@ -1484,9 +1483,7 @@ sisusb_console_init(struct sisusb_usb_data *sisusb, int first, int last)
/* Allocate screen buffer */ /* Allocate screen buffer */
if (!(sisusb->scrbuf = (unsigned long)vmalloc(sisusb->scrbuf_size))) { if (!(sisusb->scrbuf = (unsigned long)vmalloc(sisusb->scrbuf_size))) {
mutex_unlock(&sisusb->lock); mutex_unlock(&sisusb->lock);
printk(KERN_ERR dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate screen buffer\n");
"sisusbvga[%d]: Failed to allocate screen buffer\n",
minor);
return 1; return 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册