aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorChristian Krafft <krafft@de.ibm.com>2006-10-24 12:31:23 -0400
committerPaul Mackerras <paulus@samba.org>2006-10-25 00:20:21 -0400
commite570beb6bb1a623849901efbf939063ec4775c9e (patch)
tree9d6766eb2ca71393bf16f0aec0cbf726282dea6e /arch/powerpc
parentd8bf96e0793f9576da545bac333b2de304958d68 (diff)
[POWERPC] cell: add support for registering sysfs attributes to spus
In order to add sysfs attributes to all spu's, there is a need for a list of all available spu's. Adding the device_node makes also sense, as it is needed for proper register access. This patch also adds two functions to create and remove sysfs attributes and attribute_groups to all spus. That allows to group spu attributes in a subdirectory like: /sys/devices/system/spu/spuX/group_name/what_ever This will be used by cbe_thermal to group all attributes dealing with thermal support in one directory. Signed-off-by: Christian Krafft <krafft@de.ibm.com> Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index d78b0af038e6..b75b091098ef 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -333,6 +333,7 @@ static void spu_free_irqs(struct spu *spu)
333} 333}
334 334
335static struct list_head spu_list[MAX_NUMNODES]; 335static struct list_head spu_list[MAX_NUMNODES];
336static LIST_HEAD(spu_full_list);
336static DEFINE_MUTEX(spu_mutex); 337static DEFINE_MUTEX(spu_mutex);
337 338
338static void spu_init_channels(struct spu *spu) 339static void spu_init_channels(struct spu *spu)
@@ -744,6 +745,57 @@ struct sysdev_class spu_sysdev_class = {
744 set_kset_name("spu") 745 set_kset_name("spu")
745}; 746};
746 747
748int spu_add_sysdev_attr(struct sysdev_attribute *attr)
749{
750 struct spu *spu;
751 mutex_lock(&spu_mutex);
752
753 list_for_each_entry(spu, &spu_full_list, full_list)
754 sysdev_create_file(&spu->sysdev, attr);
755
756 mutex_unlock(&spu_mutex);
757 return 0;
758}
759EXPORT_SYMBOL_GPL(spu_add_sysdev_attr);
760
761int spu_add_sysdev_attr_group(struct attribute_group *attrs)
762{
763 struct spu *spu;
764 mutex_lock(&spu_mutex);
765
766 list_for_each_entry(spu, &spu_full_list, full_list)
767 sysfs_create_group(&spu->sysdev.kobj, attrs);
768
769 mutex_unlock(&spu_mutex);
770 return 0;
771}
772EXPORT_SYMBOL_GPL(spu_add_sysdev_attr_group);
773
774
775void spu_remove_sysdev_attr(struct sysdev_attribute *attr)
776{
777 struct spu *spu;
778 mutex_lock(&spu_mutex);
779
780 list_for_each_entry(spu, &spu_full_list, full_list)
781 sysdev_remove_file(&spu->sysdev, attr);
782
783 mutex_unlock(&spu_mutex);
784}
785EXPORT_SYMBOL_GPL(spu_remove_sysdev_attr);
786
787void spu_remove_sysdev_attr_group(struct attribute_group *attrs)
788{
789 struct spu *spu;
790 mutex_lock(&spu_mutex);
791
792 list_for_each_entry(spu, &spu_full_list, full_list)
793 sysfs_remove_group(&spu->sysdev.kobj, attrs);
794
795 mutex_unlock(&spu_mutex);
796}
797EXPORT_SYMBOL_GPL(spu_remove_sysdev_attr_group);
798
747static int spu_create_sysdev(struct spu *spu) 799static int spu_create_sysdev(struct spu *spu)
748{ 800{
749 int ret; 801 int ret;
@@ -817,6 +869,9 @@ static int __init create_spu(struct device_node *spe)
817 goto out_free_irqs; 869 goto out_free_irqs;
818 870
819 list_add(&spu->list, &spu_list[spu->node]); 871 list_add(&spu->list, &spu_list[spu->node]);
872 list_add(&spu->full_list, &spu_full_list);
873 spu->devnode = of_node_get(spe);
874
820 mutex_unlock(&spu_mutex); 875 mutex_unlock(&spu_mutex);
821 876
822 pr_debug(KERN_DEBUG "Using SPE %s %p %p %p %p %d\n", 877 pr_debug(KERN_DEBUG "Using SPE %s %p %p %p %p %d\n",
@@ -839,6 +894,9 @@ out:
839static void destroy_spu(struct spu *spu) 894static void destroy_spu(struct spu *spu)
840{ 895{
841 list_del_init(&spu->list); 896 list_del_init(&spu->list);
897 list_del_init(&spu->full_list);
898
899 of_node_put(spu->devnode);
842 900
843 spu_destroy_sysdev(spu); 901 spu_destroy_sysdev(spu);
844 spu_free_irqs(spu); 902 spu_free_irqs(spu);