Use kstrtoint_from_user() instead of parseFreq() and parse_count() to detect parse error. #71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this implement/fix?
Raspberry Pi OS(debian 10.10、kernel 5.10.17)でサンプルプログラムのstep4.shを実行した際、
モータが回らないタイミングがあることを確認しました。
parseFreq()でnewbufのメモリを確保する際に、ゼロで初期化していないことが原因です。メモリの確保に
kzalloc()を使用し、確保したメモリにゼロをセットすることで問題が解決しました。不具合の詳細
newbufが生成されたときに、その中身が4????のような数字で始まる場合、かつ、
セットしたいモータ速度が
-300のように先頭がマイナスの場合に問題が発生します。指示値が
-300のとき、指示値をパースした後newbuf = " 300"となるのが理想ですが、newbuf[0]の初期値に数字が入っていると、パース後はnewbuf = "4300"となってしまいます。その後、符号が処理されるので、最終的に
-4300がモータにセットされます。これは指示範囲外なので、モータが回りません。
Does this close any currently open issues?
いいえ
How has this been tested?
Raspberry Pi OSと、Ubuntu 20.04にて、step4.shを実行した際にモータが正常に回ることを確認してます。
Any other comments?
いいえ
Checklists