format files to comply with kernel coding standards, rename .config to config

This commit is contained in:
2025-08-13 19:45:11 +02:00
parent 2e4d67d510
commit cf0ab7f1db
10 changed files with 97 additions and 83 deletions

View File

@ -1,3 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
@ -21,6 +22,7 @@ static const struct file_operations fops = {
ssize_t id_read(struct file *f, char __user *buf, size_t len, loff_t *off)
{
char msg[] = VALUE;
pr_info("someone read from the file\n");
return simple_read_from_buffer(buf, len, off, msg, sizeof(msg) - 1);
}
@ -29,6 +31,7 @@ ssize_t id_read(struct file *f, char __user *buf, size_t len, loff_t *off)
ssize_t id_write(struct file *f, const char __user *buf, size_t len, loff_t *off)
{
char kbuf[64];
if (len > sizeof(kbuf) - 1)
return -EINVAL;
if (copy_from_user(kbuf, buf, len))
@ -36,7 +39,7 @@ ssize_t id_write(struct file *f, const char __user *buf, size_t len, loff_t *off
kbuf[len] = '\0';
if (strcmp(kbuf, VALUE) == 0){
if (strcmp(kbuf, VALUE) == 0) {
pr_info("someone wrote the right string\n");
return len;
}
@ -47,8 +50,9 @@ ssize_t id_write(struct file *f, const char __user *buf, size_t len, loff_t *off
int init_id(void)
{
struct dentry *ret;
ret = debugfs_create_file("id", 0666, module_dir, NULL, &fops);
if(IS_ERR(ret))
if (IS_ERR(ret))
return PTR_ERR(ret);
return 0;
}