From nobody Mon Nov 25 18:48:39 2024 Received: from cmccmta2.chinamobile.com (cmccmta2.chinamobile.com [111.22.67.135]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8ACDC189914; Fri, 25 Oct 2024 08:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=111.22.67.135 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729844470; cv=none; b=mybpzkKFh9dEKC5pIwp9/1hUrbewBkFEraHdqHFYfKRLS3E6cY6FgYjATPFXCyxSSAZFiO+sxIrYsujjKd5dYsm+Z6Buvx7CM7gFxPH3nSaMqd/ZWQMdd+U+rAaUtuTHXjtFqbIpADrsM3RiMbmeW+2mrh/Yx9k1WMwwtjf6Nas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729844470; c=relaxed/simple; bh=F+8EYrYfCSov3vYJvjIGwMMAlrlWyYadM7OBoaLYkxg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IhM5Oi5xwAVU9OBRZu0iuu0JpfJLwY4OgIhSlXA1nczBzZB8/pCq/54fL8zuoaaicYDXVnPYfH4t2tHnakQllAldngzi1qpIaAx47V4n5eCOLNOkG13kwlcBuHUteaBXP6rq2zeT/lSvsFyyRxrXIuFi9VO75gImZRxMD43DfX0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com; spf=pass smtp.mailfrom=cmss.chinamobile.com; arc=none smtp.client-ip=111.22.67.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=cmss.chinamobile.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmss.chinamobile.com X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from spf.mail.chinamobile.com (unknown[10.188.0.87]) by rmmx-syy-dmz-app07-12007 (RichMail) with SMTP id 2ee7671b54ea15c-7b171; Fri, 25 Oct 2024 16:20:58 +0800 (CST) X-RM-TRANSID: 2ee7671b54ea15c-7b171 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 Received: from leadsec.example.com.localdomain (unknown[10.55.1.71]) by rmsmtp-syy-appsvr10-12010 (RichMail) with SMTP id 2eea671b54e6a90-2f5f8; Fri, 25 Oct 2024 16:20:58 +0800 (CST) X-RM-TRANSID: 2eea671b54e6a90-2f5f8 From: Tang Bin To: shenghao-ding@ti.com, kevin-lu@ti.com, baojun.xu@ti.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com Cc: alsa-devel@alsa-project.org, linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, Tang Bin Subject: [PATCH] ASoC: tas2781: Fix redundant logical jump Date: Fri, 25 Oct 2024 16:20:42 +0800 Message-Id: <20241025082042.2872-1-tangbin@cmss.chinamobile.com> X-Mailer: git-send-email 2.33.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In these functions, some logical jump of "goto" and variable are redundant, thus remove them. Signed-off-by: Tang Bin --- sound/soc/codecs/tas2781-i2c.c | 68 +++++++++++++--------------------- 1 file changed, 25 insertions(+), 43 deletions(-) diff --git a/sound/soc/codecs/tas2781-i2c.c b/sound/soc/codecs/tas2781-i2c.c index 68887799e..27f2f84a4 100644 --- a/sound/soc/codecs/tas2781-i2c.c +++ b/sound/soc/codecs/tas2781-i2c.c @@ -489,14 +489,11 @@ static int tas2563_calib_start_put(struct snd_kcontro= l *kcontrol, struct snd_soc_component *comp =3D snd_soc_kcontrol_component(kcontrol); struct tasdevice_priv *tas_priv =3D snd_soc_component_get_drvdata(comp); const int sum =3D ARRAY_SIZE(tas2563_cali_start_reg); - int rc =3D 1; int i, j; =20 guard(mutex)(&tas_priv->codec_lock); - if (tas_priv->chip_id !=3D TAS2563) { - rc =3D -1; - goto out; - } + if (tas_priv->chip_id !=3D TAS2563) + return -1; =20 for (i =3D 0; i < tas_priv->ndev; i++) { struct tasdevice *tasdev =3D tas_priv->tasdevice; @@ -523,8 +520,8 @@ static int tas2563_calib_start_put(struct snd_kcontrol = *kcontrol, q[j].val, 4); } } -out: - return rc; + + return 1; } =20 static void tas2563_calib_stop_put(struct tasdevice_priv *tas_priv) @@ -576,7 +573,7 @@ static int tasdev_cali_data_put(struct snd_kcontrol *kc= ontrol, struct cali_reg *p =3D &cali_data->cali_reg_array; unsigned char *src =3D ucontrol->value.bytes.data; unsigned char *dst =3D cali_data->data; - int rc =3D 1, i =3D 0; + int i =3D 0; int j; =20 guard(mutex)(&priv->codec_lock); @@ -605,7 +602,7 @@ static int tasdev_cali_data_put(struct snd_kcontrol *kc= ontrol, i +=3D 3; =20 memcpy(dst, &src[i], cali_data->total_sz); - return rc; + return 1; } =20 static int tas2781_latch_reg_get(struct snd_kcontrol *kcontrol, @@ -1115,25 +1112,21 @@ static int tasdevice_dsp_create_ctrls(struct tasdev= ice_priv *tas_priv) char *conf_name, *prog_name; int nr_controls =3D 4; int mix_index =3D 0; - int ret; =20 /* Alloc kcontrol via devm_kzalloc, which don't manually * free the kcontrol */ dsp_ctrls =3D devm_kcalloc(tas_priv->dev, nr_controls, sizeof(dsp_ctrls[0]), GFP_KERNEL); - if (!dsp_ctrls) { - ret =3D -ENOMEM; - goto out; - } + if (!dsp_ctrls) + return -ENOMEM; =20 /* Create mixer items for selecting the active Program and Config */ prog_name =3D devm_kstrdup(tas_priv->dev, "Speaker Program Id", GFP_KERNEL); - if (!prog_name) { - ret =3D -ENOMEM; - goto out; - } + if (!prog_name) + return -ENOMEM; + dsp_ctrls[mix_index].name =3D prog_name; dsp_ctrls[mix_index].iface =3D SNDRV_CTL_ELEM_IFACE_MIXER; dsp_ctrls[mix_index].info =3D tasdevice_info_programs; @@ -1143,10 +1136,9 @@ static int tasdevice_dsp_create_ctrls(struct tasdevi= ce_priv *tas_priv) =20 conf_name =3D devm_kstrdup(tas_priv->dev, "Speaker Config Id", GFP_KERNEL); - if (!conf_name) { - ret =3D -ENOMEM; - goto out; - } + if (!conf_name) + return -ENOMEM; + dsp_ctrls[mix_index].name =3D conf_name; dsp_ctrls[mix_index].iface =3D SNDRV_CTL_ELEM_IFACE_MIXER; dsp_ctrls[mix_index].info =3D tasdevice_info_configurations; @@ -1156,10 +1148,9 @@ static int tasdevice_dsp_create_ctrls(struct tasdevi= ce_priv *tas_priv) =20 active_dev_num =3D devm_kstrdup(tas_priv->dev, "Activate Tasdevice Num", GFP_KERNEL); - if (!active_dev_num) { - ret =3D -ENOMEM; - goto out; - } + if (!active_dev_num) + return -ENOMEM; + dsp_ctrls[mix_index].name =3D active_dev_num; dsp_ctrls[mix_index].iface =3D SNDRV_CTL_ELEM_IFACE_MIXER; dsp_ctrls[mix_index].info =3D tasdevice_info_active_num; @@ -1168,21 +1159,17 @@ static int tasdevice_dsp_create_ctrls(struct tasdev= ice_priv *tas_priv) mix_index++; =20 chip_id =3D devm_kstrdup(tas_priv->dev, "Tasdevice Chip Id", GFP_KERNEL); - if (!chip_id) { - ret =3D -ENOMEM; - goto out; - } + if (!chip_id) + return -ENOMEM; + dsp_ctrls[mix_index].name =3D chip_id; dsp_ctrls[mix_index].iface =3D SNDRV_CTL_ELEM_IFACE_MIXER; dsp_ctrls[mix_index].info =3D tasdevice_info_chip_id; dsp_ctrls[mix_index].get =3D tasdevice_get_chip_id; mix_index++; =20 - ret =3D snd_soc_add_component_controls(tas_priv->codec, dsp_ctrls, + return snd_soc_add_component_controls(tas_priv->codec, dsp_ctrls, nr_controls < mix_index ? nr_controls : mix_index); - -out: - return ret; } =20 static int tasdevice_create_cali_ctrls(struct tasdevice_priv *priv) @@ -1469,7 +1456,6 @@ static int tasdevice_hw_params(struct snd_pcm_substre= am *substream, unsigned int slot_width; unsigned int fsrate; int bclk_rate; - int rc =3D 0; =20 fsrate =3D params_rate(params); switch (fsrate) { @@ -1479,8 +1465,7 @@ static int tasdevice_hw_params(struct snd_pcm_substre= am *substream, default: dev_err(tas_priv->dev, "%s: incorrect sample rate =3D %u\n", __func__, fsrate); - rc =3D -EINVAL; - goto out; + return -EINVAL; } =20 slot_width =3D params_width(params); @@ -1493,20 +1478,17 @@ static int tasdevice_hw_params(struct snd_pcm_subst= ream *substream, default: dev_err(tas_priv->dev, "%s: incorrect slot width =3D %u\n", __func__, slot_width); - rc =3D -EINVAL; - goto out; + return -EINVAL; } =20 bclk_rate =3D snd_soc_params_to_bclk(params); if (bclk_rate < 0) { dev_err(tas_priv->dev, "%s: incorrect bclk rate =3D %d\n", __func__, bclk_rate); - rc =3D bclk_rate; - goto out; + return bclk_rate; } =20 -out: - return rc; + return 0; } =20 static int tasdevice_set_dai_sysclk(struct snd_soc_dai *codec_dai, --=20 2.33.0