* [PATCH 14/38] mips: txx9: add missing put_device call
[not found] <1387465429-3568-2-git-send-email-levex@linux.com>
@ 2013-12-19 15:03 ` Levente Kurusa
2013-12-19 15:03 ` [PATCH 15/38] mips: txx9: 7segled: " Levente Kurusa
2013-12-19 15:03 ` [PATCH 16/38] mips: sgi-ip22: " Levente Kurusa
2 siblings, 0 replies; 3+ messages in thread
From: Levente Kurusa @ 2013-12-19 15:03 UTC (permalink / raw)
To: LKML
Cc: Levente Kurusa, Ralf Baechle, Aaro Koskinen, Markos Chandras,
Steven J. Hill, linux-mips
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.
Signed-off-by: Levente Kurusa <levex@linux.com>
---
arch/mips/txx9/generic/setup.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 2b0b83c..24332f5 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -937,6 +937,12 @@ static ssize_t txx9_sram_write(struct file *filp, struct kobject *kobj,
return size;
}
+void txx9_device_release(struct device *dev) {
+ struct txx9_sramc_dev *sramc_dev;
+ txx9_sramc_dev = container_of(dev, struct txx9_sramc_dev, dev);
+ kfree(txx9_sramc_dev);
+}
+
void __init txx9_sramc_init(struct resource *r)
{
struct txx9_sramc_dev *dev;
@@ -951,8 +957,11 @@ void __init txx9_sramc_init(struct resource *r)
return;
size = resource_size(r);
dev->base = ioremap(r->start, size);
- if (!dev->base)
- goto exit;
+ if (!dev->base) {
+ kfree(dev);
+ return;
+ }
+ dev->dev.release = &txx9_device_release;
dev->dev.bus = &txx9_sramc_subsys;
sysfs_bin_attr_init(&dev->bindata_attr);
dev->bindata_attr.attr.name = "bindata";
@@ -963,17 +972,15 @@ void __init txx9_sramc_init(struct resource *r)
dev->bindata_attr.private = dev;
err = device_register(&dev->dev);
if (err)
- goto exit;
+ goto exit_put;
err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr);
if (err) {
device_unregister(&dev->dev);
- goto exit;
- }
- return;
-exit:
- if (dev) {
- if (dev->base)
- iounmap(dev->base);
+ iounmap(dev->base);
kfree(dev);
}
+ return;
+exit_put:
+ put_device(&dev->dev);
+ return;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 15/38] mips: txx9: 7segled: add missing put_device call
[not found] <1387465429-3568-2-git-send-email-levex@linux.com>
2013-12-19 15:03 ` [PATCH 14/38] mips: txx9: add missing put_device call Levente Kurusa
@ 2013-12-19 15:03 ` Levente Kurusa
2013-12-19 15:03 ` [PATCH 16/38] mips: sgi-ip22: " Levente Kurusa
2 siblings, 0 replies; 3+ messages in thread
From: Levente Kurusa @ 2013-12-19 15:03 UTC (permalink / raw)
To: LKML; +Cc: Levente Kurusa, Ralf Baechle, linux-mips
This is required so that we give up the last reference to the device.
Also, add a new tx_7segled_release function which will be called after the
put_device to ensure that device is kfree'd.
Signed-off-by: Levente Kurusa <levex@linux.com>
---
arch/mips/txx9/generic/7segled.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/arch/mips/txx9/generic/7segled.c b/arch/mips/txx9/generic/7segled.c
index 4642f56..3caa548 100644
--- a/arch/mips/txx9/generic/7segled.c
+++ b/arch/mips/txx9/generic/7segled.c
@@ -83,6 +83,10 @@ static struct bus_type tx_7segled_subsys = {
.dev_name = "7segled",
};
+void tx_7segled_release(struct device *dev) {
+ kfree(dev);
+}
+
static int __init tx_7segled_init_sysfs(void)
{
int error, i;
@@ -103,11 +107,14 @@ static int __init tx_7segled_init_sysfs(void)
}
dev->id = i;
dev->bus = &tx_7segled_subsys;
+ dev->release = &tx_7segled_release;
error = device_register(dev);
- if (!error) {
- device_create_file(dev, &dev_attr_ascii);
- device_create_file(dev, &dev_attr_raw);
+ if (error) {
+ put_device(dev);
+ return error;
}
+ device_create_file(dev, &dev_attr_ascii);
+ device_create_file(dev, &dev_attr_raw);
}
return error;
}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 16/38] mips: sgi-ip22: add missing put_device call
[not found] <1387465429-3568-2-git-send-email-levex@linux.com>
2013-12-19 15:03 ` [PATCH 14/38] mips: txx9: add missing put_device call Levente Kurusa
2013-12-19 15:03 ` [PATCH 15/38] mips: txx9: 7segled: " Levente Kurusa
@ 2013-12-19 15:03 ` Levente Kurusa
2 siblings, 0 replies; 3+ messages in thread
From: Levente Kurusa @ 2013-12-19 15:03 UTC (permalink / raw)
To: LKML; +Cc: Levente Kurusa, Ralf Baechle, linux-mips
This is required so that we give up the last reference to the device.
Also, create a gio_bus_release() that calls kfree on the device argument to
properly kfree() the memory allocated for the device.
Signed-off-by: Levente Kurusa <levex@linux.com>
---
arch/mips/sgi-ip22/ip22-gio.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c
index ab0e379..931da33 100644
--- a/arch/mips/sgi-ip22/ip22-gio.c
+++ b/arch/mips/sgi-ip22/ip22-gio.c
@@ -24,8 +24,13 @@ static struct {
{ .name = "SGI GR2/GR3", .id = 0x7f },
};
+void gio_bus_release(struct device *dev) {
+ kfree(dev);
+}
+
static struct device gio_bus = {
.init_name = "gio",
+ .release = &gio_bus_release,
};
/**
@@ -400,8 +405,10 @@ int __init ip22_gio_init(void)
int ret;
ret = device_register(&gio_bus);
- if (ret)
+ if (ret) {
+ put_device(&gio_bus);
return ret;
+ }
ret = bus_register(&gio_bus_type);
if (!ret) {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-12-19 15:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1387465429-3568-2-git-send-email-levex@linux.com>
2013-12-19 15:03 ` [PATCH 14/38] mips: txx9: add missing put_device call Levente Kurusa
2013-12-19 15:03 ` [PATCH 15/38] mips: txx9: 7segled: " Levente Kurusa
2013-12-19 15:03 ` [PATCH 16/38] mips: sgi-ip22: " Levente Kurusa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox