Example #1
0
static int bma250_power_up(struct driver_data *dd)
{
    int                 rc;

    mutex_lock(&bma250_power_lock);

    rc = bma250_hw_setup(dd);
    if (rc)
        goto hw_setup_error;
    rc = bma250_ic_write(dd->ic_dev, BMA250_RESET_REG, BMA250_RESET);
    if (rc)
        goto power_up_error;

    msleep(4);
    rc = bma250_ic_write(dd->ic_dev, BMA250_MODE_CTRL_REG,
                         BMA250_MODE_NOSLEEP);
    if (rc)
        goto power_up_error;

    dd->power = true;
    mutex_unlock(&bma250_power_lock);
    return rc;

power_up_error:
    bma250_hw_shutdown(dd);
hw_setup_error:
    dd->power = false;
    mutex_unlock(&bma250_power_lock);
    return rc;
}
Example #2
0
static int v4l2_flash_close(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{
	struct v4l2_flash *v4l2_flash = v4l2_subdev_to_v4l2_flash(sd);
	struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev;
	struct led_classdev *led_cdev = fled_cdev ? &fled_cdev->led_cdev : NULL;
	struct led_classdev *led_cdev_ind = v4l2_flash->iled_cdev;
	int ret = 0;

	if (!v4l2_fh_is_singular(&fh->vfh))
		return 0;

	if (led_cdev) {
		mutex_lock(&led_cdev->led_access);

		if (v4l2_flash->ctrls[STROBE_SOURCE])
			ret = v4l2_ctrl_s_ctrl(
				v4l2_flash->ctrls[STROBE_SOURCE],
				V4L2_FLASH_STROBE_SOURCE_SOFTWARE);
		led_sysfs_enable(led_cdev);

		mutex_unlock(&led_cdev->led_access);
	}

	if (led_cdev_ind) {
		mutex_lock(&led_cdev_ind->led_access);
		led_sysfs_enable(led_cdev_ind);
		mutex_unlock(&led_cdev_ind->led_access);
	}

	return ret;
}
Example #3
0
/*
 * Add a reference to the global map of cpus to pools (and
 * vice versa).  Initialise the map if we're the first user.
 * Returns the number of pools.
 */
unsigned int
svc_pool_map_get(void)
{
	struct svc_pool_map *m = &svc_pool_map;
	int npools = -1;

	mutex_lock(&svc_pool_map_mutex);

	if (m->count++) {
		mutex_unlock(&svc_pool_map_mutex);
		return m->npools;
	}

	if (m->mode == SVC_POOL_AUTO)
		m->mode = svc_pool_map_choose_mode();

	switch (m->mode) {
	case SVC_POOL_PERCPU:
		npools = svc_pool_map_init_percpu(m);
		break;
	case SVC_POOL_PERNODE:
		npools = svc_pool_map_init_pernode(m);
		break;
	}

	if (npools < 0) {
		/* default, or memory allocation failure */
		npools = 1;
		m->mode = SVC_POOL_GLOBAL;
	}
	m->npools = npools;

	mutex_unlock(&svc_pool_map_mutex);
	return m->npools;
}
Example #4
0
int mtrr_add_page(unsigned long base, unsigned long size, 
		  unsigned int type, char increment)
{
	int error;
	dom0_op_t op;

	mutex_lock(&mtrr_mutex);

	op.cmd = DOM0_ADD_MEMTYPE;
	op.u.add_memtype.mfn     = base;
	op.u.add_memtype.nr_mfns = size;
	op.u.add_memtype.type    = type;
	error = HYPERVISOR_dom0_op(&op);
	if (error) {
		mutex_unlock(&mtrr_mutex);
		BUG_ON(error > 0);
		return error;
	}

	if (increment)
		++usage_table[op.u.add_memtype.reg];

	mutex_unlock(&mtrr_mutex);

	return op.u.add_memtype.reg;
}
Example #5
0
/*
 * Finish the current sequence due to disconnect.
 * See mdc_import_event()
 */
void seq_client_flush(struct lu_client_seq *seq)
{
	wait_queue_t link;

	LASSERT(seq != NULL);
	init_waitqueue_entry(&link, current);
	mutex_lock(&seq->lcs_mutex);

	while (seq->lcs_update) {
		add_wait_queue(&seq->lcs_waitq, &link);
		set_current_state(TASK_UNINTERRUPTIBLE);
		mutex_unlock(&seq->lcs_mutex);

		schedule();

		mutex_lock(&seq->lcs_mutex);
		remove_wait_queue(&seq->lcs_waitq, &link);
		set_current_state(TASK_RUNNING);
	}

        fid_zero(&seq->lcs_fid);
        /**
         * this id shld not be used for seq range allocation.
         * set to -1 for dgb check.
         */

        seq->lcs_space.lsr_index = -1;

	lu_seq_range_init(&seq->lcs_space);
	mutex_unlock(&seq->lcs_mutex);
}
Example #6
0
void
acpi_processor_unregister_performance(struct acpi_processor_performance
				      *performance, unsigned int cpu)
{
	struct acpi_processor *pr;


	mutex_lock(&performance_mutex);

	pr = processors[cpu];
	if (!pr) {
		mutex_unlock(&performance_mutex);
		return;
	}

	if (pr->performance)
		kfree(pr->performance->states);
	pr->performance = NULL;

	acpi_cpufreq_remove_file(pr);

	mutex_unlock(&performance_mutex);

	return;
}
Example #7
0
static ssize_t secvib_read(struct file *file,
		char __user *buf, size_t count, loff_t *ppos)
{

	int ret;
	struct secvib_data *secvib =
		container_of(file->private_data, struct secvib_data, miscdev);
	const size_t bufsize = (secvib->dev_name_size > (size_t)(*ppos))
		? min(count, secvib->dev_name_size - (size_t)(*ppos)) : 0;

	pr_debug("secvib: %s[%d]\n", __func__, __LINE__);

	/* End of buffer, exit */
	if (unlikely(bufsize == 0))
		return 0;

	mutex_lock(&secvib->lock);
	ret = copy_to_user(buf, secvib->dev_name + (*ppos), bufsize);
	if (unlikely(ret != 0)) {
		pr_err("secvib: read failed\n");
		mutex_unlock(&secvib->lock);
		return 0;
	}

	/* Update file position and return copied buffer size */
	*ppos += bufsize;

	mutex_unlock(&secvib->lock);

	return bufsize;

}
static void hsic_aux_work(struct work_struct *work)
{
	dev_dbg(&pci_dev->dev,
		"%s---->\n", __func__);
	mutex_lock(&hsic.hsic_mutex);
	if ((!hsic.rh_dev) || (hsic_enable == 0)) {
		dev_dbg(&pci_dev->dev,
			"root hub is already removed\n");
		mutex_unlock(&hsic.hsic_mutex);
		return;
	}

	if (hsic.port_disconnect == 0)
		hsic_port_logical_disconnect(hsic.rh_dev,
				HSIC_USH_PORT);
	else
		ush_hsic_port_disable();
	usleep_range(hsic.reenumeration_delay,
			hsic.reenumeration_delay + 1000);
	ush_hsic_port_enable();
	mutex_unlock(&hsic.hsic_mutex);

	hsic.hsic_aux_finish = 1;
	wake_up(&hsic.aux_wq);
	dev_dbg(&pci_dev->dev,
		"%s<----\n", __func__);
	return;
}
/**
 *	usb_tranzport_disconnect
 *
 *	Called by the usb core when the device is removed from the system.
 */
static void usb_tranzport_disconnect(struct usb_interface *intf)
{
	struct usb_tranzport *dev;
	int minor;
	mutex_lock(&disconnect_mutex);
	dev = usb_get_intfdata(intf);
	usb_set_intfdata(intf, NULL);
	mutex_lock(&dev->mtx);
	minor = intf->minor;
	/* give back our minor */
	usb_deregister_dev(intf, &usb_tranzport_class);

	/* if the device is not opened, then we clean up right now */
	if (!dev->open_count) {
		mutex_unlock(&dev->mtx);
		usb_tranzport_delete(dev);
	} else {
		dev->intf = NULL;
		mutex_unlock(&dev->mtx);
	}

	mutex_unlock(&disconnect_mutex);

	dev_info(&intf->dev, "Tranzport Surface #%d now disconnected\n",
		(minor - USB_TRANZPORT_MINOR_BASE));
}
Example #10
0
int snd_add_device_sysfs_file(int type, struct snd_card *card, int dev,
                              struct device_attribute *attr)
{
        int cardnum, minor, ret = -EINVAL;
        struct device *d;
	struct snd_minor *mptr;

	cardnum = card ? card->number : -1;
        mutex_lock(&sound_mutex);
	for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor)
		if ((mptr = snd_minors[minor]) != NULL &&
		    mptr->type == type &&
		    mptr->card == cardnum &&
		    mptr->device == dev)
			break;
	if (minor == ARRAY_SIZE(snd_minors)) {
		mutex_unlock(&sound_mutex);
		return -EINVAL;
	}
        if (minor >= 0 && (d = snd_minors[minor]->dev) != NULL)
                ret = device_create_file(d, attr);
        mutex_unlock(&sound_mutex);
        return ret;

}
Example #11
0
static int autofs_dev_ioctl_setpipefd(struct file *fp,
				      struct autofs_sb_info *sbi,
				      struct autofs_dev_ioctl *param)
{
	int pipefd;
	int err = 0;

	if (param->setpipefd.pipefd == -1)
		return -EINVAL;

	pipefd = param->setpipefd.pipefd;

	mutex_lock(&sbi->wq_mutex);
	if (!sbi->catatonic) {
		mutex_unlock(&sbi->wq_mutex);
		return -EBUSY;
	} else {
		struct file *pipe = fget(pipefd);
		if (!pipe->f_op || !pipe->f_op->write) {
			err = -EPIPE;
			fput(pipe);
			goto out;
		}
		sbi->oz_pgrp = task_pgrp_nr(current);
		sbi->pipefd = pipefd;
		sbi->pipe = pipe;
		sbi->catatonic = 0;
	}
out:
	mutex_unlock(&sbi->wq_mutex);
	return err;
}
Example #12
0
/**
 * snd_unregister_device - unregister the device on the given card
 * @type: the device type, SNDRV_DEVICE_TYPE_XXX
 * @card: the card instance
 * @dev: the device index
 *
 * Unregisters the device file already registered via
 * snd_register_device().
 *
 * Returns zero if sucecessful, or a negative error code on failure
 */
int snd_unregister_device(int type, struct snd_card *card, int dev)
{
	int cardnum, minor;
	struct snd_minor *mptr;

	cardnum = card ? card->number : -1;
	mutex_lock(&sound_mutex);
	for (minor = 0; minor < ARRAY_SIZE(snd_minors); ++minor)
		if ((mptr = snd_minors[minor]) != NULL &&
		    mptr->type == type &&
		    mptr->card == cardnum &&
		    mptr->device == dev)
			break;
	if (minor == ARRAY_SIZE(snd_minors)) {
		mutex_unlock(&sound_mutex);
		return -EINVAL;
	}

	class_device_destroy(sound_class, MKDEV(major, minor));

	snd_minors[minor] = NULL;
	mutex_unlock(&sound_mutex);
	kfree(mptr);
	return 0;
}
Example #13
0
static void reduce_bus_freq_handler(struct work_struct *work)
{
	mutex_lock(&bus_freq_mutex);

	if (!low_freq_bus_used()) {
		mutex_unlock(&bus_freq_mutex);
		return;
	}
	/* If we are already in audio bus freq mode,
	  * just return if lp_audio_freq is true.
	  */
	if (audio_bus_freq_mode && lp_audio_freq) {
		mutex_unlock(&bus_freq_mutex);
		return;
	}

	/* If we dont want to transition from low bus to
	  * audio bus mode and are already in
	  *low bus mode, then return.
	  */
	if (!lp_audio_freq && low_bus_freq_mode) {
		mutex_unlock(&bus_freq_mutex);
		return;
	}
	reduce_bus_freq();

	mutex_unlock(&bus_freq_mutex);
}
Example #14
0
static int isp_video_release(struct file *file)
{
	struct fimc_isp *isp = video_drvdata(file);
	struct fimc_is_video *ivc = &isp->video_capture;
	struct media_entity *entity = &ivc->ve.vdev.entity;
	struct media_device *mdev = entity->graph_obj.mdev;

	mutex_lock(&isp->video_lock);

	if (v4l2_fh_is_singular_file(file) && ivc->streaming) {
		media_entity_pipeline_stop(entity);
		ivc->streaming = 0;
	}

	vb2_fop_release(file);

	if (v4l2_fh_is_singular_file(file)) {
		fimc_pipeline_call(&ivc->ve, close);

		mutex_lock(&mdev->graph_mutex);
		entity->use_count--;
		mutex_unlock(&mdev->graph_mutex);
	}

	pm_runtime_put(&isp->pdev->dev);
	mutex_unlock(&isp->video_lock);

	return 0;
}
Example #15
0
static int vocpcm_open(struct inode *inode, struct file *file)
{
    struct voc_rpc *voc_rpc = &the_voc_proc;
    struct voc_ctxt *ctxt = voc_minor_to_ctxt(MINOR(inode->i_rdev));
    int rc = 0;

    if (!ctxt) {
        pr_err("unknown voc misc %d\n", MINOR(inode->i_rdev));
        return -ENODEV;
    }

    mutex_lock(&voc_rpc->lock);
    if (voc_rpc->inited == 0) {
        voc_rpc->ept = create_rpc_connect(RPC_SND_PROG, RPC_SND_VERS,
                                          MSM_RPC_UNINTERRUPTIBLE |
                                          MSM_RPC_ENABLE_RECEIVE);
        if (IS_ERR(voc_rpc->ept)) {
            rc = PTR_ERR(voc_rpc->ept);
            voc_rpc->ept = NULL;
            pr_err("vocpcm: failed to connect snd svc\n");
            return rc;
        }

        voc_rpc->task = create_snd_rpc_kthread();
        if (IS_ERR(voc_rpc->task)) {
            rc = PTR_ERR(voc_rpc->task);
            voc_rpc->task = NULL;
            msm_rpc_close(voc_rpc->ept);
            voc_rpc->ept = NULL;
            return rc;
        }
        voc_rpc->inited = 1;
    }
    mutex_unlock(&voc_rpc->lock);

    mutex_lock(&ctxt->lock);
    if (ctxt->opened) {
        pr_err("vocpcm already opened.\n");
        rc = -EBUSY;
        goto err;
    }

    file->private_data = ctxt;
    ctxt->head = 0;
    ctxt->tail = 0;
    ctxt->client = 0;

    memset(ctxt->buf[0].data, 0, sizeof(ctxt->buf[0].data));
    memset(ctxt->buf[1].data, 0, sizeof(ctxt->buf[1].data));
    ctxt->buf[0].index = 0;
    ctxt->buf[1].index = 0;
    ctxt->opened = 1;
    ctxt->count = 0;
    ctxt->s_ptr = 0;
    ctxt->final_input = 0;

err:
    mutex_unlock(&ctxt->lock);
    return rc;
}
Example #16
0
static struct aa_ns *__aa_create_ns(struct aa_ns *parent, const char *name,
				    struct dentry *dir)
{
	struct aa_ns *ns;
	int error;

	AA_BUG(!parent);
	AA_BUG(!name);
	AA_BUG(!mutex_is_locked(&parent->lock));

	ns = alloc_ns(parent->base.hname, name);
	if (!ns)
		return NULL;
	mutex_lock(&ns->lock);
	error = __aa_fs_ns_mkdir(ns, ns_subns_dir(parent), name);
	if (error) {
		AA_ERROR("Failed to create interface for ns %s\n",
			 ns->base.name);
		mutex_unlock(&ns->lock);
		aa_free_ns(ns);
		return ERR_PTR(error);
	}
	ns->parent = aa_get_ns(parent);
	ns->level = parent->level + 1;
	list_add_rcu(&ns->base.list, &parent->sub_ns);
	/* add list ref */
	aa_get_ns(ns);
	mutex_unlock(&ns->lock);

	return ns;
}
Example #17
0
static int __init
register_device(void)
{
    int rc;

    mutex_lock(&register_mutex);
    if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER,
                                      NULL, 0,
                                      &seq_oss_f_ops, NULL,
                                      SNDRV_SEQ_OSS_DEVNAME)) < 0) {
        snd_printk(KERN_ERR "can't register device seq\n");
        mutex_unlock(&register_mutex);
        return rc;
    }
    if ((rc = snd_register_oss_device(SNDRV_OSS_DEVICE_TYPE_MUSIC,
                                      NULL, 0,
                                      &seq_oss_f_ops, NULL,
                                      SNDRV_SEQ_OSS_DEVNAME)) < 0) {
        snd_printk(KERN_ERR "can't register device music\n");
        snd_unregister_oss_device(SNDRV_OSS_DEVICE_TYPE_SEQUENCER, NULL, 0);
        mutex_unlock(&register_mutex);
        return rc;
    }
    debug_printk(("device registered\n"));
    mutex_unlock(&register_mutex);
    return 0;
}
Example #18
0
static void
journal_ix_writelock(journal_ix *jix)
{
#if DEBUG_JOURNAL
    log_debug("journal_ix_writelock: locking");
#endif

    for(;;)
    {
        mutex_lock(&journal_ix_mtx);

        u8 f = jix->flags;
        
        if(f == LOCK_NONE)              // nobody has the lock
        {
            jix->flags = LOCK_WRITE;    // so one writer can

            mutex_unlock(&journal_ix_mtx);
            break;
        }

        mutex_unlock(&journal_ix_mtx);

        usleep(1000);
    }
    
#if DEBUG_JOURNAL
    log_debug("journal_ix_writelock: locked");
#endif

}
Example #19
0
/*
 * Disable the resource.
 * The function returns with error or the content of the register
 */
int twl4030_audio_disable_resource(enum twl4030_audio_res id)
{
	struct twl4030_audio *audio = platform_get_drvdata(twl4030_audio_dev);
	int val;

	if (id >= TWL4030_AUDIO_RES_MAX) {
		dev_err(&twl4030_audio_dev->dev,
				"Invalid resource ID (%u)\n", id);
		return -EINVAL;
	}

	mutex_lock(&audio->mutex);
	if (!audio->resource[id].request_count) {
		dev_err(&twl4030_audio_dev->dev,
			"Resource has been disabled already (%u)\n", id);
		mutex_unlock(&audio->mutex);
		return -EPERM;
	}
	audio->resource[id].request_count--;

	if (!audio->resource[id].request_count)
		/* Resource can be disabled now */
		val = twl4030_audio_set_resource(id, 0);
	else
		val = twl4030_audio_get_resource(id);

	mutex_unlock(&audio->mutex);

	return val;
}
Example #20
0
static void
journal_ix_writeunlock(journal_ix *jix)
{
#if DEBUG_JOURNAL
    log_debug("journal_ix_writeunlock: unlocking");
#endif

    mutex_lock(&journal_ix_mtx);
    
    if(jix->flags == LOCK_WRITE)    // the writer has the lock (hopefully this one)
    {
        jix->flags = LOCK_NONE;     // so we can unlock
        
        mutex_unlock(&journal_ix_mtx);
    
#if DEBUG_JOURNAL
        log_debug("journal_ix_writeunlock: unlocked");
#endif
    }
    else // else there is something really wrong happening
    {
        // bug
        log_err("journal: ix: write-unlock non-writer");
        
        mutex_unlock(&journal_ix_mtx);
        return;
    }
}
Example #21
0
void smscconn_shutdown(SMSCConn *conn, int finish_sending)
{
    gw_assert(conn != NULL);
    mutex_lock(conn->flow_mutex);
    if (conn->status == SMSCCONN_DEAD) {
	mutex_unlock(conn->flow_mutex);
	return;
    }

    /* Call SMSC specific destroyer */
    if (conn->shutdown) {
        /* 
         * we must unlock here, because module manipulate their state
         * and will try to lock this mutex.Otherwise we have deadlock!
         */
        mutex_unlock(conn->flow_mutex);
	conn->shutdown(conn, finish_sending);
    }
    else {
	conn->why_killed = SMSCCONN_KILLED_SHUTDOWN;
        mutex_unlock(conn->flow_mutex);
    }

    return;
}
Example #22
0
static void
journal_ix_readlock(journal_ix *jix)
{
    /*
    jix->rc++;
    */
    for(;;)
    {
        mutex_lock(&journal_ix_mtx);

        u8 f = jix->flags;

        if(f != LOCK_WRITE)             // either nobody or the reader has the lock 
        {
            jix->flags = LOCK_READ;
            jix->read_lock_count++;     // count the readers
            mutex_unlock(&journal_ix_mtx);
            break;
        }

        mutex_unlock(&journal_ix_mtx);

        usleep(1000);
    }
}
Example #23
0
/* Request sequence-controller node to allocate new super-sequence. */
int seq_client_alloc_super(struct lu_client_seq *seq,
                           const struct lu_env *env)
{
        int rc;
        ENTRY;

	mutex_lock(&seq->lcs_mutex);

        if (seq->lcs_srv) {
#ifdef HAVE_SEQ_SERVER
                LASSERT(env != NULL);
                rc = seq_server_alloc_super(seq->lcs_srv, &seq->lcs_space,
                                            env);
#else
		rc = 0;
#endif
	} else {
		/* Check whether the connection to seq controller has been
		 * setup (lcs_exp != NULL) */
		if (seq->lcs_exp == NULL) {
			mutex_unlock(&seq->lcs_mutex);
			RETURN(-EINPROGRESS);
		}

		rc = seq_client_rpc(seq, &seq->lcs_space,
                                    SEQ_ALLOC_SUPER, "super");
        }
	mutex_unlock(&seq->lcs_mutex);
        RETURN(rc);
}
Example #24
0
static void
journal_ix_readunlock(journal_ix *jix)
{
    mutex_lock(&journal_ix_mtx);
    
    if(jix->flags == LOCK_READ)     // a reader has the lock
    {
        if((--jix->read_lock_count) == 0) // count the readers
        {
            jix->flags = LOCK_NONE; // if there are no readers anymore, nobody has the lock
        }
        
        mutex_unlock(&journal_ix_mtx);
    }
    else   
    {
        mutex_unlock(&journal_ix_mtx);
        
        // bug
        log_err("journal: ix: read-unlock non-reader");
    }

    /*
    jix->rc--;
    */
}
Example #25
0
static int dvb_device_open(struct inode *inode, struct file *file)
{
	struct dvb_device *dvbdev;

	mutex_lock(&dvbdev_mutex);
	down_read(&minor_rwsem);
	dvbdev = dvb_minors[iminor(inode)];

	if (dvbdev && dvbdev->fops) {
		int err = 0;
		const struct file_operations *new_fops;

		new_fops = fops_get(dvbdev->fops);
		if (!new_fops)
			goto fail;
		file->private_data = dvbdev;
		replace_fops(file, new_fops);
		if (file->f_op->open)
			err = file->f_op->open(inode, file);
		up_read(&minor_rwsem);
		mutex_unlock(&dvbdev_mutex);
		return err;
	}
fail:
	up_read(&minor_rwsem);
	mutex_unlock(&dvbdev_mutex);
	return -ENODEV;
}
Example #26
0
static ssize_t qmi_read(struct file *fp, char __user *buf,
                        size_t count, loff_t *pos)
{
    struct qmi_ctxt *ctxt = fp->private_data;
    char msg[256];
    int len;
    int r;

    mutex_lock(&ctxt->lock);
    for (;;) {
        if (ctxt->state_dirty) {
            ctxt->state_dirty = 0;
            len = qmi_print_state(ctxt, msg, 256);
            break;
        }
        mutex_unlock(&ctxt->lock);
        r = wait_event_interruptible(qmi_wait_queue, ctxt->state_dirty);
        if (r < 0)
            return r;
        mutex_lock(&ctxt->lock);
    }
    mutex_unlock(&ctxt->lock);

    if (len > count)
        len = count;

    if (copy_to_user(buf, msg, len))
        return -EFAULT;

    return len;
}
static int __rmnet_open(struct net_device *dev)
{
	int r;
	void *pil;
	struct rmnet_private *p = netdev_priv(dev);

	mutex_lock(&p->pil_lock);
	if (!p->pil) {
		pil = msm_rmnet_load_modem(dev);
		if (IS_ERR(pil)) {
			mutex_unlock(&p->pil_lock);
			return PTR_ERR(pil);
		}
		p->pil = pil;
	}
	mutex_unlock(&p->pil_lock);

	if (!p->ch) {
		r = smd_open(p->chname, &p->ch, dev, smd_net_notify);

		if (r < 0)
			return -ENODEV;
	}

	smd_disable_read_intr(p->ch);
	return 0;
}
  int psb_dpst_bl(struct drm_device *dev, void *data)
{
	struct drm_psb_private *dev_priv = psb_priv(dev);
	uint32_t * arg = data;
	struct backlight_device *bd;

	bd = psb_get_backlight_device();
	if(!dev_priv)
		return 0;

	if(dev_priv->early_suspended)
		return 0;

	dpst_print("adjust percentage: %d.%d\n", *arg / 100, *arg % 100);
	dev_priv->blc_adj2 = (*arg * 255 / 100) * 255 / 100;

#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
	mutex_lock(&bd->ops_lock);
	bd->props.brightness = psb_get_brightness(bd);
	if ( 0 == bd->props.brightness)
	{
	    mutex_unlock(&bd->ops_lock);
	    return 0;
	}
	psb_set_brightness(bd);
	mutex_unlock(&bd->ops_lock);
#endif				/*  */
	    return 0;
}
static ssize_t kgsl_reg_read(struct kgsl_device *device, int count,
	reg_read_init_t reg_read_init,
	reg_read_fill_t reg_read_fill, const char *prefix, char __user *buff,
	loff_t *ppos)
{
	int i, remaining;
	const int rowc = 8;

	if (!ppos || *ppos || !device)
		return 0;

	mutex_lock(&device->mutex);
	reg_read_init(device);
	remaining = count;
	for (i = 0; i < count; i += rowc) {
		unsigned int vals[rowc];
		int ss;
		int linec = min(remaining, rowc);
		remaining -= rowc;

		reg_read_fill(device, i, vals, linec);
		ss = kgsl_hex_dump(prefix, i, (uint8_t *)vals, rowc*4, linec*4,
			buff);
		if (ss < 0) {
			mutex_unlock(&device->mutex);
			return ss;
		}
		buff += ss;
		*ppos += ss;
	}
	mutex_unlock(&device->mutex);

	return *ppos;
}
Example #30
0
static int sst_byt_pcm_open(struct snd_pcm_substream *substream)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;
	struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
	struct sst_byt_priv_data *pdata = snd_soc_component_get_drvdata(component);
	struct sst_byt_pcm_data *pcm_data = &pdata->pcm[substream->stream];
	struct sst_byt *byt = pdata->byt;

	dev_dbg(rtd->dev, "PCM: open\n");

	mutex_lock(&pcm_data->mutex);

	pcm_data->substream = substream;

	snd_soc_set_runtime_hwparams(substream, &sst_byt_pcm_hardware);

	pcm_data->stream = sst_byt_stream_new(byt, substream->stream + 1,
					      byt_notify_pointer, pcm_data);
	if (pcm_data->stream == NULL) {
		dev_err(rtd->dev, "failed to create stream\n");
		mutex_unlock(&pcm_data->mutex);
		return -EINVAL;
	}

	mutex_unlock(&pcm_data->mutex);
	return 0;
}