2022-11-18 09:42:34

by Umang Jain

[permalink] [raw]
Subject: [PATCH v2 2/3] vc04_services: mmal-vchiq: Use bool for vchiq_mmal_component.in_use

In commit 7967656ffbfa ("coding-style: Clarify the expectations around
bool") the check to dis-allow bool structure members was removed from
checkpatch.pl. It promotes bool structure members to store boolean
values. This enhances code readability.

Signed-off-by: Umang Jain <[email protected]>
---
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 6 +++---
drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
index 4abb6178cb9f..294b184d4a49 100644
--- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
@@ -1648,7 +1648,7 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
for (idx = 0; idx < VCHIQ_MMAL_MAX_COMPONENTS; idx++) {
if (!instance->component[idx].in_use) {
component = &instance->component[idx];
- component->in_use = 1;
+ component->in_use = true;
break;
}
}
@@ -1724,7 +1724,7 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
destroy_component(instance, component);
unlock:
if (component)
- component->in_use = 0;
+ component->in_use = false;
mutex_unlock(&instance->vchiq_mutex);

return ret;
@@ -1747,7 +1747,7 @@ int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,

ret = destroy_component(instance, component);

- component->in_use = 0;
+ component->in_use = false;

mutex_unlock(&instance->vchiq_mutex);

diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
index 6d984cf5a83a..09f030919d4e 100644
--- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
+++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
@@ -82,7 +82,7 @@ struct vchiq_mmal_port {
};

struct vchiq_mmal_component {
- u32 in_use:1;
+ bool in_use;
bool enabled;
u32 handle; /* VideoCore handle for component */
u32 inputs; /* Number of input ports */
--
2.38.1



2022-11-18 10:43:49

by Kieran Bingham

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] vc04_services: mmal-vchiq: Use bool for vchiq_mmal_component.in_use

Quoting Umang Jain (2022-11-18 08:42:43)
> In commit 7967656ffbfa ("coding-style: Clarify the expectations around
> bool") the check to dis-allow bool structure members was removed from
> checkpatch.pl. It promotes bool structure members to store boolean
> values. This enhances code readability.

This only talks about 7967656ffbfa as I can interpret it. A sentence
here describing what we're going to do about it in /this/ patch would be
clearer as a second paragraph:

"""
Convert the remaining bit-field storage for 'in-use' to a bool and use
it accordingly.
"""

But that's trivial and not worth a v3 specifically. (unless anyone
applying this wants to add it).

Reviewed-by: Kieran Bingham <[email protected]>

>
> Signed-off-by: Umang Jain <[email protected]>
> ---
> drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 6 +++---
> drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> index 4abb6178cb9f..294b184d4a49 100644
> --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> @@ -1648,7 +1648,7 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
> for (idx = 0; idx < VCHIQ_MMAL_MAX_COMPONENTS; idx++) {
> if (!instance->component[idx].in_use) {
> component = &instance->component[idx];
> - component->in_use = 1;
> + component->in_use = true;
> break;
> }
> }
> @@ -1724,7 +1724,7 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
> destroy_component(instance, component);
> unlock:
> if (component)
> - component->in_use = 0;
> + component->in_use = false;
> mutex_unlock(&instance->vchiq_mutex);
>
> return ret;
> @@ -1747,7 +1747,7 @@ int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,
>
> ret = destroy_component(instance, component);
>
> - component->in_use = 0;
> + component->in_use = false;
>
> mutex_unlock(&instance->vchiq_mutex);
>
> diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
> index 6d984cf5a83a..09f030919d4e 100644
> --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
> +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
> @@ -82,7 +82,7 @@ struct vchiq_mmal_port {
> };
>
> struct vchiq_mmal_component {
> - u32 in_use:1;
> + bool in_use;
> bool enabled;
> u32 handle; /* VideoCore handle for component */
> u32 inputs; /* Number of input ports */
> --
> 2.38.1
>

2022-11-18 19:27:50

by Dave Stevenson

[permalink] [raw]
Subject: Re: [PATCH v2 2/3] vc04_services: mmal-vchiq: Use bool for vchiq_mmal_component.in_use

Hi Umang & Kieran

On Fri, 18 Nov 2022 at 10:30, Kieran Bingham
<[email protected]> wrote:
>
> Quoting Umang Jain (2022-11-18 08:42:43)
> > In commit 7967656ffbfa ("coding-style: Clarify the expectations around
> > bool") the check to dis-allow bool structure members was removed from
> > checkpatch.pl. It promotes bool structure members to store boolean
> > values. This enhances code readability.
>
> This only talks about 7967656ffbfa as I can interpret it. A sentence
> here describing what we're going to do about it in /this/ patch would be
> clearer as a second paragraph:
>
> """
> Convert the remaining bit-field storage for 'in-use' to a bool and use
> it accordingly.
> """
>
> But that's trivial and not worth a v3 specifically. (unless anyone
> applying this wants to add it).

Totally agree.

> Reviewed-by: Kieran Bingham <[email protected]>

Reviewed-by: Dave Stevenson <[email protected]>

> >
> > Signed-off-by: Umang Jain <[email protected]>
> > ---
> > drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 6 +++---
> > drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h | 2 +-
> > 2 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> > index 4abb6178cb9f..294b184d4a49 100644
> > --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> > +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> > @@ -1648,7 +1648,7 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
> > for (idx = 0; idx < VCHIQ_MMAL_MAX_COMPONENTS; idx++) {
> > if (!instance->component[idx].in_use) {
> > component = &instance->component[idx];
> > - component->in_use = 1;
> > + component->in_use = true;
> > break;
> > }
> > }
> > @@ -1724,7 +1724,7 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
> > destroy_component(instance, component);
> > unlock:
> > if (component)
> > - component->in_use = 0;
> > + component->in_use = false;
> > mutex_unlock(&instance->vchiq_mutex);
> >
> > return ret;
> > @@ -1747,7 +1747,7 @@ int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,
> >
> > ret = destroy_component(instance, component);
> >
> > - component->in_use = 0;
> > + component->in_use = false;
> >
> > mutex_unlock(&instance->vchiq_mutex);
> >
> > diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
> > index 6d984cf5a83a..09f030919d4e 100644
> > --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
> > +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.h
> > @@ -82,7 +82,7 @@ struct vchiq_mmal_port {
> > };
> >
> > struct vchiq_mmal_component {
> > - u32 in_use:1;
> > + bool in_use;
> > bool enabled;
> > u32 handle; /* VideoCore handle for component */
> > u32 inputs; /* Number of input ports */
> > --
> > 2.38.1
> >