X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fpci%2Fymfpci%2Fymfpci_main.c;h=1603169511451b8dae3a78ed06829ec02ec0a86b;hb=c7b5ebbddf7bcd3651947760f423e3783bbe6573;hp=9d0aa2624151846fe0962cf0b20e1df6d0673333;hpb=a2c21200f1c81b08cb55e417b68150bba439b646;p=linux-2.6.git diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 9d0aa2624..160316951 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c @@ -42,8 +42,6 @@ #include -#define chip_t ymfpci_t - /* * constants */ @@ -102,7 +100,7 @@ static int snd_ymfpci_codec_ready(ymfpci_t *chip, int secondary) static void snd_ymfpci_codec_write(ac97_t *ac97, u16 reg, u16 val) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, ac97->private_data, return); + ymfpci_t *chip = ac97->private_data; u32 cmd; snd_ymfpci_codec_ready(chip, 0); @@ -112,7 +110,7 @@ static void snd_ymfpci_codec_write(ac97_t *ac97, u16 reg, u16 val) static u16 snd_ymfpci_codec_read(ac97_t *ac97, u16 reg) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, ac97->private_data, return -ENXIO); + ymfpci_t *chip = ac97->private_data; if (snd_ymfpci_codec_ready(chip, 0)) return ~0; @@ -330,7 +328,7 @@ static void snd_ymfpci_pcm_interrupt(ymfpci_t *chip, ymfpci_voice_t *voice) static void snd_ymfpci_pcm_capture_interrupt(snd_pcm_substream_t *substream) { snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return); + ymfpci_pcm_t *ypcm = runtime->private_data; ymfpci_t *chip = ypcm->chip; u32 pos, delta; @@ -358,7 +356,7 @@ static int snd_ymfpci_playback_trigger(snd_pcm_substream_t * substream, int cmd) { ymfpci_t *chip = snd_pcm_substream_chip(substream); - ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, substream->runtime->private_data, return -ENXIO); + ymfpci_pcm_t *ypcm = substream->runtime->private_data; int result = 0; spin_lock(&chip->reg_lock); @@ -395,7 +393,7 @@ static int snd_ymfpci_capture_trigger(snd_pcm_substream_t * substream, int cmd) { ymfpci_t *chip = snd_pcm_substream_chip(substream); - ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, substream->runtime->private_data, return -ENXIO); + ymfpci_pcm_t *ypcm = substream->runtime->private_data; int result = 0; u32 tmp; @@ -541,7 +539,8 @@ static void snd_ymfpci_pcm_init_voice(ymfpci_voice_t *voice, int stereo, static int __devinit snd_ymfpci_ac3_init(ymfpci_t *chip) { - if (snd_dma_alloc_pages(&chip->dma_dev, 4096, &chip->ac3_tmp_base) < 0) + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), + 4096, &chip->ac3_tmp_base) < 0) return -ENOMEM; chip->bank_effect[3][0]->base = @@ -568,7 +567,7 @@ static int snd_ymfpci_ac3_done(ymfpci_t *chip) spin_unlock_irq(&chip->reg_lock); // snd_ymfpci_irq_wait(chip); if (chip->ac3_tmp_base.area) { - snd_dma_free_pages(&chip->dma_dev, &chip->ac3_tmp_base); + snd_dma_free_pages(&chip->ac3_tmp_base); chip->ac3_tmp_base.area = NULL; } return 0; @@ -578,7 +577,7 @@ static int snd_ymfpci_playback_hw_params(snd_pcm_substream_t * substream, snd_pcm_hw_params_t * hw_params) { snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return -ENXIO); + ymfpci_pcm_t *ypcm = runtime->private_data; int err; if ((err = snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params))) < 0) @@ -596,7 +595,7 @@ static int snd_ymfpci_playback_hw_free(snd_pcm_substream_t * substream) if (runtime->private_data == NULL) return 0; - ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return -ENXIO); + ypcm = runtime->private_data; /* wait, until the PCI operations are not finished */ snd_ymfpci_irq_wait(chip); @@ -616,7 +615,7 @@ static int snd_ymfpci_playback_prepare(snd_pcm_substream_t * substream) { // ymfpci_t *chip = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return -ENXIO); + ymfpci_pcm_t *ypcm = runtime->private_data; unsigned int nvoice; ypcm->period_size = runtime->period_size; @@ -654,7 +653,7 @@ static int snd_ymfpci_capture_prepare(snd_pcm_substream_t * substream) { ymfpci_t *chip = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return -ENXIO); + ymfpci_pcm_t *ypcm = runtime->private_data; snd_ymfpci_capture_bank_t * bank; int nbank; u32 rate, format; @@ -698,7 +697,7 @@ static snd_pcm_uframes_t snd_ymfpci_playback_pointer(snd_pcm_substream_t * subst { ymfpci_t *chip = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return -ENXIO); + ymfpci_pcm_t *ypcm = runtime->private_data; ymfpci_voice_t *voice = ypcm->voices[0]; if (!(ypcm->running && voice)) @@ -710,7 +709,7 @@ static snd_pcm_uframes_t snd_ymfpci_capture_pointer(snd_pcm_substream_t * substr { ymfpci_t *chip = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return -ENXIO); + ymfpci_pcm_t *ypcm = runtime->private_data; if (!ypcm->running) return 0; @@ -736,7 +735,7 @@ static void snd_ymfpci_irq_wait(ymfpci_t *chip) static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, dev_id, return IRQ_NONE); + ymfpci_t *chip = dev_id; u32 status, nvoice, mode; ymfpci_voice_t *voice; @@ -830,10 +829,10 @@ static snd_pcm_hardware_t snd_ymfpci_capture = static void snd_ymfpci_pcm_free_substream(snd_pcm_runtime_t *runtime) { - ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return); + ymfpci_pcm_t *ypcm = runtime->private_data; if (ypcm) - snd_magic_kfree(ypcm); + kfree(ypcm); } static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream) @@ -842,7 +841,7 @@ static int snd_ymfpci_playback_open_1(snd_pcm_substream_t * substream) snd_pcm_runtime_t *runtime = substream->runtime; ymfpci_pcm_t *ypcm; - ypcm = snd_magic_kcalloc(ymfpci_pcm_t, 0, GFP_KERNEL); + ypcm = kcalloc(1, sizeof(*ypcm), GFP_KERNEL); if (ypcm == NULL) return -ENOMEM; ypcm->chip = chip; @@ -886,20 +885,19 @@ static int snd_ymfpci_playback_open(snd_pcm_substream_t * substream) ymfpci_t *chip = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; ymfpci_pcm_t *ypcm; - unsigned long flags; int err; if ((err = snd_ymfpci_playback_open_1(substream)) < 0) return err; - ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return 0); + ypcm = runtime->private_data; ypcm->output_front = 1; ypcm->output_rear = chip->mode_dup4ch ? 1 : 0; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); if (ypcm->output_rear) { ymfpci_open_extension(chip); chip->rear_opened++; } - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return 0; } @@ -908,22 +906,21 @@ static int snd_ymfpci_playback_spdif_open(snd_pcm_substream_t * substream) ymfpci_t *chip = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; ymfpci_pcm_t *ypcm; - unsigned long flags; int err; if ((err = snd_ymfpci_playback_open_1(substream)) < 0) return err; - ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return 0); + ypcm = runtime->private_data; ypcm->output_front = 0; ypcm->output_rear = 1; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTCTRL, snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) | 2); ymfpci_open_extension(chip); chip->spdif_pcm_bits = chip->spdif_bits; snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_pcm_bits); chip->spdif_opened++; - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); chip->spdif_pcm_ctl->vd[0].access &= ~SNDRV_CTL_ELEM_ACCESS_INACTIVE; snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | @@ -936,18 +933,17 @@ static int snd_ymfpci_playback_4ch_open(snd_pcm_substream_t * substream) ymfpci_t *chip = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; ymfpci_pcm_t *ypcm; - unsigned long flags; int err; if ((err = snd_ymfpci_playback_open_1(substream)) < 0) return err; - ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return 0); + ypcm = runtime->private_data; ypcm->output_front = 0; ypcm->output_rear = 1; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); ymfpci_open_extension(chip); chip->rear_opened++; - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return 0; } @@ -958,7 +954,7 @@ static int snd_ymfpci_capture_open(snd_pcm_substream_t * substream, snd_pcm_runtime_t *runtime = substream->runtime; ymfpci_pcm_t *ypcm; - ypcm = snd_magic_kcalloc(ymfpci_pcm_t, 0, GFP_KERNEL); + ypcm = kcalloc(1, sizeof(*ypcm), GFP_KERNEL); if (ypcm == NULL) return -ENOMEM; ypcm->chip = chip; @@ -993,30 +989,28 @@ static int snd_ymfpci_playback_close_1(snd_pcm_substream_t * substream) static int snd_ymfpci_playback_close(snd_pcm_substream_t * substream) { ymfpci_t *chip = snd_pcm_substream_chip(substream); - ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, substream->runtime->private_data, return -ENXIO); - unsigned long flags; + ymfpci_pcm_t *ypcm = substream->runtime->private_data; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); if (ypcm->output_rear && chip->rear_opened > 0) { chip->rear_opened--; ymfpci_close_extension(chip); } - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return snd_ymfpci_playback_close_1(substream); } static int snd_ymfpci_playback_spdif_close(snd_pcm_substream_t * substream) { ymfpci_t *chip = snd_pcm_substream_chip(substream); - unsigned long flags; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); chip->spdif_opened = 0; ymfpci_close_extension(chip); snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTCTRL, snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) & ~2); snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_bits); - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); chip->spdif_pcm_ctl->vd[0].access |= SNDRV_CTL_ELEM_ACCESS_INACTIVE; snd_ctl_notify(chip->card, SNDRV_CTL_EVENT_MASK_VALUE | SNDRV_CTL_EVENT_MASK_INFO, &chip->spdif_pcm_ctl->id); @@ -1026,14 +1020,13 @@ static int snd_ymfpci_playback_spdif_close(snd_pcm_substream_t * substream) static int snd_ymfpci_playback_4ch_close(snd_pcm_substream_t * substream) { ymfpci_t *chip = snd_pcm_substream_chip(substream); - unsigned long flags; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); if (chip->rear_opened > 0) { chip->rear_opened--; ymfpci_close_extension(chip); } - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return snd_ymfpci_playback_close_1(substream); } @@ -1041,7 +1034,7 @@ static int snd_ymfpci_capture_close(snd_pcm_substream_t * substream) { ymfpci_t *chip = snd_pcm_substream_chip(substream); snd_pcm_runtime_t *runtime = substream->runtime; - ymfpci_pcm_t *ypcm = snd_magic_cast(ymfpci_pcm_t, runtime->private_data, return -ENXIO); + ymfpci_pcm_t *ypcm = runtime->private_data; if (ypcm != NULL) { chip->capture_substream[ypcm->capture_bank_number] = NULL; @@ -1074,7 +1067,7 @@ static snd_pcm_ops_t snd_ymfpci_capture_rec_ops = { static void snd_ymfpci_pcm_free(snd_pcm_t *pcm) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, pcm->private_data, return); + ymfpci_t *chip = pcm->private_data; chip->pcm = NULL; snd_pcm_lib_preallocate_free_for_all(pcm); } @@ -1120,7 +1113,7 @@ static snd_pcm_ops_t snd_ymfpci_capture_ac97_ops = { static void snd_ymfpci_pcm2_free(snd_pcm_t *pcm) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, pcm->private_data, return); + ymfpci_t *chip = pcm->private_data; chip->pcm2 = NULL; snd_pcm_lib_preallocate_free_for_all(pcm); } @@ -1166,7 +1159,7 @@ static snd_pcm_ops_t snd_ymfpci_playback_spdif_ops = { static void snd_ymfpci_pcm_spdif_free(snd_pcm_t *pcm) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, pcm->private_data, return); + ymfpci_t *chip = pcm->private_data; chip->pcm_spdif = NULL; snd_pcm_lib_preallocate_free_for_all(pcm); } @@ -1211,7 +1204,7 @@ static snd_pcm_ops_t snd_ymfpci_playback_4ch_ops = { static void snd_ymfpci_pcm_4ch_free(snd_pcm_t *pcm) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, pcm->private_data, return); + ymfpci_t *chip = pcm->private_data; chip->pcm_4ch = NULL; snd_pcm_lib_preallocate_free_for_all(pcm); } @@ -1254,12 +1247,11 @@ static int snd_ymfpci_spdif_default_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - unsigned long flags; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); ucontrol->value.iec958.status[0] = (chip->spdif_bits >> 0) & 0xff; ucontrol->value.iec958.status[1] = (chip->spdif_bits >> 8) & 0xff; - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return 0; } @@ -1267,18 +1259,17 @@ static int snd_ymfpci_spdif_default_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - unsigned long flags; unsigned int val; int change; val = ((ucontrol->value.iec958.status[0] & 0x3e) << 0) | (ucontrol->value.iec958.status[1] << 8); - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); change = chip->spdif_bits != val; chip->spdif_bits = val; if ((snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) & 1) && chip->pcm_spdif == NULL) snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_bits); - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return change; } @@ -1302,12 +1293,11 @@ static int snd_ymfpci_spdif_mask_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - unsigned long flags; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); ucontrol->value.iec958.status[0] = 0x3e; ucontrol->value.iec958.status[1] = 0xff; - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return 0; } @@ -1331,12 +1321,11 @@ static int snd_ymfpci_spdif_stream_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - unsigned long flags; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); ucontrol->value.iec958.status[0] = (chip->spdif_pcm_bits >> 0) & 0xff; ucontrol->value.iec958.status[1] = (chip->spdif_pcm_bits >> 8) & 0xff; - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return 0; } @@ -1344,18 +1333,17 @@ static int snd_ymfpci_spdif_stream_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - unsigned long flags; unsigned int val; int change; val = ((ucontrol->value.iec958.status[0] & 0x3e) << 0) | (ucontrol->value.iec958.status[1] << 8); - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); change = chip->spdif_pcm_bits != val; chip->spdif_pcm_bits = val; if ((snd_ymfpci_readw(chip, YDSXGR_SPDIFOUTCTRL) & 2)) snd_ymfpci_writew(chip, YDSXGR_SPDIFOUTSTATUS, chip->spdif_pcm_bits); - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return change; } @@ -1385,12 +1373,11 @@ static int snd_ymfpci_drec_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_in static int snd_ymfpci_drec_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) { ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - unsigned long flags; u16 reg; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); reg = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); if (!(reg & 0x100)) value->value.enumerated.item[0] = 0; else @@ -1401,17 +1388,16 @@ static int snd_ymfpci_drec_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_val static int snd_ymfpci_drec_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) { ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - unsigned long flags; u16 reg, old_reg; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); old_reg = snd_ymfpci_readw(chip, YDSXGR_GLOBALCTRL); if (value->value.enumerated.item[0] == 0) reg = old_reg & ~0x100; else reg = (old_reg & ~0x300) | 0x100 | ((value->value.enumerated.item[0] == 2) << 9); snd_ymfpci_writew(chip, YDSXGR_GLOBALCTRL, reg); - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return reg != old_reg; } @@ -1470,7 +1456,6 @@ static int snd_ymfpci_get_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t static int snd_ymfpci_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - unsigned long flags; int reg = kcontrol->private_value; unsigned int shift = 0, mask = 1, invert = 0; int change; @@ -1485,12 +1470,12 @@ static int snd_ymfpci_put_single(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t if (invert) val = mask - val; val <<= shift; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); oval = snd_ymfpci_readl(chip, reg); val = (oval & ~(mask << shift)) | val; change = val != oval; snd_ymfpci_writel(chip, reg, val); - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return change; } @@ -1517,16 +1502,15 @@ static int snd_ymfpci_info_double(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t static int snd_ymfpci_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - unsigned long flags; unsigned int reg = kcontrol->private_value; unsigned int shift_left = 0, shift_right = 16, mask = 16383, invert = 0; unsigned int val; if (reg < 0x80 || reg >= 0xc0) return -EINVAL; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); val = snd_ymfpci_readl(chip, reg); - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); ucontrol->value.integer.value[0] = (val >> shift_left) & mask; ucontrol->value.integer.value[1] = (val >> shift_right) & mask; if (invert) { @@ -1539,7 +1523,6 @@ static int snd_ymfpci_get_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t static int snd_ymfpci_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) { ymfpci_t *chip = snd_kcontrol_chip(kcontrol); - unsigned long flags; unsigned int reg = kcontrol->private_value; unsigned int shift_left = 0, shift_right = 16, mask = 16383, invert = 0; int change; @@ -1555,12 +1538,12 @@ static int snd_ymfpci_put_double(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t } val1 <<= shift_left; val2 <<= shift_right; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); oval = snd_ymfpci_readl(chip, reg); val1 = (oval & ~((mask << shift_left) | (mask << shift_right))) | val1 | val2; change = val1 != oval; snd_ymfpci_writel(chip, reg, val1); - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); return change; } @@ -1594,8 +1577,6 @@ static int snd_ymfpci_put_dup4ch(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t } -#define YMFPCI_CONTROLS (sizeof(snd_ymfpci_controls)/sizeof(snd_kcontrol_new_t)) - static snd_kcontrol_new_t snd_ymfpci_controls[] __devinitdata = { YMFPCI_DOUBLE("Wave Playback Volume", 0, YDSXGR_NATIVEDACOUTVOL), YMFPCI_DOUBLE("Wave Capture Volume", 0, YDSXGR_NATIVEDACLOOPVOL), @@ -1709,31 +1690,30 @@ static snd_kcontrol_new_t snd_ymfpci_rear_shared __devinitdata = { static void snd_ymfpci_mixer_free_ac97_bus(ac97_bus_t *bus) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, bus->private_data, return); + ymfpci_t *chip = bus->private_data; chip->ac97_bus = NULL; } static void snd_ymfpci_mixer_free_ac97(ac97_t *ac97) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, ac97->private_data, return); + ymfpci_t *chip = ac97->private_data; chip->ac97 = NULL; } int __devinit snd_ymfpci_mixer(ymfpci_t *chip, int rear_switch) { - ac97_bus_t bus; - ac97_t ac97; + ac97_template_t ac97; snd_kcontrol_t *kctl; unsigned int idx; int err; + static ac97_bus_ops_t ops = { + .write = snd_ymfpci_codec_write, + .read = snd_ymfpci_codec_read, + }; - memset(&bus, 0, sizeof(bus)); - bus.write = snd_ymfpci_codec_write; - bus.read = snd_ymfpci_codec_read; - bus.private_data = chip; - bus.private_free = snd_ymfpci_mixer_free_ac97_bus; - if ((err = snd_ac97_bus(chip->card, &bus, &chip->ac97_bus)) < 0) + if ((err = snd_ac97_bus(chip->card, 0, &ops, chip, &chip->ac97_bus)) < 0) return err; + chip->ac97_bus->private_free = snd_ymfpci_mixer_free_ac97_bus; memset(&ac97, 0, sizeof(ac97)); ac97.private_data = chip; @@ -1741,7 +1721,7 @@ int __devinit snd_ymfpci_mixer(ymfpci_t *chip, int rear_switch) if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0) return err; - for (idx = 0; idx < YMFPCI_CONTROLS; idx++) { + for (idx = 0; idx < ARRAY_SIZE(snd_ymfpci_controls); idx++) { if ((err = snd_ctl_add(chip->card, snd_ctl_new1(&snd_ymfpci_controls[idx], chip))) < 0) return err; } @@ -1854,7 +1834,7 @@ int __devinit snd_ymfpci_timer(ymfpci_t *chip, int device) static void snd_ymfpci_proc_read(snd_info_entry_t *entry, snd_info_buffer_t * buffer) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, entry->private_data, return); + ymfpci_t *chip = entry->private_data; int i; snd_iprintf(buffer, "YMFPCI\n\n"); @@ -1975,7 +1955,8 @@ static int __devinit snd_ymfpci_memalloc(ymfpci_t *chip) chip->work_size; /* work_ptr must be aligned to 256 bytes, but it's already covered with the kernel page allocation mechanism */ - if (snd_dma_alloc_pages(&chip->dma_dev, size, &chip->work_ptr) < 0) + if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), + size, &chip->work_ptr) < 0) return -ENOMEM; ptr = chip->work_ptr.area; ptr_addr = chip->work_ptr.addr; @@ -2106,7 +2087,7 @@ static int snd_ymfpci_free(ymfpci_t *chip) if (chip->reg_area_virt) iounmap((void *)chip->reg_area_virt); if (chip->work_ptr.area) - snd_dma_free_pages(&chip->dma_dev, &chip->work_ptr); + snd_dma_free_pages(&chip->work_ptr); if (chip->irq >= 0) free_irq(chip->irq, (void *)chip); @@ -2117,13 +2098,13 @@ static int snd_ymfpci_free(ymfpci_t *chip) pci_write_config_word(chip->pci, 0x40, chip->old_legacy_ctrl); - snd_magic_kfree(chip); + kfree(chip); return 0; } static int snd_ymfpci_dev_free(snd_device_t *device) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, device->device_data, return -ENXIO); + ymfpci_t *chip = device->device_data; return snd_ymfpci_free(chip); } @@ -2159,7 +2140,7 @@ static int saved_regs_index[] = { static int snd_ymfpci_suspend(snd_card_t *card, unsigned int state) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, card->pm_private_data, return -EINVAL); + ymfpci_t *chip = card->pm_private_data; unsigned int i; snd_pcm_suspend_all(chip->pcm); @@ -2178,7 +2159,7 @@ static int snd_ymfpci_suspend(snd_card_t *card, unsigned int state) static int snd_ymfpci_resume(snd_card_t *card, unsigned int state) { - ymfpci_t *chip = snd_magic_cast(ymfpci_t, card->pm_private_data, return -EINVAL); + ymfpci_t *chip = card->pm_private_data; unsigned int i; pci_enable_device(chip->pci); @@ -2195,11 +2176,10 @@ static int snd_ymfpci_resume(snd_card_t *card, unsigned int state) /* start hw again */ if (chip->start_count > 0) { - unsigned long flags; - spin_lock_irqsave(&chip->reg_lock, flags); + spin_lock_irq(&chip->reg_lock); snd_ymfpci_writel(chip, YDSXGR_MODE, chip->saved_ydsxgr_mode); chip->active_bank = snd_ymfpci_readl(chip, YDSXGR_CTRLSELECT); - spin_unlock_irqrestore(&chip->reg_lock, flags); + spin_unlock_irq(&chip->reg_lock); } snd_power_change_state(card, SNDRV_CTL_POWER_D0); return 0; @@ -2223,7 +2203,7 @@ int __devinit snd_ymfpci_create(snd_card_t * card, if ((err = pci_enable_device(pci)) < 0) return err; - chip = snd_magic_kcalloc(ymfpci_t, 0, GFP_KERNEL); + chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); if (chip == NULL) return -ENOMEM; chip->old_legacy_ctrl = old_legacy_ctrl; @@ -2252,10 +2232,6 @@ int __devinit snd_ymfpci_create(snd_card_t * card, } chip->irq = pci->irq; - memset(&chip->dma_dev, 0, sizeof(chip->dma_dev)); - chip->dma_dev.type = SNDRV_DMA_TYPE_DEV; - chip->dma_dev.dev = snd_dma_pci_data(pci); - snd_ymfpci_aclink_reset(pci); if (snd_ymfpci_codec_ready(chip, 0) < 0) { snd_ymfpci_free(chip);