* [patch] ALSA: fm801: add error handling if auto-detect fails
@ 2011-05-26 8:47 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2011-05-26 8:47 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: Takashi Iwai, kernel-janitors, alsa-devel, Ondrej Zary
In the original code if auto detect failed and tea575x_tuner = 4
then we copy bogus information to chip->tea.card. I've changed the
autodetect code to cleanup and return -ENODEV on error instead.
I made the previous chunk return on error as well. Potentially the
hardware should limp along without the radio? I don't know this
hardware well enough to say.
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
Compile tested only.
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index eacd490..a7ec703 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1234,9 +1234,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci));
if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 &&
(tea575x_tuner & TUNER_TYPE_MASK) < 4) {
- if (snd_tea575x_init(&chip->tea))
+ if (snd_tea575x_init(&chip->tea)) {
snd_printk(KERN_ERR "TEA575x radio not found\n");
- } else if ((tea575x_tuner & TUNER_TYPE_MASK) = 0)
+ snd_fm801_free(chip);
+ return -ENODEV;
+ }
+ } else if ((tea575x_tuner & TUNER_TYPE_MASK) = 0) {
/* autodetect tuner connection */
for (tea575x_tuner = 1; tea575x_tuner <= 3; tea575x_tuner++) {
chip->tea575x_tuner = tea575x_tuner;
@@ -1246,6 +1249,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
break;
}
}
+ if (tea575x_tuner = 4) {
+ snd_printk(KERN_ERR "TEA575x radio not found\n");
+ snd_fm801_free(chip);
+ return -ENODEV;
+ }
+ }
strlcpy(chip->tea.card, snd_fm801_tea575x_gpios[(tea575x_tuner & TUNER_TYPE_MASK) - 1].name, sizeof(chip->tea.card));
#endif
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [patch] ALSA: fm801: add error handling if auto-detect fails
@ 2011-05-26 8:47 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2011-05-26 8:47 UTC (permalink / raw)
To: Jaroslav Kysela; +Cc: Takashi Iwai, kernel-janitors, alsa-devel, Ondrej Zary
In the original code if auto detect failed and tea575x_tuner == 4
then we copy bogus information to chip->tea.card. I've changed the
autodetect code to cleanup and return -ENODEV on error instead.
I made the previous chunk return on error as well. Potentially the
hardware should limp along without the radio? I don't know this
hardware well enough to say.
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
Compile tested only.
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index eacd490..a7ec703 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1234,9 +1234,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci));
if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 &&
(tea575x_tuner & TUNER_TYPE_MASK) < 4) {
- if (snd_tea575x_init(&chip->tea))
+ if (snd_tea575x_init(&chip->tea)) {
snd_printk(KERN_ERR "TEA575x radio not found\n");
- } else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0)
+ snd_fm801_free(chip);
+ return -ENODEV;
+ }
+ } else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0) {
/* autodetect tuner connection */
for (tea575x_tuner = 1; tea575x_tuner <= 3; tea575x_tuner++) {
chip->tea575x_tuner = tea575x_tuner;
@@ -1246,6 +1249,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
break;
}
}
+ if (tea575x_tuner == 4) {
+ snd_printk(KERN_ERR "TEA575x radio not found\n");
+ snd_fm801_free(chip);
+ return -ENODEV;
+ }
+ }
strlcpy(chip->tea.card, snd_fm801_tea575x_gpios[(tea575x_tuner & TUNER_TYPE_MASK) - 1].name, sizeof(chip->tea.card));
#endif
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [patch] ALSA: fm801: add error handling if auto-detect fails
2011-05-26 8:47 ` Dan Carpenter
@ 2011-06-03 8:12 ` Takashi Iwai
-1 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2011-06-03 8:12 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kernel-janitors, alsa-devel, Ondrej Zary
At Thu, 26 May 2011 11:47:35 +0300,
Dan Carpenter wrote:
>
> In the original code if auto detect failed and tea575x_tuner = 4
> then we copy bogus information to chip->tea.card. I've changed the
> autodetect code to cleanup and return -ENODEV on error instead.
>
> I made the previous chunk return on error as well. Potentially the
> hardware should limp along without the radio? I don't know this
> hardware well enough to say.
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Looks good to me. Applied now.
thanks,
Takashi
> ---
> Compile tested only.
>
> diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
> index eacd490..a7ec703 100644
> --- a/sound/pci/fm801.c
> +++ b/sound/pci/fm801.c
> @@ -1234,9 +1234,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
> sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci));
> if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 &&
> (tea575x_tuner & TUNER_TYPE_MASK) < 4) {
> - if (snd_tea575x_init(&chip->tea))
> + if (snd_tea575x_init(&chip->tea)) {
> snd_printk(KERN_ERR "TEA575x radio not found\n");
> - } else if ((tea575x_tuner & TUNER_TYPE_MASK) = 0)
> + snd_fm801_free(chip);
> + return -ENODEV;
> + }
> + } else if ((tea575x_tuner & TUNER_TYPE_MASK) = 0) {
> /* autodetect tuner connection */
> for (tea575x_tuner = 1; tea575x_tuner <= 3; tea575x_tuner++) {
> chip->tea575x_tuner = tea575x_tuner;
> @@ -1246,6 +1249,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
> break;
> }
> }
> + if (tea575x_tuner = 4) {
> + snd_printk(KERN_ERR "TEA575x radio not found\n");
> + snd_fm801_free(chip);
> + return -ENODEV;
> + }
> + }
> strlcpy(chip->tea.card, snd_fm801_tea575x_gpios[(tea575x_tuner & TUNER_TYPE_MASK) - 1].name, sizeof(chip->tea.card));
> #endif
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] ALSA: fm801: add error handling if auto-detect fails
@ 2011-06-03 8:12 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2011-06-03 8:12 UTC (permalink / raw)
To: Dan Carpenter; +Cc: kernel-janitors, alsa-devel, Ondrej Zary
At Thu, 26 May 2011 11:47:35 +0300,
Dan Carpenter wrote:
>
> In the original code if auto detect failed and tea575x_tuner == 4
> then we copy bogus information to chip->tea.card. I've changed the
> autodetect code to cleanup and return -ENODEV on error instead.
>
> I made the previous chunk return on error as well. Potentially the
> hardware should limp along without the radio? I don't know this
> hardware well enough to say.
>
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Looks good to me. Applied now.
thanks,
Takashi
> ---
> Compile tested only.
>
> diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
> index eacd490..a7ec703 100644
> --- a/sound/pci/fm801.c
> +++ b/sound/pci/fm801.c
> @@ -1234,9 +1234,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
> sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci));
> if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 &&
> (tea575x_tuner & TUNER_TYPE_MASK) < 4) {
> - if (snd_tea575x_init(&chip->tea))
> + if (snd_tea575x_init(&chip->tea)) {
> snd_printk(KERN_ERR "TEA575x radio not found\n");
> - } else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0)
> + snd_fm801_free(chip);
> + return -ENODEV;
> + }
> + } else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0) {
> /* autodetect tuner connection */
> for (tea575x_tuner = 1; tea575x_tuner <= 3; tea575x_tuner++) {
> chip->tea575x_tuner = tea575x_tuner;
> @@ -1246,6 +1249,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
> break;
> }
> }
> + if (tea575x_tuner == 4) {
> + snd_printk(KERN_ERR "TEA575x radio not found\n");
> + snd_fm801_free(chip);
> + return -ENODEV;
> + }
> + }
> strlcpy(chip->tea.card, snd_fm801_tea575x_gpios[(tea575x_tuner & TUNER_TYPE_MASK) - 1].name, sizeof(chip->tea.card));
> #endif
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-06-03 8:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-26 8:47 [patch] ALSA: fm801: add error handling if auto-detect fails Dan Carpenter
2011-05-26 8:47 ` Dan Carpenter
2011-06-03 8:12 ` Takashi Iwai
2011-06-03 8:12 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.