pinctrl: pinctrl-single: Avoid divisions in context save/restore

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>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Geert Uytterhoeven 2018-06-07 14:24:34 +02:00 committed by Linus Walleij
parent 7547b5969e
commit 7d71b5f4b2
1 changed files with 18 additions and 18 deletions

View File

@ -1595,19 +1595,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;
}
@ -1625,19 +1625,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;
}
}