forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/sound/aoa/soundbus/sysfs.c
....@@ -1,17 +1,9 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #include <linux/kernel.h>
3
+#include <linux/of.h>
34 #include <linux/stat.h>
45 /* FIX UP */
56 #include "soundbus.h"
6
-
7
-#define soundbus_config_of_attr(field, format_string) \
8
-static ssize_t \
9
-field##_show (struct device *dev, struct device_attribute *attr, \
10
- char *buf) \
11
-{ \
12
- struct soundbus_dev *mdev = to_soundbus_device (dev); \
13
- return sprintf (buf, format_string, mdev->ofdev.dev.of_node->field); \
14
-}
157
168 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
179 char *buf)
....@@ -25,17 +17,33 @@
2517 strcat(buf, "\n");
2618 length = strlen(buf);
2719 } else {
28
- length = sprintf(buf, "of:N%sT%s\n",
29
- of->dev.of_node->name, of->dev.of_node->type);
20
+ length = sprintf(buf, "of:N%pOFn%c%s\n",
21
+ of->dev.of_node, 'T',
22
+ of_node_get_device_type(of->dev.of_node));
3023 }
3124
3225 return length;
3326 }
3427 static DEVICE_ATTR_RO(modalias);
3528
36
-soundbus_config_of_attr (name, "%s\n");
29
+static ssize_t name_show(struct device *dev,
30
+ struct device_attribute *attr, char *buf)
31
+{
32
+ struct soundbus_dev *sdev = to_soundbus_device(dev);
33
+ struct platform_device *of = &sdev->ofdev;
34
+
35
+ return sprintf(buf, "%pOFn\n", of->dev.of_node);
36
+}
3737 static DEVICE_ATTR_RO(name);
38
-soundbus_config_of_attr (type, "%s\n");
38
+
39
+static ssize_t type_show(struct device *dev,
40
+ struct device_attribute *attr, char *buf)
41
+{
42
+ struct soundbus_dev *sdev = to_soundbus_device(dev);
43
+ struct platform_device *of = &sdev->ofdev;
44
+
45
+ return sprintf(buf, "%s\n", of_node_get_device_type(of->dev.of_node));
46
+}
3947 static DEVICE_ATTR_RO(type);
4048
4149 struct attribute *soundbus_dev_attrs[] = {