Commit 7993d3a
regulator: core: Only increment use_count when enable_count changes
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.
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.
This should make things more robust in the case where a consumer does
leak references.
Signed-off-by: Rui Zhang <zr.zhang@vivo.com>
Link: https://lore.kernel.org/r/20231103074231.8031-1-zr.zhang@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>1 parent c986968 commit 7993d3a
1 file changed
Lines changed: 30 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2918 | 2918 | | |
2919 | 2919 | | |
2920 | 2920 | | |
2921 | | - | |
| 2921 | + | |
| 2922 | + | |
2922 | 2923 | | |
2923 | 2924 | | |
2924 | 2925 | | |
| |||
2993 | 2994 | | |
2994 | 2995 | | |
2995 | 2996 | | |
2996 | | - | |
| 2997 | + | |
2997 | 2998 | | |
2998 | 2999 | | |
2999 | 3000 | | |
3000 | | - | |
3001 | | - | |
3002 | | - | |
3003 | | - | |
3004 | | - | |
3005 | | - | |
3006 | | - | |
3007 | | - | |
3008 | | - | |
3009 | | - | |
3010 | | - | |
3011 | | - | |
3012 | | - | |
3013 | | - | |
3014 | | - | |
3015 | | - | |
3016 | | - | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
3017 | 3024 | | |
3018 | | - | |
3019 | 3025 | | |
3020 | | - | |
3021 | | - | |
3022 | | - | |
3023 | 3026 | | |
3024 | | - | |
3025 | | - | |
3026 | | - | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
3027 | 3031 | | |
3028 | 3032 | | |
3029 | 3033 | | |
| |||
0 commit comments