aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/txx9/generic/setup.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index dd2cf25b5ae5..9ff200ae1c9a 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -937,6 +937,14 @@ static ssize_t txx9_sram_write(struct file *filp, struct kobject *kobj,
937 return size; 937 return size;
938} 938}
939 939
940static void txx9_device_release(struct device *dev)
941{
942 struct txx9_sramc_dev *tdev;
943
944 tdev = container_of(dev, struct txx9_sramc_dev, dev);
945 kfree(tdev);
946}
947
940void __init txx9_sramc_init(struct resource *r) 948void __init txx9_sramc_init(struct resource *r)
941{ 949{
942 struct txx9_sramc_dev *dev; 950 struct txx9_sramc_dev *dev;
@@ -951,8 +959,11 @@ void __init txx9_sramc_init(struct resource *r)
951 return; 959 return;
952 size = resource_size(r); 960 size = resource_size(r);
953 dev->base = ioremap(r->start, size); 961 dev->base = ioremap(r->start, size);
954 if (!dev->base) 962 if (!dev->base) {
955 goto exit; 963 kfree(dev);
964 return;
965 }
966 dev->dev.release = &txx9_device_release;
956 dev->dev.bus = &txx9_sramc_subsys; 967 dev->dev.bus = &txx9_sramc_subsys;
957 sysfs_bin_attr_init(&dev->bindata_attr); 968 sysfs_bin_attr_init(&dev->bindata_attr);
958 dev->bindata_attr.attr.name = "bindata"; 969 dev->bindata_attr.attr.name = "bindata";
@@ -963,17 +974,15 @@ void __init txx9_sramc_init(struct resource *r)
963 dev->bindata_attr.private = dev; 974 dev->bindata_attr.private = dev;
964 err = device_register(&dev->dev); 975 err = device_register(&dev->dev);
965 if (err) 976 if (err)
966 goto exit; 977 goto exit_put;
967 err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr); 978 err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr);
968 if (err) { 979 if (err) {
969 device_unregister(&dev->dev); 980 device_unregister(&dev->dev);
970 goto exit; 981 iounmap(dev->base);
971 }
972 return;
973exit:
974 if (dev) {
975 if (dev->base)
976 iounmap(dev->base);
977 kfree(dev); 982 kfree(dev);
978 } 983 }
984 return;
985exit_put:
986 put_device(&dev->dev);
987 return;
979} 988}