Esempio n. 1
0
static ssize_t bh1721fvc_poll_delay_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t size)
{
	int err;
	int64_t new_delay;
	struct bh1721fvc_data *bh1721fvc = dev_get_drvdata(dev);

	err = strict_strtoll(buf, 10, &new_delay);
	if (err < 0)
		return err;

	bh1721fvc_dbmsg("new delay = %lldns, old delay = %lldns\n",
			new_delay, ktime_to_ns(bh1721fvc->light_poll_delay));

	mutex_lock(&bh1721fvc->lock);
	if (new_delay != ktime_to_ns(bh1721fvc->light_poll_delay)) {
		bh1721fvc->light_poll_delay = ns_to_ktime(new_delay);
		if (bh1721fvc_is_measuring(bh1721fvc)) {
			bh1721fvc_disable(bh1721fvc);
			bh1721fvc_enable(bh1721fvc);
		}

	}
	mutex_unlock(&bh1721fvc->lock);

	return size;
}
static ssize_t poll_delay_store(struct device *dev,
			struct device_attribute *attr,
			const char *buf, size_t size)
{
	struct mlx90615_data *mlx90615 = dev_get_drvdata(dev);
	int64_t new_delay;
	int err;
	pr_info("[BODYTEMP] %s : %s\n", __func__, buf);
	err = strict_strtoll(buf, 10, &new_delay);
	if (err < 0)
		return err;

	mutex_lock(&mlx90615->power_lock);
	if (new_delay != ktime_to_ns(mlx90615->poll_delay)) {
#if 0
		if (new_delay < ktime_to_ns(mlx90615->poll_delay))
			mlx90615->poll_delay =
				ns_to_ktime(DEFAULT_DELAY * NSEC_PER_MSEC);
		else
#endif
			mlx90615->poll_delay = ns_to_ktime(new_delay);
		if (mlx90615->enabled) {
			mlx90615_disable(mlx90615);
			mlx90615_enable(mlx90615);
		}
		pr_info("[BODYTEMP] %s, poll_delay = %lld\n",
			__func__, new_delay);
	}
	mutex_unlock(&mlx90615->power_lock);

	return size;
}
Esempio n. 3
0
static ssize_t poll_delay_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t size)
{
	struct bh1721_data *bh1721 = dev_get_drvdata(dev);
	int64_t new_delay;
	int err;

	err = strict_strtoll(buf, 10, &new_delay);
	if (err < 0)
		return err;

	printk("[Light Sensor] new delay = %lldns, old delay = %lldns\n",
		    new_delay, ktime_to_ns(bh1721->light_poll_delay));
	mutex_lock(&bh1721->power_lock);
	if (new_delay != ktime_to_ns(bh1721->light_poll_delay)) {
		bh1721->light_poll_delay = ns_to_ktime(new_delay);
		if (bh1721->power_state & LIGHT_ENABLED) {
			bh1721_light_disable(bh1721);
			bh1721_light_enable(bh1721);
		}
	}
	mutex_unlock(&bh1721->power_lock);

	return size;
}
Esempio n. 4
0
static ssize_t set_sensors_enable(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	int64_t dTemp;
	unsigned int uNewEnable = 0, uChangedSensor = 0;
	struct ssp_data *data = dev_get_drvdata(dev);

	if (strict_strtoll(buf, 10, &dTemp) < 0)
		return -1;

	uNewEnable = (unsigned int)dTemp;
	ssp_dbg("[SSP]: %s - new_enable = %u, old_enable = %u\n", __func__,
		 uNewEnable, atomic_read(&data->aSensorEnable));

	if (uNewEnable == atomic_read(&data->aSensorEnable))
		return 0;

	for (uChangedSensor = 0; uChangedSensor < SENSOR_MAX; uChangedSensor++)
		if ((atomic_read(&data->aSensorEnable) & (1 << uChangedSensor))
			!= (uNewEnable & (1 << uChangedSensor))) {

			if (uNewEnable & (1 << uChangedSensor))
				ssp_add_sensor(data, uChangedSensor);
			else
				ssp_remove_sensor(data, uChangedSensor,
					uNewEnable);
			break;
		}

	atomic_set(&data->aSensorEnable, uNewEnable);

	return size;
}
Esempio n. 5
0
static ssize_t poll_delay_store(struct device *dev,
				struct device_attribute *attr,
				const char *buf, size_t size)
{
	struct gp2a_data *gp2a = dev_get_drvdata(dev);
	int64_t new_delay;
	int err;

	err = strict_strtoll(buf, 10, &new_delay);
	if (err < 0)
		return err;

	gp2a_dbgmsg("new delay = %lldns, old delay = %lldns\n",
		    new_delay, ktime_to_ns(gp2a->light_poll_delay));
	mutex_lock(&gp2a->power_lock);
	if (new_delay != ktime_to_ns(gp2a->light_poll_delay)) {
		gp2a->light_poll_delay = ns_to_ktime(new_delay);
		if (gp2a->power_state & LIGHT_ENABLED) {
			gp2a_light_disable(gp2a);
			gp2a_light_enable(gp2a);
		}
	}
	mutex_unlock(&gp2a->power_lock);

	return size;
}
Esempio n. 6
0
static ssize_t cm36686_poll_delay_store(struct device *dev,
					struct device_attribute *attr,
					const char *buf, size_t size)
{
	struct cm36686_data *cm36686 = dev_get_drvdata(dev);
	int64_t new_delay;
	int err;

	err = strict_strtoll(buf, 10, &new_delay);
	if (err < 0)
		return err;

	mutex_lock(&cm36686->power_lock);
	if (new_delay != ktime_to_ns(cm36686->light_poll_delay)) {
		cm36686->light_poll_delay = ns_to_ktime(new_delay);
		if (cm36686->power_state & LIGHT_ENABLED) {
			cm36686_light_disable(cm36686);
			cm36686_light_enable(cm36686);
		}
		pr_info("%s, poll_delay = %lld\n", __func__, new_delay);
	}
	mutex_unlock(&cm36686->power_lock);

	return size;
}
Esempio n. 7
0
static int read_sysfs_interface(const char *pbuf, s32 *pvalue, u8 base)
{
	long long val;
	int rc;

	rc = strict_strtoll(pbuf, base, &val);
	if (!rc)
		*pvalue = (s32)val;

	return rc;
}
Esempio n. 8
0
static ssize_t set_prox_delay(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	int64_t dNewDelay;
	struct ssp_data *data  = dev_get_drvdata(dev);

	if (strict_strtoll(buf, 10, &dNewDelay) < 0)
		return -1;

	change_sensor_delay(data, PROXIMITY_SENSOR, dNewDelay);
	return size;
}
Esempio n. 9
0
static ssize_t store_ami_poll_delay(struct device* dev, struct device_attribute* attr, const char *buf, size_t count)
{
	struct i2c_client *client = to_i2c_client(dev);
	struct ami306_dev_data *pdata = i2c_get_clientdata(client);
	int64_t new_delay;
	int err;

	err = strict_strtoll(buf, 10, &new_delay);
	if (err < 0)
		return err;

	pdata->poll_delay = ns_to_ktime(new_delay);
	return count;
}
Esempio n. 10
0
static ssize_t lsm330dlc_gyro_set_delay(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	int res;
	struct lsm330dlc_gyro_data *data  = dev_get_drvdata(dev);
	u64 delay_ns;

	res = strict_strtoll(buf, 10, &delay_ns);
	if (res < 0)
		return res;

	lsm330dlc_gyro_set_delay_ns(data, delay_ns);

	return size;
}
Esempio n. 11
0
static ssize_t set_sensors_enable(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	int64_t dTemp;
	unsigned int uNewEnable = 0, uChangedSensor = 0;
	struct ssp_data *data = dev_get_drvdata(dev);
	int iRet;

	if (strict_strtoll(buf, 10, &dTemp) < 0)
		return -1;

	uNewEnable = (unsigned int)dTemp;
	ssp_dbg("[SSP]: %s - new_enable = %u, old_enable = %u\n", __func__,
		 uNewEnable, atomic_read(&data->aSensorEnable));

	if (uNewEnable == atomic_read(&data->aSensorEnable))
		return 0;

	for (uChangedSensor = 0; uChangedSensor < SENSOR_MAX; uChangedSensor++)
		if ((atomic_read(&data->aSensorEnable) & (1 << uChangedSensor))
			!= (uNewEnable & (1 << uChangedSensor))) {

		        if (!(uNewEnable & (1 << uChangedSensor)))
                                ssp_remove_sensor(data, uChangedSensor,
					uNewEnable); /* disable */
			else { /* Change to ADD_SENSOR_STATE from KitKat */
			      if (data->aiCheckStatus[uChangedSensor] == INITIALIZATION_STATE) {
                                      if (uChangedSensor == ACCELEROMETER_SENSOR)
                                               accel_open_calibration(data);
                                      else if (uChangedSensor == GYROSCOPE_SENSOR)
                                               gyro_open_calibration(data);
                                      else if (uChangedSensor == PRESSURE_SENSOR)
                                               pressure_open_calibration(data);
                                      else if (uChangedSensor == PROXIMITY_SENSOR) {
                                               proximity_open_lcd_ldi(data);
                                               proximity_open_calibration(data);
                                      }
                             }
                             data->aiCheckStatus[uChangedSensor] = ADD_SENSOR_STATE;
			}
			break;
		}

	atomic_set(&data->aSensorEnable, uNewEnable);

	return size;
}
Esempio n. 12
0
static ssize_t accel_calibration_store(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	int iRet;
	int64_t dEnable;
	struct ssp_data *data = dev_get_drvdata(dev);

	iRet = strict_strtoll(buf, 10, &dEnable);
	if (iRet < 0)
		return iRet;

	iRet = accel_do_calibrate(data, (int)dEnable);
	if (iRet < 0)
		pr_err("[SSP]: %s - accel_do_calibrate() failed\n", __func__);

	return size;
}
Esempio n. 13
0
static ssize_t set_acc_delay(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	int64_t dNewDelay;
	struct ssp_data *data = dev_get_drvdata(dev);

	if (strict_strtoll(buf, 10, &dNewDelay) < 0)
		return -1;

	if ((atomic_read(&data->aSensorEnable) & (1 << ORIENTATION_SENSOR)) &&
		(data->adDelayBuf[ORIENTATION_SENSOR] < dNewDelay))
		data->adDelayBuf[ACCELEROMETER_SENSOR] = dNewDelay;
	else
		change_sensor_delay(data, ACCELEROMETER_SENSOR, dNewDelay);

	return size;
}
static ssize_t barcode_emul_enable_store(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	int iRet;
	int64_t dEnable;
	struct ssp_data *data = dev_get_drvdata(dev);

	iRet = strict_strtoll(buf, 10, &dEnable);
	if (iRet < 0)
		return iRet;

	if (dEnable)
		set_proximity_barcode_enable(data, true);
	else
		set_proximity_barcode_enable(data, false);

	return size;
}
Esempio n. 15
0
static ssize_t set_ori_delay(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	int64_t dNewDelay;
	struct ssp_data *data = dev_get_drvdata(dev);

	if (strict_strtoll(buf, 10, &dNewDelay) < 0)
		return -1;

	if (data->aiCheckStatus[ACCELEROMETER_SENSOR] == NO_SENSOR_STATE) {
		data->aiCheckStatus[ACCELEROMETER_SENSOR] = ADD_SENSOR_STATE;
		change_sensor_delay(data, ORIENTATION_SENSOR, dNewDelay);
	} else if (data->aiCheckStatus[ACCELEROMETER_SENSOR] ==
			RUNNING_SENSOR_STATE) {
		if (dNewDelay < data->adDelayBuf[ACCELEROMETER_SENSOR])
			change_sensor_delay(data,
				ORIENTATION_SENSOR, dNewDelay);
		else
			data->adDelayBuf[ORIENTATION_SENSOR] = dNewDelay;
	}
	return size;
}
static ssize_t proximity_avg_store(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t size)
{
	char chTempbuf[2] = { 1, 20};
	int iRet;
	int64_t dEnable;
	struct ssp_data *data = dev_get_drvdata(dev);

	iRet = strict_strtoll(buf, 10, &dEnable);
	if (iRet < 0)
		return iRet;

	if (dEnable) {
		send_instruction(data, ADD_SENSOR, PROXIMITY_RAW, chTempbuf, 2);
		data->bProximityRawEnabled = true;
	} else {
		send_instruction(data, REMOVE_SENSOR, PROXIMITY_RAW,
			chTempbuf, 2);
		data->bProximityRawEnabled = false;
	}

	return size;
}
Esempio n. 17
0
static ssize_t poll_delay_store(struct device *dev,struct device_attribute *attr, const char *buf, size_t size)
{
	int64_t new_delay;
	int err;

	err = strict_strtoll(buf, 10, &new_delay);
	if (err < 0)
		return err;

	printk("new delay = %lldns, old delay = %lldns\n",
		    new_delay, ktime_to_ns(bma020.acc_poll_delay));
	mutex_lock(&bma020.power_lock);
	if (new_delay != ktime_to_ns(bma020.acc_poll_delay)) {
		bma_acc_disable();
		bma020.acc_poll_delay = ns_to_ktime(new_delay);
		if (bma020.state & ACC_ENABLED) {
			bma_acc_enable();
		}
	}
	mutex_unlock(&bma020.power_lock);

	return size;
}
Esempio n. 18
0
static ssize_t k3g_set_delay(struct device *dev,
		struct device_attribute *attr, const char *buf, size_t size)
{
	struct k3g_data *k3g_data  = dev_get_drvdata(dev);
	int odr_value = ODR105_BW25;
	int res = 0;
	int i;
	u64 delay_ns;
	u8 ctrl;

	if(DEBUG_FUNC_TRACE & debug_mask)
		printk(KERN_INFO "%s: line %d\n", __func__, __LINE__);
    
	res = strict_strtoll(buf, 10, &delay_ns);
	if (res < 0)
		return res;

	if(DEBUG_FUNC_TRACE & debug_mask)
		printk(KERN_INFO "%s: line %d\n", __func__, __LINE__);

	mutex_lock(&k3g_data->lock);
	if (!k3g_data->interruptible)
		hrtimer_cancel(&k3g_data->timer);
	else
		disable_irq(k3g_data->client->irq);

	/* round to the nearest supported ODR that is less than
	 * the requested value
	 */
	for (i = 0; i < ARRAY_SIZE(odr_delay_table); i++)
		if (delay_ns <= odr_delay_table[i].delay_ns) 
		{
			odr_value = odr_delay_table[i].odr;
			delay_ns = odr_delay_table[i].delay_ns;
			k3g_data->time_to_read = delay_ns;
			k3g_data->entries = 1;
			break;
		}

	if (delay_ns >= odr_delay_table[3].delay_ns) 
	{
		if (delay_ns >= MAX_DELAY) 
		{
			k3g_data->entries = MAX_ENTRY;
			delay_ns = MAX_DELAY;
		} 
		else 
		{
			do_div(delay_ns, odr_delay_table[3].delay_ns);
			k3g_data->entries = delay_ns;
		}
		k3g_data->time_to_read = odr_delay_table[3].delay_ns;
	}

	if (odr_value != (k3g_data->ctrl_regs[0] & ODR_MASK)) {
		ctrl = (k3g_data->ctrl_regs[0] & ~ODR_MASK);
		ctrl |= odr_value;
		k3g_data->ctrl_regs[0] = ctrl;
		res = i2c_smbus_write_byte_data(k3g_data->client,
						CTRL_REG1, ctrl);
	}

	/* we see a noise in the first sample or two after we
	 * change rates.  this delay helps eliminate that noise.
	 */
	msleep((u32)delay_ns * 2 / NSEC_PER_MSEC);

	/* (re)start fifo */
	k3g_restart_fifo(k3g_data);

	if (!k3g_data->interruptible) 
	{
		delay_ns = k3g_data->entries * k3g_data->time_to_read;
		k3g_data->polling_delay = ns_to_ktime(delay_ns);
		if (k3g_data->enable)
			hrtimer_start(&k3g_data->timer,
				k3g_data->polling_delay, HRTIMER_MODE_REL);
	} 
	else
	{
		enable_irq(k3g_data->client->irq);
    }

	mutex_unlock(&k3g_data->lock);

	return size;
}