Run clang-format
This commit is contained in:
parent
372b482212
commit
d149cbe6a5
12 changed files with 974 additions and 132 deletions
|
@ -8,7 +8,7 @@
|
|||
#define CLASS_NAME "chardrv"
|
||||
|
||||
static int major_number;
|
||||
static char msg[256] = {0};
|
||||
static char msg[256] = { 0 };
|
||||
static short size_of_msg;
|
||||
static int device_open(struct inode *, struct file *);
|
||||
static int device_release(struct inode *, struct file *);
|
||||
|
@ -22,33 +22,40 @@ static struct file_operations fops = {
|
|||
.release = device_release,
|
||||
};
|
||||
|
||||
static int __init basic_module_init(void) {
|
||||
static int __init basic_module_init(void)
|
||||
{
|
||||
pr_info("Bonjour! Le module est chargé.\n");
|
||||
major_number = register_chrdev(0, DEVICE_NAME, &fops);
|
||||
if (major_number < 0) {
|
||||
pr_info("Erreur lors de l'enregistrement du périphérique de caractère\n");
|
||||
return major_number;
|
||||
}
|
||||
pr_info("Périphérique de caractère enregistré avec le numéro de majeur %d\n", major_number);
|
||||
pr_info("Périphérique de caractère enregistré avec le numéro de majeur %d\n",
|
||||
major_number);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void __exit basic_module_exit(void) {
|
||||
static void __exit basic_module_exit(void)
|
||||
{
|
||||
unregister_chrdev(major_number, DEVICE_NAME);
|
||||
pr_info("Au revoir! Le module est déchargé.\n");
|
||||
}
|
||||
|
||||
static int device_open(struct inode *inode, struct file *file) {
|
||||
static int device_open(struct inode *inode, struct file *file)
|
||||
{
|
||||
pr_info("flodev - Ouverture du périphérique\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int device_release(struct inode *inode, struct file *file) {
|
||||
static int device_release(struct inode *inode, struct file *file)
|
||||
{
|
||||
pr_info("flodev - Fermeture du périphérique\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t device_read(struct file *filp, char *buffer, size_t length, loff_t *offset) {
|
||||
static ssize_t device_read(struct file *filp, char *buffer, size_t length,
|
||||
loff_t *offset)
|
||||
{
|
||||
int bytes_read = 0;
|
||||
if (*offset >= size_of_msg) {
|
||||
return 0;
|
||||
|
@ -65,7 +72,9 @@ static ssize_t device_read(struct file *filp, char *buffer, size_t length, loff_
|
|||
return bytes_read;
|
||||
}
|
||||
|
||||
static ssize_t device_write(struct file *filp, const char *buff, size_t len, loff_t *off) {
|
||||
static ssize_t device_write(struct file *filp, const char *buff, size_t len,
|
||||
loff_t *off)
|
||||
{
|
||||
if (copy_from_user(msg, buff, len)) {
|
||||
return -EFAULT;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue