Re: [PATCH] soc: dove: constify reset_control_ops structures

From: Gregory CLEMENT
Date: Fri Jan 13 2017 - 11:37:00 EST


Hi Sebastian,

On lun., janv. 09 2017, Bhumika Goyal <bhumirks@xxxxxxxxx> wrote:

> Declare reset_control_ops as const as they are only stored in the ops
> field of a reset_controller_dev structure. This field is of type const
> struct reset_control_ops *, so reset_control_ops structures having this
> property can be declared as const.
> Done using Coccinelle:
>
> @r1 disable optional_qualifier@
> identifier i;
> position p;
> @@
> static struct reset_control_ops i@p={...};
>
> @ok1@
> identifier r1.i;
> position p;
> struct reset_controller_dev x;
> @@
> x.ops=&i@p;
>
> @bad@
> position p!={r1.p,ok1.p};
> identifier r1.i;
> @@
> i@p
>
> @depends on !bad disable optional_qualifier@
> identifier r1.i;
> @@
> +const
> struct reset_control_ops i;
>
> File size before: drivers/soc/dove/pmu.o
> text data bss dec hex filename
> 2447 112 16 2575 a0f drivers/soc/dove/pmu.o
>
> File size after: drivers/soc/dove/pmu.o
> text data bss dec hex filename
> 2479 80 16 2575 a0f drivers/soc/dove/pmu.o
>

If you agree with this patch I will apply it on mvebu/soc.

Thanks,

Gregory

> Signed-off-by: Bhumika Goyal <bhumirks@xxxxxxxxx>
> ---
> drivers/soc/dove/pmu.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/soc/dove/pmu.c b/drivers/soc/dove/pmu.c
> index 039374e..95d77ec 100644
> --- a/drivers/soc/dove/pmu.c
> +++ b/drivers/soc/dove/pmu.c
> @@ -87,7 +87,7 @@ static int pmu_reset_deassert(struct reset_controller_dev *rc, unsigned long id)
> return 0;
> }
>
> -static struct reset_control_ops pmu_reset_ops = {
> +static const struct reset_control_ops pmu_reset_ops = {
> .reset = pmu_reset_reset,
> .assert = pmu_reset_assert,
> .deassert = pmu_reset_deassert,
> --
> 1.9.1
>

--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com