aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iio/industrialio-core.c30
-rw-r--r--include/linux/iio/iio.h10
2 files changed, 39 insertions, 1 deletions
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 6d8b02785647..f05289f7b512 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -708,6 +708,36 @@ static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev,
708 goto error_ret; 708 goto error_ret;
709 attrcount++; 709 attrcount++;
710 } 710 }
711 for_each_set_bit(i, &chan->info_mask_separate, sizeof(long)*8) {
712 ret = __iio_add_chan_devattr(iio_chan_info_postfix[i],
713 chan,
714 &iio_read_channel_info,
715 &iio_write_channel_info,
716 i,
717 0,
718 &indio_dev->dev,
719 &indio_dev->channel_attr_list);
720 if (ret < 0)
721 goto error_ret;
722 attrcount++;
723 }
724 for_each_set_bit(i, &chan->info_mask_shared_by_type, sizeof(long)*8) {
725 ret = __iio_add_chan_devattr(iio_chan_info_postfix[i],
726 chan,
727 &iio_read_channel_info,
728 &iio_write_channel_info,
729 i,
730 1,
731 &indio_dev->dev,
732 &indio_dev->channel_attr_list);
733 if (ret == -EBUSY) {
734 ret = 0;
735 continue;
736 } else if (ret < 0) {
737 goto error_ret;
738 }
739 attrcount++;
740 }
711 741
712 if (chan->ext_info) { 742 if (chan->ext_info) {
713 unsigned int i = 0; 743 unsigned int i = 0;
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index da8c776ba0bd..76976509d628 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -218,6 +218,10 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,
218 * endianness: little or big endian 218 * endianness: little or big endian
219 * @info_mask: What information is to be exported about this channel. 219 * @info_mask: What information is to be exported about this channel.
220 * This includes calibbias, scale etc. 220 * This includes calibbias, scale etc.
221 * @info_mask_separate: What information is to be exported that is specific to
222 * this channel.
223 * @info_mask_shared_by_type: What information is to be exported that is shared
224* by all channels of the same type.
221 * @event_mask: What events can this channel produce. 225 * @event_mask: What events can this channel produce.
222 * @ext_info: Array of extended info attributes for this channel. 226 * @ext_info: Array of extended info attributes for this channel.
223 * The array is NULL terminated, the last element should 227 * The array is NULL terminated, the last element should
@@ -253,6 +257,8 @@ struct iio_chan_spec {
253 enum iio_endian endianness; 257 enum iio_endian endianness;
254 } scan_type; 258 } scan_type;
255 long info_mask; 259 long info_mask;
260 long info_mask_separate;
261 long info_mask_shared_by_type;
256 long event_mask; 262 long event_mask;
257 const struct iio_chan_spec_ext_info *ext_info; 263 const struct iio_chan_spec_ext_info *ext_info;
258 const char *extend_name; 264 const char *extend_name;
@@ -275,7 +281,9 @@ struct iio_chan_spec {
275static inline bool iio_channel_has_info(const struct iio_chan_spec *chan, 281static inline bool iio_channel_has_info(const struct iio_chan_spec *chan,
276 enum iio_chan_info_enum type) 282 enum iio_chan_info_enum type)
277{ 283{
278 return chan->info_mask & IIO_CHAN_INFO_BITS(type); 284 return (chan->info_mask & IIO_CHAN_INFO_BITS(type)) |
285 (chan->info_mask_separate & type) |
286 (chan->info_mask_shared_by_type & type);
279} 287}
280 288
281#define IIO_ST(si, rb, sb, sh) \ 289#define IIO_ST(si, rb, sb, sh) \