2019-05-27 14:55:05 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-10-04 00:59:50 +08:00
|
|
|
/*
|
|
|
|
* This file supports the /sys/firmware/sgi_uv interfaces for SGI UV.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
* Copyright (c) Russ Anderson
|
|
|
|
*/
|
|
|
|
|
2011-12-22 08:26:03 +08:00
|
|
|
#include <linux/device.h>
|
2008-10-04 00:59:50 +08:00
|
|
|
#include <asm/uv/bios.h>
|
2009-04-04 06:24:23 +08:00
|
|
|
#include <asm/uv/uv.h>
|
2008-10-04 00:59:50 +08:00
|
|
|
|
|
|
|
struct kobject *sgi_uv_kobj;
|
|
|
|
|
|
|
|
static ssize_t partition_id_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *buf)
|
|
|
|
{
|
|
|
|
return snprintf(buf, PAGE_SIZE, "%ld\n", sn_partition_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t coherence_id_show(struct kobject *kobj,
|
|
|
|
struct kobj_attribute *attr, char *buf)
|
|
|
|
{
|
2016-04-30 05:54:18 +08:00
|
|
|
return snprintf(buf, PAGE_SIZE, "%ld\n", uv_partition_coherence_id());
|
2008-10-04 00:59:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct kobj_attribute partition_id_attr =
|
|
|
|
__ATTR(partition_id, S_IRUGO, partition_id_show, NULL);
|
|
|
|
|
|
|
|
static struct kobj_attribute coherence_id_attr =
|
|
|
|
__ATTR(coherence_id, S_IRUGO, coherence_id_show, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
static int __init sgi_uv_sysfs_init(void)
|
|
|
|
{
|
|
|
|
unsigned long ret;
|
|
|
|
|
2009-04-04 06:24:23 +08:00
|
|
|
if (!is_uv_system())
|
|
|
|
return -ENODEV;
|
|
|
|
|
2008-10-04 00:59:50 +08:00
|
|
|
if (!sgi_uv_kobj)
|
|
|
|
sgi_uv_kobj = kobject_create_and_add("sgi_uv", firmware_kobj);
|
|
|
|
if (!sgi_uv_kobj) {
|
2010-02-07 01:47:17 +08:00
|
|
|
printk(KERN_WARNING "kobject_create_and_add sgi_uv failed\n");
|
2008-10-04 00:59:50 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = sysfs_create_file(sgi_uv_kobj, &partition_id_attr.attr);
|
|
|
|
if (ret) {
|
2010-02-07 01:47:17 +08:00
|
|
|
printk(KERN_WARNING "sysfs_create_file partition_id failed\n");
|
2008-10-04 00:59:50 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = sysfs_create_file(sgi_uv_kobj, &coherence_id_attr.attr);
|
|
|
|
if (ret) {
|
2010-02-07 01:47:17 +08:00
|
|
|
printk(KERN_WARNING "sysfs_create_file coherence_id failed\n");
|
2008-10-04 00:59:50 +08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
device_initcall(sgi_uv_sysfs_init);
|