asoc: wcd938x: Add default cases for port mapping

Return error in case of wrong path being selected
for port mapping and port params functions.

Change-Id: I5d66a9cd32e9c8e6d8ebac0ea073b1a1762407b6
Signed-off-by: Karthikeyan Mani <kmani@codeaurora.org>
This commit is contained in:
Karthikeyan Mani
2019-04-01 12:07:14 -07:00
parent b1a49c6b67
commit 05588601ac
2 changed files with 16 additions and 3 deletions

View File

@@ -22,6 +22,11 @@ static int wcd938x_slave_bind(struct device *dev,
uint8_t devnum = 0; uint8_t devnum = 0;
struct swr_device *pdev = to_swr_device(dev); struct swr_device *pdev = to_swr_device(dev);
if (!pdev) {
pr_err("%s: invalid swr device handle\n", __func__);
return -EINVAL;
}
ret = swr_get_logical_dev_num(pdev, pdev->addr, &devnum); ret = swr_get_logical_dev_num(pdev, pdev->addr, &devnum);
if (ret) { if (ret) {
dev_dbg(&pdev->dev, dev_dbg(&pdev->dev,

View File

@@ -177,7 +177,7 @@ static int wcd938x_set_port_params(struct snd_soc_component *component,
u8 *port_type, u8 path) u8 *port_type, u8 path)
{ {
int i, j; int i, j;
u8 num_ports; u8 num_ports = 0;
struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT]; struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT];
struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component); struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
@@ -190,6 +190,10 @@ static int wcd938x_set_port_params(struct snd_soc_component *component,
map = &wcd938x->tx_port_mapping; map = &wcd938x->tx_port_mapping;
num_ports = wcd938x->num_tx_ports; num_ports = wcd938x->num_tx_ports;
break; break;
default:
dev_err(component->dev, "%s Invalid path selected %u\n",
__func__, path);
return -EINVAL;
} }
for (i = 0; i <= num_ports; i++) { for (i = 0; i <= num_ports; i++) {
@@ -217,11 +221,11 @@ static int wcd938x_parse_port_mapping(struct device *dev,
char *prop, u8 path) char *prop, u8 path)
{ {
u32 *dt_array, map_size, map_length; u32 *dt_array, map_size, map_length;
u32 port_num, ch_mask, ch_rate, old_port_num = 0; u32 port_num = 0, ch_mask, ch_rate, old_port_num = 0;
u32 slave_port_type, master_port_type; u32 slave_port_type, master_port_type;
u32 i, ch_iter = 0; u32 i, ch_iter = 0;
int ret = 0; int ret = 0;
u8 *num_ports; u8 *num_ports = NULL;
struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT]; struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT];
struct wcd938x_priv *wcd938x = dev_get_drvdata(dev); struct wcd938x_priv *wcd938x = dev_get_drvdata(dev);
@@ -234,6 +238,10 @@ static int wcd938x_parse_port_mapping(struct device *dev,
map = &wcd938x->tx_port_mapping; map = &wcd938x->tx_port_mapping;
num_ports = &wcd938x->num_tx_ports; num_ports = &wcd938x->num_tx_ports;
break; break;
default:
dev_err(dev, "%s Invalid path selected %u\n",
__func__, path);
return -EINVAL;
} }
if (!of_find_property(dev->of_node, prop, if (!of_find_property(dev->of_node, prop,