Skip to contentSkip to conversation

ALSA: ice1712: remove unneeded return statement

PATCH Superseded Sudip Mukherjee 2 participants 5 messages Nov 13, 2014 – Nov 14, 2014 Sound

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ALSA: ice1712: remove unneeded return statement

the functions:

	snd_ice1712_akm4xxx_build_controls
	snd_ice1712_build_pro_mixer
	snd_ctl_add
	snd_ak4114_build
	prodigy192_ak4114_init
	snd_ak4113_build

are all returning either 0 or a negetive error value. so we can easily remove the check for a negative value and return the value instead.

---

i have not given Jaroslav Kysela <[email protected]> in the To list, as in my last mail, all mails bounced with the error:
"cant create user output file"

 sound/pci/ice1712/hoontech.c   |  5 +----
 sound/pci/ice1712/ice1712.c    | 13 +++----------
 sound/pci/ice1712/ice1724.c    |  5 +----
 sound/pci/ice1712/juli.c       |  4 +---
 sound/pci/ice1712/prodigy192.c |  4 +---
 sound/pci/ice1712/quartet.c    |  4 +---
 6 files changed, 8 insertions(+), 27 deletions(-)
sound/pci/ice1712/hoontech.c +1 -4
index 59e37c5..2c53154 100644
@@ -310,10 +310,7 @@ static int snd_ice1712_value_init(struct snd_ice1712 *ice)
 
 	/* ak4524 controls */
 	err = snd_ice1712_akm4xxx_build_controls(ice);
-	if (err < 0)
-		return err;
-
-	return 0;
+	return err;
 }
 
 static int snd_ice1712_ez8_init(struct snd_ice1712 *ice)
sound/pci/ice1712/ice1712.c +3 -10
index 48a0c33..b97a0f9 100644
@@ -1296,9 +1296,7 @@ static int snd_ice1712_pcm_profi(struct snd_ice1712 *ice, int device, struct snd
 	}
 
 	err = snd_ice1712_build_pro_mixer(ice);
-	if (err < 0)
-		return err;
-	return 0;
+	return err;
 }
 
 /*
@@ -1546,9 +1544,7 @@ static int snd_ice1712_ac97_mixer(struct snd_ice1712 *ice)
 				 "cannot initialize ac97 for consumer, skipped\n");
 		else {
 			err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice));
-			if (err < 0)
-				return err;
-			return 0;
+			return err;
 		}
 	}
 
@@ -2498,10 +2494,7 @@ static int snd_ice1712_build_controls(struct snd_ice1712 *ice)
 	if (err < 0)
 		return err;
 	err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_peak, ice));
-	if (err < 0)
-		return err;
-
-	return 0;
+	return err;
 }
 
 static int snd_ice1712_free(struct snd_ice1712 *ice)
sound/pci/ice1712/ice1724.c +1 -4
index f633e3b..fa88485 100644
@@ -2498,10 +2498,7 @@ static int snd_vt1724_build_controls(struct snd_ice1712 *ice)
 	}
 
 	err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_mixer_pro_peak, ice));
-	if (err < 0)
-		return err;
-
-	return 0;
+	return err;
 }
 
 static int snd_vt1724_free(struct snd_ice1712 *ice)
sound/pci/ice1712/juli.c +1 -3
index 7a6c078..d6f2fb0 100644
@@ -477,9 +477,7 @@ static int juli_add_controls(struct snd_ice1712 *ice)
 	/* only capture SPDIF over AK4114 */
 	err = snd_ak4114_build(spec->ak4114, NULL,
 			ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
-	if (err < 0)
-		return err;
-	return 0;
+	return err;
 }
 
 /*
sound/pci/ice1712/prodigy192.c +1 -3
index 1eb151aa..3919aed 100644
@@ -758,10 +758,8 @@ static int prodigy192_init(struct snd_ice1712 *ice)
 			"AK4114 initialized with status %d\n", err);
 	} else
 		dev_dbg(ice->card->dev, "AK4114 not found\n");
-	if (err < 0)
-		return err;
 
-	return 0;
+	return err;
 }
 
 
sound/pci/ice1712/quartet.c +1 -3
index d4caf9d..3903e05 100644
@@ -835,9 +835,7 @@ static int qtet_add_controls(struct snd_ice1712 *ice)
 	/* only capture SPDIF over AK4113 */
 	err = snd_ak4113_build(spec->ak4113,
 			ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
-	if (err < 0)
-		return err;
-	return 0;
+	return err;
 }
 
 static inline int qtet_is_spdif_master(struct snd_ice1712 *ice)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 2/2 ALSA: ice1712: remove unused variable

these variable were initialized with some value, but never used. and so they are safe to be deleted.

---

i have not given Jaroslav Kysela <[email protected]> in the To list, as in my last mail, all mails bounced with the error:
"cant create user output file"

 sound/pci/ice1712/ice1712.c | 3 +--
 sound/pci/ice1712/revo.c    | 9 +++------
 2 files changed, 4 insertions(+), 8 deletions(-)
sound/pci/ice1712/ice1712.c +1 -2
index b97a0f9..8f27357 100644
@@ -620,10 +620,9 @@ static int snd_ice1712_playback_ds_prepare(struct snd_pcm_substream *substream)
 {
 	struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
 	struct snd_pcm_runtime *runtime = substream->runtime;
-	u32 period_size, buf_size, rate, tmp, chn;
+	u32 period_size, rate, tmp, chn;
 
 	period_size = snd_pcm_lib_period_bytes(substream) - 1;
-	buf_size = snd_pcm_lib_buffer_bytes(substream) - 1;
 	tmp = 0x0064;
 	if (snd_pcm_format_width(runtime->format) == 16)
 		tmp &= ~0x04;
sound/pci/ice1712/revo.c +3 -6
index 1112ec1..1f40dab 100644
@@ -481,7 +481,6 @@ static int ap192_ak4114_init(struct snd_ice1712 *ice)
 	static const unsigned char ak4114_init_txcsb[] = {
 		0x41, 0x02, 0x2c, 0x00, 0x00
 	};
-	int err;
 
 	struct revo51_spec *spec;
 	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
@@ -489,11 +488,9 @@ static int ap192_ak4114_init(struct snd_ice1712 *ice)
 		return -ENOMEM;
 	ice->spec = spec;
 
-	err = snd_ak4114_create(ice->card,
-				 ap192_ak4114_read,
-				 ap192_ak4114_write,
-				 ak4114_init_vals, ak4114_init_txcsb,
-				 ice, &spec->ak4114);
+	snd_ak4114_create(ice->card, ap192_ak4114_read, ap192_ak4114_write,
+			  ak4114_init_vals, ak4114_init_txcsb, ice,
+			  &spec->ak4114);
 	/* AK4114 in Revo cannot detect external rate correctly.
 	 * No reason to stop capture stream due to incorrect checks */
 	spec->ak4114->check_flags = AK4114_CHECK_NO_RATE;
Signature · 1 line
1.8.1.2
#2 lore raw

Re: [alsa-devel] [PATCH 2/2] ALSA: ice1712: remove unused variable

At Thu, 13 Nov 2014 20:44:17 +0530,

Quoted 45 lines · Sudip Mukherjee

these variable were initialized with some value, but never used. and so they are safe to be deleted.

---

i have not given Jaroslav Kysela <[email protected]> in the To list, as in my last mail, all mails bounced with the error:
"cant create user output file"

 sound/pci/ice1712/ice1712.c | 3 +--
 sound/pci/ice1712/revo.c    | 9 +++------
 2 files changed, 4 insertions(+), 8 deletions(-)
sound/pci/ice1712/ice1712.c +1 -2
index b97a0f9..8f27357 100644
@@ -620,10 +620,9 @@ static int snd_ice1712_playback_ds_prepare(struct snd_pcm_substream *substream)
 {
 	struct snd_ice1712 *ice = snd_pcm_substream_chip(substream);
 	struct snd_pcm_runtime *runtime = substream->runtime;
-	u32 period_size, buf_size, rate, tmp, chn;
+	u32 period_size, rate, tmp, chn;
 
 	period_size = snd_pcm_lib_period_bytes(substream) - 1;
-	buf_size = snd_pcm_lib_buffer_bytes(substream) - 1;
 	tmp = 0x0064;
 	if (snd_pcm_format_width(runtime->format) == 16)
 		tmp &= ~0x04;
sound/pci/ice1712/revo.c +0 -1
index 1112ec1..1f40dab 100644
@@ -481,7 +481,6 @@ static int ap192_ak4114_init(struct snd_ice1712 *ice)
 	static const unsigned char ak4114_init_txcsb[] = {
 		0x41, 0x02, 0x2c, 0x00, 0x00
 	};
-	int err;
 
 	struct revo51_spec *spec;
 	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
@@ -489,11 +488,9 @@ static int ap192_ak4114_init(struct snd_ice1712 *ice)
 		return -ENOMEM;

sound/pci/ice1712/revo.c static int ap192_ak4114_init(struct snd_ice1712 *ice) · line 493

Quoted 10 lines
sound/pci/ice1712/revo.c +3 -5
 	ice->spec = spec;
 
-	err = snd_ak4114_create(ice->card,
-				 ap192_ak4114_read,
-				 ap192_ak4114_write,
-				 ak4114_init_vals, ak4114_init_txcsb,
-				 ice, &spec->ak4114);
+	snd_ak4114_create(ice->card, ap192_ak4114_read, ap192_ak4114_write,
+			  ak4114_init_vals, ak4114_init_txcsb, ice,
+			  &spec->ak4114);

IMO, this is rather a bug. It should return the error (with a proper error handling).

thanks,

Takashi

Quoted 11 lines
sound/pci/ice1712/revo.c +0 -0
 	/* AK4114 in Revo cannot detect external rate correctly.
 	 * No reason to stop capture stream due to incorrect checks */
 	spec->ak4114->check_flags = AK4114_CHECK_NO_RATE;
Signature · 6 lines
1.8.1.2

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#3 lore raw

Re: [alsa-devel] [PATCH 2/2] ALSA: ice1712: remove unused variable

Quoted 3 lines · Takashi Iwai

At Thu, 13 Nov 2014 20:44:17 +0530,

Quoted 1 line · Sudip Mukherjee

<snip>

Quoted 18 lines
Quoted 18 lines
sound/pci/ice1712/ice1712.c +0 -0
 	if (snd_pcm_format_width(runtime->format) == 16)
 		tmp &= ~0x04;
sound/pci/ice1712/revo.c +0 -1
index 1112ec1..1f40dab 100644
@@ -481,7 +481,6 @@ static int ap192_ak4114_init(struct snd_ice1712 *ice)
 	static const unsigned char ak4114_init_txcsb[] = {
 		0x41, 0x02, 0x2c, 0x00, 0x00
 	};
-	int err;
 
 	struct revo51_spec *spec;
 	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
@@ -489,11 +488,9 @@ static int ap192_ak4114_init(struct snd_ice1712 *ice)
 		return -ENOMEM;
 	ice->spec = spec;
 
Quoted 12 lines

sound/pci/ice1712/revo.c static int ap192_ak4114_init(struct snd_ice1712 *ice) · line 493

Quoted 8 lines
sound/pci/ice1712/revo.c +3 -5
-	err = snd_ak4114_create(ice->card,
-				 ap192_ak4114_read,
-				 ap192_ak4114_write,
-				 ak4114_init_vals, ak4114_init_txcsb,
-				 ice, &spec->ak4114);
+	snd_ak4114_create(ice->card, ap192_ak4114_read, ap192_ak4114_write,
+			  ak4114_init_vals, ak4114_init_txcsb, ice,
+			  &spec->ak4114);

IMO, this is rather a bug. It should return the error (with a proper error handling).

error handling is already there. ap192_ak4114_init is being called by revo_init, where the return value is being checked. revo_init is the callback function of chip_init, so if we return the error value here then chip_init will fail. but since the author commented "error ignored; it's no fatal error", so i also thought of ignoring the error.
I will send you a revised patch.

thanks
sudip

Quoted 17 lines

thanks,

Takashi

Quoted 11 lines
sound/pci/ice1712/revo.c +0 -0
 	/* AK4114 in Revo cannot detect external rate correctly.
 	 * No reason to stop capture stream due to incorrect checks */
 	spec->ak4114->check_flags = AK4114_CHECK_NO_RATE;
Signature · 6 lines
1.8.1.2

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#4 lore raw
In reply to Sudip Mukherjee

At Thu, 13 Nov 2014 20:44:16 +0530,

Quoted 11 lines · Sudip Mukherjee

the functions:

	snd_ice1712_akm4xxx_build_controls
	snd_ice1712_build_pro_mixer
	snd_ctl_add
	snd_ak4114_build
	prodigy192_ak4114_init
	snd_ak4113_build

are all returning either 0 or a negetive error value. so we can easily remove the check for a negative value and return the value instead.

In doing so, you can rewrite to return directly like

	return xxx();
instead of
	err = xxx();
	return err;

Takashi

Quoted 135 lines

---

i have not given Jaroslav Kysela <[email protected]> in the To list, as in my last mail, all mails bounced with the error:
"cant create user output file"

 sound/pci/ice1712/hoontech.c   |  5 +----
 sound/pci/ice1712/ice1712.c    | 13 +++----------
 sound/pci/ice1712/ice1724.c    |  5 +----
 sound/pci/ice1712/juli.c       |  4 +---
 sound/pci/ice1712/prodigy192.c |  4 +---
 sound/pci/ice1712/quartet.c    |  4 +---
 6 files changed, 8 insertions(+), 27 deletions(-)
sound/pci/ice1712/hoontech.c +1 -4
index 59e37c5..2c53154 100644
@@ -310,10 +310,7 @@ static int snd_ice1712_value_init(struct snd_ice1712 *ice)
 
 	/* ak4524 controls */
 	err = snd_ice1712_akm4xxx_build_controls(ice);
-	if (err < 0)
-		return err;
-
-	return 0;
+	return err;
 }
 
 static int snd_ice1712_ez8_init(struct snd_ice1712 *ice)
sound/pci/ice1712/ice1712.c +3 -10
index 48a0c33..b97a0f9 100644
@@ -1296,9 +1296,7 @@ static int snd_ice1712_pcm_profi(struct snd_ice1712 *ice, int device, struct snd
 	}
 
 	err = snd_ice1712_build_pro_mixer(ice);
-	if (err < 0)
-		return err;
-	return 0;
+	return err;
 }
 
 /*
@@ -1546,9 +1544,7 @@ static int snd_ice1712_ac97_mixer(struct snd_ice1712 *ice)
 				 "cannot initialize ac97 for consumer, skipped\n");
 		else {
 			err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_digmix_route_ac97, ice));
-			if (err < 0)
-				return err;
-			return 0;
+			return err;
 		}
 	}
 
@@ -2498,10 +2494,7 @@ static int snd_ice1712_build_controls(struct snd_ice1712 *ice)
 	if (err < 0)
 		return err;
 	err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_ice1712_mixer_pro_peak, ice));
-	if (err < 0)
-		return err;
-
-	return 0;
+	return err;
 }
 
 static int snd_ice1712_free(struct snd_ice1712 *ice)
sound/pci/ice1712/ice1724.c +1 -4
index f633e3b..fa88485 100644
@@ -2498,10 +2498,7 @@ static int snd_vt1724_build_controls(struct snd_ice1712 *ice)
 	}
 
 	err = snd_ctl_add(ice->card, snd_ctl_new1(&snd_vt1724_mixer_pro_peak, ice));
-	if (err < 0)
-		return err;
-
-	return 0;
+	return err;
 }
 
 static int snd_vt1724_free(struct snd_ice1712 *ice)
sound/pci/ice1712/juli.c +1 -3
index 7a6c078..d6f2fb0 100644
@@ -477,9 +477,7 @@ static int juli_add_controls(struct snd_ice1712 *ice)
 	/* only capture SPDIF over AK4114 */
 	err = snd_ak4114_build(spec->ak4114, NULL,
 			ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
-	if (err < 0)
-		return err;
-	return 0;
+	return err;
 }
 
 /*
sound/pci/ice1712/prodigy192.c +1 -3
index 1eb151aa..3919aed 100644
@@ -758,10 +758,8 @@ static int prodigy192_init(struct snd_ice1712 *ice)
 			"AK4114 initialized with status %d\n", err);
 	} else
 		dev_dbg(ice->card->dev, "AK4114 not found\n");
-	if (err < 0)
-		return err;
 
-	return 0;
+	return err;
 }
 
 
sound/pci/ice1712/quartet.c +1 -3
index d4caf9d..3903e05 100644
@@ -835,9 +835,7 @@ static int qtet_add_controls(struct snd_ice1712 *ice)
 	/* only capture SPDIF over AK4113 */
 	err = snd_ak4113_build(spec->ak4113,
 			ice->pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream);
-	if (err < 0)
-		return err;
-	return 0;
+	return err;
 }
 
 static inline int qtet_is_spdif_master(struct snd_ice1712 *ice)
Signature · 1 line
1.8.1.2