aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/txx9/generic/setup.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/mips/txx9/generic/setup.c')
-rw-r--r--arch/mips/txx9/generic/setup.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index ec38e00b255..ae77a7916c0 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -22,7 +22,7 @@
22#include <linux/serial_core.h> 22#include <linux/serial_core.h>
23#include <linux/mtd/physmap.h> 23#include <linux/mtd/physmap.h>
24#include <linux/leds.h> 24#include <linux/leds.h>
25#include <linux/sysdev.h> 25#include <linux/device.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/irq.h> 27#include <linux/irq.h>
28#include <asm/bootinfo.h> 28#include <asm/bootinfo.h>
@@ -897,10 +897,13 @@ void __init txx9_aclc_init(unsigned long baseaddr, int irq,
897#endif 897#endif
898} 898}
899 899
900static struct sysdev_class txx9_sramc_sysdev_class; 900static struct bus_type txx9_sramc_subsys = {
901 .name = "txx9_sram",
902 .dev_name = "txx9_sram",
903};
901 904
902struct txx9_sramc_sysdev { 905struct txx9_sramc_dev {
903 struct sys_device dev; 906 struct device dev;
904 struct bin_attribute bindata_attr; 907 struct bin_attribute bindata_attr;
905 void __iomem *base; 908 void __iomem *base;
906}; 909};
@@ -909,7 +912,7 @@ static ssize_t txx9_sram_read(struct file *filp, struct kobject *kobj,
909 struct bin_attribute *bin_attr, 912 struct bin_attribute *bin_attr,
910 char *buf, loff_t pos, size_t size) 913 char *buf, loff_t pos, size_t size)
911{ 914{
912 struct txx9_sramc_sysdev *dev = bin_attr->private; 915 struct txx9_sramc_dev *dev = bin_attr->private;
913 size_t ramsize = bin_attr->size; 916 size_t ramsize = bin_attr->size;
914 917
915 if (pos >= ramsize) 918 if (pos >= ramsize)
@@ -924,7 +927,7 @@ static ssize_t txx9_sram_write(struct file *filp, struct kobject *kobj,
924 struct bin_attribute *bin_attr, 927 struct bin_attribute *bin_attr,
925 char *buf, loff_t pos, size_t size) 928 char *buf, loff_t pos, size_t size)
926{ 929{
927 struct txx9_sramc_sysdev *dev = bin_attr->private; 930 struct txx9_sramc_dev *dev = bin_attr->private;
928 size_t ramsize = bin_attr->size; 931 size_t ramsize = bin_attr->size;
929 932
930 if (pos >= ramsize) 933 if (pos >= ramsize)
@@ -937,18 +940,13 @@ static ssize_t txx9_sram_write(struct file *filp, struct kobject *kobj,
937 940
938void __init txx9_sramc_init(struct resource *r) 941void __init txx9_sramc_init(struct resource *r)
939{ 942{
940 struct txx9_sramc_sysdev *dev; 943 struct txx9_sramc_dev *dev;
941 size_t size; 944 size_t size;
942 int err; 945 int err;
943 946
944 if (!txx9_sramc_sysdev_class.name) { 947 err = subsys_system_register(&txx9_sramc_subsys, NULL);
945 txx9_sramc_sysdev_class.name = "txx9_sram"; 948 if (err)
946 err = sysdev_class_register(&txx9_sramc_sysdev_class); 949 return;
947 if (err) {
948 txx9_sramc_sysdev_class.name = NULL;
949 return;
950 }
951 }
952 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 950 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
953 if (!dev) 951 if (!dev)
954 return; 952 return;
@@ -956,7 +954,7 @@ void __init txx9_sramc_init(struct resource *r)
956 dev->base = ioremap(r->start, size); 954 dev->base = ioremap(r->start, size);
957 if (!dev->base) 955 if (!dev->base)
958 goto exit; 956 goto exit;
959 dev->dev.cls = &txx9_sramc_sysdev_class; 957 dev->dev.bus = &txx9_sramc_subsys;
960 sysfs_bin_attr_init(&dev->bindata_attr); 958 sysfs_bin_attr_init(&dev->bindata_attr);
961 dev->bindata_attr.attr.name = "bindata"; 959 dev->bindata_attr.attr.name = "bindata";
962 dev->bindata_attr.attr.mode = S_IRUSR | S_IWUSR; 960 dev->bindata_attr.attr.mode = S_IRUSR | S_IWUSR;
@@ -964,12 +962,12 @@ void __init txx9_sramc_init(struct resource *r)
964 dev->bindata_attr.write = txx9_sram_write; 962 dev->bindata_attr.write = txx9_sram_write;
965 dev->bindata_attr.size = size; 963 dev->bindata_attr.size = size;
966 dev->bindata_attr.private = dev; 964 dev->bindata_attr.private = dev;
967 err = sysdev_register(&dev->dev); 965 err = device_register(&dev->dev);
968 if (err) 966 if (err)
969 goto exit; 967 goto exit;
970 err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr); 968 err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr);
971 if (err) { 969 if (err) {
972 sysdev_unregister(&dev->dev); 970 device_unregister(&dev->dev);
973 goto exit; 971 goto exit;
974 } 972 }
975 return; 973 return;