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.
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.
Well, first there is actually no case where
ret
is tested/used uninitialized with the current code. This can only happen if thecolor_mapping
is invalid. But it is tested byis31fl3194_check_config()
.That being said, it is interesting to consolidate the code...
About this patch, it is not optimal to initialize
ret
with 0. This opens the door to update the LED even if the channels have not been updated.Since there is no point in continuing at sending I2C I/Os if one of them fails, then I would prefer something like that:
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.
Sorry to have kept you waiting, I think your suggestion is very good. After
ret is initialized to 0
, we shouldremove the if
, I will fix it in two commits :)Edit
Hold on, we seem to have forgotten the
i2c_reg_write_byte_dt
above. Its main function is to executei2c_reg_write_byte_dt
in the if below after all thei2c_reg_write_byte_dt
above succeed. It seems that it makes sense to initialize ret to 0.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.
Sorry I don't see what is wrong this the code example I proposed. The last call to
i2c_reg_write_byte_dt
is only executed if the color registers are updated.