Exemplo n.º 1
0
static int sound_insert_unit(struct sound_unit **list, const struct file_operations *fops, int index, int low, int top, const char *name, umode_t mode, struct device *dev)
{
    struct sound_unit *s = kmalloc(sizeof(*s), GFP_KERNEL);
    int r;

    if (!s)
        return -ENOMEM;

    spin_lock(&sound_loader_lock);
    r = __sound_insert_unit(s, list, fops, index, low, top);
    spin_unlock(&sound_loader_lock);

    if (r < 0)
        goto fail;
    else if (r < SOUND_STEP)
        sprintf(s->name, "sound/%s", name);
    else
        sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);

    device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
                  NULL, s->name+6);
    return r;

fail:
    kfree(s);
    return r;
}
Exemplo n.º 2
0
static int sound_insert_unit(struct sound_unit **list, struct file_operations *fops, int index, int low, int top)
{
	int r;
	struct sound_unit *s=(struct sound_unit *)kmalloc(sizeof(struct sound_unit), GFP_KERNEL);
	if(s==NULL)
		return -1;
		
	spin_lock(&sound_loader_lock);
	r=__sound_insert_unit(s,list,fops,index,low,top);
	spin_unlock(&sound_loader_lock);
	
	if(r==-1)
		kfree(s);
	return r;
}
Exemplo n.º 3
0
static int sound_insert_unit(struct sound_unit **list, const struct file_operations *fops, int index, int low, int top, const char *name, umode_t mode, struct device *dev)
{
	struct sound_unit *s = kmalloc(sizeof(*s), GFP_KERNEL);
	int r;

	if (!s)
		return -ENOMEM;

	spin_lock(&sound_loader_lock);
retry:
	r = __sound_insert_unit(s, list, fops, index, low, top);
	spin_unlock(&sound_loader_lock);
	
	if (r < 0)
		goto fail;
	else if (r < SOUND_STEP)
		sprintf(s->name, "sound/%s", name);
	else
		sprintf(s->name, "sound/%s%d", name, r / SOUND_STEP);

	if (!preclaim_oss) {
		/*
		 * Something else might have grabbed the minor.  If
		 * first free slot is requested, rescan with @low set
		 * to the next unit; otherwise, -EBUSY.
		 */
		r = __register_chrdev(SOUND_MAJOR, s->unit_minor, 1, s->name,
				      &soundcore_fops);
		if (r < 0) {
			spin_lock(&sound_loader_lock);
			__sound_remove_unit(list, s->unit_minor);
			if (index < 0) {
				low = s->unit_minor + SOUND_STEP;
				goto retry;
			}
			spin_unlock(&sound_loader_lock);
			return -EBUSY;
		}
	}

	device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
		      NULL, s->name+6);
	return s->unit_minor;

fail:
	kfree(s);
	return r;
}