Commit 92a643ee authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Hans Verkuil
Browse files

media: atomisp: Replace COMPILATION_ERROR_IF() by static_assert()

parent 143fd8fe
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@
#ifndef _IA_CSS_CIRCBUF_COMM_H
#define _IA_CSS_CIRCBUF_COMM_H

#include <linux/build_bug.h>

#include <type_support.h>  /* uint8_t, uint32_t */

#define IA_CSS_CIRCBUF_PADDING 1 /* The circular buffer is implemented in lock-less manner, wherein
@@ -45,6 +47,8 @@ struct ia_css_circbuf_desc_s {
#define SIZE_OF_IA_CSS_CIRCBUF_DESC_S_STRUCT				\
	(4 * sizeof(uint8_t))

static_assert(sizeof(struct ia_css_circbuf_desc_s) == SIZE_OF_IA_CSS_CIRCBUF_DESC_S_STRUCT);

/**
 * @brief Data structure for the circular buffer element.
 */
@@ -56,4 +60,6 @@ struct ia_css_circbuf_elem_s {
#define SIZE_OF_IA_CSS_CIRCBUF_ELEM_S_STRUCT				\
	(sizeof(uint32_t))

static_assert(sizeof(struct ia_css_circbuf_elem_s) == SIZE_OF_IA_CSS_CIRCBUF_ELEM_S_STRUCT);

#endif /*_IA_CSS_CIRCBUF_COMM_H*/
+0 −23
Original line number Diff line number Diff line
@@ -16,29 +16,6 @@
#ifndef __ASSERT_SUPPORT_H_INCLUDED__
#define __ASSERT_SUPPORT_H_INCLUDED__

/**
 * The following macro can help to test the size of a struct at compile
 * time rather than at run-time. It does not work for all compilers; see
 * below.
 *
 * Depending on the value of 'condition', the following macro is expanded to:
 * - condition==true:
 *     an expression containing an array declaration with negative size,
 *     usually resulting in a compilation error
 * - condition==false:
 *     (void) 1; // C statement with no effect
 *
 * example:
 *  COMPILATION_ERROR_IF( sizeof(struct host_sp_queues) != SIZE_OF_HOST_SP_QUEUES_STRUCT);
 *
 * verify that the macro indeed triggers a compilation error with your compiler:
 *  COMPILATION_ERROR_IF( sizeof(struct host_sp_queues) != (sizeof(struct host_sp_queues)+1) );
 *
 * Not all compilers will trigger an error with this macro; use a search engine to search for
 * BUILD_BUG_ON to find other methods.
 */
#define COMPILATION_ERROR_IF(condition) ((void)sizeof(char[1 - 2 * !!(condition)]))

/* Compile time assertion */
#ifndef CT_ASSERT
#define CT_ASSERT(cnd) ((void)sizeof(char[(cnd) ? 1 :  -1]))
+3 −2
Original line number Diff line number Diff line
@@ -33,9 +33,10 @@

#define CHAR_BIT (8)

#include <linux/types.h>
#include <linux/limits.h>
#include <linux/errno.h>
#include <linux/limits.h>
#include <linux/types.h>

#define HOST_ADDRESS(x) (unsigned long)(x)

#endif /* __TYPE_SUPPORT_H_INCLUDED__ */
+4 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
 * This file contains types used for 3A statistics
 */

#include <linux/build_bug.h>

#include <math_support.h>
#include <type_support.h>
#include "ia_css_types.h"
@@ -80,6 +82,8 @@ struct ia_css_isp_3a_statistics {
	 SIZE_OF_IA_CSS_PTR +						\
	 4 * sizeof(uint32_t))

static_assert(sizeof(struct ia_css_isp_3a_statistics) == SIZE_OF_IA_CSS_ISP_3A_STATISTICS_STRUCT);

/* Map with host-side pointers to ISP-format statistics.
 * These pointers can either be copies of ISP data or memory mapped
 * ISP pointers.
+4 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@
 * This file contains types for DVS statistics
 */

#include <linux/build_bug.h>

#include <type_support.h>
#include "ia_css_types.h"
#include "ia_css_err.h"
@@ -55,6 +57,8 @@ struct ia_css_isp_skc_dvs_statistics;
	((3 * SIZE_OF_IA_CSS_PTR) +					\
	 (4 * sizeof(uint32_t)))

static_assert(sizeof(struct ia_css_isp_dvs_statistics) == SIZE_OF_IA_CSS_ISP_DVS_STATISTICS_STRUCT);

/* Map with host-side pointers to ISP-format statistics.
 * These pointers can either be copies of ISP data or memory mapped
 * ISP pointers.
Loading