linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4l-utils] ir-ctl: print correct transmitter count
@ 2021-07-03 15:00 Sean Young
  2021-07-05  8:33 ` Sean Young
  0 siblings, 1 reply; 2+ messages in thread
From: Sean Young @ 2021-07-03 15:00 UTC (permalink / raw)
  To: linux-media

Signed-off-by: Sean Young <sean@mess.org>
---
 utils/ir-ctl/ir-ctl.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c
index 3c3bcca1..66a257a7 100644
--- a/utils/ir-ctl/ir-ctl.c
+++ b/utils/ir-ctl/ir-ctl.c
@@ -933,7 +933,7 @@ static int lirc_options(struct arguments *args, int fd, unsigned features)
 		if (features & LIRC_CAN_SET_TRANSMITTER_MASK) {
 			rc = ioctl(fd, LIRC_SET_TRANSMITTER_MASK, &args->emitters);
 			if (rc > 0)
-				fprintf(stderr, _("warning: %s: failed to set send transmitters: only %d available\n"), dev, rc);
+				fprintf(stderr, _("warning: %s: failed to set send transmitters: only %d available\n"), dev, ffs(~rc) - 1);
 			else if (rc < 0)
 				fprintf(stderr, _("warning: %s: failed to set send transmitters: %m\n"), dev);
 		} else
@@ -1026,8 +1026,11 @@ static void lirc_features(struct arguments *args, int fd, unsigned features)
 				fprintf(stderr, _("warning: %s: device supports setting transmitter mask but returns 0 as number of transmitters\n"), dev);
 			else if (rc < 0)
 				fprintf(stderr, _("warning: %s: device supports setting transmitter mask but returns: %m\n"), dev);
-			else
-				printf(_(" - Set transmitter (%d available)\n"), rc);
+			else {
+				unsigned count = ffs(~rc) - 1;
+
+				printf(_(" - Set transmitter (%d available)\n"), count);
+			}
 		}
 	} else if (features & LIRC_CAN_SEND_LIRCCODE) {
 		printf(_(" - Device can send using device dependent LIRCCODE mode (not supported)\n"));
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-05  8:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-03 15:00 [PATCH v4l-utils] ir-ctl: print correct transmitter count Sean Young
2021-07-05  8:33 ` Sean Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).