Skip to content

Commit

Permalink
openrisc: Use asm-generic's version of fix_to_virt() & virt_to_fix()
Browse files Browse the repository at this point in the history
commit 7f1e2fc upstream.

Openrisc's implementation of fix_to_virt() & virt_to_fix() share same
functionality with ones of asm generic.

Plus, generic version of fix_to_virt() can trap invalid index at compile
time.

Thus, Replace the arch-specific implementations with asm generic's ones.

Signed-off-by: Dawei Li <[email protected]>
Signed-off-by: Stafford Horne <[email protected]>
Cc: Guenter Roeck <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Dawei Li authored and Avenger-285714 committed Dec 14, 2024
1 parent c5ab9e1 commit 0e597f1
Showing 1 changed file with 1 addition and 30 deletions.
31 changes: 1 addition & 30 deletions arch/openrisc/include/asm/fixmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,6 @@ enum fixed_addresses {
extern void __set_fixmap(enum fixed_addresses idx,
phys_addr_t phys, pgprot_t flags);

#define __fix_to_virt(x) (FIXADDR_TOP - ((x) << PAGE_SHIFT))
#define __virt_to_fix(x) ((FIXADDR_TOP - ((x)&PAGE_MASK)) >> PAGE_SHIFT)

/*
* 'index to address' translation. If anyone tries to use the idx
* directly without tranlation, we catch the bug with a NULL-deference
* kernel oops. Illegal ranges of incoming indices are caught too.
*/
static __always_inline unsigned long fix_to_virt(const unsigned int idx)
{
/*
* this branch gets completely eliminated after inlining,
* except when someone tries to use fixaddr indices in an
* illegal way. (such as mixing up address types or using
* out-of-range indices).
*
* If it doesn't get removed, the linker will complain
* loudly with a reasonably clear error message..
*/
if (idx >= __end_of_fixed_addresses)
BUG();

return __fix_to_virt(idx);
}

static inline unsigned long virt_to_fix(const unsigned long vaddr)
{
BUG_ON(vaddr >= FIXADDR_TOP || vaddr < FIXADDR_START);
return __virt_to_fix(vaddr);
}
#include <asm-generic/fixmap.h>

#endif

0 comments on commit 0e597f1

Please sign in to comment.