-
Notifications
You must be signed in to change notification settings - Fork 22
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
Character device driver implementation is finish #125
base: Oleksandr.Shmatko
Are you sure you want to change the base?
Character device driver implementation is finish #125
Conversation
Empty shell script file is created Signed-off-by: Oleksandr Shmatko <[email protected]>
Signed-off-by: Oleksandr Shmatko <[email protected]>
…tion Add commnd for /realise branch create Add command for copy .c files to /tmp/guesanumber Add functions for archivating .c files from /tmp/guesanumber to release/guesanumber.tar.gz Signed-off-by: Oleksandr Shmatko <[email protected]>
"tmp/guesanumber" defined as $tmpDir variable; "realise" defined as $realiseDir variable; add chiking of existing $tmpDir variable; add remooving $tmpDir at scritp finish Signed-off-by: Oleksandr Shmatko <[email protected]>
Empty line is added to the end of script Signed-off-by: Oleksandr Shmatko <[email protected]>
Signed-off-by: Oleksandr Shmatko <[email protected]>
Signed-off-by: Oleksandr Shmtko <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's almost perfect.
} | ||
printk(KERN_INFO "chrdev: Device initialized succesfully\n"); | ||
|
||
buffer_create(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functions buffer_crerate() and create_proc() can return errors, but these errors are ignored here.
Added error handring of buffer_create() and create_proc() in chrdev_init() function; Signed-off-by: Oleksandr Shmtko <[email protected]>
} | ||
printk(KERN_INFO "chrdev: Device initialized succesfully\n"); | ||
|
||
if (0 == err) err = buffer_create(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If buffer_create() (or create_proc()) fails here, you should immediately return with error code...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need fix
module_init(chrdev_init); | ||
module_exit(chrdev_exit); | ||
|
||
MODULE_LICENSE("GPL"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MODULE_LICENSE("GPL"); | |
MODULE_LICENSE("GPL"); | |
MODULE_AUTHOR(""); | |
MODULE_DESCRIPTION(""); | |
MODULE_VERSION("0.1"); |
Please fix description. Add AUTHOR, version
#endif | ||
|
||
#define BUFFER_SIZE 1024 | ||
#define DEVICE_NAME "charDevice" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#define DEVICE_NAME "charDevice" | |
#define DEVICE_NAME "charDevice" | |
#define CLASS_NAME "charClass" |
Please use kernel code style https://www.kernel.org/doc/html/v4.10/process/coding-style.html
Please use Check kernel code with checkpatch
clean: | ||
$(MAKE) -C $(KERNELDIR) M=$(CURDIR) clean | ||
|
||
endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
endif | |
endif | |
Please fix end of line
DEVICE_NAME, CLASS_NAME changed according to linux-codestyle; chrdev_init(void) immediately returns an error if it is. Signed-off-by: Oleksandr Shmtko <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should free resources carefully.
|
||
err = create_proc(); | ||
if (IS_ERR(err)) { | ||
class_destroy(pclass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory have allocated here. Do free it on error handling.
|
||
err = buffer_create(); | ||
if (IS_ERR(err)) { | ||
class_destroy(pclass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
device_destroy()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need fix error handling and device_destroy()
Please fix ASAP |
Character device driver implementation is finish
Please review