summaryrefslogtreecommitdiffstats
path: root/sound/firewire
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2017-01-05 07:48:12 -0500
committerTakashi Iwai <tiwai@suse.de>2017-01-05 10:58:10 -0500
commit921282360b9c9bf34c75cd18bb90f298c4f4ebc8 (patch)
tree99e4cd5b018acf67037b868257df43df6275f89a /sound/firewire
parenta4e86cba09c9e2bb64af018544a7aed4a6a1b538 (diff)
ALSA: firewire-tascam: 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/tascam/tascam-hwdep.c17
-rw-r--r--sound/firewire/tascam/tascam-midi.c26
-rw-r--r--sound/firewire/tascam/tascam-pcm.c52
3 files changed, 45 insertions, 50 deletions
diff --git a/sound/firewire/tascam/tascam-hwdep.c b/sound/firewire/tascam/tascam-hwdep.c
index 106406cbfaa3..8c4437d0051d 100644
--- a/sound/firewire/tascam/tascam-hwdep.c
+++ b/sound/firewire/tascam/tascam-hwdep.c
@@ -163,16 +163,15 @@ static int hwdep_compat_ioctl(struct snd_hwdep *hwdep, struct file *file,
163#define hwdep_compat_ioctl NULL 163#define hwdep_compat_ioctl NULL
164#endif 164#endif
165 165
166static const struct snd_hwdep_ops hwdep_ops = {
167 .read = hwdep_read,
168 .release = hwdep_release,
169 .poll = hwdep_poll,
170 .ioctl = hwdep_ioctl,
171 .ioctl_compat = hwdep_compat_ioctl,
172};
173
174int snd_tscm_create_hwdep_device(struct snd_tscm *tscm) 166int snd_tscm_create_hwdep_device(struct snd_tscm *tscm)
175{ 167{
168 static const struct snd_hwdep_ops ops = {
169 .read = hwdep_read,
170 .release = hwdep_release,
171 .poll = hwdep_poll,
172 .ioctl = hwdep_ioctl,
173 .ioctl_compat = hwdep_compat_ioctl,
174 };
176 struct snd_hwdep *hwdep; 175 struct snd_hwdep *hwdep;
177 int err; 176 int err;
178 177
@@ -182,7 +181,7 @@ int snd_tscm_create_hwdep_device(struct snd_tscm *tscm)
182 181
183 strcpy(hwdep->name, "Tascam"); 182 strcpy(hwdep->name, "Tascam");
184 hwdep->iface = SNDRV_HWDEP_IFACE_FW_TASCAM; 183 hwdep->iface = SNDRV_HWDEP_IFACE_FW_TASCAM;
185 hwdep->ops = hwdep_ops; 184 hwdep->ops = ops;
186 hwdep->private_data = tscm; 185 hwdep->private_data = tscm;
187 hwdep->exclusive = true; 186 hwdep->exclusive = true;
188 187
diff --git a/sound/firewire/tascam/tascam-midi.c b/sound/firewire/tascam/tascam-midi.c
index 41f842079d9d..7fdc71e4763e 100644
--- a/sound/firewire/tascam/tascam-midi.c
+++ b/sound/firewire/tascam/tascam-midi.c
@@ -68,20 +68,18 @@ static void midi_playback_trigger(struct snd_rawmidi_substream *substrm, int up)
68 spin_unlock_irqrestore(&tscm->lock, flags); 68 spin_unlock_irqrestore(&tscm->lock, flags);
69} 69}
70 70
71static struct snd_rawmidi_ops midi_capture_ops = {
72 .open = midi_capture_open,
73 .close = midi_capture_close,
74 .trigger = midi_capture_trigger,
75};
76
77static struct snd_rawmidi_ops midi_playback_ops = {
78 .open = midi_playback_open,
79 .close = midi_playback_close,
80 .trigger = midi_playback_trigger,
81};
82
83int snd_tscm_create_midi_devices(struct snd_tscm *tscm) 71int snd_tscm_create_midi_devices(struct snd_tscm *tscm)
84{ 72{
73 static struct snd_rawmidi_ops capture_ops = {
74 .open = midi_capture_open,
75 .close = midi_capture_close,
76 .trigger = midi_capture_trigger,
77 };
78 static struct snd_rawmidi_ops playback_ops = {
79 .open = midi_playback_open,
80 .close = midi_playback_close,
81 .trigger = midi_playback_trigger,
82 };
85 struct snd_rawmidi *rmidi; 83 struct snd_rawmidi *rmidi;
86 struct snd_rawmidi_str *stream; 84 struct snd_rawmidi_str *stream;
87 struct snd_rawmidi_substream *subs; 85 struct snd_rawmidi_substream *subs;
@@ -100,7 +98,7 @@ int snd_tscm_create_midi_devices(struct snd_tscm *tscm)
100 98
101 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT; 99 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_INPUT;
102 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT, 100 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_INPUT,
103 &midi_capture_ops); 101 &capture_ops);
104 stream = &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT]; 102 stream = &rmidi->streams[SNDRV_RAWMIDI_STREAM_INPUT];
105 103
106 /* Set port names for MIDI input. */ 104 /* Set port names for MIDI input. */
@@ -116,7 +114,7 @@ int snd_tscm_create_midi_devices(struct snd_tscm *tscm)
116 114
117 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT; 115 rmidi->info_flags |= SNDRV_RAWMIDI_INFO_OUTPUT;
118 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT, 116 snd_rawmidi_set_ops(rmidi, SNDRV_RAWMIDI_STREAM_OUTPUT,
119 &midi_playback_ops); 117 &playback_ops);
120 stream = &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT]; 118 stream = &rmidi->streams[SNDRV_RAWMIDI_STREAM_OUTPUT];
121 119
122 /* Set port names for MIDI ourput. */ 120 /* Set port names for MIDI ourput. */
diff --git a/sound/firewire/tascam/tascam-pcm.c b/sound/firewire/tascam/tascam-pcm.c
index 79db1b651f5c..f5dd6ce6b6f1 100644
--- a/sound/firewire/tascam/tascam-pcm.c
+++ b/sound/firewire/tascam/tascam-pcm.c
@@ -268,33 +268,31 @@ static snd_pcm_uframes_t pcm_playback_pointer(struct snd_pcm_substream *sbstrm)
268 return amdtp_stream_pcm_pointer(&tscm->rx_stream); 268 return amdtp_stream_pcm_pointer(&tscm->rx_stream);
269} 269}
270 270
271static const struct snd_pcm_ops pcm_capture_ops = {
272 .open = pcm_open,
273 .close = pcm_close,
274 .ioctl = snd_pcm_lib_ioctl,
275 .hw_params = pcm_capture_hw_params,
276 .hw_free = pcm_capture_hw_free,
277 .prepare = pcm_capture_prepare,
278 .trigger = pcm_capture_trigger,
279 .pointer = pcm_capture_pointer,
280 .page = snd_pcm_lib_get_vmalloc_page,
281};
282
283static const struct snd_pcm_ops pcm_playback_ops = {
284 .open = pcm_open,
285 .close = pcm_close,
286 .ioctl = snd_pcm_lib_ioctl,
287 .hw_params = pcm_playback_hw_params,
288 .hw_free = pcm_playback_hw_free,
289 .prepare = pcm_playback_prepare,
290 .trigger = pcm_playback_trigger,
291 .pointer = pcm_playback_pointer,
292 .page = snd_pcm_lib_get_vmalloc_page,
293 .mmap = snd_pcm_lib_mmap_vmalloc,
294};
295
296int snd_tscm_create_pcm_devices(struct snd_tscm *tscm) 271int snd_tscm_create_pcm_devices(struct snd_tscm *tscm)
297{ 272{
273 static const struct snd_pcm_ops capture_ops = {
274 .open = pcm_open,
275 .close = pcm_close,
276 .ioctl = snd_pcm_lib_ioctl,
277 .hw_params = pcm_capture_hw_params,
278 .hw_free = pcm_capture_hw_free,
279 .prepare = pcm_capture_prepare,
280 .trigger = pcm_capture_trigger,
281 .pointer = pcm_capture_pointer,
282 .page = snd_pcm_lib_get_vmalloc_page,
283 };
284 static const struct snd_pcm_ops playback_ops = {
285 .open = pcm_open,
286 .close = pcm_close,
287 .ioctl = snd_pcm_lib_ioctl,
288 .hw_params = pcm_playback_hw_params,
289 .hw_free = pcm_playback_hw_free,
290 .prepare = pcm_playback_prepare,
291 .trigger = pcm_playback_trigger,
292 .pointer = pcm_playback_pointer,
293 .page = snd_pcm_lib_get_vmalloc_page,
294 .mmap = snd_pcm_lib_mmap_vmalloc,
295 };
298 struct snd_pcm *pcm; 296 struct snd_pcm *pcm;
299 int err; 297 int err;
300 298
@@ -305,8 +303,8 @@ int snd_tscm_create_pcm_devices(struct snd_tscm *tscm)
305 pcm->private_data = tscm; 303 pcm->private_data = tscm;
306 snprintf(pcm->name, sizeof(pcm->name), 304 snprintf(pcm->name, sizeof(pcm->name),
307 "%s PCM", tscm->card->shortname); 305 "%s PCM", tscm->card->shortname);
308 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_playback_ops); 306 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
309 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_capture_ops); 307 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);
310 308
311 return 0; 309 return 0;
312} 310}