diff mbox series

mm: fixmap: convert __set_fixmap_offset() to an inline function

Message ID 20191108124133.31751-1-yamada.masahiro@socionext.com
State New
Headers show
Series mm: fixmap: convert __set_fixmap_offset() to an inline function | expand

Commit Message

Masahiro Yamada Nov. 8, 2019, 12:41 p.m. UTC
I just stopped by the ugly variable name, ________addr.
(8 underscores!)

If this is just a matter of casting to (unsigned long), this variable
is unneeded since you can do like this:

({                                                                      \
        __set_fixmap(idx, phys, flags);                                 \
        (unsigned long)(fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1))); \
})

However, I'd rather like to change it to an inline function since it
is more readable, and the parameter types are clearer.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

---

 include/asm-generic/fixmap.h | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

-- 
2.17.1

Comments

Masahiro Yamada Nov. 12, 2019, 7:53 a.m. UTC | #1
Hi Andrew,

On Fri, Nov 8, 2019 at 9:42 PM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>

> I just stopped by the ugly variable name, ________addr.

> (8 underscores!)

>

> If this is just a matter of casting to (unsigned long), this variable

> is unneeded since you can do like this:

>

> ({                                                                      \

>         __set_fixmap(idx, phys, flags);                                 \

>         (unsigned long)(fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1))); \

> })

>

> However, I'd rather like to change it to an inline function since it

> is more readable, and the parameter types are clearer.

>

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>



Unfortunately, this patch broke building ppc, mips, etc.
(Not all arch implement __set_fixmap)

Could you drop it from your tree?

Thanks.


-- 
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h
index 8cc7b09c1bc7..de4c36912529 100644
--- a/include/asm-generic/fixmap.h
+++ b/include/asm-generic/fixmap.h
@@ -70,14 +70,14 @@  static inline unsigned long virt_to_fix(const unsigned long vaddr)
 	__set_fixmap(idx, 0, FIXMAP_PAGE_CLEAR)
 #endif
 
-/* Return a pointer with offset calculated */
-#define __set_fixmap_offset(idx, phys, flags)				\
-({									\
-	unsigned long ________addr;					\
-	__set_fixmap(idx, phys, flags);					\
-	________addr = fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1));	\
-	________addr;							\
-})
+/* Return a virtual address with offset calculated */
+static inline unsigned long __set_fixmap_offset(enum fixed_addresses idx,
+						phys_addr_t phys,
+						pgprot_t flags)
+{
+	__set_fixmap(idx, phys, flags);
+	return fix_to_virt(idx) + ((phys) & (PAGE_SIZE - 1));
+}
 
 #define set_fixmap_offset(idx, phys) \
 	__set_fixmap_offset(idx, phys, FIXMAP_PAGE_NORMAL)