Re: [PATCH] SOUND: riptide.c proper handling of pci_register_driver for joystick

From: Takashi Iwai
Date: Wed Jul 15 2009 - 08:01:54 EST


At Wed, 15 Jul 2009 16:45:40 +0530,
Jaswinder Singh Rajput wrote:
>
> On Wed, 2009-07-15 at 11:10 +0200, Takashi Iwai wrote:
> > At Wed, 15 Jul 2009 11:57:30 +0530,
> > Jaswinder Singh Rajput wrote:
> > >
> > > I am getting this compiler warning in linus tree :
> > >
> > > CC [M] sound/pci/riptide/riptide.o
> > > sound/pci/riptide/riptide.c: In function âalsa_card_riptide_initâ:
> > > sound/pci/riptide/riptide.c:2200: warning: ignoring return value of â__pci_register_driverâ, declared with attribute warn_unused_result
> > >
> > > This fixes the warning in my case, hope this will be helpful :
> > >
> > > diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
> > > index 235a71e..fd8a552 100644
> > > --- a/sound/pci/riptide/riptide.c
> > > +++ b/sound/pci/riptide/riptide.c
> > > @@ -2197,9 +2197,9 @@ static int __init alsa_card_riptide_init(void)
> > > if (err < 0)
> > > return err;
> > > #if defined(SUPPORT_JOYSTICK)
> > > - pci_register_driver(&joystick_driver);
> > > + err = pci_register_driver(&joystick_driver);
> > > #endif
> > > - return 0;
> > > + return err;
> >
> > In that case, the formerly registered audio driver should be
> > unregistered before returning the error from the probe callback.
> > Could you fix that?
> >
>
> [PATCH] SOUND: riptide.c proper handling of pci_register_driver for joystick
>
> We need to check returning error for pci_register_driver(&joystick_driver)
>
> On failure, we should unregister formerly registered audio drivers
>
> This also fixed the compiler warning :
>
> CC [M] sound/pci/riptide/riptide.o
> sound/pci/riptide/riptide.c: In function âalsa_card_riptide_initâ:
> sound/pci/riptide/riptide.c:2200: warning: ignoring return value of â__pci_register_driverâ, declared with attribute warn_unused_result
>
> Signed-off-by: Jaswinder Singh Rajput <jaswinderrajput@xxxxxxxxx>

Applied now. Thanks.


Takashi

> ---
> sound/pci/riptide/riptide.c | 7 +++++--
> 1 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c
> index 235a71e..b5ca02e 100644
> --- a/sound/pci/riptide/riptide.c
> +++ b/sound/pci/riptide/riptide.c
> @@ -2197,9 +2197,12 @@ static int __init alsa_card_riptide_init(void)
> if (err < 0)
> return err;
> #if defined(SUPPORT_JOYSTICK)
> - pci_register_driver(&joystick_driver);
> + err = pci_register_driver(&joystick_driver);
> + /* On failure unregister formerly registered audio driver */
> + if (err < 0)
> + pci_unregister_driver(&driver);
> #endif
> - return 0;
> + return err;
> }
>
> static void __exit alsa_card_riptide_exit(void)
> --
> 1.6.0.6
>
>
>
--
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/