n_hdlc: convert debuglevel use to pr_debug
With pr_debug we have a fine-grained control about debugging prints. So convert the use of global debuglevel variable and tests to a commonly used pr_debug. And drop debuglevel completely. This also implicitly adds a loglevel to the messages (KERN_DEBUG) as it was missing on most of them. And also use __func__ instead of function names explicitly typed. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20200219084118.26491-3-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>alistair/sensors
parent
683efabc66
commit
f3c2e27750
|
@ -160,10 +160,6 @@ static struct n_hdlc_buf *n_hdlc_buf_get(struct n_hdlc_buf_list *list);
|
||||||
|
|
||||||
static struct n_hdlc *n_hdlc_alloc (void);
|
static struct n_hdlc *n_hdlc_alloc (void);
|
||||||
|
|
||||||
/* debug level can be set by insmod for debugging purposes */
|
|
||||||
#define DEBUG_LEVEL_INFO 1
|
|
||||||
static int debuglevel;
|
|
||||||
|
|
||||||
/* max frame size for memory allocations */
|
/* max frame size for memory allocations */
|
||||||
static int maxframe = 4096;
|
static int maxframe = 4096;
|
||||||
|
|
||||||
|
@ -310,11 +306,9 @@ static int n_hdlc_tty_open (struct tty_struct *tty)
|
||||||
{
|
{
|
||||||
struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
|
struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
|
||||||
|
|
||||||
if (debuglevel >= DEBUG_LEVEL_INFO)
|
pr_debug("%s(%d)%s() called (device=%s)\n",
|
||||||
printk("%s(%d)n_hdlc_tty_open() called (device=%s)\n",
|
__FILE__, __LINE__, __func__, tty->name);
|
||||||
__FILE__,__LINE__,
|
|
||||||
tty->name);
|
|
||||||
|
|
||||||
/* There should not be an existing table for this slot. */
|
/* There should not be an existing table for this slot. */
|
||||||
if (n_hdlc) {
|
if (n_hdlc) {
|
||||||
printk (KERN_ERR"n_hdlc_tty_open:tty already associated!\n" );
|
printk (KERN_ERR"n_hdlc_tty_open:tty already associated!\n" );
|
||||||
|
@ -372,10 +366,9 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
|
||||||
|
|
||||||
tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list);
|
tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list);
|
||||||
while (tbuf) {
|
while (tbuf) {
|
||||||
if (debuglevel >= DEBUG_LEVEL_INFO)
|
pr_debug("%s(%d)sending frame %p, count=%d\n",
|
||||||
printk("%s(%d)sending frame %p, count=%d\n",
|
__FILE__, __LINE__, tbuf, tbuf->count);
|
||||||
__FILE__,__LINE__,tbuf,tbuf->count);
|
|
||||||
|
|
||||||
/* Send the next block of data to device */
|
/* Send the next block of data to device */
|
||||||
set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
|
set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
|
||||||
actual = tty->ops->write(tty, tbuf->buf, tbuf->count);
|
actual = tty->ops->write(tty, tbuf->buf, tbuf->count);
|
||||||
|
@ -391,10 +384,9 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
|
||||||
actual = tbuf->count;
|
actual = tbuf->count;
|
||||||
|
|
||||||
if (actual == tbuf->count) {
|
if (actual == tbuf->count) {
|
||||||
if (debuglevel >= DEBUG_LEVEL_INFO)
|
pr_debug("%s(%d)frame %p completed\n",
|
||||||
printk("%s(%d)frame %p completed\n",
|
__FILE__, __LINE__, tbuf);
|
||||||
__FILE__,__LINE__,tbuf);
|
|
||||||
|
|
||||||
/* free current transmit buffer */
|
/* free current transmit buffer */
|
||||||
n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, tbuf);
|
n_hdlc_buf_put(&n_hdlc->tx_free_buf_list, tbuf);
|
||||||
|
|
||||||
|
@ -404,9 +396,8 @@ static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty)
|
||||||
/* get next pending transmit buffer */
|
/* get next pending transmit buffer */
|
||||||
tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list);
|
tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list);
|
||||||
} else {
|
} else {
|
||||||
if (debuglevel >= DEBUG_LEVEL_INFO)
|
pr_debug("%s(%d)frame %p pending\n",
|
||||||
printk("%s(%d)frame %p pending\n",
|
__FILE__, __LINE__, tbuf);
|
||||||
__FILE__,__LINE__,tbuf);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* the buffer was not accepted by driver,
|
* the buffer was not accepted by driver,
|
||||||
|
@ -467,10 +458,9 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
|
||||||
register struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
|
register struct n_hdlc *n_hdlc = tty2n_hdlc (tty);
|
||||||
register struct n_hdlc_buf *buf;
|
register struct n_hdlc_buf *buf;
|
||||||
|
|
||||||
if (debuglevel >= DEBUG_LEVEL_INFO)
|
pr_debug("%s(%d)%s() called count=%d\n",
|
||||||
printk("%s(%d)n_hdlc_tty_receive() called count=%d\n",
|
__FILE__, __LINE__, __func__, count);
|
||||||
__FILE__,__LINE__, count);
|
|
||||||
|
|
||||||
/* This can happen if stuff comes in on the backup tty */
|
/* This can happen if stuff comes in on the backup tty */
|
||||||
if (!n_hdlc || tty != n_hdlc->tty)
|
if (!n_hdlc || tty != n_hdlc->tty)
|
||||||
return;
|
return;
|
||||||
|
@ -483,9 +473,8 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( count>maxframe ) {
|
if ( count>maxframe ) {
|
||||||
if (debuglevel >= DEBUG_LEVEL_INFO)
|
pr_debug("%s(%d) rx count>maxframesize, data discarded\n",
|
||||||
printk("%s(%d) rx count>maxframesize, data discarded\n",
|
__FILE__, __LINE__);
|
||||||
__FILE__,__LINE__);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,9 +489,8 @@ static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
if (debuglevel >= DEBUG_LEVEL_INFO)
|
pr_debug("%s(%d) no more rx buffers, data discarded\n",
|
||||||
printk("%s(%d) no more rx buffers, data discarded\n",
|
__FILE__, __LINE__);
|
||||||
__FILE__,__LINE__);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -619,10 +607,9 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
|
||||||
DECLARE_WAITQUEUE(wait, current);
|
DECLARE_WAITQUEUE(wait, current);
|
||||||
struct n_hdlc_buf *tbuf;
|
struct n_hdlc_buf *tbuf;
|
||||||
|
|
||||||
if (debuglevel >= DEBUG_LEVEL_INFO)
|
pr_debug("%s(%d)%s() called count=%zd\n", __FILE__, __LINE__, __func__,
|
||||||
printk("%s(%d)n_hdlc_tty_write() called count=%zd\n",
|
count);
|
||||||
__FILE__,__LINE__,count);
|
|
||||||
|
|
||||||
/* Verify pointers */
|
/* Verify pointers */
|
||||||
if (!n_hdlc)
|
if (!n_hdlc)
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
@ -632,11 +619,8 @@ static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file,
|
||||||
|
|
||||||
/* verify frame size */
|
/* verify frame size */
|
||||||
if (count > maxframe ) {
|
if (count > maxframe ) {
|
||||||
if (debuglevel & DEBUG_LEVEL_INFO)
|
pr_debug("%s: truncating user packet from %zu to %d\n",
|
||||||
printk (KERN_WARNING
|
__func__, count, maxframe);
|
||||||
"n_hdlc_tty_write: truncating user packet "
|
|
||||||
"from %lu to %d\n", (unsigned long) count,
|
|
||||||
maxframe );
|
|
||||||
count = maxframe;
|
count = maxframe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -704,10 +688,8 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, struct file *file,
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct n_hdlc_buf *buf = NULL;
|
struct n_hdlc_buf *buf = NULL;
|
||||||
|
|
||||||
if (debuglevel >= DEBUG_LEVEL_INFO)
|
pr_debug("%s(%d)%s() called %d\n", __FILE__, __LINE__, __func__, cmd);
|
||||||
printk("%s(%d)n_hdlc_tty_ioctl() called %d\n",
|
|
||||||
__FILE__,__LINE__,cmd);
|
|
||||||
|
|
||||||
/* Verify the status of the device */
|
/* Verify the status of the device */
|
||||||
if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC)
|
if (!n_hdlc || n_hdlc->magic != HDLC_MAGIC)
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
@ -822,8 +804,9 @@ static struct n_hdlc *n_hdlc_alloc(void)
|
||||||
buf = kmalloc(struct_size(buf, buf, maxframe), GFP_KERNEL);
|
buf = kmalloc(struct_size(buf, buf, maxframe), GFP_KERNEL);
|
||||||
if (buf)
|
if (buf)
|
||||||
n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,buf);
|
n_hdlc_buf_put(&n_hdlc->rx_free_buf_list,buf);
|
||||||
else if (debuglevel >= DEBUG_LEVEL_INFO)
|
else
|
||||||
printk("%s(%d)n_hdlc_alloc(), kalloc() failed for rx buffer %d\n",__FILE__,__LINE__, i);
|
pr_debug("%s(%d)%s(), kmalloc() failed for rx buffer %d\n",
|
||||||
|
__FILE__, __LINE__, __func__, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate free tx buffer list */
|
/* allocate free tx buffer list */
|
||||||
|
@ -831,8 +814,9 @@ static struct n_hdlc *n_hdlc_alloc(void)
|
||||||
buf = kmalloc(struct_size(buf, buf, maxframe), GFP_KERNEL);
|
buf = kmalloc(struct_size(buf, buf, maxframe), GFP_KERNEL);
|
||||||
if (buf)
|
if (buf)
|
||||||
n_hdlc_buf_put(&n_hdlc->tx_free_buf_list,buf);
|
n_hdlc_buf_put(&n_hdlc->tx_free_buf_list,buf);
|
||||||
else if (debuglevel >= DEBUG_LEVEL_INFO)
|
else
|
||||||
printk("%s(%d)n_hdlc_alloc(), kalloc() failed for tx buffer %d\n",__FILE__,__LINE__, i);
|
pr_debug("%s(%d)%s(), kmalloc() failed for tx buffer %d\n",
|
||||||
|
__FILE__, __LINE__, __func__, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the control block */
|
/* Initialize the control block */
|
||||||
|
@ -960,6 +944,5 @@ module_exit(n_hdlc_exit);
|
||||||
|
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
MODULE_AUTHOR("Paul Fulghum paulkf@microgate.com");
|
MODULE_AUTHOR("Paul Fulghum paulkf@microgate.com");
|
||||||
module_param(debuglevel, int, 0);
|
|
||||||
module_param(maxframe, int, 0);
|
module_param(maxframe, int, 0);
|
||||||
MODULE_ALIAS_LDISC(N_HDLC);
|
MODULE_ALIAS_LDISC(N_HDLC);
|
||||||
|
|
Loading…
Reference in New Issue