summaryrefslogtreecommitdiff
path: root/drivers/media/platform/nxp/imx-mipi-csis.c
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-03-11 16:29:03 +0300
committerMauro Carvalho Chehab <mchehab@kernel.org>2022-04-24 11:05:23 +0300
commitc22afddcf7c5001c00010c38f67689cf19e5fb65 (patch)
treea85a42df89d5d214408956268aae39cbd98e24a8 /drivers/media/platform/nxp/imx-mipi-csis.c
parent2eab8739b6f6b3076a93d4b57f1b7cc92253b7c3 (diff)
downloadlinux-c22afddcf7c5001c00010c38f67689cf19e5fb65.tar.xz
media: imx: imx-mipi-csis: Simplify runtime PM implementation
The runtime PM resume handler is guaranteed to be called on a suspended device, and the suspend handler on a resumed device. The implementation can thus be simplified. While at it, rename the mipi_csis_device state field to powered, as the now state contains a single flag only. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Diffstat (limited to 'drivers/media/platform/nxp/imx-mipi-csis.c')
-rw-r--r--drivers/media/platform/nxp/imx-mipi-csis.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c
index 1b7390bba3a0..f4b32edd8dfd 100644
--- a/drivers/media/platform/nxp/imx-mipi-csis.c
+++ b/drivers/media/platform/nxp/imx-mipi-csis.c
@@ -243,10 +243,6 @@
#define MIPI_CSI2_DATA_TYPE_RAW14 0x2d
#define MIPI_CSI2_DATA_TYPE_USER(x) (0x30 + (x))
-enum {
- ST_POWERED = 1,
-};
-
struct mipi_csis_event {
bool debug;
u32 mask;
@@ -326,10 +322,10 @@ struct mipi_csis_device {
u32 hs_settle;
u32 clk_settle;
- struct mutex lock; /* Protect csis_fmt, format_mbus and state */
+ struct mutex lock; /* Protect csis_fmt, format_mbus and powered */
const struct csis_pix_format *csis_fmt;
struct v4l2_mbus_framefmt format_mbus[CSIS_PADS_NUM];
- u32 state;
+ bool powered;
spinlock_t slock; /* Protect events */
struct mipi_csis_event events[MIPI_CSIS_NUM_EVENTS];
@@ -1161,7 +1157,7 @@ static int mipi_csis_log_status(struct v4l2_subdev *sd)
mutex_lock(&csis->lock);
mipi_csis_log_counters(csis, true);
- if (csis->debug.enable && (csis->state & ST_POWERED))
+ if (csis->debug.enable && csis->powered)
mipi_csis_dump_regs(csis);
mutex_unlock(&csis->lock);
@@ -1321,13 +1317,14 @@ static int __maybe_unused mipi_csis_runtime_suspend(struct device *dev)
int ret = 0;
mutex_lock(&csis->lock);
- if (csis->state & ST_POWERED) {
- ret = mipi_csis_phy_disable(csis);
- if (ret)
- goto unlock;
- mipi_csis_clk_disable(csis);
- csis->state &= ~ST_POWERED;
- }
+
+ ret = mipi_csis_phy_disable(csis);
+ if (ret)
+ goto unlock;
+
+ mipi_csis_clk_disable(csis);
+
+ csis->powered = false;
unlock:
mutex_unlock(&csis->lock);
@@ -1343,14 +1340,13 @@ static int __maybe_unused mipi_csis_runtime_resume(struct device *dev)
mutex_lock(&csis->lock);
- if (!(csis->state & ST_POWERED)) {
- ret = mipi_csis_phy_enable(csis);
- if (ret)
- goto unlock;
+ ret = mipi_csis_phy_enable(csis);
+ if (ret)
+ goto unlock;
- csis->state |= ST_POWERED;
- mipi_csis_clk_enable(csis);
- }
+ mipi_csis_clk_enable(csis);
+
+ csis->powered = true;
unlock:
mutex_unlock(&csis->lock);