Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Replace COMPILATION_ERROR_IF() by static_assert().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20240424184421.1737776-3-andriy.shevchenko@linux.intel.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

authored by

Andy Shevchenko and committed by
Hans Verkuil
92a643ee 143fd8fe

+40 -65
+6
drivers/staging/media/atomisp/pci/base/circbuf/interface/ia_css_circbuf_comm.h
··· 16 16 #ifndef _IA_CSS_CIRCBUF_COMM_H 17 17 #define _IA_CSS_CIRCBUF_COMM_H 18 18 19 + #include <linux/build_bug.h> 20 + 19 21 #include <type_support.h> /* uint8_t, uint32_t */ 20 22 21 23 #define IA_CSS_CIRCBUF_PADDING 1 /* The circular buffer is implemented in lock-less manner, wherein ··· 47 45 #define SIZE_OF_IA_CSS_CIRCBUF_DESC_S_STRUCT \ 48 46 (4 * sizeof(uint8_t)) 49 47 48 + static_assert(sizeof(struct ia_css_circbuf_desc_s) == SIZE_OF_IA_CSS_CIRCBUF_DESC_S_STRUCT); 49 + 50 50 /** 51 51 * @brief Data structure for the circular buffer element. 52 52 */ ··· 59 55 60 56 #define SIZE_OF_IA_CSS_CIRCBUF_ELEM_S_STRUCT \ 61 57 (sizeof(uint32_t)) 58 + 59 + static_assert(sizeof(struct ia_css_circbuf_elem_s) == SIZE_OF_IA_CSS_CIRCBUF_ELEM_S_STRUCT); 62 60 63 61 #endif /*_IA_CSS_CIRCBUF_COMM_H*/
-23
drivers/staging/media/atomisp/pci/hive_isp_css_include/assert_support.h
··· 16 16 #ifndef __ASSERT_SUPPORT_H_INCLUDED__ 17 17 #define __ASSERT_SUPPORT_H_INCLUDED__ 18 18 19 - /** 20 - * The following macro can help to test the size of a struct at compile 21 - * time rather than at run-time. It does not work for all compilers; see 22 - * below. 23 - * 24 - * Depending on the value of 'condition', the following macro is expanded to: 25 - * - condition==true: 26 - * an expression containing an array declaration with negative size, 27 - * usually resulting in a compilation error 28 - * - condition==false: 29 - * (void) 1; // C statement with no effect 30 - * 31 - * example: 32 - * COMPILATION_ERROR_IF( sizeof(struct host_sp_queues) != SIZE_OF_HOST_SP_QUEUES_STRUCT); 33 - * 34 - * verify that the macro indeed triggers a compilation error with your compiler: 35 - * COMPILATION_ERROR_IF( sizeof(struct host_sp_queues) != (sizeof(struct host_sp_queues)+1) ); 36 - * 37 - * Not all compilers will trigger an error with this macro; use a search engine to search for 38 - * BUILD_BUG_ON to find other methods. 39 - */ 40 - #define COMPILATION_ERROR_IF(condition) ((void)sizeof(char[1 - 2 * !!(condition)])) 41 - 42 19 /* Compile time assertion */ 43 20 #ifndef CT_ASSERT 44 21 #define CT_ASSERT(cnd) ((void)sizeof(char[(cnd) ? 1 : -1]))
+3 -2
drivers/staging/media/atomisp/pci/hive_isp_css_include/type_support.h
··· 33 33 34 34 #define CHAR_BIT (8) 35 35 36 - #include <linux/types.h> 37 - #include <linux/limits.h> 38 36 #include <linux/errno.h> 37 + #include <linux/limits.h> 38 + #include <linux/types.h> 39 + 39 40 #define HOST_ADDRESS(x) (unsigned long)(x) 40 41 41 42 #endif /* __TYPE_SUPPORT_H_INCLUDED__ */
+4
drivers/staging/media/atomisp/pci/ia_css_3a.h
··· 20 20 * This file contains types used for 3A statistics 21 21 */ 22 22 23 + #include <linux/build_bug.h> 24 + 23 25 #include <math_support.h> 24 26 #include <type_support.h> 25 27 #include "ia_css_types.h" ··· 81 79 sizeof(uint32_t) + \ 82 80 SIZE_OF_IA_CSS_PTR + \ 83 81 4 * sizeof(uint32_t)) 82 + 83 + static_assert(sizeof(struct ia_css_isp_3a_statistics) == SIZE_OF_IA_CSS_ISP_3A_STATISTICS_STRUCT); 84 84 85 85 /* Map with host-side pointers to ISP-format statistics. 86 86 * These pointers can either be copies of ISP data or memory mapped
+4
drivers/staging/media/atomisp/pci/ia_css_dvs.h
··· 20 20 * This file contains types for DVS statistics 21 21 */ 22 22 23 + #include <linux/build_bug.h> 24 + 23 25 #include <type_support.h> 24 26 #include "ia_css_types.h" 25 27 #include "ia_css_err.h" ··· 56 54 #define SIZE_OF_IA_CSS_ISP_DVS_STATISTICS_STRUCT \ 57 55 ((3 * SIZE_OF_IA_CSS_PTR) + \ 58 56 (4 * sizeof(uint32_t))) 57 + 58 + static_assert(sizeof(struct ia_css_isp_dvs_statistics) == SIZE_OF_IA_CSS_ISP_DVS_STATISTICS_STRUCT); 59 59 60 60 /* Map with host-side pointers to ISP-format statistics. 61 61 * These pointers can either be copies of ISP data or memory mapped
+4
drivers/staging/media/atomisp/pci/ia_css_metadata.h
··· 20 20 * This file contains structure for processing sensor metadata. 21 21 */ 22 22 23 + #include <linux/build_bug.h> 24 + 23 25 #include <type_support.h> 24 26 #include "ia_css_types.h" 25 27 #include "ia_css_stream_format.h" ··· 51 49 }; 52 50 53 51 #define SIZE_OF_IA_CSS_METADATA_STRUCT sizeof(struct ia_css_metadata) 52 + 53 + static_assert(sizeof(struct ia_css_metadata) == SIZE_OF_IA_CSS_METADATA_STRUCT); 54 54 55 55 /* @brief Allocate a metadata buffer. 56 56 * @param[in] metadata_info Metadata info struct, contains details on metadata buffers.
+2
drivers/staging/media/atomisp/pci/ia_css_types.h
··· 84 84 /* Virtual address within the CSS address space. */ 85 85 typedef u32 ia_css_ptr; 86 86 87 + #define SIZE_OF_IA_CSS_PTR sizeof(uint32_t) 88 + 87 89 /* Generic resolution structure. 88 90 */ 89 91 struct ia_css_resolution {
+4
drivers/staging/media/atomisp/pci/runtime/spctrl/interface/ia_css_spctrl_comm.h
··· 16 16 #ifndef __IA_CSS_SPCTRL_COMM_H__ 17 17 #define __IA_CSS_SPCTRL_COMM_H__ 18 18 19 + #include <linux/build_bug.h> 20 + 19 21 #include <type_support.h> 20 22 21 23 /* state of SP */ ··· 44 42 (1 * SIZE_OF_IA_CSS_PTR) + \ 45 43 (4 * sizeof(uint32_t)) + \ 46 44 (1 * sizeof(sp_ID_t)) 45 + 46 + static_assert(sizeof(struct ia_css_sp_init_dmem_cfg) == SIZE_OF_IA_CSS_SP_INIT_DMEM_CFG_STRUCT); 47 47 48 48 #endif /* __IA_CSS_SPCTRL_COMM_H__ */
-38
drivers/staging/media/atomisp/pci/sh_css.c
··· 1345 1345 { 1346 1346 int err; 1347 1347 ia_css_spctrl_cfg spctrl_cfg; 1348 - 1349 1348 void (*flush_func)(struct ia_css_acc_fw *fw); 1350 1349 hrt_data select, enable; 1351 - 1352 - /* 1353 - * The C99 standard does not specify the exact object representation of structs; 1354 - * the representation is compiler dependent. 1355 - * 1356 - * The structs that are communicated between host and SP/ISP should have the 1357 - * exact same object representation. The compiler that is used to compile the 1358 - * firmware is hivecc. 1359 - * 1360 - * To check if a different compiler, used to compile a host application, uses 1361 - * another object representation, macros are defined specifying the size of 1362 - * the structs as expected by the firmware. 1363 - * 1364 - * A host application shall verify that a sizeof( ) of the struct is equal to 1365 - * the SIZE_OF_XXX macro of the corresponding struct. If they are not 1366 - * equal, functionality will break. 1367 - */ 1368 - 1369 - /* Check struct sh_css_ddr_address_map */ 1370 - COMPILATION_ERROR_IF(sizeof(struct sh_css_ddr_address_map) != SIZE_OF_SH_CSS_DDR_ADDRESS_MAP_STRUCT); 1371 - /* Check struct host_sp_queues */ 1372 - COMPILATION_ERROR_IF(sizeof(struct host_sp_queues) != SIZE_OF_HOST_SP_QUEUES_STRUCT); 1373 - COMPILATION_ERROR_IF(sizeof(struct ia_css_circbuf_desc_s) != SIZE_OF_IA_CSS_CIRCBUF_DESC_S_STRUCT); 1374 - COMPILATION_ERROR_IF(sizeof(struct ia_css_circbuf_elem_s) != SIZE_OF_IA_CSS_CIRCBUF_ELEM_S_STRUCT); 1375 - 1376 - /* Check struct host_sp_communication */ 1377 - COMPILATION_ERROR_IF(sizeof(struct host_sp_communication) != SIZE_OF_HOST_SP_COMMUNICATION_STRUCT); 1378 - COMPILATION_ERROR_IF(sizeof(struct sh_css_event_irq_mask) != SIZE_OF_SH_CSS_EVENT_IRQ_MASK_STRUCT); 1379 - 1380 - /* Check struct sh_css_hmm_buffer */ 1381 - COMPILATION_ERROR_IF(sizeof(struct sh_css_hmm_buffer) != SIZE_OF_SH_CSS_HMM_BUFFER_STRUCT); 1382 - COMPILATION_ERROR_IF(sizeof(struct ia_css_isp_3a_statistics) != SIZE_OF_IA_CSS_ISP_3A_STATISTICS_STRUCT); 1383 - COMPILATION_ERROR_IF(sizeof(struct ia_css_isp_dvs_statistics) != SIZE_OF_IA_CSS_ISP_DVS_STATISTICS_STRUCT); 1384 - COMPILATION_ERROR_IF(sizeof(struct ia_css_metadata) != SIZE_OF_IA_CSS_METADATA_STRUCT); 1385 - 1386 - /* Check struct ia_css_init_dmem_cfg */ 1387 - COMPILATION_ERROR_IF(sizeof(struct ia_css_sp_init_dmem_cfg) != SIZE_OF_IA_CSS_SP_INIT_DMEM_CFG_STRUCT); 1388 1350 1389 1351 if (!env) 1390 1352 return -EINVAL;
+13 -2
drivers/staging/media/atomisp/pci/sh_css_internal.h
··· 16 16 #ifndef _SH_CSS_INTERNAL_H_ 17 17 #define _SH_CSS_INTERNAL_H_ 18 18 19 + #include <linux/build_bug.h> 20 + #include <linux/stdarg.h> 21 + 19 22 #include <system_global.h> 20 23 #include <math_support.h> 21 24 #include <type_support.h> 22 25 #include <platform_support.h> 23 - #include <linux/stdarg.h> 24 26 25 27 #include "input_formatter.h" 26 28 #include "input_system.h" ··· 106 104 */ 107 105 #define CALC_ALIGNMENT_MEMBER(x, y) (CEIL_MUL(x, y) - x) 108 106 #define SIZE_OF_HRT_VADDRESS sizeof(hive_uint32) 109 - #define SIZE_OF_IA_CSS_PTR sizeof(uint32_t) 110 107 111 108 /* Number of SP's */ 112 109 #define NUM_OF_SPS 1 ··· 202 201 (SIZE_OF_HRT_VADDRESS + \ 203 202 (SH_CSS_MAX_STAGES * IA_CSS_NUM_MEMORIES * SIZE_OF_HRT_VADDRESS) + \ 204 203 (16 * SIZE_OF_HRT_VADDRESS)) 204 + 205 + static_assert(sizeof(struct sh_css_ddr_address_map) == SIZE_OF_SH_CSS_DDR_ADDRESS_MAP_STRUCT); 205 206 206 207 /* xmem address map allocation per pipeline */ 207 208 struct sh_css_ddr_address_map_size { ··· 708 705 SIZE_OF_IA_CSS_CLOCK_TICK_STRUCT + \ 709 706 CALC_ALIGNMENT_MEMBER(SIZE_OF_IA_CSS_CLOCK_TICK_STRUCT, 8)) 710 707 708 + static_assert(sizeof(struct sh_css_hmm_buffer) == SIZE_OF_SH_CSS_HMM_BUFFER_STRUCT); 709 + 711 710 enum sh_css_queue_type { 712 711 sh_css_invalid_queue_type = -1, 713 712 sh_css_host2sp_buffer_queue, ··· 728 723 729 724 #define SIZE_OF_SH_CSS_EVENT_IRQ_MASK_STRUCT \ 730 725 (2 * sizeof(uint16_t)) 726 + 727 + static_assert(sizeof(struct sh_css_event_irq_mask) == SIZE_OF_SH_CSS_EVENT_IRQ_MASK_STRUCT); 731 728 732 729 struct host_sp_communication { 733 730 /* ··· 767 760 (N_CSI_PORTS * NUM_MIPI_FRAMES_PER_STREAM * SIZE_OF_HRT_VADDRESS * 2) + \ 768 761 ((3 + N_CSI_PORTS) * sizeof(uint32_t)) + \ 769 762 (NR_OF_PIPELINES * SIZE_OF_SH_CSS_EVENT_IRQ_MASK_STRUCT)) 763 + 764 + static_assert(sizeof(struct host_sp_communication) == SIZE_OF_HOST_SP_COMMUNICATION_STRUCT); 770 765 771 766 struct host_sp_queues { 772 767 /* ··· 839 830 840 831 #define SIZE_OF_HOST_SP_QUEUES_STRUCT \ 841 832 (SIZE_OF_QUEUES_ELEMS + SIZE_OF_QUEUES_DESC) 833 + 834 + static_assert(sizeof(struct host_sp_queues) == SIZE_OF_HOST_SP_QUEUES_STRUCT); 842 835 843 836 extern int __printf(1, 0) (*sh_css_printf)(const char *fmt, va_list args); 844 837