* [PATCH v2 0/5] MIPS: XBurst: fix the JZ4755's clocksource
@ 2012-06-28 18:32 Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines Antony Pavlov
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Antony Pavlov @ 2012-06-28 18:32 UTC (permalink / raw)
To: barebox
This patch series fixes error in JZ4755's clocksource code.
First, it fixes common {BIG,LITTLE}_ENDIAN defines
to make work MIPS little-endian clocksource code.
Next, the patch series fixes the JZ4755's clocksource code itself.
[PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines
[PATCH v2 2/5] byteorder: add sanity check
[PATCH v2 3/5] clocksource: move the NSEC_PER_SEC constant to common
[PATCH v2 4/5] MIPS: XBurst: fix the JZ4755's clocksource input
[PATCH v2 5/5] MIPS: XBurst: use clocks_calc_mult_shift() for
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines
2012-06-28 18:32 [PATCH v2 0/5] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov
@ 2012-06-28 18:32 ` Antony Pavlov
2012-06-29 7:25 ` Sascha Hauer
2012-06-28 18:32 ` [PATCH v2 2/5] byteorder: add sanity check Antony Pavlov
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Antony Pavlov @ 2012-06-28 18:32 UTC (permalink / raw)
To: barebox
In the Linux kernel sources the only one byteorder macro
can be defined (__BIG_ENDIAN or __LITTLE_ENDIAN) at a time.
In barebox we have the __BIG_ENDIAN and __LITTLE_ENDIAN macros
defined simultaneously introduced in
commit 9ad1fe64abb12baac918ec177d9a52bbf2980d16
Author: Baruch Siach <baruch@tkos.co.il>
Date: Sun Jun 27 08:46:05 2010 +0300
byteorder: add missing {BIG,LITTLE}_ENDIAN defines
This fixes build warnings when testing __BYTE_ORDER
of the other kin
But in arch/mips/lib/libgcc.h (from Linux) we have
#ifdef __BIG_ENDIAN
struct DWstruct {
int high, low;
};
#elif defined(__LITTLE_ENDIAN)
struct DWstruct {
int low, high;
};
#else
#error I feel sick.
#endif
This means that regardless of current byteorder the big-endian
DWstruct will be selected. By turn this breaks the __lshrdi3()
function and the clocksource code on little-endian MIPS.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/ata/disk_ata_drive.c | 2 +-
drivers/nor/cfi_flash.c | 6 +++---
include/cramfs/cramfs_fs.h | 4 ++--
include/envfs.h | 16 ++++++++++++----
include/linux/byteorder/generic.h | 7 -------
include/usb/usb.h | 2 +-
6 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c
index 4602af3..d5c5837 100644
--- a/drivers/ata/disk_ata_drive.c
+++ b/drivers/ata/disk_ata_drive.c
@@ -231,7 +231,7 @@ static void __maybe_unused ata_dump_id(uint16_t *id)
*/
static void ata_fix_endianess(uint16_t *buf, unsigned wds)
{
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifdef __BIG_ENDIAN
unsigned u;
for (u = 0; u < wds; u++)
diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c
index 654e647..02340e6 100644
--- a/drivers/nor/cfi_flash.c
+++ b/drivers/nor/cfi_flash.c
@@ -82,7 +82,7 @@ static void flash_add_byte (struct flash_info *info, cfiword_t * cword, uchar c)
return;
}
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifdef __BIG_ENDIAN
*cword = (*cword << 8) | c;
#else
@@ -167,7 +167,7 @@ static void flash_printqry (struct cfi_qry *qry)
uchar flash_read_uchar (struct flash_info *info, uint offset)
{
uchar *cp = flash_make_addr(info, 0, offset);
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifdef __LITTLE_ENDIAN
return flash_read8(cp);
#else
return flash_read8(cp + info->portwidth - 1);
@@ -195,7 +195,7 @@ static ulong flash_read_long (struct flash_info *info, flash_sect_t sect, uint o
debug ("addr[%x] = 0x%x\n", x, flash_read8(addr + x));
}
#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifdef __LITTLE_ENDIAN
retval = ((flash_read8(addr) << 16) |
(flash_read8(addr + info->portwidth) << 24) |
(flash_read8(addr + 2 * info->portwidth)) |
diff --git a/include/cramfs/cramfs_fs.h b/include/cramfs/cramfs_fs.h
index af2940b..a7e9504 100644
--- a/include/cramfs/cramfs_fs.h
+++ b/include/cramfs/cramfs_fs.h
@@ -88,7 +88,7 @@ struct cramfs_super {
#error "No byte order defined in __BYTE_ORDER"
#endif
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifdef __LITTLE_ENDIAN
#define CRAMFS_16(x) (x)
#define CRAMFS_24(x) (x)
#define CRAMFS_32(x) (x)
@@ -96,7 +96,7 @@ struct cramfs_super {
#define CRAMFS_GET_OFFSET(x) ((x)->offset)
#define CRAMFS_SET_OFFSET(x,y) ((x)->offset = (y))
#define CRAMFS_SET_NAMELEN(x,y) ((x)->namelen = (y))
-#elif __BYTE_ORDER ==__BIG_ENDIAN
+#elif defined(__BIG_ENDIAN)
#ifdef __KERNEL__
#define CRAMFS_16(x) swab16(x)
#define CRAMFS_24(x) ((swab32(x)) >> 8)
diff --git a/include/envfs.h b/include/envfs.h
index 67b8902..cb1c648 100644
--- a/include/envfs.h
+++ b/include/envfs.h
@@ -38,6 +38,11 @@ struct envfs_super {
#error "No byte order defined in __BYTE_ORDER"
#endif
+#if __BYTE_ORDER != __LITTLE_ENDIAN && __BYTE_ORDER != __BIG_ENDIAN
+#error "__BYTE_ORDER must be __LITTLE_ENDIAN or __BIG_ENDIAN"
+#endif
+
+#ifdef __LITTLE_ENDIAN
#if __BYTE_ORDER == __LITTLE_ENDIAN
#define ENVFS_16(x) (x)
#define ENVFS_24(x) (x)
@@ -46,7 +51,11 @@ struct envfs_super {
#define ENVFS_GET_OFFSET(x) ((x)->offset)
#define ENVFS_SET_OFFSET(x,y) ((x)->offset = (y))
#define ENVFS_SET_NAMELEN(x,y) ((x)->namelen = (y))
-#elif __BYTE_ORDER == __BIG_ENDIAN
+#endif /* __BYTE_ORDER == __LITTLE_ENDIAN */
+#endif /* __LITTLE_ENDIAN */
+
+#ifdef __BIG_ENDIAN
+#if __BYTE_ORDER == __BIG_ENDIAN
#ifdef __KERNEL__
#define ENVFS_16(x) swab16(x)
#define ENVFS_24(x) ((swab32(x)) >> 8)
@@ -60,9 +69,8 @@ struct envfs_super {
#define ENVFS_GET_OFFSET(x) ENVFS_32(((x)->offset))
#define ENVFS_SET_NAMELEN(x,y)((x)->offset = ENVFS_32((y)))
#define ENVFS_SET_OFFSET(x,y) ((x)->namelen = ENVFS_32((y)))
-#else
-#error "__BYTE_ORDER must be __LITTLE_ENDIAN or __BIG_ENDIAN"
-#endif
+#endif /* __BYTE_ORDER == __BIG_ENDIAN */
+#endif /* __BIG_ENDIAN */
#endif /* _ENVFS_H */
diff --git a/include/linux/byteorder/generic.h b/include/linux/byteorder/generic.h
index aab8f4b..2d68d99 100644
--- a/include/linux/byteorder/generic.h
+++ b/include/linux/byteorder/generic.h
@@ -78,13 +78,6 @@
*
*/
-#ifndef __LITTLE_ENDIAN
-#define __LITTLE_ENDIAN 1234
-#endif
-#ifndef __BIG_ENDIAN
-#define __BIG_ENDIAN 4321
-#endif
-
#if defined(__KERNEL__)
/*
* inside the kernel, we can use nicknames;
diff --git a/include/usb/usb.h b/include/usb/usb.h
index f273983..e13d549 100644
--- a/include/usb/usb.h
+++ b/include/usb/usb.h
@@ -271,7 +271,7 @@ void usb_rescan(void);
((x_ & 0xFF000000UL) >> 24)); \
})
-#if __BYTE_ORDER == __LITTLE_ENDIAN
+#ifdef __LITTLE_ENDIAN
# define swap_16(x) (x)
# define swap_32(x) (x)
#else
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 2/5] byteorder: add sanity check
2012-06-28 18:32 [PATCH v2 0/5] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines Antony Pavlov
@ 2012-06-28 18:32 ` Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 3/5] clocksource: move the NSEC_PER_SEC constant to common header Antony Pavlov
` (2 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Antony Pavlov @ 2012-06-28 18:32 UTC (permalink / raw)
To: barebox
The Linux Kernel defines only one of __LITTLE_ENDIAN and
__BIG_ENDIAN. Endianess can then be tested with #ifdef __xx_ENDIAN.
Userspace always defined both __LITTLE_ENDIAN and __BIG_ENDIAN
and byteorder can then be tested with #if __BYTE_ORDER == __xx_ENDIAN.
As we tend to use a lot of Kernel code in barebox we use
the kernel way of determing the byte order. Make sure here
that architecture code properly defines it.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
include/common.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/include/common.h b/include/common.h
index 9745aeb..ece3d13 100644
--- a/include/common.h
+++ b/include/common.h
@@ -241,4 +241,22 @@ static inline void barebox_banner(void) {}
(__x < 0) ? -__x : __x; \
})
+/*
+ * sanity check. The Linux Kernel defines only one of __LITTLE_ENDIAN and
+ * __BIG_ENDIAN. Endianess can then be tested with #ifdef __xx_ENDIAN.
+ * Userspace always defined both __LITTLE_ENDIAN and __BIG_ENDIAN and
+ * byteorder can then be tested with #if __BYTE_ORDER == __xx_ENDIAN.
+ *
+ * As we tend to use a lot of Kernel code in barebox we use the kernel way of
+ * determing the byte order. Make sure here that architecture code properly
+ * defines it.
+ */
+#include <asm/byteorder.h>
+#if defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN)
+#error "both __LITTLE_ENDIAN and __BIG_ENDIAN are defined"
+#endif
+#if !defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN)
+#error "None of __LITTLE_ENDIAN and __BIG_ENDIAN are defined"
+#endif
+
#endif /* __COMMON_H_ */
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 3/5] clocksource: move the NSEC_PER_SEC constant to common header
2012-06-28 18:32 [PATCH v2 0/5] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 2/5] byteorder: add sanity check Antony Pavlov
@ 2012-06-28 18:32 ` Antony Pavlov
2012-06-29 7:57 ` Sascha Hauer
2012-06-28 18:32 ` [PATCH v2 4/5] MIPS: XBurst: fix the JZ4755's clocksource input frequency value Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 5/5] MIPS: XBurst: use clocks_calc_mult_shift() for JZ4755's clocksource Antony Pavlov
4 siblings, 1 reply; 11+ messages in thread
From: Antony Pavlov @ 2012-06-28 18:32 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/ppc/mach-mpc85xx/include/mach/clocks.h | 2 --
include/clock.h | 2 ++
include/linux/time.h | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/ppc/mach-mpc85xx/include/mach/clocks.h b/arch/ppc/mach-mpc85xx/include/mach/clocks.h
index 9477168..2ab367b 100644
--- a/arch/ppc/mach-mpc85xx/include/mach/clocks.h
+++ b/arch/ppc/mach-mpc85xx/include/mach/clocks.h
@@ -10,8 +10,6 @@ struct sys_info {
unsigned long freqLocalBus;
};
-#define NSEC_PER_SEC 1000000000L
-
unsigned long fsl_get_bus_freq(ulong dummy);
unsigned long fsl_get_timebase_clock(void);
void fsl_get_sys_info(struct sys_info *sysInfo);
diff --git a/include/clock.h b/include/clock.h
index 123f874..c01a8d0 100644
--- a/include/clock.h
+++ b/include/clock.h
@@ -3,6 +3,8 @@
#ifndef CLOCK_H
#define CLOCK_H
+#include <linux/time.h>
+
#define CLOCKSOURCE_MASK(bits) (uint64_t)((bits) < 64 ? ((1ULL<<(bits))-1) : -1)
struct clocksource {
diff --git a/include/linux/time.h b/include/linux/time.h
index bf12b99..a1be8fe 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -9,6 +9,7 @@
#define _REENT_ONLY
+#define NSEC_PER_SEC 1000000000L
#define SECSPERMIN 60L
#define MINSPERHOUR 60L
#define HOURSPERDAY 24L
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 4/5] MIPS: XBurst: fix the JZ4755's clocksource input frequency value
2012-06-28 18:32 [PATCH v2 0/5] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov
` (2 preceding siblings ...)
2012-06-28 18:32 ` [PATCH v2 3/5] clocksource: move the NSEC_PER_SEC constant to common header Antony Pavlov
@ 2012-06-28 18:32 ` Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 5/5] MIPS: XBurst: use clocks_calc_mult_shift() for JZ4755's clocksource Antony Pavlov
4 siblings, 0 replies; 11+ messages in thread
From: Antony Pavlov @ 2012-06-28 18:32 UTC (permalink / raw)
To: barebox
The 40 KHz frequency value was used to parry
__lshrdi3() error on little-endian MIPS because
the __lshrdi3() function is used in clocksource code.
The true value of the JZ4755's external clock frequency is 24 MHz.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/mips/mach-xburst/csrc-jz4750.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/mach-xburst/csrc-jz4750.c b/arch/mips/mach-xburst/csrc-jz4750.c
index f625b70..dc7135a 100644
--- a/arch/mips/mach-xburst/csrc-jz4750.c
+++ b/arch/mips/mach-xburst/csrc-jz4750.c
@@ -28,7 +28,7 @@
#include <io.h>
#include <mach/jz4750d_regs.h>
-#define JZ_TIMER_CLOCK 40000
+#define JZ_TIMER_CLOCK 24000000
static uint64_t jz4750_cs_read(void)
{
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 5/5] MIPS: XBurst: use clocks_calc_mult_shift() for JZ4755's clocksource
2012-06-28 18:32 [PATCH v2 0/5] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov
` (3 preceding siblings ...)
2012-06-28 18:32 ` [PATCH v2 4/5] MIPS: XBurst: fix the JZ4755's clocksource input frequency value Antony Pavlov
@ 2012-06-28 18:32 ` Antony Pavlov
4 siblings, 0 replies; 11+ messages in thread
From: Antony Pavlov @ 2012-06-28 18:32 UTC (permalink / raw)
To: barebox
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/mips/mach-xburst/csrc-jz4750.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/arch/mips/mach-xburst/csrc-jz4750.c b/arch/mips/mach-xburst/csrc-jz4750.c
index dc7135a..36e401e 100644
--- a/arch/mips/mach-xburst/csrc-jz4750.c
+++ b/arch/mips/mach-xburst/csrc-jz4750.c
@@ -38,12 +38,13 @@ static uint64_t jz4750_cs_read(void)
static struct clocksource jz4750_cs = {
.read = jz4750_cs_read,
.mask = CLOCKSOURCE_MASK(32),
- .shift = 10,
};
static int clocksource_init(void)
{
- jz4750_cs.mult = clocksource_hz2mult(JZ_TIMER_CLOCK, jz4750_cs.shift);
+ clocks_calc_mult_shift(&jz4750_cs.mult, &jz4750_cs.shift,
+ JZ_TIMER_CLOCK, NSEC_PER_SEC, 10);
+
init_clock(&jz4750_cs);
__raw_writel(TCU_OSTCSR_PRESCALE1 | TCU_OSTCSR_EXT_EN,
--
1.7.10
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines
2012-06-28 18:32 ` [PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines Antony Pavlov
@ 2012-06-29 7:25 ` Sascha Hauer
2012-06-29 7:36 ` Sascha Hauer
2012-06-29 8:48 ` Antony Pavlov
0 siblings, 2 replies; 11+ messages in thread
From: Sascha Hauer @ 2012-06-29 7:25 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Thu, Jun 28, 2012 at 10:32:30PM +0400, Antony Pavlov wrote:
> In the Linux kernel sources the only one byteorder macro
> can be defined (__BIG_ENDIAN or __LITTLE_ENDIAN) at a time.
>
> In barebox we have the __BIG_ENDIAN and __LITTLE_ENDIAN macros
> defined simultaneously introduced in
>
> commit 9ad1fe64abb12baac918ec177d9a52bbf2980d16
> Author: Baruch Siach <baruch@tkos.co.il>
> Date: Sun Jun 27 08:46:05 2010 +0300
>
> byteorder: add missing {BIG,LITTLE}_ENDIAN defines
>
> This fixes build warnings when testing __BYTE_ORDER
> of the other kin
>
> But in arch/mips/lib/libgcc.h (from Linux) we have
>
> #ifdef __BIG_ENDIAN
> struct DWstruct {
> int high, low;
> };
> #elif defined(__LITTLE_ENDIAN)
> struct DWstruct {
> int low, high;
> };
> #else
> #error I feel sick.
> #endif
>
> This means that regardless of current byteorder the big-endian
> DWstruct will be selected. By turn this breaks the __lshrdi3()
> function and the clocksource code on little-endian MIPS.
>
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> drivers/ata/disk_ata_drive.c | 2 +-
> drivers/nor/cfi_flash.c | 6 +++---
> include/cramfs/cramfs_fs.h | 4 ++--
> include/envfs.h | 16 ++++++++++++----
> include/linux/byteorder/generic.h | 7 -------
> include/usb/usb.h | 2 +-
> 6 files changed, 19 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c
> index 4602af3..d5c5837 100644
> --- a/drivers/ata/disk_ata_drive.c
> +++ b/drivers/ata/disk_ata_drive.c
> @@ -231,7 +231,7 @@ static void __maybe_unused ata_dump_id(uint16_t *id)
> */
> static void ata_fix_endianess(uint16_t *buf, unsigned wds)
> {
> -#if __BYTE_ORDER == __BIG_ENDIAN
> +#ifdef __BIG_ENDIAN
> unsigned u;
>
> for (u = 0; u < wds; u++)
> diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c
> index 654e647..02340e6 100644
> --- a/drivers/nor/cfi_flash.c
> +++ b/drivers/nor/cfi_flash.c
> @@ -82,7 +82,7 @@ static void flash_add_byte (struct flash_info *info, cfiword_t * cword, uchar c)
> return;
> }
>
> -#if __BYTE_ORDER == __BIG_ENDIAN
> +#ifdef __BIG_ENDIAN
> *cword = (*cword << 8) | c;
> #else
>
> @@ -167,7 +167,7 @@ static void flash_printqry (struct cfi_qry *qry)
> uchar flash_read_uchar (struct flash_info *info, uint offset)
> {
> uchar *cp = flash_make_addr(info, 0, offset);
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> +#ifdef __LITTLE_ENDIAN
> return flash_read8(cp);
> #else
> return flash_read8(cp + info->portwidth - 1);
> @@ -195,7 +195,7 @@ static ulong flash_read_long (struct flash_info *info, flash_sect_t sect, uint o
> debug ("addr[%x] = 0x%x\n", x, flash_read8(addr + x));
> }
> #endif
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> +#ifdef __LITTLE_ENDIAN
> retval = ((flash_read8(addr) << 16) |
> (flash_read8(addr + info->portwidth) << 24) |
> (flash_read8(addr + 2 * info->portwidth)) |
> diff --git a/include/cramfs/cramfs_fs.h b/include/cramfs/cramfs_fs.h
> index af2940b..a7e9504 100644
> --- a/include/cramfs/cramfs_fs.h
> +++ b/include/cramfs/cramfs_fs.h
> @@ -88,7 +88,7 @@ struct cramfs_super {
> #error "No byte order defined in __BYTE_ORDER"
> #endif
>
> -#if __BYTE_ORDER == __LITTLE_ENDIAN
> +#ifdef __LITTLE_ENDIAN
> #define CRAMFS_16(x) (x)
> #define CRAMFS_24(x) (x)
> #define CRAMFS_32(x) (x)
> @@ -96,7 +96,7 @@ struct cramfs_super {
> #define CRAMFS_GET_OFFSET(x) ((x)->offset)
> #define CRAMFS_SET_OFFSET(x,y) ((x)->offset = (y))
> #define CRAMFS_SET_NAMELEN(x,y) ((x)->namelen = (y))
> -#elif __BYTE_ORDER ==__BIG_ENDIAN
> +#elif defined(__BIG_ENDIAN)
> #ifdef __KERNEL__
> #define CRAMFS_16(x) swab16(x)
> #define CRAMFS_24(x) ((swab32(x)) >> 8)
> diff --git a/include/envfs.h b/include/envfs.h
> index 67b8902..cb1c648 100644
> --- a/include/envfs.h
> +++ b/include/envfs.h
> @@ -38,6 +38,11 @@ struct envfs_super {
> #error "No byte order defined in __BYTE_ORDER"
> #endif
>
> +#if __BYTE_ORDER != __LITTLE_ENDIAN && __BYTE_ORDER != __BIG_ENDIAN
> +#error "__BYTE_ORDER must be __LITTLE_ENDIAN or __BIG_ENDIAN"
> +#endif
On Big Endian systems __LITTLE_ENDIAN is undefined and this results in:
In file included from common/environment.c:37:
include/envfs.h:41:21: warning: "__LITTLE_ENDIAN" is not defined
> +
> +#ifdef __LITTLE_ENDIAN
As said, this file is included from scripts/bareboxenv.c which is
compiled for userspace. __LITTLE_ENDIAN will always be defined in
userspace.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines
2012-06-29 7:25 ` Sascha Hauer
@ 2012-06-29 7:36 ` Sascha Hauer
2012-06-29 8:48 ` Antony Pavlov
1 sibling, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2012-06-29 7:36 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Fri, Jun 29, 2012 at 09:25:17AM +0200, Sascha Hauer wrote:
> >
> > +#if __BYTE_ORDER != __LITTLE_ENDIAN && __BYTE_ORDER != __BIG_ENDIAN
> > +#error "__BYTE_ORDER must be __LITTLE_ENDIAN or __BIG_ENDIAN"
> > +#endif
>
> On Big Endian systems __LITTLE_ENDIAN is undefined and this results in:
>
> In file included from common/environment.c:37:
> include/envfs.h:41:21: warning: "__LITTLE_ENDIAN" is not defined
In the meantime I applied my original patch. Please let me know if there
is something wrong with it, we can still change it.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 3/5] clocksource: move the NSEC_PER_SEC constant to common header
2012-06-28 18:32 ` [PATCH v2 3/5] clocksource: move the NSEC_PER_SEC constant to common header Antony Pavlov
@ 2012-06-29 7:57 ` Sascha Hauer
0 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2012-06-29 7:57 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Thu, Jun 28, 2012 at 10:32:32PM +0400, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> arch/ppc/mach-mpc85xx/include/mach/clocks.h | 2 --
> include/clock.h | 2 ++
> include/linux/time.h | 1 +
> 3 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/ppc/mach-mpc85xx/include/mach/clocks.h b/arch/ppc/mach-mpc85xx/include/mach/clocks.h
> index 9477168..2ab367b 100644
> --- a/arch/ppc/mach-mpc85xx/include/mach/clocks.h
> +++ b/arch/ppc/mach-mpc85xx/include/mach/clocks.h
> @@ -10,8 +10,6 @@ struct sys_info {
> unsigned long freqLocalBus;
> };
>
> -#define NSEC_PER_SEC 1000000000L
> -
> unsigned long fsl_get_bus_freq(ulong dummy);
> unsigned long fsl_get_timebase_clock(void);
> void fsl_get_sys_info(struct sys_info *sysInfo);
> diff --git a/include/clock.h b/include/clock.h
> index 123f874..c01a8d0 100644
> --- a/include/clock.h
> +++ b/include/clock.h
> @@ -3,6 +3,8 @@
> #ifndef CLOCK_H
> #define CLOCK_H
>
> +#include <linux/time.h>
This breaks compilation on some ARM boards:
In file included from include/clock.h:6:0,
from drivers/i2c/i2c.c:19:
include/linux/time.h: In function 'asctime_r':
include/linux/time.h:62:5: warning: implicit declaration of function
'sprintf' [-Wimplicit-function-declaration]
In file included from include/clock.h:6:0,
from drivers/i2c/busses/i2c-imx.c:36:
I'll fold the following into this patch:
8<-----------------------------------------------------
include/linux/time.h: remove dead code
include/linux/time.h contains several unused functions derived from U-Boot
code. Since this is a file under include/linux/ it should contain only code
from the kernel, so remove all this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
include/linux/time.h | 151 --------------------------------------------------
1 file changed, 151 deletions(-)
diff --git a/include/linux/time.h b/include/linux/time.h
index a1be8fe..3942e82 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -3,157 +3,6 @@
#include <linux/types.h>
-#define _DEFUN(a,b,c) a(c)
-#define _CONST const
-#define _AND ,
-
-#define _REENT_ONLY
-
#define NSEC_PER_SEC 1000000000L
-#define SECSPERMIN 60L
-#define MINSPERHOUR 60L
-#define HOURSPERDAY 24L
-#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
-#define SECSPERDAY (SECSPERHOUR * HOURSPERDAY)
-#define DAYSPERWEEK 7
-#define MONSPERYEAR 12
-
-#define YEAR_BASE 1900
-#define EPOCH_YEAR 1970
-#define EPOCH_WDAY 4
-
-#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
-
-
-/* Used by other time functions. */
-struct tm {
- int tm_sec; /* Seconds. [0-60] (1 leap second) */
- int tm_min; /* Minutes. [0-59] */
- int tm_hour; /* Hours. [0-23] */
- int tm_mday; /* Day. [1-31] */
- int tm_mon; /* Month. [0-11] */
- int tm_year; /* Year - 1900. */
- int tm_wday; /* Day of week. [0-6] */
- int tm_yday; /* Days in year.[0-365] */
- int tm_isdst; /* DST. [-1/0/1]*/
-
-# ifdef __USE_BSD
- long int tm_gmtoff; /* Seconds east of UTC. */
- __const char *tm_zone; /* Timezone abbreviation. */
-# else
- long int __tm_gmtoff; /* Seconds east of UTC. */
- __const char *__tm_zone; /* Timezone abbreviation. */
-# endif
-};
-
-static inline char *
-_DEFUN (asctime_r, (tim_p, result),
- _CONST struct tm *tim_p _AND
- char *result)
-{
- static _CONST char day_name[7][3] = {
- "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
- };
- static _CONST char mon_name[12][3] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
- };
-
- sprintf (result, "%.3s %.3s %.2d %.2d:%.2d:%.2d %d\n",
- day_name[tim_p->tm_wday],
- mon_name[tim_p->tm_mon],
- tim_p->tm_mday, tim_p->tm_hour, tim_p->tm_min,
- tim_p->tm_sec, 1900 + tim_p->tm_year);
- return result;
-}
-
-static inline struct tm *
-_DEFUN (localtime_r, (tim_p, res),
- _CONST time_t * tim_p _AND
- struct tm *res)
-{
- static _CONST int mon_lengths[2][MONSPERYEAR] = {
- {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
- {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
- } ;
-
- static _CONST int year_lengths[2] = {
- 365,
- 366
- } ;
-
- long days, rem;
- int y;
- int yleap;
- _CONST int *ip;
-
- days = ((long) *tim_p) / SECSPERDAY;
- rem = ((long) *tim_p) % SECSPERDAY;
- while (rem < 0)
- {
- rem += SECSPERDAY;
- --days;
- }
- while (rem >= SECSPERDAY)
- {
- rem -= SECSPERDAY;
- ++days;
- }
-
- /* compute hour, min, and sec */
- res->tm_hour = (int) (rem / SECSPERHOUR);
- rem %= SECSPERHOUR;
- res->tm_min = (int) (rem / SECSPERMIN);
- res->tm_sec = (int) (rem % SECSPERMIN);
-
- /* compute day of week */
- if ((res->tm_wday = ((EPOCH_WDAY + days) % DAYSPERWEEK)) < 0)
- res->tm_wday += DAYSPERWEEK;
-
- /* compute year & day of year */
- y = EPOCH_YEAR;
- if (days >= 0)
- {
- for (;;)
- {
- yleap = isleap(y);
- if (days < year_lengths[yleap])
- break;
- y++;
- days -= year_lengths[yleap];
- }
- }
- else
- {
- do
- {
- --y;
- yleap = isleap(y);
- days += year_lengths[yleap];
- } while (days < 0);
- }
-
- res->tm_year = y - YEAR_BASE;
- res->tm_yday = days;
- ip = mon_lengths[yleap];
- for (res->tm_mon = 0; days >= ip[res->tm_mon]; ++res->tm_mon)
- days -= ip[res->tm_mon];
- res->tm_mday = days + 1;
-
- /* set daylight saving time flag */
- res->tm_isdst = -1;
-
- return (res);
-}
-
-static inline char *
-_DEFUN (ctime_r, (tim_p, result),
- _CONST time_t * tim_p _AND
- char * result)
-
-{
- struct tm tm;
- return asctime_r (localtime_r (tim_p, &tm), result);
-}
#endif
--
1.7.10
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines
2012-06-29 7:25 ` Sascha Hauer
2012-06-29 7:36 ` Sascha Hauer
@ 2012-06-29 8:48 ` Antony Pavlov
2012-06-29 9:13 ` Sascha Hauer
1 sibling, 1 reply; 11+ messages in thread
From: Antony Pavlov @ 2012-06-29 8:48 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
On 29 June 2012 11:25, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Thu, Jun 28, 2012 at 10:32:30PM +0400, Antony Pavlov wrote:
>> In the Linux kernel sources the only one byteorder macro
>> can be defined (__BIG_ENDIAN or __LITTLE_ENDIAN) at a time.
>>
>> In barebox we have the __BIG_ENDIAN and __LITTLE_ENDIAN macros
>> defined simultaneously introduced in
>>
>> commit 9ad1fe64abb12baac918ec177d9a52bbf2980d16
>> Author: Baruch Siach <baruch@tkos.co.il>
>> Date: Sun Jun 27 08:46:05 2010 +0300
>>
>> byteorder: add missing {BIG,LITTLE}_ENDIAN defines
>>
>> This fixes build warnings when testing __BYTE_ORDER
>> of the other kin
>>
>> But in arch/mips/lib/libgcc.h (from Linux) we have
>>
>> #ifdef __BIG_ENDIAN
>> struct DWstruct {
>> int high, low;
>> };
>> #elif defined(__LITTLE_ENDIAN)
>> struct DWstruct {
>> int low, high;
>> };
>> #else
>> #error I feel sick.
>> #endif
>>
>> This means that regardless of current byteorder the big-endian
>> DWstruct will be selected. By turn this breaks the __lshrdi3()
>> function and the clocksource code on little-endian MIPS.
>>
>> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
>> ---
>> drivers/ata/disk_ata_drive.c | 2 +-
>> drivers/nor/cfi_flash.c | 6 +++---
>> include/cramfs/cramfs_fs.h | 4 ++--
>> include/envfs.h | 16 ++++++++++++----
>> include/linux/byteorder/generic.h | 7 -------
>> include/usb/usb.h | 2 +-
>> 6 files changed, 19 insertions(+), 18 deletions(-)
>>
>> diff --git a/drivers/ata/disk_ata_drive.c b/drivers/ata/disk_ata_drive.c
>> index 4602af3..d5c5837 100644
>> --- a/drivers/ata/disk_ata_drive.c
>> +++ b/drivers/ata/disk_ata_drive.c
>> @@ -231,7 +231,7 @@ static void __maybe_unused ata_dump_id(uint16_t *id)
>> */
>> static void ata_fix_endianess(uint16_t *buf, unsigned wds)
>> {
>> -#if __BYTE_ORDER == __BIG_ENDIAN
>> +#ifdef __BIG_ENDIAN
>> unsigned u;
>>
>> for (u = 0; u < wds; u++)
>> diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c
>> index 654e647..02340e6 100644
>> --- a/drivers/nor/cfi_flash.c
>> +++ b/drivers/nor/cfi_flash.c
>> @@ -82,7 +82,7 @@ static void flash_add_byte (struct flash_info *info, cfiword_t * cword, uchar c)
>> return;
>> }
>>
>> -#if __BYTE_ORDER == __BIG_ENDIAN
>> +#ifdef __BIG_ENDIAN
>> *cword = (*cword << 8) | c;
>> #else
>>
>> @@ -167,7 +167,7 @@ static void flash_printqry (struct cfi_qry *qry)
>> uchar flash_read_uchar (struct flash_info *info, uint offset)
>> {
>> uchar *cp = flash_make_addr(info, 0, offset);
>> -#if __BYTE_ORDER == __LITTLE_ENDIAN
>> +#ifdef __LITTLE_ENDIAN
>> return flash_read8(cp);
>> #else
>> return flash_read8(cp + info->portwidth - 1);
>> @@ -195,7 +195,7 @@ static ulong flash_read_long (struct flash_info *info, flash_sect_t sect, uint o
>> debug ("addr[%x] = 0x%x\n", x, flash_read8(addr + x));
>> }
>> #endif
>> -#if __BYTE_ORDER == __LITTLE_ENDIAN
>> +#ifdef __LITTLE_ENDIAN
>> retval = ((flash_read8(addr) << 16) |
>> (flash_read8(addr + info->portwidth) << 24) |
>> (flash_read8(addr + 2 * info->portwidth)) |
>> diff --git a/include/cramfs/cramfs_fs.h b/include/cramfs/cramfs_fs.h
>> index af2940b..a7e9504 100644
>> --- a/include/cramfs/cramfs_fs.h
>> +++ b/include/cramfs/cramfs_fs.h
>> @@ -88,7 +88,7 @@ struct cramfs_super {
>> #error "No byte order defined in __BYTE_ORDER"
>> #endif
>>
>> -#if __BYTE_ORDER == __LITTLE_ENDIAN
>> +#ifdef __LITTLE_ENDIAN
>> #define CRAMFS_16(x) (x)
>> #define CRAMFS_24(x) (x)
>> #define CRAMFS_32(x) (x)
>> @@ -96,7 +96,7 @@ struct cramfs_super {
>> #define CRAMFS_GET_OFFSET(x) ((x)->offset)
>> #define CRAMFS_SET_OFFSET(x,y) ((x)->offset = (y))
>> #define CRAMFS_SET_NAMELEN(x,y) ((x)->namelen = (y))
>> -#elif __BYTE_ORDER ==__BIG_ENDIAN
>> +#elif defined(__BIG_ENDIAN)
>> #ifdef __KERNEL__
>> #define CRAMFS_16(x) swab16(x)
>> #define CRAMFS_24(x) ((swab32(x)) >> 8)
>> diff --git a/include/envfs.h b/include/envfs.h
>> index 67b8902..cb1c648 100644
>> --- a/include/envfs.h
>> +++ b/include/envfs.h
>> @@ -38,6 +38,11 @@ struct envfs_super {
>> #error "No byte order defined in __BYTE_ORDER"
>> #endif
>>
>> +#if __BYTE_ORDER != __LITTLE_ENDIAN && __BYTE_ORDER != __BIG_ENDIAN
>> +#error "__BYTE_ORDER must be __LITTLE_ENDIAN or __BIG_ENDIAN"
>> +#endif
>
> On Big Endian systems __LITTLE_ENDIAN is undefined and this results in:
>
> In file included from common/environment.c:37:
> include/envfs.h:41:21: warning: "__LITTLE_ENDIAN" is not defined
You are right.
>> +
>> +#ifdef __LITTLE_ENDIAN
>
> As said, this file is included from scripts/bareboxenv.c which is
> compiled for userspace. __LITTLE_ENDIAN will always be defined in
> userspace.
But it included from common/environment.c too!
Moreover, in my company there is Processor Core Testing Department.
These folks like to rebuild full MIPS Linux distribution on our
big-endian MIPS system natively just for testing purposes. So, I have
a chance to build MIPS barebox on big-endian system :))
>
> --
> Pengutronix e.K. | |
> Industrial Linux Solutions | http://www.pengutronix.de/ |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines
2012-06-29 8:48 ` Antony Pavlov
@ 2012-06-29 9:13 ` Sascha Hauer
0 siblings, 0 replies; 11+ messages in thread
From: Sascha Hauer @ 2012-06-29 9:13 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox
On Fri, Jun 29, 2012 at 12:48:23PM +0400, Antony Pavlov wrote:
> On 29 June 2012 11:25, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> >
> > In file included from common/environment.c:37:
> > include/envfs.h:41:21: warning: "__LITTLE_ENDIAN" is not defined
>
> You are right.
>
> >> +
> >> +#ifdef __LITTLE_ENDIAN
> >
> > As said, this file is included from scripts/bareboxenv.c which is
> > compiled for userspace. __LITTLE_ENDIAN will always be defined in
> > userspace.
>
> But it included from common/environment.c too!
That's why I have the following:
#ifdef __BAREBOX__
# ifdef __LITTLE_ENDIAN
# define ENVFS_ORDER_LITTLE
# elif defined __BIG_ENDIAN
# define ENVFS_ORDER_BIG
# else
# error "could not determine byte order"
# endif
#else
# if __BYTE_ORDER == __LITTLE_ENDIAN
# define ENVFS_ORDER_LITTLE
# elif __BYTE_ORDER == __BIG_ENDIAN
# define ENVFS_ORDER_BIG
# else
# error "could not determine byte order"
# endif
#endif
This should work as expected. Maybe the name ENVFS_ORDER_LITTLE and
ENVFS_ORDER_BIG are a bit confusing, should probably better ENVFS_ORDER_NATIVE
and ENVFS_ORDER_SWAP.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2012-06-29 9:13 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-28 18:32 [PATCH v2 0/5] MIPS: XBurst: fix the JZ4755's clocksource Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 1/5] byteorder: fix {BIG,LITTLE}_ENDIAN defines Antony Pavlov
2012-06-29 7:25 ` Sascha Hauer
2012-06-29 7:36 ` Sascha Hauer
2012-06-29 8:48 ` Antony Pavlov
2012-06-29 9:13 ` Sascha Hauer
2012-06-28 18:32 ` [PATCH v2 2/5] byteorder: add sanity check Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 3/5] clocksource: move the NSEC_PER_SEC constant to common header Antony Pavlov
2012-06-29 7:57 ` Sascha Hauer
2012-06-28 18:32 ` [PATCH v2 4/5] MIPS: XBurst: fix the JZ4755's clocksource input frequency value Antony Pavlov
2012-06-28 18:32 ` [PATCH v2 5/5] MIPS: XBurst: use clocks_calc_mult_shift() for JZ4755's clocksource Antony Pavlov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox