Commit a4e86cba authored by Takashi Sakamoto's avatar Takashi Sakamoto Committed by Takashi Iwai
Browse files

ALSA: firewire-digi00x: 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: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent fcbe08d4
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -173,16 +173,15 @@ static int hwdep_compat_ioctl(struct snd_hwdep *hwdep, struct file *file,
#define hwdep_compat_ioctl NULL
#endif

static const struct snd_hwdep_ops hwdep_ops = {
int snd_dg00x_create_hwdep_device(struct snd_dg00x *dg00x)
{
	static const struct snd_hwdep_ops ops = {
		.read		= hwdep_read,
		.release	= hwdep_release,
		.poll		= hwdep_poll,
		.ioctl		= hwdep_ioctl,
		.ioctl_compat	= hwdep_compat_ioctl,
	};

int snd_dg00x_create_hwdep_device(struct snd_dg00x *dg00x)
{
	struct snd_hwdep *hwdep;
	int err;

@@ -192,7 +191,7 @@ int snd_dg00x_create_hwdep_device(struct snd_dg00x *dg00x)

	strcpy(hwdep->name, "Digi00x");
	hwdep->iface = SNDRV_HWDEP_IFACE_FW_DIGI00X;
	hwdep->ops = hwdep_ops;
	hwdep->ops = ops;
	hwdep->private_data = dg00x;
	hwdep->exclusive = true;

+24 −28
Original line number Diff line number Diff line
@@ -76,18 +76,6 @@ static void midi_phys_playback_trigger(struct snd_rawmidi_substream *substream,
	spin_unlock_irqrestore(&dg00x->lock, flags);
}

static struct snd_rawmidi_ops midi_phys_capture_ops = {
	.open		= midi_phys_open,
	.close		= midi_phys_close,
	.trigger	= midi_phys_capture_trigger,
};

static struct snd_rawmidi_ops midi_phys_playback_ops = {
	.open		= midi_phys_open,
	.close		= midi_phys_close,
	.trigger	= midi_phys_playback_trigger,
};

static int midi_ctl_open(struct snd_rawmidi_substream *substream)
{
	/* Do nothing. */
@@ -139,18 +127,6 @@ static void midi_ctl_playback_trigger(struct snd_rawmidi_substream *substream,
	spin_unlock_irqrestore(&dg00x->lock, flags);
}

static struct snd_rawmidi_ops midi_ctl_capture_ops = {
	.open		= midi_ctl_open,
	.close		= midi_ctl_capture_close,
	.trigger	= midi_ctl_capture_trigger,
};

static struct snd_rawmidi_ops midi_ctl_playback_ops = {
	.open		= midi_ctl_open,
	.close		= midi_ctl_playback_close,
	.trigger	= midi_ctl_playback_trigger,
};

static void set_midi_substream_names(struct snd_dg00x *dg00x,
				     struct snd_rawmidi_str *str,
				     bool is_ctl)
@@ -172,6 +148,26 @@ static void set_midi_substream_names(struct snd_dg00x *dg00x,

int snd_dg00x_create_midi_devices(struct snd_dg00x *dg00x)
{
	static struct snd_rawmidi_ops phys_capture_ops = {
		.open		= midi_phys_open,
		.close		= midi_phys_close,
		.trigger	= midi_phys_capture_trigger,
	};
	static struct snd_rawmidi_ops phys_playback_ops = {
		.open		= midi_phys_open,
		.close		= midi_phys_close,
		.trigger	= midi_phys_playback_trigger,
	};
	static struct snd_rawmidi_ops ctl_capture_ops = {
		.open		= midi_ctl_open,
		.close		= midi_ctl_capture_close,
		.trigger	= midi_ctl_capture_trigger,
	};
	static struct snd_rawmidi_ops ctl_playback_ops = {
		.open		= midi_ctl_open,
		.close		= midi_ctl_playback_close,
		.trigger	= midi_ctl_playback_trigger,
	};
	struct snd_rawmidi *rmidi[2];
	struct snd_rawmidi_str *str;
	unsigned int i;
@@ -187,9 +183,9 @@ int snd_dg00x_create_midi_devices(struct snd_dg00x *dg00x)
		 "%s MIDI", dg00x->card->shortname);

	snd_rawmidi_set_ops(rmidi[0], SNDRV_RAWMIDI_STREAM_INPUT,
			    &midi_phys_capture_ops);
			    &phys_capture_ops);
	snd_rawmidi_set_ops(rmidi[0], SNDRV_RAWMIDI_STREAM_OUTPUT,
			    &midi_phys_playback_ops);
			    &phys_playback_ops);

	/* Add a pair of control midi ports. */
	err = snd_rawmidi_new(dg00x->card, dg00x->card->driver, 1,
@@ -201,9 +197,9 @@ int snd_dg00x_create_midi_devices(struct snd_dg00x *dg00x)
		 "%s control", dg00x->card->shortname);

	snd_rawmidi_set_ops(rmidi[1], SNDRV_RAWMIDI_STREAM_INPUT,
			    &midi_ctl_capture_ops);
			    &ctl_capture_ops);
	snd_rawmidi_set_ops(rmidi[1], SNDRV_RAWMIDI_STREAM_OUTPUT,
			    &midi_ctl_playback_ops);
			    &ctl_playback_ops);

	for (i = 0; i < ARRAY_SIZE(rmidi); i++) {
		rmidi[i]->private_data = dg00x;
+25 −27
Original line number Diff line number Diff line
@@ -329,7 +329,9 @@ static snd_pcm_uframes_t pcm_playback_pointer(struct snd_pcm_substream *sbstrm)
	return amdtp_stream_pcm_pointer(&dg00x->rx_stream);
}

static const struct snd_pcm_ops pcm_capture_ops = {
int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
{
	static const struct snd_pcm_ops capture_ops = {
		.open		= pcm_open,
		.close		= pcm_close,
		.ioctl		= snd_pcm_lib_ioctl,
@@ -340,8 +342,7 @@ static const struct snd_pcm_ops pcm_capture_ops = {
		.pointer	= pcm_capture_pointer,
		.page		= snd_pcm_lib_get_vmalloc_page,
	};

static const struct snd_pcm_ops pcm_playback_ops = {
	static const struct snd_pcm_ops playback_ops = {
		.open		= pcm_open,
		.close		= pcm_close,
		.ioctl		= snd_pcm_lib_ioctl,
@@ -353,9 +354,6 @@ static const struct snd_pcm_ops pcm_playback_ops = {
		.page		= snd_pcm_lib_get_vmalloc_page,
		.mmap		= snd_pcm_lib_mmap_vmalloc,
	};

int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
{
	struct snd_pcm *pcm;
	int err;

@@ -366,8 +364,8 @@ int snd_dg00x_create_pcm_devices(struct snd_dg00x *dg00x)
	pcm->private_data = dg00x;
	snprintf(pcm->name, sizeof(pcm->name),
		 "%s PCM", dg00x->card->shortname);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &pcm_playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &pcm_capture_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &playback_ops);
	snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &capture_ops);

	return 0;
}