Commit | Line | Data |
---|---|---|
1a59d1b8 | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
fc8c2d76 RA |
2 | /* |
3 | * This file supports the /sys/firmware/sgi_uv interfaces for SGI UV. | |
4 | * | |
fc8c2d76 RA |
5 | * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved. |
6 | * Copyright (c) Russ Anderson | |
7 | */ | |
8 | ||
edbaa603 | 9 | #include <linux/device.h> |
fc8c2d76 | 10 | #include <asm/uv/bios.h> |
06aa05b3 | 11 | #include <asm/uv/uv.h> |
fc8c2d76 RA |
12 | |
13 | struct kobject *sgi_uv_kobj; | |
14 | ||
15 | static ssize_t partition_id_show(struct kobject *kobj, | |
16 | struct kobj_attribute *attr, char *buf) | |
17 | { | |
18 | return snprintf(buf, PAGE_SIZE, "%ld\n", sn_partition_id); | |
19 | } | |
20 | ||
21 | static ssize_t coherence_id_show(struct kobject *kobj, | |
22 | struct kobj_attribute *attr, char *buf) | |
23 | { | |
ef93bf80 | 24 | return snprintf(buf, PAGE_SIZE, "%ld\n", uv_partition_coherence_id()); |
fc8c2d76 RA |
25 | } |
26 | ||
27 | static struct kobj_attribute partition_id_attr = | |
28 | __ATTR(partition_id, S_IRUGO, partition_id_show, NULL); | |
29 | ||
30 | static struct kobj_attribute coherence_id_attr = | |
31 | __ATTR(coherence_id, S_IRUGO, coherence_id_show, NULL); | |
32 | ||
33 | ||
34 | static int __init sgi_uv_sysfs_init(void) | |
35 | { | |
36 | unsigned long ret; | |
37 | ||
06aa05b3 RA |
38 | if (!is_uv_system()) |
39 | return -ENODEV; | |
40 | ||
fc8c2d76 RA |
41 | if (!sgi_uv_kobj) |
42 | sgi_uv_kobj = kobject_create_and_add("sgi_uv", firmware_kobj); | |
43 | if (!sgi_uv_kobj) { | |
3235dc3f | 44 | printk(KERN_WARNING "kobject_create_and_add sgi_uv failed\n"); |
fc8c2d76 RA |
45 | return -EINVAL; |
46 | } | |
47 | ||
48 | ret = sysfs_create_file(sgi_uv_kobj, &partition_id_attr.attr); | |
49 | if (ret) { | |
3235dc3f | 50 | printk(KERN_WARNING "sysfs_create_file partition_id failed\n"); |
fc8c2d76 RA |
51 | return ret; |
52 | } | |
53 | ||
54 | ret = sysfs_create_file(sgi_uv_kobj, &coherence_id_attr.attr); | |
55 | if (ret) { | |
3235dc3f | 56 | printk(KERN_WARNING "sysfs_create_file coherence_id failed\n"); |
fc8c2d76 RA |
57 | return ret; |
58 | } | |
59 | ||
60 | return 0; | |
61 | } | |
62 | ||
63 | device_initcall(sgi_uv_sysfs_init); |