Add error for hwmc response len 0 + replace hard-coded addresses - #285
Conversation
There was a problem hiding this comment.
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
| return -ENOBUFS; | ||
|
|
||
| if (tmp_len == 0) { | ||
| dev_err(&state->client->dev, |
There was a problem hiding this comment.
The comment on line 1827 contains a typo: "ccompletion" should be "completion".
There was a problem hiding this comment.
I think this is a mistake... I don't see this work
| "%s(): HWMC response length is 0, ret: %d\n", | ||
| __func__, ret); |
There was a problem hiding this comment.
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__); |
| "%s(): HWMC response length is 0, ret: %d\n", | ||
| __func__, ret); |
| return -ENOBUFS; | ||
|
|
||
| if (tmp_len == 0) { | ||
| dev_err(&state->client->dev, |
There was a problem hiding this comment.
I think this is a mistake... I don't see this work
* Added err and dmesg in ds5_get_hwmc if response length is 0 * Added comments and replaced hard coded HWMC addresses
No description provided.