Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b6d9245 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Jaroslav Kysela
Browse files

[ALSA] seq: set client name in snd_seq_create_kernel_client()



All users of snd_seq_create_kernel_client() have to set the client name
anyway, so we can just pass the name as parameter.  This relieves us
from having to muck around with a struct snd_seq_client_info in these
cases.

Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
parent 83e8ad69
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -75,7 +75,9 @@ struct snd_seq_port_callback {
};

/* interface for kernel client */
int snd_seq_create_kernel_client(struct snd_card *card, int client_index);
int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
				 const char *name_fmt, ...)
	__attribute__ ((format (printf, 3, 4)));
int snd_seq_delete_kernel_client(int client);
int snd_seq_kernel_client_enqueue(int client, struct snd_seq_event *ev, int atomic, int hop);
int snd_seq_kernel_client_dispatch(int client, struct snd_seq_event *ev, int atomic, int hop);
+3 −13
Original line number Diff line number Diff line
@@ -65,33 +65,24 @@ int __init
snd_seq_oss_create_client(void)
{
	int rc;
	struct snd_seq_client_info *info;
	struct snd_seq_port_info *port;
	struct snd_seq_port_callback port_callback;

	info = kmalloc(sizeof(*info), GFP_KERNEL);
	port = kmalloc(sizeof(*port), GFP_KERNEL);
	if (!info || !port) {
	if (!port) {
		rc = -ENOMEM;
		goto __error;
	}

	/* create ALSA client */
	rc = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_OSS);
	rc = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_OSS,
					  "OSS sequencer");
	if (rc < 0)
		goto __error;

	system_client = rc;
	debug_printk(("new client = %d\n", rc));

	/* set client information */
	memset(info, 0, sizeof(*info));
	info->client = system_client;
	info->type = KERNEL_CLIENT;
	strcpy(info->name, "OSS sequencer");

	rc = call_ctl(SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, info);

	/* look up midi devices */
	snd_seq_oss_midi_lookup_ports(system_client);

@@ -124,7 +115,6 @@ snd_seq_oss_create_client(void)

 __error:
	kfree(port);
	kfree(info);
	return rc;
}

+6 −2
Original line number Diff line number Diff line
@@ -2212,9 +2212,11 @@ static long snd_seq_ioctl(struct file *file, unsigned int cmd, unsigned long arg


/* exported to kernel modules */
int snd_seq_create_kernel_client(struct snd_card *card, int client_index)
int snd_seq_create_kernel_client(struct snd_card *card, int client_index,
				 const char *name_fmt, ...)
{
	struct snd_seq_client *client;
	va_list args;

	snd_assert(! in_interrupt(), return -EBUSY);

@@ -2244,7 +2246,9 @@ int snd_seq_create_kernel_client(struct snd_card *card, int client_index)
	client->accept_input = 1;
	client->accept_output = 1;
		
	sprintf(client->name, "Client-%d", client->number);
	va_start(args, name_fmt);
	vsnprintf(client->name, sizeof(client->name), name_fmt, args);
	va_end(args);

	client->type = KERNEL_CLIENT;
	up(&register_mutex);
+2 −9
Original line number Diff line number Diff line
@@ -193,7 +193,6 @@ create_port(int idx, int type)
static int __init
register_client(void)
{
	struct snd_seq_client_info cinfo;
	struct snd_seq_dummy_port *rec1, *rec2;
	int i;

@@ -203,17 +202,11 @@ register_client(void)
	}

	/* create client */
	my_client = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_DUMMY);
	my_client = snd_seq_create_kernel_client(NULL, SNDRV_SEQ_CLIENT_DUMMY,
						 "Midi Through");
	if (my_client < 0)
		return my_client;

	/* set client name */
	memset(&cinfo, 0, sizeof(cinfo));
	cinfo.client = my_client;
	cinfo.type = KERNEL_CLIENT;
	strcpy(cinfo.name, "Midi Through");
	snd_seq_kernel_client_ctl(my_client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo);

	/* create ports */
	for (i = 0; i < ports; i++) {
		rec1 = create_port(i, 0);
+5 −19
Original line number Diff line number Diff line
@@ -270,21 +270,6 @@ static void snd_seq_midisynth_delete(struct seq_midisynth *msynth)
		snd_midi_event_free(msynth->parser);
}

/* set our client name */
static int set_client_name(struct seq_midisynth_client *client, struct snd_card *card,
			   struct snd_rawmidi_info *rmidi)
{
	struct snd_seq_client_info cinfo;
	const char *name;

	memset(&cinfo, 0, sizeof(cinfo));
	cinfo.client = client->seq_client;
	cinfo.type = KERNEL_CLIENT;
	name = rmidi->name[0] ? (const char *)rmidi->name : "External MIDI";
	strlcpy(cinfo.name, name, sizeof(cinfo.name));
	return snd_seq_kernel_client_ctl(client->seq_client, SNDRV_SEQ_IOCTL_SET_CLIENT_INFO, &cinfo);
}

/* register new midi synth port */
static int
snd_seq_midisynth_register_port(struct snd_seq_device *dev)
@@ -333,16 +318,17 @@ snd_seq_midisynth_register_port(struct snd_seq_device *dev)
			kfree(info);
			return -ENOMEM;
		}
		client->seq_client = snd_seq_create_kernel_client(card, 0);
		client->seq_client =
			snd_seq_create_kernel_client(
				card, 0, "%s", info->name[0] ?
				(const char *)info->name : "External MIDI");
		if (client->seq_client < 0) {
			kfree(client);
			up(&register_mutex);
			kfree(info);
			return -ENOMEM;
		}
		set_client_name(client, card, info);
	} else if (device == 0)
		set_client_name(client, card, info); /* use the first device's name */
	}

	msynth = kcalloc(ports, sizeof(struct seq_midisynth), GFP_KERNEL);
	port = kmalloc(sizeof(*port), GFP_KERNEL);
Loading