hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/drivers/soc/versatile/soc-realview.c
....@@ -1,12 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2014 Linaro Ltd.
34 *
45 * Author: Linus Walleij <linus.walleij@linaro.org>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2, as
8
- * published by the Free Software Foundation.
9
- *
106 */
117 #include <linux/init.h>
128 #include <linux/io.h>
....@@ -43,45 +39,47 @@
4339 }
4440 }
4541
46
-static ssize_t realview_get_manf(struct device *dev,
47
- struct device_attribute *attr,
48
- char *buf)
42
+static ssize_t
43
+manufacturer_show(struct device *dev, struct device_attribute *attr, char *buf)
4944 {
5045 return sprintf(buf, "%02x\n", realview_coreid >> 24);
5146 }
5247
53
-static struct device_attribute realview_manf_attr =
54
- __ATTR(manufacturer, S_IRUGO, realview_get_manf, NULL);
48
+static DEVICE_ATTR_RO(manufacturer);
5549
56
-static ssize_t realview_get_board(struct device *dev,
57
- struct device_attribute *attr,
58
- char *buf)
50
+static ssize_t
51
+board_show(struct device *dev, struct device_attribute *attr, char *buf)
5952 {
6053 return sprintf(buf, "HBI-%03x\n", ((realview_coreid >> 16) & 0xfff));
6154 }
6255
63
-static struct device_attribute realview_board_attr =
64
- __ATTR(board, S_IRUGO, realview_get_board, NULL);
56
+static DEVICE_ATTR_RO(board);
6557
66
-static ssize_t realview_get_arch(struct device *dev,
67
- struct device_attribute *attr,
68
- char *buf)
58
+static ssize_t
59
+fpga_show(struct device *dev, struct device_attribute *attr, char *buf)
6960 {
7061 return sprintf(buf, "%s\n", realview_arch_str(realview_coreid));
7162 }
7263
73
-static struct device_attribute realview_arch_attr =
74
- __ATTR(fpga, S_IRUGO, realview_get_arch, NULL);
64
+static DEVICE_ATTR_RO(fpga);
7565
76
-static ssize_t realview_get_build(struct device *dev,
77
- struct device_attribute *attr,
78
- char *buf)
66
+static ssize_t
67
+build_show(struct device *dev, struct device_attribute *attr, char *buf)
7968 {
8069 return sprintf(buf, "%02x\n", (realview_coreid & 0xFF));
8170 }
8271
83
-static struct device_attribute realview_build_attr =
84
- __ATTR(build, S_IRUGO, realview_get_build, NULL);
72
+static DEVICE_ATTR_RO(build);
73
+
74
+static struct attribute *realview_attrs[] = {
75
+ &dev_attr_manufacturer.attr,
76
+ &dev_attr_board.attr,
77
+ &dev_attr_fpga.attr,
78
+ &dev_attr_build.attr,
79
+ NULL
80
+};
81
+
82
+ATTRIBUTE_GROUPS(realview);
8583
8684 static int realview_soc_probe(struct platform_device *pdev)
8785 {
....@@ -106,6 +104,7 @@
106104
107105 soc_dev_attr->machine = "RealView";
108106 soc_dev_attr->family = "Versatile";
107
+ soc_dev_attr->custom_attr_group = realview_groups[0];
109108 soc_dev = soc_device_register(soc_dev_attr);
110109 if (IS_ERR(soc_dev)) {
111110 kfree(soc_dev_attr);
....@@ -115,11 +114,6 @@
115114 &realview_coreid);
116115 if (ret)
117116 return -ENODEV;
118
-
119
- device_create_file(soc_device_to_device(soc_dev), &realview_manf_attr);
120
- device_create_file(soc_device_to_device(soc_dev), &realview_board_attr);
121
- device_create_file(soc_device_to_device(soc_dev), &realview_arch_attr);
122
- device_create_file(soc_device_to_device(soc_dev), &realview_build_attr);
123117
124118 dev_info(&pdev->dev, "RealView Syscon Core ID: 0x%08x, HBI-%03x\n",
125119 realview_coreid,