linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: ti-vpe: cal: avoid FIELD_GET assertion
@ 2020-12-03 23:07 Arnd Bergmann
  2020-12-06 23:57 ` Laurent Pinchart
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2020-12-03 23:07 UTC (permalink / raw)
  To: Benoit Parrot, Mauro Carvalho Chehab
  Cc: Arnd Bergmann, Hans Verkuil, Laurent Pinchart, Sakari Ailus,
	linux-media, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

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.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/media/platform/ti-vpe/cal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/ti-vpe/cal.h b/drivers/media/platform/ti-vpe/cal.h
index 4123405ee0cf..20d07311d222 100644
--- a/drivers/media/platform/ti-vpe/cal.h
+++ b/drivers/media/platform/ti-vpe/cal.h
@@ -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));
 }
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] media: ti-vpe: cal: avoid FIELD_GET assertion
  2020-12-03 23:07 [PATCH] media: ti-vpe: cal: avoid FIELD_GET assertion Arnd Bergmann
@ 2020-12-06 23:57 ` Laurent Pinchart
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Pinchart @ 2020-12-06 23:57 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Benoit Parrot, Mauro Carvalho Chehab, Arnd Bergmann,
	Hans Verkuil, Sakari Ailus, linux-media, linux-kernel

Hi Arnd,

Thank you for the patch.

On Fri, Dec 04, 2020 at 12:07:30AM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> 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.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

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
?

> ---
>  drivers/media/platform/ti-vpe/cal.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/platform/ti-vpe/cal.h b/drivers/media/platform/ti-vpe/cal.h
> index 4123405ee0cf..20d07311d222 100644
> --- a/drivers/media/platform/ti-vpe/cal.h
> +++ b/drivers/media/platform/ti-vpe/cal.h
> @@ -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));
>  }

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-06 23:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 23:07 [PATCH] media: ti-vpe: cal: avoid FIELD_GET assertion Arnd Bergmann
2020-12-06 23:57 ` Laurent Pinchart

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).