Skip to contentSkip to conversation

IIO: Cleanups and complicated channel modifiers.

PATCH In review Jonathan Cameron 3 participants 19 messages May 30, 2012 – Jun 30, 2012

Subsystems (4)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

cover IIO: Cleanups and complicated channel modifiers.

Hi All,

Dropping the reset attributes was discussed a while back and no one could come up with a reason for having them. Unless anyone does have a good reason, lets drop these before we move the relevant drivers out of staging.

The other patches here are more 'interesting' in that they make use of modifiers for sum squared of xyz and root sum squared of x and y. These are common enough things to see and to my mind are well handled as modifiers. What do people think?

Jonathan

Jonathan Cameron (8):
staging:iio:accel drop sysfs interface for resetting devices. staging:iio:gyro:adis16260 drop sysfs interface for manual device
reset.
staging:iio:imu:adis16400 drop sysfs interface for manual device
reset.
IIO: Add a modifier for sqrt(x^2+y^2) staging:iio:accel:adis16204 fix bug in channel modifier handling staging:iio:accel:adis16204 support the rss channel via chan spec.
IIO: Add a modifier for x^2+y^2+z^2
staging:iio: Add some missing peak elements to the info_mask

 drivers/iio/industrialio-core.c            |    2 +
 drivers/staging/iio/accel/adis16201_core.c |   27 --------
 drivers/staging/iio/accel/adis16203_core.c |   28 --------
 drivers/staging/iio/accel/adis16204_core.c |  103 ++++++++--------------------
 drivers/staging/iio/accel/adis16209_core.c |   29 --------
 drivers/staging/iio/accel/adis16220_core.c |   24 -------
 drivers/staging/iio/accel/adis16240_core.c |   29 ++------
 drivers/staging/iio/gyro/adis16260_core.c  |   19 -----
 drivers/staging/iio/imu/adis16400_core.c   |   22 ------
 include/linux/iio/types.h                  |    2 +
 10 files changed, 39 insertions(+), 246 deletions(-)
Signature · 1 line
1.7.10.2
#1 lore raw

On Wed 30 May 2012 15:40, Jonathan Cameron pondered:

Quoted 6 lines

Hi All,

Dropping the reset attributes was discussed a while back and no one could come up with a reason for having them. Unless anyone does have a good reason, lets drop these before we move the relevant drivers out of staging.

This is the only way that userspace can re-initialise the device (if someone modified the calibration settings, and wants to get back to the factory setting).

That doesn't mean it's necessary - it just means that is what it was there for.

-Robin

author maintainer
#2 lore raw
Quoted 8 lines · Robin

On Wed 30 May 2012 15:40, Jonathan Cameron pondered:

Quoted 6 lines

Hi All,

Dropping the reset attributes was discussed a while back and no one could come up with a reason for having them. Unless anyone does have a good reason, lets drop these before we move the relevant drivers out of staging.

Quoted 6 lines

This is the only way that userspace can re-initialise the device (if someone modified the calibration settings, and wants to get back to the factory setting).

That doesn't mean it's necessary - it just means that is what it was there for.

Indeed, it had a usecase. In my view if people go fiddlying with those without knowing what they are doing then then deserve to need to reboot or remove and reinsert the module!

Quoted 7 lines

-Robin

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#3 lore raw

PATCH 1/8 staging:iio:accel drop sysfs interface for resetting devices.

In reply to Jonathan Cameron

There is no reason why userspace should want to do this manually. Hence, lets drop this abi.

---
 drivers/staging/iio/accel/adis16201_core.c |   27 --------------------------
 drivers/staging/iio/accel/adis16203_core.c |   28 ---------------------------
 drivers/staging/iio/accel/adis16204_core.c |   20 -------------------
 drivers/staging/iio/accel/adis16209_core.c |   29 ----------------------------
 drivers/staging/iio/accel/adis16220_core.c |   24 -----------------------
 drivers/staging/iio/accel/adis16240_core.c |   20 -------------------
 6 files changed, 148 deletions(-)
drivers/staging/iio/accel/adis16201_core.c +0 -27
index 02b3409..204106b 100644
@@ -159,21 +159,6 @@ static int adis16201_reset(struct iio_dev *indio_dev)
 	return ret;
 }
 
-static ssize_t adis16201_write_reset(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf, size_t len)
-{
-	int ret;
-	bool res;
-
-	if (len < 1)
-		return -EINVAL;
-	ret = strtobool(buf, &res);
-	if (ret || !res)
-		return ret;
-	return adis16201_reset(dev_to_iio_dev(dev));
-}
-
 int adis16201_set_irq(struct iio_dev *indio_dev, bool enable)
 {
 	int ret = 0;
@@ -507,19 +492,7 @@ static struct iio_chan_spec adis16201_channels[] = {
 	IIO_CHAN_SOFT_TIMESTAMP(7)
 };
 
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16201_write_reset, 0);
-
-static struct attribute *adis16201_attributes[] = {
-	&iio_dev_attr_reset.dev_attr.attr,
-	NULL
-};
-
-static const struct attribute_group adis16201_attribute_group = {
-	.attrs = adis16201_attributes,
-};
-
 static const struct iio_info adis16201_info = {
-	.attrs = &adis16201_attribute_group,
 	.read_raw = &adis16201_read_raw,
 	.write_raw = &adis16201_write_raw,
 	.driver_module = THIS_MODULE,
drivers/staging/iio/accel/adis16203_core.c +0 -28
index 15d46bf..22085e9 100644
@@ -178,22 +178,6 @@ static int adis16203_reset(struct iio_dev *indio_dev)
 	return ret;
 }
 
-static ssize_t adis16203_write_reset(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf, size_t len)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	if (len < 1)
-		return -EINVAL;
-	switch (buf[0]) {
-	case '1':
-	case 'y':
-	case 'Y':
-		return adis16203_reset(indio_dev);
-	}
-	return -EINVAL;
-}
-
 int adis16203_set_irq(struct iio_dev *indio_dev, bool enable)
 {
 	int ret = 0;
@@ -444,19 +428,7 @@ static struct iio_chan_spec adis16203_channels[] = {
 	IIO_CHAN_SOFT_TIMESTAMP(5),
 };
 
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16203_write_reset, 0);
-
-static struct attribute *adis16203_attributes[] = {
-	&iio_dev_attr_reset.dev_attr.attr,
-	NULL
-};
-
-static const struct attribute_group adis16203_attribute_group = {
-	.attrs = adis16203_attributes,
-};
-
 static const struct iio_info adis16203_info = {
-	.attrs = &adis16203_attribute_group,
 	.read_raw = &adis16203_read_raw,
 	.write_raw = &adis16203_write_raw,
 	.driver_module = THIS_MODULE,
drivers/staging/iio/accel/adis16204_core.c +0 -20
index ac9d95e..5c02bc6 100644
@@ -207,23 +207,6 @@ static int adis16204_reset(struct iio_dev *indio_dev)
 	return ret;
 }
 
-static ssize_t adis16204_write_reset(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf, size_t len)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-
-	if (len < 1)
-		return -EINVAL;
-	switch (buf[0]) {
-	case '1':
-	case 'y':
-	case 'Y':
-		return adis16204_reset(indio_dev);
-	}
-	return -EINVAL;
-}
-
 int adis16204_set_irq(struct iio_dev *indio_dev, bool enable)
 {
 	int ret = 0;
@@ -310,8 +293,6 @@ static IIO_DEV_ATTR_ACCEL_XYPEAK(adis16204_read_14bit_signed,
 		ADIS16204_XY_PEAK_OUT);
 static IIO_CONST_ATTR(in_accel_xy_scale, "0.017125");
 
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16204_write_reset, 0);
-
 enum adis16204_channel {
 	in_supply,
 	in_aux,
@@ -520,7 +501,6 @@ static struct iio_chan_spec adis16204_channels[] = {
 };
 
 static struct attribute *adis16204_attributes[] = {
-	&iio_dev_attr_reset.dev_attr.attr,
 	&iio_dev_attr_in_accel_xy.dev_attr.attr,
 	&iio_dev_attr_in_accel_xypeak.dev_attr.attr,
 	&iio_const_attr_in_accel_xy_scale.dev_attr.attr,
drivers/staging/iio/accel/adis16209_core.c +0 -29
index f6fd0d3..f4c82f1 100644
@@ -153,23 +153,6 @@ static int adis16209_reset(struct iio_dev *indio_dev)
 	return ret;
 }
 
-static ssize_t adis16209_write_reset(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf, size_t len)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-
-	if (len < 1)
-		return -EINVAL;
-	switch (buf[0]) {
-	case '1':
-	case 'y':
-	case 'Y':
-		return adis16209_reset(indio_dev);
-	}
-	return -EINVAL;
-}
-
 int adis16209_set_irq(struct iio_dev *indio_dev, bool enable)
 {
 	int ret = 0;
@@ -519,19 +502,7 @@ static struct iio_chan_spec adis16209_channels[] = {
 	IIO_CHAN_SOFT_TIMESTAMP(8)
 };
 
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16209_write_reset, 0);
-
-static struct attribute *adis16209_attributes[] = {
-	&iio_dev_attr_reset.dev_attr.attr,
-	NULL
-};
-
-static const struct attribute_group adis16209_attribute_group = {
-	.attrs = adis16209_attributes,
-};
-
 static const struct iio_info adis16209_info = {
-	.attrs = &adis16209_attribute_group,
 	.read_raw = &adis16209_read_raw,
 	.write_raw = &adis16209_write_raw,
 	.driver_module = THIS_MODULE,
drivers/staging/iio/accel/adis16220_core.c +0 -24
index 6a9ac89..2877410 100644
@@ -204,26 +204,6 @@ static int adis16220_reset(struct iio_dev *indio_dev)
 	return ret;
 }
 
-static ssize_t adis16220_write_reset(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf, size_t len)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	bool val;
-	int ret;
-
-	ret = strtobool(buf, &val);
-	if (ret)
-		return ret;
-	if (!val)
-		return -EINVAL;
-
-	ret = adis16220_reset(indio_dev);
-	if (ret)
-		return ret;
-	return len;
-}
-
 static ssize_t adis16220_write_capture(struct device *dev,
 		struct device_attribute *attr,
 		const char *buf, size_t len)
@@ -454,9 +434,6 @@ static struct bin_attribute adc2_bin = {
 	.size = ADIS16220_CAPTURE_SIZE,
 };
 
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL,
-		adis16220_write_reset, 0);
-
 #define IIO_DEV_ATTR_CAPTURE(_store)				\
 	IIO_DEVICE_ATTR(capture, S_IWUSR, NULL, _store, 0)
 
@@ -611,7 +588,6 @@ static const struct iio_chan_spec adis16220_channels[] = {
 };
 
 static struct attribute *adis16220_attributes[] = {
-	&iio_dev_attr_reset.dev_attr.attr,
 	&iio_dev_attr_capture.dev_attr.attr,
 	&iio_dev_attr_capture_count.dev_attr.attr,
 	NULL
drivers/staging/iio/accel/adis16240_core.c +0 -20
index 8b15eae..2df39d1 100644
@@ -199,23 +199,6 @@ static int adis16240_reset(struct iio_dev *indio_dev)
 	return ret;
 }
 
-static ssize_t adis16240_write_reset(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf, size_t len)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-
-	if (len < 1)
-		return -EINVAL;
-	switch (buf[0]) {
-	case '1':
-	case 'y':
-	case 'Y':
-		return adis16240_reset(indio_dev);
-	}
-	return -EINVAL;
-}
-
 int adis16240_set_irq(struct iio_dev *indio_dev, bool enable)
 {
 	int ret = 0;
@@ -329,8 +312,6 @@ static IIO_DEVICE_ATTR(in_accel_xyz_squared_peak_raw, S_IRUGO,
 		       adis16240_read_12bit_signed, NULL,
 		       ADIS16240_XYZPEAK_OUT);
 
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16240_write_reset, 0);
-
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("4096");
 
 enum adis16240_chan {
@@ -556,7 +537,6 @@ static struct iio_chan_spec adis16240_channels[] = {
 static struct attribute *adis16240_attributes[] = {
 	&iio_dev_attr_in_accel_xyz_squared_peak_raw.dev_attr.attr,
 	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
-	&iio_dev_attr_reset.dev_attr.attr,
 	NULL
 };
 
Signature · 1 line
1.7.10.2
maintainer Acked-by on v1 1/8
#4 lore raw

RE: [PATCH 1/8] staging:iio:accel drop sysfs interface for resetting devices.

Jonathan Cameron wrote on 2012-05-30:

Quoted 4 lines

There is no reason why userspace should want to do this manually. Hence, lets drop this abi.

Quoted 35 lines
---
 drivers/staging/iio/accel/adis16201_core.c |   27 --------------------
 ------ drivers/staging/iio/accel/adis16203_core.c |   28
 -------------------- ------- drivers/staging/iio/accel/adis16204_core.c
 |   20 ------------------- drivers/staging/iio/accel/adis16209_core.c |
   29 -------------------- --------
 drivers/staging/iio/accel/adis16220_core.c |   24 --------------------
 --- drivers/staging/iio/accel/adis16240_core.c |   20

------------------- 6 files changed, 148 deletions(-)

(quoted diff) +0 -0

b/drivers/staging/iio/accel/adis16201_core.c index 02b3409..204106b 100644 --- a/drivers/staging/iio/accel/adis16201_core.c +++ b/drivers/staging/iio/accel/adis16201_core.c @@ -159,21 +159,6 @@ static int adis16201_reset(struct iio_dev *indio_dev)

      return ret;

}

drivers/staging/iio/accel/adis16201_core.c +0 -15
-static ssize_t adis16201_write_reset(struct device *dev,
-             struct device_attribute *attr,
-             const char *buf, size_t len)
-{
-     int ret;
-     bool res;
-
-     if (len < 1)
-             return -EINVAL;
-     ret =3D strtobool(buf, &res);
-     if (ret || !res)
-             return ret;
-     return adis16201_reset(dev_to_iio_dev(dev));
-}
-
 int adis16201_set_irq(struct iio_dev *indio_dev, bool enable)
 {
      int ret =3D 0;

drivers/staging/iio/accel/adis16201_core.c static struct iio_chan_spec adis16201_channels[] =3D · line 512

Quoted 6 lines
drivers/staging/iio/accel/adis16201_core.c +0 -3
@@ -507,19 +492,7 @@ static struct iio_chan_spec adis16201_channels[] =3D
 {
      IIO_CHAN_SOFT_TIMESTAMP(7)
 };
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16201_write_reset, 0);
- -static struct attribute *adis16201_attributes[] =3D {
-     &iio_dev_attr_reset.dev_attr.attr, -    NULL -}; - -static const st=

ruct

Quoted 5 lines

attribute_group adis16201_attribute_group =3D { - .attrs =3D
adis16201_attributes, -}; -
static const struct iio_info adis16201_info =3D { - .attrs =3D
&adis16201_attribute_group, .read_raw =3D &adis16201_read_raw,

      .write_raw =3D &adis16201_write_raw,      .driver_module =3D THIS_M=

ODULE,

Quoted 27 lines
(quoted diff) +0 -0

b/drivers/staging/iio/accel/adis16203_core.c index 15d46bf..22085e9 100644 --- a/drivers/staging/iio/accel/adis16203_core.c +++ b/drivers/staging/iio/accel/adis16203_core.c @@ -178,22 +178,6 @@ static int adis16203_reset(struct iio_dev *indio_dev)

      return ret;

}

drivers/staging/iio/accel/adis16203_core.c +0 -16
-static ssize_t adis16203_write_reset(struct device *dev,
-             struct device_attribute *attr,
-             const char *buf, size_t len)
-{
-     struct iio_dev *indio_dev =3D dev_to_iio_dev(dev);
-     if (len < 1)
-             return -EINVAL;
-     switch (buf[0]) {
-     case '1':
-     case 'y':
-     case 'Y':
-             return adis16203_reset(indio_dev);
-     }
-     return -EINVAL;
-}
-
 int adis16203_set_irq(struct iio_dev *indio_dev, bool enable)
 {
      int ret =3D 0;

drivers/staging/iio/accel/adis16203_core.c static struct iio_chan_spec adis16203_channels[] =3D · line 449

Quoted 6 lines
drivers/staging/iio/accel/adis16203_core.c +0 -3
@@ -444,19 +428,7 @@ static struct iio_chan_spec adis16203_channels[] =3D
 {
      IIO_CHAN_SOFT_TIMESTAMP(5),
 };
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16203_write_reset, 0);
- -static struct attribute *adis16203_attributes[] =3D {
-     &iio_dev_attr_reset.dev_attr.attr, -    NULL -}; - -static const st=

ruct

Quoted 5 lines

attribute_group adis16203_attribute_group =3D { - .attrs =3D
adis16203_attributes, -}; -
static const struct iio_info adis16203_info =3D { - .attrs =3D
&adis16203_attribute_group, .read_raw =3D &adis16203_read_raw,

      .write_raw =3D &adis16203_write_raw,      .driver_module =3D THIS_M=

ODULE,

Quoted 73 lines
(quoted diff) +0 -0

b/drivers/staging/iio/accel/adis16204_core.c index ac9d95e..5c02bc6 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -207,23 +207,6 @@ static int adis16204_reset(struct iio_dev *indio_dev)

      return ret;

}

drivers/staging/iio/accel/adis16204_core.c +0 -19
-static ssize_t adis16204_write_reset(struct device *dev,
-             struct device_attribute *attr,
-             const char *buf, size_t len)
-{
-     struct iio_dev *indio_dev =3D dev_to_iio_dev(dev);
-
-     if (len < 1)
-             return -EINVAL;
-     switch (buf[0]) {
-     case '1':
-     case 'y':
-     case 'Y':
-             return adis16204_reset(indio_dev);
-     }
-     return -EINVAL;
-}
-
 int adis16204_set_irq(struct iio_dev *indio_dev, bool enable)
 {
      int ret =3D 0;
@@ -310,8 +293,6 @@ static
 IIO_DEV_ATTR_ACCEL_XYPEAK(adis16204_read_14bit_signed,
              ADIS16204_XY_PEAK_OUT);
 static IIO_CONST_ATTR(in_accel_xy_scale, "0.017125");
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16204_write_reset, 0);
-
 enum adis16204_channel {
      in_supply,
      in_aux,
@@ -520,7 +501,6 @@ static struct iio_chan_spec adis16204_channels[] =3D
 {
 };
 
 static struct attribute *adis16204_attributes[] =3D {
 -    &iio_dev_attr_reset.dev_attr.attr,
      &iio_dev_attr_in_accel_xy.dev_attr.attr,
      &iio_dev_attr_in_accel_xypeak.dev_attr.attr,
      &iio_const_attr_in_accel_xy_scale.dev_attr.attr,
(quoted diff) +0 -0

b/drivers/staging/iio/accel/adis16209_core.c index f6fd0d3..f4c82f1 100644 --- a/drivers/staging/iio/accel/adis16209_core.c +++ b/drivers/staging/iio/accel/adis16209_core.c @@ -153,23 +153,6 @@ static int adis16209_reset(struct iio_dev *indio_dev)

      return ret;

}

drivers/staging/iio/accel/adis16209_core.c +0 -17
-static ssize_t adis16209_write_reset(struct device *dev,
-             struct device_attribute *attr,
-             const char *buf, size_t len)
-{
-     struct iio_dev *indio_dev =3D dev_to_iio_dev(dev);
-
-     if (len < 1)
-             return -EINVAL;
-     switch (buf[0]) {
-     case '1':
-     case 'y':
-     case 'Y':
-             return adis16209_reset(indio_dev);
-     }
-     return -EINVAL;
-}
-
 int adis16209_set_irq(struct iio_dev *indio_dev, bool enable)
 {
      int ret =3D 0;

drivers/staging/iio/accel/adis16209_core.c static struct iio_chan_spec adis16209_channels[] =3D · line 524

Quoted 6 lines
drivers/staging/iio/accel/adis16209_core.c +0 -3
@@ -519,19 +502,7 @@ static struct iio_chan_spec adis16209_channels[] =3D
 {
      IIO_CHAN_SOFT_TIMESTAMP(8)
 };
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16209_write_reset, 0);
- -static struct attribute *adis16209_attributes[] =3D {
-     &iio_dev_attr_reset.dev_attr.attr, -    NULL -}; - -static const st=

ruct

Quoted 5 lines

attribute_group adis16209_attribute_group =3D { - .attrs =3D
adis16209_attributes, -}; -
static const struct iio_info adis16209_info =3D { - .attrs =3D
&adis16209_attribute_group, .read_raw =3D &adis16209_read_raw,

      .write_raw =3D &adis16209_write_raw,      .driver_module =3D THIS_M=

ODULE,

Quoted 18 lines
(quoted diff) +0 -0

b/drivers/staging/iio/accel/adis16220_core.c index 6a9ac89..2877410 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -204,26 +204,6 @@ static int adis16220_reset(struct iio_dev *indio_dev)

      return ret;

}

drivers/staging/iio/accel/adis16220_core.c +0 -11
-static ssize_t adis16220_write_reset(struct device *dev,
-             struct device_attribute *attr,
-             const char *buf, size_t len)
-{
-     struct iio_dev *indio_dev =3D dev_to_iio_dev(dev);
-     bool val;
-     int ret;
-
-     ret =3D strtobool(buf, &val);
-     if (ret)
-             return ret;

drivers/staging/iio/accel/adis16220_core.c static int adis16220_reset(struct iio_dev *indio_dev)

Quoted 10 lines
drivers/staging/iio/accel/adis16220_core.c +0 -9
-     if (!val)
-             return -EINVAL;
-
-     ret =3D adis16220_reset(indio_dev);
-     if (ret)
-             return ret;
-     return len;
-}
-
 static ssize_t adis16220_write_capture(struct device *dev,           str=

uct

Quoted 1 line

device_attribute *attr, const char *buf, size_t len) @@ -45=

4,9 +434,6

Quoted 52 lines

@@ static struct bin_attribute adc2_bin =3D { .size =3D ADIS16220_CAPTURE_SIZE, };

drivers/staging/iio/accel/adis16220_core.c +0 -3
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL,
-             adis16220_write_reset, 0);
-
 #define IIO_DEV_ATTR_CAPTURE(_store)                         \
      IIO_DEVICE_ATTR(capture, S_IWUSR, NULL, _store, 0)
@@ -611,7 +588,6 @@ static const struct iio_chan_spec
 adis16220_channels[] =3D {
 };
 
 static struct attribute *adis16220_attributes[] =3D {
 -    &iio_dev_attr_reset.dev_attr.attr,
      &iio_dev_attr_capture.dev_attr.attr,
      &iio_dev_attr_capture_count.dev_attr.attr,      NULL
(quoted diff) +0 -0

b/drivers/staging/iio/accel/adis16240_core.c index 8b15eae..2df39d1 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -199,23 +199,6 @@ static int adis16240_reset(struct iio_dev *indio_dev)

      return ret;

}

drivers/staging/iio/accel/adis16240_core.c +0 -19
-static ssize_t adis16240_write_reset(struct device *dev,
-             struct device_attribute *attr,
-             const char *buf, size_t len)
-{
-     struct iio_dev *indio_dev =3D dev_to_iio_dev(dev);
-
-     if (len < 1)
-             return -EINVAL;
-     switch (buf[0]) {
-     case '1':
-     case 'y':
-     case 'Y':
-             return adis16240_reset(indio_dev);
-     }
-     return -EINVAL;
-}
-
 int adis16240_set_irq(struct iio_dev *indio_dev, bool enable)
 {
      int ret =3D 0;
@@ -329,8 +312,6 @@ static
 IIO_DEVICE_ATTR(in_accel_xyz_squared_peak_raw, S_IRUGO,
                     adis16240_read_12bit_signed, NULL,
                     ADIS16240_XYZPEAK_OUT);
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16240_write_reset, 0);
-
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("4096");
 
 enum adis16240_chan {

drivers/staging/iio/accel/adis16240_core.c static struct iio_chan_spec adis16240_channels[] =3D · line 541

Quoted 5 lines
drivers/staging/iio/accel/adis16240_core.c +0 -0
@@ -556,7 +537,6 @@ static struct iio_chan_spec adis16240_channels[] =3D
 {
 static struct attribute *adis16240_attributes[] =3D {
      &iio_dev_attr_in_accel_xyz_squared_peak_raw.dev_attr.attr,
      &iio_const_attr_sampling_frequency_available.dev_attr.attr,
 -    &iio_dev_attr_reset.dev_attr.attr,      NULL };

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar= garet Seif

author maintainer
#5 lore raw

PATCH 2/8 staging:iio:gyro:adis16260 drop sysfs interface for manual device reset.

In reply to Jonathan Cameron

There is no reason for userspace to do this, so lets drop this abi.

---
 drivers/staging/iio/gyro/adis16260_core.c |   19 -------------------
 1 file changed, 19 deletions(-)
drivers/staging/iio/gyro/adis16260_core.c +0 -19
index ec765f9..a19bf44 100644
@@ -233,22 +233,6 @@ static int adis16260_reset(struct iio_dev *indio_dev)
 	return ret;
 }
 
-static ssize_t adis16260_write_reset(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf, size_t len)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	if (len < 1)
-		return -EINVAL;
-	switch (buf[0]) {
-	case '1':
-	case 'y':
-	case 'Y':
-		return adis16260_reset(indio_dev);
-	}
-	return -EINVAL;
-}
-
 int adis16260_set_irq(struct iio_dev *indio_dev, bool enable)
 {
 	int ret;
@@ -375,8 +359,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
 		adis16260_read_frequency,
 		adis16260_write_frequency);
 
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16260_write_reset, 0);
-
 static IIO_DEVICE_ATTR(sampling_frequency_available,
 		       S_IRUGO, adis16260_read_frequency_available, NULL, 0);
 
@@ -604,7 +586,6 @@ static int adis16260_write_raw(struct iio_dev *indio_dev,
 static struct attribute *adis16260_attributes[] = {
 	&iio_dev_attr_sampling_frequency.dev_attr.attr,
 	&iio_dev_attr_sampling_frequency_available.dev_attr.attr,
-	&iio_dev_attr_reset.dev_attr.attr,
 	NULL
 };
 
Signature · 1 line
1.7.10.2
maintainer Acked-by on v1 2/8
#6 lore raw

RE: [PATCH 2/8] staging:iio:gyro:adis16260 drop sysfs interface for manual device reset.

Jonathan Cameron wrote on 2012-05-30:

Quoted 4 lines

There is no reason for userspace to do this, so lets drop this abi.

Quoted 19 lines
---
 drivers/staging/iio/gyro/adis16260_core.c |   19 -------------------
 1 file changed, 19 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/iio/gyro/adis16260_core.c index ec765f9..a19bf44 100644 --- a/drivers/staging/iio/gyro/adis16260_core.c +++ b/drivers/staging/iio/gyro/adis16260_core.c @@ -233,22 +233,6 @@ static int adis16260_reset(struct iio_dev *indio_dev)

      return ret;

}

drivers/staging/iio/gyro/adis16260_core.c +0 -9
-static ssize_t adis16260_write_reset(struct device *dev,
-             struct device_attribute *attr,
-             const char *buf, size_t len)
-{
-     struct iio_dev *indio_dev =3D dev_to_iio_dev(dev);
-     if (len < 1)
-             return -EINVAL;
-     switch (buf[0]) {
-     case '1':

drivers/staging/iio/gyro/adis16260_core.c static int adis16260_reset(struct iio_dev *indio_dev)

Quoted 10 lines
drivers/staging/iio/gyro/adis16260_core.c +0 -7
-     case 'y':
-     case 'Y':
-             return adis16260_reset(indio_dev);
-     }
-     return -EINVAL;
-}
-
 int adis16260_set_irq(struct iio_dev *indio_dev, bool enable) {      int
 ret; @@ -375,8 +359,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR |
 S_IRUGO,             adis16260_read_frequency,               adis16260_w=

rite_frequency);

Review static int adis16260_write_raw(struct iio_dev · line 590

Quoted 12 lines
drivers/staging/iio/gyro/adis16260_core.c +0 -2
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16260_write_reset, 0);
-
 static IIO_DEVICE_ATTR(sampling_frequency_available,
                     S_IRUGO, adis16260_read_frequency_available, NULL,

0);

(quoted diff) +0 -0
@@ -604,7 +586,6 @@ static int adis16260_write_raw(struct iio_dev
 *indio_dev,
 static struct attribute *adis16260_attributes[] =3D {
      &iio_dev_attr_sampling_frequency.dev_attr.attr,
      &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
 -    &iio_dev_attr_reset.dev_attr.attr,      NULL };

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar= garet Seif

author maintainer
#7 lore raw

PATCH 3/8 staging:iio:imu:adis16400 drop sysfs interface for manual device reset.

In reply to Jonathan Cameron

There is no reason for userspace to do this, so lets drop this abi.

---
 drivers/staging/iio/imu/adis16400_core.c |   22 ----------------------
 1 file changed, 22 deletions(-)
drivers/staging/iio/imu/adis16400_core.c +0 -22
index 1f6bd85..57b165d 100644
@@ -268,25 +268,6 @@ static int adis16400_reset(struct iio_dev *indio_dev)
 	return ret;
 }
 
-static ssize_t adis16400_write_reset(struct device *dev,
-		struct device_attribute *attr,
-		const char *buf, size_t len)
-{
-	bool val;
-	int ret;
-
-	ret = strtobool(buf, &val);
-	if (ret < 0)
-		return ret;
-	if (val) {
-		ret = adis16400_reset(dev_to_iio_dev(dev));
-		if (ret < 0)
-			return ret;
-	}
-
-	return len;
-}
-
 int adis16400_set_irq(struct iio_dev *indio_dev, bool enable)
 {
 	int ret;
@@ -454,8 +435,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
 			      adis16400_read_frequency,
 			      adis16400_write_frequency);
 
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16400_write_reset, 0);
-
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
 
 enum adis16400_chan {
@@ -1064,7 +1043,6 @@ static const struct iio_chan_spec adis16334_channels[] = {
 static struct attribute *adis16400_attributes[] = {
 	&iio_dev_attr_sampling_frequency.dev_attr.attr,
 	&iio_const_attr_sampling_frequency_available.dev_attr.attr,
-	&iio_dev_attr_reset.dev_attr.attr,
 	NULL
 };
 
Signature · 1 line
1.7.10.2
maintainer Acked-by on v1 3/8
#8 lore raw

RE: [PATCH 3/8] staging:iio:imu:adis16400 drop sysfs interface for manual device reset.

Jonathan Cameron wrote on 2012-05-30:

Quoted 4 lines

There is no reason for userspace to do this, so lets drop this abi.

Quoted 39 lines
---
 drivers/staging/iio/imu/adis16400_core.c |   22 ----------------------
 1 file changed, 22 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/iio/imu/adis16400_core.c index 1f6bd85..57b165d 100644 --- a/drivers/staging/iio/imu/adis16400_core.c +++ b/drivers/staging/iio/imu/adis16400_core.c @@ -268,25 +268,6 @@ static int adis16400_reset(struct iio_dev *indio_dev)

      return ret;

}

drivers/staging/iio/imu/adis16400_core.c +0 -21
-static ssize_t adis16400_write_reset(struct device *dev,
-             struct device_attribute *attr,
-             const char *buf, size_t len)
-{
-     bool val;
-     int ret;
-
-     ret =3D strtobool(buf, &val);
-     if (ret < 0)
-             return ret;
-     if (val) {
-             ret =3D adis16400_reset(dev_to_iio_dev(dev));
-             if (ret < 0)
-                     return ret;
-     }
-
-     return len;
-}
-
 int adis16400_set_irq(struct iio_dev *indio_dev, bool enable) {      int
 ret; @@ -454,8 +435,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR |
 S_IRUGO,                           adis16400_read_frequency,
 adis16400_write_frequency);
-static IIO_DEVICE_ATTR(reset, S_IWUSR, NULL, adis16400_write_reset, 0);
-
 static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
 
 enum adis16400_chan {

drivers/staging/iio/imu/adis16400_core.c static const struct iio_chan_spec · line 1047

Quoted 5 lines
drivers/staging/iio/imu/adis16400_core.c +0 -0
@@ -1064,7 +1043,6 @@ static const struct iio_chan_spec
 adis16334_channels[] =3D {
 static struct attribute *adis16400_attributes[] =3D {
      &iio_dev_attr_sampling_frequency.dev_attr.attr,
      &iio_const_attr_sampling_frequency_available.dev_attr.attr,
 -    &iio_dev_attr_reset.dev_attr.attr,      NULL };

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar= garet Seif

author maintainer
#9 lore raw

PATCH 4/8 IIO: Add a modifier for sqrt(x^2+y^2)

In reply to Jonathan Cameron

There will probably be a number of such modifiers eventually but this one is used in the adis16204 accelerometer driver.

---
 drivers/iio/industrialio-core.c |    1 +
 include/linux/iio/types.h       |    1 +
 2 files changed, 2 insertions(+)
drivers/iio/industrialio-core.c +1 -0
index aa2edf4..071fbf1 100644
@@ -70,6 +70,7 @@ static const char * const iio_modifier_names[] = {
 	[IIO_MOD_X] = "x",
 	[IIO_MOD_Y] = "y",
 	[IIO_MOD_Z] = "z",
+	[IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
 	[IIO_MOD_LIGHT_BOTH] = "both",
 	[IIO_MOD_LIGHT_IR] = "ir",
 };
include/linux/iio/types.h +1 -0
index 1b073b1..ab907bf 100644
@@ -45,6 +45,7 @@ enum iio_modifier {
 	IIO_MOD_X_OR_Y_OR_Z,
 	IIO_MOD_LIGHT_BOTH,
 	IIO_MOD_LIGHT_IR,
+	IIO_MOD_ROOT_SUM_SQUARED_X_Y,
 };
 
 #define IIO_VAL_INT 1
Signature · 1 line
1.7.10.2
author maintainer
#10 lore raw

PATCH 5/8 staging:iio:accel:adis16204 fix bug in channel modifier handling

In reply to Jonathan Cameron

Will result in the correct scale value for the x axis.

---
 drivers/staging/iio/accel/adis16204_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/accel/adis16204_core.c +1 -1
index 5c02bc6..a36135d 100644
@@ -362,7 +362,7 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,
 			return IIO_VAL_INT_PLUS_MICRO;
 		case IIO_ACCEL:
 			*val = 0;
-			if (chan->channel == 'x')
+			if (chan->channel2 == IIO_CHAN_MOD_X)
 				*val2 = 17125;
 			else
 				*val2 = 8407;
Signature · 1 line
1.7.10.2
maintainer Acked-by on v1 5/8
#11 lore raw

RE: [PATCH 5/8] staging:iio:accel:adis16204 fix bug in channel modifier handling

Jonathan Cameron wrote on 2012-05-30:

Quoted 3 lines

Will result in the correct scale value for the x axis.

Quoted 11 lines
---
 drivers/staging/iio/accel/adis16204_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/staging/iio/accel/adis16204_core.c index 5c02bc6..a36135d 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -362,7 +362,7 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,

                      return IIO_VAL_INT_PLUS_MICRO;
              case IIO_ACCEL:
                      *val =3D 0;

Review

Quoted 5 lines
(quoted diff) +1 -1
-                     if (chan->channel =3D=3D 'x')
+                     if (chan->channel2 =3D=3D IIO_CHAN_MOD_X)
                              *val2 =3D 17125;
                      else
                              *val2 =3D 8407;

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar= garet Seif

author maintainer
#12 lore raw

Re: [PATCH 5/8] staging:iio:accel:adis16204 fix bug in channel modifier handling

Quoted 5 lines · Michael

Jonathan Cameron wrote on 2012-05-30:

Quoted 3 lines

Will result in the correct scale value for the x axis.

Quoted 13 lines

drivers/staging/iio/accel/adis16204_core.c static int adis16204_read_raw(struct iio_dev *indio_dev, · line 365

Quoted 13 lines
---
 drivers/staging/iio/accel/adis16204_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/staging/iio/accel/adis16204_core.c index 5c02bc6..a36135d 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -362,7 +362,7 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,

                      return IIO_VAL_INT_PLUS_MICRO;
              case IIO_ACCEL:
                      *val = 0;
drivers/staging/iio/accel/adis16204_core.c +1 -1
-                     if (chan->channel == 'x')
+                     if (chan->channel2 == IIO_CHAN_MOD_X)

Should be IIO_MOD_X oops. Was wiped out in the next patch. Picked up doing some final compile tests on this set.

Quoted 19 lines
Quoted 3 lines
                              *val2 = 17125;
                      else
                              *val2 = 8407;

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Margaret Seif

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author maintainer
#13 lore raw

PATCH 6/8 staging:iio:accel:adis16204 support the rss channel via chan spec.

In reply to Jonathan Cameron

Reduces code and makes this channel available within the kernel. Note that it is not added to the buffer, thus maintaining the previous functionality of this driver.

---
 drivers/staging/iio/accel/adis16204_core.c |   83 ++++++++++------------------
 1 file changed, 29 insertions(+), 54 deletions(-)
drivers/staging/iio/accel/adis16204_core.c +29 -54
index a36135d..cb8701d 100644
@@ -169,32 +169,6 @@ error_ret:
 	return ret;
 }
 
-static ssize_t adis16204_read_14bit_signed(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	s16 val = 0;
-	ssize_t ret;
-
-	mutex_lock(&indio_dev->mlock);
-
-	ret = adis16204_spi_read_reg_16(indio_dev,
-					this_attr->address, (u16 *)&val);
-	if (!ret) {
-		if (val & ADIS16204_ERROR_ACTIVE)
-			adis16204_check_status(indio_dev);
-
-		val = ((s16)(val << 2) >> 2);
-		ret = sprintf(buf, "%d\n", val);
-	}
-
-	mutex_unlock(&indio_dev->mlock);
-
-	return ret;
-}
-
 static int adis16204_reset(struct iio_dev *indio_dev)
 {
 	int ret;
@@ -282,16 +256,6 @@ err_ret:
 }
 
 /* Unique to this driver currently */
-#define IIO_DEV_ATTR_ACCEL_XY(_show, _addr)			\
-	IIO_DEVICE_ATTR(in_accel_xy, S_IRUGO, _show, NULL, _addr)
-#define IIO_DEV_ATTR_ACCEL_XYPEAK(_show, _addr)		\
-	IIO_DEVICE_ATTR(in_accel_xypeak, S_IRUGO, _show, NULL, _addr)
-
-static IIO_DEV_ATTR_ACCEL_XY(adis16204_read_14bit_signed,
-		ADIS16204_XY_RSS_OUT);
-static IIO_DEV_ATTR_ACCEL_XYPEAK(adis16204_read_14bit_signed,
-		ADIS16204_XY_PEAK_OUT);
-static IIO_CONST_ATTR(in_accel_xy_scale, "0.017125");
 
 enum adis16204_channel {
 	in_supply,
@@ -299,9 +263,10 @@ enum adis16204_channel {
 	temp,
 	accel_x,
 	accel_y,
+	accel_xy,
 };
 
-static u8 adis16204_addresses[5][3] = {
+static u8 adis16204_addresses[6][3] = {
 	[in_supply] = { ADIS16204_SUPPLY_OUT },
 	[in_aux] = { ADIS16204_AUX_ADC },
 	[temp] = { ADIS16204_TEMP_OUT },
@@ -309,6 +274,8 @@ static u8 adis16204_addresses[5][3] = {
 		      ADIS16204_X_PEAK_OUT },
 	[accel_y] = { ADIS16204_XACCL_OUT, ADIS16204_YACCL_NULL,
 		      ADIS16204_Y_PEAK_OUT },
+	[accel_xy] = { ADIS16204_XY_RSS_OUT, 0,
+		       ADIS16204_XY_PEAK_OUT },
 };
 
 static int adis16204_read_raw(struct iio_dev *indio_dev,
@@ -362,10 +329,16 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,
 			return IIO_VAL_INT_PLUS_MICRO;
 		case IIO_ACCEL:
 			*val = 0;
-			if (chan->channel2 == IIO_CHAN_MOD_X)
-				*val2 = 17125;
-			else
-				*val2 = 8407;
+			switch (chan->channel2) {
+			case IIO_MOD_X:
+			case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
+ 				*val2 = 17125;
+				break;
+			case IIO_MOD_Y:
+			case IIO_MOD_Z:
+ 				*val2 = 8407;
+				break;
+			}
 			return IIO_VAL_INT_PLUS_MICRO;
 		default:
 			return -EINVAL;
@@ -498,21 +471,23 @@ static struct iio_chan_spec adis16204_channels[] = {
 		},
 	},
 	IIO_CHAN_SOFT_TIMESTAMP(5),
-};
-
-static struct attribute *adis16204_attributes[] = {
-	&iio_dev_attr_in_accel_xy.dev_attr.attr,
-	&iio_dev_attr_in_accel_xypeak.dev_attr.attr,
-	&iio_const_attr_in_accel_xy_scale.dev_attr.attr,
-	NULL
-};
-
-static const struct attribute_group adis16204_attribute_group = {
-	.attrs = adis16204_attributes,
+	{
+		.type = IIO_ACCEL,
+		.modified = 1,
+		.channel2 = IIO_MOD_ROOT_SUM_SQUARED_X_Y,
+		.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+		IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
+		IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
+		.address = accel_xy,
+		.scan_type = {
+			.sign = 'u',
+			.realbits = 14,
+			.storagebits = 16,
+		},
+	}
 };
 
 static const struct iio_info adis16204_info = {
-	.attrs = &adis16204_attribute_group,
 	.read_raw = &adis16204_read_raw,
 	.write_raw = &adis16204_write_raw,
 	.driver_module = THIS_MODULE,
@@ -549,7 +524,7 @@ static int __devinit adis16204_probe(struct spi_device *spi)
 
 	ret = iio_buffer_register(indio_dev,
 				  adis16204_channels,
-				  ARRAY_SIZE(adis16204_channels));
+				  6);
 	if (ret) {
 		printk(KERN_ERR "failed to initialize the ring\n");
 		goto error_unreg_ring_funcs;
Signature · 1 line
1.7.10.2
author maintainer
#14 lore raw

Re: [PATCH 6/8] staging:iio:accel:adis16204 support the rss channel via chan spec.

Quoted 3 lines · Jonathan Cameron

Reduces code and makes this channel available within the kernel. Note that it is not added to the buffer, thus maintaining the previous functionality of this driver.

Sorry all, clean forgot to run checkpatch on this and some tab / space mess has snuck in. Will fixup, please just pretend it isn't there!

Quoted 147 lines
---
 drivers/staging/iio/accel/adis16204_core.c |   83 ++++++++++------------------
 1 file changed, 29 insertions(+), 54 deletions(-)
drivers/staging/iio/accel/adis16204_core.c +29 -54
index a36135d..cb8701d 100644
@@ -169,32 +169,6 @@ error_ret:
 	return ret;
 }
 
-static ssize_t adis16204_read_14bit_signed(struct device *dev,
-		struct device_attribute *attr,
-		char *buf)
-{
-	struct iio_dev *indio_dev = dev_to_iio_dev(dev);
-	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	s16 val = 0;
-	ssize_t ret;
-
-	mutex_lock(&indio_dev->mlock);
-
-	ret = adis16204_spi_read_reg_16(indio_dev,
-					this_attr->address, (u16 *)&val);
-	if (!ret) {
-		if (val & ADIS16204_ERROR_ACTIVE)
-			adis16204_check_status(indio_dev);
-
-		val = ((s16)(val << 2) >> 2);
-		ret = sprintf(buf, "%d\n", val);
-	}
-
-	mutex_unlock(&indio_dev->mlock);
-
-	return ret;
-}
-
 static int adis16204_reset(struct iio_dev *indio_dev)
 {
 	int ret;
@@ -282,16 +256,6 @@ err_ret:
 }
 
 /* Unique to this driver currently */
-#define IIO_DEV_ATTR_ACCEL_XY(_show, _addr)			\
-	IIO_DEVICE_ATTR(in_accel_xy, S_IRUGO, _show, NULL, _addr)
-#define IIO_DEV_ATTR_ACCEL_XYPEAK(_show, _addr)		\
-	IIO_DEVICE_ATTR(in_accel_xypeak, S_IRUGO, _show, NULL, _addr)
-
-static IIO_DEV_ATTR_ACCEL_XY(adis16204_read_14bit_signed,
-		ADIS16204_XY_RSS_OUT);
-static IIO_DEV_ATTR_ACCEL_XYPEAK(adis16204_read_14bit_signed,
-		ADIS16204_XY_PEAK_OUT);
-static IIO_CONST_ATTR(in_accel_xy_scale, "0.017125");
 
 enum adis16204_channel {
 	in_supply,
@@ -299,9 +263,10 @@ enum adis16204_channel {
 	temp,
 	accel_x,
 	accel_y,
+	accel_xy,
 };
 
-static u8 adis16204_addresses[5][3] = {
+static u8 adis16204_addresses[6][3] = {
 	[in_supply] = { ADIS16204_SUPPLY_OUT },
 	[in_aux] = { ADIS16204_AUX_ADC },
 	[temp] = { ADIS16204_TEMP_OUT },
@@ -309,6 +274,8 @@ static u8 adis16204_addresses[5][3] = {
 		      ADIS16204_X_PEAK_OUT },
 	[accel_y] = { ADIS16204_XACCL_OUT, ADIS16204_YACCL_NULL,
 		      ADIS16204_Y_PEAK_OUT },
+	[accel_xy] = { ADIS16204_XY_RSS_OUT, 0,
+		       ADIS16204_XY_PEAK_OUT },
 };
 
 static int adis16204_read_raw(struct iio_dev *indio_dev,
@@ -362,10 +329,16 @@ static int adis16204_read_raw(struct iio_dev *indio_dev,
 			return IIO_VAL_INT_PLUS_MICRO;
 		case IIO_ACCEL:
 			*val = 0;
-			if (chan->channel2 == IIO_CHAN_MOD_X)
-				*val2 = 17125;
-			else
-				*val2 = 8407;
+			switch (chan->channel2) {
+			case IIO_MOD_X:
+			case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
+ 				*val2 = 17125;
+				break;
+			case IIO_MOD_Y:
+			case IIO_MOD_Z:
+ 				*val2 = 8407;
+				break;
+			}
 			return IIO_VAL_INT_PLUS_MICRO;
 		default:
 			return -EINVAL;
@@ -498,21 +471,23 @@ static struct iio_chan_spec adis16204_channels[] = {
 		},
 	},
 	IIO_CHAN_SOFT_TIMESTAMP(5),
-};
-
-static struct attribute *adis16204_attributes[] = {
-	&iio_dev_attr_in_accel_xy.dev_attr.attr,
-	&iio_dev_attr_in_accel_xypeak.dev_attr.attr,
-	&iio_const_attr_in_accel_xy_scale.dev_attr.attr,
-	NULL
-};
-
-static const struct attribute_group adis16204_attribute_group = {
-	.attrs = adis16204_attributes,
+	{
+		.type = IIO_ACCEL,
+		.modified = 1,
+		.channel2 = IIO_MOD_ROOT_SUM_SQUARED_X_Y,
+		.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+		IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
+		IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
+		.address = accel_xy,
+		.scan_type = {
+			.sign = 'u',
+			.realbits = 14,
+			.storagebits = 16,
+		},
+	}
 };
 
 static const struct iio_info adis16204_info = {
-	.attrs = &adis16204_attribute_group,
 	.read_raw = &adis16204_read_raw,
 	.write_raw = &adis16204_write_raw,
 	.driver_module = THIS_MODULE,
@@ -549,7 +524,7 @@ static int __devinit adis16204_probe(struct spi_device *spi)
 
 	ret = iio_buffer_register(indio_dev,
 				  adis16204_channels,
-				  ARRAY_SIZE(adis16204_channels));
+				  6);
 	if (ret) {
 		printk(KERN_ERR "failed to initialize the ring\n");
 		goto error_unreg_ring_funcs;
maintainer Acked-by on v1 6/8
#15 lore raw

RE: [PATCH 6/8] staging:iio:accel:adis16204 support the rss channel via chan spec.

In reply to Jonathan Cameron

Jonathan Cameron wrote on 2012-05-30:

Quoted 5 lines

Reduces code and makes this channel available within the kernel. Note that it is not added to the buffer, thus maintaining the previous functionality of this driver.

Review

Quoted 12 lines
---
 drivers/staging/iio/accel/adis16204_core.c |   83 ++++++++++----------

-------- 1 file changed, 29 insertions(+), 54 deletions(-)

(quoted diff) +0 -0

b/drivers/staging/iio/accel/adis16204_core.c index a36135d..cb8701d 100644 --- a/drivers/staging/iio/accel/adis16204_core.c +++ b/drivers/staging/iio/accel/adis16204_core.c @@ -169,32 +169,6 @@ error_ret:

      return ret;

}

(quoted diff) +0 -2
-static ssize_t adis16204_read_14bit_signed(struct device *dev,
-             struct device_attribute *attr, -                char *buf) =

-{ - struct iio_dev

Quoted 1 line

*indio_dev =3D dev_to_iio_dev(dev); - struct iio_dev_attr *this_attr =

=3D

Quoted 3 lines

to_iio_dev_attr(attr); - s16 val =3D 0; - ssize_t ret; -
- mutex_lock(&indio_dev->mlock); - - ret =3D
adis16204_spi_read_reg_16(indio_dev, - =

     this_attr->address, (u16
Quoted 2 lines

*)&val); - if (!ret) { - if (val & ADIS16204_ERROR_ACTIVE)
- adis16204_check_status(indio_dev); - - val=

=3D ((s16)(val << 2) >>

Quoted 12 lines

2); - ret =3D sprintf(buf, "%d\n", val); - } -

(quoted diff) +0 -3
-     mutex_unlock(&indio_dev->mlock); - -    return ret; -} -
 static int adis16204_reset(struct iio_dev *indio_dev) {      int ret; @@
 -282,16 +256,6 @@ err_ret: }
 
 /* Unique to this driver currently */
-#define IIO_DEV_ATTR_ACCEL_XY(_show, _addr)                  \
-     IIO_DEVICE_ATTR(in_accel_xy, S_IRUGO, _show, NULL, _addr) -#define

IIO_DEV_ATTR_ACCEL_XYPEAK(_show, _addr) \

(quoted diff) +0 -3
-     IIO_DEVICE_ATTR(in_accel_xypeak, S_IRUGO, _show, NULL, _addr) -
-static IIO_DEV_ATTR_ACCEL_XY(adis16204_read_14bit_signed,
-             ADIS16204_XY_RSS_OUT); -static
Quoted 2 lines

IIO_DEV_ATTR_ACCEL_XYPEAK(adis16204_read_14bit_signed,
- ADIS16204_XY_PEAK_OUT); -static IIO_CONST_ATTR(in_accel_xy_=

scale,

Quoted 4 lines

"0.017125");

enum adis16204_channel { in_supply, @@ -299,9 +263,10 @@ enum
adis16204_channel { temp, accel_x, accel_y, + accel_xy, }=

;

Review

Quoted 4 lines
(quoted diff) +1 -1
-static u8 adis16204_addresses[5][3] =3D {
+static u8 adis16204_addresses[6][3] =3D {
      [in_supply] =3D { ADIS16204_SUPPLY_OUT },         [in_aux] =3D {
 ADIS16204_AUX_ADC },         [temp] =3D { ADIS16204_TEMP_OUT }, @@ -309,=

6 +274,8

Quoted 1 line

@@ static u8 adis16204_addresses[5][3] =3D { ADIS16204_X=

_PEAK_OUT

Quoted 30 lines

}, [accel_y] =3D { ADIS16204_XACCL_OUT, ADIS16204_YACCL_NULL,
ADIS16204_Y_PEAK_OUT },

drivers/staging/iio/accel/adis16204_core.c +12 -4
+     [accel_xy] =3D { ADIS16204_XY_RSS_OUT, 0,
+                    ADIS16204_XY_PEAK_OUT },
 };
 
 static int adis16204_read_raw(struct iio_dev *indio_dev,
@@ -362,10 +329,16 @@ static int adis16204_read_raw(struct iio_dev
 *indio_dev,
                      return IIO_VAL_INT_PLUS_MICRO;
              case IIO_ACCEL:
                      *val =3D 0;
-                     if (chan->channel2 =3D=3D IIO_CHAN_MOD_X)
-                             *val2 =3D 17125;
-                     else
-                             *val2 =3D 8407;
+                     switch (chan->channel2) {
+                     case IIO_MOD_X:
+                     case IIO_MOD_ROOT_SUM_SQUARED_X_Y:
+                             *val2 =3D 17125;
+                             break;
+                     case IIO_MOD_Y:
+                     case IIO_MOD_Z:
+                             *val2 =3D 8407;
+                             break;
+                     }
                      return IIO_VAL_INT_PLUS_MICRO;
              default:
                      return -EINVAL;

drivers/staging/iio/accel/adis16204_core.c static struct iio_chan_spec adis16204_channels[] · line 505

Quoted 8 lines
drivers/staging/iio/accel/adis16204_core.c +0 -4
@@ -498,21 +471,23 @@ static struct iio_chan_spec adis16204_channels[]
 =3D {
              },
      },
      IIO_CHAN_SOFT_TIMESTAMP(5),
-}; - -static struct attribute *adis16204_attributes[] =3D {
-     &iio_dev_attr_in_accel_xy.dev_attr.attr,
-     &iio_dev_attr_in_accel_xypeak.dev_attr.attr,
-     &iio_const_attr_in_accel_xy_scale.dev_attr.attr, -      NULL -}; - =

-static

Quoted 1 line

const struct attribute_group adis16204_attribute_group =3D { - .attrs =

=3D

Quoted 1 line

adis16204_attributes, + { + .type =3D IIO_ACCEL, + =

       .modified =3D 1,
Quoted 1 line

+ .channel2 =3D IIO_MOD_ROOT_SUM_SQUARED_X_Y, + .=

info_mask =3D

Quoted 1 line

IIO_CHAN_INFO_RAW_SEPARATE_BIT | + IIO_CHAN_INFO_SCALE_SEPARAT=

E_BIT |

Quoted 1 line

+ IIO_CHAN_INFO_PEAK_SEPARATE_BIT, + .address =

=3D accel_xy,

Quoted 1 line

+ .scan_type =3D { + .sign =3D 'u', + =

.realbits =3D 14, + .storagebits

Quoted 6 lines

=3D 16, + }, + }
};

static const struct iio_info adis16204_info =3D { - .attrs =3D
&adis16204_attribute_group, .read_raw =3D &adis16204_read_raw,

      .write_raw =3D &adis16204_write_raw,      .driver_module =3D THIS_M=

ODULE,

Quoted 10 lines
drivers/staging/iio/accel/adis16204_core.c +1 -1
@@ -549,7 +524,7 @@ static int __devinit adis16204_probe(struct
 spi_device *spi)
 
      ret =3D iio_buffer_register(indio_dev,
                                adis16204_channels,
-                               ARRAY_SIZE(adis16204_channels));
+                               6);
      if (ret) {
              printk(KERN_ERR "failed to initialize the ring\n");
              goto error_unreg_ring_funcs;

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar= garet Seif

author maintainer
#16 lore raw

PATCH 7/8 IIO: Add a modifier for x^2+y^2+z^2

In reply to Jonathan Cameron

There will probably be a number of such modifiers eventually but this one is used in the adis16240 accelerometer driver.

---
 drivers/iio/industrialio-core.c |    1 +
 include/linux/iio/types.h       |    1 +
 2 files changed, 2 insertions(+)
drivers/iio/industrialio-core.c +1 -0
index 071fbf1..6c433e8 100644
@@ -71,6 +71,7 @@ static const char * const iio_modifier_names[] = {
 	[IIO_MOD_Y] = "y",
 	[IIO_MOD_Z] = "z",
 	[IIO_MOD_ROOT_SUM_SQUARED_X_Y] = "sqrt(x^2+y^2)",
+	[IIO_MOD_SUM_SQUARED_X_Y_Z] = "x^2+y^2+z^2",
 	[IIO_MOD_LIGHT_BOTH] = "both",
 	[IIO_MOD_LIGHT_IR] = "ir",
 };
include/linux/iio/types.h +1 -0
index ab907bf..2ca6058 100644
@@ -46,6 +46,7 @@ enum iio_modifier {
 	IIO_MOD_LIGHT_BOTH,
 	IIO_MOD_LIGHT_IR,
 	IIO_MOD_ROOT_SUM_SQUARED_X_Y,
+	IIO_MOD_SUM_SQUARED_X_Y_Z,
 };
 
 #define IIO_VAL_INT 1
Signature · 1 line
1.7.10.2
author maintainer
#17 lore raw

PATCH 8/8 staging:iio: Add some missing peak elements to the info_mask

In reply to Jonathan Cameron

These are supported by raw_read but not actually there.

---
 drivers/staging/iio/accel/adis16240_core.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/staging/iio/accel/adis16240_core.c +6 -3
index 2df39d1..3f30a99 100644
@@ -481,7 +481,8 @@ static struct iio_chan_spec adis16240_channels[] = {
 		.channel2 = IIO_MOD_X,
 		.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
 		IIO_CHAN_INFO_SCALE_SHARED_BIT |
-		IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+		IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+		IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
 		.address = accel_x,
 		.scan_index = ADIS16240_SCAN_ACC_X,
 		.scan_type = {
@@ -495,7 +496,8 @@ static struct iio_chan_spec adis16240_channels[] = {
 		.channel2 = IIO_MOD_Y,
 		.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
 		IIO_CHAN_INFO_SCALE_SHARED_BIT |
-		IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+		IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+		IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
 		.address = accel_y,
 		.scan_index = ADIS16240_SCAN_ACC_Y,
 		.scan_type = {
@@ -509,7 +511,8 @@ static struct iio_chan_spec adis16240_channels[] = {
 		.channel2 = IIO_MOD_Z,
 		.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
 		IIO_CHAN_INFO_SCALE_SHARED_BIT |
-		IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+		IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+		IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
 		.address = accel_z,
 		.scan_index = ADIS16240_SCAN_ACC_Z,
 		.scan_type = {
Signature · 1 line
1.7.10.2
maintainer Acked-by on v1 8/8
#18 lore raw

RE: [PATCH 8/8] staging:iio: Add some missing peak elements to the info_mask

Jonathan Cameron wrote on 2012-05-30:

Quoted 3 lines

These are supported by raw_read but not actually there.

Quoted 38 lines
---
 drivers/staging/iio/accel/adis16240_core.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/iio/accel/adis16240_core.c index 2df39d1..3f30a99 100644 --- a/drivers/staging/iio/accel/adis16240_core.c +++ b/drivers/staging/iio/accel/adis16240_core.c @@ -481,7 +481,8 @@ static struct iio_chan_spec adis16240_channels[] =3D {
.channel2 =3D IIO_MOD_X,
.info_mask =3D IIO_CHAN_INFO_RAW_SEPARATE_BIT | IIO_CHAN_INFO_SCALE_SHARED_BIT |

drivers/staging/iio/accel/adis16240_core.c +4 -2
-             IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+             IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+             IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
              .address =3D accel_x,
              .scan_index =3D ADIS16240_SCAN_ACC_X,
              .scan_type =3D {
@@ -495,7 +496,8 @@ static struct iio_chan_spec adis16240_channels[] =3D
 {
              .channel2 =3D IIO_MOD_Y,
              .info_mask =3D IIO_CHAN_INFO_RAW_SEPARATE_BIT |
              IIO_CHAN_INFO_SCALE_SHARED_BIT |
-             IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+             IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+             IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
              .address =3D accel_y,
              .scan_index =3D ADIS16240_SCAN_ACC_Y,
              .scan_type =3D {
(quoted diff) +2 -1
@@ -509,7 +511,8 @@ static struct iio_chan_spec adis16240_channels[] =3D
 {
              .channel2 =3D IIO_MOD_Z,
              .info_mask =3D IIO_CHAN_INFO_RAW_SEPARATE_BIT |
              IIO_CHAN_INFO_SCALE_SHARED_BIT |
-             IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT,
+             IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
+             IIO_CHAN_INFO_PEAK_SEPARATE_BIT,
              .address =3D accel_z,
              .scan_index =3D ADIS16240_SCAN_ACC_Z,
Quoted 1 line
              .scan_type =3D {

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368; Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin, Mar= garet Seif