Skip to content

Commit f66f4e1

Browse files
dlechnunojsa
authored andcommitted
Revert "iio: add support for multiple scan types per channel"
Revert commit f1aa31e ("iio: add support for multiple scan types per channel"). Somehow, this was not the same as the upstream commit. The actual upstream commit will be added in a following commit. Signed-off-by: David Lechner <[email protected]>
1 parent 3b06f2e commit f66f4e1

File tree

2 files changed

+22
-92
lines changed

2 files changed

+22
-92
lines changed

drivers/iio/industrialio-buffer.c

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -399,16 +399,9 @@ static ssize_t iio_show_fixed_type(struct device *dev,
399399
struct device_attribute *attr,
400400
char *buf)
401401
{
402-
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
403402
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
404-
const struct iio_scan_type *scan_type;
405-
u8 type;
406-
407-
scan_type = iio_get_current_scan_type(indio_dev, this_attr->c);
408-
if (IS_ERR(scan_type))
409-
return PTR_ERR(scan_type);
410-
411-
type = scan_type->endianness;
403+
const struct iio_scan_type *scan_type = &this_attr->c->scan_type;
404+
u8 type = scan_type->endianness;
412405

413406
if (type == IIO_CPU) {
414407
#ifdef __LITTLE_ENDIAN
@@ -739,20 +732,24 @@ static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
739732
return sysfs_emit(buf, "%d\n", iio_buffer_is_active(buffer));
740733
}
741734

742-
static int iio_storage_bytes_for_si(struct iio_dev *indio_dev,
743-
unsigned int scan_index)
735+
static unsigned int iio_storage_bytes_for_si(struct iio_dev *indio_dev,
736+
unsigned int scan_index)
744737
{
745738
const struct iio_chan_spec *ch;
739+
const struct iio_scan_type *scan_type;
746740
unsigned int bytes;
747741

748742
ch = iio_find_channel_from_si(indio_dev, scan_index);
749-
bytes = ch->scan_type.storagebits / 8;
750-
if (ch->scan_type.repeat > 1)
751-
bytes *= ch->scan_type.repeat;
743+
scan_type = &ch->scan_type;
744+
bytes = scan_type->storagebits / 8;
745+
746+
if (scan_type->repeat > 1)
747+
bytes *= scan_type->repeat;
748+
752749
return bytes;
753750
}
754751

755-
static int iio_storage_bytes_for_timestamp(struct iio_dev *indio_dev)
752+
static unsigned int iio_storage_bytes_for_timestamp(struct iio_dev *indio_dev)
756753
{
757754
struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
758755

@@ -770,19 +767,13 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev,
770767
for_each_set_bit(i, mask,
771768
indio_dev->masklength) {
772769
length = iio_storage_bytes_for_si(indio_dev, i);
773-
if (length < 0)
774-
return length;
775-
776770
bytes = ALIGN(bytes, length);
777771
bytes += length;
778772
largest = max(largest, length);
779773
}
780774

781775
if (timestamp) {
782776
length = iio_storage_bytes_for_timestamp(indio_dev);
783-
if (length < 0)
784-
return length;
785-
786777
bytes = ALIGN(bytes, length);
787778
bytes += length;
788779
largest = max(largest, length);
@@ -1061,22 +1052,14 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
10611052
indio_dev->masklength,
10621053
in_ind + 1);
10631054
while (in_ind != out_ind) {
1064-
ret = iio_storage_bytes_for_si(indio_dev, in_ind);
1065-
if (ret < 0)
1066-
goto error_clear_mux_table;
1067-
1068-
length = ret;
1055+
length = iio_storage_bytes_for_si(indio_dev, in_ind);
10691056
/* Make sure we are aligned */
10701057
in_loc = roundup(in_loc, length) + length;
10711058
in_ind = find_next_bit(indio_dev->active_scan_mask,
10721059
indio_dev->masklength,
10731060
in_ind + 1);
10741061
}
1075-
ret = iio_storage_bytes_for_si(indio_dev, in_ind);
1076-
if (ret < 0)
1077-
goto error_clear_mux_table;
1078-
1079-
length = ret;
1062+
length = iio_storage_bytes_for_si(indio_dev, in_ind);
10801063
out_loc = roundup(out_loc, length);
10811064
in_loc = roundup(in_loc, length);
10821065
ret = iio_buffer_add_demux(buffer, &p, in_loc, out_loc, length);
@@ -1087,11 +1070,7 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
10871070
}
10881071
/* Relies on scan_timestamp being last */
10891072
if (buffer->scan_timestamp) {
1090-
ret = iio_storage_bytes_for_timestamp(indio_dev);
1091-
if (ret < 0)
1092-
goto error_clear_mux_table;
1093-
1094-
length = ret;
1073+
length = iio_storage_bytes_for_timestamp(indio_dev);
10951074
out_loc = roundup(out_loc, length);
10961075
in_loc = roundup(in_loc, length);
10971076
ret = iio_buffer_add_demux(buffer, &p, in_loc, out_loc, length);
@@ -1920,14 +1899,16 @@ static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
19201899
if (channels[i].scan_index < 0)
19211900
continue;
19221901

1902+
scan_type = &channels[i].scan_type;
1903+
19231904
/* Verify that sample bits fit into storage */
19241905
if (scan_type->storagebits <
19251906
scan_type->realbits + scan_type->shift) {
19261907
dev_err(&indio_dev->dev,
19271908
"Channel %d storagebits (%d) < shifted realbits (%d + %d)\n",
1928-
i, channels[i].scan_type.storagebits,
1929-
channels[i].scan_type.realbits,
1930-
channels[i].scan_type.shift);
1909+
i, scan_type->storagebits,
1910+
scan_type->realbits,
1911+
scan_type->shift);
19311912
ret = -EINVAL;
19321913
goto error_cleanup_dynamic;
19331914
}

include/linux/iio/iio.h

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,7 @@ struct iio_scan_type {
204204
* @address: Driver specific identifier.
205205
* @scan_index: Monotonic index to give ordering in scans when read
206206
* from a buffer.
207-
* @scan_type: struct describing the scan type - mutually exclusive
208-
* with ext_scan_type.
209-
* @ext_scan_type: Used in rare cases where there is more than one scan
210-
* format for a channel. When this is used, the flag
211-
* has_ext_scan_type must be set and the driver must
212-
* implement get_current_scan_type in struct iio_info.
213-
* @num_ext_scan_type: Number of elements in ext_scan_type.
207+
* @scan_type: struct describing the scan type
214208
* @info_mask_separate: What information is to be exported that is specific to
215209
* this channel.
216210
* @info_mask_separate_available: What availability information is to be
@@ -251,21 +245,14 @@ struct iio_scan_type {
251245
* attributes but not for event codes.
252246
* @output: Channel is output.
253247
* @differential: Channel is differential.
254-
* @has_ext_scan_type: True if ext_scan_type is used instead of scan_type.
255248
*/
256249
struct iio_chan_spec {
257250
enum iio_chan_type type;
258251
int channel;
259252
int channel2;
260253
unsigned long address;
261254
int scan_index;
262-
union {
263-
struct iio_scan_type scan_type;
264-
struct {
265-
const struct iio_scan_type *ext_scan_type;
266-
unsigned int num_ext_scan_type;
267-
};
268-
};
255+
struct iio_scan_type scan_type;
269256
long info_mask_separate;
270257
long info_mask_separate_available;
271258
long info_mask_shared_by_type;
@@ -283,7 +270,6 @@ struct iio_chan_spec {
283270
unsigned indexed:1;
284271
unsigned output:1;
285272
unsigned differential:1;
286-
unsigned has_ext_scan_type:1;
287273
};
288274

289275

@@ -441,9 +427,6 @@ struct iio_trigger; /* forward declaration */
441427
* for better event identification.
442428
* @validate_trigger: function to validate the trigger when the
443429
* current trigger gets changed.
444-
* @get_current_scan_type: must be implemented by drivers that use ext_scan_type
445-
* in the channel spec to return the index of the currently
446-
* active ext_scan type for a channel.
447430
* @update_scan_mode: function to configure device and scan buffer when
448431
* channels have changed
449432
* @debugfs_reg_access: function to read or write register value of device
@@ -534,8 +517,6 @@ struct iio_info {
534517

535518
int (*validate_trigger)(struct iio_dev *indio_dev,
536519
struct iio_trigger *trig);
537-
int (*get_current_scan_type)(const struct iio_dev *indio_dev,
538-
const struct iio_chan_spec *chan);
539520
int (*update_scan_mode)(struct iio_dev *indio_dev,
540521
const unsigned long *scan_mask);
541522
int (*debugfs_reg_access)(struct iio_dev *indio_dev,
@@ -806,38 +787,6 @@ static inline struct dentry *iio_get_debugfs_dentry(struct iio_dev *indio_dev)
806787
}
807788
#endif
808789

809-
/**
810-
* iio_get_current_scan_type - Get the current scan type for a channel
811-
* @indio_dev: the IIO device to get the scan type for
812-
* @chan: the channel to get the scan type for
813-
*
814-
* Most devices only have one scan type per channel and can just access it
815-
* directly without calling this function. Core IIO code and drivers that
816-
* implement ext_scan_type in the channel spec should use this function to
817-
* get the current scan type for a channel.
818-
*
819-
* Returns: the current scan type for the channel or error.
820-
*/
821-
static inline const struct iio_scan_type
822-
*iio_get_current_scan_type(const struct iio_dev *indio_dev,
823-
const struct iio_chan_spec *chan)
824-
{
825-
int ret;
826-
827-
if (chan->has_ext_scan_type) {
828-
ret = indio_dev->info->get_current_scan_type(indio_dev, chan);
829-
if (ret < 0)
830-
return ERR_PTR(ret);
831-
832-
if (ret >= chan->num_ext_scan_type)
833-
return ERR_PTR(-EINVAL);
834-
835-
return &chan->ext_scan_type[ret];
836-
}
837-
838-
return &chan->scan_type;
839-
}
840-
841790
/**
842791
* iio_get_masklength - Get length of the channels mask
843792
* @indio_dev: the IIO device to get the masklength for

0 commit comments

Comments
 (0)