aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLevente Kurusa <levex@linux.com>2013-12-19 10:03:25 -0500
committerRalf Baechle <ralf@linux-mips.org>2014-07-30 07:27:50 -0400
commit1610c8a8f2d3eb5dac5a418356c179d28da4e74e (patch)
treeea7a4c2baf59af3684e384992d86f928dcd07c14
parent1795cd9b3a91d4b5473c97f491d63892442212ab (diff)
MIPS: TXx9: Add missing put_device call
This is required so that we give up the last reference to the device. Also, rework error path so that it is easier to read. [ralf@linux-mips.org: Reformat to Linux coding style and make txx9_device_release static; folded in build fix by Levente for the original patch.] Signed-off-by: Levente Kurusa <levex@linux.com> Cc: LKML <linux-kernel@vger.kernel.org> Cc: Aaro Koskinen <aaro.koskinen@iki.fi> Cc: Markos Chandras <markos.chandras@imgtec.com> Cc: Steven J. Hill <Steven.Hill@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/6259/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-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}