All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Jean Delvare <khali@linux-fr.org>
Cc: LMML <linux-media@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Guenter Roeck <linux@roeck-us.net>,
	Mauro Carvalho Chehab <mchehab@infradead.org>
Subject: Re: [PATCH] [media] mceusb: Optimize DIV_ROUND_CLOSEST call
Date: Tue, 18 Sep 2012 12:49:53 -0300	[thread overview]
Message-ID: <50589821.6000108@redhat.com> (raw)
In-Reply-To: <20120901205357.1a75d8a1@endymion.delvare>

Em 01-09-2012 15:53, Jean Delvare escreveu:
> DIV_ROUND_CLOSEST is faster if the compiler knows it will only be
> dealing with unsigned dividends.
> 
> Signed-off-by: Jean Delvare <khali@linux-fr.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Guenter Roeck <linux@roeck-us.net>
> Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
> ---
>  drivers/media/rc/mceusb.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> --- linux-3.6-rc3.orig/drivers/media/rc/mceusb.c	2012-08-04 21:49:27.000000000 +0200
> +++ linux-3.6-rc3/drivers/media/rc/mceusb.c	2012-09-01 18:53:32.053042123 +0200
> @@ -627,7 +627,7 @@ static void mceusb_dev_printdata(struct
>  			break;
>  		case MCE_RSP_EQIRCFS:
>  			period = DIV_ROUND_CLOSEST(
> -					(1 << data1 * 2) * (data2 + 1), 10);
> +					(1U << data1 * 2) * (data2 + 1), 10);
>  			if (!period)
>  				break;
>  			carrier = (1000 * 1000) / period;
> 
> 

Hmm... this generates the following warning with "W=1":

drivers/media/rc/mceusb.c:629:4: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
drivers/media/rc/mceusb.c:629:4: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

Perhaps it makes sense to use an optimized version for unsigned, or to
change the macro to take the data types into account.

Regards,
Mauro

  parent reply	other threads:[~2012-09-18 15:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-01 18:53 [PATCH] [media] mceusb: Optimize DIV_ROUND_CLOSEST call Jean Delvare
2012-09-02  4:54 ` Guenter Roeck
2012-09-18 15:49 ` Mauro Carvalho Chehab [this message]
2012-09-18 16:24   ` Guenter Roeck
2012-09-18 18:35   ` Jean Delvare
2012-09-19  3:46     ` Guenter Roeck

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=50589821.6000108@redhat.com \
    --to=mchehab@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=khali@linux-fr.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mchehab@infradead.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.