summaryrefslogtreecommitdiffstats
path: root/sound/soc/sof/sof-client-probes.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2022-10-03 16:30:42 +0200
committerTakashi Iwai <tiwai@suse.de>2022-10-03 16:30:42 +0200
commit86a4d29e75540e20f991e72f17aa51d0e775a397 (patch)
tree87d99ee3855d97da60074fdc9c0cdd63dd2da66b /sound/soc/sof/sof-client-probes.c
parent02f2e785c4834828876a4701926416157dfd7b26 (diff)
parentf0c8d7468af0001b80b0c86802ee28063f800987 (diff)
downloadlinux-stable-86a4d29e75540e20f991e72f17aa51d0e775a397.tar.gz
linux-stable-86a4d29e75540e20f991e72f17aa51d0e775a397.tar.bz2
linux-stable-86a4d29e75540e20f991e72f17aa51d0e775a397.zip
Merge tag 'asoc-v6.1' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
ASoC: Updates for v6.1 This has been a very quiet release for the core but quite a busy one for drivers with a big crop of new drivers and lots of feature additions and fixes to existing ones: - A new string helper parse_int_array_user(). - Improvements to the SOF IPC4 code, especially around trace. - Support for AMD Rembrant DSPs, AMD Pink Sardine ACP 6.2, Apple Silcon systems, Everest ES8326, Intel Sky Lake and Kaby Lake, MediaTek MT8186 support, NXP i.MX8ULP DSPs, Qualcomm SC8280XP, SM8250 and SM8450 and Texas Instruments SRC4392 There is a conflict with the conversion of I2C remove functions to void in the cs42l42 driver which is fairly straightforward to resolve but should be highlighted to Linus.
Diffstat (limited to 'sound/soc/sof/sof-client-probes.c')
-rw-r--r--sound/soc/sof/sof-client-probes.c104
1 files changed, 15 insertions, 89 deletions
diff --git a/sound/soc/sof/sof-client-probes.c b/sound/soc/sof/sof-client-probes.c
index eb246b823461..ddeabbb5580e 100644
--- a/sound/soc/sof/sof-client-probes.c
+++ b/sound/soc/sof/sof-client-probes.c
@@ -12,6 +12,8 @@
#include <linux/debugfs.h>
#include <linux/module.h>
#include <linux/pm_runtime.h>
+#include <linux/string_helpers.h>
+
#include <sound/soc.h>
#include <sound/sof/header.h>
#include "sof-client.h"
@@ -410,79 +412,6 @@ static const struct snd_compress_ops sof_probes_compressed_ops = {
.copy = sof_probes_compr_copy,
};
-/**
- * strsplit_u32 - Split string into sequence of u32 tokens
- * @buf: String to split into tokens.
- * @delim: String containing delimiter characters.
- * @tkns: Returned u32 sequence pointer.
- * @num_tkns: Returned number of tokens obtained.
- */
-static int strsplit_u32(char *buf, const char *delim, u32 **tkns, size_t *num_tkns)
-{
- char *s;
- u32 *data, *tmp;
- size_t count = 0;
- size_t cap = 32;
- int ret = 0;
-
- *tkns = NULL;
- *num_tkns = 0;
- data = kcalloc(cap, sizeof(*data), GFP_KERNEL);
- if (!data)
- return -ENOMEM;
-
- while ((s = strsep(&buf, delim)) != NULL) {
- ret = kstrtouint(s, 0, data + count);
- if (ret)
- goto exit;
- if (++count >= cap) {
- cap *= 2;
- tmp = krealloc(data, cap * sizeof(*data), GFP_KERNEL);
- if (!tmp) {
- ret = -ENOMEM;
- goto exit;
- }
- data = tmp;
- }
- }
-
- if (!count)
- goto exit;
- *tkns = kmemdup(data, count * sizeof(*data), GFP_KERNEL);
- if (!(*tkns)) {
- ret = -ENOMEM;
- goto exit;
- }
- *num_tkns = count;
-
-exit:
- kfree(data);
- return ret;
-}
-
-static int tokenize_input(const char __user *from, size_t count,
- loff_t *ppos, u32 **tkns, size_t *num_tkns)
-{
- char *buf;
- int ret;
-
- buf = kmalloc(count + 1, GFP_KERNEL);
- if (!buf)
- return -ENOMEM;
-
- ret = simple_write_to_buffer(buf, count, ppos, from, count);
- if (ret != count) {
- ret = ret >= 0 ? -EIO : ret;
- goto exit;
- }
-
- buf[count] = '\0';
- ret = strsplit_u32(buf, ",", tkns, num_tkns);
-exit:
- kfree(buf);
- return ret;
-}
-
static ssize_t sof_probes_dfs_points_read(struct file *file, char __user *to,
size_t count, loff_t *ppos)
{
@@ -548,8 +477,8 @@ sof_probes_dfs_points_write(struct file *file, const char __user *from,
struct sof_probes_priv *priv = cdev->data;
struct device *dev = &cdev->auxdev.dev;
struct sof_probe_point_desc *desc;
- size_t num_tkns, bytes;
- u32 *tkns;
+ u32 num_elems, *array;
+ size_t bytes;
int ret, err;
if (priv->extractor_stream_tag == SOF_PROBES_INVALID_NODE_ID) {
@@ -557,16 +486,18 @@ sof_probes_dfs_points_write(struct file *file, const char __user *from,
return -ENOENT;
}
- ret = tokenize_input(from, count, ppos, &tkns, &num_tkns);
+ ret = parse_int_array_user(from, count, (int **)&array);
if (ret < 0)
return ret;
- bytes = sizeof(*tkns) * num_tkns;
- if (!num_tkns || (bytes % sizeof(*desc))) {
+
+ num_elems = *array;
+ bytes = sizeof(*array) * num_elems;
+ if (bytes % sizeof(*desc)) {
ret = -EINVAL;
goto exit;
}
- desc = (struct sof_probe_point_desc *)tkns;
+ desc = (struct sof_probe_point_desc *)&array[1];
ret = pm_runtime_resume_and_get(dev);
if (ret < 0 && ret != -EACCES) {
@@ -583,7 +514,7 @@ sof_probes_dfs_points_write(struct file *file, const char __user *from,
if (err < 0)
dev_err_ratelimited(dev, "debugfs write failed to idle %d\n", err);
exit:
- kfree(tkns);
+ kfree(array);
return ret;
}
@@ -603,22 +534,17 @@ sof_probes_dfs_points_remove_write(struct file *file, const char __user *from,
struct sof_client_dev *cdev = file->private_data;
struct sof_probes_priv *priv = cdev->data;
struct device *dev = &cdev->auxdev.dev;
- size_t num_tkns;
- u32 *tkns;
int ret, err;
+ u32 *array;
if (priv->extractor_stream_tag == SOF_PROBES_INVALID_NODE_ID) {
dev_warn(dev, "no extractor stream running\n");
return -ENOENT;
}
- ret = tokenize_input(from, count, ppos, &tkns, &num_tkns);
+ ret = parse_int_array_user(from, count, (int **)&array);
if (ret < 0)
return ret;
- if (!num_tkns) {
- ret = -EINVAL;
- goto exit;
- }
ret = pm_runtime_resume_and_get(dev);
if (ret < 0) {
@@ -626,7 +552,7 @@ sof_probes_dfs_points_remove_write(struct file *file, const char __user *from,
goto exit;
}
- ret = sof_probes_points_remove(cdev, tkns, num_tkns);
+ ret = sof_probes_points_remove(cdev, &array[1], array[0]);
if (!ret)
ret = count;
@@ -635,7 +561,7 @@ sof_probes_dfs_points_remove_write(struct file *file, const char __user *from,
if (err < 0)
dev_err_ratelimited(dev, "debugfs write failed to idle %d\n", err);
exit:
- kfree(tkns);
+ kfree(array);
return ret;
}