From f7d42ed1c44a982c6a14ed5720650ad42a84b062 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Wed, 10 Jan 2024 14:45:19 +0000 Subject: [PATCH] media: i2c: Fix build for GCC 6/7 Building nv_ar0234 and nv_hawk_owl sensor drivers with GCC 6/7 fails with the following errors ... drivers/media/i2c/nv_ar0234.c:797:66: error: initialiser element is not constant .compound_ctrl_size = {sizeof(struct NvCamSyncSensorCalibData), alternating_exposure_cfg_size}, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/media/i2c/nv_hawk_owl.c:883:59: error: initialiser element is not constant .compound_ctrl_size = {sizeof(NvCamSyncSensorCalibData), alternating_exposure_cfg_size}, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ These older versions of GCC are not able to reconcile the size from the variable 'alternating_exposure_cfg_size' even though it is defined as const. Given that the variable 'alternating_exposure_cfg_size' is only used here, fix this by removing this variable and directly defining the size in the declaration of the 'compound_ctrl_size' parameter. Note that the minimum GCC compiler currently supported by the Linux kernel is v5.1. Bug 4448563 Change-Id: I4d3ac6eeb961a944901e73a1d92e753cae44220c Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3050272 (cherry picked from commit 8b3ebff940327f9e60f02135b2ebf359a6439992) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3051959 Reviewed-by: Laxman Dewangan GVS: Gerrit_Virtual_Submit --- drivers/media/i2c/nv_ar0234.c | 7 +++---- drivers/media/i2c/nv_hawk_owl.c | 6 ++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/media/i2c/nv_ar0234.c b/drivers/media/i2c/nv_ar0234.c index 13903bf3..8df3cc22 100644 --- a/drivers/media/i2c/nv_ar0234.c +++ b/drivers/media/i2c/nv_ar0234.c @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: GPL-2.0 -// Copyright (c) 2018-2023, NVIDIA CORPORATION & AFFILIATES. All Rights Reserved. +// SPDX-License-Identifier: GPL-2.0-only +// SPDX-FileCopyrightText: Copyright (c) 2018-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. /* * ar0234.c - ar0234 sensor driver */ @@ -62,7 +62,6 @@ static const u32 ctrl_cid_list[] = { TEGRA_CAMERA_CID_ALTERNATING_EXPOSURE, }; -const u16 alternating_exposure_cfg_size = sizeof(struct alternating_exposure_cfg); // Coefficients as per distortion model (wide FOV) being used struct fisheye_lens_distortion_coeff { @@ -792,7 +791,7 @@ static struct tegracam_ctrl_ops ar0234_ctrl_ops = { .numctrls = ARRAY_SIZE(ctrl_cid_list), .ctrl_cid_list = ctrl_cid_list, .string_ctrl_size = {AR0234_EEPROM_STR_SIZE}, - .compound_ctrl_size = {sizeof(struct NvCamSyncSensorCalibData), alternating_exposure_cfg_size}, + .compound_ctrl_size = {sizeof(struct NvCamSyncSensorCalibData), sizeof(struct alternating_exposure_cfg)}, .set_gain = ar0234_set_gain, .set_exposure = ar0234_set_exposure, .set_exposure_short = ar0234_set_exposure, diff --git a/drivers/media/i2c/nv_hawk_owl.c b/drivers/media/i2c/nv_hawk_owl.c index c015ab62..0f86d198 100644 --- a/drivers/media/i2c/nv_hawk_owl.c +++ b/drivers/media/i2c/nv_hawk_owl.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -// SPDX-FileCopyrightText: Copyright (c) 2022-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-FileCopyrightText: Copyright (c) 2022-2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. /* * nv_hawk_owl.c.c - ar0234 sensor driver */ @@ -65,8 +65,6 @@ static const u32 ctrl_cid_list[] = { TEGRA_CAMERA_CID_ALTERNATING_EXPOSURE, }; -const u16 alternating_exposure_cfg_size = sizeof(struct alternating_exposure_cfg); - // Coefficients as per distortion model (wide FOV) being used typedef struct { @@ -878,7 +876,7 @@ static struct tegracam_ctrl_ops ar0234_ctrl_ops = { .numctrls = ARRAY_SIZE(ctrl_cid_list), .ctrl_cid_list = ctrl_cid_list, .string_ctrl_size = {AR0234_EEPROM_STR_SIZE}, - .compound_ctrl_size = {sizeof(NvCamSyncSensorCalibData), alternating_exposure_cfg_size}, + .compound_ctrl_size = {sizeof(NvCamSyncSensorCalibData), sizeof(struct alternating_exposure_cfg)}, .set_gain = ar0234_set_gain, .set_exposure = ar0234_set_exposure, .set_exposure_short = ar0234_set_exposure,