Skip to content
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

drivers: ncp5623: Fix error check #63731

Merged
merged 1 commit into from
Oct 20, 2023
Merged

Conversation

finikorg
Copy link
Collaborator

num_colors cannot be not equal to different values at the same time.

@finikorg finikorg marked this pull request as ready for review October 10, 2023 07:21
@zephyrbot zephyrbot added the area: LED Label to identify LED subsystem label Oct 10, 2023
@@ -149,7 +149,7 @@ static int ncp5623_led_init(const struct device *dev)
return -ENODEV;
}

if (led_info->num_colors != 3 || led_info->num_colors != 1) {
if (led_info->num_colors != 3 && led_info->num_colors != 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this.

In addition I think the code should rather be:

if (led_info->num_colors != NCP5623_CHANNEL_COUNT) {
                LOG_ERR("%s: invalid number of colors %d (must be %d when defining a single LED)",
                                  dev->name, led_info->num_colors, NCP5623_CHANNEL_COUNT);
}

@PetervdPerk-NXP, please can you have a look ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was for the weird edge where one would be attaching one singe color led to the ncp5623.
@simonguinot suggestion to just enforce 3 colors in single led rgb mode would make more sense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed proposed way.

Copy link
Collaborator

@simonguinot simonguinot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care @finikorg !

jhedberg
jhedberg previously approved these changes Oct 13, 2023
@bbilas
Copy link
Collaborator

bbilas commented Oct 13, 2023

Shouldn't we return any errno in that case?

fabiobaltieri
fabiobaltieri previously approved these changes Oct 13, 2023
@fabiobaltieri fabiobaltieri added this to the v3.5.0 milestone Oct 13, 2023
@jhedberg
Copy link
Member

Shouldn't we return any errno in that case?

Yeah, at least to me it seems like return -EINVAL would be the right thing (and consistent with how the function is dealing with other similar errors).

@simonguinot simonguinot self-requested a review October 13, 2023 15:48
@simonguinot simonguinot self-requested a review October 13, 2023 15:51
Copy link
Collaborator

@simonguinot simonguinot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's prevent this to be merged before return is added.

@simonguinot
Copy link
Collaborator

Shouldn't we return any errno in that case?

Well spotted !

num_colors cannot be not equal to different values at the same time.

Signed-off-by: Andrei Emeltchenko <[email protected]>
@simonguinot simonguinot self-requested a review October 16, 2023 09:07
Copy link
Collaborator

@simonguinot simonguinot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

Copy link
Member

@jhedberg jhedberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, however since we're at the last stages of the release, it's unlikely this will get merged before 3.5 (would require that it's fixing a release blocker issue)

@jhedberg jhedberg modified the milestones: v3.5.0, v3.6.0 Oct 17, 2023
@carlescufi carlescufi merged commit 76c7393 into zephyrproject-rtos:main Oct 20, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: LED Label to identify LED subsystem
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants