@@ -400,7 +400,8 @@ static ssize_t iio_show_fixed_type(struct device *dev,
400
400
char * buf )
401
401
{
402
402
struct iio_dev_attr * this_attr = to_iio_dev_attr (attr );
403
- u8 type = this_attr -> c -> scan_type .endianness ;
403
+ const struct iio_scan_type * scan_type = & this_attr -> c -> scan_type ;
404
+ u8 type = scan_type -> endianness ;
404
405
405
406
if (type == IIO_CPU ) {
406
407
#ifdef __LITTLE_ENDIAN
@@ -409,21 +410,21 @@ static ssize_t iio_show_fixed_type(struct device *dev,
409
410
type = IIO_BE ;
410
411
#endif
411
412
}
412
- if (this_attr -> c -> scan_type . repeat > 1 )
413
+ if (scan_type -> repeat > 1 )
413
414
return sysfs_emit (buf , "%s:%c%d/%dX%d>>%u\n" ,
414
415
iio_endian_prefix [type ],
415
- this_attr -> c -> scan_type . sign ,
416
- this_attr -> c -> scan_type . realbits ,
417
- this_attr -> c -> scan_type . storagebits ,
418
- this_attr -> c -> scan_type . repeat ,
419
- this_attr -> c -> scan_type . shift );
416
+ scan_type -> sign ,
417
+ scan_type -> realbits ,
418
+ scan_type -> storagebits ,
419
+ scan_type -> repeat ,
420
+ scan_type -> shift );
420
421
else
421
422
return sysfs_emit (buf , "%s:%c%d/%d>>%u\n" ,
422
423
iio_endian_prefix [type ],
423
- this_attr -> c -> scan_type . sign ,
424
- this_attr -> c -> scan_type . realbits ,
425
- this_attr -> c -> scan_type . storagebits ,
426
- this_attr -> c -> scan_type . shift );
424
+ scan_type -> sign ,
425
+ scan_type -> realbits ,
426
+ scan_type -> storagebits ,
427
+ scan_type -> shift );
427
428
}
428
429
429
430
static ssize_t iio_scan_el_show (struct device * dev ,
@@ -735,12 +736,16 @@ static unsigned int iio_storage_bytes_for_si(struct iio_dev *indio_dev,
735
736
unsigned int scan_index )
736
737
{
737
738
const struct iio_chan_spec * ch ;
739
+ const struct iio_scan_type * scan_type ;
738
740
unsigned int bytes ;
739
741
740
742
ch = iio_find_channel_from_si (indio_dev , scan_index );
741
- bytes = ch -> scan_type .storagebits / 8 ;
742
- if (ch -> scan_type .repeat > 1 )
743
- 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
+
744
749
return bytes ;
745
750
}
746
751
@@ -1889,18 +1894,21 @@ static int __iio_buffer_alloc_sysfs_and_mask(struct iio_buffer *buffer,
1889
1894
if (channels ) {
1890
1895
/* new magic */
1891
1896
for (i = 0 ; i < indio_dev -> num_channels ; i ++ ) {
1897
+ const struct iio_scan_type * scan_type ;
1898
+
1892
1899
if (channels [i ].scan_index < 0 )
1893
1900
continue ;
1894
1901
1902
+ scan_type = & channels [i ].scan_type ;
1903
+
1895
1904
/* Verify that sample bits fit into storage */
1896
- if (channels [i ].scan_type .storagebits <
1897
- channels [i ].scan_type .realbits +
1898
- channels [i ].scan_type .shift ) {
1905
+ if (scan_type -> storagebits <
1906
+ scan_type -> realbits + scan_type -> shift ) {
1899
1907
dev_err (& indio_dev -> dev ,
1900
1908
"Channel %d storagebits (%d) < shifted realbits (%d + %d)\n" ,
1901
- i , channels [ i ]. scan_type . storagebits ,
1902
- channels [ i ]. scan_type . realbits ,
1903
- channels [ i ]. scan_type . shift );
1909
+ i , scan_type -> storagebits ,
1910
+ scan_type -> realbits ,
1911
+ scan_type -> shift );
1904
1912
ret = - EINVAL ;
1905
1913
goto error_cleanup_dynamic ;
1906
1914
}
0 commit comments