: Fixes for ubifs build on ARM
Subsystems (4)
cover : Fixes for ubifs build on ARM
Hello!
This series of patches corrects some of the issues I've had with building and using the ubifs support on ARM (and some general things). In summary:
- move __set_bit and __clear_bit to bitops.h (was defined in ubifs.h)
- define fls for all architectures (and ffs where it was missing)
- unaligned.h was missing for ARM, add it
- use do_div from div64.h for vsprintf (avoid __udivdi3)
- use lldiv in ubifs (again to avoid __udivdi3 references)
- handle VID header offset in the ubi part command
- proper argument checking in ubifsmount
I've built and tested it on ARM (OpenRD base), but some of the patches also affect other architectures, so please look this through!
// Simon
PATCH 1/8 : Move __set/clear_bit from ubifs.h to bitops.h
Move __set/clear_bit from ubifs.h to bitops.h
__set_bit and __clear_bit are defined in ubifs.h as well as in asm/include/bitops.h for some architectures. This patch moves the generic implementation to include/linux/bitops.h and uses that unless it's defined by the architecture.
--- fs/ubifs/ubifs.h | 32 -------------------------------- include/asm-avr32/bitops.h | 3 +++ include/asm-m68k/bitops.h | 3 +++ include/asm-nios/bitops.h | 3 +++ include/asm-nios2/bitops.h | 3 +++ include/asm-ppc/bitops.h | 3 +++ include/asm-sh/bitops.h | 4 ++++ include/asm-sparc/bitops.h | 3 +++ include/linux/bitops.h | 30 ++++++++++++++++++++++++++++++ 9 files changed, 52 insertions(+), 32 deletions(-)
fs/ubifs/ubifs.h +0 -32
@@ -449,38 +449,6 @@ static inline ino_t parent_ino(struct dentry *dentry)return res; } -/* linux/include/linux/bitops.h */ - -#define BIT_MASK (nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD (nr) ((nr) / BITS_PER_LONG) - -/* linux/include/asm-generic/bitops/non-atomic.h */ - -/** -* __set_bit - Set a bit in memory -* @nr: the bit to set -* @addr: the address to start counting from -* -* Unlike set_bit(), this function is non-atomic and may be reordered. -* If it's called on the same region of memory simultaneously, the effect -* may be that only one operation succeeds. -*/ -static inline void __set_bit (int nr,volatile unsigned long *addr) -{ -unsigned long mask =BIT_MASK (nr); -unsigned long *p = ((unsigned long *)addr) +BIT_WORD (nr); - - *p |= mask; -} - -static inline void __clear_bit (int nr,volatile unsigned long *addr) -{ -unsigned long mask =BIT_MASK (nr); -unsigned long *p = ((unsigned long *)addr) +BIT_WORD (nr); - - *p &= ~mask; -} -/* debug.c */ #define DEFINE_SPINLOCK (...)
include/asm-avr32/bitops.h +3 -0
@@ -22,4 +22,7 @@#ifndef __ASM_AVR32_BITOPS_H#define __ASM_AVR32_BITOPS_H +#define __set_bit (nr, addr) generic_set_bit(nr, addr) +#define __clear_bit (nr, addr) generic_clear_bit(nr, addr) +#endif /* __ASM_AVR32_BITOPS_H */
include/asm-m68k/bitops.h +3 -0
@@ -15,6 +15,9 @@ extern int test_and_set_bit(int nr, volatile void *addr);extern int test_and_clear_bit (int nr,volatile void *addr);extern int test_and_change_bit (int nr,volatile void *addr); +#define __set_bit (nr, addr) generic_set_bit(nr, addr) +#define __clear_bit (nr, addr) generic_clear_bit(nr, addr) +#ifdef __KERNEL__/*
include/asm-nios/bitops.h +3 -0
@@ -34,4 +34,7 @@ extern int test_and_change_bit(int nr, volatile void * addr);extern int test_bit (int nr,volatile void * a);extern int ffs (int i); +#define __set_bit (nr, addr) generic_set_bit(nr, addr) +#define __clear_bit (nr, addr) generic_clear_bit(nr, addr) +#endif /* _ASM_NIOS_BITOPS_H */
include/asm-nios2/bitops.h +3 -0
@@ -34,4 +34,7 @@ extern int test_and_change_bit(int nr, volatile void * addr);extern int test_bit (int nr,volatile void * a);extern int ffs (int i); +#define __set_bit (nr, addr) generic_set_bit(nr, addr) +#define __clear_bit (nr, addr) generic_clear_bit(nr, addr) +#endif /* __ASM_NIOS2_BITOPS_H */
include/asm-ppc/bitops.h +3 -0
@@ -144,6 +144,9 @@ extern __inline__ int test_and_change_bit(int nr, volatile void *addr) }#endif /* __INLINE_BITOPS */ +#define __set_bit (nr, addr) generic_set_bit(nr, addr) +#define __clear_bit (nr, addr) generic_clear_bit(nr, addr) + extern __inline__ int test_bit(int nr, __const__ volatile void *addr) { __const__ unsigned int *p = (__const__ unsigned int *) addr;
include/asm-sh/bitops.h +4 -0
@@ -146,6 +146,10 @@ static inline int ffs (int x) }return r; } + +#define __set_bit (nr, addr) generic_set_bit(nr, addr) +#define __clear_bit (nr, addr) generic_clear_bit(nr, addr) +#endif /* __KERNEL__ */ #endif /* __ASM_SH_BITOPS_H */
include/asm-sparc/bitops.h +3 -0
@@ -26,4 +26,7 @@#ifndef _SPARC_BITOPS_H#define _SPARC_BITOPS_H +#define __set_bit (nr, addr) generic_set_bit(nr, addr) +#define __clear_bit (nr, addr) generic_clear_bit(nr, addr) +#endif /* _SPARC_BITOPS_H */
include/linux/bitops.h +30 -0
@@ -69,4 +69,34 @@ static inline unsigned int generic_hweight8(unsigned int w)#include <asm/bitops.h> +#define BIT_MASK (nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD (nr) ((nr) / BITS_PER_LONG) + +/* linux/include/asm-generic/bitops/non-atomic.h */ + +/** +* __set_bit - Set a bit in memory +* @nr: the bit to set +* @addr: the address to start counting from +* +* Unlike set_bit(), this function is non-atomic and may be reordered. +* If it's called on the same region of memory simultaneously, the effect +* may be that only one operation succeeds. +*/ +static inline void generic_set_bit (int nr,volatile unsigned long *addr) +{ +unsigned long mask =BIT_MASK (nr); +unsigned long *p = ((unsigned long *)addr) +BIT_WORD (nr); + + *p |= mask; +} + +static inline void generic_clear_bit (int nr,volatile unsigned long *addr) +{ +unsigned long mask =BIT_MASK (nr); +unsigned long *p = ((unsigned long *)addr) +BIT_WORD (nr); + + *p &= ~mask; +} +#endif
Signature · 1 line
1.6.0.4
PATCH 1/8 : Move __set/clear_bit from ubifs.h to bitops.h
Quoted 8 lines · On Tuesday 07 July 2009 15:56:31 Simon Kagstrom wrote:
Move __set/clear_bit from
ubifs.htobitops.h
__set_bitand__clear_bitare defined inubifs.has well as inasm/include/bitops.hfor some architectures. This patch moves the generic implementation toinclude/linux/bitops.hand uses that unless it's defined by the architecture.Signed-off-by Simon Kagstrom <[email protected]>
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 1/8 : Move __set/clear_bit from ubifs.h to bitops.h
In reply to Simon KagstromQuoted 8 lines · Simon Kagstrom
Move __set/clear_bit from
ubifs.htobitops.h
__set_bitand__clear_bitare defined inubifs.has well as inasm/include/bitops.hfor some architectures. This patch moves the generic implementation toinclude/linux/bitops.hand uses that unless it's defined by the architecture.Signed-off-by Simon Kagstrom <[email protected]>
Quoted 10 lines
--- fs/ubifs/ubifs.h | 32 -------------------------------- include/asm-avr32/bitops.h | 3 +++ include/asm-m68k/bitops.h | 3 +++ include/asm-nios/bitops.h | 3 +++ include/asm-nios2/bitops.h | 3 +++ include/asm-ppc/bitops.h | 3 +++ include/asm-sh/bitops.h | 4 ++++ include/asm-sparc/bitops.h | 3 +++ include/linux/bitops.h | 30 ++++++++++++++++++++++++++++++
IIRC it's not include/linux/bitops.h
butinclude/asm-generic/bitops/non-atomic.h
Best Regards,
J.
PATCH 2/8 : Define ffs/fls for all architectures
In reply to Simon KagstromUBIFS requires fls(), which is not defined for arm (and some other architectures) and this patch adds it. The implementation is taken from Linux and is generic. ffs() is also defined for those that miss it.
--- include/asm-arm/bitops.h | 4 ++++ include/asm-avr32/bitops.h | 3 +++ include/asm-i386/bitops.h | 2 ++ include/asm-m68k/bitops.h | 2 ++ include/asm-microblaze/bitops.h | 2 ++ include/asm-mips/bitops.h | 2 ++ include/asm-nios/bitops.h | 4 +++- include/asm-nios2/bitops.h | 4 +++- include/asm-sh/bitops.h | 2 ++ include/asm-sparc/bitops.h | 3 +++ include/linux/bitops.h | 37 +++++++++++++++++++++++++++++++++++++ 11 files changed, 63 insertions(+), 2 deletions(-)
include/asm-arm/bitops.h +4 -0
@@ -17,6 +17,8 @@#ifdef __KERNEL__ +#include <asm/types.h> +#define smp_mb__before_clear_bit () do { } while (0)#define smp_mb__after_clear_bit () do { } while (0)
@@ -117,6 +119,8 @@ static inline unsigned long ffz(unsigned long word)#define ffs (x) generic_ffs(x) +#define fls (x) generic_fls(x) +/* * hweightN: returns the hamming weight (i.e. the number * of bits set) of a N-bit word
include/asm-avr32/bitops.h +3 -0
@@ -25,4 +25,7 @@#define __set_bit (nr, addr) generic_set_bit(nr, addr)#define __clear_bit (nr, addr) generic_clear_bit(nr, addr) +#define ffs (x) generic_ffs(x) +#define fls (x) generic_fls(x) +#endif /* __ASM_AVR32_BITOPS_H */
include/asm-i386/bitops.h +2 -0
@@ -350,6 +350,8 @@ static __inline__ int ffs(int x)return r+1 ; } +#define fls (x) generic_fls(x) +/** * hweightN - returns the hamming weight of a N-bit word * @x: the word to weigh
include/asm-m68k/bitops.h +2 -0
@@ -55,6 +55,8 @@ extern __inline__ int ffs(int x) }#define __ffs (x) (ffs(x) - 1) +#define fls (x) generic_fls(x) +#endif /* __KERNEL__ */ #endif /* _M68K_BITOPS_H */
include/asm-microblaze/bitops.h +2 -0
@@ -266,6 +266,8 @@ found_middle:#define ffs (x) generic_ffs(x) +#define fls (x) generic_fls(x) +/* * hweightN: returns the hamming weight (i.e. the number * of bits set) of a N-bit word
include/asm-mips/bitops.h +2 -0
@@ -716,6 +716,8 @@ static __inline__ unsigned long ffz(unsigned long word)#define ffs (x) generic_ffs(x) +#define fls (x) generic_fls(x) +/* * hweightN - returns the hamming weight of a N-bit word * @x: the word to weigh
include/asm-nios/bitops.h +3 -1
@@ -32,7 +32,9 @@ extern void change_bit(unsigned long nr, volatile void *addr);extern int test_and_set_bit (int nr,volatile void * a);extern int test_and_change_bit (int nr,volatile void * addr);extern int test_bit (int nr,volatile void * a); -extern int ffs (int i); + +#define ffs (x) generic_ffs(x) +#define fls (x) generic_fls(x)#define __set_bit (nr, addr) generic_set_bit(nr, addr)#define __clear_bit (nr, addr) generic_clear_bit(nr, addr)
include/asm-nios2/bitops.h +3 -1
@@ -32,7 +32,9 @@ extern void change_bit(unsigned long nr, volatile void *addr);extern int test_and_set_bit (int nr,volatile void * a);extern int test_and_change_bit (int nr,volatile void * addr);extern int test_bit (int nr,volatile void * a); -extern int ffs (int i); + +#define ffs (x) generic_ffs(x) +#define fls (x) generic_fls(x)#define __set_bit (nr, addr) generic_set_bit(nr, addr)#define __clear_bit (nr, addr) generic_clear_bit(nr, addr)
include/asm-sh/bitops.h +2 -0
@@ -147,6 +147,8 @@ static inline int ffs (int x)return r; } +#define fls (x) generic_fls(x) +#define __set_bit (nr, addr) generic_set_bit(nr, addr)#define __clear_bit (nr, addr) generic_clear_bit(nr, addr)
include/asm-sparc/bitops.h +3 -0
@@ -29,4 +29,7 @@#define __set_bit (nr, addr) generic_set_bit(nr, addr)#define __clear_bit (nr, addr) generic_clear_bit(nr, addr) +#define ffs (x) generic_ffs(x) +#define fls (x) generic_fls(x) +#endif /* _SPARC_BITOPS_H */
include/linux/bitops.h +37 -0
@@ -37,6 +37,43 @@ static inline int generic_ffs(int x)return r; } +/** +* fls - find last (most-significant) bit set +* @x: the word to search +* +* This is defined the same way as ffs. +* Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32. +*/ +static inline int generic_fls (int x) +{ +int r =32 ; + +if (!x) +return 0 ; +if (!(x &0xffff0000u )) { + x <<=16 ; + r -=16 ; + } +if (!(x &0xff000000u )) { + x <<=8 ; + r -=8 ; + } +if (!(x &0xf0000000u )) { + x <<=4 ; + r -=4 ; + } +if (!(x &0xc0000000u )) { + x <<=2 ; + r -=2 ; + } +if (!(x &0x80000000u )) { + x <<=1 ; + r -=1 ; + } +return r; +} + +/* * hweightN: returns the hamming weight (i.e. the number * of bits set) of a N-bit word
Signature · 1 line
1.6.0.4
PATCH 2/8 : Define ffs/fls for all architectures
Dear Simon Kagstrom,
Quoted 5 lines · In message <[email protected]> you wrote:
UBIFS requires
fls(), which is not defined for arm (and some other architectures) and this patch adds it. The implementation is taken from Linux and is generic.ffs()is also defined for those that miss it.Signed-off-by Simon Kagstrom <[email protected]>
Quoted 13 lines
--- include/asm-arm/bitops.h | 4 ++++ include/asm-avr32/bitops.h | 3 +++ include/asm-i386/bitops.h | 2 ++ include/asm-m68k/bitops.h | 2 ++ include/asm-microblaze/bitops.h | 2 ++ include/asm-mips/bitops.h | 2 ++ include/asm-nios/bitops.h | 4 +++- include/asm-nios2/bitops.h | 4 +++- include/asm-sh/bitops.h | 2 ++ include/asm-sparc/bitops.h | 3 +++ include/linux/bitops.h | 37 +++++++++++++++++++++++++++++++++++++ 11 files changed, 63 insertions(+), 2 deletions(-)
This patch does not apply at all:
Applying: Define ffs/fls for all architectures
error: patch failed: include/asm-avr32/bitops.h:25
error: include/asm-avr32/bitops.h: patch does not apply
error: patch failed: include/asm-nios/bitops.h:32
error: include/asm-nios/bitops.h: patch does not apply
error: patch failed: include/asm-nios2/bitops.h:32
error: include/asm-nios2/bitops.h: patch does not apply
error: patch failed: include/asm-sh/bitops.h:147
error: include/asm-sh/bitops.h: patch does not apply
error: patch failed: include/asm-sparc/bitops.h:29
error: include/asm-sparc/bitops.h: patch does not apply
fatal: sha1 information is lacking or useless (include/asm-avr32/bitops.h). Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge.
Patch failed at 0001.
Quoted 14 lines
include/asm-arm/bitops.h +2
-0@@ -17,6 +17,8 @@#ifdef __KERNEL__ +#include <asm/types.h> +#define smp_mb__before_clear_bit () do { } while (0)#define smp_mb__after_clear_bit () do { } while (0)
include/asm-arm/bitops.h static inline unsigned long ffz(unsigned long word) · line 122
Quoted 4 lines
include/asm-arm/bitops.h +1
-0@@ -117,6 +119,8 @@ static inline unsigned long ffz(unsigned long word)#define ffs (x) generic_ffs(x) +#define fls (x) generic_fls(x)
Please use a consistent style: here you have an empty line between the two #define's.
include/asm-avr32/bitops.h line 29
Quoted 10 lines
include/asm-avr32/bitops.h +2
-0@@ -25,4 +25,7 @@#define __set_bit (nr, addr) generic_set_bit(nr, addr)#define __clear_bit (nr, addr) generic_clear_bit(nr, addr) +#define ffs (x) generic_ffs(x) +#define fls (x) generic_fls(x)
Here you don't ... and do on.
Please clean up and resubmit.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de There is a multi-legged creature crawling on your shoulder. -- Spock, "A Taste of Armageddon", stardate 3193.9
PATCH 3/8 : Define test_and_set/clear_bit for ARM
In reply to Simon Kagstrom--- include/asm-arm/bitops.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
include/asm-arm/bitops.h +2 -2
@@ -48,7 +48,7 @@ static inline void __change_bit(int nr, volatile void *addr)extern int test_and_set_bit (int nr,volatile void * addr); -static inline int __test_and_set_bit (int nr,volatile void *addr) +extern inline int test_and_set_bit (int nr,volatile void *addr) {unsigned int mask =1 << (nr &7 );unsigned int oldval;
@@ -60,7 +60,7 @@ static inline int __test_and_set_bit(int nr, volatile void *addr)extern int test_and_clear_bit (int nr,volatile void * addr); -static inline int __test_and_clear_bit (int nr,volatile void *addr) +extern inline int test_and_clear_bit (int nr,volatile void *addr) {unsigned int mask =1 << (nr &7 );unsigned int oldval;
Signature · 1 line
1.6.0.4
PATCH 3/8 : Define test_and_set/clear_bit for ARM
Quoted 5 lines · Simon Kagstrom
Signed-off-by Simon Kagstrom <[email protected]>--- include/asm-arm/bitops.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
NACK
the test_and_set_bit and co must be endianless specific which is not the case here
rename it ____atomic_test_and_set_bit if you want but not test_and_set_bit
Best Regards,
J.
PATCH 3/8 : Define test_and_set/clear_bit for ARM
Dear Jean-Christophe PLAGNIOL-VILLARD,
Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 5 lines · Simon Kagstrom
Signed-off-by Simon Kagstrom <[email protected]>--- include/asm-arm/bitops.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
Quoted 6 lines
NACK
the
test_and_set_bitand co must be endianless specific which is not the case hererename it
____atomic_test_and_set_bitif you want but nottest_and_set_bit
Please explain. What has atomicity dto do with the fact if the implementation depends on the byte order or not?
I agree that such macros should be independet of the byteorder, but this applies to test_and_set_bit as well as to ____atomic_test_and_set_bit - why should adding "____atomic_" here make such a difference?
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I am a computer. I am dumber than any human and smarter than any ad- ministrator.
PATCH 3/8 : Define test_and_set/clear_bit for ARM
In reply to Jean-Christophe PLAGNIOL-VILLARDQuoted 10 lines · On Sun, 19 Jul 2009 11:47:13 +0200 Jean-Christophe PLAGNIOL-VILLARD…
Quoted 5 lines · Simon Kagstrom
Signed-off-by Simon Kagstrom <[email protected]>--- include/asm-arm/bitops.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)NACK
the
test_and_set_bitand co must be endianless specific which is not the case here
OK. Anyway, the bitops implementation is a bit messy (which I noted when trying to get ubifs working on arm - hence these patches). Maybe an idea could be to bring in the Linux asm-generic/bitops/* instead and remove the architecture-specific versions?
// Simon
PATCH 4/8 : Add unaligned.h for arm
In reply to Simon KagstromThis patch adds unaligned.h for ARM (needed to build with LZO compression). The file is taken from the linux kernel, but includes u-boot headers instead.
--- include/asm-arm/unaligned.h | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) create mode 100644 include/asm-arm/unaligned.h
include/asm-arm/unaligned.h new file +18 -0
@@ -0,0 +1,18 @@ +#ifndef _ASM_ARM_UNALIGNED_H +#define _ASM_ARM_UNALIGNED_H + +#include <linux/unaligned/access_ok.h> +#include <linux/unaligned/generic.h> + +/* +* Select endianness +*/ +#ifndef __ARMEB__ +#define get_unaligned __get_unaligned_le +#define put_unaligned __put_unaligned_le +#else +#define get_unaligned __get_unaligned_be +#define put_unaligned __put_unaligned_be +#endif + +#endif /* _ASM_ARM_UNALIGNED_H */
Signature · 1 line
1.6.0.4
PATCH 4/8 : Add unaligned.h for arm
Quoted 5 lines · On Tuesday 07 July 2009 15:58:51 Simon Kagstrom wrote:
This patch adds
unaligned.hfor ARM (needed to build with LZO compression). The file is taken from the linux kernel, but includes u-boot headers instead.Signed-off-by Simon Kagstrom <[email protected]>
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
Wolfgang Denk
AppliedPATCH 4/8 : Add unaligned.h for arm
In reply to Simon KagstromDear Simon Kagstrom,
Quoted 9 lines · In message <[email protected]> you wrote:
This patch adds
unaligned.hfor ARM (needed to build with LZO compression). The file is taken from the linux kernel, but includes u-boot headers instead.Signed-off-by Simon Kagstrom <[email protected]>--- include/asm-arm/unaligned.h | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) create mode 100644 include/asm-arm/unaligned.h
Applied. Thanks.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Be careful what you wish for. You never know who will be listening.
- Terry Pratchett, _Soul Music_PATCH 5/8 : Use do_div from div64.h for vsprintf
In reply to Simon Kagstrom--- lib_generic/vsprintf.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
lib_generic/vsprintf.c +1 -6
@@ -13,6 +13,7 @@#include <linux/types.h> #include <linux/string.h> #include <linux/ctype.h> +#include <div64.h> #include <common.h> #if !defined (CONFIG_PANIC_HANG )
@@ -28,12 +29,6 @@ extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);#endif #define noinline __attribute__((noinline)) -#define do_div (n, base) ({ \ - unsigned int __res; \ - __res = ((unsigned NUM_TYPE) n) % base; \ - n = ((unsigned NUM_TYPE) n) / base; \ - __res; \ -})const char hex_asc[] ="0123456789abcdef" ;#define hex_asc_lo (x) hex_asc[((x) & 0x0f)]
Signature · 1 line
1.6.0.4
PATCH 5/8 : Use do_div from div64.h for vsprintf
Quoted 1 line · On Tuesday 07 July 2009 15:59:27 Simon Kagstrom wrote:
Signed-off-by Simon Kagstrom <[email protected]>
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 5/8 : Use do_div from div64.h for vsprintf
Quoted 4 lines · Stefan Roese
Quoted 1 line · On Tuesday 07 July 2009 15:59:27 Simon Kagstrom wrote:
Signed-off-by Simon Kagstrom <[email protected]>Acked-by Stefan Roese <[email protected]>
Could we have this patch asap (for merge window close?) in mainline? Seems that everybody agrees on it.
Many thanks
Dirk
Wolfgang Denk
AppliedPATCH 5/8 : Use do_div from div64.h for vsprintf
In reply to Simon KagstromDear Simon Kagstrom,
Quoted 4 lines · In message <[email protected]> you wrote:
Signed-off-by Simon Kagstrom <[email protected]>--- lib_generic/vsprintf.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Hindsight is an exact science.
PATCH 5/8 : Use do_div from div64.h for vsprintf
Dear Simon Kagstrom,
Quoted 9 lines · In message <[email protected]> I wrote:
Dear Simon Kagstrom,
Quoted 4 lines · In message <[email protected]> you wrote:
Signed-off-by Simon Kagstrom <[email protected]>--- lib_generic/vsprintf.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)Applied, thanks.
Sorry, I had to back out your patch. as it is causing compile problems:
-> ./MAKEALL voiceblue
Configuring for voiceblue board...vsprintf.c: In function 'put_dec':
vsprintf.c:237: warning: comparison of distinct pointer types lacks a cast vsprintf.c:237: warning: right shift count >= width of type
vsprintf.c:237: warning: passing argument 1 of '__div64_32' from incompatible pointer type
text data bss dec hex filename
142099 5196 23304 170599 29a67 ./u-boot
Please fix and resubmit.
Best regards,
Wolfgang Denk
Signature · 5 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I think animal testing is a terrible idea; they get all nervous and give the wrong answers.
PATCH 5/8 : Use do_div from div64.h for vsprintf
Quoted 23 lines · Wolfgang Denk
Dear Simon Kagstrom,
Quoted 8 lines · In message <[email protected]> I wrote:
Dear Simon Kagstrom,
Quoted 4 lines · In message <[email protected]> you wrote:
Signed-off-by Simon Kagstrom <[email protected]>--- lib_generic/vsprintf.c | 7 +------ 1 files changed, 1 insertions(+), 6 deletions(-)Applied, thanks.
Sorry, I had to back out your patch. as it is causing compile problems:
-> ./MAKEALL voiceblue
Configuring for voiceblue board...vsprintf.c: In function 'put_dec':
vsprintf.c:237: warning: comparison of distinct pointer types lacks a cast vsprintf.c:237: warning: right shift count >= width of type
vsprintf.c:237: warning: passing argument 1 of '__div64_32' from incompatible pointer type
text data bss dec hex filename
142099 5196 23304 170599 29a67 ./u-boot
Quoted 1 line
Please fix and resubmit.
:(
This is because do_div() in div64.h only likes a 64bit value as first parameter.
So something like
lib_generic/vsprintf.c +4 -3
@@ -22,18 +22,19 @@ extern int do_reset (cmd_tbl_t *cmdtp, i#endif #ifdef CONFIG_SYS_64BIT_VSPRINTF +#include <div64.h> # define NUM_TYPE long long#else # define NUM_TYPE long -#endif -#define noinline __attribute__((noinline)) -#define do_div (n, base) ({ \ unsigned int __res; \ __res = ((unsigned NUM_TYPE) n) % base; \ n = ((unsigned NUM_TYPE) n) / base; \ __res; \ }) +#endif +#define noinline __attribute__((noinline)) +
would do the trick. I don't know any clean way how to do this, though.
Best regards
Dirk
PATCH 5/8 : Use do_div from div64.h for vsprintf
Hi Dirk,
Quoted 28 lines · On Tuesday 21 July 2009 20:32:01 Dirk Behme wrote:
This is because
do_div()indiv64.honly likes a 64bit value as first parameter.So something like
lib_generic/vsprintf.c +4
-3@@ -22,18 +22,19 @@ extern int do_reset (cmd_tbl_t *cmdtp, i#endif #ifdef CONFIG_SYS_64BIT_VSPRINTF +#include <div64.h> # define NUM_TYPE long long#else # define NUM_TYPE long -#endif -#define noinline __attribute__((noinline)) -#define do_div (n, base) ({ \ unsigned int __res; \ __res = ((unsigned NUM_TYPE) n) % base; \ n = ((unsigned NUM_TYPE) n) / base; \ __res; \ }) +#endif +#define noinline __attribute__((noinline)) +
Quoted 1 line
would do the trick. I don't know any clean way how to do this, though.
I have no "better" idea as well. It's still an improvement to the current implementation. So I suggest you prepare a patch (IIRC, Simon is on vacation right now).
Thanks.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 6/8 : Use lldiv to avoid references to __udvidi3 on (at least) ARM
In reply to Simon Kagstrom--- drivers/mtd/ubi/build.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mtd/ubi/build.c +1 -1
@@ -536,7 +536,7 @@ static int io_init(struct ubi_device *ubi)*/ ubi->peb_size = ubi->mtd->erasesize; - ubi->peb_count = ubi->mtd->size / ubi->mtd->erasesize; + ubi->peb_count =lldiv (ubi->mtd->size, ubi->mtd->erasesize); ubi->flash_size = ubi->mtd->size;if (ubi->mtd->block_isbad && ubi->mtd->block_markbad)
Signature · 1 line
1.6.0.4
PATCH 6/8 : Use lldiv to avoid references to __udvidi3 on (at least) ARM
Hi Simon,
Quoted 10 lines · On Tuesday 07 July 2009 15:59:56 Simon Kagstrom wrote:
Signed-off-by Simon Kagstrom <[email protected]>--- drivers/mtd/ubi/build.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/mtd/ubi/build.c +0
-0
drivers/mtd/ubi/build.c static int io_init(struct ubi_device *ubi) · line 539
Quoted 5 lines
drivers/mtd/ubi/build.c +1
-1@@ -536,7 +536,7 @@ static int io_init(struct ubi_device *ubi)*/ ubi->peb_size = ubi->mtd->erasesize; - ubi->peb_count = ubi->mtd->size / ubi->mtd->erasesize; + ubi->peb_count =lldiv (ubi->mtd->size, ubi->mtd->erasesize);
This rebinds me of a patch I sent a few weeks ago (and forgot to actually push into u-boot-ubi):
http://article.gmane.org/gmane.comp.boot-loaders.u-boot/62440
I suggest we use my patch version since this brings the u-boot UBI version back in sync with the Linux version.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 6/8 : Use lldiv to avoid references to __udvidi3 on (at least) ARM
Quoted 10 lines · On Tue, 7 Jul 2009 16:20:49 +0200 Stefan Roese <[email protected]> wrote:
drivers/mtd/ubi/build.c static int io_init(struct ubi_device *ubi) · line 539
Quoted 2 lines
drivers/mtd/ubi/build.c +1
-1- ubi->peb_count = ubi->mtd->size / ubi->mtd->erasesize; + ubi->peb_count =lldiv (ubi->mtd->size, ubi->mtd->erasesize);This rebinds me of a patch I sent a few weeks ago (and forgot to actually push into u-boot-ubi):
http://article.gmane.org/gmane.comp.boot-loaders.u-boot/62440
I suggest we use my patch version since this brings the u-boot UBI version back in sync with the Linux version.
Agreed!
// Simon
PATCH 7/8 : Handle VID header offset in ubi part command
In reply to Simon KagstromThe VID header offset is sometimes needed to initialize the UBI partition. This patch adds it (optionally) to the command line for the ubi part command.
--- common/cmd_ubi.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)
common/cmd_ubi.c +12 -5
@@ -395,11 +395,12 @@ static int ubi_volume_read(char *volume, char *buf, size_t size)return err ? err : count_save - size; } -static int ubi_dev_scan (struct mtd_info *info,char *ubidev) +static int ubi_dev_scan (struct mtd_info *info,char *ubidev,const char *vid_header_offset) {struct mtd_device *dev;struct part_info *part;struct mtd_partition mtd_part; +char ubi_mtd_param_buffer[80 ];u8 pnum;int err;
@@ -413,7 +414,10 @@ static int ubi_dev_scan(struct mtd_info *info, char *ubidev) mtd_part.offset = part->offset;add_mtd_partitions (info, &mtd_part,1 ); - err =ubi_mtd_param_parse (buffer,NULL ); +strcpy (ubi_mtd_param_buffer, buffer); +if (vid_header_offset) +sprintf (ubi_mtd_param_buffer,"mtd=%d,%s" , pnum, vid_header_offset); + err =ubi_mtd_param_parse (ubi_mtd_param_buffer,NULL );if (err) {del_mtd_partitions (info);return err;
@@ -450,6 +454,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])char mtd_dev[16 ];struct mtd_device *dev;struct part_info *part; +const char *vid_header_offset =NULL ;u8 pnum;/* Print current partition */
@@ -497,8 +502,10 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) ubi_dev.selected =1 ; +if (argc >3 ) + vid_header_offset = argv[3 ];strcpy (ubi_dev.part_name, argv[2 ]); - err =ubi_dev_scan (ubi_dev.mtd_info, ubi_dev.part_name); + err =ubi_dev_scan (ubi_dev.mtd_info, ubi_dev.part_name, vid_header_offset);if (err) {printf ("UBI init error %d\n" , err); ubi_dev.selected =0 ;
@@ -594,8 +601,8 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])U_BOOT_CMD (ubi,6 ,1 , do_ubi,"ubi commands" , -"part [part]" -" - Show or set current partition\n" +"part [part] [offset]" +" - Show or set current partition (with optional VID header offset)\n" "ubi info [l[ayout]]" " - Display volume and ubi layout information\n" "ubi create[vol] volume [size] [type]"
Signature · 1 line
1.6.0.4
PATCH 7/8 : Handle VID header offset in ubi part command
Quoted 14 lines · On Tuesday 07 July 2009 16:00:30 Simon Kagstrom wrote:
The VID header offset is sometimes needed to initialize the UBI partition. This patch adds it (optionally) to the command line for the ubi part command.
Signed-off-by Simon Kagstrom <[email protected]>--- common/cmd_ubi.c | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-)common/cmd_ubi.c +0
-0
common/cmd_ubi.c static int ubi_volume_read(char *volume, char *buf, · line 398
Quoted 5 lines
common/cmd_ubi.c +1
-1@@ -395,11 +395,12 @@ static int ubi_volume_read(char *volume, char *buf, size_t size) return err ? err : count_save - size; } -static int ubi_dev_scan (struct mtd_info *info,char *ubidev) +static int ubi_dev_scan (struct mtd_info *info,char *ubidev,const char *vid_header_offset) {
Line too long. Please re-check the patch for other such occurrences and resubmit.
Other than this:
Thank.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 7/8 : Handle VID header offset in ubi part command
The VID header offset is sometimes needed to initialize the UBI partition. This patch adds it (optionally) to the command line for the ubi part command.
(Lines have been properly wrapped since last version)
--- common/cmd_ubi.c | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-)
common/cmd_ubi.c +16 -5
@@ -395,11 +395,13 @@ static int ubi_volume_read(char *volume, char *buf, size_t size)return err ? err : count_save - size; } -static int ubi_dev_scan (struct mtd_info *info,char *ubidev) +static int ubi_dev_scan (struct mtd_info *info,char *ubidev, +const char *vid_header_offset) {struct mtd_device *dev;struct part_info *part;struct mtd_partition mtd_part; +char ubi_mtd_param_buffer[80 ];u8 pnum;int err;
@@ -413,7 +415,11 @@ static int ubi_dev_scan(struct mtd_info *info, char *ubidev) mtd_part.offset = part->offset;add_mtd_partitions (info, &mtd_part,1 ); - err =ubi_mtd_param_parse (buffer,NULL ); +strcpy (ubi_mtd_param_buffer, buffer); +if (vid_header_offset) +sprintf (ubi_mtd_param_buffer,"mtd=%d,%s" , pnum, + vid_header_offset); + err =ubi_mtd_param_parse (ubi_mtd_param_buffer,NULL );if (err) {del_mtd_partitions (info);return err;
@@ -450,6 +456,7 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])char mtd_dev[16 ];struct mtd_device *dev;struct part_info *part; +const char *vid_header_offset =NULL ;u8 pnum;/* Print current partition */
@@ -497,8 +504,11 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) ubi_dev.selected =1 ; +if (argc >3 ) + vid_header_offset = argv[3 ];strcpy (ubi_dev.part_name, argv[2 ]); - err =ubi_dev_scan (ubi_dev.mtd_info, ubi_dev.part_name); + err =ubi_dev_scan (ubi_dev.mtd_info, ubi_dev.part_name, + vid_header_offset);if (err) {printf ("UBI init error %d\n" , err); ubi_dev.selected =0 ;
@@ -594,8 +604,9 @@ static int do_ubi(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])U_BOOT_CMD (ubi,6 ,1 , do_ubi,"ubi commands" , -"part [part]" -" - Show or set current partition\n" +"part [part] [offset]\n" +" - Show or set current partition (with optional VID" +" header offset)\n" "ubi info [l[ayout]]" " - Display volume and ubi layout information\n" "ubi create[vol] volume [size] [type]"
Signature · 1 line
1.6.0.4
PATCH 7/8 : Handle VID header offset in ubi part command
Quoted 8 lines · On Tuesday 07 July 2009 16:59:46 Simon Kagstrom wrote:
The VID header offset is sometimes needed to initialize the UBI partition. This patch adds it (optionally) to the command line for the ubi part command.
(Lines have been properly wrapped since last version)
Signed-off-by Simon Kagstrom <[email protected]>Acked-by Stefan Roese <[email protected]>
Applied to u-boot-ubi. Thanks.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 8/8 : Command improvements for ubifs
In reply to Simon KagstromCheck that an argument is passed to ubifsmount and that addresses and sizes are actually numbers for ubifsload. Also improve the instructions a bit.
--- common/cmd_ubifs.c | 26 +++++++++++++++++++++----- 1 files changed, 21 insertions(+), 5 deletions(-)
common/cmd_ubifs.c +21 -5
@@ -47,6 +47,10 @@ int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])char *vol_name;int ret; +if (argc !=2 ) { +cmd_usage (cmdtp); +return 1 ; + } vol_name = argv[1 ];debug ("Using volume %s\n" , vol_name);
@@ -88,6 +92,7 @@ int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])int do_ubifs_load (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[]) {char *filename; +char *endp;int ret;u32 addr;u32 size =0 ;
@@ -98,15 +103,25 @@ int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) }if (argc <3 ) { -printf ("Usage:\n%s\n" , cmdtp->usage); +cmd_usage (cmdtp);return -1 ; } - addr =simple_strtoul (argv[1 ],NULL ,16 ); + addr =simple_strtoul (argv[1 ], &endp,16 ); +if (endp == argv[1 ]) { +cmd_usage (cmdtp); +return 1 ; + } + filename = argv[2 ]; -if (argc ==4 ) - size =simple_strtoul (argv[3 ],NULL ,16 ); +if (argc ==4 ) { + size =simple_strtoul (argv[3 ], &endp,16 ); +if (endp == argv[3 ]) { +cmd_usage (cmdtp); +return 1 ; + } + }debug ("Loading file '%s' to address 0x%08x (size %d)\n" , filename, addr, size); ret =ubifs_load (filename, addr, size);
@@ -119,7 +134,8 @@ int do_ubifs_load(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])U_BOOT_CMD ( ubifsmount,2 ,0 , do_ubifs_mount,"mount UBIFS volume" , -"" +"<volume-name>\n" +" - mount 'volume-name' volume" ); U_BOOT_CMD(ubifsls, 2, 0, do_ubifs_ls,
Signature · 1 line
1.6.0.4
PATCH 8/8 : Command improvements for ubifs
Quoted 5 lines · On Tuesday 07 July 2009 16:01:02 Simon Kagstrom wrote:
Check that an argument is passed to ubifsmount and that addresses and sizes are actually numbers for ubifsload. Also improve the instructions a bit.
Signed-off-by Simon Kagstrom <[email protected]>
Looks good, so:
Thanks.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================
PATCH 8/8 : Command improvements for ubifs
In reply to Simon KagstromQuoted 3 lines · On Tuesday 07 July 2009 16:01:02 Simon Kagstrom wrote:
Check that an argument is passed to ubifsmount and that addresses and sizes are actually numbers for ubifsload. Also improve the instructions a bit.
Applied to u-boot-ubi. Thanks.
Simon, one request for your next patches. Please add a keyword to the patch subject, e.g.:
ARM: Add unaligned.h
or
UBI: Handle VID header offset in ubi part command
Thanks.
Best regards,
Stefan
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office at denx.de
=====================================================================