linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 2/2] pata_amd: fix sparse warning
@ 2008-03-28 21:33 akpm
  2008-03-29 16:17 ` Jeff Garzik
  2008-04-04  7:39 ` Jeff Garzik
  0 siblings, 2 replies; 4+ messages in thread
From: akpm @ 2008-03-28 21:33 UTC (permalink / raw)
  To: jeff; +Cc: linux-ide, akpm, harvey.harrison, alan

From: Harvey Harrison <harvey.harrison@gmail.com>

Current code is essentially choosing between dividing by 1 or
dividing by two, make the conditions a little more obvious.

As a bonus, removes a sparse error:
drivers/ata/pata_amd.c:59:11: warning: symbol '__x' shadows an earlier one
drivers/ata/pata_amd.c:59:11: originally declared here

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 drivers/ata/pata_amd.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff -puN drivers/ata/pata_amd.c~pata_amd-fix-sparse-warning drivers/ata/pata_amd.c
--- a/drivers/ata/pata_amd.c~pata_amd-fix-sparse-warning
+++ a/drivers/ata/pata_amd.c
@@ -56,7 +56,9 @@ static void timing_setup(struct ata_port
 	u8 t;
 
 	T = 1000000000 / amd_clock;
-	UT = T / min_t(int, max_t(int, clock, 1), 2);
+	UT = T;
+	if (clock >= 2)
+		UT = T / 2;
 
 	if (ata_timing_compute(adev, speed, &at, T, UT) < 0) {
 		dev_printk(KERN_ERR, &pdev->dev, "unknown mode %d.\n", speed);
_

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

* Re: [patch 2/2] pata_amd: fix sparse warning
  2008-03-28 21:33 [patch 2/2] pata_amd: fix sparse warning akpm
@ 2008-03-29 16:17 ` Jeff Garzik
  2008-03-31  3:12   ` Grant Grundler
  2008-04-04  7:39 ` Jeff Garzik
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff Garzik @ 2008-03-29 16:17 UTC (permalink / raw)
  To: akpm; +Cc: linux-ide, harvey.harrison, alan

akpm@linux-foundation.org wrote:
> From: Harvey Harrison <harvey.harrison@gmail.com>
> 
> Current code is essentially choosing between dividing by 1 or
> dividing by two, make the conditions a little more obvious.
> 
> As a bonus, removes a sparse error:
> drivers/ata/pata_amd.c:59:11: warning: symbol '__x' shadows an earlier one
> drivers/ata/pata_amd.c:59:11: originally declared here
> 
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  drivers/ata/pata_amd.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff -puN drivers/ata/pata_amd.c~pata_amd-fix-sparse-warning drivers/ata/pata_amd.c
> --- a/drivers/ata/pata_amd.c~pata_amd-fix-sparse-warning
> +++ a/drivers/ata/pata_amd.c
> @@ -56,7 +56,9 @@ static void timing_setup(struct ata_port
>  	u8 t;
>  
>  	T = 1000000000 / amd_clock;
> -	UT = T / min_t(int, max_t(int, clock, 1), 2);
> +	UT = T;
> +	if (clock >= 2)
> +		UT = T / 2;

Why assign UT twice, potentially?



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

* Re: [patch 2/2] pata_amd: fix sparse warning
  2008-03-29 16:17 ` Jeff Garzik
@ 2008-03-31  3:12   ` Grant Grundler
  0 siblings, 0 replies; 4+ messages in thread
From: Grant Grundler @ 2008-03-31  3:12 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: akpm, linux-ide, harvey.harrison, alan

On Sat, Mar 29, 2008 at 9:17 AM, Jeff Garzik <jeff@garzik.org> wrote:
...
>  > +     UT = T;
>  > +     if (clock >= 2)
>  > +             UT = T / 2;
>
>  Why assign UT twice, potentially?

This construct used in many places in the kernel because it
makes the code more readable.

"UT" is a regular "int" type and assigning it twice is ok.

e.g. from tg3_writephy():
...
        ret = -EBUSY;
        if (loops != 0)
                ret = 0;

hth,
grant

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

* Re: [patch 2/2] pata_amd: fix sparse warning
  2008-03-28 21:33 [patch 2/2] pata_amd: fix sparse warning akpm
  2008-03-29 16:17 ` Jeff Garzik
@ 2008-04-04  7:39 ` Jeff Garzik
  1 sibling, 0 replies; 4+ messages in thread
From: Jeff Garzik @ 2008-04-04  7:39 UTC (permalink / raw)
  To: akpm; +Cc: linux-ide, harvey.harrison, alan

akpm@linux-foundation.org wrote:
> From: Harvey Harrison <harvey.harrison@gmail.com>
> 
> Current code is essentially choosing between dividing by 1 or
> dividing by two, make the conditions a little more obvious.
> 
> As a bonus, removes a sparse error:
> drivers/ata/pata_amd.c:59:11: warning: symbol '__x' shadows an earlier one
> drivers/ata/pata_amd.c:59:11: originally declared here
> 
> Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  drivers/ata/pata_amd.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff -puN drivers/ata/pata_amd.c~pata_amd-fix-sparse-warning drivers/ata/pata_amd.c
> --- a/drivers/ata/pata_amd.c~pata_amd-fix-sparse-warning
> +++ a/drivers/ata/pata_amd.c
> @@ -56,7 +56,9 @@ static void timing_setup(struct ata_port
>  	u8 t;
>  
>  	T = 1000000000 / amd_clock;
> -	UT = T / min_t(int, max_t(int, clock, 1), 2);
> +	UT = T;
> +	if (clock >= 2)
> +		UT = T / 2;
>  
>  	if (ata_timing_compute(adev, speed, &at, T, UT) < 0) {

applied



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

end of thread, other threads:[~2008-04-04  7:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-28 21:33 [patch 2/2] pata_amd: fix sparse warning akpm
2008-03-29 16:17 ` Jeff Garzik
2008-03-31  3:12   ` Grant Grundler
2008-04-04  7:39 ` Jeff Garzik

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).