format files to comply with kernel coding standards, rename .config to config
This commit is contained in:
11
07/foo.c
11
07/foo.c
@ -1,3 +1,4 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/fs.h>
|
||||
@ -13,7 +14,7 @@ ssize_t foo_write(struct file *f, const char __user *buf, size_t len, loff_t *of
|
||||
int init_foo(void);
|
||||
|
||||
char buffer[PAGE_SIZE];
|
||||
size_t buffer_len = 0;
|
||||
size_t buffer_len;
|
||||
DEFINE_MUTEX(rw_lock);
|
||||
|
||||
static const struct file_operations fops = {
|
||||
@ -26,7 +27,7 @@ static const struct file_operations fops = {
|
||||
ssize_t foo_read(struct file *f, char __user *buf, size_t len, loff_t *off)
|
||||
{
|
||||
size_t read;
|
||||
|
||||
|
||||
mutex_lock(&rw_lock);
|
||||
read = simple_read_from_buffer(buf, len, off, buffer, buffer_len);
|
||||
mutex_unlock(&rw_lock);
|
||||
@ -39,8 +40,7 @@ ssize_t foo_write(struct file *f, const char __user *buf, size_t len, loff_t *of
|
||||
if (len > sizeof(buffer))
|
||||
return -EINVAL;
|
||||
mutex_lock(&rw_lock);
|
||||
if (copy_from_user(buffer, buf, len))
|
||||
{
|
||||
if (copy_from_user(buffer, buf, len)) {
|
||||
mutex_unlock(&rw_lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
@ -55,6 +55,7 @@ int init_foo(void)
|
||||
|
||||
mutex_init(&rw_lock);
|
||||
ret = debugfs_create_file("foo", 0644, module_dir, NULL, &fops);
|
||||
if (IS_ERR(ret)) return PTR_ERR(ret);
|
||||
if (IS_ERR(ret))
|
||||
return PTR_ERR(ret);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user