ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
if (ret)
goto error_ret;
- len = sprintf(buf, "%d\n", (rx[1] & SCA3000_RING_BUF_8BIT) ? 8 : 11);
+ if (rx[1] & SCA3000_RING_BUF_8BIT)
+ len = sprintf(buf, "s8/8\n");
+ else
+ len = sprintf(buf, "s11/16\n");
kfree(rx);
error_ret:
mutex_unlock(&st->lock);
struct sca3000_state *st = indio_dev->dev_data;
int ret;
u8 *rx;
- long val;
- ret = strict_strtol(buf, 10, &val);
- if (ret)
- return ret;
mutex_lock(&st->lock);
ret = sca3000_read_data(st, SCA3000_REG_ADDR_MODE, &rx, 1);
- if (!ret)
- switch (val) {
- case 8:
- ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
- rx[1] | SCA3000_RING_BUF_8BIT);
- st->bpse = 8;
- break;
- case 11:
- ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
- rx[1] & ~SCA3000_RING_BUF_8BIT);
- st->bpse = 11;
- break;
- default:
- ret = -EINVAL;
- break;
- }
+ if (ret)
+ goto error_ret;
+ if (strncmp(buf, "s8/8", 4) == 0) {
+ ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
+ rx[1] | SCA3000_RING_BUF_8BIT);
+ st->bpse = 8;
+ } else if (strncmp(buf, "s11/16", 5) == 0) {
+ ret = sca3000_write_reg(st, SCA3000_REG_ADDR_MODE,
+ rx[1] & ~SCA3000_RING_BUF_8BIT);
+ st->bpse = 11;
+ } else
+ ret = -EINVAL;
+error_ret:
mutex_unlock(&st->lock);
return ret ? ret : len;
static IIO_SCAN_EL_C(accel_x, 0, 0, 0, NULL);
static IIO_SCAN_EL_C(accel_y, 1, 0, 0, NULL);
static IIO_SCAN_EL_C(accel_z, 2, 0, 0, NULL);
-static IIO_CONST_ATTR(accel_precision_available, "8 11");
-static IIO_DEVICE_ATTR(accel_precision,
+static IIO_CONST_ATTR(accel_type_available, "s8/8 s11/16");
+static IIO_DEVICE_ATTR(accel_type,
S_IRUGO | S_IWUSR,
sca3000_show_ring_bpse,
sca3000_store_ring_bpse,
&iio_scan_el_accel_x.dev_attr.attr,
&iio_scan_el_accel_y.dev_attr.attr,
&iio_scan_el_accel_z.dev_attr.attr,
- &iio_const_attr_accel_precision_available.dev_attr.attr,
- &iio_dev_attr_accel_precision.dev_attr.attr,
+ &iio_const_attr_accel_type_available.dev_attr.attr,
+ &iio_dev_attr_accel_type.dev_attr.attr,
NULL
};