-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refine doc & code #158
Comments
|
Hi @minghu6 ,
Yes, it won't affect the registering of the device, but the paragraph here actually talks about the file operation. And, it seems like the file operation will be related to the
The macro,
Yes, it should uses the
The read/write functions are a little weird. I will modify them. |
The Thanks |
According to the issue sysprog21#158, it is more appropriate to use the value.
According to the issue sysprog21#158, it is more appropriate to use the value EOPNOTSUPP rather than EINVAL.
Sorry, I recheck the write man page to make sure that the change here is suitable to the definition.
The |
Oops, I saw the comments. |
Ready to close? |
Sure, I think. |
Move the confusing note about
struct proc_ops
replacing withstruct file_operations
on linux >=5.6:lkmpg/lkmpg.tex
Lines 957 to 990 in 637e707
The
struct proc_ops
would replace thestruct file-operations
only when create proc releated defined on <linux/proc_fs.h>In other word, regist device doesn't be affected, still using
struct file_operations
. It's confusing write this note above the regist device code (FOE ME, I HAVE SPENT PLENTY OF TIME ON SEARCHING HOW TO REGIST DEVICE USING STRUCT PROC_OPS)I highly recommend to move this note down to next code example which replacing takes place truely!
lkmpg/examples/chardev.c
Lines 25 to 39 in 637e707
The msg char array should be declared with length of
BUF_LEN + 1
sinceBUF_LEN
is max length of message.lkmpg/examples/chardev.c
Line 152 in 637e707
On
device_write
, It's prefered to useEOPNOTSUPP
instead ofEINVAL
since the former raises unsupported error, the latter raises invalid argument.Improve read/write fucntion code among
fsproc{1-3}.c
:lkmpg/examples/procfs3.c
Lines 23 to 40 in 637e707
lkmpg/examples/procfs3.c
Lines 41 to 53 in 637e707
These code are a little wired and far from decent, the parameter
loff_t *
is ignored incorrectly and so the behavior is quite different from normal read/write.I've reimplemented read/write code, here is full code:It need more modern c standard config than C90, for example
ccflags-y += -std=gnu17
.The text was updated successfully, but these errors were encountered: