@@ -381,8 +381,10 @@ static void print_value(struct parser_pdata *pdata, long value)
381381static ssize_t send_sample (const struct iio_channel * chn ,
382382 void * src , size_t length , void * d )
383383{
384+ unsigned int number = get_channel_number (chn );
384385 struct sample_cb_info * info = d ;
385- if (chn -> index < 0 || !TEST_BIT (info -> mask , chn -> number ))
386+
387+ if (iio_channel_get_index (chn ) < 0 || !TEST_BIT (info -> mask , number ))
386388 return 0 ;
387389 if (info -> nb_bytes < length )
388390 return 0 ;
@@ -408,8 +410,10 @@ static ssize_t send_sample(const struct iio_channel *chn,
408410static ssize_t receive_sample (const struct iio_channel * chn ,
409411 void * dst , size_t length , void * d )
410412{
413+ unsigned int number = get_channel_number (chn );
411414 struct sample_cb_info * info = d ;
412- if (chn -> index < 0 || !TEST_BIT (info -> mask , chn -> number ))
415+
416+ if (iio_channel_get_index (chn ) < 0 || !TEST_BIT (info -> mask , number ))
413417 return 0 ;
414418 if (info -> cpt == info -> nb_bytes )
415419 return 0 ;
@@ -436,6 +440,7 @@ static ssize_t send_data(struct DevEntry *dev, struct ThdEntry *thd, size_t len)
436440{
437441 struct parser_pdata * pdata = thd -> pdata ;
438442 bool demux = server_demux && dev -> sample_size != thd -> sample_size ;
443+ void * start ;
439444
440445 if (demux )
441446 len = (len / dev -> sample_size ) * thd -> sample_size ;
@@ -475,7 +480,8 @@ static ssize_t send_data(struct DevEntry *dev, struct ThdEntry *thd, size_t len)
475480
476481 if (!demux ) {
477482 /* Short path */
478- return write_all (pdata , dev -> buf -> buffer , len );
483+ start = iio_buffer_start (dev -> buf );
484+ return write_all (pdata , start , len );
479485 } else {
480486 struct sample_cb_info info = {
481487 .pdata = pdata ,
@@ -505,7 +511,7 @@ static ssize_t receive_data(struct DevEntry *dev, struct ThdEntry *thd)
505511 if (thd -> nb < len )
506512 len = thd -> nb ;
507513
508- return read_all (pdata , dev -> buf -> buffer , len );
514+ return read_all (pdata , iio_buffer_start ( dev -> buf ) , len );
509515 } else {
510516 /* Long path: Mux the samples to the buffer */
511517
@@ -586,14 +592,15 @@ static void rw_thd(struct thread_pool *pool, void *d)
586592 if (entry -> buf )
587593 iio_buffer_destroy (entry -> buf );
588594
589- for (i = 0 ; i < dev -> nb_channels ; i ++ ) {
590- struct iio_channel * chn = dev -> channels [i ];
591- long index = chn -> index ;
595+ for (i = 0 ; i < iio_device_get_channels_count (dev ); i ++ ) {
596+ struct iio_channel * chn = iio_device_get_channel (dev , i );
597+ unsigned int number = get_channel_number (chn );
598+ long index = iio_channel_get_index (chn );
592599
593600 if (index < 0 )
594601 continue ;
595602
596- if (TEST_BIT (entry -> mask , chn -> number ))
603+ if (TEST_BIT (entry -> mask , number ))
597604 iio_channel_enable (chn );
598605 else
599606 iio_channel_disable (chn );
@@ -955,7 +962,7 @@ static int open_dev_helper(struct parser_pdata *pdata, struct iio_device *dev,
955962 if (!dev )
956963 return - ENODEV ;
957964
958- nb_channels = dev -> nb_channels ;
965+ nb_channels = iio_device_get_channels_count ( dev ) ;
959966 if (len != ((nb_channels + 31 ) / 32 ) * 8 )
960967 return - EINVAL ;
961968
@@ -1322,12 +1329,13 @@ ssize_t get_trigger(struct parser_pdata *pdata, struct iio_device *dev)
13221329
13231330 ret = iio_device_get_trigger (dev , & trigger );
13241331 if (!ret && trigger ) {
1332+ const char * name = iio_device_get_name (trigger );
13251333 char buf [256 ];
13261334
1327- ret = strlen (trigger -> name );
1335+ ret = strlen (name );
13281336 print_value (pdata , ret );
13291337
1330- snprintf (buf , sizeof (buf ), "%s\n" , trigger -> name );
1338+ snprintf (buf , sizeof (buf ), "%s\n" , name );
13311339 ret = write_all (pdata , buf , ret + 1 );
13321340 } else {
13331341 print_value (pdata , ret );
0 commit comments