Re: [PATCH 25/52] m68k: apollo: Replace set but not used variable by READ_ONCE()

Finn Thain
2023-09-07T23:37:07Z

On Thu, 7 Sep 2023, Geert Uytterhoeven wrote:

> --- a/arch/m68k/apollo/config.c
> +++ b/arch/m68k/apollo/config.c
> @@ -146,13 +146,11 @@ void __init config_apollo(void)
>
> irqreturn_t dn_timer_int(int irq, void *dev_id)
> {
> - volatile unsigned char x;
> -
> legacy_timer_tick(1);
> timer_heartbeat();
>
> - x = *(volatile unsigned char *)(apollo_timer + 3);
> - x = *(volatile unsigned char *)(apollo_timer + 5);
> + READ_ONCE(*(volatile unsigned char *)(apollo_timer + 3));
> + READ_ONCE(*(volatile unsigned char *)(apollo_timer + 5));
>
> return IRQ_HANDLED;
> }
>

I believe the volatile cast is redundant here, as READ_ONCE does that.
Perhaps the remaining cast could be deduplicated like so:

- volatile unsigned char x;
+ unsigned char *at = (unsigned char *)apollo_timer;

legacy_timer_tick(1);
timer_heartbeat();

- x = *(volatile unsigned char *)(apollo_timer + 3);
- x = *(volatile unsigned char *)(apollo_timer + 5);
+ READ_ONCE(*(at + 3));
+ READ_ONCE(*(at + 5));