diff options
author | Takashi Iwai <tiwai@suse.de> | 2017-05-12 04:03:35 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-05-17 01:12:57 -0400 |
commit | 2e0de6ea956ff429cf11bd1a92d7444bc6000698 (patch) | |
tree | 7cd743dd2f71643a3d09ca565912d11f684246e9 | |
parent | 5f976f58917eafbd8f725b9b7c0efcf6937e0e83 (diff) |
ALSA: vxpocket: Use container_of()
The vxpocket driver is using the explicit cast from the parent class
pointer, but it'll be broken when the structure field randomization is
applied. Use container_of() in a modern manner, instead.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/pcmcia/vx/vxp_mixer.c | 10 | ||||
-rw-r--r-- | sound/pcmcia/vx/vxp_ops.c | 28 | ||||
-rw-r--r-- | sound/pcmcia/vx/vxpocket.c | 4 | ||||
-rw-r--r-- | sound/pcmcia/vx/vxpocket.h | 2 |
4 files changed, 23 insertions, 21 deletions
diff --git a/sound/pcmcia/vx/vxp_mixer.c b/sound/pcmcia/vx/vxp_mixer.c index a4a664259f0d..1ca3eef9e305 100644 --- a/sound/pcmcia/vx/vxp_mixer.c +++ b/sound/pcmcia/vx/vxp_mixer.c | |||
@@ -43,7 +43,7 @@ static int vx_mic_level_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_ | |||
43 | static int vx_mic_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 43 | static int vx_mic_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
44 | { | 44 | { |
45 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); | 45 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); |
46 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 46 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
47 | ucontrol->value.integer.value[0] = chip->mic_level; | 47 | ucontrol->value.integer.value[0] = chip->mic_level; |
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |
@@ -51,7 +51,7 @@ static int vx_mic_level_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v | |||
51 | static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 51 | static int vx_mic_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
52 | { | 52 | { |
53 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); | 53 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); |
54 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 54 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
55 | unsigned int val = ucontrol->value.integer.value[0]; | 55 | unsigned int val = ucontrol->value.integer.value[0]; |
56 | 56 | ||
57 | if (val > MIC_LEVEL_MAX) | 57 | if (val > MIC_LEVEL_MAX) |
@@ -88,7 +88,7 @@ static struct snd_kcontrol_new vx_control_mic_level = { | |||
88 | static int vx_mic_boost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 88 | static int vx_mic_boost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
89 | { | 89 | { |
90 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); | 90 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); |
91 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 91 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
92 | ucontrol->value.integer.value[0] = chip->mic_level; | 92 | ucontrol->value.integer.value[0] = chip->mic_level; |
93 | return 0; | 93 | return 0; |
94 | } | 94 | } |
@@ -96,7 +96,7 @@ static int vx_mic_boost_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_v | |||
96 | static int vx_mic_boost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) | 96 | static int vx_mic_boost_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) |
97 | { | 97 | { |
98 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); | 98 | struct vx_core *_chip = snd_kcontrol_chip(kcontrol); |
99 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 99 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
100 | int val = !!ucontrol->value.integer.value[0]; | 100 | int val = !!ucontrol->value.integer.value[0]; |
101 | mutex_lock(&_chip->mixer_mutex); | 101 | mutex_lock(&_chip->mixer_mutex); |
102 | if (chip->mic_level != val) { | 102 | if (chip->mic_level != val) { |
@@ -120,7 +120,7 @@ static struct snd_kcontrol_new vx_control_mic_boost = { | |||
120 | 120 | ||
121 | int vxp_add_mic_controls(struct vx_core *_chip) | 121 | int vxp_add_mic_controls(struct vx_core *_chip) |
122 | { | 122 | { |
123 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 123 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
124 | int err; | 124 | int err; |
125 | 125 | ||
126 | /* mute input levels */ | 126 | /* mute input levels */ |
diff --git a/sound/pcmcia/vx/vxp_ops.c b/sound/pcmcia/vx/vxp_ops.c index 5f97791f00d7..8cde40226355 100644 --- a/sound/pcmcia/vx/vxp_ops.c +++ b/sound/pcmcia/vx/vxp_ops.c | |||
@@ -50,7 +50,7 @@ static int vxp_reg_offset[VX_REG_MAX] = { | |||
50 | 50 | ||
51 | static inline unsigned long vxp_reg_addr(struct vx_core *_chip, int reg) | 51 | static inline unsigned long vxp_reg_addr(struct vx_core *_chip, int reg) |
52 | { | 52 | { |
53 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 53 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
54 | return chip->port + vxp_reg_offset[reg]; | 54 | return chip->port + vxp_reg_offset[reg]; |
55 | } | 55 | } |
56 | 56 | ||
@@ -110,7 +110,7 @@ static int vx_check_magic(struct vx_core *chip) | |||
110 | 110 | ||
111 | static void vxp_reset_dsp(struct vx_core *_chip) | 111 | static void vxp_reset_dsp(struct vx_core *_chip) |
112 | { | 112 | { |
113 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 113 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
114 | 114 | ||
115 | /* set the reset dsp bit to 1 */ | 115 | /* set the reset dsp bit to 1 */ |
116 | vx_outb(chip, CDSP, chip->regCDSP | VXP_CDSP_DSP_RESET_MASK); | 116 | vx_outb(chip, CDSP, chip->regCDSP | VXP_CDSP_DSP_RESET_MASK); |
@@ -128,7 +128,7 @@ static void vxp_reset_dsp(struct vx_core *_chip) | |||
128 | */ | 128 | */ |
129 | static void vxp_reset_codec(struct vx_core *_chip) | 129 | static void vxp_reset_codec(struct vx_core *_chip) |
130 | { | 130 | { |
131 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 131 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
132 | 132 | ||
133 | /* Set the reset CODEC bit to 1. */ | 133 | /* Set the reset CODEC bit to 1. */ |
134 | vx_outb(chip, CDSP, chip->regCDSP | VXP_CDSP_CODEC_RESET_MASK); | 134 | vx_outb(chip, CDSP, chip->regCDSP | VXP_CDSP_CODEC_RESET_MASK); |
@@ -147,7 +147,7 @@ static void vxp_reset_codec(struct vx_core *_chip) | |||
147 | */ | 147 | */ |
148 | static int vxp_load_xilinx_binary(struct vx_core *_chip, const struct firmware *fw) | 148 | static int vxp_load_xilinx_binary(struct vx_core *_chip, const struct firmware *fw) |
149 | { | 149 | { |
150 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 150 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
151 | unsigned int i; | 151 | unsigned int i; |
152 | int c; | 152 | int c; |
153 | int regCSUER, regRUER; | 153 | int regCSUER, regRUER; |
@@ -280,7 +280,7 @@ static int vxp_load_dsp(struct vx_core *vx, int index, const struct firmware *fw | |||
280 | */ | 280 | */ |
281 | static int vxp_test_and_ack(struct vx_core *_chip) | 281 | static int vxp_test_and_ack(struct vx_core *_chip) |
282 | { | 282 | { |
283 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 283 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
284 | 284 | ||
285 | /* not booted yet? */ | 285 | /* not booted yet? */ |
286 | if (! (_chip->chip_status & VX_STAT_XILINX_LOADED)) | 286 | if (! (_chip->chip_status & VX_STAT_XILINX_LOADED)) |
@@ -307,7 +307,7 @@ static int vxp_test_and_ack(struct vx_core *_chip) | |||
307 | */ | 307 | */ |
308 | static void vxp_validate_irq(struct vx_core *_chip, int enable) | 308 | static void vxp_validate_irq(struct vx_core *_chip, int enable) |
309 | { | 309 | { |
310 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 310 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
311 | 311 | ||
312 | /* Set the interrupt enable bit to 1 in CDSP register */ | 312 | /* Set the interrupt enable bit to 1 in CDSP register */ |
313 | if (enable) | 313 | if (enable) |
@@ -323,7 +323,7 @@ static void vxp_validate_irq(struct vx_core *_chip, int enable) | |||
323 | */ | 323 | */ |
324 | static void vx_setup_pseudo_dma(struct vx_core *_chip, int do_write) | 324 | static void vx_setup_pseudo_dma(struct vx_core *_chip, int do_write) |
325 | { | 325 | { |
326 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 326 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
327 | 327 | ||
328 | /* Interrupt mode and HREQ pin enabled for host transmit / receive data transfers */ | 328 | /* Interrupt mode and HREQ pin enabled for host transmit / receive data transfers */ |
329 | vx_outb(chip, ICR, do_write ? ICR_TREQ : ICR_RREQ); | 329 | vx_outb(chip, ICR, do_write ? ICR_TREQ : ICR_RREQ); |
@@ -343,7 +343,7 @@ static void vx_setup_pseudo_dma(struct vx_core *_chip, int do_write) | |||
343 | */ | 343 | */ |
344 | static void vx_release_pseudo_dma(struct vx_core *_chip) | 344 | static void vx_release_pseudo_dma(struct vx_core *_chip) |
345 | { | 345 | { |
346 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 346 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
347 | 347 | ||
348 | /* Disable DMA and 16-bit accesses */ | 348 | /* Disable DMA and 16-bit accesses */ |
349 | chip->regDIALOG &= ~(VXP_DLG_DMAWRITE_SEL_MASK| | 349 | chip->regDIALOG &= ~(VXP_DLG_DMAWRITE_SEL_MASK| |
@@ -403,7 +403,7 @@ static void vxp_dma_write(struct vx_core *chip, struct snd_pcm_runtime *runtime, | |||
403 | static void vxp_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime, | 403 | static void vxp_dma_read(struct vx_core *chip, struct snd_pcm_runtime *runtime, |
404 | struct vx_pipe *pipe, int count) | 404 | struct vx_pipe *pipe, int count) |
405 | { | 405 | { |
406 | struct snd_vxpocket *pchip = (struct snd_vxpocket *)chip; | 406 | struct snd_vxpocket *pchip = to_vxpocket(chip); |
407 | long port = vxp_reg_addr(chip, VX_DMA); | 407 | long port = vxp_reg_addr(chip, VX_DMA); |
408 | int offset = pipe->hw_ptr; | 408 | int offset = pipe->hw_ptr; |
409 | unsigned short *addr = (unsigned short *)(runtime->dma_area + offset); | 409 | unsigned short *addr = (unsigned short *)(runtime->dma_area + offset); |
@@ -467,7 +467,7 @@ static void vxp_write_codec_reg(struct vx_core *chip, int codec, unsigned int da | |||
467 | */ | 467 | */ |
468 | void vx_set_mic_boost(struct vx_core *chip, int boost) | 468 | void vx_set_mic_boost(struct vx_core *chip, int boost) |
469 | { | 469 | { |
470 | struct snd_vxpocket *pchip = (struct snd_vxpocket *)chip; | 470 | struct snd_vxpocket *pchip = to_vxpocket(chip); |
471 | 471 | ||
472 | if (chip->chip_status & VX_STAT_IS_STALE) | 472 | if (chip->chip_status & VX_STAT_IS_STALE) |
473 | return; | 473 | return; |
@@ -509,7 +509,7 @@ static int vx_compute_mic_level(int level) | |||
509 | */ | 509 | */ |
510 | void vx_set_mic_level(struct vx_core *chip, int level) | 510 | void vx_set_mic_level(struct vx_core *chip, int level) |
511 | { | 511 | { |
512 | struct snd_vxpocket *pchip = (struct snd_vxpocket *)chip; | 512 | struct snd_vxpocket *pchip = to_vxpocket(chip); |
513 | 513 | ||
514 | if (chip->chip_status & VX_STAT_IS_STALE) | 514 | if (chip->chip_status & VX_STAT_IS_STALE) |
515 | return; | 515 | return; |
@@ -528,7 +528,7 @@ void vx_set_mic_level(struct vx_core *chip, int level) | |||
528 | */ | 528 | */ |
529 | static void vxp_change_audio_source(struct vx_core *_chip, int src) | 529 | static void vxp_change_audio_source(struct vx_core *_chip, int src) |
530 | { | 530 | { |
531 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 531 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
532 | 532 | ||
533 | switch (src) { | 533 | switch (src) { |
534 | case VX_AUDIO_SRC_DIGITAL: | 534 | case VX_AUDIO_SRC_DIGITAL: |
@@ -568,7 +568,7 @@ static void vxp_change_audio_source(struct vx_core *_chip, int src) | |||
568 | */ | 568 | */ |
569 | static void vxp_set_clock_source(struct vx_core *_chip, int source) | 569 | static void vxp_set_clock_source(struct vx_core *_chip, int source) |
570 | { | 570 | { |
571 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 571 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
572 | 572 | ||
573 | if (source == INTERNAL_QUARTZ) | 573 | if (source == INTERNAL_QUARTZ) |
574 | chip->regCDSP &= ~VXP_CDSP_CLOCKIN_SEL_MASK; | 574 | chip->regCDSP &= ~VXP_CDSP_CLOCKIN_SEL_MASK; |
@@ -583,7 +583,7 @@ static void vxp_set_clock_source(struct vx_core *_chip, int source) | |||
583 | */ | 583 | */ |
584 | static void vxp_reset_board(struct vx_core *_chip, int cold_reset) | 584 | static void vxp_reset_board(struct vx_core *_chip, int cold_reset) |
585 | { | 585 | { |
586 | struct snd_vxpocket *chip = (struct snd_vxpocket *)_chip; | 586 | struct snd_vxpocket *chip = to_vxpocket(_chip); |
587 | 587 | ||
588 | chip->regCDSP = 0; | 588 | chip->regCDSP = 0; |
589 | chip->regDIALOG = 0; | 589 | chip->regDIALOG = 0; |
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c index b16f42deed67..ca0d19e723fd 100644 --- a/sound/pcmcia/vx/vxpocket.c +++ b/sound/pcmcia/vx/vxpocket.c | |||
@@ -155,7 +155,7 @@ static int snd_vxpocket_new(struct snd_card *card, int ibl, | |||
155 | } | 155 | } |
156 | chip->ibl.size = ibl; | 156 | chip->ibl.size = ibl; |
157 | 157 | ||
158 | vxp = (struct snd_vxpocket *)chip; | 158 | vxp = to_vxpocket(chip); |
159 | 159 | ||
160 | vxp->p_dev = link; | 160 | vxp->p_dev = link; |
161 | link->priv = chip; | 161 | link->priv = chip; |
@@ -187,7 +187,7 @@ static int snd_vxpocket_assign_resources(struct vx_core *chip, int port, int irq | |||
187 | { | 187 | { |
188 | int err; | 188 | int err; |
189 | struct snd_card *card = chip->card; | 189 | struct snd_card *card = chip->card; |
190 | struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip; | 190 | struct snd_vxpocket *vxp = to_vxpocket(chip); |
191 | 191 | ||
192 | snd_printdd(KERN_DEBUG "vxpocket assign resources: port = 0x%x, irq = %d\n", port, irq); | 192 | snd_printdd(KERN_DEBUG "vxpocket assign resources: port = 0x%x, irq = %d\n", port, irq); |
193 | vxp->port = port; | 193 | vxp->port = port; |
diff --git a/sound/pcmcia/vx/vxpocket.h b/sound/pcmcia/vx/vxpocket.h index 13d658c1a216..26f4255e132e 100644 --- a/sound/pcmcia/vx/vxpocket.h +++ b/sound/pcmcia/vx/vxpocket.h | |||
@@ -43,6 +43,8 @@ struct snd_vxpocket { | |||
43 | struct pcmcia_device *p_dev; | 43 | struct pcmcia_device *p_dev; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | #define to_vxpocket(x) container_of(x, struct snd_vxpocket, core) | ||
47 | |||
46 | extern struct snd_vx_ops snd_vxpocket_ops; | 48 | extern struct snd_vx_ops snd_vxpocket_ops; |
47 | 49 | ||
48 | void vx_set_mic_boost(struct vx_core *chip, int boost); | 50 | void vx_set_mic_boost(struct vx_core *chip, int boost); |