media: atomisp: Move calling of css_[un]init() to power_on()/_off()
authorHans de Goede <hdegoede@redhat.com>
Mon, 14 Nov 2022 15:55:38 +0000 (15:55 +0000)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Fri, 25 Nov 2022 08:24:07 +0000 (08:24 +0000)
atomisp_css_init() is always called after calling atomisp_power_on()
either directly or through getting a runtime-pm reference.

Likewise atomisp_css_uninit() is always called after calling
atomisp_power_off().

Move the call site of these 2 functions to inside atomisp_power_on() /
atomisp_power_off() to make this more explicit.

Note this makes atomisp_reset() also set isp_fatal_error on
atomisp_power_on() errors, where as before it only did this on
atomisp_css_init() errors. This behavior change is for the better,
since power-on failing is pretty fatal too.

Reviewed-by: Andy Shevchenko <andy@kernel.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/staging/media/atomisp/pci/atomisp_cmd.c
drivers/staging/media/atomisp/pci/atomisp_fops.c
drivers/staging/media/atomisp/pci/atomisp_v4l2.c

index 65a42034032b30bc3b1033b572f7cc9b18c0b1f6..26f504ff4b6870f16e740c035e9facd15beb31e1 100644 (file)
@@ -302,18 +302,16 @@ int atomisp_reset(struct atomisp_device *isp)
        int ret = 0;
 
        dev_dbg(isp->dev, "%s\n", __func__);
-       atomisp_css_uninit(isp);
+
        ret = atomisp_power_off(isp->dev);
        if (ret < 0)
                dev_err(isp->dev, "atomisp_power_off failed, %d\n", ret);
 
        ret = atomisp_power_on(isp->dev);
-       if (ret < 0)
+       if (ret < 0) {
                dev_err(isp->dev, "atomisp_power_on failed, %d\n", ret);
-
-       ret = atomisp_css_init(isp);
-       if (ret)
                isp->isp_fatal_error = true;
+       }
 
        return ret;
 }
index b627c3110ca77c147e95b6fd61aed2f8a55348d2..acea7492847d8ba98c170602d99eb168468bf9b7 100644 (file)
@@ -808,13 +808,6 @@ static int atomisp_open(struct file *file)
                goto error;
        }
 
-       /* Init ISP */
-       if (atomisp_css_init(isp)) {
-               ret = -EINVAL;
-               /* Need to clean up CSS init if it fails. */
-               goto css_error;
-       }
-
        atomisp_dev_init_struct(isp);
 
        ret = v4l2_subdev_call(isp->flash, core, s_power, 1);
@@ -839,7 +832,6 @@ done:
        return 0;
 
 css_error:
-       atomisp_css_uninit(isp);
        pm_runtime_put(vdev->v4l2_dev->dev);
 error:
        mutex_unlock(&isp->mutex);
@@ -908,7 +900,6 @@ static int atomisp_release(struct file *file)
                goto done;
 
        atomisp_destroy_pipes_stream_force(asd);
-       atomisp_css_uninit(isp);
 
        if (defer_fw_load) {
                ia_css_unload_firmware();
index f670517bc1415ac8c0a6e505cb38855dd6da8980..f46046d7ef50a920471a488025319fa089dff557 100644 (file)
@@ -726,6 +726,8 @@ int atomisp_power_off(struct device *dev)
                                     dev_get_drvdata(dev);
        int ret;
 
+       atomisp_css_uninit(isp);
+
        ret = atomisp_mrfld_pre_power_down(isp);
        if (ret)
                return ret;
@@ -761,7 +763,8 @@ int atomisp_power_on(struct device *dev)
                atomisp_restore_iunit_reg(isp);
 
        atomisp_freq_scaling(isp, ATOMISP_DFS_MODE_LOW, true);
-       return 0;
+
+       return atomisp_css_init(isp);
 }
 
 static int __maybe_unused atomisp_suspend(struct device *dev)