* [PATCH] pinctrl: pinctrl-single: Avoid divisions in context save/restore
@ 2018-06-07 12:24 ` Geert Uytterhoeven
0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2018-06-07 12:24 UTC (permalink / raw)
To: Keerthy, Tony Lindgren, Haojian Zhuang, Linus Walleij
Cc: linux-gpio, linux-omap, Geert Uytterhoeven, linux-arm-kernel
The divisions (and multiplications) can be avoided by changing the loops
to use increments of mux_bytes instead of 1.
While at it, remove the unneeded casts when assigning void pointers.
This saves +100 bytes of kernel size on arm32/arm64.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Compile-tested only.
As the loops are now identical, the code could be made even smaller by
moving the switch() inside the loop, at the expense of readability.
---
drivers/pinctrl/pinctrl-single.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 9c3c00515aa0fe20..5de5dedb804928eb 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1593,19 +1593,19 @@ static int pcs_save_context(struct pcs_device *pcs)
switch (pcs->width) {
case 64:
- regsl = (u64 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- regsl[i] = pcs->read(pcs->base + i * mux_bytes);
+ regsl = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ *regsl++ = pcs->read(pcs->base + i);
break;
case 32:
- regsw = (u32 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- regsw[i] = pcs->read(pcs->base + i * mux_bytes);
+ regsw = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ *regsw++ = pcs->read(pcs->base + i);
break;
case 16:
- regshw = (u16 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- regshw[i] = pcs->read(pcs->base + i * mux_bytes);
+ regshw = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ *regshw++ = pcs->read(pcs->base + i);
break;
}
@@ -1623,19 +1623,19 @@ static void pcs_restore_context(struct pcs_device *pcs)
switch (pcs->width) {
case 64:
- regsl = (u64 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- pcs->write(regsl[i], pcs->base + i * mux_bytes);
+ regsl = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ pcs->write(*regsl++, pcs->base + i);
break;
case 32:
- regsw = (u32 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- pcs->write(regsw[i], pcs->base + i * mux_bytes);
+ regsw = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ pcs->write(*regsw++, pcs->base + i);
break;
case 16:
- regshw = (u16 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- pcs->write(regshw[i], pcs->base + i * mux_bytes);
+ regshw = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ pcs->write(*regshw++, pcs->base + i);
break;
}
}
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] pinctrl: pinctrl-single: Avoid divisions in context save/restore
@ 2018-06-07 12:24 ` Geert Uytterhoeven
0 siblings, 0 replies; 8+ messages in thread
From: Geert Uytterhoeven @ 2018-06-07 12:24 UTC (permalink / raw)
To: linux-arm-kernel
The divisions (and multiplications) can be avoided by changing the loops
to use increments of mux_bytes instead of 1.
While at it, remove the unneeded casts when assigning void pointers.
This saves +100 bytes of kernel size on arm32/arm64.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Compile-tested only.
As the loops are now identical, the code could be made even smaller by
moving the switch() inside the loop, at the expense of readability.
---
drivers/pinctrl/pinctrl-single.c | 36 ++++++++++++++++++------------------
1 file changed, 18 insertions(+), 18 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index 9c3c00515aa0fe20..5de5dedb804928eb 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1593,19 +1593,19 @@ static int pcs_save_context(struct pcs_device *pcs)
switch (pcs->width) {
case 64:
- regsl = (u64 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- regsl[i] = pcs->read(pcs->base + i * mux_bytes);
+ regsl = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ *regsl++ = pcs->read(pcs->base + i);
break;
case 32:
- regsw = (u32 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- regsw[i] = pcs->read(pcs->base + i * mux_bytes);
+ regsw = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ *regsw++ = pcs->read(pcs->base + i);
break;
case 16:
- regshw = (u16 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- regshw[i] = pcs->read(pcs->base + i * mux_bytes);
+ regshw = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ *regshw++ = pcs->read(pcs->base + i);
break;
}
@@ -1623,19 +1623,19 @@ static void pcs_restore_context(struct pcs_device *pcs)
switch (pcs->width) {
case 64:
- regsl = (u64 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- pcs->write(regsl[i], pcs->base + i * mux_bytes);
+ regsl = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ pcs->write(*regsl++, pcs->base + i);
break;
case 32:
- regsw = (u32 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- pcs->write(regsw[i], pcs->base + i * mux_bytes);
+ regsw = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ pcs->write(*regsw++, pcs->base + i);
break;
case 16:
- regshw = (u16 *)pcs->saved_vals;
- for (i = 0; i < pcs->size / mux_bytes; i++)
- pcs->write(regshw[i], pcs->base + i * mux_bytes);
+ regshw = pcs->saved_vals;
+ for (i = 0; i < pcs->size; i += mux_bytes)
+ pcs->write(*regshw++, pcs->base + i);
break;
}
}
--
2.7.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] pinctrl: pinctrl-single: Avoid divisions in context save/restore
2018-06-07 12:24 ` Geert Uytterhoeven
@ 2018-06-08 6:26 ` Tony Lindgren
-1 siblings, 0 replies; 8+ messages in thread
From: Tony Lindgren @ 2018-06-08 6:26 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Keerthy, Linus Walleij, linux-gpio, Haojian Zhuang, linux-omap,
linux-arm-kernel
* Geert Uytterhoeven <geert+renesas@glider.be> [180607 13:40]:
> The divisions (and multiplications) can be avoided by changing the loops
> to use increments of mux_bytes instead of 1.
> While at it, remove the unneeded casts when assigning void pointers.
>
> This saves +100 bytes of kernel size on arm32/arm64.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Compile-tested only.
Makes sense to me:
Acked-by: Tony Lindgren <tony@atomide.com>
Keerthy can you please test?
Regards,
Tony
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] pinctrl: pinctrl-single: Avoid divisions in context save/restore
@ 2018-06-08 6:26 ` Tony Lindgren
0 siblings, 0 replies; 8+ messages in thread
From: Tony Lindgren @ 2018-06-08 6:26 UTC (permalink / raw)
To: linux-arm-kernel
* Geert Uytterhoeven <geert+renesas@glider.be> [180607 13:40]:
> The divisions (and multiplications) can be avoided by changing the loops
> to use increments of mux_bytes instead of 1.
> While at it, remove the unneeded casts when assigning void pointers.
>
> This saves +100 bytes of kernel size on arm32/arm64.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Compile-tested only.
Makes sense to me:
Acked-by: Tony Lindgren <tony@atomide.com>
Keerthy can you please test?
Regards,
Tony
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] pinctrl: pinctrl-single: Avoid divisions in context save/restore
2018-06-08 6:26 ` Tony Lindgren
@ 2018-06-08 6:48 ` Keerthy
-1 siblings, 0 replies; 8+ messages in thread
From: Keerthy @ 2018-06-08 6:48 UTC (permalink / raw)
To: Tony Lindgren, Geert Uytterhoeven
Cc: linux-gpio, Linus Walleij, linux-omap, Haojian Zhuang, linux-arm-kernel
On Friday 08 June 2018 11:56 AM, Tony Lindgren wrote:
> * Geert Uytterhoeven <geert+renesas@glider.be> [180607 13:40]:
>> The divisions (and multiplications) can be avoided by changing the loops
>> to use increments of mux_bytes instead of 1.
>> While at it, remove the unneeded casts when assigning void pointers.
>>
>> This saves +100 bytes of kernel size on arm32/arm64.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>> ---
>> Compile-tested only.
>
> Makes sense to me:
>
> Acked-by: Tony Lindgren <tony@atomide.com>
>
> Keerthy can you please test?
Tested on AM437x-gp-evm for Deep Sleep0.
Tested-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>
Thanks Geert!
>
> Regards,
>
> Tony
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] pinctrl: pinctrl-single: Avoid divisions in context save/restore
@ 2018-06-08 6:48 ` Keerthy
0 siblings, 0 replies; 8+ messages in thread
From: Keerthy @ 2018-06-08 6:48 UTC (permalink / raw)
To: linux-arm-kernel
On Friday 08 June 2018 11:56 AM, Tony Lindgren wrote:
> * Geert Uytterhoeven <geert+renesas@glider.be> [180607 13:40]:
>> The divisions (and multiplications) can be avoided by changing the loops
>> to use increments of mux_bytes instead of 1.
>> While at it, remove the unneeded casts when assigning void pointers.
>>
>> This saves +100 bytes of kernel size on arm32/arm64.
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>> ---
>> Compile-tested only.
>
> Makes sense to me:
>
> Acked-by: Tony Lindgren <tony@atomide.com>
>
> Keerthy can you please test?
Tested on AM437x-gp-evm for Deep Sleep0.
Tested-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>
Thanks Geert!
>
> Regards,
>
> Tony
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] pinctrl: pinctrl-single: Avoid divisions in context save/restore
2018-06-07 12:24 ` Geert Uytterhoeven
@ 2018-06-14 8:33 ` Linus Walleij
-1 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2018-06-14 8:33 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Tony Lindgren, Keerthy, open list:GPIO SUBSYSTEM, Haojian Zhuang,
Linux-OMAP, Linux ARM
On Thu, Jun 7, 2018 at 2:24 PM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> The divisions (and multiplications) can be avoided by changing the loops
> to use increments of mux_bytes instead of 1.
> While at it, remove the unneeded casts when assigning void pointers.
>
> This saves +100 bytes of kernel size on arm32/arm64.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Patch applied for v4.19.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] pinctrl: pinctrl-single: Avoid divisions in context save/restore
@ 2018-06-14 8:33 ` Linus Walleij
0 siblings, 0 replies; 8+ messages in thread
From: Linus Walleij @ 2018-06-14 8:33 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Jun 7, 2018 at 2:24 PM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> The divisions (and multiplications) can be avoided by changing the loops
> to use increments of mux_bytes instead of 1.
> While at it, remove the unneeded casts when assigning void pointers.
>
> This saves +100 bytes of kernel size on arm32/arm64.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Patch applied for v4.19.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-06-14 8:33 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-07 12:24 [PATCH] pinctrl: pinctrl-single: Avoid divisions in context save/restore Geert Uytterhoeven
2018-06-07 12:24 ` Geert Uytterhoeven
2018-06-08 6:26 ` Tony Lindgren
2018-06-08 6:26 ` Tony Lindgren
2018-06-08 6:48 ` Keerthy
2018-06-08 6:48 ` Keerthy
2018-06-14 8:33 ` Linus Walleij
2018-06-14 8:33 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.