Skip to content

Remove redundant code #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions examples/chardev.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ static ssize_t device_read(struct file *, char __user *, size_t, loff_t *);
static ssize_t device_write(struct file *, const char __user *, size_t,
loff_t *);

#define SUCCESS 0
#define DEVICE_NAME "chardev" /* Dev name as it appears in /proc/devices */
#define BUF_LEN 80 /* Max length of the message from the device */

Expand Down Expand Up @@ -72,7 +71,7 @@ static int __init chardev_init(void)

pr_info("Device created on /dev/%s\n", DEVICE_NAME);

return SUCCESS;
return 0;
}

static void __exit chardev_exit(void)
Expand All @@ -99,7 +98,7 @@ static int device_open(struct inode *inode, struct file *file)
sprintf(msg, "I already told you %d times Hello world!\n", counter++);
try_module_get(THIS_MODULE);

return SUCCESS;
return 0;
}

/* Called when a process closes the device file. */
Expand All @@ -113,7 +112,7 @@ static int device_release(struct inode *inode, struct file *file)
*/
module_put(THIS_MODULE);

return SUCCESS;
return 0;
}

/* Called when a process, which already opened the dev file, attempts to
Expand Down
7 changes: 3 additions & 4 deletions examples/chardev2.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <asm/errno.h>

#include "chardev.h"
#define SUCCESS 0
#define DEVICE_NAME "char_dev"
#define BUF_LEN 80

Expand All @@ -42,15 +41,15 @@ static int device_open(struct inode *inode, struct file *file)
pr_info("device_open(%p)\n", file);

try_module_get(THIS_MODULE);
return SUCCESS;
return 0;
}

static int device_release(struct inode *inode, struct file *file)
{
pr_info("device_release(%p,%p)\n", inode, file);

module_put(THIS_MODULE);
return SUCCESS;
return 0;
}

/* This function is called whenever a process which has already opened the
Expand Down Expand Up @@ -126,7 +125,7 @@ device_ioctl(struct file *file, /* ditto */
unsigned long ioctl_param)
{
int i;
long ret = SUCCESS;
long ret = 0;

/* We don't want to talk to two processes at the same time. */
if (atomic_cmpxchg(&already_open, CDEV_NOT_USED, CDEV_EXCLUSIVE_OPEN))
Expand Down
7 changes: 3 additions & 4 deletions examples/static_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
static ssize_t device_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos);

#define SUCCESS 0
#define DEVICE_NAME "key_state"
#define BUF_LEN 10

Expand Down Expand Up @@ -71,7 +70,7 @@ static int __init chardev_init(void)

pr_info("Device created on /dev/%s\n", DEVICE_NAME);

return SUCCESS;
return 0;
}

static void __exit chardev_exit(void)
Expand Down Expand Up @@ -103,7 +102,7 @@ static int device_open(struct inode *inode, struct file *file)

try_module_get(THIS_MODULE);

return SUCCESS;
return 0;
}

/**
Expand All @@ -120,7 +119,7 @@ static int device_release(struct inode *inode, struct file *file)
*/
module_put(THIS_MODULE);

return SUCCESS;
return 0;
}

/**
Expand Down