Changeset b7fd2a0 in mainline for uspace/drv/audio/sb16/dsp.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/sb16/dsp.c

    r36f0738 rb7fd2a0  
    8989}
    9090
    91 static inline int dsp_read(sb_dsp_t *dsp, uint8_t *data)
     91static inline errno_t dsp_read(sb_dsp_t *dsp, uint8_t *data)
    9292{
    9393        assert(data);
     
    106106}
    107107
    108 static inline int dsp_write(sb_dsp_t *dsp, uint8_t data)
     108static inline errno_t dsp_write(sb_dsp_t *dsp, uint8_t data)
    109109{
    110110        assert(dsp);
     
    159159}
    160160
    161 static inline int setup_dma(sb_dsp_t *dsp, uintptr_t pa, size_t size)
     161static inline errno_t setup_dma(sb_dsp_t *dsp, uintptr_t pa, size_t size)
    162162{
    163163        async_sess_t *sess = ddf_dev_parent_sess_get(dsp->sb_dev);
     
    168168}
    169169
    170 static inline int setup_buffer(sb_dsp_t *dsp, size_t size)
     170static inline errno_t setup_buffer(sb_dsp_t *dsp, size_t size)
    171171{
    172172        assert(dsp);
     
    178178        void *buffer = AS_AREA_ANY;
    179179       
    180         int ret = dmamem_map_anonymous(size, DMAMEM_16MiB | 0x0000ffff,
     180        errno_t ret = dmamem_map_anonymous(size, DMAMEM_16MiB | 0x0000ffff,
    181181            AS_AREA_WRITE | AS_AREA_READ, 0, &pa, &buffer);
    182182        if (ret != EOK) {
     
    202202}
    203203
    204 int sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs, ddf_dev_t *dev,
     204errno_t sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs, ddf_dev_t *dev,
    205205    int dma8, int dma16)
    206206{
     
    215215        dsp_reset(dsp);
    216216        uint8_t response;
    217         const int ret = dsp_read(dsp, &response);
     217        const errno_t ret = dsp_read(dsp, &response);
    218218        if (ret != EOK) {
    219219                ddf_log_error("Failed to read DSP reset response value.");
     
    294294}
    295295
    296 int sb_dsp_get_buffer_position(sb_dsp_t *dsp, size_t *pos)
     296errno_t sb_dsp_get_buffer_position(sb_dsp_t *dsp, size_t *pos)
    297297{
    298298        if (dsp->state == DSP_NO_BUFFER)
     
    304304        // TODO: Assumes DMA 16
    305305        size_t remain;
    306         int rc = hw_res_dma_channel_remain(sess, dsp->dma16_channel, &remain);
     306        errno_t rc = hw_res_dma_channel_remain(sess, dsp->dma16_channel, &remain);
    307307        if (rc == EOK) {
    308308                *pos = dsp->buffer.size - remain;
     
    311311}
    312312
    313 int sb_dsp_test_format(sb_dsp_t *dsp, unsigned *channels, unsigned *rate,
     313errno_t sb_dsp_test_format(sb_dsp_t *dsp, unsigned *channels, unsigned *rate,
    314314  pcm_sample_format_t *format)
    315315{
    316         int ret = EOK;
     316        errno_t ret = EOK;
    317317        if (*channels == 0 || *channels > 2) {
    318318                *channels = 2;
     
    336336}
    337337
    338 int sb_dsp_set_event_session(sb_dsp_t *dsp, async_sess_t *session)
     338errno_t sb_dsp_set_event_session(sb_dsp_t *dsp, async_sess_t *session)
    339339{
    340340        assert(dsp);
     
    353353}
    354354
    355 int sb_dsp_get_buffer(sb_dsp_t *dsp, void **buffer, size_t *size)
     355errno_t sb_dsp_get_buffer(sb_dsp_t *dsp, void **buffer, size_t *size)
    356356{
    357357        assert(dsp);
     
    364364        assert(dsp->buffer.data == NULL);
    365365
    366         const int ret = setup_buffer(dsp, *size);
     366        const errno_t ret = setup_buffer(dsp, *size);
    367367        if (ret == EOK) {
    368368                ddf_log_debug("Providing buffer: %p, %zu B.",
     
    378378}
    379379
    380 int sb_dsp_release_buffer(sb_dsp_t *dsp)
     380errno_t sb_dsp_release_buffer(sb_dsp_t *dsp)
    381381{
    382382        assert(dsp);
     
    392392}
    393393
    394 int sb_dsp_start_playback(sb_dsp_t *dsp, unsigned frames,
     394errno_t sb_dsp_start_playback(sb_dsp_t *dsp, unsigned frames,
    395395    unsigned channels, unsigned sampling_rate, pcm_sample_format_t format)
    396396{
     
    441441}
    442442
    443 int sb_dsp_stop_playback(sb_dsp_t *dsp, bool immediate)
     443errno_t sb_dsp_stop_playback(sb_dsp_t *dsp, bool immediate)
    444444{
    445445        assert(dsp);
     
    471471}
    472472
    473 int sb_dsp_start_capture(sb_dsp_t *dsp, unsigned frames,
     473errno_t sb_dsp_start_capture(sb_dsp_t *dsp, unsigned frames,
    474474    unsigned channels, unsigned sampling_rate, pcm_sample_format_t format)
    475475{
     
    517517}
    518518
    519 int sb_dsp_stop_capture(sb_dsp_t *dsp, bool immediate)
     519errno_t sb_dsp_stop_capture(sb_dsp_t *dsp, bool immediate)
    520520{
    521521        assert(dsp);
Note: See TracChangeset for help on using the changeset viewer.