static inline unsigned long vx2_reg_addr(struct vx_core *_chip, int reg)
 {
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
        return chip->port[vx2_reg_index[reg]] + vx2_reg_offset[reg];
 }
 
 
 static void vx2_reset_dsp(struct vx_core *_chip)
 {
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
 
        /* set the reset dsp bit to 0 */
        vx_outl(chip, CDSP, chip->regCDSP & ~VX_CDSP_DSP_RESET_MASK);
 
 static int vx2_test_xilinx(struct vx_core *_chip)
 {
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
        unsigned int data;
 
        dev_dbg(_chip->card->dev, "testing xilinx...\n");
  */
 static void vx2_validate_irq(struct vx_core *_chip, int enable)
 {
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
 
        /* Set the interrupt enable bit to 1 in CDSP register */
        if (enable) {
  */
 static void vx2_reset_codec(struct vx_core *_chip)
 {
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
 
        /* Set the reset CODEC bit to 0. */
        vx_outl(chip, CDSP, chip->regCDSP &~ VX_CDSP_CODEC_RESET_MASK);
  */
 static void vx2_change_audio_source(struct vx_core *_chip, int src)
 {
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
 
        switch (src) {
        case VX_AUDIO_SRC_DIGITAL:
  */
 static void vx2_set_clock_source(struct vx_core *_chip, int source)
 {
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
 
        if (source == INTERNAL_QUARTZ)
                chip->regCFG &= ~VX_CFG_CLOCKIN_SEL_MASK;
  */
 static void vx2_reset_board(struct vx_core *_chip, int cold_reset)
 {
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
 
        /* initialize the register values */
        chip->regCDSP = VX_CDSP_CODEC_RESET_MASK | VX_CDSP_DSP_RESET_MASK ;
 static int vx_input_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
        mutex_lock(&_chip->mixer_mutex);
        ucontrol->value.integer.value[0] = chip->input_level[0];
        ucontrol->value.integer.value[1] = chip->input_level[1];
 static int vx_input_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
        if (ucontrol->value.integer.value[0] < 0 ||
            ucontrol->value.integer.value[0] > MIC_LEVEL_MAX)
                return -EINVAL;
 static int vx_mic_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
        ucontrol->value.integer.value[0] = chip->mic_level;
        return 0;
 }
 static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
 {
        struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
        if (ucontrol->value.integer.value[0] < 0 ||
            ucontrol->value.integer.value[0] > MIC_LEVEL_MAX)
                return -EINVAL;
 
 static int vx2_add_mic_controls(struct vx_core *_chip)
 {
-       struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
+       struct snd_vx222 *chip = to_vx222(_chip);
        int err;
 
        if (_chip->type != VX_TYPE_MIC)