summaryrefslogtreecommitdiff
path: root/drivers/staging
diff options
context:
space:
mode:
authorBrent Pappas <bpappas@pappasbrent.com>2023-01-18 19:07:39 +0300
committerMauro Carvalho Chehab <mchehab@kernel.org>2023-02-08 10:24:35 +0300
commit2e82f054b58546efd062595dcfa448ee3d048273 (patch)
treee14bd035920f78fd3b355da127d75f418313efe2 /drivers/staging
parentb3118a942c820c8d94a11ffd3d950660b3566d35 (diff)
downloadlinux-2e82f054b58546efd062595dcfa448ee3d048273.tar.xz
media: atomisp: pci: Replace bytes macros with functions
Replace the function-like macros FPNTBL_BYTES(), SCTBL_BYTES(), and MORPH_PLANE_BYTES() with functions to comply with Linux coding style standards. Replace multiplication with calls to array_size() and array3_size() to prevent accidental arithmetic overflow. Link: https://lore.kernel.org/r/20230118160739.26059-1-bpappas@pappasbrent.com Signed-off-by: Brent Pappas <bpappas@pappasbrent.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/media/atomisp/pci/sh_css_params.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/drivers/staging/media/atomisp/pci/sh_css_params.c b/drivers/staging/media/atomisp/pci/sh_css_params.c
index f08564f58242..588f2adab058 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_params.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_params.c
@@ -98,17 +98,27 @@
#include "sh_css_frac.h"
#include "ia_css_bufq.h"
-#define FPNTBL_BYTES(binary) \
- (sizeof(char) * (binary)->in_frame_info.res.height * \
- (binary)->in_frame_info.padded_width)
+static size_t fpntbl_bytes(const struct ia_css_binary *binary)
+{
+ return array3_size(sizeof(char),
+ binary->in_frame_info.res.height,
+ binary->in_frame_info.padded_width);
+}
-#define SCTBL_BYTES(binary) \
- (sizeof(unsigned short) * (binary)->sctbl_height * \
- (binary)->sctbl_aligned_width_per_color * IA_CSS_SC_NUM_COLORS)
+static size_t sctbl_bytes(const struct ia_css_binary *binary)
+{
+ return size_mul(sizeof(unsigned short),
+ array3_size(binary->sctbl_height,
+ binary->sctbl_aligned_width_per_color,
+ IA_CSS_SC_NUM_COLORS));
+}
-#define MORPH_PLANE_BYTES(binary) \
- (SH_CSS_MORPH_TABLE_ELEM_BYTES * (binary)->morph_tbl_aligned_width * \
- (binary)->morph_tbl_height)
+static size_t morph_plane_bytes(const struct ia_css_binary *binary)
+{
+ return array3_size(SH_CSS_MORPH_TABLE_ELEM_BYTES,
+ binary->morph_tbl_aligned_width,
+ binary->morph_tbl_height);
+}
/* We keep a second copy of the ptr struct for the SP to access.
Again, this would not be necessary on the chip. */
@@ -3279,7 +3289,7 @@ sh_css_params_write_to_ddr_internal(
if (binary->info->sp.enable.fpnr) {
buff_realloced = reallocate_buffer(&ddr_map->fpn_tbl,
&ddr_map_size->fpn_tbl,
- (size_t)(FPNTBL_BYTES(binary)),
+ fpntbl_bytes(binary),
params->config_changed[IA_CSS_FPN_ID],
&err);
if (err) {
@@ -3304,7 +3314,7 @@ sh_css_params_write_to_ddr_internal(
buff_realloced = reallocate_buffer(&ddr_map->sc_tbl,
&ddr_map_size->sc_tbl,
- SCTBL_BYTES(binary),
+ sctbl_bytes(binary),
params->sc_table_changed,
&err);
if (err) {
@@ -3538,8 +3548,7 @@ sh_css_params_write_to_ddr_internal(
buff_realloced |=
reallocate_buffer(virt_addr_tetra_x[i],
virt_size_tetra_x[i],
- (size_t)
- (MORPH_PLANE_BYTES(binary)),
+ morph_plane_bytes(binary),
params->morph_table_changed,
&err);
if (err) {
@@ -3549,8 +3558,7 @@ sh_css_params_write_to_ddr_internal(
buff_realloced |=
reallocate_buffer(virt_addr_tetra_y[i],
virt_size_tetra_y[i],
- (size_t)
- (MORPH_PLANE_BYTES(binary)),
+ morph_plane_bytes(binary),
params->morph_table_changed,
&err);
if (err) {