Commit 2e82f054 authored by Brent Pappas's avatar Brent Pappas Committed by Mauro Carvalho Chehab

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.comSigned-off-by: default avatarBrent Pappas <bpappas@pappasbrent.com>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent b3118a94
...@@ -98,17 +98,27 @@ ...@@ -98,17 +98,27 @@
#include "sh_css_frac.h" #include "sh_css_frac.h"
#include "ia_css_bufq.h" #include "ia_css_bufq.h"
#define FPNTBL_BYTES(binary) \ static size_t fpntbl_bytes(const struct ia_css_binary *binary)
(sizeof(char) * (binary)->in_frame_info.res.height * \ {
(binary)->in_frame_info.padded_width) return array3_size(sizeof(char),
binary->in_frame_info.res.height,
binary->in_frame_info.padded_width);
}
#define SCTBL_BYTES(binary) \ static size_t sctbl_bytes(const struct ia_css_binary *binary)
(sizeof(unsigned short) * (binary)->sctbl_height * \ {
(binary)->sctbl_aligned_width_per_color * IA_CSS_SC_NUM_COLORS) 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) \ static size_t morph_plane_bytes(const struct ia_css_binary *binary)
(SH_CSS_MORPH_TABLE_ELEM_BYTES * (binary)->morph_tbl_aligned_width * \ {
(binary)->morph_tbl_height) 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. /* We keep a second copy of the ptr struct for the SP to access.
Again, this would not be necessary on the chip. */ Again, this would not be necessary on the chip. */
...@@ -3279,7 +3289,7 @@ sh_css_params_write_to_ddr_internal( ...@@ -3279,7 +3289,7 @@ sh_css_params_write_to_ddr_internal(
if (binary->info->sp.enable.fpnr) { if (binary->info->sp.enable.fpnr) {
buff_realloced = reallocate_buffer(&ddr_map->fpn_tbl, buff_realloced = reallocate_buffer(&ddr_map->fpn_tbl,
&ddr_map_size->fpn_tbl, &ddr_map_size->fpn_tbl,
(size_t)(FPNTBL_BYTES(binary)), fpntbl_bytes(binary),
params->config_changed[IA_CSS_FPN_ID], params->config_changed[IA_CSS_FPN_ID],
&err); &err);
if (err) { if (err) {
...@@ -3304,7 +3314,7 @@ sh_css_params_write_to_ddr_internal( ...@@ -3304,7 +3314,7 @@ sh_css_params_write_to_ddr_internal(
buff_realloced = reallocate_buffer(&ddr_map->sc_tbl, buff_realloced = reallocate_buffer(&ddr_map->sc_tbl,
&ddr_map_size->sc_tbl, &ddr_map_size->sc_tbl,
SCTBL_BYTES(binary), sctbl_bytes(binary),
params->sc_table_changed, params->sc_table_changed,
&err); &err);
if (err) { if (err) {
...@@ -3538,8 +3548,7 @@ sh_css_params_write_to_ddr_internal( ...@@ -3538,8 +3548,7 @@ sh_css_params_write_to_ddr_internal(
buff_realloced |= buff_realloced |=
reallocate_buffer(virt_addr_tetra_x[i], reallocate_buffer(virt_addr_tetra_x[i],
virt_size_tetra_x[i], virt_size_tetra_x[i],
(size_t) morph_plane_bytes(binary),
(MORPH_PLANE_BYTES(binary)),
params->morph_table_changed, params->morph_table_changed,
&err); &err);
if (err) { if (err) {
...@@ -3549,8 +3558,7 @@ sh_css_params_write_to_ddr_internal( ...@@ -3549,8 +3558,7 @@ sh_css_params_write_to_ddr_internal(
buff_realloced |= buff_realloced |=
reallocate_buffer(virt_addr_tetra_y[i], reallocate_buffer(virt_addr_tetra_y[i],
virt_size_tetra_y[i], virt_size_tetra_y[i],
(size_t) morph_plane_bytes(binary),
(MORPH_PLANE_BYTES(binary)),
params->morph_table_changed, params->morph_table_changed,
&err); &err);
if (err) { if (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment