Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification
@ 2025-12-12 10:38 Cezary Rojewski
  2025-12-12 10:38 ` [PATCH 1/5] ASoC: Intel: catpt: Move IPC error messages one level down Cezary Rojewski
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Cezary Rojewski @ 2025-12-12 10:38 UTC (permalink / raw)
  To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski

Entire patchset provides no new features and does not alter the code
from functional (user) perspective.

The first two improve IPC-error logging 'mechanism' and align the
catpt-driver with what's done in another Intel's driver: the avs-driver.
In essence, no need to log the error in every function, let the common
handler do so instead.

The last three simplify the code, and fix some spacing issues.  All in
all, we get better readability with lower LOC.

Cezary Rojewski (5):
  ASoC: Intel: catpt: Move IPC error messages one level down
  ASoC: Intel: catpt: Update CATPT_IPC_ERROR macro
  ASoC: Intel: catpt: Simplify catpt_stream_read_position()
  ASoC: Intel: catpt: Specify image names in the device descriptor
  ASoC: Intel: catpt: Drop superfluous space in PCM code

 sound/soc/intel/catpt/core.h     |  7 +--
 sound/soc/intel/catpt/device.c   |  6 ++-
 sound/soc/intel/catpt/ipc.c      | 12 +++--
 sound/soc/intel/catpt/loader.c   |  8 +--
 sound/soc/intel/catpt/messages.c | 89 +++++---------------------------
 sound/soc/intel/catpt/pcm.c      | 46 +++++++----------
 sound/soc/intel/catpt/sysfs.c    |  2 +-
 7 files changed, 49 insertions(+), 121 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/5] ASoC: Intel: catpt: Move IPC error messages one level down
  2025-12-12 10:38 [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification Cezary Rojewski
@ 2025-12-12 10:38 ` Cezary Rojewski
  2025-12-12 10:38 ` [PATCH 2/5] ASoC: Intel: catpt: Update CATPT_IPC_ERROR macro Cezary Rojewski
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Cezary Rojewski @ 2025-12-12 10:38 UTC (permalink / raw)
  To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski

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 <cezary.rojewski@intel.com>
---
 sound/soc/intel/catpt/core.h     |  4 +-
 sound/soc/intel/catpt/ipc.c      | 12 +++--
 sound/soc/intel/catpt/messages.c | 89 +++++---------------------------
 3 files changed, 21 insertions(+), 84 deletions(-)

diff --git a/sound/soc/intel/catpt/core.h b/sound/soc/intel/catpt/core.h
index c01d27e9fd88..7b7c30a0d2ac 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 d26863249097..5a01a9afb26e 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 30eec2de4dc1..688a2d79500d 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");
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/5] ASoC: Intel: catpt: Update CATPT_IPC_ERROR macro
  2025-12-12 10:38 [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification Cezary Rojewski
  2025-12-12 10:38 ` [PATCH 1/5] ASoC: Intel: catpt: Move IPC error messages one level down Cezary Rojewski
@ 2025-12-12 10:38 ` Cezary Rojewski
  2025-12-12 10:38 ` [PATCH 3/5] ASoC: Intel: catpt: Simplify catpt_stream_read_position() Cezary Rojewski
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Cezary Rojewski @ 2025-12-12 10:38 UTC (permalink / raw)
  To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski

Make it easier for functions that call IPC handlers to deal with their
results by accounting for '0' (success) code. Rename the macro to
reflect this behaviour change.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/catpt/core.h   |  2 +-
 sound/soc/intel/catpt/device.c |  4 ++--
 sound/soc/intel/catpt/loader.c |  2 +-
 sound/soc/intel/catpt/pcm.c    | 24 ++++++++++--------------
 sound/soc/intel/catpt/sysfs.c  |  2 +-
 5 files changed, 15 insertions(+), 19 deletions(-)

diff --git a/sound/soc/intel/catpt/core.h b/sound/soc/intel/catpt/core.h
index 7b7c30a0d2ac..d273f24d3d53 100644
--- a/sound/soc/intel/catpt/core.h
+++ b/sound/soc/intel/catpt/core.h
@@ -129,7 +129,7 @@ irqreturn_t catpt_dsp_irq_thread(int irq, void *dev_id);
  * HOST <-> DSP communication yet failure to process specific request.
  * Use below macro to convert returned non-zero values appropriately
  */
-#define CATPT_IPC_ERROR(err) (((err) < 0) ? (err) : -EREMOTEIO)
+#define CATPT_IPC_RET(ret)	(((ret) <= 0) ? (ret) : -EREMOTEIO)
 
 int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev,
 			       struct catpt_ipc_msg request,
diff --git a/sound/soc/intel/catpt/device.c b/sound/soc/intel/catpt/device.c
index d13062c8e907..d8e0da558495 100644
--- a/sound/soc/intel/catpt/device.c
+++ b/sound/soc/intel/catpt/device.c
@@ -41,7 +41,7 @@ static int catpt_do_suspend(struct device *dev)
 	memset(&cdev->dx_ctx, 0, sizeof(cdev->dx_ctx));
 	ret = catpt_ipc_enter_dxstate(cdev, CATPT_DX_STATE_D3, &cdev->dx_ctx);
 	if (ret) {
-		ret = CATPT_IPC_ERROR(ret);
+		ret = CATPT_IPC_RET(ret);
 		goto release_dma_chan;
 	}
 
@@ -107,7 +107,7 @@ static int catpt_resume(struct device *dev)
 
 		ret = catpt_ipc_set_device_format(cdev, &cdev->devfmt[i]);
 		if (ret)
-			return CATPT_IPC_ERROR(ret);
+			return CATPT_IPC_RET(ret);
 	}
 
 	return 0;
diff --git a/sound/soc/intel/catpt/loader.c b/sound/soc/intel/catpt/loader.c
index 6fd1a32f3863..566b6e04a848 100644
--- a/sound/soc/intel/catpt/loader.c
+++ b/sound/soc/intel/catpt/loader.c
@@ -657,7 +657,7 @@ int catpt_first_boot_firmware(struct catpt_dev *cdev)
 
 	ret = catpt_ipc_get_mixer_stream_info(cdev, &cdev->mixer);
 	if (ret)
-		return CATPT_IPC_ERROR(ret);
+		return CATPT_IPC_RET(ret);
 
 	ret = catpt_arm_stream_templates(cdev);
 	if (ret) {
diff --git a/sound/soc/intel/catpt/pcm.c b/sound/soc/intel/catpt/pcm.c
index abd1cb07c60c..cc43346f83af 100644
--- a/sound/soc/intel/catpt/pcm.c
+++ b/sound/soc/intel/catpt/pcm.c
@@ -365,9 +365,7 @@ static int catpt_dai_apply_usettings(struct snd_soc_dai *dai,
 	if (stream->template->type != CATPT_STRM_TYPE_LOOPBACK)
 		return catpt_set_dspvol(cdev, id, (long *)pos->private_value);
 	ret = catpt_ipc_mute_loopback(cdev, id, *(bool *)pos->private_value);
-	if (ret)
-		return CATPT_IPC_ERROR(ret);
-	return 0;
+	return CATPT_IPC_RET(ret);
 }
 
 static int catpt_dai_hw_params(struct snd_pcm_substream *substream,
@@ -414,7 +412,7 @@ static int catpt_dai_hw_params(struct snd_pcm_substream *substream,
 				     cdev->scratch,
 				     &stream->info);
 	if (ret)
-		return CATPT_IPC_ERROR(ret);
+		return CATPT_IPC_RET(ret);
 
 	ret = catpt_dai_apply_usettings(dai, stream);
 	if (ret) {
@@ -456,11 +454,11 @@ static int catpt_dai_prepare(struct snd_pcm_substream *substream,
 
 	ret = catpt_ipc_reset_stream(cdev, stream->info.stream_hw_id);
 	if (ret)
-		return CATPT_IPC_ERROR(ret);
+		return CATPT_IPC_RET(ret);
 
 	ret = catpt_ipc_pause_stream(cdev, stream->info.stream_hw_id);
 	if (ret)
-		return CATPT_IPC_ERROR(ret);
+		return CATPT_IPC_RET(ret);
 
 	stream->prepared = true;
 	return 0;
@@ -491,7 +489,7 @@ static int catpt_dai_trigger(struct snd_pcm_substream *substream, int cmd,
 		ret = catpt_ipc_set_write_pos(cdev, stream->info.stream_hw_id,
 					      pos, false, false);
 		if (ret)
-			return CATPT_IPC_ERROR(ret);
+			return CATPT_IPC_RET(ret);
 		fallthrough;
 	case SNDRV_PCM_TRIGGER_RESUME:
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
@@ -499,7 +497,7 @@ static int catpt_dai_trigger(struct snd_pcm_substream *substream, int cmd,
 		catpt_dsp_update_lpclock(cdev);
 		ret = catpt_ipc_resume_stream(cdev, stream->info.stream_hw_id);
 		if (ret)
-			return CATPT_IPC_ERROR(ret);
+			return CATPT_IPC_RET(ret);
 		break;
 
 	case SNDRV_PCM_TRIGGER_STOP:
@@ -510,7 +508,7 @@ static int catpt_dai_trigger(struct snd_pcm_substream *substream, int cmd,
 		ret = catpt_ipc_pause_stream(cdev, stream->info.stream_hw_id);
 		catpt_dsp_update_lpclock(cdev);
 		if (ret)
-			return CATPT_IPC_ERROR(ret);
+			return CATPT_IPC_RET(ret);
 		break;
 
 	default:
@@ -679,7 +677,7 @@ static int catpt_dai_pcm_new(struct snd_soc_pcm_runtime *rtm,
 	pm_runtime_put_autosuspend(cdev->dev);
 
 	if (ret)
-		return CATPT_IPC_ERROR(ret);
+		return CATPT_IPC_RET(ret);
 
 	/* store device format set for given SSP */
 	memcpy(&cdev->devfmt[devfmt.iface], &devfmt, sizeof(devfmt));
@@ -849,9 +847,7 @@ static int catpt_set_dspvol(struct catpt_dev *cdev, u8 stream_id, long *ctlvol)
 		}
 	}
 
-	if (ret)
-		return CATPT_IPC_ERROR(ret);
-	return 0;
+	return CATPT_IPC_RET(ret);
 }
 
 static int catpt_volume_info(struct snd_kcontrol *kcontrol,
@@ -1041,7 +1037,7 @@ static int catpt_loopback_switch_put(struct snd_kcontrol *kcontrol,
 	pm_runtime_put_autosuspend(cdev->dev);
 
 	if (ret)
-		return CATPT_IPC_ERROR(ret);
+		return CATPT_IPC_RET(ret);
 
 	*(bool *)kcontrol->private_value = mute;
 	return 0;
diff --git a/sound/soc/intel/catpt/sysfs.c b/sound/soc/intel/catpt/sysfs.c
index e961e172f9b7..0cb122a4dfd2 100644
--- a/sound/soc/intel/catpt/sysfs.c
+++ b/sound/soc/intel/catpt/sysfs.c
@@ -24,7 +24,7 @@ static ssize_t fw_version_show(struct device *dev,
 	pm_runtime_put_autosuspend(cdev->dev);
 
 	if (ret)
-		return CATPT_IPC_ERROR(ret);
+		return CATPT_IPC_RET(ret);
 
 	return sysfs_emit(buf, "%d.%d.%d.%d\n", version.type, version.major,
 			  version.minor, version.build);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/5] ASoC: Intel: catpt: Simplify catpt_stream_read_position()
  2025-12-12 10:38 [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification Cezary Rojewski
  2025-12-12 10:38 ` [PATCH 1/5] ASoC: Intel: catpt: Move IPC error messages one level down Cezary Rojewski
  2025-12-12 10:38 ` [PATCH 2/5] ASoC: Intel: catpt: Update CATPT_IPC_ERROR macro Cezary Rojewski
@ 2025-12-12 10:38 ` Cezary Rojewski
  2025-12-12 10:38 ` [PATCH 4/5] ASoC: Intel: catpt: Specify image names in the device descriptor Cezary Rojewski
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Cezary Rojewski @ 2025-12-12 10:38 UTC (permalink / raw)
  To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski

Add position to the argument list to simplify the wrapper.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/catpt/pcm.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/sound/soc/intel/catpt/pcm.c b/sound/soc/intel/catpt/pcm.c
index cc43346f83af..cbb1c3942409 100644
--- a/sound/soc/intel/catpt/pcm.c
+++ b/sound/soc/intel/catpt/pcm.c
@@ -114,14 +114,10 @@ catpt_stream_find(struct catpt_dev *cdev, u8 stream_hw_id)
 	return result;
 }
 
-static u32 catpt_stream_read_position(struct catpt_dev *cdev,
-				      struct catpt_stream_runtime *stream)
+static void catpt_stream_read_position(struct catpt_dev *cdev,
+				       struct catpt_stream_runtime *stream, u32 *pos)
 {
-	u32 pos;
-
-	memcpy_fromio(&pos, cdev->lpe_ba + stream->info.read_pos_regaddr,
-		      sizeof(pos));
-	return pos;
+	memcpy_fromio(pos, cdev->lpe_ba + stream->info.read_pos_regaddr, sizeof(*pos));
 }
 
 static u32 catpt_stream_volume(struct catpt_dev *cdev,
@@ -615,7 +611,7 @@ catpt_component_pointer(struct snd_soc_component *component,
 		return 0;
 
 	stream = snd_soc_dai_get_dma_data(cpu_dai, substream);
-	pos = catpt_stream_read_position(cdev, stream);
+	catpt_stream_read_position(cdev, stream, &pos);
 
 	return bytes_to_frames(substream->runtime, pos);
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/5] ASoC: Intel: catpt: Specify image names in the device descriptor
  2025-12-12 10:38 [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification Cezary Rojewski
                   ` (2 preceding siblings ...)
  2025-12-12 10:38 ` [PATCH 3/5] ASoC: Intel: catpt: Simplify catpt_stream_read_position() Cezary Rojewski
@ 2025-12-12 10:38 ` Cezary Rojewski
  2025-12-12 10:38 ` [PATCH 5/5] ASoC: Intel: catpt: Drop superfluous space in PCM code Cezary Rojewski
  2025-12-15 13:58 ` [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Cezary Rojewski @ 2025-12-12 10:38 UTC (permalink / raw)
  To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski

State files to load explicitly in the device descriptor instead of
hiding the details within a loading function. Apart from readability,
this also reduces the catpt module size slightly.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/catpt/core.h   | 1 +
 sound/soc/intel/catpt/device.c | 2 ++
 sound/soc/intel/catpt/loader.c | 6 +-----
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/sound/soc/intel/catpt/core.h b/sound/soc/intel/catpt/core.h
index d273f24d3d53..df8a5fd95e13 100644
--- a/sound/soc/intel/catpt/core.h
+++ b/sound/soc/intel/catpt/core.h
@@ -62,6 +62,7 @@ struct catpt_module_type {
 struct catpt_spec {
 	struct snd_soc_acpi_mach *machines;
 	u8 core_id;
+	const char *fw_name;
 	u32 host_dram_offset;
 	u32 host_iram_offset;
 	u32 host_shim_offset;
diff --git a/sound/soc/intel/catpt/device.c b/sound/soc/intel/catpt/device.c
index d8e0da558495..0638aecba40d 100644
--- a/sound/soc/intel/catpt/device.c
+++ b/sound/soc/intel/catpt/device.c
@@ -348,6 +348,7 @@ static struct snd_soc_acpi_mach wpt_machines[] = {
 static struct catpt_spec lpt_desc = {
 	.machines = lpt_machines,
 	.core_id = 0x01,
+	.fw_name = "intel/IntcSST1.bin",
 	.host_dram_offset = 0x000000,
 	.host_iram_offset = 0x080000,
 	.host_shim_offset = 0x0E7000,
@@ -363,6 +364,7 @@ static struct catpt_spec lpt_desc = {
 static struct catpt_spec wpt_desc = {
 	.machines = wpt_machines,
 	.core_id = 0x02,
+	.fw_name = "intel/IntcSST2.bin",
 	.host_dram_offset = 0x000000,
 	.host_iram_offset = 0x0A0000,
 	.host_shim_offset = 0x0FB000,
diff --git a/sound/soc/intel/catpt/loader.c b/sound/soc/intel/catpt/loader.c
index 566b6e04a848..05c50a6728f6 100644
--- a/sound/soc/intel/catpt/loader.c
+++ b/sound/soc/intel/catpt/loader.c
@@ -581,10 +581,6 @@ static int catpt_load_image(struct catpt_dev *cdev, struct dma_chan *chan,
 
 static int catpt_load_images(struct catpt_dev *cdev, bool restore)
 {
-	static const char *const names[] = {
-		"intel/IntcSST1.bin",
-		"intel/IntcSST2.bin",
-	};
 	struct dma_chan *chan;
 	int ret;
 
@@ -592,7 +588,7 @@ static int catpt_load_images(struct catpt_dev *cdev, bool restore)
 	if (IS_ERR(chan))
 		return PTR_ERR(chan);
 
-	ret = catpt_load_image(cdev, chan, names[cdev->spec->core_id - 1],
+	ret = catpt_load_image(cdev, chan, cdev->spec->fw_name,
 			       FW_SIGNATURE, restore);
 	if (ret)
 		goto release_dma_chan;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 5/5] ASoC: Intel: catpt: Drop superfluous space in PCM code
  2025-12-12 10:38 [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification Cezary Rojewski
                   ` (3 preceding siblings ...)
  2025-12-12 10:38 ` [PATCH 4/5] ASoC: Intel: catpt: Specify image names in the device descriptor Cezary Rojewski
@ 2025-12-12 10:38 ` Cezary Rojewski
  2025-12-15 13:58 ` [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Cezary Rojewski @ 2025-12-12 10:38 UTC (permalink / raw)
  To: broonie; +Cc: tiwai, perex, amade, linux-sound, Cezary Rojewski

Those spaces are redundant.

Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/catpt/pcm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/soc/intel/catpt/pcm.c b/sound/soc/intel/catpt/pcm.c
index cbb1c3942409..2c3405686f79 100644
--- a/sound/soc/intel/catpt/pcm.c
+++ b/sound/soc/intel/catpt/pcm.c
@@ -687,7 +687,7 @@ static const struct snd_soc_dai_ops catpt_dai_ops = {
 static struct snd_soc_dai_driver dai_drivers[] = {
 /* FE DAIs */
 {
-	.name  = "System Pin",
+	.name = "System Pin",
 	.id = CATPT_STRM_TYPE_SYSTEM,
 	.ops = &catpt_fe_dai_ops,
 	.playback = {
@@ -710,7 +710,7 @@ static struct snd_soc_dai_driver dai_drivers[] = {
 	},
 },
 {
-	.name  = "Offload0 Pin",
+	.name = "Offload0 Pin",
 	.id = CATPT_STRM_TYPE_RENDER,
 	.ops = &catpt_fe_dai_ops,
 	.playback = {
@@ -724,7 +724,7 @@ static struct snd_soc_dai_driver dai_drivers[] = {
 	},
 },
 {
-	.name  = "Offload1 Pin",
+	.name = "Offload1 Pin",
 	.id = CATPT_STRM_TYPE_RENDER,
 	.ops = &catpt_fe_dai_ops,
 	.playback = {
@@ -738,7 +738,7 @@ static struct snd_soc_dai_driver dai_drivers[] = {
 	},
 },
 {
-	.name  = "Loopback Pin",
+	.name = "Loopback Pin",
 	.id = CATPT_STRM_TYPE_LOOPBACK,
 	.ops = &catpt_fe_dai_ops,
 	.capture = {
@@ -752,7 +752,7 @@ static struct snd_soc_dai_driver dai_drivers[] = {
 	},
 },
 {
-	.name  = "Bluetooth Pin",
+	.name = "Bluetooth Pin",
 	.id = CATPT_STRM_TYPE_BLUETOOTH_RENDER,
 	.ops = &catpt_fe_dai_ops,
 	.playback = {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification
  2025-12-12 10:38 [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification Cezary Rojewski
                   ` (4 preceding siblings ...)
  2025-12-12 10:38 ` [PATCH 5/5] ASoC: Intel: catpt: Drop superfluous space in PCM code Cezary Rojewski
@ 2025-12-15 13:58 ` Mark Brown
  5 siblings, 0 replies; 7+ messages in thread
From: Mark Brown @ 2025-12-15 13:58 UTC (permalink / raw)
  To: Cezary Rojewski; +Cc: tiwai, perex, amade, linux-sound

On Fri, 12 Dec 2025 11:38:53 +0100, Cezary Rojewski wrote:
> Entire patchset provides no new features and does not alter the code
> from functional (user) perspective.
> 
> The first two improve IPC-error logging 'mechanism' and align the
> catpt-driver with what's done in another Intel's driver: the avs-driver.
> In essence, no need to log the error in every function, let the common
> handler do so instead.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/5] ASoC: Intel: catpt: Move IPC error messages one level down
      commit: 384b13038715f16713d1b2bfe5fb927c8437e48b
[2/5] ASoC: Intel: catpt: Update CATPT_IPC_ERROR macro
      commit: eded4483b8a21eaeb0886ef6f961ccf4e0d9c976
[3/5] ASoC: Intel: catpt: Simplify catpt_stream_read_position()
      commit: d44f62b09b1e97baee3b10484a1c3c203bb83caf
[4/5] ASoC: Intel: catpt: Specify image names in the device descriptor
      commit: e97e07138f956a551895a9556d1a929978a5346d
[5/5] ASoC: Intel: catpt: Drop superfluous space in PCM code
      commit: aa30193af8873b3ccfd70a4275336ab6cbd4e5e6

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-12-15 13:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-12 10:38 [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification Cezary Rojewski
2025-12-12 10:38 ` [PATCH 1/5] ASoC: Intel: catpt: Move IPC error messages one level down Cezary Rojewski
2025-12-12 10:38 ` [PATCH 2/5] ASoC: Intel: catpt: Update CATPT_IPC_ERROR macro Cezary Rojewski
2025-12-12 10:38 ` [PATCH 3/5] ASoC: Intel: catpt: Simplify catpt_stream_read_position() Cezary Rojewski
2025-12-12 10:38 ` [PATCH 4/5] ASoC: Intel: catpt: Specify image names in the device descriptor Cezary Rojewski
2025-12-12 10:38 ` [PATCH 5/5] ASoC: Intel: catpt: Drop superfluous space in PCM code Cezary Rojewski
2025-12-15 13:58 ` [PATCH 0/5] ASoC: Intel: catpt: IPC log improvements and code simplification Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox