Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 304650
b: refs/heads/master
c: 67eedba
h: refs/heads/master
v: v3
  • Loading branch information
Michael Hennerich authored and Greg Kroah-Hartman committed May 14, 2012
1 parent 9368b97 commit 6166953
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 49b81a3c7415d9b02169f37b8559d468fd17686a
refs/heads/master: 67eedba39ed1ac29908453647652c02fbbeeca1b
19 changes: 13 additions & 6 deletions trunk/drivers/iio/industrialio-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,26 +295,33 @@ static ssize_t iio_read_channel_info(struct device *dev,
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int val, val2;
bool scale_db = false;
int ret = indio_dev->info->read_raw(indio_dev, this_attr->c,
&val, &val2, this_attr->address);

if (ret < 0)
return ret;

if (ret == IIO_VAL_INT)
switch (ret) {
case IIO_VAL_INT:
return sprintf(buf, "%d\n", val);
else if (ret == IIO_VAL_INT_PLUS_MICRO) {
case IIO_VAL_INT_PLUS_MICRO_DB:
scale_db = true;
case IIO_VAL_INT_PLUS_MICRO:
if (val2 < 0)
return sprintf(buf, "-%d.%06u\n", val, -val2);
return sprintf(buf, "-%d.%06u%s\n", val, -val2,
scale_db ? " dB" : "");
else
return sprintf(buf, "%d.%06u\n", val, val2);
} else if (ret == IIO_VAL_INT_PLUS_NANO) {
return sprintf(buf, "%d.%06u%s\n", val, val2,
scale_db ? " dB" : "");
case IIO_VAL_INT_PLUS_NANO:
if (val2 < 0)
return sprintf(buf, "-%d.%09u\n", val, -val2);
else
return sprintf(buf, "%d.%09u\n", val, val2);
} else
default:
return 0;
}
}

static ssize_t iio_write_channel_info(struct device *dev,
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/iio/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ enum iio_modifier {
#define IIO_VAL_INT 1
#define IIO_VAL_INT_PLUS_MICRO 2
#define IIO_VAL_INT_PLUS_NANO 3
#define IIO_VAL_INT_PLUS_MICRO_DB 4

#endif /* _IIO_TYPES_H_ */

0 comments on commit 6166953

Please sign in to comment.