Пример #1
0
static int wcnss_node_open(struct inode *inode, struct file *file)
{
	struct platform_device *pdev;
	int rc = 0;

	if (!penv)
		return -EFAULT;

	if (!penv->triggered) {
		pr_info(DEVICE " triggered by userspace\n");
		pdev = penv->pdev;
		rc = wcnss_trigger_config(pdev);
		if (rc)
			return -EFAULT;
	}

	mutex_lock(&penv->dev_lock);
	penv->user_cal_rcvd = 0;
	penv->user_cal_read = 0;
	penv->user_cal_available = false;
	penv->user_cal_data = NULL;
	penv->device_opened = 1;
	mutex_unlock(&penv->dev_lock);

	return rc;
}
Пример #2
0
static int wcnss_node_open(struct inode *inode, struct file *file)
{
	struct platform_device *pdev;

	if (!penv)
		return -EFAULT;

	/* first open is only to trigger WCNSS platform driver */
	if (!penv->triggered) {
		pr_info(DEVICE " triggered by userspace\n");
		pdev = penv->pdev;
		return wcnss_trigger_config(pdev);

	} else if (penv->device_opened) {
		pr_info(DEVICE " already opened\n");
		return -EBUSY;
	}

	mutex_lock(&penv->dev_lock);
	penv->user_cal_rcvd = 0;
	penv->user_cal_read = 0;
	penv->user_cal_available = false;
	penv->user_cal_data = NULL;
	penv->device_opened = 1;
	mutex_unlock(&penv->dev_lock);

	return 0;
}
Пример #3
0
static int __devinit
wcnss_wlan_probe(struct platform_device *pdev)
{

    if (penv) {
        dev_err(&pdev->dev, "cannot handle multiple devices.\n");
        return -ENODEV;
    }

#ifdef CONFIG_PERFLOCK
    perf_lock_init(&qcom_wlan_perf_lock, TYPE_PERF_LOCK, PERF_LOCK_HIGHEST, "qcom-wifi-perf");
#endif


    penv = kzalloc(sizeof(*penv), GFP_KERNEL);
    if (!penv) {
        dev_err(&pdev->dev, "cannot allocate device memory.\n");
        return -ENOMEM;
    }
    penv->pdev = pdev;

#ifdef MODULE

    pr_info(DEVICE " probed in MODULE mode\n");
    return wcnss_trigger_config(pdev);

#else

    pr_info(DEVICE " probed in built-in mode\n");
    return misc_register(&wcnss_misc);

#endif
}
Пример #4
0
static ssize_t wcnss_node_write(struct file *file,
			const char __user *ubuf, size_t count, loff_t *ppos)
{
	struct platform_device *pdev;
	char *buf;

	pr_info(DEVICE " %s: triggered by userspace\n", __func__);

	pdev = penv->pdev;
	if(count < 1 || count > SZ_4K)
		return -EINVAL;

	buf = kmalloc(count, GFP_KERNEL);
	if(!buf)
		return -ENOMEM;

	if(copy_from_user(buf, ubuf, sizeof(buf))){
		kfree(buf);
		return -EFAULT;
	}

	if(buf[0] == '1')
		wcnss_trigger_config(pdev);

	kfree(buf);
	return count;
}
Пример #5
0
static int wcnss_node_open(struct inode *inode, struct file *file)
{
	struct platform_device *pdev;

	pr_info(DEVICE " triggered by userspace\n");

	pdev = penv->pdev;
	return wcnss_trigger_config(pdev);
}
Пример #6
0
static int __devinit
wcnss_wlan_probe(struct platform_device *pdev)
{
	int ret = 0;

	/* verify we haven't been called more than once */
	if (penv) {
		dev_err(&pdev->dev, "cannot handle multiple devices.\n");
		return -ENODEV;
	}

	/* create an environment to track the device */
	penv = kzalloc(sizeof(*penv), GFP_KERNEL);
	if (!penv) {
		dev_err(&pdev->dev, "cannot allocate device memory.\n");
		return -ENOMEM;
	}
	penv->pdev = pdev;

	/* register sysfs entries */
	ret = wcnss_create_sysfs(&pdev->dev);
	if (ret)
		return -ENOENT;


#ifdef MODULE

	/*
	 * Since we were built as a module, we are running because
	 * the module was loaded, therefore we assume userspace
	 * applications are available to service PIL, so we can
	 * trigger the WCNSS configuration now
	 */
	pr_info(DEVICE " probed in MODULE mode\n");
	return wcnss_trigger_config(pdev);

#else

	/*
	 * Since we were built into the kernel we'll be called as part
	 * of kernel initialization.  We don't know if userspace
	 * applications are available to service PIL at this time
	 * (they probably are not), so we simply create a device node
	 * here.  When userspace is available it should touch the
	 * device so that we know that WCNSS configuration can take
	 * place
	 */
	pr_info(DEVICE " probed in built-in mode\n");
	return misc_register(&wcnss_misc);

#endif
}
Пример #7
0
static int wcnss_node_open(struct inode *inode, struct file *file)
{
    struct platform_device *pdev;
    int ret = 0;

    pr_info(DEVICE " triggered by userspace (%p)\n", penv);

    if (penv == NULL) {
        printk("penv == NULL");
        return ENODEV;
    }

    pdev = penv->pdev;
    ret = wcnss_trigger_config(pdev);
    pr_err("wcnss_trigger_config ret = %d\n", ret);
    if(ret != 0) {
        panic("wcnss_trigger_config fail");
        return ret;
    } else {
        return ret;
    }
}