On Thu, 03 May 2018 23:42:44 +0200,
Connor McAdams wrote:
> 
> @@ -4691,8 +4699,17 @@ static void ca0132_free(struct hda_codec *codec)
>  
>       cancel_delayed_work_sync(&spec->unsol_hp_work);
>       snd_hda_power_up(codec);
> -     snd_hda_sequence_write(codec, spec->base_exit_verbs);
> -     ca0132_exit_chip(codec);
> +     switch (spec->quirk) {
> +     case QUIRK_SBZ:
> +             iounmap(spec->mem_base);
> +             snd_hda_sequence_write(codec, spec->base_exit_verbs);
> +             ca0132_exit_chip(codec);
> +             break;

Do you need to unmap before the rest procedure?
Usually the unmapping happens at the last, after all commands
finished.

> +     default:
> +             snd_hda_sequence_write(codec, spec->base_exit_verbs);
> +             ca0132_exit_chip(codec);
> +             break;
> +     }
>       snd_hda_power_down(codec);
>       kfree(spec->spec_init_verbs);
>       kfree(codec->spec);

So in this case, a cleaner way would be to add the conditional iounmap
like:

        snd_hda_power_down(codec);
        if (spec->mem_base)
                iounmap(spec->mem_base);
        kfree(spec->spec_init_verbs);
        kfree(codec->spec);
        
> @@ -4909,6 +4926,15 @@ static int patch_ca0132(struct hda_codec *codec)
>       else
>               spec->quirk = QUIRK_NONE;
>  
> +     /* Setup BAR Region 2 for Sound Blaster Z */
> +     if (spec->quirk == QUIRK_SBZ) {
> +             spec->mem_base = pci_iomap(codec->bus->pci, 2, 0xC20);
> +             if (spec->mem_base == NULL) {
> +                     codec_dbg(codec, "pci_iomap failed!");
> +                     codec_dbg(codec, "perhaps this is not an SBZ?");

This should be shown more explicitly, so better to be codec_warn() or
codec_info().


thanks,

Takashi

Reply via email to