From: Martiros Shakhzadyan <vrzh@vrzh.net>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Martiros Shakhzadyan <vrzh@vrzh.net>,
Sakari Ailus <sakari.ailus@linux.intel.com>,
linux-media@vger.kernel.org
Subject: [PATCH 5/8] staging: media: atomisp: Refactor ia_css_stream_load()
Date: Mon, 19 Apr 2021 15:25:59 -0400 [thread overview]
Message-ID: <20210419192602.498815-6-vrzh@vrzh.net> (raw)
In-Reply-To: <20210419192602.498815-1-vrzh@vrzh.net>
Move the support check to the beginning of the function.
Replace ENOTSUPP with a standard EOPNOTSUPP exit code.
Use goto instead of nesting blocks in the stream search loop.
Move variable assignment outside of the if statement.
Remove an unnecessary check.
Signed-off-by: Martiros Shakhzadyan <vrzh@vrzh.net>
---
drivers/staging/media/atomisp/pci/sh_css.c | 72 +++++++++++-----------
1 file changed, 35 insertions(+), 37 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c
index 87438b5948ba..71e8133abf04 100644
--- a/drivers/staging/media/atomisp/pci/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/sh_css.c
@@ -9616,48 +9616,46 @@ ia_css_stream_get_info(const struct ia_css_stream *stream,
int
ia_css_stream_load(struct ia_css_stream *stream)
{
- if (!IS_ISP2401) {
- int i;
- int err;
+ int i, j, err;
- assert(stream);
- ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_stream_load() enter,\n");
- for (i = 0; i < MAX_ACTIVE_STREAMS; i++) {
- if (my_css_save.stream_seeds[i].stream == stream) {
- int j;
+ if (IS_ISP2401) {
+ /* TODO remove function - DEPRECATED */
+ (void)stream;
+ return -EOPNOTSUPP;
+ }
- for (j = 0; j < my_css_save.stream_seeds[i].num_pipes; j++) {
- if ((err = ia_css_pipe_create(&my_css_save.stream_seeds[i].pipe_config[j],
- &my_css_save.stream_seeds[i].pipes[j])) != 0) {
- if (j) {
- int k;
+ assert(stream);
+ ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_stream_load() enter,\n");
+ for (i = 0; i < MAX_ACTIVE_STREAMS; i++)
+ if (my_css_save.stream_seeds[i].stream == stream)
+ goto found;
+ goto done;
+
+found:
+ for (j = 0; j < my_css_save.stream_seeds[i].num_pipes; j++) {
+ err = ia_css_pipe_create(&my_css_save.stream_seeds[i].pipe_config[j],
+ &my_css_save.stream_seeds[i].pipes[j]);
+ if (err) {
+ int k;
- for (k = 0; k < j; k++)
- ia_css_pipe_destroy(my_css_save.stream_seeds[i].pipes[k]);
- }
- return err;
- }
- }
- err = ia_css_stream_create(&my_css_save.stream_seeds[i].stream_config,
- my_css_save.stream_seeds[i].num_pipes,
- my_css_save.stream_seeds[i].pipes,
- &my_css_save.stream_seeds[i].stream);
- if (err) {
- ia_css_stream_destroy(stream);
- for (j = 0; j < my_css_save.stream_seeds[i].num_pipes; j++)
- ia_css_pipe_destroy(my_css_save.stream_seeds[i].pipes[j]);
- return err;
- }
- break;
- }
+ for (k = 0; k < j; k++)
+ ia_css_pipe_destroy(my_css_save.stream_seeds[i].pipes[k]);
+ return err;
}
- ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_stream_load() exit,\n");
- return 0;
- } else {
- /* TODO remove function - DEPRECATED */
- (void)stream;
- return -ENOTSUPP;
}
+ err = ia_css_stream_create(&my_css_save.stream_seeds[i].stream_config,
+ my_css_save.stream_seeds[i].num_pipes,
+ my_css_save.stream_seeds[i].pipes,
+ &my_css_save.stream_seeds[i].stream);
+ if (err) {
+ ia_css_stream_destroy(stream);
+ for (j = 0; j < my_css_save.stream_seeds[i].num_pipes; j++)
+ ia_css_pipe_destroy(my_css_save.stream_seeds[i].pipes[j]);
+ return err;
+ }
+done:
+ ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_stream_load() exit,\n");
+ return 0;
}
int
--
2.31.1
next prev parent reply other threads:[~2021-04-19 19:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-19 19:25 [PATCH 0/8] staging: media: atomisp: A series of cleanup Martiros Shakhzadyan
2021-04-19 19:25 ` [PATCH 1/8] staging: media: atomisp: Fix the rest of sh_css.c brace issues Martiros Shakhzadyan
2021-04-19 19:25 ` [PATCH 2/8] staging: media: atomisp: Remove all redundant assertions in sh_css.c Martiros Shakhzadyan
2021-04-19 19:25 ` [PATCH 3/8] staging: media: atomisp: Remove a superfluous else clause " Martiros Shakhzadyan
2021-04-19 19:25 ` [PATCH 4/8] staging: media: atomisp: Replace goto with immediate return in sh_css_pipe_get_grid_info() Martiros Shakhzadyan
2021-04-20 12:57 ` Hans Verkuil
2021-04-19 19:25 ` Martiros Shakhzadyan [this message]
2021-04-20 13:11 ` [PATCH 5/8] staging: media: atomisp: Refactor ia_css_stream_load() Hans Verkuil
2021-04-19 19:26 ` [PATCH 6/8] staging: media: atomisp: Replace if else clause with a ternary Martiros Shakhzadyan
2021-04-19 19:26 ` [PATCH 7/8] staging: media: atomisp: Fix line split style issues Martiros Shakhzadyan
2021-04-20 13:02 ` Hans Verkuil
2021-04-19 19:26 ` [PATCH 8/8] staging: media: atomisp: Fix alignment and line length issues Martiros Shakhzadyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210419192602.498815-6-vrzh@vrzh.net \
--to=vrzh@vrzh.net \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).