Skip to content

Commit

Permalink
ASoC: sti: check return of of_property_read
Browse files Browse the repository at this point in the history
Add check on of_property_read to return error when
DT required property is not defined.

Signed-off-by: Arnaud Pouliquen <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
arnopo authored and broonie committed Sep 10, 2015
1 parent 9193132 commit 3a0e27d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 10 additions & 4 deletions sound/soc/sti/uniperif_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -989,19 +989,25 @@ static int uni_player_parse_dt(struct platform_device *pdev,
if (!info)
return -ENOMEM;

of_property_read_u32(pnode, "version", &player->ver);
if (player->ver == SND_ST_UNIPERIF_VERSION_UNKNOWN) {
if (of_property_read_u32(pnode, "version", &player->ver) ||
player->ver == SND_ST_UNIPERIF_VERSION_UNKNOWN) {
dev_err(dev, "Unknown uniperipheral version ");
return -EINVAL;
}
/* Underflow recovery is only supported on later ip revisions */
if (player->ver >= SND_ST_UNIPERIF_VERSION_UNI_PLR_TOP_1_0)
info->underflow_enabled = 1;

of_property_read_u32(pnode, "uniperiph-id", &info->id);
if (of_property_read_u32(pnode, "uniperiph-id", &info->id)) {
dev_err(dev, "uniperipheral id not defined");
return -EINVAL;
}

/* Read the device mode property */
of_property_read_string(pnode, "mode", &mode);
if (of_property_read_string(pnode, "mode", &mode)) {
dev_err(dev, "uniperipheral mode not defined");
return -EINVAL;
}

if (strcasecmp(mode, "hdmi") == 0)
info->player_type = SND_ST_UNIPERIF_PLAYER_TYPE_HDMI;
Expand Down
6 changes: 5 additions & 1 deletion sound/soc/sti/uniperif_reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,11 @@ static int uni_reader_parse_dt(struct platform_device *pdev,
if (!info)
return -ENOMEM;

of_property_read_u32(node, "version", &reader->ver);
if (of_property_read_u32(node, "version", &reader->ver) ||
reader->ver == SND_ST_UNIPERIF_VERSION_UNKNOWN) {
dev_err(&pdev->dev, "Unknown uniperipheral version ");
return -EINVAL;
}

/* Save the info structure */
reader->info = info;
Expand Down

0 comments on commit 3a0e27d

Please sign in to comment.