Browse Source

Merge "asoc: wcd938x: Add default cases for port mapping"

qctecmdr 6 years ago
parent
commit
d2c21188e5
2 changed files with 16 additions and 3 deletions
  1. 5 0
      asoc/codecs/wcd938x/wcd938x-slave.c
  2. 11 3
      asoc/codecs/wcd938x/wcd938x.c

+ 5 - 0
asoc/codecs/wcd938x/wcd938x-slave.c

@@ -22,6 +22,11 @@ static int wcd938x_slave_bind(struct device *dev,
 	uint8_t devnum = 0;
 	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);
 	if (ret) {
 		dev_dbg(&pdev->dev,

+ 11 - 3
asoc/codecs/wcd938x/wcd938x.c

@@ -177,7 +177,7 @@ static int wcd938x_set_port_params(struct snd_soc_component *component,
 			u8 *port_type, u8 path)
 {
 	int i, j;
-	u8 num_ports;
+	u8 num_ports = 0;
 	struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT];
 	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;
 		num_ports = wcd938x->num_tx_ports;
 		break;
+	default:
+		dev_err(component->dev, "%s Invalid path selected %u\n",
+					__func__, path);
+		return -EINVAL;
 	}
 
 	for (i = 0; i <= num_ports; i++) {
@@ -217,11 +221,11 @@ static int wcd938x_parse_port_mapping(struct device *dev,
 			char *prop, u8 path)
 {
 	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 i, ch_iter = 0;
 	int ret = 0;
-	u8 *num_ports;
+	u8 *num_ports = NULL;
 	struct codec_port_info (*map)[MAX_PORT][MAX_CH_PER_PORT];
 	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;
 		num_ports = &wcd938x->num_tx_ports;
 		break;
+	default:
+		dev_err(dev, "%s Invalid path selected %u\n",
+			      __func__, path);
+		return -EINVAL;
 	}
 
 	if (!of_find_property(dev->of_node, prop,