Changeset de16f89 in mainline for uspace/drv/audio/hdaudio/hdactl.c


Ignore:
Timestamp:
2014-09-05T08:52:51Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
089901e
Parents:
3fec817
Message:

Add cleanup code to error paths.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/hdaudio/hdactl.c

    r3fec817 rde16f89  
    217217        return EOK;
    218218error:
     219        if (hda->ctl->corb_virt != NULL)
     220                dmamem_unmap_anonymous(&hda->ctl->corb_virt);
    219221        return EIO;
     222}
     223
     224/** Tear down the CORB */
     225static void hda_corb_fini(hda_t *hda)
     226{
     227        uint8_t ctl;
     228
     229        /* Stop CORB */
     230        ctl = hda_reg8_read(&hda->regs->corbctl);
     231        hda_reg8_write(&hda->regs->corbctl, ctl & ~BIT_V(uint8_t, corbctl_run));
     232
     233        if (hda->ctl->corb_virt != NULL)
     234                dmamem_unmap_anonymous(&hda->ctl->corb_virt);
    220235}
    221236
     
    290305        return EOK;
    291306error:
     307        if (hda->ctl->rirb_virt != NULL)
     308                dmamem_unmap_anonymous(&hda->ctl->rirb_virt);
    292309        return EIO;
     310}
     311
     312/** Tear down the RIRB */
     313static void hda_rirb_fini(hda_t *hda)
     314{
     315        uint8_t ctl;
     316
     317        /* Stop RIRB and disable RIRB interrupt */
     318        ctl = hda_reg8_read(&hda->regs->rirbctl);
     319        hda_reg8_write(&hda->regs->rirbctl, ctl &
     320            ~(BIT_V(uint8_t, rirbctl_run) | BIT_V(uint8_t, rirbctl_int)));
     321
     322        if (hda->ctl->rirb_virt != NULL)
     323                dmamem_unmap_anonymous(&hda->ctl->rirb_virt);
    293324}
    294325
     
    571602        return ctl;
    572603error:
     604        hda_rirb_fini(hda);
     605        hda_corb_fini(hda);
    573606        free(ctl);
    574607        hda->ctl = NULL;
    575608        return NULL;
     609}
     610
     611void hda_ctl_fini(hda_ctl_t *ctl)
     612{
     613        ddf_msg(LVL_NOTE, "hda_ctl_fini()");
     614        hda_rirb_fini(ctl->hda);
     615        hda_corb_fini(ctl->hda);
     616        free(ctl);
    576617}
    577618
     
    595636
    596637        return EOK;
    597 }
    598 
    599 void hda_ctl_fini(hda_ctl_t *ctl)
    600 {
    601         ddf_msg(LVL_NOTE, "hda_ctl_fini()");
    602         free(ctl);
    603638}
    604639
Note: See TracChangeset for help on using the changeset viewer.