Repository navigation
ipc: Refactor ipc_comp_dai_config #1997
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -436,49 +436,33 @@ int ipc_comp_dai_config(struct ipc *ipc, struct sof_ipc_dai_config *config) | |
| struct sof_ipc_comp_dai *dai; | ||
| struct ipc_comp_dev *icd; | ||
| struct list_item *clist; | ||
| struct comp_dev *dev; | ||
| int ret = -ENODEV; | ||
|
|
||
| /* for each component */ | ||
| list_for_item(clist, &ipc->shared_ctx->comp_list) { | ||
| icd = container_of(clist, struct ipc_comp_dev, list); | ||
| switch (icd->type) { | ||
| case COMP_TYPE_COMPONENT: | ||
|
|
||
| /* make sure we only config DAI comps */ | ||
| switch (icd->cd->comp.type) { | ||
| case SOF_COMP_DAI: | ||
| case SOF_COMP_SG_DAI: | ||
| dev = icd->cd; | ||
| dai = (struct sof_ipc_comp_dai *)&dev->comp; | ||
|
|
||
| /* | ||
| * set config if comp dai_index matches | ||
| * config dai_index. | ||
| */ | ||
| if (dai->dai_index == config->dai_index && | ||
| dai->type == config->type) { | ||
| ret = comp_dai_config(dev, config); | ||
| if (ret < 0) { | ||
| trace_ipc_error | ||
| ("ipc_comp_dai_config() " | ||
| "error: comp_dai_config() " | ||
| "failed"); | ||
| return ret; | ||
| } | ||
| } | ||
| break; | ||
|
dbaluta marked this conversation as resolved.
Resolved
|
||
| default: | ||
| break; | ||
| } | ||
| /* make sure we only config DAI comps */ | ||
| if (icd->type != COMP_TYPE_COMPONENT) | ||
| continue; | ||
|
|
||
| break; | ||
| /* ignore non components */ | ||
| default: | ||
| break; | ||
| if (icd->cd->comp.type == SOF_COMP_DAI || | ||
| icd->cd->comp.type == SOF_COMP_SG_DAI) { | ||
| dai = (struct sof_ipc_comp_dai *)&icd->cd->comp; | ||
| /* | ||
| * set config if comp dai_index matches | ||
| * config dai_index. | ||
| */ | ||
| if (dai->dai_index == config->dai_index && | ||
| dai->type == config->type) | ||
| ret = comp_dai_config(icd->cd, config); | ||
| } | ||
| } | ||
|
|
||
| if (ret < 0) { | ||
| trace_ipc_error("ipc_comp_dai_config() error: " | ||
| "comp_dai_config() failed"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for curly braces around trace_ipc_error here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need because it is a macro
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trace_* macros have been written to act like functions from the point of view of using them so no, the braces aren't needed.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ktrzcinx do you mean that if we have something like this and the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm OK with the code as it is now, but we should keep this discussion open.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I claim that when or Now will trace independently ret value but my solution will still work correctly. There also won't be any compilation error and a lot of tests should pass. In conclusion, I rather prefer defensive programming with extra |
||
| } | ||
|
|
||
| return ret; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.