forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
kernel/drivers/soc/ux500/ux500-soc-id.c
....@@ -1,8 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) ST-Ericsson SA 2010
34 *
45 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
5
- * License terms: GNU General Public License (GPL) version 2
66 */
77
88 #include <linux/kernel.h>
....@@ -146,15 +146,23 @@
146146 return kasprintf(GFP_KERNEL, "%s", "Unknown");
147147 }
148148
149
-static ssize_t ux500_get_process(struct device *dev,
150
- struct device_attribute *attr,
151
- char *buf)
149
+static ssize_t
150
+process_show(struct device *dev, struct device_attribute *attr, char *buf)
152151 {
153152 if (dbx500_id.process == 0x00)
154153 return sprintf(buf, "Standard\n");
155154
156155 return sprintf(buf, "%02xnm\n", dbx500_id.process);
157156 }
157
+
158
+static DEVICE_ATTR_RO(process);
159
+
160
+static struct attribute *ux500_soc_attrs[] = {
161
+ &dev_attr_process.attr,
162
+ NULL
163
+};
164
+
165
+ATTRIBUTE_GROUPS(ux500_soc);
158166
159167 static const char *db8500_read_soc_id(struct device_node *backupram)
160168 {
....@@ -184,14 +192,11 @@
184192 soc_dev_attr->machine = ux500_get_machine();
185193 soc_dev_attr->family = ux500_get_family();
186194 soc_dev_attr->revision = ux500_get_revision();
195
+ soc_dev_attr->custom_attr_group = ux500_soc_groups[0];
187196 }
188
-
189
-static const struct device_attribute ux500_soc_attr =
190
- __ATTR(process, S_IRUGO, ux500_get_process, NULL);
191197
192198 static int __init ux500_soc_device_init(void)
193199 {
194
- struct device *parent;
195200 struct soc_device *soc_dev;
196201 struct soc_device_attribute *soc_dev_attr;
197202 struct device_node *backupram;
....@@ -203,19 +208,19 @@
203208 ux500_setup_id();
204209
205210 soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
206
- if (!soc_dev_attr)
211
+ if (!soc_dev_attr) {
212
+ of_node_put(backupram);
207213 return -ENOMEM;
214
+ }
208215
209216 soc_info_populate(soc_dev_attr, backupram);
217
+ of_node_put(backupram);
210218
211219 soc_dev = soc_device_register(soc_dev_attr);
212220 if (IS_ERR(soc_dev)) {
213221 kfree(soc_dev_attr);
214222 return PTR_ERR(soc_dev);
215223 }
216
-
217
- parent = soc_device_to_device(soc_dev);
218
- device_create_file(parent, &ux500_soc_attr);
219224
220225 return 0;
221226 }