Re: [PATCH v5 07/29] nios2: I/O Mapping

From: Ley Foon Tan
Date: Wed Oct 29 2014 - 03:00:19 EST


On Tue, Oct 28, 2014 at 9:30 PM, Arnd Bergmann <arnd@xxxxxxxx> wrote:
> On Friday 24 October 2014 16:24:09 Ley Foon Tan wrote:
>
>> +/* PCI is not supported in nios2, set this to 0. */
>> +#define IO_SPACE_LIMIT 0
>> +
>> +extern void outsb(unsigned long addr, const void *buf, int len);
>> +extern void outsw(unsigned long addr, const void *buf, int len);
>> +extern void outsl(unsigned long addr, const void *buf, int len);
>> +extern void insb(unsigned long addr, void *buf, int len);
>> +extern void insw(unsigned long addr, void *buf, int len);
>> +extern void insl(unsigned long addr, void *buf, int len);
>> +#define outsb outsb
>> +#define outsw outsw
>> +#define outsl outsl
>> +#define insb insb
>> +#define insw insw
>> +#define insl insl
>
> You don't have inb/outb, so you shouldn't have these either.
Okay, will remove.
>
>> +/*
>> + * PCI is not enabled in nios2. Provide dummy implementation to get 'allyesconfig'
>> + * to build successfully.
>> + */
>> +#define inb(addr) ({ 0; })
>> +#define inw(addr) ({ 0; })
>> +#define inl(addr) ({ 0; })
>> +#define outb(x, addr) do { } while (0)
>> +#define outw(x, addr) do { } while (0)
>> +#define outl(x, addr) do { } while (0)
>
> What fails if you take these out?
Seem good, will remove this as well.
>
>> +
>> +/* Use "Duff's Device" to unroll the loops. */
>> +#define __IO_OUT_LOOP(a, b, l) \
>> + do { \
>> + if (l > 0) { \
>> + int _n = (l + 7) / 8; \
>> + switch (l % 8) { \
>> + case 0: \
>> + do { \
>> + *a = *b++; \
>> + case 7: \
>> + *a = *b++; \
>> + case 6: \
>> + *a = *b++; \
>> + case 5: \
>> + *a = *b++; \
>> + case 4: \
>> + *a = *b++; \
>> + case 3: \
>> + *a = *b++; \
>> + case 2: \
>> + *a = *b++; \
>> + case 1: \
>> + *a = *b++; \
>> + } while (--_n > 0); \
>> + } \
>> + } \
>> + } while (0)
>> +
>> +#define __IO_IN_LOOP(a, b, l) \
>> + do { \
>> + if (l > 0) { \
>> + int _n = (l + 7) / 8; \
>> + switch (l % 8) { \
>> + case 0: \
>> + do { \
>> + *b++ = *a; \
>> + case 7: \
>> + *b++ = *a; \
>> + case 6: \
>> + *b++ = *a; \
>> + case 5: \
>> + *b++ = *a; \
>> + case 4: \
>> + *b++ = *a; \
>> + case 3: \
>> + *b++ = *a; \
>> + case 2: \
>> + *b++ = *a; \
>> + case 1: \
>> + *b++ = *a; \
>> + } while (--_n > 0); \
>> + } \
>> + } \
>> + } while (0)
>> +
>> +#else /* __IO_USE_DUFFS */
>> +
>> +/* Use simple loops. */
>> +#define __IO_OUT_LOOP(a, b, l) \
>> + do { \
>> + while (l--) \
>> + *a = *b++; \
>> + } while (0)
>> +
>> +#define __IO_IN_LOOP(a, b, l) \
>> + do { \
>> + while (l--) \
>> + *b++ = *a; \
>> + } while (0)
>> +
>> +#endif /* __IO_USE_DUFFS */
>> +
>> +void outsb(unsigned long addr, const void *buf, int len)
>> +{
>> + volatile unsigned char *ap = (volatile unsigned char *)addr;
>> + unsigned char *bp = (unsigned char *)buf;
>> + __IO_OUT_LOOP(ap, bp, len);
>> +}
>> +EXPORT_SYMBOL(outsb);
>> +
>> +void outsw(unsigned long addr, const void *buf, int len)
>> +{
>> + volatile unsigned short *ap = (volatile unsigned short *)addr;
>> + unsigned short *bp = (unsigned short *)buf;
>> + __IO_OUT_LOOP(ap, bp, len);
>> +}
>> +EXPORT_SYMBOL(outsw);
>
> This implementation makes no sense, so definitely remove them.
Okay.

Thanks.

Regards
Ley Foon
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/