Exemplo n.º 1
0
static ssize_t
magnetic_enable_store(struct device *dev, struct device_attribute *attr,
			const char *buf, size_t count)
{
	int value;
	int err = 0;

	err = kstrtoint(buf, 10, &value);

	pr_debug("%s, %d value = %d\n", __func__, __LINE__, value);

	mutex_lock(&alps_lock);
	flag_mag = value;
	hscd_activate(1, flag_mag, mag_delay);
	mutex_unlock(&alps_lock);
	return count;
}
Exemplo n.º 2
0
static ssize_t
magnetic_delay_store(struct device *dev, struct device_attribute *attr,
				const char *buf, size_t count)
{
	int new_delay;
	int err = 0;

	err = kstrtoint(buf, 10, &new_delay);

	if (err) {
		pr_err("%s, kstrtoint failed.", __func__);
		goto done;
	}
	if (new_delay < 0)
		goto done;

	pr_info("%s, new_delay = %d, old_delay = %d", __func__, new_delay,
			mag_delay);

	if (new_delay <= 15)
		new_delay = 10;
	else if (new_delay <= 45)
		new_delay = 20;
	else if (new_delay <= 135)
		new_delay = 70;
	else
		new_delay = SENSOR_DEFAULT_DELAY;

	mag_delay = new_delay;

	mutex_lock(&alps_lock);
	hscd_activate(1, flag_mag, new_delay);
	mutex_unlock(&alps_lock);
done:
	return count;
}
Exemplo n.º 3
0
static long alps_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
	void __user *argp = (void __user *)arg;
	int ret = -1, tmpval;

	switch (cmd) {
	case ALPSIO_SET_MAGACTIVATE:
#if defined(CONFIG_SENSORS_HSCDTD006A) || defined(CONFIG_SENSORS_HSCDTD008A)
			ret = copy_from_user(&tmpval, argp, sizeof(tmpval));
			if (ret) {
				pr_info("error : ioctl(ALPSIO_SET_MAGACTIVATE)\n");
				return -EFAULT;
			}
#ifdef ALPS_DEBUG
			pr_info("ioctl(ALPSIO_SET_MAGACTIVATE) M=%d\n", tmpval);
#endif
			mutex_lock(&alps_lock);
			if (probeM == PROBE_SUCCESS)
				hscd_activate(1, tmpval, delay);
			flgM = tmpval;
			mutex_unlock(&alps_lock);
#endif
			break;

	case ALPSIO_SET_ACCACTIVATE:
#if defined(CONFIG_SENSORS_BMA222E) || defined(CONFIG_SENSORS_BMA222) || defined(CONFIG_SENSORS_K2DH)
			ret = copy_from_user(&tmpval, argp, sizeof(tmpval));
			if (ret) {
				pr_info("error : ioctl(cmd = ALPSIO_SET_ACCACTIVATE)\n");
				return -EFAULT;
			}
#ifdef ALPS_DEBUG
			pr_info("ioctl(ALPSIO_SET_ACCACTIVATE) A=%d\n", tmpval);
#endif
			mutex_lock(&alps_lock);
			if (probeA == PROBE_SUCCESS)
				accsns_activate(1, tmpval, delay);
			poll_stop_cnt = 1;
			flgA = tmpval;
			mutex_unlock(&alps_lock);
#endif
			break;

	case ALPSIO_SET_DELAY:
			ret = copy_from_user(&tmpval, argp, sizeof(tmpval));
			if (ret) {
				pr_info("error : ioctl(ALPSIO_SET_DELAY)\n");
				return -EFAULT;
			}
#ifdef ALPS_DEBUG
			pr_info("ioctl(ALPSIO_SET_DELAY)\n");
#endif
			if (tmpval <=  10)
				tmpval =  10;
			else if (tmpval <=  20)
				tmpval =  20;
			else if (tmpval <=  70)
				tmpval =  70;
			else
				tmpval = 200;
			mutex_lock(&alps_lock);
			delay = tmpval;
			poll_stop_cnt = 1;
#if defined(CONFIG_SENSORS_HSCDTD006A) || defined(CONFIG_SENSORS_HSCDTD008A)
			if (probeM == PROBE_SUCCESS)
				hscd_activate(1, flgM, delay);
#endif
#if defined(CONFIG_SENSORS_BMA222E) || defined(CONFIG_SENSORS_BMA222) || defined(CONFIG_SENSORS_K2DH)
			if (probeA == PROBE_SUCCESS)
				accsns_activate(1, flgA, delay);
#endif
			mutex_unlock(&alps_lock);
#ifdef ALPS_DEBUG
			pr_info("     delay = %d\n", delay);
#endif
			break;

	default:
			return -ENOTTY;
	}
	return 0;
}
Exemplo n.º 4
0
static long alps_ioctl( struct file* filp, unsigned int cmd, unsigned long arg)
{
	void __user *argp = (void __user *)arg;
	int ret = -1, tmpval;

	switch (cmd) {
		case ALPSIO_SET_MAGACTIVATE:
			ret = copy_from_user(&tmpval, argp, sizeof(tmpval));
			if (ret) {
				printk(KERN_ERR "error : alps_ioctl(cmd = ALPSIO_SET_MAGACTIVATE)\n" );
				return -EFAULT;
			}

			printk(KERN_INFO "[ALPS] ioctl(cmd = ALPSIO_SET_MAGACTIVATE), flgM = %d\n", tmpval);

			mutex_lock(&alps_lock);
			flgM = tmpval;
			hscd_activate(1, tmpval, delay);
			mutex_unlock(&alps_lock);
			break;

		case ALPSIO_SET_ACCACTIVATE:
			ret = copy_from_user(&tmpval, argp, sizeof(tmpval));
			if (ret) {
				printk(KERN_ERR "error : alps_ioctl(cmd = ALPSIO_SET_ACCACTIVATE)\n");
				return -EFAULT;
			}

			printk(KERN_INFO "[ALPS] ioctl(cmd = ALPSIO_SET_ACCACTIVATE), flgA = %d\n", tmpval);

			mutex_lock(&alps_lock);
			flgA = tmpval;
			accsns_activate(1, flgA, delay);
			mutex_unlock(&alps_lock);
			break;

		case ALPSIO_SET_DELAY:
			ret = copy_from_user(&tmpval, argp, sizeof(tmpval));
			if (ret) {
				printk(KERN_ERR "error : alps_ioctl(cmd = ALPSIO_SET_DELAY)\n" );
				return -EFAULT;
			}

			ALPSDBG("[ALPS] ioctl(cmd = ALPSIO_SET_DELAY), delay=%d\n", tmpval);

                        mutex_lock(&alps_lock);
                        if (flgM) {
                            if      (tmpval <=  10) tmpval =  10;
                            else if (tmpval <=  20) tmpval =  20;
                            else if (tmpval <=  60) tmpval =  50;
                            else                    tmpval = 100;
                        }
                        else {
                            if      (tmpval <=  10) tmpval =  10;
                        }
			delay = tmpval;
			/*poll_stop_cnt = POLL_STOP_TIME / tmpval;*/
			hscd_activate(1, flgM, delay);
			accsns_activate(1, flgA, delay);
			mutex_unlock(&alps_lock);

			ALPSDBG("[ALPS] delay = %d\n", delay);

			break;

		default:
			return -ENOTTY;
	}
	return 0;
}
Exemplo n.º 5
0
static long alps_ioctl(struct file* filp, unsigned int cmd, unsigned long arg)
{
	void __user *argp = (void __user *)arg;
	int ret = -1, tmpval;

	switch (cmd) {
	case ALPSIO_SET_MAGACTIVATE:
		ret = copy_from_user(&tmpval, argp, sizeof(tmpval));
		if (ret) {
			alps_errmsg("Failed (cmd = ALPSIO_SET_MAGACTIVATE)\n" );
			return -EFAULT;
		}

		mutex_lock(&alps_lock);
		flag_mag = tmpval;

		hscd_activate(1, tmpval, mag_delay);
		mutex_unlock(&alps_lock);

		alps_info("ALPSIO_SET_MAGACTIVATE, flag_mag = %d\n", flag_mag);
		break;

	case ALPSIO_SET_DELAY:
		ret = copy_from_user(&tmpval, argp, sizeof(tmpval));
		if (ret) {
			alps_errmsg("Failed (cmd = ALPSIO_SET_DELAY)\n" );
			return -EFAULT;
		}

		mutex_lock(&alps_lock);
		if (tmpval <=  15)			tmpval =  10;
		else if (tmpval <=  45)		tmpval =  20;
		else if (tmpval <=  135)	tmpval =  70;
		else	tmpval = 200;

		mag_delay = tmpval;
		hscd_activate(1, flag_mag, mag_delay);
		mutex_unlock(&alps_lock);

		alps_info("ALPSIO_SET_DELAY, delay = %d\n", mag_delay);
		break;

	case ALPSIO_ACT_SELF_TEST_A:

		mutex_lock(&alps_lock);
		ret = hscd_self_test_A();
		mutex_unlock(&alps_lock);

		alps_info("ALPSIO_ACT_SELF_TEST_A, result = %d\n", ret);

		if (copy_to_user(argp, &ret, sizeof(ret))) {
			alps_errmsg("Failed (cmd = ALPSIO_ACT_SELF_TEST_A)\n" );
			return -EFAULT;
		}
		break;

	case ALPSIO_ACT_SELF_TEST_B:

		mutex_lock(&alps_lock);
		ret = hscd_self_test_B();
		mutex_unlock(&alps_lock);

		alps_info("ALPSIO_ACT_SELF_TEST_B, result = %d\n", ret);

		if (copy_to_user(argp, &ret, sizeof(ret))) {
			alps_errmsg("Failed (cmd = ALPSIO_ACT_SELF_TEST_B)\n" );
			return -EFAULT;
		}
		break;

	default:
		return -ENOTTY;
	}

	return 0;
}