| .. | .. |
|---|
| 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"); |
|---|
| .. | .. |
|---|
| 156 | 155 | return sprintf(buf, "%02xnm\n", dbx500_id.process); |
|---|
| 157 | 156 | } |
|---|
| 158 | 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); |
|---|
| 166 | + |
|---|
| 159 | 167 | static const char *db8500_read_soc_id(struct device_node *backupram) |
|---|
| 160 | 168 | { |
|---|
| 161 | 169 | void __iomem *base; |
|---|
| 162 | | - void __iomem *uid; |
|---|
| 163 | 170 | const char *retstr; |
|---|
| 171 | + u32 uid[5]; |
|---|
| 164 | 172 | |
|---|
| 165 | 173 | base = of_iomap(backupram, 0); |
|---|
| 166 | 174 | if (!base) |
|---|
| 167 | 175 | return NULL; |
|---|
| 168 | | - uid = base + 0x1fc0; |
|---|
| 176 | + memcpy_fromio(uid, base + 0x1fc0, sizeof(uid)); |
|---|
| 169 | 177 | |
|---|
| 170 | 178 | /* Throw these device-specific numbers into the entropy pool */ |
|---|
| 171 | | - add_device_randomness(uid, 0x14); |
|---|
| 179 | + add_device_randomness(uid, sizeof(uid)); |
|---|
| 172 | 180 | retstr = kasprintf(GFP_KERNEL, "%08x%08x%08x%08x%08x", |
|---|
| 173 | | - readl((u32 *)uid+0), |
|---|
| 174 | | - readl((u32 *)uid+1), readl((u32 *)uid+2), |
|---|
| 175 | | - readl((u32 *)uid+3), readl((u32 *)uid+4)); |
|---|
| 181 | + uid[0], uid[1], uid[2], uid[3], uid[4]); |
|---|
| 176 | 182 | iounmap(base); |
|---|
| 177 | 183 | return retstr; |
|---|
| 178 | 184 | } |
|---|
| .. | .. |
|---|
| 184 | 190 | soc_dev_attr->machine = ux500_get_machine(); |
|---|
| 185 | 191 | soc_dev_attr->family = ux500_get_family(); |
|---|
| 186 | 192 | soc_dev_attr->revision = ux500_get_revision(); |
|---|
| 193 | + soc_dev_attr->custom_attr_group = ux500_soc_groups[0]; |
|---|
| 187 | 194 | } |
|---|
| 188 | | - |
|---|
| 189 | | -static const struct device_attribute ux500_soc_attr = |
|---|
| 190 | | - __ATTR(process, S_IRUGO, ux500_get_process, NULL); |
|---|
| 191 | 195 | |
|---|
| 192 | 196 | static int __init ux500_soc_device_init(void) |
|---|
| 193 | 197 | { |
|---|
| 194 | | - struct device *parent; |
|---|
| 195 | 198 | struct soc_device *soc_dev; |
|---|
| 196 | 199 | struct soc_device_attribute *soc_dev_attr; |
|---|
| 197 | 200 | struct device_node *backupram; |
|---|
| .. | .. |
|---|
| 203 | 206 | ux500_setup_id(); |
|---|
| 204 | 207 | |
|---|
| 205 | 208 | soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL); |
|---|
| 206 | | - if (!soc_dev_attr) |
|---|
| 209 | + if (!soc_dev_attr) { |
|---|
| 210 | + of_node_put(backupram); |
|---|
| 207 | 211 | return -ENOMEM; |
|---|
| 212 | + } |
|---|
| 208 | 213 | |
|---|
| 209 | 214 | soc_info_populate(soc_dev_attr, backupram); |
|---|
| 215 | + of_node_put(backupram); |
|---|
| 210 | 216 | |
|---|
| 211 | 217 | soc_dev = soc_device_register(soc_dev_attr); |
|---|
| 212 | 218 | if (IS_ERR(soc_dev)) { |
|---|
| 213 | 219 | kfree(soc_dev_attr); |
|---|
| 214 | 220 | return PTR_ERR(soc_dev); |
|---|
| 215 | 221 | } |
|---|
| 216 | | - |
|---|
| 217 | | - parent = soc_device_to_device(soc_dev); |
|---|
| 218 | | - device_create_file(parent, &ux500_soc_attr); |
|---|
| 219 | 222 | |
|---|
| 220 | 223 | return 0; |
|---|
| 221 | 224 | } |
|---|