diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-12-26 15:25:56 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2010-08-06 12:55:44 -0400 |
commit | f2521ce9ce84d1f10016a8fc91108ef9d3b14d2b (patch) | |
tree | 660d1eced596877b36c7b6a5e6971c0df94aadea /arch/blackfin/include/asm/def_LPBlackfin.h | |
parent | 222f6eb66eb966ac9f21c0224f53b98787529e10 (diff) | |
download | talos-obmc-linux-f2521ce9ce84d1f10016a8fc91108ef9d3b14d2b.tar.gz talos-obmc-linux-f2521ce9ce84d1f10016a8fc91108ef9d3b14d2b.zip |
Blackfin: new dynamic bfin read/write mmr helpers
These are useful when working with C structs of MMRs as the appropriate
size is selected based on the given argument.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin/include/asm/def_LPBlackfin.h')
-rw-r--r-- | arch/blackfin/include/asm/def_LPBlackfin.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/arch/blackfin/include/asm/def_LPBlackfin.h b/arch/blackfin/include/asm/def_LPBlackfin.h index f342ff0319df..4e562850021c 100644 --- a/arch/blackfin/include/asm/def_LPBlackfin.h +++ b/arch/blackfin/include/asm/def_LPBlackfin.h @@ -50,6 +50,23 @@ #define bfin_write16(addr, val) _bfin_writeX(addr, val, 16, w) #define bfin_write32(addr, val) _bfin_writeX(addr, val, 32, ) +#define bfin_read(addr) \ +({ \ + sizeof(*(addr)) == 1 ? bfin_read8(addr) : \ + sizeof(*(addr)) == 2 ? bfin_read16(addr) : \ + sizeof(*(addr)) == 4 ? bfin_read32(addr) : \ + ({ BUG(); 0; }); \ +}) +#define bfin_write(addr, val) \ +({ \ + switch (sizeof(*(addr))) { \ + case 1: bfin_write8(addr, val); break; \ + case 2: bfin_write16(addr, val); break; \ + case 4: bfin_write32(addr, val); break; \ + default: BUG(); \ + } \ +}) + #endif /* __ASSEMBLY__ */ /************************************************** |