2024-02-26 19:41:14

by Jonathan Bergh

[permalink] [raw]
Subject: [PATCH 0/6] staging: media: atomisp: Fix various small code and code style formatting issues

These patches address a number of small code and code style formatting
including:
* removing unneeded braces from single line statements
* replace "unsigned *" with "unsigned int *"
* remove spurious whitespace and ensure trailing statements are included
on a newline following a conditional statement
* remove unneeded parentheses from conditional statement
* remove unneeded "return" statement from void function, and finally
* remove commented code and fix multiple block comments to meet the kernel
code style guidelines.

Jonathan Bergh (6):
staging: media: atomisp: Remove unnecessary braces from single line
conditional statements
staging: media: atomisp: Fixed "unsigned int *" rather than "unsigned
*" declaration in variable declaration
staging: media: atomisp: Ensure trailing statements are on a newline
and remove spurious whitespaces
staging: media: atomisp: Remove unnecessary parentheses from
conditional statement
staging: media: atomisp: Remove unneeded return statement from void
function
staging: media: atomisp: Remove old commented code and fix multiple
block comment style

drivers/staging/media/atomisp/pci/sh_css_sp.c | 109 +++++++++---------
1 file changed, 57 insertions(+), 52 deletions(-)

--
2.40.1



2024-02-26 19:41:39

by Jonathan Bergh

[permalink] [raw]
Subject: [PATCH 2/6] staging: media: atomisp: Fixed "unsigned int *" rather than "unsigned *" declaration in variable declaration

This code fixes a code style issue where:
* Checkpatch suggests using "unsigned int *" rather than a bare
"unsigned *" declaration in the code

Signed-off-by: Jonathan Bergh <[email protected]>
---
drivers/staging/media/atomisp/pci/sh_css_sp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c
index 23893189ba82..9c15b8a1a93e 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_sp.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c
@@ -187,7 +187,7 @@ sh_css_sp_get_debug_state(struct sh_css_sp_debug_state *state)

(void)HIVE_ADDR_sp_output; /* To get rid of warning in CRUN */
for (i = 0; i < sizeof(*state) / sizeof(int); i++)
- ((unsigned *)state)[i] = load_sp_array_uint(sp_output, i + offset);
+ ((unsigned int *)state)[i] = load_sp_array_uint(sp_output, i + offset);
}

#endif
--
2.40.1


2024-02-26 19:42:09

by Jonathan Bergh

[permalink] [raw]
Subject: [PATCH 1/6] staging: media: atomisp: Remove unnecessary braces from single line conditional statements

This patch does the following things:
* Tidies up code in several places where braces were used in conjunction
with single line conditional statements

Signed-off-by: Jonathan Bergh <[email protected]>
---
drivers/staging/media/atomisp/pci/sh_css_sp.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c
index cd7f5a3fecaa..23893189ba82 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_sp.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c
@@ -420,9 +420,8 @@ sh_css_copy_buffer_attr_to_spbuffer(struct ia_css_buffer_sp *dest_buf,
lines below. In order to satisfy KW an additional if
has been added. This one will always yield true.
*/
- if ((queue_id < SH_CSS_MAX_NUM_QUEUES)) {
+ if ((queue_id < SH_CSS_MAX_NUM_QUEUES))
dest_buf->buf_src.queue_id = queue_id;
- }
} else {
assert(xmem_addr != mmgr_EXCEPTION);
dest_buf->buf_src.xmem_addr = xmem_addr;
@@ -860,9 +859,8 @@ initialize_isp_states(const struct ia_css_binary *binary)

if (!binary->info->mem_offsets.offsets.state)
return;
- for (i = 0; i < IA_CSS_NUM_STATE_IDS; i++) {
+ for (i = 0; i < IA_CSS_NUM_STATE_IDS; i++)
ia_css_kernel_init_state[i](binary);
- }
}

static void
@@ -878,9 +876,8 @@ initialize_stage_frames(struct ia_css_frames_sp *frames)
unsigned int i;

initialize_frame_buffer_attribute(&frames->in.buf_attr);
- for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++) {
+ for (i = 0; i < IA_CSS_BINARY_MAX_OUTPUT_PORTS; i++)
initialize_frame_buffer_attribute(&frames->out[i].buf_attr);
- }
initialize_frame_buffer_attribute(&frames->out_vf.buf_attr);
initialize_frame_buffer_attribute(&frames->s3a_buf);
initialize_frame_buffer_attribute(&frames->dvs_buf);
@@ -1269,9 +1266,8 @@ sh_css_sp_init_pipeline(struct ia_css_pipeline *me,

pipe = find_pipe_by_num(pipe_num);
assert(pipe);
- if (!pipe) {
+ if (!pipe)
return;
- }
sh_css_sp_group.pipe[thread_id].scaler_pp_lut = sh_css_pipe_get_pp_gdc_lut(pipe);

if (md_info && md_info->size > 0) {
--
2.40.1


2024-02-26 19:42:26

by Jonathan Bergh

[permalink] [raw]
Subject: [PATCH 5/6] staging: media: atomisp: Remove unneeded return statement from void function

This patch makes the following change:
* Removes an unnecessary 'return' statement from a void function
implementation

Signed-off-by: Jonathan Bergh <[email protected]>
---
drivers/staging/media/atomisp/pci/sh_css_sp.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c
index 281cbbb89a14..3ccbfcc553fb 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_sp.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c
@@ -642,8 +642,6 @@ void sh_css_sp_set_if_configs(
*config_b;
sh_css_sp_group.config.input_formatter.b_changed = true;
}
-
- return;
}

void
--
2.40.1


2024-02-26 19:42:33

by Jonathan Bergh

[permalink] [raw]
Subject: [PATCH 3/6] staging: media: atomisp: Ensure trailing statements are on a newline and remove spurious whitespaces

This patch fixes the following minor code style issues:
* Ensure trailing statements are located on a newline
* Removes an instance of a spurious whitespace following a conditional
statement

Signed-off-by: Jonathan Bergh <[email protected]>
---
drivers/staging/media/atomisp/pci/sh_css_sp.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c
index 9c15b8a1a93e..aad0a40d08cb 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_sp.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c
@@ -732,7 +732,8 @@ sh_css_sp_write_frame_pointers(const struct sh_css_binary_args *args)

/* we don't pass this error back to the upper layer, so we add a assert here
because we actually hit the error here but it still works by accident... */
- if (err) assert(false);
+ if (err)
+ assert(false);
return err;
}

@@ -747,7 +748,8 @@ sh_css_sp_init_group(bool two_ppc,

sh_css_sp_group.config.no_isp_sync = (uint8_t)no_isp_sync;
/* decide whether the frame is processed online or offline */
- if (if_config_index == SH_CSS_IF_CONFIG_NOT_NEEDED) return;
+ if (if_config_index == SH_CSS_IF_CONFIG_NOT_NEEDED)
+ return;

if (!IS_ISP2401) {
assert(if_config_index < SH_CSS_MAX_IF_CONFIGS);
@@ -1266,7 +1268,7 @@ sh_css_sp_init_pipeline(struct ia_css_pipeline *me,

pipe = find_pipe_by_num(pipe_num);
assert(pipe);
- if (!pipe)
+ if (!pipe)
return;
sh_css_sp_group.pipe[thread_id].scaler_pp_lut = sh_css_pipe_get_pp_gdc_lut(pipe);

--
2.40.1


2024-02-26 19:43:00

by Jonathan Bergh

[permalink] [raw]
Subject: [PATCH 4/6] staging: media: atomisp: Remove unnecessary parentheses from conditional statement

This patch makes the following changes:
* Removes additional, unnecessary parentheses from a conditional "if"
statement

Signed-off-by: Jonathan Bergh <[email protected]>
---
drivers/staging/media/atomisp/pci/sh_css_sp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c
index aad0a40d08cb..281cbbb89a14 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_sp.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c
@@ -420,7 +420,7 @@ sh_css_copy_buffer_attr_to_spbuffer(struct ia_css_buffer_sp *dest_buf,
lines below. In order to satisfy KW an additional if
has been added. This one will always yield true.
*/
- if ((queue_id < SH_CSS_MAX_NUM_QUEUES))
+ if (queue_id < SH_CSS_MAX_NUM_QUEUES)
dest_buf->buf_src.queue_id = queue_id;
} else {
assert(xmem_addr != mmgr_EXCEPTION);
--
2.40.1


2024-02-26 19:43:08

by Jonathan Bergh

[permalink] [raw]
Subject: [PATCH 6/6] staging: media: atomisp: Remove old commented code and fix multiple block comment style

This patch fixes the following minor code and code style issues:
* Removes a block of commented out (unused) code from the src
* Reformats various multiline block comments to meet the kernel code
style guidelines for block comments

Signed-off-by: Jonathan Bergh <[email protected]>
---
drivers/staging/media/atomisp/pci/sh_css_sp.c | 87 ++++++++++---------
1 file changed, 48 insertions(+), 39 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css_sp.c b/drivers/staging/media/atomisp/pci/sh_css_sp.c
index 3ccbfcc553fb..2999d44d61d1 100644
--- a/drivers/staging/media/atomisp/pci/sh_css_sp.c
+++ b/drivers/staging/media/atomisp/pci/sh_css_sp.c
@@ -108,11 +108,6 @@ copy_isp_stage_to_sp_stage(void)
sh_css_isp_stage.binary_info.iterator.row_stripes_overlap_lines;
sh_css_sp_stage.top_cropping = (uint16_t)
sh_css_isp_stage.binary_info.pipeline.top_cropping;
- /* moved to sh_css_sp_init_stage
- sh_css_sp_stage.enable.vf_output =
- sh_css_isp_stage.binary_info.enable.vf_veceven ||
- sh_css_isp_stage.binary_info.num_output_pins > 1;
- */
sh_css_sp_stage.enable.sdis = sh_css_isp_stage.binary_info.enable.dis;
sh_css_sp_stage.enable.s3a = sh_css_isp_stage.binary_info.enable.s3a;
}
@@ -411,14 +406,15 @@ sh_css_copy_buffer_attr_to_spbuffer(struct ia_css_buffer_sp *dest_buf,
*/
assert(queue_id < SH_CSS_MAX_NUM_QUEUES);

- /* Klocwork assumes assert can be disabled;
- Since we can get there with any type, and it does not
- know that frame_in->dynamic_data_index can only be set
- for one of the types in the assert) it has to assume we
- can get here for any type. however this could lead to an
- out of bounds reference when indexing buf_type about 10
- lines below. In order to satisfy KW an additional if
- has been added. This one will always yield true.
+ /*
+ * Klocwork assumes assert can be disabled;
+ * Since we can get there with any type, and it does not
+ * know that frame_in->dynamic_data_index can only be set
+ * for one of the types in the assert) it has to assume we
+ * can get here for any type. however this could lead to an
+ * out of bounds reference when indexing buf_type about 10
+ * lines below. In order to satisfy KW an additional if
+ * has been added. This one will always yield true.
*/
if (queue_id < SH_CSS_MAX_NUM_QUEUES)
dest_buf->buf_src.queue_id = queue_id;
@@ -514,7 +510,8 @@ sh_css_copy_frame_to_spframe(struct ia_css_frame_sp *sp_frame_out,
frame_in->planes.binary.data.offset;
break;
default:
- /* This should not happen, but in case it does,
+ /*
+ * This should not happen, but in case it does,
* nullify the planes
*/
memset(&sp_frame_out->planes, 0, sizeof(sp_frame_out->planes));
@@ -949,9 +946,10 @@ sh_css_sp_init_stage(struct ia_css_binary *binary,
sh_css_sp_stage.isp_copy_output = (uint8_t)args->copy_output;
sh_css_sp_stage.enable.vf_output = (args->out_vf_frame != NULL);

- /* Copy the frame infos first, to be overwritten by the frames,
- if these are present.
- */
+ /*
+ * Copy the frame infos first, to be overwritten by the frames,
+ * if these are present.
+ */
sh_css_sp_stage.frames.effective_in_res.width = binary->effective_in_frame_res.width;
sh_css_sp_stage.frames.effective_in_res.height = binary->effective_in_frame_res.height;

@@ -1028,10 +1026,12 @@ sh_css_sp_init_stage(struct ia_css_binary *binary,

initialize_isp_states(binary);

- /* we do this only for preview pipe because in fill_binary_info function
+ /*
+ * We do this only for preview pipe because in fill_binary_info function
* we assign vf_out res to out res, but for ISP internal processing, we need
* the original out res. for video pipe, it has two output pins --- out and
- * vf_out, so it can keep these two resolutions already. */
+ * vf_out, so it can keep these two resolutions already.
+ */
if (binary->info->sp.pipeline.mode == IA_CSS_BINARY_MODE_PREVIEW &&
(binary->vf_downscale_log2 > 0)) {
/* TODO: Remove this after preview output decimation is fixed
@@ -1067,20 +1067,22 @@ sp_init_stage(struct ia_css_pipeline_stage *stage,
*/
const char *binary_name = "";
const struct ia_css_binary_xinfo *info = NULL;
- /* note: the var below is made static as it is quite large;
- if it is not static it ends up on the stack which could
- cause issues for drivers
- */
+ /*
+ * Note: the var below is made static as it is quite large;
+ * if it is not static it ends up on the stack which could
+ * cause issues for drivers
+ */
static struct ia_css_binary tmp_binary;
const struct ia_css_blob_info *blob_info = NULL;
struct ia_css_isp_param_css_segments isp_mem_if;
- /* LA: should be ia_css_data, should not contain host pointer.
- However, CSS/DDR pointer is not available yet.
- Hack is to store it in params->ddr_ptrs and then copy it late in the SP just before vmem init.
- TODO: Call this after CSS/DDR allocation and store that pointer.
- Best is to allocate it at stage creation time together with host pointer.
- Remove vmem from params.
- */
+ /*
+ * LA: should be ia_css_data, should not contain host pointer.
+ * However, CSS/DDR pointer is not available yet.
+ * Hack is to store it in params->ddr_ptrs and then copy it late in the SP just before vmem init.
+ * TODO: Call this after CSS/DDR allocation and store that pointer.
+ * Best is to allocate it at stage creation time together with host pointer.
+ * Remove vmem from params.
+ */
struct ia_css_isp_param_css_segments *mem_if = &isp_mem_if;

int err = 0;
@@ -1120,10 +1122,12 @@ sp_init_stage(struct ia_css_pipeline_stage *stage,
} else {
/* SP stage */
assert(stage->sp_func != IA_CSS_PIPELINE_NO_FUNC);
- /* binary and blob_info are now NULL.
- These will be passed to sh_css_sp_init_stage
- and dereferenced there, so passing a NULL
- pointer is no good. return an error */
+ /*
+ * binary and blob_info are now NULL.
+ * These will be passed to sh_css_sp_init_stage
+ * and dereferenced there, so passing a NULL
+ * pointer is no good. return an error
+ */
return -EINVAL;
}

@@ -1257,8 +1261,10 @@ sh_css_sp_init_pipeline(struct ia_css_pipeline *me,
SH_CSS_PIPE_CONFIG_SAMPLE_PARAMS << thread_id;
}

- /* For continuous use-cases, SP copy is responsible for sampling the
- * parameters */
+ /*
+ * For continuous use-cases, SP copy is responsible for sampling the
+ * parameters
+ */
if (continuous)
sh_css_sp_group.pipe[thread_id].pipe_config = 0;

@@ -1539,7 +1545,8 @@ ia_css_pipe_set_irq_mask(struct ia_css_pipe *pipe,
assert(pipe);

assert(IA_CSS_PIPE_ID_NUM == NR_OF_PIPELINES);
- /* Linux kernel does not have UINT16_MAX
+ /*
+ * Linux kernel does not have UINT16_MAX
* Therefore decided to comment out these 2 asserts for Linux
* Alternatives that were not chosen:
* - add a conditional #define for UINT16_MAX
@@ -1638,7 +1645,8 @@ sh_css_sp_start_isp(void)
(unsigned int)sp_address_of(sp_sw_state),
(uint32_t)(IA_CSS_SP_SW_TERMINATED));

- /* Note 1: The sp_start_isp function contains a wait till
+ /*
+ * Note 1: The sp_start_isp function contains a wait till
* the input network is configured by the SP.
* Note 2: Not all SP binaries supports host2sp_commands.
* In case a binary does support it, the host2sp_command
@@ -1648,7 +1656,8 @@ sh_css_sp_start_isp(void)
* received, the SP starts configuring the input network.
*/

- /* we need to set sp_running before we call ia_css_mmu_invalidate_cache
+ /*
+ * We need to set sp_running before we call ia_css_mmu_invalidate_cache
* as ia_css_mmu_invalidate_cache checks on sp_running to
* avoid that it accesses dmem while the SP is not powered
*/
--
2.40.1