media: ti-vpe: cal: avoid FIELD_GET assertion
PATCH 1/1 media: ti-vpe: cal: avoid FIELD_GET assertion
From: Arnd Bergmann <[email protected]>
FIELD_GET() must only be used with a mask that is a compile-time constant:
drivers/media/platform/ti-vpe/cal.h: In function 'cal_read_field':include/linux/compiler_types.h:320:38: error: call to '__compiletime_assert_247' declared with attribute error: FIELD_GET: mask is not constant include/linux/bitfield.h:46:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'
46 | BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \
| ^~~~~~~~~~~~~~~~
drivers/media/platform/ti-vpe/cal.h:220:9: note: in expansion of macro 'FIELD_GET'
220 | return FIELD_GET(mask, cal_read(cal, offset));
| ^~~~~~~~~The problem here is that the function is not always inlined. Mark it __always_inline to avoid the problem.
--- drivers/media/platform/ti-vpe/cal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/ti-vpe/cal.h +1 -1
@@ -215,7 +215,7 @@ static inline void cal_write(struct cal_dev *cal, u32 offset, u32 val)iowrite32 (val, cal->base + offset); } -static inline u32 cal_read_field (struct cal_dev *cal,u32 offset,u32 mask) +static __always_inline u32 cal_read_field(struct cal_dev *cal, u32 offset, u32 mask) {return FIELD_GET (mask,cal_read (cal, offset)); }
Signature · 1 line
2.27.0
Hi Arnd,
Thank you for the patch.
Quoted 14 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
FIELD_GET()must only be used with a mask that is a compile-time constant:
drivers/media/platform/ti-vpe/cal.h: In function 'cal_read_field':include/linux/compiler_types.h:320:38: error: call to '__compiletime_assert_247' declared with attribute error:FIELD_GET: mask is not constantinclude/linux/bitfield.h:46:3: note: in expansion of macro 'BUILD_BUG_ON_MSG'46 | BUILD_BUG_ON_MSG(!__builtin_constant_p(_mask), \ | ^~~~~~~~~~~~~~~~ drivers/media/platform/ti-vpe/cal.h:220:9: note: in expansion of macro 'FIELD_GET' 220 | return FIELD_GET(mask, cal_read(cal, offset)); | ^~~~~~~~~
Quoted 4 lines
The problem here is that the function is not always inlined. Mark it
__always_inlineto avoid the problem.Signed-off-by Arnd Bergmann <[email protected]>
This doesn't conflict with the series I've just sent for the CAL driver, and can thus be applied first or on top. Hans, can I let you handle this ?
Quoted 17 lines
--- drivers/media/platform/ti-vpe/cal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/media/platform/ti-vpe/cal.h +1
-1@@ -215,7 +215,7 @@ static inline void cal_write(struct cal_dev *cal, u32 offset, u32 val)iowrite32 (val, cal->base + offset); } -static inline u32 cal_read_field (struct cal_dev *cal,u32 offset,u32 mask) +static __always_inline u32 cal_read_field(struct cal_dev *cal, u32 offset, u32 mask) {return FIELD_GET (mask,cal_read (cal, offset)); }
Signature · 3 lines
Regards, Laurent Pinchart