Ejemplo n.º 1
0
static ssize_t srf08_store_range_mm(struct device *dev,
					struct device_attribute *attr,
					const char *buf, size_t len)
{
	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
	struct srf08_data *data = iio_priv(indio_dev);
	int ret;
	int integer, fract;

	ret = iio_str_to_fixpoint(buf, 100, &integer, &fract);
	if (ret)
		return ret;

	ret = srf08_write_range_mm(data, integer * 1000 + fract);
	if (ret < 0)
		return ret;

	return len;
}
static ssize_t adis16400_write_frequency(struct device *dev,
	struct device_attribute *attr, const char *buf, size_t len)
{
	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
	struct adis16400_state *st = iio_priv(indio_dev);
	int i, f, val;
	int ret;

	ret = iio_str_to_fixpoint(buf, 100, &i, &f);
	if (ret)
		return ret;

	val = i * 1000 + f;

	if (val <= 0)
		return -EINVAL;

	mutex_lock(&indio_dev->mlock);
	st->variant->set_freq(st, val);
	mutex_unlock(&indio_dev->mlock);

	return ret ? ret : len;
}