* [PATCH 1/2] ALSA: ice1712: remove unneeded return statement
@ 2014-11-13 15:14 Sudip Mukherjee
2014-11-13 15:14 ` [PATCH 2/2] ALSA: ice1712: remove unused variable Sudip Mukherjee
2014-11-13 15:21 ` [PATCH 1/2] ALSA: ice1712: remove unneeded return statement Takashi Iwai
0 siblings, 2 replies; 5+ messages in thread
From: Sudip Mukherjee @ 2014-11-13 15:14 UTC (permalink / raw)
To: Takashi Iwai; +Cc: Sudip Mukherjee, alsa-devel, linux-kernel
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.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
i have not given Jaroslav Kysela <perex@perex.cz> 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(-)
diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c
index 59e37c5..2c53154 100644
--- a/sound/pci/ice1712/hoontech.c
+++ b/sound/pci/ice1712/hoontech.c
@@ -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)
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index 48a0c33..b97a0f9 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -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)
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index f633e3b..fa88485 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -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)
diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
index 7a6c078..d6f2fb0 100644
--- a/sound/pci/ice1712/juli.c
+++ b/sound/pci/ice1712/juli.c
@@ -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;
}
/*
diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
index 1eb151aa..3919aed 100644
--- a/sound/pci/ice1712/prodigy192.c
+++ b/sound/pci/ice1712/prodigy192.c
@@ -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;
}
diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c
index d4caf9d..3903e05 100644
--- a/sound/pci/ice1712/quartet.c
+++ b/sound/pci/ice1712/quartet.c
@@ -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)
--
1.8.1.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] ALSA: ice1712: remove unused variable
2014-11-13 15:14 [PATCH 1/2] ALSA: ice1712: remove unneeded return statement Sudip Mukherjee
@ 2014-11-13 15:14 ` Sudip Mukherjee
2014-11-13 15:22 ` [alsa-devel] " Takashi Iwai
2014-11-13 15:21 ` [PATCH 1/2] ALSA: ice1712: remove unneeded return statement Takashi Iwai
1 sibling, 1 reply; 5+ messages in thread
From: Sudip Mukherjee @ 2014-11-13 15:14 UTC (permalink / raw)
To: Takashi Iwai; +Cc: Sudip Mukherjee, alsa-devel, linux-kernel
these variable were initialized with some value, but never used.
and so they are safe to be deleted.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
i have not given Jaroslav Kysela <perex@perex.cz> 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(-)
diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
index b97a0f9..8f27357 100644
--- a/sound/pci/ice1712/ice1712.c
+++ b/sound/pci/ice1712/ice1712.c
@@ -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;
diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
index 1112ec1..1f40dab 100644
--- a/sound/pci/ice1712/revo.c
+++ b/sound/pci/ice1712/revo.c
@@ -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;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] ALSA: ice1712: remove unneeded return statement
2014-11-13 15:14 [PATCH 1/2] ALSA: ice1712: remove unneeded return statement Sudip Mukherjee
2014-11-13 15:14 ` [PATCH 2/2] ALSA: ice1712: remove unused variable Sudip Mukherjee
@ 2014-11-13 15:21 ` Takashi Iwai
1 sibling, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2014-11-13 15:21 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: alsa-devel, linux-kernel
At Thu, 13 Nov 2014 20:44:16 +0530,
Sudip Mukherjee wrote:
>
> 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
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>
> i have not given Jaroslav Kysela <perex@perex.cz> 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(-)
>
> diff --git a/sound/pci/ice1712/hoontech.c b/sound/pci/ice1712/hoontech.c
> index 59e37c5..2c53154 100644
> --- a/sound/pci/ice1712/hoontech.c
> +++ b/sound/pci/ice1712/hoontech.c
> @@ -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)
> diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
> index 48a0c33..b97a0f9 100644
> --- a/sound/pci/ice1712/ice1712.c
> +++ b/sound/pci/ice1712/ice1712.c
> @@ -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)
> diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
> index f633e3b..fa88485 100644
> --- a/sound/pci/ice1712/ice1724.c
> +++ b/sound/pci/ice1712/ice1724.c
> @@ -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)
> diff --git a/sound/pci/ice1712/juli.c b/sound/pci/ice1712/juli.c
> index 7a6c078..d6f2fb0 100644
> --- a/sound/pci/ice1712/juli.c
> +++ b/sound/pci/ice1712/juli.c
> @@ -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;
> }
>
> /*
> diff --git a/sound/pci/ice1712/prodigy192.c b/sound/pci/ice1712/prodigy192.c
> index 1eb151aa..3919aed 100644
> --- a/sound/pci/ice1712/prodigy192.c
> +++ b/sound/pci/ice1712/prodigy192.c
> @@ -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;
> }
>
>
> diff --git a/sound/pci/ice1712/quartet.c b/sound/pci/ice1712/quartet.c
> index d4caf9d..3903e05 100644
> --- a/sound/pci/ice1712/quartet.c
> +++ b/sound/pci/ice1712/quartet.c
> @@ -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)
> --
> 1.8.1.2
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [alsa-devel] [PATCH 2/2] ALSA: ice1712: remove unused variable
2014-11-13 15:14 ` [PATCH 2/2] ALSA: ice1712: remove unused variable Sudip Mukherjee
@ 2014-11-13 15:22 ` Takashi Iwai
2014-11-14 8:19 ` Sudip Mukherjee
0 siblings, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2014-11-13 15:22 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: alsa-devel, linux-kernel
At Thu, 13 Nov 2014 20:44:17 +0530,
Sudip Mukherjee wrote:
>
> these variable were initialized with some value, but never used.
> and so they are safe to be deleted.
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>
> i have not given Jaroslav Kysela <perex@perex.cz> 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(-)
>
> diff --git a/sound/pci/ice1712/ice1712.c b/sound/pci/ice1712/ice1712.c
> index b97a0f9..8f27357 100644
> --- a/sound/pci/ice1712/ice1712.c
> +++ b/sound/pci/ice1712/ice1712.c
> @@ -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;
> diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
> index 1112ec1..1f40dab 100644
> --- a/sound/pci/ice1712/revo.c
> +++ b/sound/pci/ice1712/revo.c
> @@ -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);
IMO, this is rather a bug. It should return the error (with a proper
error handling).
thanks,
Takashi
> /* 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;
> --
> 1.8.1.2
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [alsa-devel] [PATCH 2/2] ALSA: ice1712: remove unused variable
2014-11-13 15:22 ` [alsa-devel] " Takashi Iwai
@ 2014-11-14 8:19 ` Sudip Mukherjee
0 siblings, 0 replies; 5+ messages in thread
From: Sudip Mukherjee @ 2014-11-14 8:19 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel, linux-kernel
On Thu, Nov 13, 2014 at 04:22:45PM +0100, Takashi Iwai wrote:
> At Thu, 13 Nov 2014 20:44:17 +0530,
> Sudip Mukherjee wrote:
> >
<snip>
> > if (snd_pcm_format_width(runtime->format) == 16)
> > tmp &= ~0x04;
> > diff --git a/sound/pci/ice1712/revo.c b/sound/pci/ice1712/revo.c
> > index 1112ec1..1f40dab 100644
> > --- a/sound/pci/ice1712/revo.c
> > +++ b/sound/pci/ice1712/revo.c
> > @@ -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);
>
> 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
>
> thanks,
>
> Takashi
>
>
> > /* 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;
> > --
> > 1.8.1.2
> >
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-11-14 8:19 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-13 15:14 [PATCH 1/2] ALSA: ice1712: remove unneeded return statement Sudip Mukherjee
2014-11-13 15:14 ` [PATCH 2/2] ALSA: ice1712: remove unused variable Sudip Mukherjee
2014-11-13 15:22 ` [alsa-devel] " Takashi Iwai
2014-11-14 8:19 ` Sudip Mukherjee
2014-11-13 15:21 ` [PATCH 1/2] ALSA: ice1712: remove unneeded return statement Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox