From 1c93f2f5ef03cb2d32b15c246722e5b7ce67107a Mon Sep 17 00:00:00 2001 From: Jim Huang Date: Thu, 22 Jul 2021 10:55:14 +0800 Subject: [PATCH] Shorten sample code --- examples/chardev2.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/examples/chardev2.c b/examples/chardev2.c index cdfb32d..8e26003 100644 --- a/examples/chardev2.c +++ b/examples/chardev2.c @@ -43,9 +43,7 @@ static struct class *cls; */ static int device_open(struct inode *inode, struct file *file) { -#ifdef DEBUG pr_info("device_open(%p)\n", file); -#endif /* * We don't want to talk to two processes at the same time @@ -64,9 +62,7 @@ static int device_open(struct inode *inode, struct file *file) static int device_release(struct inode *inode, struct file *file) { -#ifdef DEBUG pr_info("device_release(%p,%p)\n", inode, file); -#endif /* * We're now ready for our next caller @@ -92,9 +88,7 @@ static ssize_t device_read(struct file *file, /* see include/linux/fs.h */ */ int bytes_read = 0; -#ifdef DEBUG - pr_info("device_read(%p,%p,%d)\n", file, buffer, length); -#endif + pr_info("device_read(%p,%p,%ld)\n", file, buffer, length); /* * If we're at the end of the message, return 0 @@ -119,9 +113,7 @@ static ssize_t device_read(struct file *file, /* see include/linux/fs.h */ bytes_read++; } -#ifdef DEBUG - pr_info("Read %d bytes, %d left\n", bytes_read, length); -#endif + pr_info("Read %d bytes, %ld left\n", bytes_read, length); /* * Read functions are supposed to return the number @@ -141,9 +133,7 @@ static ssize_t device_write(struct file *file, { int i; -#ifdef DEBUG - pr_info("device_write(%p,%s,%d)", file, buffer, length); -#endif + pr_info("device_write(%p,%s,%ld)", file, buffer, length); for (i = 0; i < length && i < BUF_LEN; i++) get_user(Message[i], buffer + i);