* [PATCH v3 0/2] media: qcom: camss: Re-structure camss_link_entities
@ 2024-11-25 10:34 Vikram Sharma
2024-11-25 10:34 ` [PATCH v3 1/2] media: qcom: camss: reducing the repitious error message string Vikram Sharma
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Vikram Sharma @ 2024-11-25 10:34 UTC (permalink / raw)
To: rfoss, todor.too, bryan.odonoghue; +Cc: linux-media, linux-kernel, kernel
Refactor the camss_link_entities function by breaking it down into
three distinct functions. Each function will handle the linking of
a specific entity separately, enhancing readability.
Changes in V3:
- Broke down the change in 2 patches. first one to functionally
decompose link error message. second to restrcture the link
function.
- Removed the declarion of camss_link_error from header file.
- Link to v2: https://lore.kernel.org/linux-arm-msm/20241112133846.2397017-1-quic_vikramsa@quicinc.com/
Changes in V2:
- Declared variables in reverse christmas tree order.
- Functionally decomposed link error message.
- Link to v1: https://lore.kernel.org/linux-arm-msm/20241111173845.1773553-1-quic_vikramsa@quicinc.com/
To: Robert Foss <rfoss@kernel.org>
To: Todor Tomov <todor.too@gmail.com>
To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Cc: linux-media@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Vikram Sharma <quic_vikramsa@quicinc.com>
Vikram Sharma (2):
media: qcom: camss: reducing the repitious error message string
media: qcom: camss: Restructure camss_link_entities
drivers/media/platform/qcom/camss/camss.c | 195 ++++++++++++++--------
1 file changed, 130 insertions(+), 65 deletions(-)
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/2] media: qcom: camss: reducing the repitious error message string
2024-11-25 10:34 [PATCH v3 0/2] media: qcom: camss: Re-structure camss_link_entities Vikram Sharma
@ 2024-11-25 10:34 ` Vikram Sharma
2024-11-25 12:10 ` Bryan O'Donoghue
2024-11-25 10:34 ` [PATCH v3 2/2] media: qcom: camss: Restructure camss_link_entities Vikram Sharma
2024-11-25 11:57 ` [PATCH v3 0/2] media: qcom: camss: Re-structure camss_link_entities Vladimir Zapolskiy
2 siblings, 1 reply; 6+ messages in thread
From: Vikram Sharma @ 2024-11-25 10:34 UTC (permalink / raw)
To: rfoss, todor.too, bryan.odonoghue; +Cc: linux-media, linux-kernel, kernel
Introducing a new function camss_link_err to avoid repition of
same error message, improving code maintainability.
Signed-off-by: Vikram Sharma <quic_vikramsa@quicinc.com>
---
drivers/media/platform/qcom/camss/camss.c | 60 ++++++++++++++---------
1 file changed, 37 insertions(+), 23 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index 9fb31f4c18ad..520c5bc7a265 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -1993,6 +1993,26 @@ static int camss_init_subdevices(struct camss *camss)
return 0;
}
+/*
+ * camss_link_entities - Register subdev nodes and create links
+ * camss_link_err - print error in case link creation fails
+ * @src_name: name for source of the link
+ * @sink_name: name for sink of the link
+ */
+inline void camss_link_err(struct camss *camss,
+ const char *src_name,
+ const char *sink_name,
+ int ret)
+{
+ if (!camss || !src_name || !sink_name)
+ return;
+ dev_err(camss->dev,
+ "Failed to link %s->%s entities: %d\n",
+ src_name,
+ sink_name,
+ ret);
+}
+
/*
* camss_link_entities - Register subdev nodes and create links
* @camss: CAMSS device
@@ -2012,11 +2032,10 @@ static int camss_link_entities(struct camss *camss)
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);
+ camss_link_err(camss,
+ camss->csiphy[i].subdev.entity.name,
+ camss->csid[j].subdev.entity.name,
+ ret);
return ret;
}
}
@@ -2031,11 +2050,10 @@ static int camss_link_entities(struct camss *camss)
MSM_ISPIF_PAD_SINK,
0);
if (ret < 0) {
- dev_err(camss->dev,
- "Failed to link %s->%s entities: %d\n",
- camss->csid[i].subdev.entity.name,
- camss->ispif->line[j].subdev.entity.name,
- ret);
+ camss_link_err(camss, src_entity->name,
+ camss->csid[i].subdev.entity.name,
+ camss->ispif->line[j].subdev.entity.name,
+ ret);
return ret;
}
}
@@ -2053,11 +2071,9 @@ static int camss_link_entities(struct camss *camss)
MSM_VFE_PAD_SINK,
0);
if (ret < 0) {
- dev_err(camss->dev,
- "Failed to link %s->%s entities: %d\n",
- ispif->entity.name,
- vfe->entity.name,
- ret);
+ camss_link_err(camss, ispif->entity.name,
+ vfe->entity.name,
+ ret);
return ret;
}
}
@@ -2074,11 +2090,9 @@ static int camss_link_entities(struct camss *camss)
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);
+ camss_link_err(camss, csid->entity.name,
+ vfe->entity.name,
+ ret);
return ret;
}
}
@@ -2227,9 +2241,9 @@ static int camss_subdev_notifier_complete(struct v4l2_async_notifier *async)
input, MSM_CSIPHY_PAD_SINK,
MEDIA_LNK_FL_IMMUTABLE | MEDIA_LNK_FL_ENABLED);
if (ret < 0) {
- dev_err(camss->dev,
- "Failed to link %s->%s entities: %d\n",
- sensor->name, input->name, ret);
+ camss_link_err(camss, sensor->name,
+ input->name,
+ ret);
return ret;
}
}
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 2/2] media: qcom: camss: Restructure camss_link_entities
2024-11-25 10:34 [PATCH v3 0/2] media: qcom: camss: Re-structure camss_link_entities Vikram Sharma
2024-11-25 10:34 ` [PATCH v3 1/2] media: qcom: camss: reducing the repitious error message string Vikram Sharma
@ 2024-11-25 10:34 ` Vikram Sharma
2024-11-25 11:57 ` [PATCH v3 0/2] media: qcom: camss: Re-structure camss_link_entities Vladimir Zapolskiy
2 siblings, 0 replies; 6+ messages in thread
From: Vikram Sharma @ 2024-11-25 10:34 UTC (permalink / raw)
To: rfoss, todor.too, bryan.odonoghue; +Cc: linux-media, linux-kernel, kernel
Refactor the camss_link_entities function by breaking it down into
three distinct functions. Each function will handle the linking of
a specific entity separately.
SC7280 and later targets mandates for 1:1 linking for csid -> vfe.
i.e. csid0 can be mapped to vfe0 only.
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 | 155 ++++++++++++++--------
1 file changed, 103 insertions(+), 52 deletions(-)
diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
index 520c5bc7a265..6ebf65019eed 100644
--- a/drivers/media/platform/qcom/camss/camss.c
+++ b/drivers/media/platform/qcom/camss/camss.c
@@ -1994,7 +1994,6 @@ static int camss_init_subdevices(struct camss *camss)
}
/*
- * camss_link_entities - Register subdev nodes and create links
* camss_link_err - print error in case link creation fails
* @src_name: name for source of the link
* @sink_name: name for sink of the link
@@ -2014,14 +2013,64 @@ inline void camss_link_err(struct camss *camss,
}
/*
- * camss_link_entities - Register subdev nodes and create links
+ * camss_link_entities_csid - 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(struct camss *camss)
+static int camss_link_entities_csid(struct camss *camss)
{
- int i, j, k;
+ struct media_entity *src_entity;
+ struct media_entity *sink_entity;
+ int ret, line_num;
+ u16 sink_pad;
+ u16 src_pad;
+ int i, j;
+
+ for (i = 0; i < camss->res->csid_num; i++) {
+ if (camss->ispif)
+ line_num = camss->ispif->line_num;
+ else
+ line_num = camss->vfe[i].res->line_num;
+
+ src_entity = &camss->csid[i].subdev.entity;
+ for (j = 0; j < line_num; j++) {
+ if (camss->ispif) {
+ sink_entity = &camss->ispif->line[j].subdev.entity;
+ src_pad = MSM_CSID_PAD_SRC;
+ sink_pad = MSM_ISPIF_PAD_SINK;
+ } else {
+ sink_entity = &camss->vfe[i].line[j].subdev.entity;
+ src_pad = MSM_CSID_PAD_FIRST_SRC + j;
+ sink_pad = MSM_VFE_PAD_SINK;
+ }
+
+ ret = media_create_pad_link(src_entity,
+ src_pad,
+ sink_entity,
+ sink_pad,
+ 0);
+ if (ret < 0) {
+ camss_link_err(camss, src_entity->name,
+ sink_entity->name,
+ ret);
+ return ret;
+ }
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * camss_link_entities_csiphy - 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_csiphy(struct camss *camss)
+{
+ int i, j;
int ret;
for (i = 0; i < camss->res->csiphy_num; i++) {
@@ -2041,66 +2090,68 @@ static int camss_link_entities(struct camss *camss)
}
}
- if (camss->ispif) {
- for (i = 0; i < camss->res->csid_num; i++) {
- for (j = 0; j < camss->ispif->line_num; j++) {
- ret = media_create_pad_link(&camss->csid[i].subdev.entity,
- MSM_CSID_PAD_SRC,
- &camss->ispif->line[j].subdev.entity,
- MSM_ISPIF_PAD_SINK,
+ return 0;
+}
+
+/*
+ * camss_link_entities_ispif - 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_ispif(struct camss *camss)
+{
+ int i, j, k;
+ int ret;
+
+ for (i = 0; i < camss->ispif->line_num; i++) {
+ for (k = 0; k < camss->res->vfe_num; k++) {
+ for (j = 0; j < camss->vfe[k].res->line_num; j++) {
+ struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev;
+ struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
+
+ ret = media_create_pad_link(&ispif->entity,
+ MSM_ISPIF_PAD_SRC,
+ &vfe->entity,
+ MSM_VFE_PAD_SINK,
0);
if (ret < 0) {
- camss_link_err(camss, src_entity->name,
- camss->csid[i].subdev.entity.name,
- camss->ispif->line[j].subdev.entity.name,
+ camss_link_err(camss, ispif->entity.name,
+ vfe->entity.name,
ret);
return ret;
}
}
}
-
- for (i = 0; i < camss->ispif->line_num; i++)
- for (k = 0; k < camss->res->vfe_num; k++)
- for (j = 0; j < camss->vfe[k].res->line_num; j++) {
- struct v4l2_subdev *ispif = &camss->ispif->line[i].subdev;
- struct v4l2_subdev *vfe = &camss->vfe[k].line[j].subdev;
-
- ret = media_create_pad_link(&ispif->entity,
- MSM_ISPIF_PAD_SRC,
- &vfe->entity,
- MSM_VFE_PAD_SINK,
- 0);
- if (ret < 0) {
- camss_link_err(camss, ispif->entity.name,
- vfe->entity.name,
- ret);
- return ret;
- }
- }
- } else {
- for (i = 0; i < camss->res->csid_num; i++)
- for (k = 0; k < camss->res->vfe_num; k++)
- for (j = 0; j < camss->vfe[k].res->line_num; j++) {
- struct v4l2_subdev *csid = &camss->csid[i].subdev;
- struct v4l2_subdev *vfe = &camss->vfe[k].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) {
- camss_link_err(camss, csid->entity.name,
- vfe->entity.name,
- ret);
- return ret;
- }
- }
}
return 0;
}
+/*
+ * camss_link_entities - 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(struct camss *camss)
+{
+ int ret;
+
+ ret = camss_link_entities_csiphy(camss);
+ if (ret < 0)
+ return ret;
+
+ ret = camss_link_entities_csid(camss);
+ if (ret < 0)
+ return ret;
+
+ if (camss->ispif)
+ ret = camss_link_entities_ispif(camss);
+
+ return ret;
+}
+
/*
* camss_register_entities - Register subdev nodes and create links
* @camss: CAMSS device
--
2.25.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] media: qcom: camss: Re-structure camss_link_entities
2024-11-25 10:34 [PATCH v3 0/2] media: qcom: camss: Re-structure camss_link_entities Vikram Sharma
2024-11-25 10:34 ` [PATCH v3 1/2] media: qcom: camss: reducing the repitious error message string Vikram Sharma
2024-11-25 10:34 ` [PATCH v3 2/2] media: qcom: camss: Restructure camss_link_entities Vikram Sharma
@ 2024-11-25 11:57 ` Vladimir Zapolskiy
2024-11-25 12:14 ` Bryan O'Donoghue
2 siblings, 1 reply; 6+ messages in thread
From: Vladimir Zapolskiy @ 2024-11-25 11:57 UTC (permalink / raw)
To: Vikram Sharma, rfoss, todor.too, bryan.odonoghue
Cc: linux-media, linux-kernel, kernel
Hi Vikram,
On 11/25/24 12:34, Vikram Sharma wrote:
> Refactor the camss_link_entities function by breaking it down into
> three distinct functions. Each function will handle the linking of
> a specific entity separately, enhancing readability.
>
> Changes in V3:
> - Broke down the change in 2 patches. first one to functionally
> decompose link error message. second to restrcture the link
> function.
> - Removed the declarion of camss_link_error from header file.
> - Link to v2: https://lore.kernel.org/linux-arm-msm/20241112133846.2397017-1-quic_vikramsa@quicinc.com/
as I said last time I don't see the value of these changes.
Since the changes are non-functional, then hopefully there should be
no issues with them, however I really miss the point of adding 65
lines of code for a questionable reason and at the price of increased
complexity.
Is there a good reason not to drop the series?
> Changes in V2:
> - Declared variables in reverse christmas tree order.
> - Functionally decomposed link error message.
> - Link to v1: https://lore.kernel.org/linux-arm-msm/20241111173845.1773553-1-quic_vikramsa@quicinc.com/
>
> To: Robert Foss <rfoss@kernel.org>
> To: Todor Tomov <todor.too@gmail.com>
> To: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
> Cc: linux-media@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
>
> Signed-off-by: Vikram Sharma <quic_vikramsa@quicinc.com>
>
> Vikram Sharma (2):
> media: qcom: camss: reducing the repitious error message string
> media: qcom: camss: Restructure camss_link_entities
>
> drivers/media/platform/qcom/camss/camss.c | 195 ++++++++++++++--------
> 1 file changed, 130 insertions(+), 65 deletions(-)
>
--
Best wishes,
Vladimir
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/2] media: qcom: camss: reducing the repitious error message string
2024-11-25 10:34 ` [PATCH v3 1/2] media: qcom: camss: reducing the repitious error message string Vikram Sharma
@ 2024-11-25 12:10 ` Bryan O'Donoghue
0 siblings, 0 replies; 6+ messages in thread
From: Bryan O'Donoghue @ 2024-11-25 12:10 UTC (permalink / raw)
To: Vikram Sharma, rfoss, todor.too; +Cc: linux-media, linux-kernel, kernel
On 25/11/2024 10:34, Vikram Sharma wrote:
> Introducing a new function camss_link_err to avoid repition of
> same error message, improving code maintainability.
>
> Signed-off-by: Vikram Sharma <quic_vikramsa@quicinc.com>
> ---
> drivers/media/platform/qcom/camss/camss.c | 60 ++++++++++++++---------
> 1 file changed, 37 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c
> index 9fb31f4c18ad..520c5bc7a265 100644
> --- a/drivers/media/platform/qcom/camss/camss.c
> +++ b/drivers/media/platform/qcom/camss/camss.c
> @@ -1993,6 +1993,26 @@ static int camss_init_subdevices(struct camss *camss)
> return 0;
> }
>
> +/*
> + * camss_link_entities - Register subdev nodes and create links
> + * camss_link_err - print error in case link creation fails
> + * @src_name: name for source of the link
> + * @sink_name: name for sink of the link
> + */
> +inline void camss_link_err(struct camss *camss,
> + const char *src_name,
> + const char *sink_name,
> + int ret)
> +{
> + if (!camss || !src_name || !sink_name)
> + return;
You don't need this defensive coding error check, please drop.
Once done you can add
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] media: qcom: camss: Re-structure camss_link_entities
2024-11-25 11:57 ` [PATCH v3 0/2] media: qcom: camss: Re-structure camss_link_entities Vladimir Zapolskiy
@ 2024-11-25 12:14 ` Bryan O'Donoghue
0 siblings, 0 replies; 6+ messages in thread
From: Bryan O'Donoghue @ 2024-11-25 12:14 UTC (permalink / raw)
To: Vladimir Zapolskiy, Vikram Sharma, rfoss, todor.too
Cc: linux-media, linux-kernel, kernel
On 25/11/2024 11:57, Vladimir Zapolskiy wrote:
> Hi Vikram,
>
> On 11/25/24 12:34, Vikram Sharma wrote:
>> Refactor the camss_link_entities function by breaking it down into
>> three distinct functions. Each function will handle the linking of
>> a specific entity separately, enhancing readability.
>>
>> Changes in V3:
>> - Broke down the change in 2 patches. first one to functionally
>> decompose link error message. second to restrcture the link
>> function.
>> - Removed the declarion of camss_link_error from header file.
>> - Link to v2: https://lore.kernel.org/linux-arm-
>> msm/20241112133846.2397017-1-quic_vikramsa@quicinc.com/
>
> as I said last time I don't see the value of these changes.
>
> Since the changes are non-functional, then hopefully there should be
> no issues with them, however I really miss the point of adding 65
> lines of code for a questionable reason and at the price of increased
> complexity.
>
> Is there a good reason not to drop the series?
I think there is value in both functional decomposition and tidying up
code - for example removing circuitous if/elses in favour of more
discreet and easy to read functions, so I'm inclined to accept this series.
---
bod
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-25 12:14 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-25 10:34 [PATCH v3 0/2] media: qcom: camss: Re-structure camss_link_entities Vikram Sharma
2024-11-25 10:34 ` [PATCH v3 1/2] media: qcom: camss: reducing the repitious error message string Vikram Sharma
2024-11-25 12:10 ` Bryan O'Donoghue
2024-11-25 10:34 ` [PATCH v3 2/2] media: qcom: camss: Restructure camss_link_entities Vikram Sharma
2024-11-25 11:57 ` [PATCH v3 0/2] media: qcom: camss: Re-structure camss_link_entities Vladimir Zapolskiy
2024-11-25 12:14 ` Bryan O'Donoghue
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®