[PATCH] media-radio: video device unregister in one fail case [Was: Re: [PATCH 1/4] media-radio: Pci probing for maestro radio]

From: Jiri Slaby
Date: Wed Jan 04 2006 - 05:21:18 EST


Adam Tlalka wrote:
>Dnia 04-01-2006 o 10:45:32 Andrew Morton <akpm@xxxxxxxx> napisal:
>
>> "Jiri Slaby" <xslaby@xxxxxxxxxx> wrote:
>>>
>>> + retval = video_register_device(maestro_radio_inst, VFL_TYPE_RADIO,
>>> + radio_nr);
>>> + if (retval) {
>>> + printk(KERN_ERR "can't register video device!\n");
>>> + goto errfr1;
>>> + }
>>> +
>>> + if (!radio_power_on(radio_unit)) {
>>> + retval = -EIO;
>>
>> Shouldn't we unregister the video device here?
>
>Current behaviour means that device is here but not functioning properly
>but
>we can unregister it of course because it is useless anyway ;-).
Yup, here is a patch to avoid this. Thanks. [Applicable/dependent after/on
media-radio-maestro-types-change (last patch)]

media-radio-pci-probing-for-maestro-radio-unregister-video

Unregister video device if it is registered, but driver fail still in
initialization.

--
radio-maestro.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletion(-)

--- drivers/media/radio/radio-maestro.c.old 2006-01-04 11:07:41.000000000 +0100
+++ drivers/media/radio/radio-maestro.c 2006-01-04 11:09:48.000000000 +0100
@@ -333,7 +333,7 @@ static int __devinit maestro_probe(struc

if (!radio_power_on(radio_unit)) {
retval = -EIO;
- goto errfr1;
+ goto errunr;
}

dev_info(&pdev->dev, "version " DRIVER_VERSION " time " __TIME__ " "
@@ -341,6 +341,8 @@ static int __devinit maestro_probe(struc
dev_info(&pdev->dev, "radio chip initialized\n");

return 0;
+errunr:
+ video_unregister_device(maestro_radio_inst);
errfr1:
kfree(maestro_radio_inst);
errfr:
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/