]> git.ipfire.org Git - thirdparty/linux.git/blame - sound/aoa/soundbus/sysfs.c
License cleanup: add SPDX GPL-2.0 license identifier to files with no license
[thirdparty/linux.git] / sound / aoa / soundbus / sysfs.c
CommitLineData
b2441318 1// SPDX-License-Identifier: GPL-2.0
f3d9478b
JB
2#include <linux/kernel.h>
3#include <linux/stat.h>
4/* FIX UP */
5#include "soundbus.h"
6
7#define soundbus_config_of_attr(field, format_string) \
8static ssize_t \
9field##_show (struct device *dev, struct device_attribute *attr, \
10 char *buf) \
11{ \
12 struct soundbus_dev *mdev = to_soundbus_device (dev); \
61c7a080 13 return sprintf (buf, format_string, mdev->ofdev.dev.of_node->field); \
f3d9478b
JB
14}
15
16static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
17 char *buf)
18{
19 struct soundbus_dev *sdev = to_soundbus_device(dev);
2dc11581 20 struct platform_device *of = &sdev->ofdev;
f3d9478b
JB
21 int length;
22
23 if (*sdev->modalias) {
24 strlcpy(buf, sdev->modalias, sizeof(sdev->modalias) + 1);
25 strcat(buf, "\n");
26 length = strlen(buf);
27 } else {
28 length = sprintf(buf, "of:N%sT%s\n",
61c7a080 29 of->dev.of_node->name, of->dev.of_node->type);
f3d9478b
JB
30 }
31
32 return length;
33}
a038b979 34static DEVICE_ATTR_RO(modalias);
f3d9478b
JB
35
36soundbus_config_of_attr (name, "%s\n");
a038b979 37static DEVICE_ATTR_RO(name);
f3d9478b 38soundbus_config_of_attr (type, "%s\n");
a038b979 39static DEVICE_ATTR_RO(type);
f3d9478b 40
a038b979
QL
41struct attribute *soundbus_dev_attrs[] = {
42 &dev_attr_name.attr,
43 &dev_attr_type.attr,
44 &dev_attr_modalias.attr,
45 NULL,
f3d9478b 46};