From: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
To: Vikram Sharma <quic_vikramsa@quicinc.com>,
Robert Foss <rfoss@kernel.org>, Todor Tomov <todor.too@gmail.com>,
Bryan O'Donoghue <bryan.odonoghue@linaro.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Kapatrala Syed <akapatra@quicinc.com>,
Hariram Purushothaman <hariramp@quicinc.com>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konradybcio@kernel.org>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
cros-qcom-dts-watchers@chromium.org,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>
Cc: linux-arm-msm@vger.kernel.org, linux-media@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Suresh Vankadara <quic_svankada@quicinc.com>,
Trishansh Bhardwaj <quic_tbhardwa@quicinc.com>
Subject: Re: [PATCH 06/10] media: qcom: camss: Add camss_link_entities_v2
Date: Wed, 4 Sep 2024 15:50:05 +0100 [thread overview]
Message-ID: <a010743e-0018-4b6a-adeb-c6f3203f1e67@linaro.org> (raw)
In-Reply-To: <20240904-camss_on_sc7280_rb3gen2_vision_v2_patches-v1-6-b18ddcd7d9df@quicinc.com>
On 04/09/2024 12:10, Vikram Sharma wrote:
> Add camss_link_entities_v2, derived from the camss_link_entities
> function, to handle linking for targets without ISPIF.
>
> camss_link_entities -> Targets with ispif.
> camss_link_entities_v2 -> Targets without ispif.
>
> Signed-off-by: Suresh Vankadara <quic_svankada@quicinc.com>
> Signed-off-by: Trishansh Bhardwaj <quic_tbhardwa@quicinc.com>
> Signed-off-by: Vikram Sharma <quic_vikramsa@quicinc.com>
> ---
> drivers/media/platform/qcom/camss/camss.c | 53 ++++++++++++++++++++++++++++++-
> 1 file changed, 52 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index 5e7235001239..516434686a27 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
> @@ -2154,6 +2154,57 @@ static int camss_init_subdevices(struct camss *camss)
> return 0;
> }
>
> +/*
> + * camss_link_entities_v2 - Register subdev nodes and create links
> + * @camss: CAMSS device
> + *
> + * Return 0 on success or a negative error code on failure
> + */
> +static int camss_link_entities_v2(struct camss *camss)
> +{
> + int i, j;
> + int ret;
> +
> + for (i = 0; i < camss->res->csiphy_num; i++) {
> + for (j = 0; j < camss->res->csid_num; j++) {
> + ret = media_create_pad_link(&camss->csiphy[i].subdev.entity,
> + MSM_CSIPHY_PAD_SRC,
> + &camss->csid[j].subdev.entity,
> + MSM_CSID_PAD_SINK,
> + 0);
> + if (ret < 0) {
> + dev_err(camss->dev,
> + "Failed to link %s->%s entities: %d\n",
> + camss->csiphy[i].subdev.entity.name,
> + camss->csid[j].subdev.entity.name,
> + ret);
> + return ret;
> + }
> + }
> + }
Please reduce the above loop down into a common call that both
camss_link_entities_ispif()[1] and camss_link_entities() can call.
Because => functional decomposition and code reuse instead of code
replication.
> + for (i = 0; i < camss->res->csid_num; i++)
> + for (j = 0; j < camss->vfe[i].res->line_num; j++) {
> + struct v4l2_subdev *csid = &camss->csid[i].subdev;
> + struct v4l2_subdev *vfe = &camss->vfe[i].line[j].subdev;
> +
> + ret = media_create_pad_link(&csid->entity,
> + MSM_CSID_PAD_FIRST_SRC + j,
> + &vfe->entity,
> + MSM_VFE_PAD_SINK,
> + 0);
> + if (ret < 0) {
> + dev_err(camss->dev,
> + "Failed to link %s->%s entities: %d\n",
> + csid->entity.name,
> + vfe->entity.name,
> + ret);
> + return ret;
> + }
> + }
> + return 0;
> +}
Having a tidy function for every non ispif SoC seems like nice code,
approve.
However the corollary is the ispif version of the code should then drop the
if (camss->ispif) {
//do stuff
} else {
// do other stuff
}
i.e. your function pointer now determines if ispif is true so you can
drop the dead code on the else path in camss_link_entities_ispif()
> +
> /*
> * camss_link_entities - Register subdev nodes and create links
> * @camss: CAMSS device
> @@ -2769,7 +2820,7 @@ static const struct camss_resources sc8280xp_resources = {
> .csiphy_num = ARRAY_SIZE(csiphy_res_sc8280xp),
> .csid_num = ARRAY_SIZE(csid_res_sc8280xp),
> .vfe_num = ARRAY_SIZE(vfe_res_sc8280xp),
> - .link_entities = camss_link_entities
> + .link_entities = camss_link_entities_v2
> };
>
> static const struct camss_resources sc7280_resources = {
>
This change isn't correct.
There are six upstream camss entires
grep camss arch/arm64/boot/dts/qcom/*.dtsi | grep compat | wc -l
6
Only three of which have ispif
grep -m1 "ispif" arch/arm64/boot/dts/qcom/*.dtsi | wc -l
3
=> You've missed 2/3 of the SoCs the change should apply to - 845 and 8250.
[1] I also think the legacy function should be called
camss_link_entities_ispif() with the default being camss_link_entities();
1. Please change the name of the existing function to
camss_link_entities_ispif() to reflect its function and dependency.
2. Functionally decompose the top part of the loop into some common
method that both camss_link_entities_ispif() and
camss_link_entities() can call.
Because functionally decomposed and reused code is better code.
3. You need to make sure you hook the right set of SoCs with the
default and legacy versions of the function
-> msm8916/msm8996/sdm630 .link_entites = camss_link_entities_ispif()
-> sdm845/sc7280/sc8280xp .link_entities = camss_link_entities()
---
bod
next prev parent reply other threads:[~2024-09-04 14:50 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 11:10 [PATCH 00/10] (no cover subject) Vikram Sharma
2024-09-04 11:10 ` [PATCH 01/10] media: dt-bindings: media: camss: Add qcom,sc7280-camss binding Vikram Sharma
2024-09-04 11:28 ` Krzysztof Kozlowski
2024-09-05 6:47 ` Krzysztof Kozlowski
2024-09-04 11:10 ` [PATCH 02/10] media: dt-bindings: media: qcs6490-rb3gen2-vision-mezzanine: Add dt bindings Vikram Sharma
2024-09-04 11:29 ` Krzysztof Kozlowski
2024-09-04 11:10 ` [PATCH 03/10] media: qcom: camss: Fix potential crash if domain attach fails Vikram Sharma
2024-09-05 12:13 ` Konrad Dybcio
2024-09-04 11:10 ` [PATCH 04/10] media: qcom: camss: Sort CAMSS version enums and compatible strings Vikram Sharma
2024-09-04 14:44 ` Bryan O'Donoghue
2024-09-04 11:10 ` [PATCH 05/10] media: qcom: camss: Add support for camss driver on SC7280 Vikram Sharma
2024-09-04 11:10 ` [PATCH 06/10] media: qcom: camss: Add camss_link_entities_v2 Vikram Sharma
2024-09-04 14:50 ` Bryan O'Donoghue [this message]
2024-09-04 11:10 ` [PATCH 07/10] arm64: dts: qcom: sc7280: Add support for camss Vikram Sharma
2024-09-04 11:31 ` Krzysztof Kozlowski
2024-09-04 11:10 ` [PATCH 08/10] arm64: dts: qcom: qcs6490-rb3gen2-vision-mezzanine: Enable IMX577 sensor Vikram Sharma
2024-09-04 11:32 ` Krzysztof Kozlowski
2024-09-04 11:10 ` [PATCH 09/10] arm64: dts: qcom: sc7280: Add default and suspend states for GPIO Vikram Sharma
2024-09-04 11:33 ` Krzysztof Kozlowski
2024-09-04 11:10 ` [PATCH 10/10] arm64: defconfig: Enable camcc driver for SC7280 Vikram Sharma
2024-09-04 11:33 ` Krzysztof Kozlowski
2024-09-04 11:21 ` [PATCH 00/10] (no cover subject) Bryan O'Donoghue
2024-09-04 11:22 ` Bryan O'Donoghue
2024-09-04 13:36 ` Rob Herring (Arm)
2024-09-30 10:52 ` Luca Weiss
2024-09-30 11:54 ` Bryan O'Donoghue
2024-10-01 8:24 ` Luca Weiss
2024-10-01 8:51 ` Vikram Sharma
2024-10-01 9:30 ` Bryan O'Donoghue
2024-10-01 11:39 ` Luca Weiss
2024-10-01 12:49 ` Bryan O'Donoghue
2024-10-01 14:22 ` Luca Weiss
2024-10-01 14:58 ` Bryan O'Donoghue
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=a010743e-0018-4b6a-adeb-c6f3203f1e67@linaro.org \
--to=bryan.odonoghue@linaro.org \
--cc=akapatra@quicinc.com \
--cc=andersson@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=conor+dt@kernel.org \
--cc=cros-qcom-dts-watchers@chromium.org \
--cc=devicetree@vger.kernel.org \
--cc=hariramp@quicinc.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=konradybcio@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=quic_svankada@quicinc.com \
--cc=quic_tbhardwa@quicinc.com \
--cc=quic_vikramsa@quicinc.com \
--cc=rfoss@kernel.org \
--cc=robh@kernel.org \
--cc=todor.too@gmail.com \
--cc=will@kernel.org \
/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).