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; }
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; }