mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-01 10:43:43 +00:00
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>
This commit is contained in:
parent
7450320ec7
commit
0980bb1ff0
@ -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 soundbus_dev *sdev = to_soundbus_device(dev);
|
||||||
struct platform_device *of = &sdev->ofdev;
|
struct platform_device *of = &sdev->ofdev;
|
||||||
int length;
|
|
||||||
|
|
||||||
if (*sdev->modalias) {
|
if (*sdev->modalias)
|
||||||
strscpy(buf, sdev->modalias, sizeof(sdev->modalias) + 1);
|
return sysfs_emit(buf, "%s\n", sdev->modalias);
|
||||||
strcat(buf, "\n");
|
else
|
||||||
length = strlen(buf);
|
return sysfs_emit(buf, "of:N%pOFn%c%s\n",
|
||||||
} else {
|
of->dev.of_node, 'T',
|
||||||
length = sprintf(buf, "of:N%pOFn%c%s\n",
|
of_node_get_device_type(of->dev.of_node));
|
||||||
of->dev.of_node, 'T',
|
|
||||||
of_node_get_device_type(of->dev.of_node));
|
|
||||||
}
|
|
||||||
|
|
||||||
return length;
|
|
||||||
}
|
}
|
||||||
static DEVICE_ATTR_RO(modalias);
|
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 soundbus_dev *sdev = to_soundbus_device(dev);
|
||||||
struct platform_device *of = &sdev->ofdev;
|
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);
|
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 soundbus_dev *sdev = to_soundbus_device(dev);
|
||||||
struct platform_device *of = &sdev->ofdev;
|
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);
|
static DEVICE_ATTR_RO(type);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user