Re: [PATCH] regulator: core: Only increment use_count when enable_count changes
From: Mark Brown
Date: Fri Nov 03 2023 - 08:51:30 EST
On Fri, Nov 03, 2023 at 03:42:31PM +0800, Rui Zhang wrote:
> The use_count of a regulator should only be incremented when the
> enable_count changes from 0 to 1. Similarly, the use_count should
> only be decremented when the enable_count changes from 1 to 0.
Why?
> In the previous implementation, use_count was sometimes decremented
> to 0 when some consumer called unbalanced disable,
> leading to unexpected disable even the regulator is enabled by
> other consumers. With this change, the use_count accurately reflects
> the number of users which the regulator is enabled.
If a consumer does an unbalanced disable the consumer is buggy and the
reference counting is wrong overall. The bug is in the consumer driver
doing the unbalanced disable.
Attachment:
signature.asc
Description: PGP signature