Esempio n. 1
0
static int isl29028_proxim_get(struct isl29028_chip *chip, int *prox_data)
{
	int ret;

	if (!chip->enable_prox) {
		ret = isl29028_enable_proximity(chip, true);
		if (ret < 0)
			return ret;
		chip->enable_prox = true;
	}
	return isl29028_read_proxim(chip, prox_data);
}
/* Display proxim data  */
static ssize_t show_proxim_data(struct device *dev,
	struct device_attribute *attr, char *buf)
{
	struct iio_dev *indio_dev = dev_get_drvdata(dev);
	struct isl29028_chip *chip = iio_priv(indio_dev);
	int prox_data;
	bool st;
	ssize_t buf_count = 0;

	dev_vdbg(dev, "%s()\n", __func__);
	mutex_lock(&chip->lock);

	if (chip->is_prox_enable) {
		st = isl29028_read_proxim(chip->client, &prox_data);
		if (st) {
			buf_count = sprintf(buf, "%d\n", prox_data);
			chip->prox_reading = prox_data;
		}
	} else
		buf_count = sprintf(buf, "%d\n", chip->prox_reading);

	mutex_unlock(&chip->lock);
	return buf_count;
}