In my read function myread it is continuously printing the read data when i do cat /driver/mydriver. I need to print only once how to do that
问题 I wrote h into driver by doing echo: echo -n h /dev/mydriver When I do cat /dev/mydriver, myread function is printing h continuously. I wanted to print once. How to do that. static char m; static ssize_t myread(struct file *f, char __user *buf, size_t len, loff_t *off) { printk(KERN_INFO "Read()\n"); if (copy_to_user(buf, &m, 1) != 0) return -EFAULT; else return 1; } static ssize_t my_write(struct file *f, const char __user *buf, size_t len, loff_t *off) { printk(KERN_INFO "Write()\n"); if