| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) ST-Ericsson SA 2010 |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson |
|---|
| 5 | | - * License terms: GNU General Public License (GPL) version 2 |
|---|
| 6 | 6 | */ |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 146 | 146 | return kasprintf(GFP_KERNEL, "%s", "Unknown"); |
|---|
| 147 | 147 | } |
|---|
| 148 | 148 | |
|---|
| 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) |
|---|
| 152 | 151 | { |
|---|
| 153 | 152 | if (dbx500_id.process == 0x00) |
|---|
| 154 | 153 | return sprintf(buf, "Standard\n"); |
|---|
| 155 | 154 | |
|---|
| 156 | 155 | return sprintf(buf, "%02xnm\n", dbx500_id.process); |
|---|
| 157 | 156 | } |
|---|
| 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); |
|---|
| 158 | 166 | |
|---|
| 159 | 167 | static const char *db8500_read_soc_id(struct device_node *backupram) |
|---|
| 160 | 168 | { |
|---|
| .. | .. |
|---|
| 184 | 192 | soc_dev_attr->machine = ux500_get_machine(); |
|---|
| 185 | 193 | soc_dev_attr->family = ux500_get_family(); |
|---|
| 186 | 194 | soc_dev_attr->revision = ux500_get_revision(); |
|---|
| 195 | + soc_dev_attr->custom_attr_group = ux500_soc_groups[0]; |
|---|
| 187 | 196 | } |
|---|
| 188 | | - |
|---|
| 189 | | -static const struct device_attribute ux500_soc_attr = |
|---|
| 190 | | - __ATTR(process, S_IRUGO, ux500_get_process, NULL); |
|---|
| 191 | 197 | |
|---|
| 192 | 198 | static int __init ux500_soc_device_init(void) |
|---|
| 193 | 199 | { |
|---|
| 194 | | - struct device *parent; |
|---|
| 195 | 200 | struct soc_device *soc_dev; |
|---|
| 196 | 201 | struct soc_device_attribute *soc_dev_attr; |
|---|
| 197 | 202 | struct device_node *backupram; |
|---|
| .. | .. |
|---|
| 203 | 208 | ux500_setup_id(); |
|---|
| 204 | 209 | |
|---|
| 205 | 210 | 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); |
|---|
| 207 | 213 | return -ENOMEM; |
|---|
| 214 | + } |
|---|
| 208 | 215 | |
|---|
| 209 | 216 | soc_info_populate(soc_dev_attr, backupram); |
|---|
| 217 | + of_node_put(backupram); |
|---|
| 210 | 218 | |
|---|
| 211 | 219 | soc_dev = soc_device_register(soc_dev_attr); |
|---|
| 212 | 220 | if (IS_ERR(soc_dev)) { |
|---|
| 213 | 221 | kfree(soc_dev_attr); |
|---|
| 214 | 222 | return PTR_ERR(soc_dev); |
|---|
| 215 | 223 | } |
|---|
| 216 | | - |
|---|
| 217 | | - parent = soc_device_to_device(soc_dev); |
|---|
| 218 | | - device_create_file(parent, &ux500_soc_attr); |
|---|
| 219 | 224 | |
|---|
| 220 | 225 | return 0; |
|---|
| 221 | 226 | } |
|---|