Skip to content

Commit ef553aa

Browse files
authored
Merge pull request #293 from jeremy90307/master
Remove redundant code
2 parents e061eaf + d1d76f7 commit ef553aa

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

examples/chardev.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ static ssize_t device_read(struct file *, char __user *, size_t, loff_t *);
2525
static ssize_t device_write(struct file *, const char __user *, size_t,
2626
loff_t *);
2727

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

@@ -72,7 +71,7 @@ static int __init chardev_init(void)
7271

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

75-
return SUCCESS;
74+
return 0;
7675
}
7776

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

102-
return SUCCESS;
101+
return 0;
103102
}
104103

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

116-
return SUCCESS;
115+
return 0;
117116
}
118117

119118
/* Called when a process, which already opened the dev file, attempts to

examples/chardev2.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include <asm/errno.h>
1818

1919
#include "chardev.h"
20-
#define SUCCESS 0
2120
#define DEVICE_NAME "char_dev"
2221
#define BUF_LEN 80
2322

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

4443
try_module_get(THIS_MODULE);
45-
return SUCCESS;
44+
return 0;
4645
}
4746

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

5251
module_put(THIS_MODULE);
53-
return SUCCESS;
52+
return 0;
5453
}
5554

5655
/* This function is called whenever a process which has already opened the
@@ -126,7 +125,7 @@ device_ioctl(struct file *file, /* ditto */
126125
unsigned long ioctl_param)
127126
{
128127
int i;
129-
long ret = SUCCESS;
128+
long ret = 0;
130129

131130
/* We don't want to talk to two processes at the same time. */
132131
if (atomic_cmpxchg(&already_open, CDEV_NOT_USED, CDEV_EXCLUSIVE_OPEN))

examples/static_key.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ static ssize_t device_read(struct file *file, char __user *buf, size_t count,
2222
static ssize_t device_write(struct file *file, const char __user *buf,
2323
size_t count, loff_t *ppos);
2424

25-
#define SUCCESS 0
2625
#define DEVICE_NAME "key_state"
2726
#define BUF_LEN 10
2827

@@ -71,7 +70,7 @@ static int __init chardev_init(void)
7170

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

74-
return SUCCESS;
73+
return 0;
7574
}
7675

7776
static void __exit chardev_exit(void)
@@ -103,7 +102,7 @@ static int device_open(struct inode *inode, struct file *file)
103102

104103
try_module_get(THIS_MODULE);
105104

106-
return SUCCESS;
105+
return 0;
107106
}
108107

109108
/**
@@ -120,7 +119,7 @@ static int device_release(struct inode *inode, struct file *file)
120119
*/
121120
module_put(THIS_MODULE);
122121

123-
return SUCCESS;
122+
return 0;
124123
}
125124

126125
/**

0 commit comments

Comments
 (0)