[PATCH linux dev-4.7 v2] drivers/fsi: Free up allocated resources on fsi-master unbind
Christopher Bostic
cbostic at linux.vnet.ibm.com
Fri Mar 10 06:12:39 AEDT 2017
In order to allow repeated bind/unbind operations on fsi-master
the scan file created on bind must be removed. Also check for
valid pointers during unregister which is the path taken during
unbind.
Signed-off-by: Christopher Bostic <cbostic at linux.vnet.ibm.com>
---
v2 - Remove devm_kfree in gpio remove
- Rebase on e97a91f178e55719b08d48af7f592b18cfd4da91
---
drivers/fsi/fsi-core.c | 8 ++++----
drivers/fsi/fsi-master-gpio.c | 1 +
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index b3b245a..3d382e6 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -868,11 +868,11 @@ EXPORT_SYMBOL_GPL(fsi_master_register);
void fsi_master_unregister(struct fsi_master *master)
{
- if (master->idx >= 0) {
- ida_simple_remove(&master_ida, master->idx);
- master->idx = -1;
- }
+ if (!master || !master->dev || master->idx < 0)
+ return;
+ ida_simple_remove(&master_ida, master->idx);
+ master->idx = -1;
device_remove_file(master->dev, &dev_attr_fsi_ipoll_period);
fsi_master_unscan(master);
put_device(master->dev);
diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index c923846..e3431c4 100644
--- a/drivers/fsi/fsi-master-gpio.c
+++ b/drivers/fsi/fsi-master-gpio.c
@@ -576,6 +576,7 @@ static int fsi_master_gpio_remove(struct platform_device *pdev)
devm_gpiod_put(&pdev->dev, master->gpio_mux);
}
fsi_master_unregister(&master->master);
+ device_remove_file(&pdev->dev, &dev_attr_scan);
return 0;
}
--
1.8.2.2
More information about the openbmc
mailing list