int init_display_pm(struct display_driver *dispdrv)
{
	init_display_pm_status(dispdrv);

	spin_lock_init(&dispdrv->pm_status.slock);
	mutex_init(&dispdrv->pm_status.pm_lock);
	mutex_init(&dispdrv->pm_status.clk_lock);
#ifdef CONFIG_FB_HIBERNATION_DISPLAY
	set_default_hibernation_mode(dispdrv);
#else
	dispdrv->pm_status.clock_gating_on = false;
	dispdrv->pm_status.power_gating_on = false;
	dispdrv->pm_status.hotplug_gating_on = false;
#endif

	init_kthread_worker(&dispdrv->pm_status.control_clock_gating);

	dispdrv->pm_status.control_clock_gating_thread = kthread_run(kthread_worker_fn,
			&dispdrv->pm_status.control_clock_gating,
			"decon_clk_thread");
	if (IS_ERR(dispdrv->pm_status.control_clock_gating_thread)) {
		int err = PTR_ERR(dispdrv->pm_status.control_clock_gating_thread);
		dispdrv->pm_status.control_clock_gating_thread = NULL;

		pr_err("failed to run control_clock_gating_thread\n");
		return err;
	}
	init_kthread_work(&dispdrv->pm_status.control_clock_gating_work,
		decon_clock_gating_handler);

	init_kthread_worker(&dispdrv->pm_status.control_power_gating);

	dispdrv->pm_status.control_power_gating_thread = kthread_run(kthread_worker_fn,
			&dispdrv->pm_status.control_power_gating,
			"decon_power_thread");
	if (IS_ERR(dispdrv->pm_status.control_power_gating_thread)) {
		int err = PTR_ERR(dispdrv->pm_status.control_power_gating_thread);
		dispdrv->pm_status.control_power_gating_thread = NULL;

		pr_err("failed to run control_power_gating_thread\n");
		return err;
	}
	init_kthread_work(&dispdrv->pm_status.control_power_gating_work,
		decon_power_gating_handler);

#ifdef CONFIG_FB_HIBERNATION_DISPLAY
	dispdrv->pm_status.ops = &display_block_ops;
	dispdrv->decon_driver.ops = &decon_pm_ops;
	dispdrv->dsi_driver.ops = &dsi_pm_ops;
#ifdef CONFIG_DECON_MIC
	dispdrv->mic_driver.ops = &mic_pm_ops;
#endif
#endif
	return 0;
}
Пример #2
0
static struct mcuio_soft_hc *__setup_shc(const struct mcuio_soft_hc_ops *ops,
					 void *priv)
{
	struct mcuio_soft_hc *shc = kzalloc(sizeof(*shc), GFP_KERNEL);
	if (!shc)
		return ERR_PTR(-ENOMEM);
	init_kthread_worker(&shc->irq_kworker);
	shc->irq_kworker_task = kthread_run(kthread_worker_fn,
					    &shc->irq_kworker,
					    "shc_irq");
	if (IS_ERR(shc->irq_kworker_task)) {
		pr_err("failed to create irq tsk for shc\n");
		return ERR_PTR(PTR_ERR(shc->irq_kworker_task));
	}
	init_kthread_work(&shc->do_irq, __do_irq);
	shc->ops = ops;
	shc->priv = priv;
	shc->rx_circ_buf.head = shc->rx_circ_buf.tail = 0;
	shc->rx_circ_buf.buf = shc->rx_buf;
	shc->chip.name = "MCUIO-SHC";
	shc->chip.irq_mask = mcuio_soft_hc_irq_mask;
	shc->chip.irq_unmask = mcuio_soft_hc_irq_unmask;
	shc->irqno = irq_alloc_desc(0);
	irq_set_chip(shc->irqno, &shc->chip);
	irq_set_handler(shc->irqno, &handle_simple_irq);
	irq_modify_status(shc->irqno,
			  IRQ_NOREQUEST | IRQ_NOAUTOEN,
			  IRQ_NOPROBE);
	return shc;
}
Пример #3
0
/**
 * rvt_driver_cq_init - Init cq resources on behalf of driver
 * @rdi: rvt dev structure
 *
 * Return: 0 on success
 */
int rvt_driver_cq_init(struct rvt_dev_info *rdi)
{
	int ret = 0;
	int cpu;
	struct task_struct *task;

	if (rdi->worker)
		return 0;
	spin_lock_init(&rdi->n_cqs_lock);
	rdi->worker = kzalloc(sizeof(*rdi->worker), GFP_KERNEL);
	if (!rdi->worker)
		return -ENOMEM;
	init_kthread_worker(rdi->worker);
	task = kthread_create_on_node(
		kthread_worker_fn,
		rdi->worker,
		rdi->dparms.node,
		"%s", rdi->dparms.cq_name);
	if (IS_ERR(task)) {
		kfree(rdi->worker);
		rdi->worker = NULL;
		return PTR_ERR(task);
	}

	set_user_nice(task, MIN_NICE);
	cpu = cpumask_first(cpumask_of_node(rdi->dparms.node));
	kthread_bind(task, cpu);
	wake_up_process(task);
	return ret;
}
Пример #4
0
/*
 * Fully initialize a .request_fn request-based queue.
 */
int dm_old_init_request_queue(struct mapped_device *md)
{
	/* Fully initialize the queue */
	if (!blk_init_allocated_queue(md->queue, dm_old_request_fn, NULL))
		return -EINVAL;

	/* disable dm_old_request_fn's merge heuristic by default */
	md->seq_rq_merge_deadline_usecs = 0;

	dm_init_normal_md_queue(md);
	blk_queue_softirq_done(md->queue, dm_softirq_done);
	blk_queue_prep_rq(md->queue, dm_old_prep_fn);

	/* Initialize the request-based DM worker thread */
	init_kthread_worker(&md->kworker);
	md->kworker_task = kthread_run(kthread_worker_fn, &md->kworker,
				       "kdmwork-%s", dm_device_name(md));

	elv_register_queue(md->queue);

	return 0;
}
Пример #5
0
static int __devinit bq2419x_probe(struct i2c_client *client,
				const struct i2c_device_id *id)
{
	struct bq2419x_chip *bq2419x;
	struct bq2419x_platform_data *pdata;
	int ret = 0;

	pdata = client->dev.platform_data;
	if (!pdata) {
		dev_err(&client->dev, "No Platform data");
		return -EINVAL;
	}

	bq2419x = devm_kzalloc(&client->dev, sizeof(*bq2419x), GFP_KERNEL);
	if (!bq2419x) {
		dev_err(&client->dev, "Memory allocation failed\n");
		return -ENOMEM;
	}

	bq2419x->regmap = devm_regmap_init_i2c(client, &bq2419x_regmap_config);
	if (IS_ERR(bq2419x->regmap)) {
		ret = PTR_ERR(bq2419x->regmap);
		dev_err(&client->dev, "regmap init failed with err %d\n", ret);
		return ret;
	}

	bq2419x->dev = &client->dev;

	if (pdata->bcharger_pdata) {
		bq2419x->update_status	= pdata->bcharger_pdata->update_status;
		bq2419x->rtc_alarm_time	= pdata->bcharger_pdata->rtc_alarm_time;
		bq2419x->wdt_time_sec	= pdata->bcharger_pdata->wdt_timeout;
		bq2419x->chg_restart_time =
					pdata->bcharger_pdata->chg_restart_time;
		bq2419x->chg_enable	= true;
	}

	bq2419x->wdt_refresh_timeout = 25;
	i2c_set_clientdata(client, bq2419x);
	bq2419x->irq = client->irq;

	if (bq2419x->rtc_alarm_time)
		bq2419x->rtc = alarmtimer_get_rtcdev();

	mutex_init(&bq2419x->mutex);
	bq2419x->suspended = 0;
	bq2419x->chg_restart_timeout = 0;

	ret = bq2419x_show_chip_version(bq2419x);
	if (ret < 0) {
		dev_err(&client->dev, "version read failed %d\n", ret);
		return ret;
	}

	ret = bq2419x_charger_init(bq2419x);
	if (ret < 0) {
		dev_err(bq2419x->dev, "Charger init failed: %d\n", ret);
		return ret;
	}

	ret = bq2419x_init_charger_regulator(bq2419x, pdata);
	if (ret < 0) {
		dev_err(&client->dev,
			"Charger regualtor init failed %d\n", ret);
		return ret;
	}

	ret = bq2419x_init_vbus_regulator(bq2419x, pdata);
	if (ret < 0) {
		dev_err(&client->dev,
			"VBUS regualtor init failed %d\n", ret);
		goto scrub_chg_reg;
	}

	init_kthread_worker(&bq2419x->bq_kworker);
	bq2419x->bq_kworker_task = kthread_run(kthread_worker_fn,
				&bq2419x->bq_kworker,
				dev_name(bq2419x->dev));
	if (IS_ERR(bq2419x->bq_kworker_task)) {
		ret = PTR_ERR(bq2419x->bq_kworker_task);
		dev_err(&client->dev, "Kworker task creation failed %d\n", ret);
		goto scrub_vbus_reg;
	}

	init_kthread_work(&bq2419x->bq_wdt_work, bq2419x_work_thread);
	sched_setscheduler(bq2419x->bq_kworker_task,
			SCHED_FIFO, &bq2419x_param);
	queue_kthread_work(&bq2419x->bq_kworker, &bq2419x->bq_wdt_work);

	ret = bq2419x_watchdog_init(bq2419x, bq2419x->wdt_time_sec, "PROBE");
	if (ret < 0) {
		dev_err(bq2419x->dev, "BQWDT init failed %d\n", ret);
		goto scrub_kthread;
	}

	ret = bq2419x_fault_clear_sts(bq2419x);
	if (ret < 0) {
		dev_err(bq2419x->dev, "fault clear status failed %d\n", ret);
		goto scrub_kthread;
	}

	ret = request_threaded_irq(bq2419x->irq, NULL,
		bq2419x_irq, IRQF_TRIGGER_FALLING,
			dev_name(bq2419x->dev), bq2419x);
	if (ret < 0) {
		dev_err(bq2419x->dev, "request IRQ %d fail, err = %d\n",
				bq2419x->irq, ret);
		goto scrub_kthread;
	}

	/* enable charging */
	ret = bq2419x_charger_enable(bq2419x);
	if (ret < 0)
		goto scrub_irq;

	return 0;
scrub_irq:
	free_irq(bq2419x->irq, bq2419x);
scrub_kthread:
	bq2419x->stop_thread = true;
	flush_kthread_worker(&bq2419x->bq_kworker);
	kthread_stop(bq2419x->bq_kworker_task);
scrub_vbus_reg:
	regulator_unregister(bq2419x->vbus_rdev);
scrub_chg_reg:
	regulator_unregister(bq2419x->chg_rdev);
	mutex_destroy(&bq2419x->mutex);
	return ret;
}
int fimc_is_lib_vra_init_task(struct fimc_is_lib_vra *lib_vra)
{
	s32 ret = 0, cnt = 0;
	struct sched_param param = {.sched_priority = 0};

	if (unlikely(!lib_vra)) {
		err_lib("VRA library is NULL");
		return -EINVAL;
	}

	spin_lock_init(&lib_vra->task_vra.work_lock);
	init_kthread_worker(&lib_vra->task_vra.worker);

	lib_vra->task_vra.task = kthread_run(kthread_worker_fn,
		&lib_vra->task_vra.worker, "fimc_is_lib_vra");
	if (unlikely(!lib_vra->task_vra.task)) {
		err_lib("failed to create VRA task");
		return -ENOMEM;
	}

	ret = sched_setscheduler_nocheck(lib_vra->task_vra.task,
		SCHED_NORMAL, &param);
	if (ret) {
		err("sched_setscheduler_nocheck is fail(%d)", ret);
		return ret;
	}

	lib_vra->task_vra.work_index = 0;

	for (cnt = 0; cnt < FIMC_IS_MAX_TASK; cnt++) {
		lib_vra->task_vra.work[cnt].func = NULL;
		lib_vra->task_vra.work[cnt].params = NULL;
		init_kthread_work(&lib_vra->task_vra.work[cnt].work,
			fimc_is_lib_vra_task_work);
	}

	return 0;
}

void fimc_is_lib_vra_control_set_event(u32 event_type)
{
	int ret;
	struct fimc_is_lib_vra *lib_vra;

	if (unlikely(!g_lib_vra)) {
		err_lib("VRA library is NULL");
		return;
	}

	lib_vra = g_lib_vra;

	switch (event_type) {
	case CTRL_TASK_SET_CH0_INT:
		lib_vra->ctl_task_type = CTRL_TASK_SET_CH0_INT;
		fimc_is_lib_vra_task_trigger(lib_vra,
			fimc_is_lib_vra_invoke_contol_event);
		break;
	case CTRL_TASK_SET_CH1_INT:
		lib_vra->ctl_task_type = CTRL_TASK_SET_CH1_INT;
		fimc_is_lib_vra_task_trigger(lib_vra,
			fimc_is_lib_vra_invoke_contol_event);
		break;
	case CTRL_TASK_SET_NEWFR:
		lib_vra->ctl_task_type = CTRL_TASK_SET_NEWFR;
		ret = fimc_is_lib_vra_invoke_contol_event(lib_vra);
		if (ret) {
			err_lib("vra control set is fail(%#x)", ret);
			return;
		}
		break;
	case CTRL_TASK_SET_ABORT:
		lib_vra->ctl_task_type = CTRL_TASK_SET_ABORT;
		ret = fimc_is_lib_vra_invoke_contol_event(lib_vra);
		if (ret) {
			err_lib("vra control set is fail(%d)", ret);
			return;
		}
		break;
	case CTRL_TASK_SET_FWALGS:
		lib_vra->ctl_task_type = CTRL_TASK_SET_FWALGS;
		fimc_is_lib_vra_task_trigger(lib_vra,
			fimc_is_lib_vra_invoke_contol_event);
		break;
	default:
		err_lib("vra_control_set_event is undefine (%d)", event_type);
		break;

	}
}