media: atomisp_gmin_platform: Add enable-count to gmin_[v1p8|v2p8]_ctrl()
authorHans de Goede <hdegoede@redhat.com>
Sun, 16 Jan 2022 21:52:00 +0000 (22:52 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Tue, 8 Feb 2022 05:28:37 +0000 (06:28 +0100)
commit74bfe151d0aa06c76d35ae5ee02f6897240a2094
tree4d69461212cd2d8fab5e645450cc9ff1bccf72ca
parent9bad7640dcd64d7054601b0f43b52a0af387413f
media: atomisp_gmin_platform: Add enable-count to gmin_[v1p8|v2p8]_ctrl()

On devices with 2 sensors the 2 sensors may get probed simultaneously
and the v1p8 and v2p8 regulators are ususally shared between the
2 sensors.

This means that the probe() function of sensor 1 may end up calling
gmin_v1p8_ctrl(..., false) turning the regulator off while sensor 2's
probe() function still needs it to be on, causing the probe() of
sensor 2 to sometimes fail.

Fix this by adding an enable-count for both regulators and only
disabling them again when that goes to 0.

Note all this really should be converted to use the standard kernel
regulator framework, I have doing this on my long term TODO list,
this fix is only meant as a temporary workaround for the issue.

Link: https://lore.kernel.org/linux-media/20220116215204.307649-6-hdegoede@redhat.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c