/* These are described as signed 12 bit on the data sheet, which appears to be a conventional 2's complement 13 bit.  */
static ssize_t sca3000_read_13bit_signed(struct device *dev, struct device_attribute *attr, char *buf)
/* These are described as signed 12 bit on the data sheet, which appears to be a conventional 2's complement 13 bit.  */
static ssize_t sca3000_read_13bit_signed(struct device *dev, struct device_attribute *attr, char *buf)
{
	int len = 0, ret;
	int val;
	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
	u8 *rx;
	struct iio_dev *indio_dev = dev_get_drvdata(dev);
	struct sca3000_state *st = indio_dev->dev_data;
	mutex_lock(&st->lock);
	ret = sca3000_read_data(st, this_attr->address, &rx, 2);
	if (ret < 0)
		goto error_ret;
	val = sca3000_13bit_convert(rx[1], rx[2]);
	len += sprintf(buf + len, "%d\n", val);
	kfree(rx);
error_ret:
	mutex_unlock(&st->lock);
	return ret ? ret : len;
}