.. | .. |
---|
1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
---|
2 | 2 | #include <linux/kernel.h> |
---|
| 3 | +#include <linux/of.h> |
---|
3 | 4 | #include <linux/stat.h> |
---|
4 | 5 | /* FIX UP */ |
---|
5 | 6 | #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 | | -} |
---|
15 | 7 | |
---|
16 | 8 | static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, |
---|
17 | 9 | char *buf) |
---|
.. | .. |
---|
25 | 17 | strcat(buf, "\n"); |
---|
26 | 18 | length = strlen(buf); |
---|
27 | 19 | } 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)); |
---|
30 | 23 | } |
---|
31 | 24 | |
---|
32 | 25 | return length; |
---|
33 | 26 | } |
---|
34 | 27 | static DEVICE_ATTR_RO(modalias); |
---|
35 | 28 | |
---|
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 | +} |
---|
37 | 37 | 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 | +} |
---|
39 | 47 | static DEVICE_ATTR_RO(type); |
---|
40 | 48 | |
---|
41 | 49 | struct attribute *soundbus_dev_attrs[] = { |
---|