tools: iio: iio_generic_buffer: -A option code cleanups
v2 cover tools: iio: iio_generic_buffer: -A option code cleanups
Address Peter's comments:
https://marc.info/?l=linux-iio&m=147673895620791&w=2
Change in v2:
* Update force_autochannels to true/false instead of 1/0.
Eva Rachel Retuya (2):
tools: iio: iio_generic_buffer: rename and change type of force
variable
tools: iio: iio_generic_buffer: drop unneeded parentheses
tools/iio/iio_generic_buffer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/2 tools: iio: iio_generic_buffer: rename and change type of force variable
Replace the type of 'force' flag from int to bool and at the same time rename it to 'force_autochannels' for better readability.
--- tools/iio/iio_generic_buffer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/iio/iio_generic_buffer.c +5 -4
@@ -348,7 +348,7 @@ int main(int argc, char **argv)int noevents =0 ;int notrigger =0 ;char *dummy; -int force =0 ; +bool force_autochannels = false;struct iio_channel_info *channels =NULL ;
@@ -362,7 +362,7 @@ int main(int argc, char **argv)break ;case 'A' : autochannels =AUTOCHANNELS_ENABLED ; - force =1 ; + force_autochannels = true;break ;case 'c' : errno =0 ;
@@ -526,14 +526,15 @@ int main(int argc, char **argv) "diag %s\n", dev_dir_name); goto error; } -if ((num_channels && autochannels ==AUTOCHANNELS_ENABLED ) && !force) { +if ((num_channels && autochannels ==AUTOCHANNELS_ENABLED ) && + !force_autochannels) {fprintf (stderr,"Auto-channels selected but some channels " "are already activated in sysfs\n" );fprintf (stderr,"Proceeding without activating any channels\n" ); }if ((!num_channels && autochannels ==AUTOCHANNELS_ENABLED ) || - ((autochannels ==AUTOCHANNELS_ENABLED ) && force)) { + ((autochannels ==AUTOCHANNELS_ENABLED ) && force_autochannels)) {fprintf (stderr,"Enabling all channels\n" ); ret =enable_disable_all_channels (dev_dir_name,1 );
Signature · 1 line
2.7.4
Jonathan Cameron
maintainerRe: [PATCH v2 1/2] tools: iio: iio_generic_buffer: rename and change type of force variable
Quoted 5 lines · Eva Rachel Retuya
Replace the type of 'force' flag from int to bool and at the same time rename it to '
force_autochannels' for better readability.Suggested-by Peter Meerwald-Stadler <[email protected]>Signed-off-by Eva Rachel Retuya <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 45 lines
--- tools/iio/iio_generic_buffer.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)tools/iio/iio_generic_buffer.c +5
-4@@ -348,7 +348,7 @@ int main(int argc, char **argv)int noevents =0 ;int notrigger =0 ;char *dummy; -int force =0 ; +bool force_autochannels = false;struct iio_channel_info *channels =NULL ;@@ -362,7 +362,7 @@ int main(int argc, char **argv)break ;case 'A' : autochannels =AUTOCHANNELS_ENABLED ; - force =1 ; + force_autochannels = true;break ;case 'c' : errno =0 ;@@ -526,14 +526,15 @@ int main(int argc, char **argv) "diag %s\n", dev_dir_name); goto error; } -if ((num_channels && autochannels ==AUTOCHANNELS_ENABLED ) && !force) { +if ((num_channels && autochannels ==AUTOCHANNELS_ENABLED ) && + !force_autochannels) {fprintf (stderr,"Auto-channels selected but some channels " "are already activated in sysfs\n" );fprintf (stderr,"Proceeding without activating any channels\n" ); }if ((!num_channels && autochannels ==AUTOCHANNELS_ENABLED ) || - ((autochannels ==AUTOCHANNELS_ENABLED ) && force)) { + ((autochannels ==AUTOCHANNELS_ENABLED ) && force_autochannels)) {fprintf (stderr,"Enabling all channels\n" ); ret =enable_disable_all_channels (dev_dir_name,1 );
PATCH v2 2/2 tools: iio: iio_generic_buffer: drop unneeded parentheses
In reply to Eva Rachel RetuyaRemove extra parentheses introduced in commit <73e176a tools: iio:iio_generic_buffer: add -A to force-enable all channels>.
--- tools/iio/iio_generic_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/iio/iio_generic_buffer.c +2 -2
@@ -526,7 +526,7 @@ int main(int argc, char **argv) "diag %s\n", dev_dir_name); goto error; } -if ((num_channels && autochannels ==AUTOCHANNELS_ENABLED ) && +if (num_channels && autochannels ==AUTOCHANNELS_ENABLED && !force_autochannels) {fprintf (stderr,"Auto-channels selected but some channels " "are already activated in sysfs\n" );
@@ -534,7 +534,7 @@ int main(int argc, char **argv) }if ((!num_channels && autochannels ==AUTOCHANNELS_ENABLED ) || - ((autochannels ==AUTOCHANNELS_ENABLED ) && force_autochannels)) { + (autochannels ==AUTOCHANNELS_ENABLED && force_autochannels)) {fprintf (stderr,"Enabling all channels\n" ); ret =enable_disable_all_channels (dev_dir_name,1 );
Signature · 1 line
2.7.4
Re: [PATCH v2 2/2] tools: iio: iio_generic_buffer: drop unneeded parentheses
Quoted 5 lines · Eva Rachel Retuya
Remove extra parentheses introduced in commit <73e176a tools: iio:
iio_generic_buffer: add -A to force-enable all channels>.Suggested-by Peter Meerwald-Stadler <[email protected]>Signed-off-by Eva Rachel Retuya <[email protected]>
Applied, thanks,
Jonathan
Quoted 27 lines
--- tools/iio/iio_generic_buffer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)tools/iio/iio_generic_buffer.c +2
-2@@ -526,7 +526,7 @@ int main(int argc, char **argv) "diag %s\n", dev_dir_name); goto error; } -if ((num_channels && autochannels ==AUTOCHANNELS_ENABLED ) && +if (num_channels && autochannels ==AUTOCHANNELS_ENABLED && !force_autochannels) {fprintf (stderr,"Auto-channels selected but some channels " "are already activated in sysfs\n" );@@ -534,7 +534,7 @@ int main(int argc, char **argv) }if ((!num_channels && autochannels ==AUTOCHANNELS_ENABLED ) || - ((autochannels ==AUTOCHANNELS_ENABLED ) && force_autochannels)) { + (autochannels ==AUTOCHANNELS_ENABLED && force_autochannels)) {fprintf (stderr,"Enabling all channels\n" ); ret =enable_disable_all_channels (dev_dir_name,1 );