static int cyttsp4_debug_release(struct cyttsp4_device *ttsp)
{
	struct device *dev = &ttsp->dev;
	struct cyttsp4_debug_data *dd = dev_get_drvdata(dev);
	int rc = 0;
	dev_dbg(dev, "%s\n", __func__);

	if (dev_get_drvdata(&ttsp->core->dev) == NULL) {
		dev_err(dev, "%s: Error, core driver does not exist. "
			       "Unable to un-subscribe attention\n",
				__func__);
		goto cyttsp4_debug_release_exit;
	}

	rc = cyttsp4_unsubscribe_attention(ttsp, CY_ATTEN_IRQ,
		cyttsp4_debug_attention, CY_MODE_OPERATIONAL);
	if (rc < 0) {
		dev_err(dev, "%s: Error, "
				"could not un-subscribe attention\n",
				__func__);
		goto cyttsp4_debug_release_exit;
	}

cyttsp4_debug_release_exit:
	pm_runtime_suspend(dev);
	pm_runtime_disable(dev);
	device_remove_file(dev, &dev_attr_int_count);
	dev_set_drvdata(dev, NULL);
	kfree(dd);

	return rc;
}
static int cyttsp4_proximity_release(struct cyttsp4_device *ttsp)
{
	struct device *dev = &ttsp->dev;
	struct cyttsp4_proximity_data *pd = dev_get_drvdata(dev);

	tp_log_debug("%s\n", __func__);

	if (pd->input_device_registered) {
		/* Disable proximity sensing */
		mutex_lock(&pd->sysfs_lock);
		if (pd->enable_count)
			_cyttsp4_proximity_disable(pd, true);
		mutex_unlock(&pd->sysfs_lock);
		device_remove_file(dev, &dev_attr_enable);
		input_unregister_device(pd->input);
	} else {
		input_free_device(pd->input);
		cyttsp4_unsubscribe_attention(ttsp, CY_ATTEN_STARTUP,
					      cyttsp4_setup_input_attention, 0);
	}

	pm_runtime_suspend(dev);
	pm_runtime_disable(dev);

	dev_set_drvdata(dev, NULL);
	kfree(pd);
	return 0;
}
示例#3
0
static int rvin_release(struct file *file)
{
	struct rvin_dev *vin = video_drvdata(file);
	bool fh_singular;
	int ret;

	mutex_lock(&vin->lock);

	/* Save the singular status before we call the clean-up helper */
	fh_singular = v4l2_fh_is_singular_file(file);

	/* the release helper will cleanup any on-going streaming */
	ret = _vb2_fop_release(file, NULL);

	/*
	 * If this was the last open file.
	 * Then de-initialize hw module.
	 */
	if (fh_singular) {
		pm_runtime_suspend(&vin->vdev.dev);
		pm_runtime_disable(&vin->vdev.dev);
		rvin_power_off(vin);
	}

	mutex_unlock(&vin->lock);

	return ret;
}
static int cyttsp5_device_access_release(struct cyttsp5_device *ttsp)
{
	struct device *dev = &ttsp->dev;
	struct cyttsp5_device_access_data *dad = dev_get_drvdata(dev);

	pm_runtime_suspend(dev);
	pm_runtime_disable(dev);

	if (dad->sysfs_nodes_created) {
		device_remove_file(dev, &dev_attr_command);
		device_remove_file(dev, &dev_attr_status);
		device_remove_file(dev, &dev_attr_response);
		device_remove_file(dev, &dev_attr_responsestr);
#ifdef CONFIG_TCMD 
		device_remove_file(dev, &dev_attr_tcmdresponse);
		device_remove_file(dev, &dev_attr_tcmdresponsesize);
		device_remove_file(dev, &dev_attr_tcmdread_status);
#endif
#ifdef TTHE_TUNER_SUPPORT
		debugfs_remove(dad->tthe_get_panel_data_debugfs);
#endif
	} else {
		cyttsp5_unsubscribe_attention(ttsp, CY_ATTEN_STARTUP,
			cyttsp5_setup_sysfs_attention, 0);
	}

	dev_set_drvdata(dev, NULL);
	kfree(dad);
	return 0;
}
static int cyttsp4_debug_release(struct cyttsp4_device *ttsp)
{
	struct device *dev = &ttsp->dev;
	struct cyttsp4_debug_data *dd = dev_get_drvdata(dev);
	int rc = 0;
	tp_log_debug( "%s\n", __func__);

	if (dev_get_drvdata(&ttsp->core->dev) == NULL) {
		tp_log_err( "%s: Unable to un-subscribe attention\n",
				__func__);
		goto cyttsp4_debug_release_exit;
	}

	/* Unsubscribe from attentions */
	cyttsp4_unsubscribe_attention(ttsp, CY_ATTEN_IRQ,
		cyttsp4_debug_op_attention, CY_MODE_OPERATIONAL);
	cyttsp4_unsubscribe_attention(ttsp, CY_ATTEN_IRQ,
		cyttsp4_debug_cat_attention, CY_MODE_CAT);
	cyttsp4_unsubscribe_attention(ttsp, CY_ATTEN_STARTUP,
		cyttsp4_debug_startup_attention, 0);

cyttsp4_debug_release_exit:
	pm_runtime_suspend(dev);
	pm_runtime_disable(dev);
	device_remove_file(dev, &dev_attr_int_count);
	dev_set_drvdata(dev, NULL);
	kfree(dd);

	return rc;
}
static int cyttsp4_btn_release(struct cyttsp4_device *ttsp)
{
	struct device *dev = &ttsp->dev;
	struct cyttsp4_btn_data *bd = dev_get_drvdata(dev);

	dev_dbg(dev, "%s\n", __func__);

#ifdef CONFIG_HAS_EARLYSUSPEND
	/*
	 * This check is to prevent pm_runtime usage_count drop below zero
	 * because of removing the module while in suspended state
	 */
	if (bd->is_suspended)
		pm_runtime_get_noresume(dev);

	unregister_early_suspend(&bd->es);
#endif

	if (bd->input_device_registered) {
		input_unregister_device(bd->input);
	} else {
		input_free_device(bd->input);
		cyttsp4_unsubscribe_attention(ttsp, CY_ATTEN_STARTUP,
			cyttsp4_setup_input_attention, 0);
	}

	pm_runtime_suspend(dev);
	pm_runtime_disable(dev);

	dev_set_drvdata(dev, NULL);
	kfree(bd);
	return 0;
}
示例#7
0
int smdhsic_pm_suspend(void)
{
	int r = 0;
	struct device *dev;

	pr_debug("%s\n", __func__);

	if (!g_usbdev.usbdev) {
		pr_err("%s(NOT INIT DEVICE)\n", __func__);
		return -EFAULT;
	}

	if (g_usbdev.suspended) {
		pr_info("[%d] %s\n", __LINE__, __func__);
		return 0;
	}

	dev = &g_usbdev.usbdev->dev;

	if (usb_runtime_pm_ap_initiated_L2) {
		pm_runtime_suspend(dev);
		return 0;
	}

	pr_debug("%s(%d)\n", __func__, dev->power.runtime_status);
	pr_debug("%s(pwr.usg_cnt:%d)\n", __func__,
		atomic_read(&dev->power.usage_count));
	if (atomic_read(&dev->power.usage_count))
		r = pm_runtime_put_sync(dev);
	pr_debug("%s done %d \t %d\n",
		__func__, r, dev->power.usage_count.counter);
	return r;
}
示例#8
0
static void kbase_device_runtime_workqueue_callback(struct work_struct *work)
{
    int result;
    struct kbase_device *kbdev;

    kbdev = container_of(work, struct kbase_device, runtime_pm_workqueue.work);
    /********************************************
     *
     *  This is workaround about occurred kernel panic when you turn off the system.
     *
     *  System kernel will call the "__pm_runtime_disable" when you turn off the system.
     *  After that function, System kernel do not run the runtimePM API more.
     *
     *  So, this code is check the "dev->power.disable_depth" value is not zero.
     *
    ********************************************/

    if(kbdev->osdev.dev->power.disable_depth > 0)
        return;

    mutex_lock(&runtime_pm_lock);
    result = pm_runtime_suspend(kbdev->osdev.dev);
    kbase_platform_clock_off(kbdev);
    mutex_unlock(&runtime_pm_lock);

#if MALI_GATOR_SUPPORT
    kbase_trace_mali_timeline_event(GATOR_MAKE_EVENT(ACTIVITY_RTPM_CHANGED, ACTIVITY_RTPM));
#endif
#if MALI_RTPM_DEBUG
    printk( "kbase_device_runtime_workqueue_callback, usage_count=%d\n", atomic_read(&kbdev->osdev.dev->power.usage_count));
#endif

    if(result < 0 && result != -EAGAIN)
        printk("pm_runtime_put_sync failed (%d)\n", result);
}
示例#9
0
int platform_pm_runtime_idle(struct device *dev)
{
	ret = pm_runtime_suspend(dev);
	dev_dbg(dev, "%s [%d]\n", __func__, ret);

	return 0;
};
示例#10
0
static int mmc_runtime_idle(struct device *dev)
{
	int ret;
	
	DBG("[%s] s\n",__func__);

	ret = pm_runtime_suspend(dev);

	DBG("[%s] e\n",__func__);
	/*return pm_runtime_suspend(dev);*/
	return ret;
}
static int cyttsp5_device_access_probe(struct cyttsp5_device *ttsp)
{
	struct device *dev = &ttsp->dev;
	struct cyttsp5_device_access_data *dad;
	struct cyttsp5_device_access_platform_data *pdata =
			dev_get_platdata(dev);
	int rc = 0;

	dad = kzalloc(sizeof(*dad), GFP_KERNEL);
	if (dad == NULL) {
		dev_err(dev, "%s: Error, kzalloc\n", __func__);
		rc = -ENOMEM;
		goto cyttsp5_device_access_probe_data_failed;
	}

	mutex_init(&dad->sysfs_lock);
	dad->ttsp = ttsp;
	dad->pdata = pdata;
	dev_set_drvdata(dev, dad);
#ifdef TTHE_TUNER_SUPPORT
	mutex_init(&dad->debugfs_lock);
	dad->heatmap.num_element = 200;
#endif

	pm_runtime_enable(dev);
	pm_runtime_get_sync(dev);

	/* get sysinfo */
	dad->si = cyttsp5_request_sysinfo(ttsp);
	pm_runtime_put(dev);
	if (dad->si) {
		rc = cyttsp5_setup_sysfs(ttsp);
		if (rc)
			goto cyttsp5_device_access_setup_sysfs_failed;
	} else {
		dev_err(dev, "%s: Fail get sysinfo pointer from core p=%p\n",
				__func__, dad->si);
		cyttsp5_subscribe_attention(ttsp, CY_ATTEN_STARTUP,
			cyttsp5_setup_sysfs_attention, 0);
	}

	return 0;

 cyttsp5_device_access_setup_sysfs_failed:
	pm_runtime_suspend(dev);
	pm_runtime_disable(dev);
	dev_set_drvdata(dev, NULL);
	kfree(dad);
 cyttsp5_device_access_probe_data_failed:
	dev_err(dev, "%s failed.\n", __func__);
	return rc;
}
示例#12
0
static int scsi_runtime_idle(struct device *dev)
{
    int err;

    dev_dbg(dev, "scsi_runtime_idle\n");

    /* Insert hooks here for targets, hosts, and transport classes */

    if (scsi_is_sdev_device(dev)) {
        struct scsi_device *sdev = to_scsi_device(dev);

        if (sdev->request_queue->dev) {
            pm_runtime_mark_last_busy(dev);
            err = pm_runtime_autosuspend(dev);
        } else {
            err = pm_runtime_suspend(dev);
        }
    } else {
        err = pm_runtime_suspend(dev);
    }
    return err;
}
static int __devexit lm3561_remove(struct i2c_client *client)
{
	struct lm3561_drv_data *data = dev_get_drvdata(&client->dev);
	struct lm3561_platform_data *pdata = client->dev.platform_data;

	remove_sysfs_interfaces(&client->dev);
	pm_runtime_suspend(&client->dev);
	pm_runtime_disable(&client->dev);
	if (pdata->platform_init)
		pdata->platform_init(&client->dev, false);
	kfree(data);
	return 0;
}
/**
 * pm_generic_runtime_idle - Generic runtime idle callback for subsystems.
 * @dev: Device to handle.
 *
 * If PM operations are defined for the @dev's driver and they include
 * ->runtime_idle(), execute it and return its error code, if nonzero.
 * Otherwise, execute pm_runtime_suspend() for the device and return 0.
 */
int pm_generic_runtime_idle(struct device *dev)
{
    const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;

    if (pm && pm->runtime_idle) {
        int ret = pm->runtime_idle(dev);
        if (ret)
            return ret;
    }

    pm_runtime_suspend(dev);
    return 0;
}
示例#15
0
static int scsi_runtime_idle(struct device *dev)
{
	int err;

	dev_dbg(dev, "scsi_runtime_idle\n");

	/* Insert hooks here for targets, hosts, and transport classes */

	if (scsi_is_sdev_device(dev))
		err = pm_schedule_suspend(dev, 100);
	else
		err = pm_runtime_suspend(dev);
	return err;
}
static void gpu_power_suspend(struct kbase_device *kbdev)
{
	struct exynos_context *platform = (struct exynos_context *) kbdev->platform_context;
	if (!platform)
		return;

	GPU_LOG(DVFS_INFO, DUMMY, 0u, 0u, "power suspend\n");
	gpu_control_enable_customization(kbdev);

	pm_runtime_suspend(kbdev->dev);

	if (platform->early_clk_gating_status)
		gpu_control_disable_clock(kbdev);
}
示例#17
0
static int scsi_runtime_idle(struct device *dev)
{
	int err;

	dev_dbg(dev, "scsi_runtime_idle\n");

	

	if (scsi_is_sdev_device(dev))
		err = pm_schedule_suspend(dev, 100);
	else
		err = pm_runtime_suspend(dev);
	return err;
}
static int mali_runtime_idle(struct device *device)
{
	MALI_DEBUG_PRINT(4, ("mali_runtime_idle() called\n"));

	if (NULL != device->driver &&
	    NULL != device->driver->pm &&
	    NULL != device->driver->pm->runtime_idle)
	{
		/* Need to notify Mali driver about this event */
		int ret = device->driver->pm->runtime_idle(device);
		if (0 != ret)
		{
			return ret;
		}
	}

	pm_runtime_suspend(device);

	return 0;
}
示例#19
0
static int pmic8058_vib_set(struct pmic8058_vib *vib, int on)
{
	int rc;
	u8 val;

	if (on) {
		rc = pm_runtime_resume(vib->dev);
		if (rc < 0)
			dev_dbg(vib->dev, "pm_runtime_resume failed\n");

//[SIMT-lilening-20110804] add vibrator start voltage{
		val = vib->reg_vib_drv;
		val &= ~VIB_DRV_SEL_MASK;
		val |= ((VIB_START_VOLTAGE_mV << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK);
		rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		udelay(20);
//[SIMT-lilening-20110804] add vibrator start voltage}
		val = vib->reg_vib_drv;
		val |= ((vib->level << VIB_DRV_SEL_SHIFT) & VIB_DRV_SEL_MASK);
		rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		vib->reg_vib_drv = val;
	} else {
		val = vib->reg_vib_drv;
		val &= ~VIB_DRV_SEL_MASK;
		rc = pmic8058_vib_write_u8(vib, val, VIB_DRV);
		if (rc < 0)
			return rc;
		vib->reg_vib_drv = val;

		rc = pm_runtime_suspend(vib->dev);
		if (rc < 0)
			dev_dbg(vib->dev, "pm_runtime_suspend failed\n");
	}
	__dump_vib_regs(vib, "vib_set_end");

	return rc;
}
示例#20
0
static int ehci_msm_bus_suspend(struct usb_hcd *hcd)
{
    int ret;
    struct msmusb_hcd *mhcd = hcd_to_mhcd(hcd);
    struct device *dev = hcd->self.controller;

    ret = ehci_bus_suspend(hcd);
    if (ret) {
        pr_err("ehci_bus suspend faield\n");
        return ret;
    }
    if (PHY_TYPE(mhcd->pdata->phy_info) == USB_PHY_INTEGRATED)
        ret = usb_phy_set_suspend(mhcd->xceiv, 1);
    else
        ret = usb_lpm_enter(hcd);

    pm_runtime_put_noidle(dev);
    pm_runtime_suspend(dev);
    wake_unlock(&mhcd->wlock);
    return ret;
}
示例#21
0
int platform_pm_runtime_idle(struct device *dev)
{
    struct platform_device *pdev = to_platform_device(dev);
    int hwblk = pdev->archdata.hwblk_id;
    int ret = 0;

    dev_dbg(dev, "platform_pm_runtime_idle() [%d]\n", hwblk);

    /* ignore off-chip platform devices */
    if (!hwblk)
        goto out;

    /* interrupt context not allowed, use pm_runtime_put()! */
    might_sleep();

    /* suspend synchronously to disable clocks immediately */
    ret = pm_runtime_suspend(dev);
out:
    dev_dbg(dev, "platform_pm_runtime_idle() [%d] done!\n", hwblk);
    return ret;
}
/*
 ****************************************************************************
 * - Device operation such as;
 *   probe, init/exit, remove
 ****************************************************************************
 */
static int __devinit lm3561_probe(struct i2c_client *client,
	  const struct i2c_device_id *id)
{
	struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
	struct lm3561_platform_data *pdata = client->dev.platform_data;
	struct lm3561_drv_data *data;
	int result;

	dev_dbg(&client->dev, "%s\n", __func__);

	if (!pdata) {
		dev_err(&client->dev,
			"%s(): failed during init",
				__func__);
		return -EINVAL;
	}

	if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) {
		dev_err(&client->dev,
			"%s(): failed during i2c_check_functionality",
			__func__);
		return -EIO;
	}

	data = kzalloc(sizeof(*data), GFP_KERNEL);
	if (!data) {
		dev_err(&client->dev, "%s(): failed during kzalloc", __func__);
		return -ENOMEM;
	}

	dev_set_drvdata(&client->dev, data);
	data->client = client;
	data->led_nums = 1;
	data->torch_current_shift = 0;
	data->flash_current_shift = 0;
	if (pdata->current_limit >= 1500000) {
		data->reg_flash_duration_limit =
			LM3561_FLASH_DURATION_CL_1500MA;
	} else if (pdata->current_limit >= 1000000) {
		data->reg_flash_duration_limit =
			LM3561_FLASH_DURATION_CL_1000MA;
	} else {
		/* current_limit > 1500000uA || current_limit < 1000000uA */
		dev_err(&data->client->dev,
			"%s(): current_limit(%luuA) is invalid\n",
			__func__, pdata->current_limit);
		result = -EINVAL;
		goto err_init;
	}
	mutex_init(&data->lock);
	pm_runtime_enable(&client->dev);
	pm_suspend_ignore_children(&client->dev, true);
	result = pm_runtime_get_sync(&client->dev);
	if (result < 0)
		goto err_setup;
	result = lm3561_chip_init(data, pdata);
	if (result) {
		dev_err(&client->dev, "%s:chip init error\n", __func__);
		goto err_chip_init;
	}
	result = lm3561_create_sysfs_interfaces(&client->dev);
	if (result) {
		dev_err(&data->client->dev,
			"%s(): create sysfs failed",
				__func__);
		goto err_chip_init;
	}
	pm_runtime_set_autosuspend_delay(&client->dev, autosuspend_delay_ms);
	pm_runtime_use_autosuspend(&client->dev);
	pm_runtime_mark_last_busy(&data->client->dev);
	pm_runtime_put_autosuspend(&data->client->dev);
	dev_info(&data->client->dev, "%s: loaded\n", __func__);
	return 0;

err_chip_init:
	pm_runtime_suspend(&client->dev);
err_setup:
	pm_runtime_disable(&client->dev);
	if (pdata->platform_init)
		pdata->platform_init(&client->dev, 0);
err_init:
	dev_set_drvdata(&client->dev, NULL);
	kfree(data);
	dev_err(&client->dev,
		"%s: failed with code %d.\n", __func__, result);

	return result;
}
static int sh_mmcif_probe(struct platform_device *pdev)
{
	int ret = 0, irq[2];
	struct mmc_host *mmc;
	struct sh_mmcif_host *host;
	struct sh_mmcif_plat_data *pd = pdev->dev.platform_data;
	struct resource *res;
	void __iomem *reg;
	const char *name;

	irq[0] = platform_get_irq(pdev, 0);
	irq[1] = platform_get_irq(pdev, 1);
	if (irq[0] < 0) {
		dev_err(&pdev->dev, "Get irq error\n");
		return -ENXIO;
	}
	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res) {
		dev_err(&pdev->dev, "platform_get_resource error.\n");
		return -ENXIO;
	}
	reg = ioremap(res->start, resource_size(res));
	if (!reg) {
		dev_err(&pdev->dev, "ioremap error.\n");
		return -ENOMEM;
	}

	mmc = mmc_alloc_host(sizeof(struct sh_mmcif_host), &pdev->dev);
	if (!mmc) {
		ret = -ENOMEM;
		goto ealloch;
	}

	ret = mmc_of_parse(mmc);
	if (ret < 0)
		goto eofparse;

	host		= mmc_priv(mmc);
	host->mmc	= mmc;
	host->addr	= reg;
	host->timeout	= msecs_to_jiffies(10000);
	host->ccs_enable = !pd || !pd->ccs_unsupported;
	host->clk_ctrl2_enable = pd && pd->clk_ctrl2_present;

	host->pd = pdev;

	spin_lock_init(&host->lock);

	mmc->ops = &sh_mmcif_ops;
	sh_mmcif_init_ocr(host);

	mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_WAIT_WHILE_BUSY;
	if (pd && pd->caps)
		mmc->caps |= pd->caps;
	mmc->max_segs = 32;
	mmc->max_blk_size = 512;
	mmc->max_req_size = PAGE_CACHE_SIZE * mmc->max_segs;
	mmc->max_blk_count = mmc->max_req_size / mmc->max_blk_size;
	mmc->max_seg_size = mmc->max_req_size;

	platform_set_drvdata(pdev, host);

	pm_runtime_enable(&pdev->dev);
	host->power = false;

	host->hclk = clk_get(&pdev->dev, NULL);
	if (IS_ERR(host->hclk)) {
		ret = PTR_ERR(host->hclk);
		dev_err(&pdev->dev, "cannot get clock: %d\n", ret);
		goto eclkget;
	}
	ret = sh_mmcif_clk_update(host);
	if (ret < 0)
		goto eclkupdate;

	ret = pm_runtime_resume(&pdev->dev);
	if (ret < 0)
		goto eresume;

	INIT_DELAYED_WORK(&host->timeout_work, mmcif_timeout_work);

	sh_mmcif_sync_reset(host);
	sh_mmcif_writel(host->addr, MMCIF_CE_INT_MASK, MASK_ALL);

	name = irq[1] < 0 ? dev_name(&pdev->dev) : "sh_mmc:error";
	ret = request_threaded_irq(irq[0], sh_mmcif_intr, sh_mmcif_irqt, 0, name, host);
	if (ret) {
		dev_err(&pdev->dev, "request_irq error (%s)\n", name);
		goto ereqirq0;
	}
	if (irq[1] >= 0) {
		ret = request_threaded_irq(irq[1], sh_mmcif_intr, sh_mmcif_irqt,
					   0, "sh_mmc:int", host);
		if (ret) {
			dev_err(&pdev->dev, "request_irq error (sh_mmc:int)\n");
			goto ereqirq1;
		}
	}

	if (pd && pd->use_cd_gpio) {
		ret = mmc_gpio_request_cd(mmc, pd->cd_gpio, 0);
		if (ret < 0)
			goto erqcd;
	}

	mutex_init(&host->thread_lock);

	clk_disable_unprepare(host->hclk);
	ret = mmc_add_host(mmc);
	if (ret < 0)
		goto emmcaddh;

	dev_pm_qos_expose_latency_limit(&pdev->dev, 100);

	dev_info(&pdev->dev, "driver version %s\n", DRIVER_VERSION);
	dev_dbg(&pdev->dev, "chip ver H'%04x\n",
		sh_mmcif_readl(host->addr, MMCIF_CE_VERSION) & 0x0000ffff);
	return ret;

emmcaddh:
erqcd:
	if (irq[1] >= 0)
		free_irq(irq[1], host);
ereqirq1:
	free_irq(irq[0], host);
ereqirq0:
	pm_runtime_suspend(&pdev->dev);
eresume:
	clk_disable_unprepare(host->hclk);
eclkupdate:
	clk_put(host->hclk);
eclkget:
	pm_runtime_disable(&pdev->dev);
eofparse:
	mmc_free_host(mmc);
ealloch:
	iounmap(reg);
	return ret;
}
static int cyttsp4_btn_probe(struct cyttsp4_device *ttsp)
{
	struct cyttsp4_btn_data *bd;
	struct device *dev = &ttsp->dev;
	struct cyttsp4_btn_platform_data *pdata = dev_get_platdata(dev);
	int rc = 0;

	dev_info(dev, "%s\n", __func__);
	dev_dbg(dev, "%s: debug on\n", __func__);
	dev_vdbg(dev, "%s: verbose debug on\n", __func__);

/*Increase the judgment conditions*/
	if (pdata == NULL) {
		dev_err(dev, "%s: Missing platform data\n", __func__);
		rc = -ENODEV;
		goto error_no_pdata;
	}
	bd = kzalloc(sizeof(*bd), GFP_KERNEL);
	if (bd == NULL) {
		dev_err(dev, "%s: Error, kzalloc\n", __func__);
		rc = -ENOMEM;
		goto error_alloc_data_failed;
	}

	mutex_init(&bd->report_lock);
	bd->ttsp = ttsp;
	bd->pdata = pdata;
	dev_set_drvdata(dev, bd);
	/* Create the input device and register it. */
	dev_vdbg(dev, "%s: Create the input device and register it\n",
		__func__);
	bd->input = input_allocate_device();
	if (bd->input == NULL) {
		dev_err(dev, "%s: Error, failed to allocate input device\n",
			__func__);
		rc = -ENOSYS;
		goto error_alloc_failed;
	}

	bd->input->name = ttsp->name;
	scnprintf(bd->phys, sizeof(bd->phys)-1, "%s", dev_name(dev));
	bd->input->phys = bd->phys;
	bd->input->dev.parent = &bd->ttsp->dev;
	bd->input->open = cyttsp4_btn_open;
	bd->input->close = cyttsp4_btn_close;
	input_set_drvdata(bd->input, bd);

	pm_runtime_enable(dev);

	/* get sysinfo */
	bd->si = cyttsp4_request_sysinfo(ttsp);
	if (bd->si) {
		rc = cyttsp4_setup_input_device(ttsp);
		if (rc)
			goto error_init_input;
	} else {
		dev_err(dev, "%s: Fail get sysinfo pointer from core p=%p\n",
			__func__, bd->si);
		cyttsp4_subscribe_attention(ttsp, CY_ATTEN_STARTUP,
			cyttsp4_setup_input_attention, 0);
	}

#ifdef CONFIG_HAS_EARLYSUSPEND
	bd->es.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	bd->es.suspend = cyttsp4_btn_early_suspend;
	bd->es.resume = cyttsp4_btn_late_resume;
	register_early_suspend(&bd->es);
#endif

	dev_dbg(dev, "%s: ok\n", __func__);
	return 0;

error_init_input:
	pm_runtime_suspend(dev);
	pm_runtime_disable(dev);
	input_free_device(bd->input);
error_alloc_failed:
	dev_set_drvdata(dev, NULL);
	kfree(bd);
error_alloc_data_failed:
error_no_pdata:
	dev_err(dev, "%s failed.\n", __func__);
	return rc;
}
static int cyttsp4_debug_probe(struct cyttsp4_device *ttsp)
{
	struct device *dev = &ttsp->dev;
	struct cyttsp4_debug_data *dd;
	struct cyttsp4_debug_platform_data *pdata = dev_get_platdata(dev);
	int rc;

	tp_log_info( "%s: startup\n", __func__);
	tp_log_debug( "%s: debug on\n", __func__);
	tp_log_debug( "%s: verbose debug on\n", __func__);

	/* get context and debug print buffers */
	dd = kzalloc(sizeof(*dd), GFP_KERNEL);
	if (dd == NULL) {
		tp_log_err( "%s: Error, kzalloc\n", __func__);
		rc = -ENOMEM;
		goto cyttsp4_debug_probe_alloc_failed;
	}

	rc = device_create_file(dev, &dev_attr_int_count);
	if (rc) {
		tp_log_err( "%s: Error, could not create int_count\n",
				__func__);
		goto cyttsp4_debug_probe_create_int_count_failed;
	}

	rc = device_create_file(dev, &dev_attr_formated_output);
	if (rc) {
		tp_log_err( "%s: Error, could not create formated_output\n",
				__func__);
		goto cyttsp4_debug_probe_create_formated_failed;
	}

	mutex_init(&dd->sysfs_lock);
	dd->ttsp = ttsp;
	dd->pdata = pdata;
	dev_set_drvdata(dev, dd);

	pm_runtime_enable(dev);

	dd->si = cyttsp4_request_sysinfo(ttsp);
	if (dd->si == NULL) {
		tp_log_err( "%s: Fail get sysinfo pointer from core\n",
				__func__);
		rc = -ENODEV;
		goto cyttsp4_debug_probe_sysinfo_failed;
	}

	rc = cyttsp4_subscribe_attention(ttsp, CY_ATTEN_IRQ,
		cyttsp4_debug_op_attention, CY_MODE_OPERATIONAL);
	if (rc < 0) {
		tp_log_err( "%s: Error, could not subscribe Operating mode attention cb\n",
				__func__);
		goto cyttsp4_debug_probe_subscribe_op_failed;
	}

	rc = cyttsp4_subscribe_attention(ttsp, CY_ATTEN_IRQ,
		cyttsp4_debug_cat_attention, CY_MODE_CAT);
	if (rc < 0) {
		tp_log_err( "%s: Error, could not subscribe CaT mode attention cb\n",
				__func__);
		goto cyttsp4_debug_probe_subscribe_cat_failed;
	}

	rc = cyttsp4_subscribe_attention(ttsp, CY_ATTEN_STARTUP,
		cyttsp4_debug_startup_attention, 0);
	if (rc < 0) {
		tp_log_err( "%s: Error, could not subscribe startup attention cb\n",
				__func__);
		goto cyttsp4_debug_probe_subscribe_startup_failed;
	}
	return 0;

cyttsp4_debug_probe_subscribe_startup_failed:
	cyttsp4_unsubscribe_attention(ttsp, CY_ATTEN_IRQ,
		cyttsp4_debug_cat_attention, CY_MODE_CAT);
cyttsp4_debug_probe_subscribe_cat_failed:
	cyttsp4_unsubscribe_attention(ttsp, CY_ATTEN_IRQ,
		cyttsp4_debug_op_attention, CY_MODE_OPERATIONAL);
cyttsp4_debug_probe_subscribe_op_failed:
cyttsp4_debug_probe_sysinfo_failed:
	pm_runtime_suspend(dev);
	pm_runtime_disable(dev);
	dev_set_drvdata(dev, NULL);
	device_remove_file(dev, &dev_attr_formated_output);
cyttsp4_debug_probe_create_formated_failed:
	device_remove_file(dev, &dev_attr_int_count);
cyttsp4_debug_probe_create_int_count_failed:
	kfree(dd);
cyttsp4_debug_probe_alloc_failed:
	tp_log_err( "%s failed.\n", __func__);
	return rc;
}
示例#26
0
static int cyttsp4_proximity_probe(struct cyttsp4_device *ttsp)
{
	struct cyttsp4_proximity_data *pd;
	struct device *dev = &ttsp->dev;
	struct cyttsp4_proximity_platform_data *pdata = dev_get_platdata(dev);
	int rc = 0;

	tp_log_info("%s\n", __func__);
	tp_log_debug("%s: debug on\n", __func__);
	tp_log_debug("%s: verbose debug on\n", __func__);

	if (pdata == NULL) {
		tp_log_err("%s: Missing platform data\n", __func__);
		rc = -ENODEV;
		goto error_no_pdata;
	}

	pd = kzalloc(sizeof(*pd), GFP_KERNEL);
	if (pd == NULL) {
		tp_log_err("%s: Error, kzalloc\n", __func__);
		rc = -ENOMEM;
		goto error_alloc_data_failed;
	}

	mutex_init(&pd->report_lock);
	mutex_init(&pd->sysfs_lock);
	pd->ttsp = ttsp;
	pd->pdata = pdata;
	dev_set_drvdata(dev, pd);
	/* Create the input device and register it. */
	tp_log_debug("%s: Create the input device and register it\n", __func__);
	pd->input = input_allocate_device();
	if (pd->input == NULL) {
		tp_log_err("%s: Error, failed to allocate input device\n",
			   __func__);
		rc = -ENOSYS;
		goto error_alloc_failed;
	}

	pd->input->name = ttsp->name;
	scnprintf(pd->phys, sizeof(pd->phys) - 1, "%s", dev_name(dev));
	pd->input->phys = pd->phys;
	pd->input->dev.parent = &pd->ttsp->dev;
	input_set_drvdata(pd->input, pd);

	pm_runtime_enable(dev);

	/* get sysinfo */
	pd->si = cyttsp4_request_sysinfo(ttsp);
	if (pd->si) {
		rc = cyttsp4_setup_input_device_and_sysfs(ttsp);
		if (rc)
			goto error_init_input;
	} else {
		tp_log_err("%s: Fail get sysinfo pointer from core \n",
			   __func__);
		cyttsp4_subscribe_attention(ttsp, CY_ATTEN_STARTUP,
					    cyttsp4_setup_input_attention, 0);
	}

	tp_log_debug("%s: ok\n", __func__);
	return 0;

error_init_input:
	pm_runtime_suspend(dev);
	pm_runtime_disable(dev);
	input_free_device(pd->input);
error_alloc_failed:
	dev_set_drvdata(dev, NULL);
	kfree(pd);
error_alloc_data_failed:
error_no_pdata:
	tp_log_err("%s failed.\n", __func__);
	return rc;
}
示例#27
0
static void msm_hsusb_request_host(void *handle, int request)
{
    struct msmusb_hcd *mhcd = handle;
    struct usb_hcd *hcd = mhcd_to_hcd(mhcd);
    struct msm_usb_host_platform_data *pdata = mhcd->pdata;
    struct msm_otg *otg = container_of(mhcd->xceiv, struct msm_otg, phy);
#ifdef CONFIG_USB_OTG
    struct usb_device *udev = hcd->self.root_hub;
#endif
    struct device *dev = hcd->self.controller;

    switch (request) {
#ifdef CONFIG_USB_OTG
    case REQUEST_HNP_SUSPEND:
        /* disable Root hub auto suspend. As hardware is configured
         * for peripheral mode, mark hardware is not available.
         */
        if (PHY_TYPE(pdata->phy_info) == USB_PHY_INTEGRATED) {
            pm_runtime_disable(&udev->dev);
            /* Mark root hub as disconnected. This would
             * protect suspend/resume via sysfs.
             */
            udev->state = USB_STATE_NOTATTACHED;
            clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
            hcd->state = HC_STATE_HALT;
            pm_runtime_put_noidle(dev);
            pm_runtime_suspend(dev);
        }
        break;
    case REQUEST_HNP_RESUME:
        if (PHY_TYPE(pdata->phy_info) == USB_PHY_INTEGRATED) {
            pm_runtime_get_noresume(dev);
            pm_runtime_resume(dev);
            disable_irq(hcd->irq);
            ehci_msm_reset(hcd);
            ehci_msm_run(hcd);
            set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags);
            pm_runtime_enable(&udev->dev);
            udev->state = USB_STATE_CONFIGURED;
            enable_irq(hcd->irq);
        }
        break;
#endif
    case REQUEST_RESUME:
        usb_hcd_resume_root_hub(hcd);
        break;
    case REQUEST_START:
        if (mhcd->running)
            break;
        pm_runtime_get_noresume(dev);
        pm_runtime_resume(dev);
        wake_lock(&mhcd->wlock);
        msm_xusb_pm_qos_update(mhcd, 1);
        msm_xusb_enable_clks(mhcd);
        if (PHY_TYPE(pdata->phy_info) == USB_PHY_INTEGRATED)
            if (otg->set_clk)
                otg->set_clk(mhcd->xceiv, 1);
        if (pdata->vbus_power)
            pdata->vbus_power(pdata->phy_info, 1);
        if (pdata->config_gpio)
            pdata->config_gpio(1);
        usb_add_hcd(hcd, hcd->irq, IRQF_SHARED);
        mhcd->running = 1;
        if (PHY_TYPE(pdata->phy_info) == USB_PHY_INTEGRATED)
            if (otg->set_clk)
                otg->set_clk(mhcd->xceiv, 0);
        break;
    case REQUEST_STOP:
        if (!mhcd->running)
            break;
        mhcd->running = 0;
        /* come out of lpm before deregistration */
        if (PHY_TYPE(pdata->phy_info) == USB_PHY_SERIAL_PMIC) {
            usb_lpm_exit(hcd);
            if (cancel_work_sync(&(mhcd->lpm_exit_work)))
                usb_lpm_exit_w(&mhcd->lpm_exit_work);
        }
        usb_remove_hcd(hcd);
        if (pdata->config_gpio)
            pdata->config_gpio(0);
        if (pdata->vbus_power)
            pdata->vbus_power(pdata->phy_info, 0);
        msm_xusb_disable_clks(mhcd);
        wake_lock_timeout(&mhcd->wlock, HZ/2);
        msm_xusb_pm_qos_update(mhcd, 0);
        pm_runtime_put_noidle(dev);
        pm_runtime_suspend(dev);
        break;
    }
}
示例#28
0
static int default_platform_runtime_idle(struct device *dev)
{
	/* suspend synchronously to disable clocks immediately */
	return pm_runtime_suspend(dev);
}
static int mmc_runtime_idle(struct device *dev)
{
	return pm_runtime_suspend(dev);
}
示例#30
0
static int ux500_pd_runtime_idle(struct device *dev)
{
	return pm_runtime_suspend(dev);
}