drivers/fsi: Free up allocated resources on fsi-master unbind
PATCH v2 1/1 drivers/fsi: Free up allocated resources on fsi-master unbind
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 <[email protected]>
---
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(-)
drivers/fsi/fsi-core.c +4 -4
@@ -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);
drivers/fsi/fsi-master-gpio.c +1 -0
@@ -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 ; }
Signature · 1 line
1.8.2.2
Joel Stanley
AppliedQuoted 9 lines · Christopher Bostic
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 <[email protected]>---
v2 - Removedevm_kfreein gpio remove
- Rebase one97a91f178e55719b08d48af7f592b18cfd4da91
Applied to dev-4.7.
Cheers,
Joel
Quoted 40 lines
--- drivers/fsi/fsi-core.c | 8 ++++---- drivers/fsi/fsi-master-gpio.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-)drivers/fsi/fsi-core.c +4
-4@@ -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);drivers/fsi/fsi-master-gpio.c +1
-1@@ -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