Message ID | 20230823104444.1954663-11-bryan.odonoghue@linaro.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: qcom: camss: Add parameter passing to remove several outstanding bugs | expand |
On 23.08.2023 12:44, Bryan O'Donoghue wrote: > The number of Video Front End - VFE or Image Front End - IFE supported > with new SoCs can vary both for the full and lite cases. > > For example sdm845 has one vfe_lite and two vfe interfaces with the vfe > clock called simply "vfe_lite" with no integer postfix. sc8280xp has four > vfe and four vfe lite blocks. > > We need to support the following clock name formats > > - vfeN > - vfe_liteN > - vfe_lite > > with N being any reasonably sized integer. > > There are two sites in this code which need to do the same thing, > constructing and matching strings with the pattern above, so encapsulate > the logic in one function. > > Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > --- > drivers/media/platform/qcom/camss/camss-vfe.c | 22 ++++++++++++++----- > 1 file changed, 16 insertions(+), 6 deletions(-) > > diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c > index 8f48401e31cd3..73380e75dbb22 100644 > --- a/drivers/media/platform/qcom/camss/camss-vfe.c > +++ b/drivers/media/platform/qcom/camss/camss-vfe.c > @@ -437,6 +437,20 @@ void vfe_isr_reset_ack(struct vfe_device *vfe) > complete(&vfe->reset_complete); > } > > +static int vfe_match_clock_names(struct vfe_device *vfe, > + struct camss_clock *clock) > +{ > + char vfe_name[CAMSS_RES_MAX]; > + char vfe_lite_name[CAMSS_RES_MAX]; I don't think using the "number of resources" define to define the maximum length of a resource name is a good idea. Perhaps we can do: char vfe_name[5]; /* "vfeX\0" */ char vfe_lite_name[10]; /* "vfe_liteX\0" */ if index > 9 return INCREASE_THE_BUFFER Konrad
On 26/08/2023 11:08, Konrad Dybcio wrote: > On 23.08.2023 12:44, Bryan O'Donoghue wrote: >> The number of Video Front End - VFE or Image Front End - IFE supported >> with new SoCs can vary both for the full and lite cases. >> >> For example sdm845 has one vfe_lite and two vfe interfaces with the vfe >> clock called simply "vfe_lite" with no integer postfix. sc8280xp has four >> vfe and four vfe lite blocks. >> >> We need to support the following clock name formats >> >> - vfeN >> - vfe_liteN >> - vfe_lite >> >> with N being any reasonably sized integer. >> >> There are two sites in this code which need to do the same thing, >> constructing and matching strings with the pattern above, so encapsulate >> the logic in one function. >> >> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> >> --- >> drivers/media/platform/qcom/camss/camss-vfe.c | 22 ++++++++++++++----- >> 1 file changed, 16 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c >> index 8f48401e31cd3..73380e75dbb22 100644 >> --- a/drivers/media/platform/qcom/camss/camss-vfe.c >> +++ b/drivers/media/platform/qcom/camss/camss-vfe.c >> @@ -437,6 +437,20 @@ void vfe_isr_reset_ack(struct vfe_device *vfe) >> complete(&vfe->reset_complete); >> } >> >> +static int vfe_match_clock_names(struct vfe_device *vfe, >> + struct camss_clock *clock) >> +{ >> + char vfe_name[CAMSS_RES_MAX]; >> + char vfe_lite_name[CAMSS_RES_MAX]; > I don't think using the "number of resources" define to define > the maximum length of a resource name is a good idea. > > Perhaps we can do: > > char vfe_name[5]; /* "vfeX\0" */ > char vfe_lite_name[10]; /* "vfe_liteX\0" */ > > if index > 9 > return INCREASE_THE_BUFFER > > Konrad I'm reluctant to fix only the VFE clock name string length in isolation, plus I'm aware of another patchset coming down the line from other people which will likely address the string length stuff. But in the interests of consensus I will restrict the length in the helper. --- bod
On Wed, Aug 23, 2023 at 11:44:39AM +0100, Bryan O'Donoghue wrote: > The number of Video Front End - VFE or Image Front End - IFE supported > with new SoCs can vary both for the full and lite cases. > > For example sdm845 has one vfe_lite and two vfe interfaces with the vfe > clock called simply "vfe_lite" with no integer postfix. sc8280xp has four > vfe and four vfe lite blocks. > > We need to support the following clock name formats > > - vfeN > - vfe_liteN > - vfe_lite > > with N being any reasonably sized integer. > > There are two sites in this code which need to do the same thing, > constructing and matching strings with the pattern above, so encapsulate > the logic in one function. > > Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> > --- > drivers/media/platform/qcom/camss/camss-vfe.c | 22 ++++++++++++++----- > 1 file changed, 16 insertions(+), 6 deletions(-) > > diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c > index 8f48401e31cd3..73380e75dbb22 100644 > --- a/drivers/media/platform/qcom/camss/camss-vfe.c > +++ b/drivers/media/platform/qcom/camss/camss-vfe.c > @@ -437,6 +437,20 @@ void vfe_isr_reset_ack(struct vfe_device *vfe) > complete(&vfe->reset_complete); > } > > +static int vfe_match_clock_names(struct vfe_device *vfe, > + struct camss_clock *clock) > +{ > + char vfe_name[CAMSS_RES_MAX]; > + char vfe_lite_name[CAMSS_RES_MAX]; > + > + snprintf(vfe_name, sizeof(vfe_name), "vfe%d", vfe->id); > + snprintf(vfe_lite_name, sizeof(vfe_lite_name), "vfe_lite%d", vfe->id); > + > + return (!strcmp(clock->name, vfe_name) || > + !strcmp(clock->name, vfe_lite_name) || > + !strcmp(clock->name, "vfe_lite")); The code below will match "vfe0", "vfe1" and "vfe_lite", which the code here matches "vfe%d", "vfe_life%d" and "vfe_lite". The commit message doesn't explain why you can restrict the clock name to "vfe%d" instead of matching both "vfe0" and "vfe1". I could try to guess, but it's better to clarify it in the commit message. > +} > + > /* > * vfe_set_clock_rates - Calculate and set clock rates on VFE module > * @vfe: VFE device > @@ -460,9 +474,7 @@ static int vfe_set_clock_rates(struct vfe_device *vfe) > for (i = 0; i < vfe->nclocks; i++) { > struct camss_clock *clock = &vfe->clock[i]; > > - if (!strcmp(clock->name, "vfe0") || > - !strcmp(clock->name, "vfe1") || > - !strcmp(clock->name, "vfe_lite")) { > + if (vfe_match_clock_names(vfe, clock)) { > u64 min_rate = 0; > long rate; > > @@ -543,9 +555,7 @@ static int vfe_check_clock_rates(struct vfe_device *vfe) > for (i = 0; i < vfe->nclocks; i++) { > struct camss_clock *clock = &vfe->clock[i]; > > - if (!strcmp(clock->name, "vfe0") || > - !strcmp(clock->name, "vfe1") || > - !strcmp(clock->name, "vfe_lite")) { > + if (vfe_match_clock_names(vfe, clock)) { > u64 min_rate = 0; > unsigned long rate; >
diff --git a/drivers/media/platform/qcom/camss/camss-vfe.c b/drivers/media/platform/qcom/camss/camss-vfe.c index 8f48401e31cd3..73380e75dbb22 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe.c +++ b/drivers/media/platform/qcom/camss/camss-vfe.c @@ -437,6 +437,20 @@ void vfe_isr_reset_ack(struct vfe_device *vfe) complete(&vfe->reset_complete); } +static int vfe_match_clock_names(struct vfe_device *vfe, + struct camss_clock *clock) +{ + char vfe_name[CAMSS_RES_MAX]; + char vfe_lite_name[CAMSS_RES_MAX]; + + snprintf(vfe_name, sizeof(vfe_name), "vfe%d", vfe->id); + snprintf(vfe_lite_name, sizeof(vfe_lite_name), "vfe_lite%d", vfe->id); + + return (!strcmp(clock->name, vfe_name) || + !strcmp(clock->name, vfe_lite_name) || + !strcmp(clock->name, "vfe_lite")); +} + /* * vfe_set_clock_rates - Calculate and set clock rates on VFE module * @vfe: VFE device @@ -460,9 +474,7 @@ static int vfe_set_clock_rates(struct vfe_device *vfe) for (i = 0; i < vfe->nclocks; i++) { struct camss_clock *clock = &vfe->clock[i]; - if (!strcmp(clock->name, "vfe0") || - !strcmp(clock->name, "vfe1") || - !strcmp(clock->name, "vfe_lite")) { + if (vfe_match_clock_names(vfe, clock)) { u64 min_rate = 0; long rate; @@ -543,9 +555,7 @@ static int vfe_check_clock_rates(struct vfe_device *vfe) for (i = 0; i < vfe->nclocks; i++) { struct camss_clock *clock = &vfe->clock[i]; - if (!strcmp(clock->name, "vfe0") || - !strcmp(clock->name, "vfe1") || - !strcmp(clock->name, "vfe_lite")) { + if (vfe_match_clock_names(vfe, clock)) { u64 min_rate = 0; unsigned long rate;
The number of Video Front End - VFE or Image Front End - IFE supported with new SoCs can vary both for the full and lite cases. For example sdm845 has one vfe_lite and two vfe interfaces with the vfe clock called simply "vfe_lite" with no integer postfix. sc8280xp has four vfe and four vfe lite blocks. We need to support the following clock name formats - vfeN - vfe_liteN - vfe_lite with N being any reasonably sized integer. There are two sites in this code which need to do the same thing, constructing and matching strings with the pattern above, so encapsulate the logic in one function. Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org> --- drivers/media/platform/qcom/camss/camss-vfe.c | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-)