sound: use DEFINE_PCI_DEVICE_TABLE
[safe/jmp/linux-2.6] / sound / pci / mixart / mixart.c
index 082c0d0..7e8e7da 100644 (file)
  */
 
 
-#include <sound/driver.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/pci.h>
+#include <linux/dma-mapping.h>
 #include <linux/moduleparam.h>
+#include <linux/mutex.h>
+
 #include <sound/core.h>
 #include <sound/initval.h>
 #include <sound/info.h>
@@ -58,19 +60,20 @@ MODULE_PARM_DESC(enable, "Enable Digigram " CARD_NAME " soundcard.");
 /*
  */
 
-static struct pci_device_id snd_mixart_ids[] = {
-       { 0x1057, 0x0003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0, }, /* MC8240 */
+static DEFINE_PCI_DEVICE_TABLE(snd_mixart_ids) = {
+       { PCI_VDEVICE(MOTOROLA, 0x0003), 0, }, /* MC8240 */
        { 0, }
 };
 
 MODULE_DEVICE_TABLE(pci, snd_mixart_ids);
 
 
-static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int start)
+static int mixart_set_pipe_state(struct mixart_mgr *mgr,
+                                struct mixart_pipe *pipe, int start)
 {
-       mixart_group_state_req_t group_state;
-       mixart_group_state_resp_t group_state_resp;
-       mixart_msg_t request;
+       struct mixart_group_state_req group_state;
+       struct mixart_group_state_resp group_state_resp;
+       struct mixart_msg request;
        int err;
        u32 system_msg_uid;
 
@@ -92,7 +95,7 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta
        /* wait on the last MSG_SYSTEM_SEND_SYNCHRO_CMD command to be really finished */
 
        request.message_id = MSG_SYSTEM_WAIT_SYNCHRO_CMD;
-       request.uid = (mixart_uid_t){0,0};
+       request.uid = (struct mixart_uid){0,0};
        request.data = &system_msg_uid;
        request.size = sizeof(system_msg_uid);
 
@@ -113,7 +116,7 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta
        else
                request.message_id = MSG_STREAM_STOP_STREAM_GRP_PACKET;
 
-       request.uid = pipe->group_uid; /*(mixart_uid_t){0,0};*/
+       request.uid = pipe->group_uid; /*(struct mixart_uid){0,0};*/
        request.data = &group_state;
        request.size = sizeof(group_state);
 
@@ -137,7 +140,7 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta
                /* in case of start send a synchro top */
 
                request.message_id = MSG_SYSTEM_SEND_SYNCHRO_CMD;
-               request.uid = (mixart_uid_t){0,0};
+               request.uid = (struct mixart_uid){0,0};
                request.data = NULL;
                request.size = 0;
 
@@ -156,11 +159,12 @@ static int mixart_set_pipe_state(mixart_mgr_t *mgr, mixart_pipe_t* pipe, int sta
 }
 
 
-static int mixart_set_clock(mixart_mgr_t *mgr, mixart_pipe_t *pipe, unsigned int rate)
+static int mixart_set_clock(struct mixart_mgr *mgr,
+                           struct mixart_pipe *pipe, unsigned int rate)
 {
-       mixart_msg_t request;
-       mixart_clock_properties_t clock_properties;
-       mixart_clock_properties_resp_t clock_prop_resp;
+       struct mixart_msg request;
+       struct mixart_clock_properties clock_properties;
+       struct mixart_clock_properties_resp clock_prop_resp;
        int err;
 
        switch(pipe->status) {
@@ -208,11 +212,13 @@ static int mixart_set_clock(mixart_mgr_t *mgr, mixart_pipe_t *pipe, unsigned int
 /*
  *  Allocate or reference output pipe for analog IOs (pcmp0/1)
  */
-mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capture, int monitoring)
+struct mixart_pipe *
+snd_mixart_add_ref_pipe(struct snd_mixart *chip, int pcm_number, int capture,
+                       int monitoring)
 {
        int stream_count;
-       mixart_pipe_t *pipe;
-       mixart_msg_t request;
+       struct mixart_pipe *pipe;
+       struct mixart_msg request;
 
        if(capture) {
                if (pcm_number == MIXART_PCM_ANALOG) {
@@ -241,8 +247,8 @@ mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capt
        if( pipe->status == PIPE_UNDEFINED ) {
                int err, i;
                struct {
-                       mixart_streaming_group_req_t sgroup_req;
-                       mixart_streaming_group_t sgroup_resp;
+                       struct mixart_streaming_group_req sgroup_req;
+                       struct mixart_streaming_group sgroup_resp;
                } *buf;
 
                snd_printdd("add_ref_pipe audio chip(%d) pcm(%d)\n", chip->chip_idx, pcm_number);
@@ -251,7 +257,7 @@ mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capt
                if (!buf)
                        return NULL;
 
-               request.uid = (mixart_uid_t){0,0};      /* should be StreamManagerUID, but zero is OK if there is only one ! */
+               request.uid = (struct mixart_uid){0,0};      /* should be StreamManagerUID, but zero is OK if there is only one ! */
                request.data = &buf->sgroup_req;
                request.size = sizeof(buf->sgroup_req);
 
@@ -279,7 +285,7 @@ mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capt
                        buf->sgroup_req.flow_entry[i] = j;
 
                        flowinfo = (struct mixart_flowinfo *)chip->mgr->flowinfo.area;
-                       flowinfo[j].bufferinfo_array_phy_address = (u32)chip->mgr->bufferinfo.addr + (j * sizeof(mixart_bufferinfo_t));
+                       flowinfo[j].bufferinfo_array_phy_address = (u32)chip->mgr->bufferinfo.addr + (j * sizeof(struct mixart_bufferinfo));
                        flowinfo[j].bufferinfo_count = 1;               /* 1 will set the miXart to ring-buffer mode ! */
 
                        bufferinfo = (struct mixart_bufferinfo *)chip->mgr->bufferinfo.area;
@@ -315,7 +321,8 @@ mixart_pipe_t* snd_mixart_add_ref_pipe( mixart_t *chip, int pcm_number, int capt
 }
 
 
-int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monitoring)
+int snd_mixart_kill_ref_pipe(struct mixart_mgr *mgr,
+                            struct mixart_pipe *pipe, int monitoring)
 {
        int err = 0;
 
@@ -329,8 +336,8 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito
 
        if((pipe->references <= 0) && (pipe->monitoring == 0)) {
 
-               mixart_msg_t request;
-               mixart_delete_group_resp_t delete_resp;
+               struct mixart_msg request;
+               struct mixart_delete_group_resp delete_resp;
 
                /* release the clock */
                err = mixart_set_clock( mgr, pipe, 0);
@@ -345,7 +352,7 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito
                }
 
                request.message_id = MSG_STREAM_DELETE_GROUP;
-               request.uid = (mixart_uid_t){0,0};
+               request.uid = (struct mixart_uid){0,0};
                request.data = &pipe->group_uid;            /* the streaming group ! */
                request.size = sizeof(pipe->group_uid);
 
@@ -355,7 +362,7 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito
                        snd_printk(KERN_ERR "error MSG_STREAM_DELETE_GROUP err(%x), status(%x)\n", err, delete_resp.status);
                }
 
-               pipe->group_uid = (mixart_uid_t){0,0};
+               pipe->group_uid = (struct mixart_uid){0,0};
                pipe->stream_count = 0;
                pipe->status = PIPE_UNDEFINED;
        }
@@ -363,11 +370,11 @@ int snd_mixart_kill_ref_pipe( mixart_mgr_t *mgr, mixart_pipe_t *pipe, int monito
        return err;
 }
 
-static int mixart_set_stream_state(mixart_stream_t *stream, int start)
+static int mixart_set_stream_state(struct mixart_stream *stream, int start)
 {
-       mixart_t *chip;
-       mixart_stream_state_req_t stream_state_req;
-       mixart_msg_t request;
+       struct snd_mixart *chip;
+       struct mixart_stream_state_req stream_state_req;
+       struct mixart_msg request;
 
        if(!stream->substream)
                return -EINVAL;
@@ -382,7 +389,7 @@ static int mixart_set_stream_state(mixart_stream_t *stream, int start)
        else
                request.message_id = start ? MSG_STREAM_START_OUTPUT_STAGE_PACKET : MSG_STREAM_STOP_OUTPUT_STAGE_PACKET;
 
-       request.uid = (mixart_uid_t){0,0};
+       request.uid = (struct mixart_uid){0,0};
        request.data = &stream_state_req;
        request.size = sizeof(stream_state_req);
 
@@ -399,9 +406,9 @@ static int mixart_set_stream_state(mixart_stream_t *stream, int start)
  *  Trigger callback
  */
 
-static int snd_mixart_trigger(snd_pcm_substream_t *subs, int cmd)
+static int snd_mixart_trigger(struct snd_pcm_substream *subs, int cmd)
 {
-       mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data;
+       struct mixart_stream *stream = subs->runtime->private_data;
 
        switch (cmd) {
        case SNDRV_PCM_TRIGGER_START:
@@ -443,16 +450,15 @@ static int snd_mixart_trigger(snd_pcm_substream_t *subs, int cmd)
        return 0;
 }
 
-static int mixart_sync_nonblock_events(mixart_mgr_t *mgr)
+static int mixart_sync_nonblock_events(struct mixart_mgr *mgr)
 {
-       int timeout = HZ;
+       unsigned long timeout = jiffies + HZ;
        while (atomic_read(&mgr->msg_processed) > 0) {
-               if (! timeout--) {
+               if (time_after(jiffies, timeout)) {
                        snd_printk(KERN_ERR "mixart: cannot process nonblock events!\n");
                        return -EBUSY;
                }
-               set_current_state(TASK_UNINTERRUPTIBLE);
-               schedule_timeout(1);
+               schedule_timeout_uninterruptible(1);
        }
        return 0;
 }
@@ -460,12 +466,12 @@ static int mixart_sync_nonblock_events(mixart_mgr_t *mgr)
 /*
  *  prepare callback for all pcms
  */
-static int snd_mixart_prepare(snd_pcm_substream_t *subs)
+static int snd_mixart_prepare(struct snd_pcm_substream *subs)
 {
-       mixart_t *chip = snd_pcm_substream_chip(subs);
-       mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data;
+       struct snd_mixart *chip = snd_pcm_substream_chip(subs);
+       struct mixart_stream *stream = subs->runtime->private_data;
 
-       /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */
+       /* TODO de façon non bloquante, réappliquer les hw_params (rate, bits, codec) */
 
        snd_printdd("snd_mixart_prepare\n");
 
@@ -486,13 +492,13 @@ static int snd_mixart_prepare(snd_pcm_substream_t *subs)
 }
 
 
-static int mixart_set_format(mixart_stream_t *stream, snd_pcm_format_t format)
+static int mixart_set_format(struct mixart_stream *stream, snd_pcm_format_t format)
 {
        int err;
-       mixart_t *chip;
-       mixart_msg_t request;
-       mixart_stream_param_desc_t stream_param;
-       mixart_return_uid_t resp;
+       struct snd_mixart *chip;
+       struct mixart_msg request;
+       struct mixart_stream_param_desc stream_param;
+       struct mixart_return_uid resp;
 
        chip = snd_pcm_substream_chip(stream->substream);
 
@@ -553,7 +559,7 @@ static int mixart_set_format(mixart_stream_t *stream, snd_pcm_format_t format)
        stream_param.stream_desc[0].stream_idx = stream->substream->number;
 
        request.message_id = MSG_STREAM_SET_INPUT_STAGE_PARAM;
-       request.uid = (mixart_uid_t){0,0};
+       request.uid = (struct mixart_uid){0,0};
        request.data = &stream_param;
        request.size = sizeof(stream_param);
 
@@ -569,12 +575,12 @@ static int mixart_set_format(mixart_stream_t *stream, snd_pcm_format_t format)
 /*
  *  HW_PARAMS callback for all pcms
  */
-static int snd_mixart_hw_params(snd_pcm_substream_t *subs,
-                                snd_pcm_hw_params_t *hw)
+static int snd_mixart_hw_params(struct snd_pcm_substream *subs,
+                                struct snd_pcm_hw_params *hw)
 {
-       mixart_t *chip = snd_pcm_substream_chip(subs);
-       mixart_mgr_t *mgr = chip->mgr;
-       mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data;
+       struct snd_mixart *chip = snd_pcm_substream_chip(subs);
+       struct mixart_mgr *mgr = chip->mgr;
+       struct mixart_stream *stream = subs->runtime->private_data;
        snd_pcm_format_t format;
        int err;
        int channels;
@@ -585,7 +591,7 @@ static int snd_mixart_hw_params(snd_pcm_substream_t *subs,
        /*  set up format for the stream */
        format = params_format(hw);
 
-       down(&mgr->setup_mutex);
+       mutex_lock(&mgr->setup_mutex);
 
        /* update the stream levels */
        if( stream->pcm_number <= MIXART_PCM_DIGITAL ) {
@@ -601,6 +607,7 @@ static int snd_mixart_hw_params(snd_pcm_substream_t *subs,
        /* set the format to the board */
        err = mixart_set_format(stream, format);
        if(err < 0) {
+               mutex_unlock(&mgr->setup_mutex);
                return err;
        }
 
@@ -624,14 +631,14 @@ static int snd_mixart_hw_params(snd_pcm_substream_t *subs,
                                bufferinfo[i].available_length,
                                subs->number);
        }
-       up(&mgr->setup_mutex);
+       mutex_unlock(&mgr->setup_mutex);
 
        return err;
 }
 
-static int snd_mixart_hw_free(snd_pcm_substream_t *subs)
+static int snd_mixart_hw_free(struct snd_pcm_substream *subs)
 {
-       mixart_t *chip = snd_pcm_substream_chip(subs);
+       struct snd_mixart *chip = snd_pcm_substream_chip(subs);
        snd_pcm_lib_free_pages(subs);
        mixart_sync_nonblock_events(chip->mgr);
        return 0;
@@ -642,10 +649,10 @@ static int snd_mixart_hw_free(snd_pcm_substream_t *subs)
 /*
  *  TODO CONFIGURATION SPACE for all pcms, mono pcm must update channels_max
  */
-static snd_pcm_hardware_t snd_mixart_analog_caps =
+static struct snd_pcm_hardware snd_mixart_analog_caps =
 {
        .info             = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
-                             SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START |
+                             SNDRV_PCM_INFO_MMAP_VALID |
                              SNDRV_PCM_INFO_PAUSE),
        .formats          = ( SNDRV_PCM_FMTBIT_U8 |
                              SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
@@ -663,10 +670,10 @@ static snd_pcm_hardware_t snd_mixart_analog_caps =
        .periods_max      = (32*1024/256),
 };
 
-static snd_pcm_hardware_t snd_mixart_digital_caps =
+static struct snd_pcm_hardware snd_mixart_digital_caps =
 {
        .info             = ( SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
-                             SNDRV_PCM_INFO_MMAP_VALID | SNDRV_PCM_INFO_SYNC_START |
+                             SNDRV_PCM_INFO_MMAP_VALID |
                              SNDRV_PCM_INFO_PAUSE),
        .formats          = ( SNDRV_PCM_FMTBIT_U8 |
                              SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S16_BE |
@@ -685,24 +692,24 @@ static snd_pcm_hardware_t snd_mixart_digital_caps =
 };
 
 
-static int snd_mixart_playback_open(snd_pcm_substream_t *subs)
+static int snd_mixart_playback_open(struct snd_pcm_substream *subs)
 {
-       mixart_t            *chip = snd_pcm_substream_chip(subs);
-       mixart_mgr_t        *mgr = chip->mgr;
-       snd_pcm_runtime_t   *runtime = subs->runtime;
-       snd_pcm_t           *pcm = subs->pcm;
-       mixart_stream_t     *stream;
-       mixart_pipe_t       *pipe;
+       struct snd_mixart            *chip = snd_pcm_substream_chip(subs);
+       struct mixart_mgr        *mgr = chip->mgr;
+       struct snd_pcm_runtime *runtime = subs->runtime;
+       struct snd_pcm *pcm = subs->pcm;
+       struct mixart_stream     *stream;
+       struct mixart_pipe       *pipe;
        int err = 0;
        int pcm_number;
 
-       down(&mgr->setup_mutex);
+       mutex_lock(&mgr->setup_mutex);
 
        if ( pcm == chip->pcm ) {
                pcm_number = MIXART_PCM_ANALOG;
                runtime->hw = snd_mixart_analog_caps;
        } else {
-               snd_assert ( pcm == chip->pcm_dig ); 
+               snd_BUG_ON(pcm != chip->pcm_dig);
                pcm_number = MIXART_PCM_DIGITAL;
                runtime->hw = snd_mixart_digital_caps;
        }
@@ -754,30 +761,30 @@ static int snd_mixart_playback_open(snd_pcm_substream_t *subs)
        }
 
  _exit_open:
-       up(&mgr->setup_mutex);
+       mutex_unlock(&mgr->setup_mutex);
 
        return err;
 }
 
 
-static int snd_mixart_capture_open(snd_pcm_substream_t *subs)
+static int snd_mixart_capture_open(struct snd_pcm_substream *subs)
 {
-       mixart_t            *chip = snd_pcm_substream_chip(subs);
-       mixart_mgr_t        *mgr = chip->mgr;
-       snd_pcm_runtime_t   *runtime = subs->runtime;
-       snd_pcm_t           *pcm = subs->pcm;
-       mixart_stream_t     *stream;
-       mixart_pipe_t       *pipe;
+       struct snd_mixart            *chip = snd_pcm_substream_chip(subs);
+       struct mixart_mgr        *mgr = chip->mgr;
+       struct snd_pcm_runtime *runtime = subs->runtime;
+       struct snd_pcm *pcm = subs->pcm;
+       struct mixart_stream     *stream;
+       struct mixart_pipe       *pipe;
        int err = 0;
        int pcm_number;
 
-       down(&mgr->setup_mutex);
+       mutex_lock(&mgr->setup_mutex);
 
        if ( pcm == chip->pcm ) {
                pcm_number = MIXART_PCM_ANALOG;
                runtime->hw = snd_mixart_analog_caps;
        } else {
-               snd_assert ( pcm == chip->pcm_dig ); 
+               snd_BUG_ON(pcm != chip->pcm_dig);
                pcm_number = MIXART_PCM_DIGITAL;
                runtime->hw = snd_mixart_digital_caps;
        }
@@ -832,20 +839,20 @@ static int snd_mixart_capture_open(snd_pcm_substream_t *subs)
        }
 
  _exit_open:
-       up(&mgr->setup_mutex);
+       mutex_unlock(&mgr->setup_mutex);
 
        return err;
 }
 
 
 
-static int snd_mixart_close(snd_pcm_substream_t *subs)
+static int snd_mixart_close(struct snd_pcm_substream *subs)
 {
-       mixart_t *chip = snd_pcm_substream_chip(subs);
-       mixart_mgr_t *mgr = chip->mgr;
-       mixart_stream_t *stream = (mixart_stream_t*)subs->runtime->private_data;
+       struct snd_mixart *chip = snd_pcm_substream_chip(subs);
+       struct mixart_mgr *mgr = chip->mgr;
+       struct mixart_stream *stream = subs->runtime->private_data;
 
-       down(&mgr->setup_mutex);
+       mutex_lock(&mgr->setup_mutex);
 
        snd_printdd("snd_mixart_close C%d/P%d/Sub%d\n", chip->chip_idx, stream->pcm_number, subs->number);
 
@@ -864,22 +871,22 @@ static int snd_mixart_close(snd_pcm_substream_t *subs)
        stream->status    = MIXART_STREAM_STATUS_FREE;
        stream->substream = NULL;
 
-       up(&mgr->setup_mutex);
+       mutex_unlock(&mgr->setup_mutex);
        return 0;
 }
 
 
-static snd_pcm_uframes_t snd_mixart_stream_pointer(snd_pcm_substream_t * subs)
+static snd_pcm_uframes_t snd_mixart_stream_pointer(struct snd_pcm_substream *subs)
 {
-       snd_pcm_runtime_t *runtime = subs->runtime;
-       mixart_stream_t   *stream  = (mixart_stream_t*)runtime->private_data;
+       struct snd_pcm_runtime *runtime = subs->runtime;
+       struct mixart_stream   *stream  = runtime->private_data;
 
        return (snd_pcm_uframes_t)((stream->buf_periods * runtime->period_size) + stream->buf_period_frag);
 }
 
 
 
-static snd_pcm_ops_t snd_mixart_playback_ops = {
+static struct snd_pcm_ops snd_mixart_playback_ops = {
        .open      = snd_mixart_playback_open,
        .close     = snd_mixart_close,
        .ioctl     = snd_pcm_lib_ioctl,
@@ -890,7 +897,7 @@ static snd_pcm_ops_t snd_mixart_playback_ops = {
        .pointer   = snd_mixart_stream_pointer,
 };
 
-static snd_pcm_ops_t snd_mixart_capture_ops = {
+static struct snd_pcm_ops snd_mixart_capture_ops = {
        .open      = snd_mixart_capture_open,
        .close     = snd_mixart_close,
        .ioctl     = snd_pcm_lib_ioctl,
@@ -901,10 +908,10 @@ static snd_pcm_ops_t snd_mixart_capture_ops = {
        .pointer   = snd_mixart_stream_pointer,
 };
 
-static void preallocate_buffers(mixart_t *chip, snd_pcm_t *pcm)
+static void preallocate_buffers(struct snd_mixart *chip, struct snd_pcm *pcm)
 {
 #if 0
-       snd_pcm_substream_t *subs;
+       struct snd_pcm_substream *subs;
        int stream;
 
        for (stream = 0; stream < 2; stream++) {
@@ -922,10 +929,10 @@ static void preallocate_buffers(mixart_t *chip, snd_pcm_t *pcm)
 
 /*
  */
-static int snd_mixart_pcm_analog(mixart_t *chip)
+static int snd_mixart_pcm_analog(struct snd_mixart *chip)
 {
        int err;
-       snd_pcm_t *pcm;
+       struct snd_pcm *pcm;
        char name[32];
 
        sprintf(name, "miXart analog %d", chip->chip_idx);
@@ -953,10 +960,10 @@ static int snd_mixart_pcm_analog(mixart_t *chip)
 
 /*
  */
-static int snd_mixart_pcm_digital(mixart_t *chip)
+static int snd_mixart_pcm_digital(struct snd_mixart *chip)
 {
        int err;
-       snd_pcm_t *pcm;
+       struct snd_pcm *pcm;
        char name[32];
 
        sprintf(name, "miXart AES/EBU %d", chip->chip_idx);
@@ -981,30 +988,30 @@ static int snd_mixart_pcm_digital(mixart_t *chip)
        return 0;
 }
 
-static int snd_mixart_chip_free(mixart_t *chip)
+static int snd_mixart_chip_free(struct snd_mixart *chip)
 {
        kfree(chip);
        return 0;
 }
 
-static int snd_mixart_chip_dev_free(snd_device_t *device)
+static int snd_mixart_chip_dev_free(struct snd_device *device)
 {
-       mixart_t *chip = device->device_data;
+       struct snd_mixart *chip = device->device_data;
        return snd_mixart_chip_free(chip);
 }
 
 
 /*
  */
-static int __devinit snd_mixart_create(mixart_mgr_t *mgr, snd_card_t *card, int idx)
+static int __devinit snd_mixart_create(struct mixart_mgr *mgr, struct snd_card *card, int idx)
 {
        int err;
-       mixart_t *chip;
-       static snd_device_ops_t ops = {
+       struct snd_mixart *chip;
+       static struct snd_device_ops ops = {
                .dev_free = snd_mixart_chip_dev_free,
        };
 
-       mgr->chip[idx] = chip = kcalloc(1, sizeof(*chip), GFP_KERNEL);
+       chip = kzalloc(sizeof(*chip), GFP_KERNEL);
        if (! chip) {
                snd_printk(KERN_ERR "cannot allocate chip\n");
                return -ENOMEM;
@@ -1019,12 +1026,13 @@ static int __devinit snd_mixart_create(mixart_mgr_t *mgr, snd_card_t *card, int
                return err;
        }
 
+       mgr->chip[idx] = chip;
        snd_card_set_dev(card, &mgr->pci->dev);
 
        return 0;
 }
 
-int snd_mixart_create_pcm(mixart_t* chip)
+int snd_mixart_create_pcm(struct snd_mixart* chip)
 {
        int err;
 
@@ -1045,7 +1053,7 @@ int snd_mixart_create_pcm(mixart_t* chip)
 /*
  * release all the cards assigned to a manager instance
  */
-static int snd_mixart_free(mixart_mgr_t *mgr)
+static int snd_mixart_free(struct mixart_mgr *mgr)
 {
        unsigned int i;
 
@@ -1059,7 +1067,7 @@ static int snd_mixart_free(mixart_mgr_t *mgr)
 
        /* release irq  */
        if (mgr->irq >= 0)
-               free_irq(mgr->irq, (void *)mgr);
+               free_irq(mgr->irq, mgr);
 
        /* reset board if some firmware was loaded */
        if(mgr->dsp_loaded) {
@@ -1093,7 +1101,7 @@ static int snd_mixart_free(mixart_mgr_t *mgr)
 /*
  * proc interface
  */
-static long long snd_mixart_BA0_llseek(snd_info_entry_t *entry,
+static long long snd_mixart_BA0_llseek(struct snd_info_entry *entry,
                                       void *private_file_data,
                                       struct file *file,
                                       long long offset,
@@ -1102,13 +1110,13 @@ static long long snd_mixart_BA0_llseek(snd_info_entry_t *entry,
        offset = offset & ~3; /* 4 bytes aligned */
 
        switch(orig) {
-       case 0:  /* SEEK_SET */
+       case SEEK_SET:
                file->f_pos = offset;
                break;
-       case 1:  /* SEEK_CUR */
+       case SEEK_CUR:
                file->f_pos += offset;
                break;
-       case 2:  /* SEEK_END, offset is negative */
+       case SEEK_END: /* offset is negative */
                file->f_pos = MIXART_BA0_SIZE + offset;
                break;
        default:
@@ -1119,7 +1127,7 @@ static long long snd_mixart_BA0_llseek(snd_info_entry_t *entry,
        return file->f_pos;
 }
 
-static long long snd_mixart_BA1_llseek(snd_info_entry_t *entry,
+static long long snd_mixart_BA1_llseek(struct snd_info_entry *entry,
                                       void *private_file_data,
                                       struct file *file,
                                       long long offset,
@@ -1128,13 +1136,13 @@ static long long snd_mixart_BA1_llseek(snd_info_entry_t *entry,
        offset = offset & ~3; /* 4 bytes aligned */
 
        switch(orig) {
-       case 0:  /* SEEK_SET */
+       case SEEK_SET:
                file->f_pos = offset;
                break;
-       case 1:  /* SEEK_CUR */
+       case SEEK_CUR:
                file->f_pos += offset;
                break;
-       case 2: /* SEEK_END, offset is negative */
+       case SEEK_END: /* offset is negative */
                file->f_pos = MIXART_BA1_SIZE + offset;
                break;
        default:
@@ -1148,11 +1156,11 @@ static long long snd_mixart_BA1_llseek(snd_info_entry_t *entry,
 /*
   mixart_BA0 proc interface for BAR 0 - read callback
  */
-static long snd_mixart_BA0_read(snd_info_entry_t *entry, void *file_private_data,
+static long snd_mixart_BA0_read(struct snd_info_entry *entry, void *file_private_data,
                                struct file *file, char __user *buf,
                                unsigned long count, unsigned long pos)
 {
-       mixart_mgr_t *mgr = entry->private_data;
+       struct mixart_mgr *mgr = entry->private_data;
 
        count = count & ~3; /* make sure the read size is a multiple of 4 bytes */
        if(count <= 0)
@@ -1167,11 +1175,11 @@ static long snd_mixart_BA0_read(snd_info_entry_t *entry, void *file_private_data
 /*
   mixart_BA1 proc interface for BAR 1 - read callback
  */
-static long snd_mixart_BA1_read(snd_info_entry_t *entry, void *file_private_data,
+static long snd_mixart_BA1_read(struct snd_info_entry *entry, void *file_private_data,
                                struct file *file, char __user *buf,
                                unsigned long count, unsigned long pos)
 {
-       mixart_mgr_t *mgr = entry->private_data;
+       struct mixart_mgr *mgr = entry->private_data;
 
        count = count & ~3; /* make sure the read size is a multiple of 4 bytes */
        if(count <= 0)
@@ -1194,10 +1202,10 @@ static struct snd_info_entry_ops snd_mixart_proc_ops_BA1 = {
 };
 
 
-static void snd_mixart_proc_read(snd_info_entry_t *entry, 
-                                 snd_info_buffer_t * buffer)
+static void snd_mixart_proc_read(struct snd_info_entry *entry, 
+                                 struct snd_info_buffer *buffer)
 {
-       mixart_t *chip = entry->private_data;        
+       struct snd_mixart *chip = entry->private_data;        
        u32 ref; 
 
        snd_iprintf(buffer, "Digigram miXart (alsa card %d)\n\n", chip->chip_idx);
@@ -1230,14 +1238,13 @@ static void snd_mixart_proc_read(snd_info_entry_t *entry,
        } /* endif elf loaded */
 }
 
-static void __devinit snd_mixart_proc_init(mixart_t *chip)
+static void __devinit snd_mixart_proc_init(struct snd_mixart *chip)
 {
-       snd_info_entry_t *entry;
+       struct snd_info_entry *entry;
 
        /* text interface to read perf and temp meters */
        if (! snd_card_proc_new(chip->card, "board_info", &entry)) {
                entry->private_data = chip;
-               entry->c.text.read_size = 1024;
                entry->c.text.read = snd_mixart_proc_read;
        }
 
@@ -1264,7 +1271,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
                                      const struct pci_device_id *pci_id)
 {
        static int dev;
-       mixart_mgr_t *mgr;
+       struct mixart_mgr *mgr;
        unsigned int i;
        int err;
        size_t size;
@@ -1284,7 +1291,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
        pci_set_master(pci);
 
        /* check if we can restrict PCI DMA transfers to 32 bits */
-       if (pci_set_dma_mask(pci, 0xffffffff) < 0) {
+       if (pci_set_dma_mask(pci, DMA_BIT_MASK(32)) < 0) {
                snd_printk(KERN_ERR "architecture does not support 32bit PCI busmaster DMA\n");
                pci_disable_device(pci);
                return -ENXIO;
@@ -1292,7 +1299,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
 
        /*
         */
-       mgr = kcalloc(1, sizeof(*mgr), GFP_KERNEL);
+       mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
        if (! mgr) {
                pci_disable_device(pci);
                return -ENOMEM;
@@ -1309,11 +1316,17 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
        }
        for (i = 0; i < 2; i++) {
                mgr->mem[i].phys = pci_resource_start(pci, i);
-               mgr->mem[i].virt = ioremap_nocache(mgr->mem[i].phys,
-                                                  pci_resource_len(pci, i));
+               mgr->mem[i].virt = pci_ioremap_bar(pci, i);
+               if (!mgr->mem[i].virt) {
+                       printk(KERN_ERR "unable to remap resource 0x%lx\n",
+                              mgr->mem[i].phys);
+                       snd_mixart_free(mgr);
+                       return -EBUSY;
+               }
        }
 
-       if (request_irq(pci->irq, snd_mixart_interrupt, SA_INTERRUPT|SA_SHIRQ, CARD_NAME, (void *)mgr)) {
+       if (request_irq(pci->irq, snd_mixart_interrupt, IRQF_SHARED,
+                       CARD_NAME, mgr)) {
                snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq);
                snd_mixart_free(mgr);
                return -EBUSY;
@@ -1331,20 +1344,20 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
        mgr->msg_fifo_writeptr = 0;
 
        spin_lock_init(&mgr->msg_lock);
-       init_MUTEX(&mgr->msg_mutex);
+       mutex_init(&mgr->msg_mutex);
        init_waitqueue_head(&mgr->msg_sleep);
        atomic_set(&mgr->msg_processed, 0);
 
        /* init setup mutex*/
-       init_MUTEX(&mgr->setup_mutex);
+       mutex_init(&mgr->setup_mutex);
 
        /* init message taslket */
-       tasklet_init( &mgr->msg_taskq, snd_mixart_msg_tasklet, (unsigned long) mgr);
+       tasklet_init(&mgr->msg_taskq, snd_mixart_msg_tasklet, (unsigned long) mgr);
 
        /* card assignment */
        mgr->num_cards = MIXART_MAX_CARDS; /* 4  FIXME: configurable? */
        for (i = 0; i < mgr->num_cards; i++) {
-               snd_card_t *card;
+               struct snd_card *card;
                char tmpid[16];
                int idx;
 
@@ -1353,12 +1366,12 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
                else
                        idx = index[dev] + i;
                snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i);
-               card = snd_card_new(idx, tmpid, THIS_MODULE, 0);
+               err = snd_card_create(idx, tmpid, THIS_MODULE, 0, &card);
 
-               if (! card) {
+               if (err < 0) {
                        snd_printk(KERN_ERR "cannot allocate the card %d\n", i);
                        snd_mixart_free(mgr);
-                       return -ENOMEM;
+                       return err;
                }
 
                strcpy(card->driver, CARD_NAME);
@@ -1366,6 +1379,7 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
                sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i);
 
                if ((err = snd_mixart_create(mgr, card, i)) < 0) {
+                       snd_card_free(card);
                        snd_mixart_free(mgr);
                        return err;
                }
@@ -1385,7 +1399,8 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
        mgr->board_type = MIXART_DAUGHTER_TYPE_NONE;
 
        /* create array of streaminfo */
-       size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * sizeof(mixart_flowinfo_t)) );
+       size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS *
+                           sizeof(struct mixart_flowinfo)) );
        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
                                size, &mgr->flowinfo) < 0) {
                snd_mixart_free(mgr);
@@ -1395,7 +1410,8 @@ static int __devinit snd_mixart_probe(struct pci_dev *pci,
        memset(mgr->flowinfo.area, 0, size);
 
        /* create array of bufferinfo */
-       size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS * sizeof(mixart_bufferinfo_t)) );
+       size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS *
+                           sizeof(struct mixart_bufferinfo)) );
        if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci),
                                size, &mgr->bufferinfo) < 0) {
                snd_mixart_free(mgr);