mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-17 09:43:59 +08:00
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>
This commit is contained in:
parent
1795cd9b3a
commit
1610c8a8f2
@ -937,6 +937,14 @@ static ssize_t txx9_sram_write(struct file *filp, struct kobject *kobj,
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void txx9_device_release(struct device *dev)
|
||||||
|
{
|
||||||
|
struct txx9_sramc_dev *tdev;
|
||||||
|
|
||||||
|
tdev = container_of(dev, struct txx9_sramc_dev, dev);
|
||||||
|
kfree(tdev);
|
||||||
|
}
|
||||||
|
|
||||||
void __init txx9_sramc_init(struct resource *r)
|
void __init txx9_sramc_init(struct resource *r)
|
||||||
{
|
{
|
||||||
struct txx9_sramc_dev *dev;
|
struct txx9_sramc_dev *dev;
|
||||||
@ -951,8 +959,11 @@ void __init txx9_sramc_init(struct resource *r)
|
|||||||
return;
|
return;
|
||||||
size = resource_size(r);
|
size = resource_size(r);
|
||||||
dev->base = ioremap(r->start, size);
|
dev->base = ioremap(r->start, size);
|
||||||
if (!dev->base)
|
if (!dev->base) {
|
||||||
goto exit;
|
kfree(dev);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dev->dev.release = &txx9_device_release;
|
||||||
dev->dev.bus = &txx9_sramc_subsys;
|
dev->dev.bus = &txx9_sramc_subsys;
|
||||||
sysfs_bin_attr_init(&dev->bindata_attr);
|
sysfs_bin_attr_init(&dev->bindata_attr);
|
||||||
dev->bindata_attr.attr.name = "bindata";
|
dev->bindata_attr.attr.name = "bindata";
|
||||||
@ -963,17 +974,15 @@ void __init txx9_sramc_init(struct resource *r)
|
|||||||
dev->bindata_attr.private = dev;
|
dev->bindata_attr.private = dev;
|
||||||
err = device_register(&dev->dev);
|
err = device_register(&dev->dev);
|
||||||
if (err)
|
if (err)
|
||||||
goto exit;
|
goto exit_put;
|
||||||
err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr);
|
err = sysfs_create_bin_file(&dev->dev.kobj, &dev->bindata_attr);
|
||||||
if (err) {
|
if (err) {
|
||||||
device_unregister(&dev->dev);
|
device_unregister(&dev->dev);
|
||||||
goto exit;
|
iounmap(dev->base);
|
||||||
}
|
|
||||||
return;
|
|
||||||
exit:
|
|
||||||
if (dev) {
|
|
||||||
if (dev->base)
|
|
||||||
iounmap(dev->base);
|
|
||||||
kfree(dev);
|
kfree(dev);
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
exit_put:
|
||||||
|
put_device(&dev->dev);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user