media: atomisp: Fix probe()/remove() power-management
Fix probe()/remove() power-management:
-Currently the driver uses pm_runtime_put_noidle() and relies on
userspace to open + close the /dev/video# node at least once to
actually turn the ISP off. Replace the pm_runtime_put_noidle()
with pm_runtime_put_sync() to make sure that the device is turned
off without relying on userspace for this.
This also ensures that atomisp_css_init() is run (by atomisp_power_on())
if the first userspace process opening /dev/video# wants to do more then
just query the v4l2-caps.
As part of this change move the pm setup code in probe() to just before
calling v4l2_async_nf_register() which registers the /dev/* nodes, so
that the device is left on for the entirety of the probe() function.
-Remove the turning off of the atomisp from the exit-error path,
the PCI subsystem and subsequent probe() attempts expect the device
to be in the on state when probe() fails.
This also fixes the atomisp driver causing the system to hang / freeze
when its firmware is missing. This freeze is caused by an unidentified
bug in the power-off on exit-error code which is now removed.
-Make sure that remove() properly powers on the device by replacing
pm_runtime_get_noresume() with pm_runtime_get_sync. The PCI subsystem
and subsequent probe() attempts expect the device to be in the on state
after unbinding the driver.
-Note this also swaps the order of put()/allow() and forbid()/get()
so that the sync versions actually work by calling allow() before put()
and forbid() after get()
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>