uv_sysfs.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * This file supports the /sys/firmware/sgi_uv interfaces for SGI UV.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17. *
  18. * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
  19. * Copyright (c) Russ Anderson
  20. */
  21. #include <linux/device.h>
  22. #include <asm/uv/bios.h>
  23. #include <asm/uv/uv.h>
  24. struct kobject *sgi_uv_kobj;
  25. static ssize_t partition_id_show(struct kobject *kobj,
  26. struct kobj_attribute *attr, char *buf)
  27. {
  28. return snprintf(buf, PAGE_SIZE, "%ld\n", sn_partition_id);
  29. }
  30. static ssize_t coherence_id_show(struct kobject *kobj,
  31. struct kobj_attribute *attr, char *buf)
  32. {
  33. return snprintf(buf, PAGE_SIZE, "%ld\n", uv_partition_coherence_id());
  34. }
  35. static struct kobj_attribute partition_id_attr =
  36. __ATTR(partition_id, S_IRUGO, partition_id_show, NULL);
  37. static struct kobj_attribute coherence_id_attr =
  38. __ATTR(coherence_id, S_IRUGO, coherence_id_show, NULL);
  39. static int __init sgi_uv_sysfs_init(void)
  40. {
  41. unsigned long ret;
  42. if (!is_uv_system())
  43. return -ENODEV;
  44. if (!sgi_uv_kobj)
  45. sgi_uv_kobj = kobject_create_and_add("sgi_uv", firmware_kobj);
  46. if (!sgi_uv_kobj) {
  47. printk(KERN_WARNING "kobject_create_and_add sgi_uv failed\n");
  48. return -EINVAL;
  49. }
  50. ret = sysfs_create_file(sgi_uv_kobj, &partition_id_attr.attr);
  51. if (ret) {
  52. printk(KERN_WARNING "sysfs_create_file partition_id failed\n");
  53. return ret;
  54. }
  55. ret = sysfs_create_file(sgi_uv_kobj, &coherence_id_attr.attr);
  56. if (ret) {
  57. printk(KERN_WARNING "sysfs_create_file coherence_id failed\n");
  58. return ret;
  59. }
  60. return 0;
  61. }
  62. device_initcall(sgi_uv_sysfs_init);