diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2017-01-05 07:48:08 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2017-01-05 10:58:03 -0500 |
commit | 7cdc887a00d79a1553009eb7afd308882e4b74d5 (patch) | |
tree | 3b6fc7167b4a1a9c3089343dc4ecf96c654232f7 /sound/firewire | |
parent | 4780f774f99129f1650d250e346d5bfba98d9f4f (diff) |
ALSA: fireworks: enclose identifiers referred by single function
Some identifiers are referred just by one functions. In this case, they
can be put into the function definition. This brings two merits; readers
can easily follow codes related to the identifiers, developers are free
from name conflict.
This commit moves such identifiers to each function definition.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/firewire')
-rw-r--r-- | sound/firewire/fireworks/fireworks_hwdep.c | 19 | ||||
-rw-r--r-- | sound/firewire/fireworks/fireworks_midi.c | 26 | ||||
-rw-r--r-- | sound/firewire/fireworks/fireworks_pcm.c | 52 |
3 files changed, 46 insertions, 51 deletions
diff --git a/sound/firewire/fireworks/fireworks_hwdep.c b/sound/firewire/fireworks/fireworks_hwdep.c index 2e1d9a23920c..a3a3a16f5e08 100644 --- a/sound/firewire/fireworks/fireworks_hwdep.c +++ b/sound/firewire/fireworks/fireworks_hwdep.c | |||
@@ -303,17 +303,16 @@ hwdep_compat_ioctl(struct snd_hwdep *hwdep, struct file *file, | |||
303 | #define hwdep_compat_ioctl NULL | 303 | #define hwdep_compat_ioctl NULL |
304 | #endif | 304 | #endif |
305 | 305 | ||
306 | static const struct snd_hwdep_ops hwdep_ops = { | ||
307 | .read = hwdep_read, | ||
308 | .write = hwdep_write, | ||
309 | .release = hwdep_release, | ||
310 | .poll = hwdep_poll, | ||
311 | .ioctl = hwdep_ioctl, | ||
312 | .ioctl_compat = hwdep_compat_ioctl, | ||
313 | }; | ||
314 | |||
315 | int snd_efw_create_hwdep_device(struct snd_efw *efw) | 306 | int snd_efw_create_hwdep_device(struct snd_efw *efw) |
316 | { | 307 | { |
308 | static const struct snd_hwdep_ops ops = { | ||
309 | .read = hwdep_read, | ||
310 | .write = hwdep_write, | ||
311 | .release = hwdep_release, | ||
312 | .poll = hwdep_poll, | ||
313 | .ioctl = hwdep_ioctl, | ||
314 | .ioctl_compat = hwdep_compat_ioctl, | ||
315 | }; | ||
317 | struct snd_hwdep *hwdep; | 316 | struct snd_hwdep *hwdep; |
318 | int err; | 317 | int err; |
319 | 318 | ||
@@ -322,7 +321,7 @@ int snd_efw_create_hwdep_device(struct snd_efw *efw) | |||
322 | goto end; | 321 | goto end; |
323 | strcpy(hwdep->name, "Fireworks"); | 322 | strcpy(hwdep->name, "Fireworks"); |
324 | hwdep->iface = SNDRV_HWDEP_IFACE_FW_FIREWORKS; | 323 | hwdep->iface = SNDRV_HWDEP_IFACE_FW_FIREWORKS; |
325 | hwdep->ops = hwdep_ops; | 324 | hwdep->ops = ops; |
326 | hwdep->private_data = efw; | 325 | hwdep->private_data = efw; |
327 | hwdep->exclusive = true; | 326 | hwdep->exclusive = true; |
328 | end: | 327 | end: |
diff --git a/sound/firewire/fireworks/fireworks_midi.c b/sound/firewire/fireworks/fireworks_midi.c index 3e8c4cf9fe1e..2873eca22bfc 100644 --- a/sound/firewire/fireworks/fireworks_midi.c +++ b/sound/firewire/fireworks/fireworks_midi.c | |||
@@ -107,18 +107,6 @@ static void midi_playback_trigger(struct snd_rawmidi_substream *substrm, int up) | |||
107 | spin_unlock_irqrestore(&efw->lock, flags); | 107 | spin_unlock_irqrestore(&efw->lock, flags); |
108 | } | 108 | } |
109 | 109 | ||
110 | static struct snd_rawmidi_ops midi_capture_ops = { | ||
111 | .open = midi_capture_open, | ||
112 | .close = midi_capture_close, | ||
113 | .trigger = midi_capture_trigger, | ||
114 | }; | ||
115 | |||
116 | static struct snd_rawmidi_ops midi_playback_ops = { | ||
117 | .open = midi_playback_open, | ||
118 | .close = midi_playback_close, | ||
119 | .trigger = midi_playback_trigger, | ||
120 | }; | ||
121 | |||
122 | static void set_midi_substream_names(struct snd_efw *efw, | 110 | static void set_midi_substream_names(struct snd_efw *efw, |
123 | struct snd_rawmidi_str *str) | 111 | struct snd_rawmidi_str *str) |
124 | { | 112 | { |
@@ -132,6 +120,16 @@ static void set_midi_substream_names(struct snd_efw *efw, | |||
132 | 120 | ||
133 | int snd_efw_create_midi_devices(struct snd_efw *efw) | 121 | int snd_efw_create_midi_devices(struct snd_efw *efw) |
134 | { | 122 | { |
123 | static struct snd_rawmidi_ops capture_ops = { | ||
124 | .open = midi_capture_open, | ||
125 | .close = midi_capture_close, | ||
126 | .trigger = midi_capture_trigger, | ||
127 | }; | ||
128 | static struct snd_rawmidi_ops playback_ops = { | ||
129 | .open = midi_playback_open, | ||
130 | .close = midi_playback_close, | ||
131 | .trigger = midi_playback_trigger, | ||
132 | }; | ||
135 | struct snd_rawmidi *rmidi; | 133 | struct snd_rawmidi *rmidi; |
136 | struct snd_rawmidi_str *str; | 134 | struct snd_rawmidi_str *str; |
137 | int err; | 135 | int err; |
@@ -151,7 +149,7 @@ int snd_efw_create_midi_devices(struct snd_efw *efw) | |||
151 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; | 149 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; |
152 | 150 | ||
153 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, | 151 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, |
154 | &midi_capture_ops); | 152 | &capture_ops); |
155 | 153 | ||
156 | str = &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]; | 154 | str = &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]; |
157 | 155 | ||
@@ -162,7 +160,7 @@ int snd_efw_create_midi_devices(struct snd_efw *efw) | |||
162 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT; | 160 | rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT; |
163 | 161 | ||
164 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, | 162 | snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, |
165 | &midi_playback_ops); | 163 | &playback_ops); |
166 | 164 | ||
167 | str = &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]; | 165 | str = &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]; |
168 | 166 | ||
diff --git a/sound/firewire/fireworks/fireworks_pcm.c b/sound/firewire/fireworks/fireworks_pcm.c index f4fbf75ed198..9171702f7d0b 100644 --- a/sound/firewire/fireworks/fireworks_pcm.c +++ b/sound/firewire/fireworks/fireworks_pcm.c | |||
@@ -383,33 +383,31 @@ static snd_pcm_uframes_t pcm_playback_pointer(struct snd_pcm_substream *sbstrm) | |||
383 | return amdtp_stream_pcm_pointer(&efw->rx_stream); | 383 | return amdtp_stream_pcm_pointer(&efw->rx_stream); |
384 | } | 384 | } |
385 | 385 | ||
386 | static const struct snd_pcm_ops pcm_capture_ops = { | ||
387 | .open = pcm_open, | ||
388 | .close = pcm_close, | ||
389 | .ioctl = snd_pcm_lib_ioctl, | ||
390 | .hw_params = pcm_capture_hw_params, | ||
391 | .hw_free = pcm_capture_hw_free, | ||
392 | .prepare = pcm_capture_prepare, | ||
393 | .trigger = pcm_capture_trigger, | ||
394 | .pointer = pcm_capture_pointer, | ||
395 | .page = snd_pcm_lib_get_vmalloc_page, | ||
396 | }; | ||
397 | |||
398 | static const struct snd_pcm_ops pcm_playback_ops = { | ||
399 | .open = pcm_open, | ||
400 | .close = pcm_close, | ||
401 | .ioctl = snd_pcm_lib_ioctl, | ||
402 | .hw_params = pcm_playback_hw_params, | ||
403 | .hw_free = pcm_playback_hw_free, | ||
404 | .prepare = pcm_playback_prepare, | ||
405 | .trigger = pcm_playback_trigger, | ||
406 | .pointer = pcm_playback_pointer, | ||
407 | .page = snd_pcm_lib_get_vmalloc_page, | ||
408 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
409 | }; | ||
410 | |||
411 | int snd_efw_create_pcm_devices(struct snd_efw *efw) | 386 | int snd_efw_create_pcm_devices(struct snd_efw *efw) |
412 | { | 387 | { |
388 | static const struct snd_pcm_ops capture_ops = { | ||
389 | .open = pcm_open, | ||
390 | .close = pcm_close, | ||
391 | .ioctl = snd_pcm_lib_ioctl, | ||
392 | .hw_params = pcm_capture_hw_params, | ||
393 | .hw_free = pcm_capture_hw_free, | ||
394 | .prepare = pcm_capture_prepare, | ||
395 | .trigger = pcm_capture_trigger, | ||
396 | .pointer = pcm_capture_pointer, | ||
397 | .page = snd_pcm_lib_get_vmalloc_page, | ||
398 | }; | ||
399 | static const struct snd_pcm_ops playback_ops = { | ||
400 | .open = pcm_open, | ||
401 | .close = pcm_close, | ||
402 | .ioctl = snd_pcm_lib_ioctl, | ||
403 | .hw_params = pcm_playback_hw_params, | ||
404 | .hw_free = pcm_playback_hw_free, | ||
405 | .prepare = pcm_playback_prepare, | ||
406 | .trigger = pcm_playback_trigger, | ||
407 | .pointer = pcm_playback_pointer, | ||
408 | .page = snd_pcm_lib_get_vmalloc_page, | ||
409 | .mmap = snd_pcm_lib_mmap_vmalloc, | ||
410 | }; | ||
413 | struct snd_pcm *pcm; | 411 | struct snd_pcm *pcm; |
414 | int err; | 412 | int err; |
415 | 413 | ||
@@ -419,8 +417,8 @@ int snd_efw_create_pcm_devices(struct snd_efw *efw) | |||
419 | 417 | ||
420 | pcm->private_data = efw; | 418 | pcm->private_data = efw; |
421 | snprintf(pcm->name, sizeof(pcm->name), "%s PCM", efw->card->shortname); | 419 | snprintf(pcm->name, sizeof(pcm->name), "%s PCM", efw->card->shortname); |
422 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_playback_ops); | 420 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops); |
423 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_capture_ops); | 421 | snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops); |
424 | end: | 422 | end: |
425 | return err; | 423 | return err; |
426 | } | 424 | } |