Skip to contentSkip to conversation

Fix compilation warnings when building eNET

PATCH New Vadim Bendebury 2 participants 6 messages Dec 9, 2011 – Dec 12, 2011 2 messages not in the archive x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix compilation warnings when building eNET

There have been a couple of unused variable cases, causing compilation warnings when building the eNET target.

While the board/eNET/eNET.c:last_stage_init() case seems a leftover from a quick edit, the arch/x86/cpu/sc520/sc520_timer.c:sc520_udelay() seems to actually require accessing the registers discarding the values.

The source code is being modified accordingly.

TEST:
- the eNET target now builds cleanly
- examining disassembled sc520_timer.o shows that the registers are still being accessed in the beginning of the function.

---
 arch/x86/cpu/sc520/sc520_timer.c |    1 +
 board/eNET/eNET.c                |    5 -----
 2 files changed, 1 insertions(+), 5 deletions(-)
arch/x86/cpu/sc520/sc520_timer.c +1 -0
index 495a694..a7bbe92 100644
@@ -87,4 +87,5 @@ void sc520_udelay(unsigned long usec)
 		m += readw(&sc520_mmcr->swtmrmilli);
 		u = readw(&sc520_mmcr->swtmrmicro) + (m * 1000);
 	} while (u < usec);
+	(void) temp;
 }
board/eNET/eNET.c +0 -5
index 429fe1b..2f26470 100644
@@ -178,11 +178,6 @@ void show_boot_progress(int val)
 
 int last_stage_init(void)
 {
-	int minor;
-	int major;
-
-	major = minor = 0;
-
 	outb(0x00, LED_LATCH_ADDRESS);
 
 	register_timer_isr(enet_timer_isr);
Signature · 1 line
1.7.3.1
#1 lore raw

PATCH 1/1 Fix compilation warnings when building eNET

There have been a couple of unused variable cases, causing compilation warnings when building the eNET target.

While the board/eNET/eNET.c:last_stage_init() case seems a leftover from a quick edit, the arch/x86/cpu/sc520/sc520_timer.c:sc520_udelay() seems to actually require accessing the registers discarding the values.

The source code is being modified accordingly.

TEST:
?- the eNET target now builds cleanly
?- examining disassembled sc520_timer.o shows that the registers are ? still being accessed in the beginning of the function.

---

[Resend with the proper cc: header]

?arch/x86/cpu/sc520/sc520_timer.c | ? ?1 +
?board/eNET/eNET.c ? ? ? ? ? ? ? ?| ? ?5 -----
?2 files changed, 1 insertions(+), 5 deletions(-)

arch/x86/cpu/sc520/sc520_timer.c +0 -0
index 495a694..a7bbe92 100644
@@ -87,4 +87,5 @@ void sc520_udelay(unsigned long usec)

? ? ? ? ? ? ? ?m += readw(&sc520_mmcr->swtmrmilli);
? ? ? ? ? ? ? ?u = readw(&sc520_mmcr->swtmrmicro) + (m * 1000); ? ? ? ?} while (u < usec);
+ ? ? ? (void) temp;
?}

board/eNET/eNET.c +0 -0
index 429fe1b..2f26470 100644
@@ -178,11 +178,6 @@ void show_boot_progress(int val)
 

?int last_stage_init(void)
?{
- ? ? ? int minor;
- ? ? ? int major;
-
- ? ? ? major = minor = 0;
-
? ? ? ?outb(0x00, LED_LATCH_ADDRESS);

? ? ? ?register_timer_isr(enet_timer_isr);
--
1.7.3.1

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

#2 lore raw

PATCH 1/1 Fix compilation warnings when building eNET

Hi Vadim,

Quoted 8 lines · Vadim Bendebury

There have been a couple of unused variable cases, causing compilation warnings when building the eNET target.

While the board/eNET/eNET.c:last_stage_init() case seems a leftover from a quick edit, the arch/x86/cpu/sc520/sc520_timer.c:sc520_udelay() seems to actually require accessing the registers discarding the values.

Thanks for picking this up, I've been a bit preoccupie lately.

I'll need to look a bit more closely, but there should be no need for such trickery...

Regards,

Graeme

Quoted 11 lines

The source code is being modified accordingly.

TEST:
- the eNET target now builds cleanly
- examining disassembled sc520_timer.o shows that the registers are still being accessed in the beginning of the function.

---

Review

Quoted 7 lines

[Resend with the proper cc: header]

 arch/x86/cpu/sc520/sc520_timer.c |    1 +
 board/eNET/eNET.c                |    5 -----
 2 files changed, 1 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/arch/x86/cpu/sc520/sc520_timer.c

Quoted 32 lines

index 495a694..a7bbe92 100644

arch/x86/cpu/sc520/sc520_timer.c +1 -0
@@ -87,4 +87,5 @@ void sc520_udelay(unsigned long usec)
               m += readw(&sc520_mmcr->swtmrmilli);
               u = readw(&sc520_mmcr->swtmrmicro) + (m * 1000);
       } while (u < usec);
+       (void) temp;
 }
board/eNET/eNET.c +0 -6
index 429fe1b..2f26470 100644
@@ -178,11 +178,6 @@ void show_boot_progress(int val)
 
 int last_stage_init(void)
 {
-       int minor;
-       int major;
-
-       major = minor = 0;
-
       outb(0x00, LED_LATCH_ADDRESS);
 
       register_timer_isr(enet_timer_isr);
--

1.7.3.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#3 lore raw

PATCH 1/1 Fix compilation warnings when building eNET

Quoted 13 lines · Graeme Russ

Hi Vadim,

Quoted 8 lines · Vadim Bendebury

There have been a couple of unused variable cases, causing compilation warnings when building the eNET target.

While the board/eNET/eNET.c:last_stage_init() case seems a leftover from a quick edit, the arch/x86/cpu/sc520/sc520_timer.c:sc520_udelay() seems to actually require accessing the registers discarding the values.

Quoted 9 lines

Thanks for picking this up, I've been a bit preoccupie lately.

I'll need to look a bit more closely, but there should be no need for such trickery...

Regards,

Graeme

Hi Graeme, thank you for a quick response.

Do you mean that there is no need to read the registers before the actual udelay functionality or do you have another way of pacifying the compiler in mind?

cheers,
/v

Quoted 52 lines
Quoted 52 lines

The source code is being modified accordingly.

TEST:
?- the eNET target now builds cleanly
?- examining disassembled sc520_timer.o shows that the registers are ? still being accessed in the beginning of the function.

---

[Resend with the proper ?cc: header]

?arch/x86/cpu/sc520/sc520_timer.c | ? ?1 +
?board/eNET/eNET.c ? ? ? ? ? ? ? ?| ? ?5 -----
?2 files changed, 1 insertions(+), 5 deletions(-)

arch/x86/cpu/sc520/sc520_timer.c +1 -0
index 495a694..a7bbe92 100644
@@ -87,4 +87,5 @@ void sc520_udelay(unsigned long usec)
 ? ? ? ? ? ? ? ?m += readw(&sc520_mmcr->swtmrmilli);
 ? ? ? ? ? ? ? ?u = readw(&sc520_mmcr->swtmrmicro) + (m * 1000);
 ? ? ? ?} while (u < usec);
+ ? ? ? (void) temp;
 ?}
board/eNET/eNET.c +0 -6
index 429fe1b..2f26470 100644
@@ -178,11 +178,6 @@ void show_boot_progress(int val)
 
 ?int last_stage_init(void)
 ?{
- ? ? ? int minor;
- ? ? ? int major;
-
- ? ? ? major = minor = 0;
-
 ? ? ? ?outb(0x00, LED_LATCH_ADDRESS);
 
 ? ? ? ?register_timer_isr(enet_timer_isr);
--

1.7.3.1

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#6 lore raw

PATCH 1/1 Fix compilation warnings when building eNET

In reply to a message not in the archive

Hi Vadim,

Oops, dropped the ML...

Quoted 8 lines · Graeme Russ

Hi Vadim,

Quoted 4 lines · Graeme Russ

Hi Vadim,

On Dec 10, 2011 12:08 PM, "Vadim Bendebury" <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines

On Fri, Dec 9, 2011 at 3:57 PM, Graeme Russ <[email protected]>

Quoted 4 lines · wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

Hi Vadim,

On Dec 10, 2011 10:31 AM, "Vadim Bendebury" <[email protected]>

Quoted 2 lines · wrote:
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

There have been a couple of unused variable cases, causing

compilation

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

warnings when building the eNET target.

While the board/eNET/eNET.c:last_stage_init() case seems a

leftover

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

from a quick edit, the

arch/x86/cpu/sc520/sc520_timer.c:sc520_udelay()

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

seems to actually require accessing the registers discarding the values.

Thanks for picking this up, I've been a bit preoccupie lately.

I'll need to look a bit more closely, but there should be no need

for such trickery...

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 6 lines

Regards,

Graeme

Hi Graeme, thank you for a quick response.

Do you mean that there is no need to read the registers before the actual udelay functionality or do you have another way of pacifying the compiler in mind?

Quoted 5 lines
Quoted 3 lines

On closer inspection, I can't think of a better way

Sorry, bit I just had a closer look at this and after reading the

datasheet I've come to the realization that the udelay function is broken - not badly, but it can timeout up to 1ms early.

Quoted 2 lines

The read of swtmrmilli reads the current value of the millisecond timer,

latches the value of the internal microsecond timer and resets the millisecond timer to zero

Quoted 4 lines

The read of swtmrmicro reads the latched microsecond value

The code assumes that reading swtmrmicro resets the microsecond counter,

which it does not. So if the internal microsecond timer is, say, 900 then udelay(500) for example will return without any delay at all

Quoted 4 lines

I need to fix this, but cannot do so any time soon...

I have no objection to the compiler warning fix, but is there any point

in applying a cosmetic fix to broken code?

Quoted 1 line

I'm not near my dev PC so the formatting is all wrong, but this should fix the bug and the compiler warning:

void sc520_udelay(unsigned long usec)
{
int m;
long u;
long start_us;

   /* Reset millisecond counter */
   m = readw(&sc520_mmcr->swtmrmilli);
   m = 0;

   /* Read initial microsecond count */
   start_us = readw(&sc520_mmcr->swtmrmicro);
   do {
      m += readw(&sc520_mmcr->swtmrmilli);
      u = readw(&sc520_mmcr->swtmrmicro) + (m * 1000);

} while ((u - start_us) < usec);
}

Regards,

Graeme

#7 lore raw

PATCH 1/1 Fix compilation warnings when building eNET

Quoted 84 lines · Graeme Russ

Hi Vadim,

Oops, dropped the ML...

Quoted 60 lines · Graeme Russ

Hi Vadim,

Quoted 38 lines · Graeme Russ

Hi Vadim,

Quoted 33 lines · Vadim Bendebury
Quoted 17 lines · Graeme Russ

Hi Vadim,

Quoted 11 lines · Vadim Bendebury

There have been a couple of unused variable cases, causing compilation
warnings when building the eNET target.

While the board/eNET/eNET.c:last_stage_init() case seems a leftover
from a quick edit, the arch/x86/cpu/sc520/sc520_timer.c:sc520_udelay()
seems to actually require accessing the registers discarding the values.

Quoted 10 lines

Thanks for picking this up, I've been a bit preoccupie lately.

I'll need to look a bit more closely, but there should be no need for such trickery...

Regards,

Graeme

Hi Graeme, thank you for a quick response.

Quoted 7 lines
Quoted 3 lines

Do you mean that there is no need to read the registers before the actual udelay functionality or do you have another way of pacifying the compiler in mind?

On closer inspection, I can't think of a better way

Sorry, bit I just had a closer look at this and after reading the datasheet I've come to the realization that the udelay function is broken - not badly, but it can timeout up to 1ms early.

The read of swtmrmilli reads the current value of the millisecond timer, latches the value of the internal microsecond timer and resets the millisecond timer to zero

The read of swtmrmicro reads the latched microsecond value

Quoted 9 lines

The code assumes that reading swtmrmicro resets the microsecond counter, which it does not. So if the internal microsecond timer is, say, 900 then udelay(500) for example will return without any delay at all

I need to fix this, but cannot do so any time soon...

I have no objection to the compiler warning fix, but is there any point in applying a cosmetic fix to broken code?

I'm not near my dev PC so the formatting is all wrong, but this should fix the bug and the compiler warning:

void sc520_udelay(unsigned long usec)
{
?? int m;
?? long u;
?? long start_us;

Quoted 4 lines

?? /* Reset millisecond counter */
?? m = readw(&sc520_mmcr->swtmrmilli);
?? m = 0;

Looks reasonable, not much difference from the original submission IMO.

The important thing is that there should be no compilation warnings allowed, as if there are a few 'legitimate' ones, it becomes easy to let the illegitimate ones to slip through :P

cheers,
/vb

Quoted 14 lines

?? /* Read initial microsecond count */
?? start_us = readw(&sc520_mmcr->swtmrmicro);

?? do {

????? m += readw(&sc520_mmcr->swtmrmilli); ????? u = readw(&sc520_mmcr->swtmrmicro) + (m * 1000); ?? } while ((u - start_us) < usec);
}

Regards,

Graeme