All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: linux-media@vger.kernel.org
Subject: Re: [PATCH v4l-utils] ir-ctl: print correct transmitter count
Date: Mon, 5 Jul 2021 09:33:07 +0100	[thread overview]
Message-ID: <20210705083307.GA5225@gofer.mess.org> (raw)
In-Reply-To: <20210703150049.11917-1-sean@mess.org>

On Sat, Jul 03, 2021 at 04:00:49PM +0100, Sean Young wrote:
> 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);

I was mistaken; the ioctl does return the tx emitter count, not the valid
mask. 

All the existing drivers except rc-loopback return the count, not the mask.
The documentation also says so. 

I'll have to revert.

Sean

>  			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

      reply	other threads:[~2021-07-05  8:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-03 15:00 [PATCH v4l-utils] ir-ctl: print correct transmitter count Sean Young
2021-07-05  8:33 ` Sean Young [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210705083307.GA5225@gofer.mess.org \
    --to=sean@mess.org \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.