Re: Can this be a invalid memory access? (was: Re: [PATCH] spi/xilinx: Cast ioread32/iowrite32 function pointers)

2015-02-02 Thread Geert Uytterhoeven
Hi Ricardo, On Mon, Feb 2, 2015 at 3:05 PM, Ricardo Ribalda Delgado wrote: > On Mon, Feb 2, 2015 at 2:04 PM, Geert Uytterhoeven > wrote: >>> void * pvar=varB; >> >> ... = &varB; >> >>> *pvar = ioread8(valid_memory); >>> >>> Depending if ioread8 returns a u8 or a unsigned int, aren't we also >>>

Re: Can this be a invalid memory access? (was: Re: [PATCH] spi/xilinx: Cast ioread32/iowrite32 function pointers)

2015-02-02 Thread Ricardo Ribalda Delgado
Hello Geert On Mon, Feb 2, 2015 at 2:04 PM, Geert Uytterhoeven wrote: >> void * pvar=varB; > > ... = &varB; > >> *pvar = ioread8(valid_memory); >> >> Depending if ioread8 returns a u8 or a unsigned int, aren't we also >> accessing varC? >> >> Could not this be a problem? > > Please try to compil

Re: Can this be a invalid memory access? (was: Re: [PATCH] spi/xilinx: Cast ioread32/iowrite32 function pointers)

2015-02-02 Thread Geert Uytterhoeven
Hi Ricardo, On Mon, Feb 2, 2015 at 1:49 PM, Ricardo Ribalda Delgado wrote: > Regarding ioread8 et al. > > On include/asm-generic/io.h is defined as: > extern unsigned int ioread8(void __iomem *); > > On include/asm-generic/io.h: > static inline u8 ioread8(const volatile void __iomem *addr) > > Pl

Can this be a invalid memory access? (was: Re: [PATCH] spi/xilinx: Cast ioread32/iowrite32 function pointers)

2015-02-02 Thread Ricardo Ribalda Delgado
Hello Regarding ioread8 et al. On include/asm-generic/io.h is defined as: extern unsigned int ioread8(void __iomem *); On include/asm-generic/io.h: static inline u8 ioread8(const volatile void __iomem *addr) Please ignore the qualifiers right now. The first function returns an unsigned integer,

Re: [PATCH] spi/xilinx: Cast ioread32/iowrite32 function pointers

2015-01-29 Thread Arnd Bergmann
On Thursday 29 January 2015 23:14:46 Ricardo Ribalda Delgado wrote: > What about the different return type? u8 vs int Too many drivers use all sorts of different types, I've given up hope of changing drivers to agree on the same type here. Basically you can think of 'void __iomem *' as the magic k

Re: [PATCH] spi/xilinx: Cast ioread32/iowrite32 function pointers

2015-01-29 Thread Ricardo Ribalda Delgado
Hello Arnd On Thu, Jan 29, 2015 at 11:11 PM, Arnd Bergmann wrote: >> > I think the definitions in include/asm-generic/iomap.h are actually wrong, >> > as they lack a const: >> > >> > extern unsigned int ioread8(void __iomem *); >> > extern unsigned int ioread16(void __iomem *); >> > e

Re: [PATCH] spi/xilinx: Cast ioread32/iowrite32 function pointers

2015-01-29 Thread Arnd Bergmann
On Thursday 29 January 2015 17:39:08 Ricardo Ribalda Delgado wrote: > > I think the definitions in include/asm-generic/iomap.h are actually wrong, > > as they lack a const: > > > > extern unsigned int ioread8(void __iomem *); > > extern unsigned int ioread16(void __iomem *); > > extern

Re: [PATCH] spi/xilinx: Cast ioread32/iowrite32 function pointers

2015-01-29 Thread Ricardo Ribalda Delgado
Hello Arnd On Thu, Jan 29, 2015 at 5:04 PM, Arnd Bergmann wrote: > Casting the type of a function you call seems rather dangerous. Why not > add an inline function in this driver as a wrapper? > > Arnd Agree, please ignore this patch. Sorry for the noise -- Ricardo Ribalda -- To unsub

Re: [PATCH] spi/xilinx: Cast ioread32/iowrite32 function pointers

2015-01-29 Thread Ricardo Ribalda Delgado
Hello Geert On Thu, Jan 29, 2015 at 4:56 PM, Geert Uytterhoeven wrote: > On Thu, Jan 29, 2015 at 3:51 PM, Ricardo Ribalda Delgado > wrote: >> IO functions prototypes may have different argument qualifiers >> on different architectures. >> >> This patch cast the assignment of the function, to mat

Re: [PATCH] spi/xilinx: Cast ioread32/iowrite32 function pointers

2015-01-29 Thread Arnd Bergmann
On Thursday 29 January 2015 15:51:13 Ricardo Ribalda Delgado wrote: > * Setup little endian helper functions first and try to use them > * and check if bit was correctly setup or not. > */ > - xspi->read_fn = ioread32; > - xspi->write_fn = iowrite32; > +

Re: [PATCH] spi/xilinx: Cast ioread32/iowrite32 function pointers

2015-01-29 Thread Geert Uytterhoeven
On Thu, Jan 29, 2015 at 3:51 PM, Ricardo Ribalda Delgado wrote: > IO functions prototypes may have different argument qualifiers > on different architectures. > > This patch cast the assignment of the function, to match the one defined > at iomap.h. Adding casts is (usually) not the solution to t