From patchwork Sat Jul 3 15:00:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Young X-Patchwork-Id: 12357021 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A8F9C07E99 for ; Sat, 3 Jul 2021 15:00:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF48C6162C for ; Sat, 3 Jul 2021 15:00:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229852AbhGCPD0 (ORCPT ); Sat, 3 Jul 2021 11:03:26 -0400 Received: from gofer.mess.org ([88.97.38.141]:45647 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbhGCPDY (ORCPT ); Sat, 3 Jul 2021 11:03:24 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id 872C4C6402; Sat, 3 Jul 2021 16:00:49 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mess.org; s=2020; t=1625324449; bh=BtrZZ6MbcFj9yQGIoSoMHEVONnKHSp0m2Ud31v00gh0=; h=From:To:Subject:Date:From; b=egqpjz3XLNAfucwDvNlCwAn5VJMl59oJQYTr1JB0tkgyEYzUDUA17ZgCpBJ/ZFavh vR6uyrxmDNwvjKXllJdZ1KJ+qgfjaR2/LgCz9elJfLWgfrTLd0R+uM16WQT+h0J0qZ OKS03gnSExz9/Coae8NOYxU8jj+vc5BXCOJd5GJBeocJRFePidluVJnb7cL524LRA3 yfVvjJE+l0C02Jey2cQdeFa9DurEUNdo2w3hpMj4K8Uf7ux4E75HkYS07ll8Wv8c4u nuj10rAtKdzvGjBBjw1rVdl5lPnbwQycPthL3cesayVr89ZKyZCHqzBEmyoVsF0Ruh jX+TsdfiZjClw== From: Sean Young To: linux-media@vger.kernel.org Subject: [PATCH v4l-utils] ir-ctl: print correct transmitter count Date: Sat, 3 Jul 2021 16:00:49 +0100 Message-Id: <20210703150049.11917-1-sean@mess.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Signed-off-by: Sean Young --- 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"));