Re: [PATCH v2] staging: most: dim2: use atomic_t for channel state counters

From: Dan Carpenter

Date: Wed Nov 18 2026 - 03:58:32 EST


On Tue, Nov 17, 2026 at 04:06:06PM -0800, Maximo Manriquez Lizarraga via B4 Relay wrote:
> @@ -682,8 +682,9 @@ static u8 channel_service(struct dim_channel *ch)
> {
> struct int_ch_state *const state = &ch->state;
>
> - if (state->service_counter != state->request_counter) {
> - state->service_counter++;
> + if (atomic_read(&state->service_counter) !=
> + atomic_read(&state->request_counter)) {
> + atomic_inc(&state->service_counter);


This isn't the right way to do it, because it's no longer atomic if
you do it as two steps.

regards,
dan carpenter