staging: media: atomisp: pci: Replace bytes macros with functions
Commit Message
Replace the function-like macros FPNTBL_BYTES, SCTBL_BYTES, and
MORPH_PLANE_BYTES with static inline functions to comply with Linux coding
style standards.
Signed-off-by: Brent Pappas <bpappas@pappasbrent.com>
---
.../staging/media/atomisp/pci/sh_css_params.c | 34 +++++++++++--------
1 file changed, 19 insertions(+), 15 deletions(-)
Comments
On Tue, Jan 17, 2023 at 10:08:41AM -0500, Brent Pappas wrote:
> Replace the function-like macros FPNTBL_BYTES, SCTBL_BYTES, and
> MORPH_PLANE_BYTES with static inline functions to comply with Linux coding
> style standards.
Thank you!
But I think what you need, besides dropping unneeded parentheses is to use some
macros from overflow.h.
On Tue, Jan 17, 2023 at 05:34:12PM +0200, Andy Shevchenko wrote:
> On Tue, Jan 17, 2023 at 10:08:41AM -0500, Brent Pappas wrote:
> > Replace the function-like macros FPNTBL_BYTES, SCTBL_BYTES, and
> > MORPH_PLANE_BYTES with static inline functions to comply with Linux coding
> > style standards.
>
> Thank you!
>
> But I think what you need, besides dropping unneeded parentheses, is to use some
> macros from overflow.h.
And drop "staging:" prefix from the patch since media maintainer uses (dumb)
script that adds "media:" if it doesn't lead the Subject.
@@ -98,17 +98,23 @@
#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 inline size_t fpntbl_bytes(const struct ia_css_binary *binary)
+{
+ return (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 inline size_t sctbl_bytes(const struct ia_css_binary *binary)
+{
+ return (sizeof(unsigned short) * 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 inline size_t morph_plane_bytes(const struct ia_css_binary *binary)
+{
+ return (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 +3285,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 +3310,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 +3544,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 +3554,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) {