-
Notifications
You must be signed in to change notification settings - Fork 21
Add error for hwmc response len 0 + replace hard-coded addresses #285
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
Conversation
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.
Pull Request Overview
This PR improves error handling and code maintainability for the RealSense D4xx kernel driver by adding validation for zero-length HWMC responses and replacing hard-coded register addresses with predefined constants.
- Adds error checking for zero-length HWMC responses with appropriate error logging
- Replaces hard-coded register addresses (0x4900, 0x4904, 0x4908, 0x490c) with named constants
- Adds explanatory comments for register operations
if (ret) | ||
return -EBADMSG; | ||
|
||
if (tmp_len > cmdDataLen) | ||
return -ENOBUFS; | ||
|
||
if (tmp_len == 0) { | ||
dev_err(&state->client->dev, |
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 comment on line 1827 contains a typo: "ccompletion" should be "completion".
Copilot uses AI. Check for mistakes.
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.
I think this is a mistake... I don't see this work
kernel/realsense/d4xx.c
Outdated
"%s(): HWMC response length is 0, ret: %d\n", | ||
__func__, ret); |
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 error message includes 'ret: %d' but 'ret' is always 0 at this point since the regmap_raw_read succeeded. This could be confusing as it will always log 'ret: 0' even when there's an error condition.
"%s(): HWMC response length is 0, ret: %d\n", | |
__func__, ret); | |
"%s(): HWMC response length is 0\n", | |
__func__); |
Copilot uses AI. Check for mistakes.
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.
ret can be non-zero?
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.
Fixed
kernel/realsense/d4xx.c
Outdated
"%s(): HWMC response length is 0, ret: %d\n", | ||
__func__, ret); |
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.
ret can be non-zero?
if (ret) | ||
return -EBADMSG; | ||
|
||
if (tmp_len > cmdDataLen) | ||
return -ENOBUFS; | ||
|
||
if (tmp_len == 0) { | ||
dev_err(&state->client->dev, |
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.
I think this is a mistake... I don't see this work
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.
LGTM
No description provided.