From: Cezary Rojewski Date: Fri, 12 Dec 2025 10:38:54 +0000 (+0100) Subject: ASoC: Intel: catpt: Move IPC error messages one level down X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=384b13038715f16713d1b2bfe5fb927c8437e48b;p=thirdparty%2Fkernel%2Flinux.git ASoC: Intel: catpt: Move IPC error messages one level down Code size can be reduced if catpt_dsp_do_send_msg() takes responsibility for dumping logs in case of an IPC message failure. Signed-off-by: Cezary Rojewski Link: https://patch.msgid.link/20251212103858.110701-2-cezary.rojewski@intel.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/intel/catpt/core.h b/sound/soc/intel/catpt/core.h index c01d27e9fd88f..7b7c30a0d2ace 100644 --- a/sound/soc/intel/catpt/core.h +++ b/sound/soc/intel/catpt/core.h @@ -133,9 +133,9 @@ irqreturn_t catpt_dsp_irq_thread(int irq, void *dev_id); int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev, struct catpt_ipc_msg request, - struct catpt_ipc_msg *reply, int timeout); + struct catpt_ipc_msg *reply, int timeout, const char *name); int catpt_dsp_send_msg(struct catpt_dev *cdev, struct catpt_ipc_msg request, - struct catpt_ipc_msg *reply); + struct catpt_ipc_msg *reply, const char *name); int catpt_first_boot_firmware(struct catpt_dev *cdev); int catpt_boot_firmware(struct catpt_dev *cdev, bool restore); diff --git a/sound/soc/intel/catpt/ipc.c b/sound/soc/intel/catpt/ipc.c index d26863249097f..5a01a9afb26ee 100644 --- a/sound/soc/intel/catpt/ipc.c +++ b/sound/soc/intel/catpt/ipc.c @@ -84,7 +84,7 @@ static int catpt_wait_msg_completion(struct catpt_dev *cdev, int timeout) static int catpt_dsp_do_send_msg(struct catpt_dev *cdev, struct catpt_ipc_msg request, - struct catpt_ipc_msg *reply, int timeout) + struct catpt_ipc_msg *reply, int timeout, const char *name) { struct catpt_ipc *ipc = &cdev->ipc; unsigned long flags; @@ -111,6 +111,8 @@ static int catpt_dsp_do_send_msg(struct catpt_dev *cdev, } ret = ipc->rx.rsp.status; + if (ret) + dev_err(cdev->dev, "%s (0x%08x) failed: %d\n", name, request.header, ret); if (reply) { reply->header = ipc->rx.header; @@ -123,23 +125,23 @@ static int catpt_dsp_do_send_msg(struct catpt_dev *cdev, int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev, struct catpt_ipc_msg request, - struct catpt_ipc_msg *reply, int timeout) + struct catpt_ipc_msg *reply, int timeout, const char *name) { struct catpt_ipc *ipc = &cdev->ipc; int ret; mutex_lock(&ipc->mutex); - ret = catpt_dsp_do_send_msg(cdev, request, reply, timeout); + ret = catpt_dsp_do_send_msg(cdev, request, reply, timeout, name); mutex_unlock(&ipc->mutex); return ret; } int catpt_dsp_send_msg(struct catpt_dev *cdev, struct catpt_ipc_msg request, - struct catpt_ipc_msg *reply) + struct catpt_ipc_msg *reply, const char *name) { return catpt_dsp_send_msg_timeout(cdev, request, reply, - cdev->ipc.default_timeout); + cdev->ipc.default_timeout, name); } static void diff --git a/sound/soc/intel/catpt/messages.c b/sound/soc/intel/catpt/messages.c index 30eec2de4dc13..688a2d79500d6 100644 --- a/sound/soc/intel/catpt/messages.c +++ b/sound/soc/intel/catpt/messages.c @@ -15,17 +15,12 @@ int catpt_ipc_get_fw_version(struct catpt_dev *cdev, { union catpt_global_msg msg = CATPT_GLOBAL_MSG(GET_FW_VERSION); struct catpt_ipc_msg request = {{0}}, reply; - int ret; request.header = msg.val; reply.size = sizeof(*version); reply.data = version; - ret = catpt_dsp_send_msg(cdev, request, &reply); - if (ret) - dev_err(cdev->dev, "get fw version failed: %d\n", ret); - - return ret; + return catpt_dsp_send_msg(cdev, request, &reply, "get fw version"); } struct catpt_alloc_stream_input { @@ -94,11 +89,7 @@ int catpt_ipc_alloc_stream(struct catpt_dev *cdev, reply.size = sizeof(*sinfo); reply.data = sinfo; - ret = catpt_dsp_send_msg(cdev, request, &reply); - if (ret) - dev_err(cdev->dev, "alloc stream type %d failed: %d\n", - type, ret); - + ret = catpt_dsp_send_msg(cdev, request, &reply, "alloc stream"); kfree(payload); return ret; } @@ -107,18 +98,12 @@ int catpt_ipc_free_stream(struct catpt_dev *cdev, u8 stream_hw_id) { union catpt_global_msg msg = CATPT_GLOBAL_MSG(FREE_STREAM); struct catpt_ipc_msg request; - int ret; request.header = msg.val; request.size = sizeof(stream_hw_id); request.data = &stream_hw_id; - ret = catpt_dsp_send_msg(cdev, request, NULL); - if (ret) - dev_err(cdev->dev, "free stream %d failed: %d\n", - stream_hw_id, ret); - - return ret; + return catpt_dsp_send_msg(cdev, request, NULL, "free stream"); } int catpt_ipc_set_device_format(struct catpt_dev *cdev, @@ -126,17 +111,12 @@ int catpt_ipc_set_device_format(struct catpt_dev *cdev, { union catpt_global_msg msg = CATPT_GLOBAL_MSG(SET_DEVICE_FORMATS); struct catpt_ipc_msg request; - int ret; request.header = msg.val; request.size = sizeof(*devfmt); request.data = devfmt; - ret = catpt_dsp_send_msg(cdev, request, NULL); - if (ret) - dev_err(cdev->dev, "set device format failed: %d\n", ret); - - return ret; + return catpt_dsp_send_msg(cdev, request, NULL, "set device format"); } int catpt_ipc_enter_dxstate(struct catpt_dev *cdev, enum catpt_dx_state state, @@ -144,7 +124,6 @@ int catpt_ipc_enter_dxstate(struct catpt_dev *cdev, enum catpt_dx_state state, { union catpt_global_msg msg = CATPT_GLOBAL_MSG(ENTER_DX_STATE); struct catpt_ipc_msg request, reply; - int ret; request.header = msg.val; request.size = sizeof(state); @@ -152,11 +131,7 @@ int catpt_ipc_enter_dxstate(struct catpt_dev *cdev, enum catpt_dx_state state, reply.size = sizeof(*context); reply.data = context; - ret = catpt_dsp_send_msg(cdev, request, &reply); - if (ret) - dev_err(cdev->dev, "enter dx state failed: %d\n", ret); - - return ret; + return catpt_dsp_send_msg(cdev, request, &reply, "enter dx state"); } int catpt_ipc_get_mixer_stream_info(struct catpt_dev *cdev, @@ -164,68 +139,45 @@ int catpt_ipc_get_mixer_stream_info(struct catpt_dev *cdev, { union catpt_global_msg msg = CATPT_GLOBAL_MSG(GET_MIXER_STREAM_INFO); struct catpt_ipc_msg request = {{0}}, reply; - int ret; request.header = msg.val; reply.size = sizeof(*info); reply.data = info; - ret = catpt_dsp_send_msg(cdev, request, &reply); - if (ret) - dev_err(cdev->dev, "get mixer info failed: %d\n", ret); - - return ret; + return catpt_dsp_send_msg(cdev, request, &reply, "get mixer info"); } int catpt_ipc_reset_stream(struct catpt_dev *cdev, u8 stream_hw_id) { union catpt_stream_msg msg = CATPT_STREAM_MSG(RESET_STREAM); struct catpt_ipc_msg request = {{0}}; - int ret; msg.stream_hw_id = stream_hw_id; request.header = msg.val; - ret = catpt_dsp_send_msg(cdev, request, NULL); - if (ret) - dev_err(cdev->dev, "reset stream %d failed: %d\n", - stream_hw_id, ret); - - return ret; + return catpt_dsp_send_msg(cdev, request, NULL, "reset stream"); } int catpt_ipc_pause_stream(struct catpt_dev *cdev, u8 stream_hw_id) { union catpt_stream_msg msg = CATPT_STREAM_MSG(PAUSE_STREAM); struct catpt_ipc_msg request = {{0}}; - int ret; msg.stream_hw_id = stream_hw_id; request.header = msg.val; - ret = catpt_dsp_send_msg(cdev, request, NULL); - if (ret) - dev_err(cdev->dev, "pause stream %d failed: %d\n", - stream_hw_id, ret); - - return ret; + return catpt_dsp_send_msg(cdev, request, NULL, "pause stream"); } int catpt_ipc_resume_stream(struct catpt_dev *cdev, u8 stream_hw_id) { union catpt_stream_msg msg = CATPT_STREAM_MSG(RESUME_STREAM); struct catpt_ipc_msg request = {{0}}; - int ret; msg.stream_hw_id = stream_hw_id; request.header = msg.val; - ret = catpt_dsp_send_msg(cdev, request, NULL); - if (ret) - dev_err(cdev->dev, "resume stream %d failed: %d\n", - stream_hw_id, ret); - - return ret; + return catpt_dsp_send_msg(cdev, request, NULL, "resume stream"); } struct catpt_set_volume_input { @@ -243,7 +195,6 @@ int catpt_ipc_set_volume(struct catpt_dev *cdev, u8 stream_hw_id, union catpt_stream_msg msg = CATPT_STAGE_MSG(SET_VOLUME); struct catpt_ipc_msg request; struct catpt_set_volume_input input; - int ret; msg.stream_hw_id = stream_hw_id; input.channel = channel; @@ -255,12 +206,7 @@ int catpt_ipc_set_volume(struct catpt_dev *cdev, u8 stream_hw_id, request.size = sizeof(input); request.data = &input; - ret = catpt_dsp_send_msg(cdev, request, NULL); - if (ret) - dev_err(cdev->dev, "set stream %d volume failed: %d\n", - stream_hw_id, ret); - - return ret; + return catpt_dsp_send_msg(cdev, request, NULL, "set stream volume"); } struct catpt_set_write_pos_input { @@ -275,7 +221,6 @@ int catpt_ipc_set_write_pos(struct catpt_dev *cdev, u8 stream_hw_id, union catpt_stream_msg msg = CATPT_STAGE_MSG(SET_WRITE_POSITION); struct catpt_ipc_msg request; struct catpt_set_write_pos_input input; - int ret; msg.stream_hw_id = stream_hw_id; input.new_write_pos = pos; @@ -286,28 +231,18 @@ int catpt_ipc_set_write_pos(struct catpt_dev *cdev, u8 stream_hw_id, request.size = sizeof(input); request.data = &input; - ret = catpt_dsp_send_msg(cdev, request, NULL); - if (ret) - dev_err(cdev->dev, "set stream %d write pos failed: %d\n", - stream_hw_id, ret); - - return ret; + return catpt_dsp_send_msg(cdev, request, NULL, "set stream write pos"); } int catpt_ipc_mute_loopback(struct catpt_dev *cdev, u8 stream_hw_id, bool mute) { union catpt_stream_msg msg = CATPT_STAGE_MSG(MUTE_LOOPBACK); struct catpt_ipc_msg request; - int ret; msg.stream_hw_id = stream_hw_id; request.header = msg.val; request.size = sizeof(mute); request.data = &mute; - ret = catpt_dsp_send_msg(cdev, request, NULL); - if (ret) - dev_err(cdev->dev, "mute loopback failed: %d\n", ret); - - return ret; + return catpt_dsp_send_msg(cdev, request, NULL, "mute loopback"); }