hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// SPDX-License-Identifier: GPL-2.0
#include <linux/kernel.h>
#include <linux/of.h>
#include <linux/stat.h>
/* FIX UP */
#include "soundbus.h"
 
static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
                char *buf)
{
   struct soundbus_dev *sdev = to_soundbus_device(dev);
   struct platform_device *of = &sdev->ofdev;
   int length;
 
   if (*sdev->modalias) {
       strlcpy(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;
}
static DEVICE_ATTR_RO(modalias);
 
static ssize_t name_show(struct device *dev,
            struct device_attribute *attr, char *buf)
{
   struct soundbus_dev *sdev = to_soundbus_device(dev);
   struct platform_device *of = &sdev->ofdev;
 
   return sprintf(buf, "%pOFn\n", of->dev.of_node);
}
static DEVICE_ATTR_RO(name);
 
static ssize_t type_show(struct device *dev,
            struct device_attribute *attr, char *buf)
{
   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));
}
static DEVICE_ATTR_RO(type);
 
struct attribute *soundbus_dev_attrs[] = {
   &dev_attr_name.attr,
   &dev_attr_type.attr,
   &dev_attr_modalias.attr,
   NULL,
};