Commit 2af677fc authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Jaroslav Kysela
Browse files

[ALSA] dynamic minors (1/6): store device type in struct snd_minor



Instead of a comment string, store the device type in the snd_minor
structure.  This makes snd_minor more flexible, and has the nice side
effect that we don't need anymore to create a separate snd_minor
template for registering a device but can pass the file_operations
directly to snd_register_device().

Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
parent a106cd3d
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -185,8 +185,8 @@ static inline int snd_power_wait(struct snd_card *card, unsigned int state, stru
struct snd_minor {
	struct list_head list;		/* list of all minors per card */
	int number;			/* minor number */
	int type;			/* SNDRV_DEVICE_TYPE_XXX */
	int device;			/* device number */
	const char *comment;		/* for /proc/asound/devices */
	struct file_operations *f_ops;	/* file operations */
	char name[0];			/* device name (keep at the end of
								structure) */
@@ -199,11 +199,13 @@ extern int snd_ecards_limit;

void snd_request_card(int card);

int snd_register_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name);
int snd_register_device(int type, struct snd_card *card, int dev,
			struct file_operations *f_ops, const char *name);
int snd_unregister_device(int type, struct snd_card *card, int dev);

#ifdef CONFIG_SND_OSSEMUL
int snd_register_oss_device(int type, struct snd_card *card, int dev, struct snd_minor *reg, const char *name);
int snd_register_oss_device(int type, struct snd_card *card, int dev,
			    struct file_operations *f_ops, const char *name);
int snd_unregister_oss_device(int type, struct snd_card *card, int dev);
#endif

+1 −2
Original line number Diff line number Diff line
@@ -402,7 +402,6 @@ struct snd_pcm_str {
	struct snd_pcm_oss_stream oss;
#endif
	struct snd_pcm_file *files;
	struct snd_minor *reg;
	struct snd_info_entry *proc_root;
	struct snd_info_entry *proc_info_entry;
#ifdef CONFIG_SND_DEBUG
@@ -441,7 +440,7 @@ struct snd_pcm_notify {
 */

extern struct snd_pcm *snd_pcm_devices[];
extern struct snd_minor snd_pcm_reg[2];
extern struct file_operations snd_pcm_f_ops[2];

int snd_pcm_new(struct snd_card *card, char *id, int device,
		int playback_count, int capture_count,
+3 −8
Original line number Diff line number Diff line
@@ -1264,12 +1264,6 @@ static struct file_operations snd_ctl_f_ops =
	.fasync =	snd_ctl_fasync,
};

static struct snd_minor snd_ctl_reg =
{
	.comment =	"ctl",
	.f_ops =	&snd_ctl_f_ops,
};

/*
 * registration of the control device
 */
@@ -1284,7 +1278,7 @@ static int snd_ctl_dev_register(struct snd_device *device)
	snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
	sprintf(name, "controlC%i", cardnum);
	if ((err = snd_register_device(SNDRV_DEVICE_TYPE_CONTROL,
					card, 0, &snd_ctl_reg, name)) < 0)
				       card, -1, &snd_ctl_f_ops, name)) < 0)
		return err;
	return 0;
}
@@ -1336,7 +1330,8 @@ static int snd_ctl_dev_unregister(struct snd_device *device)
	snd_assert(card != NULL, return -ENXIO);
	cardnum = card->number;
	snd_assert(cardnum >= 0 && cardnum < SNDRV_CARDS, return -ENXIO);
	if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL, card, 0)) < 0)
	if ((err = snd_unregister_device(SNDRV_DEVICE_TYPE_CONTROL,
					 card, -1)) < 0)
		return err;
	return snd_ctl_dev_free(device);
}
+3 −8
Original line number Diff line number Diff line
@@ -330,12 +330,6 @@ static struct file_operations snd_hwdep_f_ops =
	.mmap =		snd_hwdep_mmap,
};

static struct snd_minor snd_hwdep_reg =
{
	.comment =	"hardware dependent",
	.f_ops =	&snd_hwdep_f_ops,
};

/**
 * snd_hwdep_new - create a new hwdep instance
 * @card: the card instance
@@ -416,7 +410,7 @@ static int snd_hwdep_dev_register(struct snd_device *device)
	sprintf(name, "hwC%iD%i", hwdep->card->number, hwdep->device);
	if ((err = snd_register_device(SNDRV_DEVICE_TYPE_HWDEP,
				       hwdep->card, hwdep->device,
				       &snd_hwdep_reg, name)) < 0) {
				       &snd_hwdep_f_ops, name)) < 0) {
		snd_printk(KERN_ERR "unable to register hardware dependent device %i:%i\n",
			   hwdep->card->number, hwdep->device);
		snd_hwdep_devices[idx] = NULL;
@@ -431,7 +425,8 @@ static int snd_hwdep_dev_register(struct snd_device *device)
		} else {
			if (snd_register_oss_device(hwdep->oss_type,
						    hwdep->card, hwdep->device,
						    &snd_hwdep_reg, hwdep->oss_dev) < 0) {
						    &snd_hwdep_f_ops,
						    hwdep->oss_dev) < 0) {
				snd_printk(KERN_ERR "unable to register OSS compatibility device %i:%i\n",
					   hwdep->card->number, hwdep->device);
			} else
+1 −7
Original line number Diff line number Diff line
@@ -398,12 +398,6 @@ static struct file_operations snd_mixer_oss_f_ops =
	.compat_ioctl =	snd_mixer_oss_ioctl_compat,
};

static struct snd_minor snd_mixer_oss_reg =
{
	.comment =	"mixer",
	.f_ops =	&snd_mixer_oss_f_ops,
};

/*
 *  utilities
 */
@@ -1292,7 +1286,7 @@ static int snd_mixer_oss_notify_handler(struct snd_card *card, int cmd)
		sprintf(name, "mixer%i%i", card->number, 0);
		if ((err = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MIXER,
						   card, 0,
						   &snd_mixer_oss_reg,
						   &snd_mixer_oss_f_ops,
						   name)) < 0) {
			snd_printk(KERN_ERR "unable to register OSS mixer device %i:%i\n",
				   card->number, 0);
Loading