Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7fb3af7a authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: vidc: Convert macros into inline functions"

parents dbe4b031 2f3a39a9
Loading
Loading
Loading
Loading
+25 −19
Original line number Diff line number Diff line
@@ -76,16 +76,6 @@ struct tzbsp_video_set_state_req {
	u32 spare; /*reserved for future, should be zero*/
};

#define VENUS_SET_STATE(__device, __state) {\
		mutex_lock(&(__device)->write_lock);	\
		mutex_lock(&(__device)->read_lock);		\
		(__device)->state = __state;			\
		mutex_unlock(&(__device)->write_lock);	\
		mutex_unlock(&(__device)->read_lock); }

#define IS_VENUS_IN_VALID_STATE(__device) (\
		(__device)->state != VENUS_STATE_DEINIT)

static int venus_hfi_power_enable(void *dev);

static inline int venus_hfi_clk_gating_off(struct venus_hfi_device *device);
@@ -96,6 +86,22 @@ static inline int venus_hfi_prepare_enable_clks(
static inline void venus_hfi_disable_unprepare_clks(
	struct venus_hfi_device *device);

static inline void venus_hfi_set_state(struct venus_hfi_device *device,
		enum venus_hfi_state state)
{
	mutex_lock(&device->write_lock);
	mutex_lock(&device->read_lock);
	device->state = state;
	mutex_unlock(&device->write_lock);
	mutex_unlock(&device->read_lock);
}

static inline bool venus_hfi_core_in_valid_state(
		struct venus_hfi_device *device)
{
	return device->state != VENUS_STATE_DEINIT;
}

static void venus_hfi_dump_packet(u8 *packet)
{
	u32 c = 0, packet_size = *(u32 *)packet;
@@ -1523,8 +1529,8 @@ static int venus_hfi_iface_cmdq_write_nolock(struct venus_hfi_device *device,
	}
	WARN(!mutex_is_locked(&device->write_lock),
			"Cmd queue write lock must be acquired");
	if (!IS_VENUS_IN_VALID_STATE(device)) {
		dprintk(VIDC_ERR, "%s - fw not in init state\n", __func__);
	if (!venus_hfi_core_in_valid_state(device)) {
		dprintk(VIDC_DBG, "%s - fw not in init state\n", __func__);
		result = -EINVAL;
		goto err_q_null;
	}
@@ -1580,8 +1586,8 @@ static int venus_hfi_iface_msgq_read(struct venus_hfi_device *device, void *pkt)
		return -EINVAL;
	}
	mutex_lock(&device->read_lock);
	if (!IS_VENUS_IN_VALID_STATE(device)) {
		dprintk(VIDC_ERR, "%s - fw not in init state\n", __func__);
	if (!venus_hfi_core_in_valid_state(device)) {
		dprintk(VIDC_DBG, "%s - fw not in init state\n", __func__);
		rc = -EINVAL;
		goto read_error_null;
	}
@@ -1631,8 +1637,8 @@ static int venus_hfi_iface_dbgq_read(struct venus_hfi_device *device, void *pkt)
		return -EINVAL;
	}
	mutex_lock(&device->read_lock);
	if (!IS_VENUS_IN_VALID_STATE(device)) {
		dprintk(VIDC_ERR, "%s - fw not in init state\n", __func__);
	if (!venus_hfi_core_in_valid_state(device)) {
		dprintk(VIDC_DBG, "%s - fw not in init state\n", __func__);
		rc = -EINVAL;
		goto dbg_error_null;
	}
@@ -2064,7 +2070,7 @@ static int venus_hfi_core_init(void *device)
		return -ENODEV;
	}

	VENUS_SET_STATE(dev, VENUS_STATE_INIT);
	venus_hfi_set_state(dev, VENUS_STATE_INIT);

	dev->intr_status = 0;
	INIT_LIST_HEAD(&dev->sess_head);
@@ -2117,7 +2123,7 @@ static int venus_hfi_core_init(void *device)

	return rc;
err_core_init:
	VENUS_SET_STATE(dev, VENUS_STATE_DEINIT);
	venus_hfi_set_state(dev, VENUS_STATE_DEINIT);
	disable_irq_nosync(dev->hal_data->irq);
	return rc;
}
@@ -2148,7 +2154,7 @@ static int venus_hfi_core_release(void *device)
		dev->intr_status = 0;
		mutex_unlock(&dev->clk_pwr_lock);
	}
	VENUS_SET_STATE(dev, VENUS_STATE_DEINIT);
	venus_hfi_set_state(dev, VENUS_STATE_DEINIT);

	dprintk(VIDC_INFO, "HAL exited\n");
	return 0;