IIO: Refactor info_mask* and ext_info handling and introduce info_mask_shared_[by_all/by_type]
Subsystems (5)
Jonathan Cameron
maintainerv2 cover IIO: Refactor info_mask* and ext_info handling and introduce info_mask_shared_[by_all/by_type]
Changes since V1.
1) Deal with ext_info as well as the info_mask.
In the previous set things sort of worked by coincidence of the ordering in the enum. This version handles this cleanly.
2) Dropped the bonus const in tmp006.
Original message :
This series first performs a bit of refactoring of the core handling of info_mask_separate and info_mask_shared_by_type.
Next we introduce info_mask_shared_by_dir and info_mask_shared_by_all to allow for attributes of the form
in_sampling_frequency or sampling_frequency as appropriate.
Most existing drivers will make no use of the shared_by_dir case, but it is there to handle devices with both and input and output channels.
There are two main reasons for adding these two cases.
1) Should result in shorter code, particularly for complex drivers.
2) Allows for in kernel consumers accessing this functionality.
The intent is to follow this series with one providing a standard way of providing 'available' attributes. The combination of the two should mean that very few things are still handled via direct registration of attributes.
Thanks,
Jonathan
Jonathan Cameron (5):
iio: drop info_mask from struct iio_dev
iio: refactor info mask and ext_info attribute creation.
iio: add info_mask_[shared_by_dir/shared_by_all] staging:iio: dummy driver additions to show shared_by_dir infomask
usage
iio:temperature:tmp006 put sampling_frequency in
info_mask_shared_by_all
drivers/iio/dac/ad5064.c | 3 +- drivers/iio/dac/ad5380.c | 4 +- drivers/iio/dac/ad5446.c | 3 +- drivers/iio/dac/ad5504.c | 4 +- drivers/iio/dac/ad5624r_spi.c | 4 +- drivers/iio/dac/ad5686.c | 3 +- drivers/iio/dac/ad5755.c | 1 + drivers/iio/dac/ad5791.c | 5 +- drivers/iio/dac/ad7303.c | 1 + drivers/iio/dac/mcp4725.c | 3 +- drivers/iio/frequency/adf4350.c | 1 + drivers/iio/iio_core.h | 2 +- drivers/iio/industrialio-buffer.c | 2 +- drivers/iio/industrialio-core.c | 179 ++++++++++++++++++++------------- drivers/iio/temperature/tmp006.c | 57 +++++------ drivers/staging/iio/iio_simple_dummy.c | 16 +++ include/linux/iio/iio.h | 24 +++-- 17 files changed, 195 insertions(+), 117 deletions(-)
Signature · 1 line
1.8.3.4
Jonathan Cameron
maintainerPATCH v2 1/5 iio: drop info_mask from struct iio_dev
Somehow this got missed when dropping all the code that used it prior to the split. Remove it now, there are no users.
--- include/linux/iio/iio.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
include/linux/iio/iio.h +1 -4
@@ -146,12 +146,10 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,* shift: Shift right by this before masking out * realbits. * endianness: little or big endian -* @info_mask: What information is to be exported about this channel. -* This includes calibbias, scale etc. * @info_mask_separate: What information is to be exported that is specific to * this channel. * @info_mask_shared_by_type: What information is to be exported that is shared -* by all channels of the same type. +* by all channels of the same type. * @event_mask: What events can this channel produce. * @ext_info: Array of extended info attributes for this channel. * The array is NULL terminated, the last element should
@@ -186,7 +184,6 @@ struct iio_chan_spec {u8 shift;enum iio_endian endianness; } scan_type; -long info_mask;long info_mask_separate;long info_mask_shared_by_type;long event_mask;
Signature · 1 line
1.8.3.4
Jonathan Cameron
maintainerPATCH v2 2/5 iio: refactor info mask and ext_info attribute creation.
In reply to Jonathan CameronIntroduce an enum to specify whether the attribute is separate or shared.
Factor out the bitmap handling for loop into a separate function.
Tidy up error handling and add a NULL assignment to squish a false positive warning from GCC.
Change ext_info shared type from boolean to enum and update in all drivers.
--- drivers/iio/dac/ad5064.c | 3 +- drivers/iio/dac/ad5380.c | 4 +- drivers/iio/dac/ad5446.c | 3 +- drivers/iio/dac/ad5504.c | 4 +- drivers/iio/dac/ad5624r_spi.c | 4 +- drivers/iio/dac/ad5686.c | 3 +- drivers/iio/dac/ad5755.c | 1 + drivers/iio/dac/ad5791.c | 5 +- drivers/iio/dac/ad7303.c | 1 + drivers/iio/dac/mcp4725.c | 3 +- drivers/iio/frequency/adf4350.c | 1 + drivers/iio/iio_core.h | 2 +- drivers/iio/industrialio-buffer.c | 2 +- drivers/iio/industrialio-core.c | 149 ++++++++++++++++++++------------------ include/linux/iio/iio.h | 7 +- 15 files changed, 110 insertions(+), 82 deletions(-)
drivers/iio/dac/ad5064.c +2 -1
@@ -285,8 +285,9 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = { .name = "powerdown", .read = ad5064_read_dac_powerdown, .write = ad5064_write_dac_powerdown, + .shared = IIO_SEPARATE, }, - IIO_ENUM("powerdown_mode", false, &ad5064_powerdown_mode_enum), + IIO_ENUM("powerdown_mode", IIO_SEPARATE, &ad5064_powerdown_mode_enum), IIO_ENUM_AVAILABLE("powerdown_mode", &ad5064_powerdown_mode_enum), { }, };
drivers/iio/dac/ad5380.c +3 -1
@@ -247,8 +247,10 @@ static struct iio_chan_spec_ext_info ad5380_ext_info[] = { .name = "powerdown", .read = ad5380_read_dac_powerdown, .write = ad5380_write_dac_powerdown, + .shared = IIO_SEPARATE, }, - IIO_ENUM("powerdown_mode", true, &ad5380_powerdown_mode_enum), + IIO_ENUM("powerdown_mode", IIO_SHARED_BY_TYPE, + &ad5380_powerdown_mode_enum), IIO_ENUM_AVAILABLE("powerdown_mode", &ad5380_powerdown_mode_enum), { }, };
drivers/iio/dac/ad5446.c +2 -1
@@ -132,8 +132,9 @@ static const struct iio_chan_spec_ext_info ad5446_ext_info_powerdown[] = { .name = "powerdown", .read = ad5446_read_dac_powerdown, .write = ad5446_write_dac_powerdown, + .shared = IIO_SEPARATE, }, - IIO_ENUM("powerdown_mode", false, &ad5446_powerdown_mode_enum), + IIO_ENUM("powerdown_mode", IIO_SEPARATE, &ad5446_powerdown_mode_enum), IIO_ENUM_AVAILABLE("powerdown_mode", &ad5446_powerdown_mode_enum), { }, };
drivers/iio/dac/ad5504.c +3 -1
@@ -248,8 +248,10 @@ static const struct iio_chan_spec_ext_info ad5504_ext_info[] = { .name = "powerdown", .read = ad5504_read_dac_powerdown, .write = ad5504_write_dac_powerdown, + .shared = IIO_SEPARATE, }, - IIO_ENUM("powerdown_mode", true, &ad5504_powerdown_mode_enum), + IIO_ENUM("powerdown_mode", IIO_SHARED_BY_TYPE, + &ad5504_powerdown_mode_enum), IIO_ENUM_AVAILABLE("powerdown_mode", &ad5504_powerdown_mode_enum), { }, };
drivers/iio/dac/ad5624r_spi.c +3 -1
@@ -163,8 +163,10 @@ static const struct iio_chan_spec_ext_info ad5624r_ext_info[] = { .name = "powerdown", .read = ad5624r_read_dac_powerdown, .write = ad5624r_write_dac_powerdown, + .shared = IIO_SEPARATE, }, - IIO_ENUM("powerdown_mode", true, &ad5624r_powerdown_mode_enum), + IIO_ENUM("powerdown_mode", IIO_SHARED_BY_TYPE, + &ad5624r_powerdown_mode_enum), IIO_ENUM_AVAILABLE("powerdown_mode", &ad5624r_powerdown_mode_enum), { }, };
drivers/iio/dac/ad5686.c +2 -1
@@ -265,8 +265,9 @@ static const struct iio_chan_spec_ext_info ad5686_ext_info[] = { .name = "powerdown", .read = ad5686_read_dac_powerdown, .write = ad5686_write_dac_powerdown, + .shared = IIO_SEPARATE, }, - IIO_ENUM("powerdown_mode", false, &ad5686_powerdown_mode_enum), + IIO_ENUM("powerdown_mode", IIO_SEPARATE, &ad5686_powerdown_mode_enum), IIO_ENUM_AVAILABLE("powerdown_mode", &ad5686_powerdown_mode_enum), { }, };
drivers/iio/dac/ad5755.c +1 -0
@@ -386,6 +386,7 @@ static const struct iio_chan_spec_ext_info ad5755_ext_info[] = { .name = "powerdown", .read = ad5755_read_powerdown, .write = ad5755_write_powerdown, + .shared = IIO_SEPARATE, }, { }, };
drivers/iio/dac/ad5791.c +3 -2
@@ -287,11 +287,12 @@ static int ad5791_read_raw(struct iio_dev *indio_dev,static const struct iio_chan_spec_ext_info ad5791_ext_info[] = { { .name ="powerdown" , - .shared = true, + .shared =IIO_SHARED_BY_TYPE , .read = ad5791_read_dac_powerdown, .write = ad5791_write_dac_powerdown, }, -IIO_ENUM ("powerdown_mode" , true, &ad5791_powerdown_mode_enum), +IIO_ENUM ("powerdown_mode" ,IIO_SHARED_BY_TYPE , + &ad5791_powerdown_mode_enum),IIO_ENUM_AVAILABLE ("powerdown_mode" , &ad5791_powerdown_mode_enum), { }, };
drivers/iio/dac/ad7303.c +1 -0
@@ -169,6 +169,7 @@ static const struct iio_chan_spec_ext_info ad7303_ext_info[] = { .name = "powerdown", .read = ad7303_read_dac_powerdown, .write = ad7303_write_dac_powerdown, + .shared = IIO_SEPARATE, }, { }, };
drivers/iio/dac/mcp4725.c +2 -1
@@ -195,8 +195,9 @@ static const struct iio_chan_spec_ext_info mcp4725_ext_info[] = { .name = "powerdown", .read = mcp4725_read_powerdown, .write = mcp4725_write_powerdown, + .shared = IIO_SEPARATE, }, - IIO_ENUM("powerdown_mode", false, &mcp4725_powerdown_mode_enum), + IIO_ENUM("powerdown_mode", IIO_SEPARATE, &mcp4725_powerdown_mode_enum), IIO_ENUM_AVAILABLE("powerdown_mode", &mcp4725_powerdown_mode_enum), { }, };
drivers/iio/frequency/adf4350.c +1 -0
@@ -351,6 +351,7 @@ static ssize_t adf4350_read(struct iio_dev *indio_dev, .read = adf4350_read, \ .write = adf4350_write, \ .private = _ident, \ + .shared = IIO_SEPARATE, \ }static const struct iio_chan_spec_ext_info adf4350_ext_info[] = {
drivers/iio/iio_core.h +1 -1
@@ -30,7 +30,7 @@ int __iio_add_chan_devattr(const char *postfix,const char *buf, size_t len), u64 mask, - bool generic, + enum iio_shared_by shared_by, struct device *dev, struct list_head *attr_list);
drivers/iio/industrialio-buffer.c +1 -1
@@ -214,7 +214,7 @@ static int iio_buffer_add_channel_sysfs(struct iio_dev *indio_dev, &iio_show_scan_index,NULL ,0 , -0 , +IIO_SEPARATE , &indio_dev->dev, &buffer->scan_el_dev_attr_list);if (ret)
drivers/iio/industrialio-core.c +80 -69
245 lines not on this page · raw message
include/linux/iio/iio.h +5 -2
@@ -38,6 +38,9 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_HYSTERESIS, }; +enum iio_shared_by {IIO_SEPARATE , +IIO_SHARED_BY_TYPE }; +enum iio_endian {IIO_CPU ,IIO_BE ,
@@ -57,7 +60,7 @@ struct iio_dev;*/ struct iio_chan_spec_ext_info {const char *name; -bool shared; +enum iio_shared_by shared;ssize_t (*read)(struct iio_dev *,uintptr_t private,struct iio_chan_spec const *,char *buf); ssize_t (*write)(struct iio_dev *, uintptr_t private,
@@ -125,7 +128,7 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,#define IIO_ENUM_AVAILABLE (_name, _e) \ { \ .name = (_name "_available"), \ - .shared = true, \ + .shared = IIO_SHARED_BY_TYPE, \ .read = iio_enum_available_read, \ .private = (uintptr_t)(_e), \ }
Signature · 1 line
1.8.3.4
Re: [PATCH 2/5] iio: refactor info mask and ext_info attribute creation.
[...]
include/linux/iio/iio.h enum iio_chan_info_enum { · line 43
Quoted 11 lines
include/linux/iio/iio.h +3
-0@@ -38,6 +38,9 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_HYSTERESIS, }; +enum iio_shared_by {IIO_SEPARATE , +IIO_SHARED_BY_TYPE }; +
That's not kernel style formating, is it?
enum iio_shared_by {
IIO_SEPARATE,
IIO_SHARED_BY_TYPE,
};
... looks much better in my opinion
[...]
Jonathan Cameron
maintainerRe: [PATCH 2/5] iio: refactor info mask and ext_info attribute creation.
Quoted 15 lines · Lars-Peter Clausen
[...]
include/linux/iio/iio.h enum iio_chan_info_enum { · line 43
Quoted 11 lines
include/linux/iio/iio.h +3
-0@@ -38,6 +38,9 @@ enum iio_chan_info_enum { IIO_CHAN_INFO_HYSTERESIS, }; +enum iio_shared_by {IIO_SEPARATE , +IIO_SHARED_BY_TYPE }; +That's not kernel style formating, is it?
Quoted 7 lines
enum
iio_shared_by{
IIO_SEPARATE,
IIO_SHARED_BY_TYPE,
};... looks much better in my opinion
Fair point, v3 coming up.
Quoted 2 lines
[...]
Jonathan Cameron
maintainerPATCH v2 3/5 iio: add info_mask_[shared_by_dir/shared_by_all]
In reply to Jonathan CameronThese two additional info_mask bitmaps should allow all 'standard' numeric attributes to be handled using the read_raw and write_raw callbacks. Whilst this should reduce code, the more important element is that this makes these values easily accessible to in kernel users of IIO devices.
--- drivers/iio/industrialio-core.c | 30 ++++++++++++++++++++++++++++++ include/linux/iio/iio.h | 14 ++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-)
drivers/iio/industrialio-core.c +30 -0
@@ -550,6 +550,14 @@ int __iio_device_attr_init(struct device_attribute *dev_attr,if (chan->differential) {/* Differential can not have modifier */ switch (shared_by) { +case IIO_SHARED_BY_ALL : + name_format =kasprintf (GFP_KERNEL ,"%s" , full_postfix); +break ; +case IIO_SHARED_BY_DIR : + name_format =kasprintf (GFP_KERNEL ,"%s_%s" , + iio_direction[chan->output], + full_postfix); +break ;case IIO_SHARED_BY_TYPE : name_format = kasprintf(GFP_KERNEL, "%s_%s-%s_%s",
@@ -577,6 +585,14 @@ int __iio_device_attr_init(struct device_attribute *dev_attr, } }else {/* Single ended */ switch (shared_by) { +case IIO_SHARED_BY_ALL : + name_format =kasprintf (GFP_KERNEL ,"%s" , full_postfix); +break ; +case IIO_SHARED_BY_DIR : + name_format =kasprintf (GFP_KERNEL ,"%s_%s" , + iio_direction[chan->output], + full_postfix); +break ;case IIO_SHARED_BY_TYPE : name_format = kasprintf(GFP_KERNEL, "%s_%s_%s",
@@ -735,6 +751,20 @@ static int iio_device_add_channel_sysfs(struct iio_dev *indio_dev,return ret; attrcount += ret; + ret =iio_device_add_info_mask_type (indio_dev, chan, +IIO_SHARED_BY_DIR , + &chan->info_mask_shared_by_dir); +if (ret <0 ) +return ret; + attrcount += ret; + + ret =iio_device_add_info_mask_type (indio_dev, chan, +IIO_SHARED_BY_ALL , + &chan->info_mask_shared_by_all); +if (ret <0 ) +return ret; + attrcount += ret; +if (chan->ext_info) {unsigned int i =0 ;for (ext_info = chan->ext_info; ext_info->name; ext_info++) {
include/linux/iio/iio.h +12 -2
@@ -39,7 +39,9 @@ enum iio_chan_info_enum { };enum iio_shared_by {IIO_SEPARATE , -IIO_SHARED_BY_TYPE }; +IIO_SHARED_BY_TYPE , +IIO_SHARED_BY_DIR , +IIO_SHARED_BY_ALL };enum iio_endian {IIO_CPU ,
@@ -153,6 +155,10 @@ ssize_t iio_enum_write(struct iio_dev *indio_dev,* this channel. * @info_mask_shared_by_type: What information is to be exported that is shared * by all channels of the same type. +* @info_mask_shared_by_dir: What information is to be exported that is shared +* by all channels of the same direction. +* @info_mask_shared_by_all: What information is to be exported that is shared +* by all channels. * @event_mask: What events can this channel produce. * @ext_info: Array of extended info attributes for this channel. * The array is NULL terminated, the last element should
@@ -189,6 +195,8 @@ struct iio_chan_spec { } scan_type;long info_mask_separate;long info_mask_shared_by_type; +long info_mask_shared_by_dir; +long info_mask_shared_by_all;long event_mask;const struct iio_chan_spec_ext_info *ext_info;const char *extend_name;
@@ -212,7 +220,9 @@ static inline bool iio_channel_has_info(const struct iio_chan_spec *chan, enum iio_chan_info_enum type) {return (chan->info_mask_separate &BIT (type)) | - (chan->info_mask_shared_by_type &BIT (type)); + (chan->info_mask_shared_by_type &BIT (type)) | + (chan->info_mask_shared_by_dir &BIT (type)) | + (chan->info_mask_shared_by_all &BIT (type)); }#define IIO_ST (si, rb, sb, sh) \
Signature · 1 line
1.8.3.4
Jonathan Cameron
maintainerPATCH v2 4/5 staging:iio: dummy driver additions to show shared_by_dir infomask usage
In reply to Jonathan CameronNote that as this driver has output as well as output channels an example of info_mask_shared_by_all that makes any sense does not exist.
--- drivers/staging/iio/iio_simple_dummy.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/staging/iio/iio_simple_dummy.c +16 -0
@@ -90,6 +90,11 @@ static const struct iio_chan_spec iio_dummy_channels[] = {* when converting to standard units (microvolts) */ BIT (IIO_CHAN_INFO_SCALE ), +/* +* sampling_frequency +* The frequency in Hz at which the channels are sampled +*/ + .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ),/* The ordering of elements in the buffer via an enum */ .scan_index = voltage0, .scan_type = { /* Description of storage in buffer */
@@ -130,6 +135,10 @@ static const struct iio_chan_spec iio_dummy_channels[] = {* input channels of type IIO_VOLTAGE. */ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), + /* + * sampling_frequency + * The frequency in Hz at which the channels are sampled + */ .scan_index = diffvoltage1m2, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */
@@ -147,6 +156,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = { .channel2 = 4, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), .scan_index = diffvoltage3m4, .scan_type = { .sign = 's',
@@ -173,6 +183,7 @@ static const struct iio_chan_spec iio_dummy_channels[] = {*/ BIT (IIO_CHAN_INFO_CALIBSCALE ) | BIT(IIO_CHAN_INFO_CALIBBIAS), + .info_mask_shared_by_dir = BIT(IIO_CHAN_INFO_SAMP_FREQ), .scan_index = accelx, .scan_type = { /* Description of storage in buffer */ .sign = 's', /* signed */
@@ -272,6 +283,11 @@ static int iio_dummy_read_raw(struct iio_dev *indio_dev, *val2 = st->accel_calibscale->val2; ret =IIO_VAL_INT_PLUS_MICRO ;break ; +case IIO_CHAN_INFO_SAMP_FREQ : + *val =3 ; + *val2 =33 ; + ret =IIO_VAL_INT_PLUS_NANO ; +break ;default :break ; }
Signature · 1 line
1.8.3.4
Jonathan Cameron
maintainerPATCH v2 5/5 iio:temperature:tmp006 put sampling_frequency in info_mask_shared_by_all
In reply to Jonathan CameronDoing this makes it possible to access this control from within the kernel.
--- drivers/iio/temperature/tmp006.c | 57 +++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 30 deletions(-)
drivers/iio/temperature/tmp006.c +27 -30
@@ -70,12 +70,16 @@ static int tmp006_read_measurement(struct tmp006_data *data, u8 reg)return i2c_smbus_read_word_swapped (data->client, reg); } +static const int tmp006_freqs[5 ][2 ] = { {4 ,0 }, {2 ,0 }, {1 ,0 }, + {0 ,500000 }, {0 ,250000 } }; +static int tmp006_read_raw (struct iio_dev *indio_dev,struct iio_chan_spec const *channel,int *val,int *val2,long mask) {struct tmp006_data *data =iio_priv (indio_dev);s32 ret; +int cr;switch (mask) {case IIO_CHAN_INFO_RAW :
@@ -106,6 +110,12 @@ static int tmp006_read_raw(struct iio_dev *indio_dev,break ; }return IIO_VAL_INT_PLUS_MICRO ; +case IIO_CHAN_INFO_SAMP_FREQ : + cr = (data->config &TMP006_CONFIG_CR_MASK ) + >>TMP006_CONFIG_CR_SHIFT ; + *val = tmp006_freqs[cr][0 ]; + *val2 = tmp006_freqs[cr][1 ]; +return IIO_VAL_INT_PLUS_MICRO ;default :break ; }
@@ -113,48 +123,32 @@ static int tmp006_read_raw(struct iio_dev *indio_dev,return -EINVAL ; } -static const char *const tmp006_freqs[] = {"4" ,"2" ,"1" ,"0.5" ,"0.25" }; - -static ssize_t tmp006_show_freq (struct device *dev, -struct device_attribute *attr,char *buf) -{ -struct tmp006_data *data =iio_priv (dev_to_iio_dev (dev)); -int cr = (data->config &TMP006_CONFIG_CR_MASK ) - >>TMP006_CONFIG_CR_SHIFT ; -return sprintf (buf,"%s\n" , tmp006_freqs[cr]); -} - -static ssize_t tmp006_store_freq (struct device *dev, -struct device_attribute *attr, -const char *buf,size_t len) +static int tmp006_write_raw (struct iio_dev *indio_dev, +struct iio_chan_spec const *chan, +int val, +int val2, +long mask) { -struct iio_dev *indio_dev =dev_to_iio_dev (dev);struct tmp006_data *data =iio_priv (indio_dev);int i; -bool found = false;for (i =0 ; i <ARRAY_SIZE (tmp006_freqs); i++) -if (sysfs_streq (buf, tmp006_freqs[i])) { - found = true; -break ; - } -if (!found) -return -EINVAL ; +if ((val == tmp006_freqs[i][0 ]) && + (val2 == tmp006_freqs[i][1 ])) { + data->config &= ~TMP006_CONFIG_CR_MASK ; + data->config |= i <<TMP006_CONFIG_CR_SHIFT ; - data->config &= ~TMP006_CONFIG_CR_MASK ; - data->config |= i <<TMP006_CONFIG_CR_SHIFT ; +return i2c_smbus_write_word_swapped (data->client, +TMP006_CONFIG , + data->config); -return i2c_smbus_write_word_swapped (data->client,TMP006_CONFIG , - data->config); + } +return -EINVAL ; } -static IIO_DEV_ATTR_SAMP_FREQ(S_IRUGO | S_IWUSR, - tmp006_show_freq, tmp006_store_freq); - static IIO_CONST_ATTR(sampling_frequency_available, "4 2 1 0.5 0.25");static struct attribute *tmp006_attributes[] = { - &iio_dev_attr_sampling_frequency.dev_attr.attr, &iio_const_attr_sampling_frequency_available.dev_attr.attr,NULL };
@@ -168,16 +162,19 @@ static const struct iio_chan_spec tmp006_channels[] = { .type = IIO_VOLTAGE, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), }, { .type = IIO_TEMP, .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE), + .info_mask_shared_by_all = BIT(IIO_CHAN_INFO_SAMP_FREQ), } };static const struct iio_info tmp006_info = { .read_raw = tmp006_read_raw, + .write_raw = tmp006_write_raw, .attrs = &tmp006_attribute_group, .driver_module =THIS_MODULE , };
Signature · 1 line
1.8.3.4
Jonathan Cameron
maintainerIf anyone has a chance to review this series, particularly patches 2 and 3 that would be a great help!
Thanks,
Jonathan
Quoted 63 lines · Jonathan Cameron
Changes since V1.
1) Deal withext_infoas well as theinfo_mask.
In the previous set things sort of worked by coincidence of the ordering in the enum. This version handles this cleanly.
2) Dropped the bonus const in tmp006.Original message :
This series first performs a bit of refactoring of the core handling of
info_mask_separateandinfo_mask_shared_by_type.Next we introduce
info_mask_shared_by_dirandinfo_mask_shared_by_allto allow for attributes of the form
in_sampling_frequencyorsampling_frequencyas appropriate.Most existing drivers will make no use of the
shared_by_dircase, but it is there to handle devices with both and input and output channels.There are two main reasons for adding these two cases.
1) Should result in shorter code, particularly for complex drivers.
2) Allows for in kernel consumers accessing this functionality.The intent is to follow this series with one providing a standard way of providing 'available' attributes. The combination of the two should mean that very few things are still handled via direct registration of attributes.
Thanks,
Jonathan
Jonathan Cameron (5):
iio: dropinfo_maskfrom structiio_dev
iio: refactor info mask andext_infoattribute creation.
iio: add info_mask_[shared_by_dir/shared_by_all] staging:iio: dummy driver additions to showshared_by_dirinfomask
usage
iio:temperature:tmp006 putsampling_frequencyin
info_mask_shared_by_alldrivers/iio/dac/ad5064.c | 3 +- drivers/iio/dac/ad5380.c | 4 +- drivers/iio/dac/ad5446.c | 3 +- drivers/iio/dac/ad5504.c | 4 +- drivers/iio/dac/ad5624r_spi.c | 4 +- drivers/iio/dac/ad5686.c | 3 +- drivers/iio/dac/ad5755.c | 1 + drivers/iio/dac/ad5791.c | 5 +- drivers/iio/dac/ad7303.c | 1 + drivers/iio/dac/mcp4725.c | 3 +- drivers/iio/frequency/adf4350.c | 1 + drivers/iio/iio_core.h | 2 +- drivers/iio/industrialio-buffer.c | 2 +- drivers/iio/industrialio-core.c | 179 ++++++++++++++++++++------------- drivers/iio/temperature/tmp006.c | 57 +++++------ drivers/staging/iio/iio_simple_dummy.c | 16 +++ include/linux/iio/iio.h | 24 +++-- 17 files changed, 195 insertions(+), 117 deletions(-)
Quoted 20 lines · Jonathan Cameron
Changes since V1.
1) Deal withext_infoas well as theinfo_mask.
In the previous set things sort of worked by coincidence of the ordering in the enum. This version handles this cleanly.
2) Dropped the bonus const in tmp006.Original message :
This series first performs a bit of refactoring of the core handling of
info_mask_separateandinfo_mask_shared_by_type.Next we introduce
info_mask_shared_by_dirandinfo_mask_shared_by_allto allow for attributes of the form
in_sampling_frequencyorsampling_frequencyas appropriate.Most existing drivers will make no use of the
shared_by_dircase, but it is there to handle devices with both and input and output channels.
Quoted 8 lines
There are two main reasons for adding these two cases.
1) Should result in shorter code, particularly for complex drivers.
2) Allows for in kernel consumers accessing this functionality.The intent is to follow this series with one providing a standard way of providing 'available' attributes. The combination of the two should mean that very few things are still handled via direct registration of attributes.
Makes sense and looks good, except for that enum formating issue.