#ifndef _PKEYS_HELPER_H #define _PKEYS_HELPER_H #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #define NR_PKEYS 16 #define PKRU_BITS_PER_PKEY 2 #ifndef DEBUG_LEVEL #define DEBUG_LEVEL 0 #endif #define DPRINT_IN_SIGNAL_BUF_SIZE 4096 extern int dprint_in_signal; extern char dprint_in_signal_buffer[DPRINT_IN_SIGNAL_BUF_SIZE]; static inline void sigsafe_printf(const char *format, ...) { va_list ap; va_start(ap, format); if (!dprint_in_signal) { vprintf(format, ap); } else { int len = vsnprintf(dprint_in_signal_buffer, DPRINT_IN_SIGNAL_BUF_SIZE, format, ap); /* * len is amount that would have been printed, * but actual write is truncated at BUF_SIZE. */ if (len > DPRINT_IN_SIGNAL_BUF_SIZE) len = DPRINT_IN_SIGNAL_BUF_SIZE; write(1, dprint_in_signal_buffer, len); } va_end(ap); } #define dprintf_level(level, args...) do { \ if (level <= DEBUG_LEVEL) \ sigsafe_printf(args); \ fflush(NULL); \ } while (0) #define dprintf0(args...) dprintf_level(0, args) #define dprintf1(args...) dprintf_level(1, args) #define dprintf2(args...) dprintf_level(2, args) #define dprintf3(args...) dprintf_level(3, args) #define dprintf4(args...) dprintf_level(4, args) extern unsigned int shadow_pkru; static inline unsigned int __rdpkru(void) { unsigned int eax, edx; unsigned int ecx = 0; unsigned int pkru; asm volatile(".byte 0x0f,0x01,0xee\n\t" : "=a" (eax), "=d" (edx) : "c" (ecx)); pkru = eax; return pkru; } static inline unsigned int _rdpkru(int line) { unsigned int pkru = __rdpkru(); dprintf4("rdpkru(line=%d) pkru: %x shadow: %x\n", line, pkru, shadow_pkru); assert(pkru == shadow_pkru); return pkru; } #define rdpkru() _rdpkru(__LINE__) static inline void __wrpkru(unsigned int pkru) { unsigned int eax = pkru; unsigned int ecx = 0; unsigned int edx = 0; dprintf4("%s() changing %08x to %08x\n", __func__, __rdpkru(), pkru); asm volatile(".byte 0x0f,0x01,0xef\n\t" : : "a" (eax), "c" (ecx), "d" (edx)); assert(pkru == __rdpkru()); } static inline void wrpkru(unsigned int pkru) { dprintf4("%s() changing %08x to %08x\n", __func__, __rdpkru(), pkru); /* will do the shadow check for us: */ rdpkru(); __wrpkru(pkru); shadow_pkru = pkru; dprintf4("%s(%08x) pkru: %08x\n", __func__, pkru, __rdpkru()); } /* * These are technically racy. since something could * change PKRU between the read and the write. */ static inline void __pkey_access_allow(int pkey, int do_allow) { unsigned int pkru = rdpkru(); int bit = pkey * 2; if (do_allow) pkru &= (1<2017-01-29 15:07:34 +0300 committerDavid S. Miller <davem@davemloft.net>2017-01-30 22:05:43 -0500 commit1a0bee6c1e788218fd1d141db320db970aace7f0 (patch) tree46c4116bc8ef4a7df718516a648597d9e21c15f1 /sound/soc/mediatek parent63c190429020a9701b42887ac22c28f287f1762f (diff)
sh_eth: rename EESIPR bits
Since the commit b0ca2a21f769 ("sh_eth: Add support of SH7763 to sh_eth") the *enum* declaring the EESIPR bits (interrupt mask) went out of sync with the *enum* declaring the EESR bits (interrupt status) WRT bit naming and formatting. I'd like to restore the consistency by using EESIPR as the bit name prefix, renaming the *enum* to EESIPR_BIT, and (finally) renaming the bits according to the available Renesas SH77{34|63} manuals; additionally, reconstruct couple names using the EESR bit declaration above... Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'sound/soc/mediatek')