On Sun 7 Jun 2009 17:21, [email protected] pondered:
>       Revision
>       6603 
> <http://blackfin.uclinux.org/gf/project/linux-kernel/scmsvn/?action=browse&path=/&view=rev&root=linux-kernel&revision=6603>
>  
>       Author
>       vapier <http://blackfin.uclinux.org/gf/user/vapier/> 
>       Date
>       2009-06-07 16:21:31 -0500 (Sun, 07 Jun 2009)
[snip]

> --- trunk/arch/blackfin/kernel/process.c      2009-06-07 19:11:50 UTC (rev 
> 6602)
> +++ trunk/arch/blackfin/kernel/process.c      2009-06-07 21:21:31 UTC (rev 
> 6603)
> @@ -321,6 +321,57 @@
>       }
>  }
>  
> +#define IN_MEM(addr, size, const_addr, const_size) \
> +({ \
> +     unsigned long __addr = (unsigned long)(addr); \
> +     (const_size && \
> +      __addr >= const_addr && \
> +      __addr + (size) <= const_addr + const_size); \
> +})
> +#define IN_ASYNC(bnum, bctlnum) \
> +({ \
> +     (bfin_read_EBIU_AMGCTL() & 0xe) < ((bnum + 1) << 1) ? -EFAULT : \
> +     bfin_read_EBIU_AMBCTL##bctlnum() & B##bnum##RDYEN ? -EFAULT : 0; \
> +})
> +int bfin_mem_access_type(unsigned long addr, unsigned long size)
> +{
> +     /* Check that things do not wrap around */
> +     if (addr > ULONG_MAX - size)
> +             return -EFAULT;
> +
> +     if (addr >= FIXED_CODE_START && (addr + size) <= physical_mem_end)
> +             return 0;
> +
> +     if (IN_MEM(addr, size, get_l1_code_start(), L1_CODE_LENGTH))
> +             return 1;
> +
> +     if (IN_MEM(addr, size, get_l1_scratch_start(), L1_SCRATCH_LENGTH))
> +             return 0;
> +     if (IN_MEM(addr, size, get_l1_data_a_start(), L1_DATA_A_LENGTH))
> +             return 0;
> +     if (IN_MEM(addr, size, get_l1_data_b_start(), L1_DATA_B_LENGTH))
> +             return 0;
> +     if (IN_MEM(addr, size, L2_START, L2_LENGTH))
> +             return 0;
> +
> +     if (addr >= SYSMMR_BASE)
> +             return 0;
> +
> +     /* We can't read EBIU banks that aren't enabled or we end up hanging
> +      * on the access to the async space.
> +      */
> +     if (IN_MEM(addr, size, ASYNC_BANK0_BASE, ASYNC_BANK0_SIZE))
> +             return IN_ASYNC(0, 0);
> +     if (IN_MEM(addr, size, ASYNC_BANK1_BASE, ASYNC_BANK1_SIZE))
> +             return IN_ASYNC(1, 0);
> +     if (IN_MEM(addr, size, ASYNC_BANK2_BASE, ASYNC_BANK2_SIZE))
> +             return IN_ASYNC(2, 1);
> +     if (IN_MEM(addr, size, ASYNC_BANK3_BASE, ASYNC_BANK3_SIZE))
> +             return IN_ASYNC(3, 1);
> +
> +     return -EFAULT;
> +}
> +

Rather than returning magic numbers (0, 1 or 2) - can we define some constants 
in the .h file, and use those?

_______________________________________________
Linux-kernel-commits mailing list
[email protected]
https://blackfin.uclinux.org/mailman/listinfo/linux-kernel-commits

Reply via email to