summaryrefslogtreecommitdiff
path: root/sound/aoa
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2022-08-01 18:56:34 +0200
committerTakashi Iwai <tiwai@suse.de>2022-08-02 16:03:42 +0200
commit0980bb1ff0f0ef0a3fb08f7596167eda2c932b45 (patch)
tree0de67313a528c12eb5606fbb7c96a6a182911f2d /sound/aoa
parent7450320ec7ab11e89e3f9b8f2c1229f3964181c1 (diff)
ALSA: aoa: Replace sprintf() with sysfs_emit()
For sysfs outputs, it's safer to use a new helper, sysfs_emit(), instead of the raw sprintf() & co. This patch replaces such sprintf() calls with sysfs_emit() while simplifying the open code in modalias_show(); as modalias[] is a NUL-terminated string, we can pass it straightly to a printf() argument. Link: https://lore.kernel.org/r/20220801165639.26030-3-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/aoa')
-rw-r--r--sound/aoa/soundbus/sysfs.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/sound/aoa/soundbus/sysfs.c b/sound/aoa/soundbus/sysfs.c
index dead3105689b..e87b28428b99 100644
--- a/sound/aoa/soundbus/sysfs.c
+++ b/sound/aoa/soundbus/sysfs.c
@@ -10,19 +10,13 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
{
struct soundbus_dev *sdev = to_soundbus_device(dev);
struct platform_device *of = &sdev->ofdev;
- int length;
- if (*sdev->modalias) {
- strscpy(buf, sdev->modalias, sizeof(sdev->modalias) + 1);
- strcat(buf, "\n");
- length = strlen(buf);
- } else {
- length = sprintf(buf, "of:N%pOFn%c%s\n",
- of->dev.of_node, 'T',
- of_node_get_device_type(of->dev.of_node));
- }
-
- return length;
+ if (*sdev->modalias)
+ return sysfs_emit(buf, "%s\n", sdev->modalias);
+ else
+ return sysfs_emit(buf, "of:N%pOFn%c%s\n",
+ of->dev.of_node, 'T',
+ of_node_get_device_type(of->dev.of_node));
}
static DEVICE_ATTR_RO(modalias);
@@ -32,7 +26,7 @@ static ssize_t name_show(struct device *dev,
struct soundbus_dev *sdev = to_soundbus_device(dev);
struct platform_device *of = &sdev->ofdev;
- return sprintf(buf, "%pOFn\n", of->dev.of_node);
+ return sysfs_emit(buf, "%pOFn\n", of->dev.of_node);
}
static DEVICE_ATTR_RO(name);
@@ -42,7 +36,7 @@ static ssize_t type_show(struct device *dev,
struct soundbus_dev *sdev = to_soundbus_device(dev);
struct platform_device *of = &sdev->ofdev;
- return sprintf(buf, "%s\n", of_node_get_device_type(of->dev.of_node));
+ return sysfs_emit(buf, "%s\n", of_node_get_device_type(of->dev.of_node));
}
static DEVICE_ATTR_RO(type);