aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/cell/spu_base.c
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2011-12-21 17:29:42 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2011-12-21 17:29:42 -0500
commit8a25a2fd126c621f44f3aeaef80d51f00fc11639 (patch)
tree41694ab1a9c82a7a02d9cd33c929fd039c98c815 /arch/powerpc/platforms/cell/spu_base.c
parentcb0c05c5fae12eeb7c85c205578df277bd706155 (diff)
cpu: convert 'cpu' and 'machinecheck' sysdev_class to a regular subsystem
This moves the 'cpu sysdev_class' over to a regular 'cpu' subsystem and converts the devices to regular devices. The sysdev drivers are implemented as subsystem interfaces now. After all sysdev classes are ported to regular driver core entities, the sysdev implementation will be entirely removed from the kernel. Userspace relies on events and generic sysfs subsystem infrastructure from sysdev devices, which are made available with this conversion. Cc: Haavard Skinnemoen <hskinnemoen@gmail.com> Cc: Hans-Christian Egtvedt <egtvedt@samfundet.no> Cc: Tony Luck <tony.luck@intel.com> Cc: Fenghua Yu <fenghua.yu@intel.com> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Martin Schwidefsky <schwidefsky@de.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Paul Mundt <lethal@linux-sh.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Chris Metcalf <cmetcalf@tilera.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Borislav Petkov <bp@amd64.org> Cc: Tigran Aivazian <tigran@aivazian.fsnet.co.uk> Cc: Len Brown <lenb@kernel.org> Cc: Zhang Rui <rui.zhang@intel.com> Cc: Dave Jones <davej@redhat.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Russell King <rmk+kernel@arm.linux.org.uk> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Arjan van de Ven <arjan@linux.intel.com> Cc: "Rafael J. Wysocki" <rjw@sisk.pl> Cc: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com> Signed-off-by: Kay Sievers <kay.sievers@vrfy.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'arch/powerpc/platforms/cell/spu_base.c')
-rw-r--r--arch/powerpc/platforms/cell/spu_base.c61
1 files changed, 31 insertions, 30 deletions
diff --git a/arch/powerpc/platforms/cell/spu_base.c b/arch/powerpc/platforms/cell/spu_base.c
index 3675da73623..1708fb7aba3 100644
--- a/arch/powerpc/platforms/cell/spu_base.c
+++ b/arch/powerpc/platforms/cell/spu_base.c
@@ -522,31 +522,32 @@ void spu_init_channels(struct spu *spu)
522} 522}
523EXPORT_SYMBOL_GPL(spu_init_channels); 523EXPORT_SYMBOL_GPL(spu_init_channels);
524 524
525static struct sysdev_class spu_sysdev_class = { 525static struct bus_type spu_subsys = {
526 .name = "spu", 526 .name = "spu",
527 .dev_name = "spu",
527}; 528};
528 529
529int spu_add_sysdev_attr(struct sysdev_attribute *attr) 530int spu_add_dev_attr(struct device_attribute *attr)
530{ 531{
531 struct spu *spu; 532 struct spu *spu;
532 533
533 mutex_lock(&spu_full_list_mutex); 534 mutex_lock(&spu_full_list_mutex);
534 list_for_each_entry(spu, &spu_full_list, full_list) 535 list_for_each_entry(spu, &spu_full_list, full_list)
535 sysdev_create_file(&spu->sysdev, attr); 536 device_create_file(&spu->dev, attr);
536 mutex_unlock(&spu_full_list_mutex); 537 mutex_unlock(&spu_full_list_mutex);
537 538
538 return 0; 539 return 0;
539} 540}
540EXPORT_SYMBOL_GPL(spu_add_sysdev_attr); 541EXPORT_SYMBOL_GPL(spu_add_dev_attr);
541 542
542int spu_add_sysdev_attr_group(struct attribute_group *attrs) 543int spu_add_dev_attr_group(struct attribute_group *attrs)
543{ 544{
544 struct spu *spu; 545 struct spu *spu;
545 int rc = 0; 546 int rc = 0;
546 547
547 mutex_lock(&spu_full_list_mutex); 548 mutex_lock(&spu_full_list_mutex);
548 list_for_each_entry(spu, &spu_full_list, full_list) { 549 list_for_each_entry(spu, &spu_full_list, full_list) {
549 rc = sysfs_create_group(&spu->sysdev.kobj, attrs); 550 rc = sysfs_create_group(&spu->dev.kobj, attrs);
550 551
551 /* we're in trouble here, but try unwinding anyway */ 552 /* we're in trouble here, but try unwinding anyway */
552 if (rc) { 553 if (rc) {
@@ -555,7 +556,7 @@ int spu_add_sysdev_attr_group(struct attribute_group *attrs)
555 556
556 list_for_each_entry_continue_reverse(spu, 557 list_for_each_entry_continue_reverse(spu,
557 &spu_full_list, full_list) 558 &spu_full_list, full_list)
558 sysfs_remove_group(&spu->sysdev.kobj, attrs); 559 sysfs_remove_group(&spu->dev.kobj, attrs);
559 break; 560 break;
560 } 561 }
561 } 562 }
@@ -564,45 +565,45 @@ int spu_add_sysdev_attr_group(struct attribute_group *attrs)
564 565
565 return rc; 566 return rc;
566} 567}
567EXPORT_SYMBOL_GPL(spu_add_sysdev_attr_group); 568EXPORT_SYMBOL_GPL(spu_add_dev_attr_group);
568 569
569 570
570void spu_remove_sysdev_attr(struct sysdev_attribute *attr) 571void spu_remove_dev_attr(struct device_attribute *attr)
571{ 572{
572 struct spu *spu; 573 struct spu *spu;
573 574
574 mutex_lock(&spu_full_list_mutex); 575 mutex_lock(&spu_full_list_mutex);
575 list_for_each_entry(spu, &spu_full_list, full_list) 576 list_for_each_entry(spu, &spu_full_list, full_list)
576 sysdev_remove_file(&spu->sysdev, attr); 577 device_remove_file(&spu->dev, attr);
577 mutex_unlock(&spu_full_list_mutex); 578 mutex_unlock(&spu_full_list_mutex);
578} 579}
579EXPORT_SYMBOL_GPL(spu_remove_sysdev_attr); 580EXPORT_SYMBOL_GPL(spu_remove_dev_attr);
580 581
581void spu_remove_sysdev_attr_group(struct attribute_group *attrs) 582void spu_remove_dev_attr_group(struct attribute_group *attrs)
582{ 583{
583 struct spu *spu; 584 struct spu *spu;
584 585
585 mutex_lock(&spu_full_list_mutex); 586 mutex_lock(&spu_full_list_mutex);
586 list_for_each_entry(spu, &spu_full_list, full_list) 587 list_for_each_entry(spu, &spu_full_list, full_list)
587 sysfs_remove_group(&spu->sysdev.kobj, attrs); 588 sysfs_remove_group(&spu->dev.kobj, attrs);
588 mutex_unlock(&spu_full_list_mutex); 589 mutex_unlock(&spu_full_list_mutex);
589} 590}
590EXPORT_SYMBOL_GPL(spu_remove_sysdev_attr_group); 591EXPORT_SYMBOL_GPL(spu_remove_dev_attr_group);
591 592
592static int spu_create_sysdev(struct spu *spu) 593static int spu_create_dev(struct spu *spu)
593{ 594{
594 int ret; 595 int ret;
595 596
596 spu->sysdev.id = spu->number; 597 spu->dev.id = spu->number;
597 spu->sysdev.cls = &spu_sysdev_class; 598 spu->dev.bus = &spu_subsys;
598 ret = sysdev_register(&spu->sysdev); 599 ret = device_register(&spu->dev);
599 if (ret) { 600 if (ret) {
600 printk(KERN_ERR "Can't register SPU %d with sysfs\n", 601 printk(KERN_ERR "Can't register SPU %d with sysfs\n",
601 spu->number); 602 spu->number);
602 return ret; 603 return ret;
603 } 604 }
604 605
605 sysfs_add_device_to_node(&spu->sysdev, spu->node); 606 sysfs_add_device_to_node(&spu->dev, spu->node);
606 607
607 return 0; 608 return 0;
608} 609}
@@ -638,7 +639,7 @@ static int __init create_spu(void *data)
638 if (ret) 639 if (ret)
639 goto out_destroy; 640 goto out_destroy;
640 641
641 ret = spu_create_sysdev(spu); 642 ret = spu_create_dev(spu);
642 if (ret) 643 if (ret)
643 goto out_free_irqs; 644 goto out_free_irqs;
644 645
@@ -695,10 +696,10 @@ static unsigned long long spu_acct_time(struct spu *spu,
695} 696}
696 697
697 698
698static ssize_t spu_stat_show(struct sys_device *sysdev, 699static ssize_t spu_stat_show(struct device *dev,
699 struct sysdev_attribute *attr, char *buf) 700 struct device_attribute *attr, char *buf)
700{ 701{
701 struct spu *spu = container_of(sysdev, struct spu, sysdev); 702 struct spu *spu = container_of(dev, struct spu, dev);
702 703
703 return sprintf(buf, "%s %llu %llu %llu %llu " 704 return sprintf(buf, "%s %llu %llu %llu %llu "
704 "%llu %llu %llu %llu %llu %llu %llu %llu\n", 705 "%llu %llu %llu %llu %llu %llu %llu %llu\n",
@@ -717,7 +718,7 @@ static ssize_t spu_stat_show(struct sys_device *sysdev,
717 spu->stats.libassist); 718 spu->stats.libassist);
718} 719}
719 720
720static SYSDEV_ATTR(stat, 0644, spu_stat_show, NULL); 721static DEVICE_ATTR(stat, 0644, spu_stat_show, NULL);
721 722
722#ifdef CONFIG_KEXEC 723#ifdef CONFIG_KEXEC
723 724
@@ -816,8 +817,8 @@ static int __init init_spu_base(void)
816 if (!spu_management_ops) 817 if (!spu_management_ops)
817 goto out; 818 goto out;
818 819
819 /* create sysdev class for spus */ 820 /* create system subsystem for spus */
820 ret = sysdev_class_register(&spu_sysdev_class); 821 ret = subsys_system_register(&spu_subsys, NULL);
821 if (ret) 822 if (ret)
822 goto out; 823 goto out;
823 824
@@ -826,7 +827,7 @@ static int __init init_spu_base(void)
826 if (ret < 0) { 827 if (ret < 0) {
827 printk(KERN_WARNING "%s: Error initializing spus\n", 828 printk(KERN_WARNING "%s: Error initializing spus\n",
828 __func__); 829 __func__);
829 goto out_unregister_sysdev_class; 830 goto out_unregister_subsys;
830 } 831 }
831 832
832 if (ret > 0) 833 if (ret > 0)
@@ -836,15 +837,15 @@ static int __init init_spu_base(void)
836 xmon_register_spus(&spu_full_list); 837 xmon_register_spus(&spu_full_list);
837 crash_register_spus(&spu_full_list); 838 crash_register_spus(&spu_full_list);
838 mutex_unlock(&spu_full_list_mutex); 839 mutex_unlock(&spu_full_list_mutex);
839 spu_add_sysdev_attr(&attr_stat); 840 spu_add_dev_attr(&dev_attr_stat);
840 register_syscore_ops(&spu_syscore_ops); 841 register_syscore_ops(&spu_syscore_ops);
841 842
842 spu_init_affinity(); 843 spu_init_affinity();
843 844
844 return 0; 845 return 0;
845 846
846 out_unregister_sysdev_class: 847 out_unregister_subsys:
847 sysdev_class_unregister(&spu_sysdev_class); 848 bus_unregister(&spu_subsys);
848 out: 849 out:
849 return ret; 850 return ret;
850} 851}