From: Tomasz Figa <tfiga@chromium.org>
To: Jonathan Bakker <xc-racer2@live.ca>
Cc: kyungmin.park@samsung.com, s.nawrocki@samsung.com,
mchehab@kernel.org, kgene@kernel.org, krzk@kernel.org,
linux-media@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 07/11] media: exynos4-is: Add support for multiple sensors on one port
Date: Tue, 7 Jul 2020 18:36:55 +0000 [thread overview]
Message-ID: <20200707183655.GG2621465@chromium.org> (raw)
In-Reply-To: <BN6PR04MB0660CE60DA8585C5E1DA9EB9A3AE0@BN6PR04MB0660.namprd04.prod.outlook.com>
On Sat, Apr 25, 2020 at 07:26:46PM -0700, Jonathan Bakker wrote:
> On some devices, there may be multiple camera sensors attached
> to the same port. Make sure we probe all of them, not just the
> first one.
>
> Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
> ---
> drivers/media/platform/exynos4-is/media-dev.c | 32 ++++++++++++-------
> 1 file changed, 21 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
> index b38445219c72..a87ebd7913be 100644
> --- a/drivers/media/platform/exynos4-is/media-dev.c
> +++ b/drivers/media/platform/exynos4-is/media-dev.c
> @@ -397,25 +397,28 @@ static void fimc_md_pipelines_free(struct fimc_md *fmd)
> /* Parse port node and register as a sub-device any sensor specified there. */
> static int fimc_md_parse_port_node(struct fimc_md *fmd,
> struct device_node *port,
> - unsigned int index)
> + unsigned int *index)
> {
> - struct fimc_source_info *pd = &fmd->sensor[index].pdata;
> + struct fimc_source_info *pd;
> struct device_node *rem, *ep, *np;
> - struct v4l2_fwnode_endpoint endpoint = { .bus_type = 0 };
> + struct v4l2_fwnode_endpoint endpoint;
> int ret;
>
> - /* Assume here a port node can have only one endpoint node. */
> ep = of_get_next_child(port, NULL);
> if (!ep)
> return 0;
>
> +parse_sensor:
> + pd = &fmd->sensor[*index].pdata;
> + endpoint.bus_type = 0;
> +
> ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(ep), &endpoint);
> if (ret) {
> of_node_put(ep);
> return ret;
> }
>
> - if (WARN_ON(endpoint.base.port == 0) || index >= FIMC_MAX_SENSORS) {
> + if (WARN_ON(endpoint.base.port == 0) || *index >= FIMC_MAX_SENSORS) {
> of_node_put(ep);
> return -EINVAL;
> }
> @@ -462,16 +465,16 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
> pd->fimc_bus_type = pd->sensor_bus_type;
> of_node_put(np);
>
> - if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor))) {
> + if (WARN_ON(*index >= ARRAY_SIZE(fmd->sensor))) {
> of_node_put(rem);
> return -EINVAL;
> }
>
> - fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> - fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem);
> + fmd->sensor[*index].asd.match_type = V4L2_ASYNC_MATCH_FWNODE;
> + fmd->sensor[*index].asd.match.fwnode = of_fwnode_handle(rem);
>
> ret = v4l2_async_notifier_add_subdev(&fmd->subdev_notifier,
> - &fmd->sensor[index].asd);
> + &fmd->sensor[*index].asd);
> if (ret) {
> of_node_put(rem);
> return ret;
> @@ -479,6 +482,13 @@ static int fimc_md_parse_port_node(struct fimc_md *fmd,
>
> fmd->num_sensors++;
>
> + /* Check for additional sensors on same port */
> + ep = of_get_next_child(port, ep);
> + if (ep) {
> + (*index)++;
Do we need this index argument at all? I can see that we already have
fmd->num_sensors and we increment it every time we discover a sensor.
Perhaps we could just use it instead?
> + goto parse_sensor;
As we know, goto in principle isn't the best coding pattern. There is a
number of exceptions where it is welcome, e.g. error handling, but
reimplementing a loop using goto is not very nice.
Instead, could you separate the code that probes one sensor into
fimc_md_parse_one_endpoint() and in this one simply iterate over all child
nodes of the port using for_each_child_of_node()?
Best regards,
Tomasz
next prev parent reply other threads:[~2020-07-07 18:36 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200426022650.10355-1-xc-racer2@live.ca>
2020-04-26 2:26 ` [PATCH 01/11] media: exynos4-is: Remove static driver data for S5PV210 FIMC variants Jonathan Bakker
2020-07-07 17:33 ` Tomasz Figa
2020-07-08 14:45 ` Sylwester Nawrocki
2020-04-26 2:26 ` [PATCH 02/11] media: exynos4-is: Request syscon only if ISP writeback is present Jonathan Bakker
2020-07-07 17:34 ` Tomasz Figa
2020-07-08 14:47 ` Sylwester Nawrocki
2020-04-26 2:26 ` [PATCH 03/11] media: exynos4-is: Fix nullptr when no CSIS device present Jonathan Bakker
2020-07-07 17:55 ` Tomasz Figa
2020-07-08 15:11 ` Sylwester Nawrocki
2020-07-11 16:27 ` Jonathan Bakker
2020-07-08 14:49 ` Sylwester Nawrocki
2020-04-26 2:26 ` [PATCH 04/11] media: exynos4-is: Correct missing entity function initialization Jonathan Bakker
2020-07-07 18:09 ` Tomasz Figa
2020-07-08 15:34 ` Sylwester Nawrocki
2020-07-11 16:35 ` Jonathan Bakker
2020-04-26 2:26 ` [PATCH 05/11] media: exynos4-is: Improve support for sensors with multiple pads Jonathan Bakker
2020-07-07 18:13 ` Tomasz Figa
2020-07-11 18:21 ` Jonathan Bakker
2020-04-26 2:26 ` [PATCH 06/11] media: exynos4-is: Properly set JPEG options when not using CSIS Jonathan Bakker
2020-07-07 18:23 ` Tomasz Figa
2020-07-08 15:45 ` Sylwester Nawrocki
2020-07-11 16:43 ` Jonathan Bakker
2020-07-08 15:46 ` Sylwester Nawrocki
2020-04-26 2:26 ` [PATCH 07/11] media: exynos4-is: Add support for multiple sensors on one port Jonathan Bakker
2020-07-07 18:36 ` Tomasz Figa [this message]
2020-07-11 16:48 ` Jonathan Bakker
2020-04-26 2:26 ` [PATCH 08/11] media: exynos4-is: Remove inh_sensor_ctrls Jonathan Bakker
2020-07-07 18:37 ` Tomasz Figa
2020-07-08 15:47 ` Sylwester Nawrocki
2020-04-26 2:26 ` [PATCH 09/11] media: exynos4-is: Remove unused struct member input_index Jonathan Bakker
2020-07-07 18:38 ` Tomasz Figa
2020-07-08 15:49 ` Sylwester Nawrocki
2020-04-26 2:26 ` [PATCH 10/11] media: exynos4-is: Prevent duplicate call to media_pipeline_stop Jonathan Bakker
2020-07-07 18:44 ` Tomasz Figa
2020-07-11 18:17 ` Jonathan Bakker
2020-07-20 13:10 ` Tomasz Figa
2020-07-24 23:46 ` Jonathan Bakker
2020-07-27 13:48 ` Tomasz Figa
2020-04-26 2:26 ` [PATCH 11/11] media: exynos4-is: Correct parallel port probing Jonathan Bakker
2020-07-07 18:48 ` Tomasz Figa
2020-07-08 16:15 ` Sylwester Nawrocki
2020-07-11 18:18 ` Jonathan Bakker
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=20200707183655.GG2621465@chromium.org \
--to=tfiga@chromium.org \
--cc=kgene@kernel.org \
--cc=krzk@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=s.nawrocki@samsung.com \
--cc=xc-racer2@live.ca \
/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).