drivers: fsi: Improve driver cleanup
cover drivers: fsi: Improve driver cleanup
From: "Edward A. James" <[email protected]>
Need to delete the fsi device during the "unscan" process. Also add remove function for scom client driver, otherwise we end up with bad files in /dev.
Edward A. James (2):
drivers: fsi: delete device on unscan
drivers: fsi: scom: Add remove function
drivers/fsi/fsi-core.c | 1 + drivers/fsi/fsi-scom.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+)
Signature · 1 line
1.8.3.1
PATCH 1/2 drivers: fsi: delete device on unscan
From: "Edward A. James" <[email protected]>
need to delete device so that client driver "remove" is called.
--- drivers/fsi/fsi-core.c | 1 + 1 file changed, 1 insertion(+)
drivers/fsi/fsi-core.c +1 -0
@@ -512,6 +512,7 @@ static void fsi_master_unscan(struct fsi_master *master)list_for_each_entry_safe (fsi_dev, fsi_dev_tmp, &slave->my_engines, link) {list_del (&fsi_dev->link); +device_del (&fsi_dev->dev);put_device (&fsi_dev->dev); }device_unregister (&slave->dev);
Signature · 1 line
1.8.3.1
Re: [PATCH linux dev-4.7 1/2] drivers: fsi: delete device on unscan
Acked by: Christopher Bostic <[email protected]>
Quoted 21 lines · Eddie James
From: "Edward A. James" <[email protected]>
need to delete device so that client driver "remove" is called.
Signed-off-by Edward A. James <[email protected]>--- drivers/fsi/fsi-core.c | 1 + 1 file changed, 1 insertion(+)drivers/fsi/fsi-core.c +1
-0@@ -512,6 +512,7 @@ static void fsi_master_unscan(struct fsi_master *master)list_for_each_entry_safe (fsi_dev, fsi_dev_tmp, &slave->my_engines, link) {list_del (&fsi_dev->link); +device_del (&fsi_dev->dev);put_device (&fsi_dev->dev); }device_unregister (&slave->dev);
Re: [PATCH linux dev-4.7 1/2] drivers: fsi: delete device on unscan
Hi Chris,
Quoted 1 line · Christopher Bostic
Acked by: Christopher Bostic <[email protected]>
Thanks for checking over this.
Next time you need to write "Acked-by" for patchwork to recognise your tag:
http://patchwork.ozlabs.org/patch/727563/
Cheers,
Joel
Quoted 29 lines · Eddie James
Quoted 23 lines
From: "Edward A. James" <[email protected]>
need to delete device so that client driver "remove" is called.
Signed-off-by Edward A. James <[email protected]>--- drivers/fsi/fsi-core.c | 1 + 1 file changed, 1 insertion(+)drivers/fsi/fsi-core.c +1
-0@@ -512,6 +512,7 @@ static void fsi_master_unscan(struct fsi_master *master)list_for_each_entry_safe (fsi_dev, fsi_dev_tmp, &slave->my_engines, link) {list_del (&fsi_dev->link); +device_del (&fsi_dev->dev);put_device (&fsi_dev->dev); }device_unregister(&slave->dev);
Re: [PATCH linux dev-4.7 1/2] drivers: fsi: delete device on unscan
In reply to Eddie JamesQuoted 14 lines · Eddie James
From: "Edward A. James" <[email protected]>
need to delete device so that client driver "remove" is called.
Signed-off-by Edward A. James <[email protected]>--- drivers/fsi/fsi-core.c | 1 + 1 file changed, 1 insertion(+)drivers/fsi/fsi-core.c +0
-0
drivers/fsi/fsi-core.c static void fsi_master_unscan(struct fsi_master *master) · line 516
Quoted 5 lines
drivers/fsi/fsi-core.c +1
-0@@ -512,6 +512,7 @@ static void fsi_master_unscan(struct fsi_master *master)list_for_each_entry_safe (fsi_dev, fsi_dev_tmp, &slave->my_engines, link) {list_del (&fsi_dev->link); +device_del (&fsi_dev->dev);put_device (&fsi_dev->dev);
put_device calls kobject_put, but device_del has already called kobject_del. Are you sure this is what you want to do here?
Quoted 5 lines
drivers/fsi/fsi-core.c +0
-1}device_unregister (&slave->dev); --1.8.3.1
Re: [PATCH linux dev-4.7 1/2] drivers: fsi: delete device on unscan
Quoted 10 lines · Joel Stanley
Quoted 9 lines · Eddie James
From: "Edward A. James" <[email protected]>
need to delete device so that client driver "remove" is called.
Signed-off-by Edward A. James <[email protected]>--- drivers/fsi/fsi-core.c | 1 + 1 file changed, 1 insertion(+)
Quoted 12 lines
drivers/fsi/fsi-core.c static void fsi_master_unscan(struct fsi_master *master) · line 516
Quoted 10 lines
drivers/fsi/fsi-core.c +1
-0@@ -512,6 +512,7 @@ static void fsi_master_unscan(struct fsi_master *master)list_for_each_entry_safe (fsi_dev, fsi_dev_tmp, &slave->my_engines, link) {list_del (&fsi_dev->link); +device_del (&fsi_dev->dev);put_device (&fsi_dev->dev);
put_devicecallskobject_put, butdevice_delhas already calledkobject_del. Are you sure this is what you want to do here?
Hmm, I was just doing what device_unregister() does. We manually call device_add() for these devices, so I understand from the documentation that device_del() should be called, but I think device_unregister would work as well. I can confirm this works and doesn't throw any warnings after repeated fsi scans.
Quoted 7 lines
Quoted 7 lines
drivers/fsi/fsi-core.c +0
-1}device_unregister (&slave->dev); --1.8.3.1
Re: [PATCH linux dev-4.7 1/2] drivers: fsi: delete device on unscan
Quoted 13 lines · Eddie James
Quoted 10 lines · Joel Stanley
drivers/fsi/fsi-core.c static void fsi_master_unscan(struct fsi_master · line 517
Quoted 7 lines
drivers/fsi/fsi-core.c +1
-0@@ -512,6 +512,7 @@ static void fsi_master_unscan(struct fsi_master *master)list_for_each_entry_safe (fsi_dev, fsi_dev_tmp, &slave->my_engines, link) {list_del (&fsi_dev->link); +device_del (&fsi_dev->dev);put_device (&fsi_dev->dev);
put_devicecallskobject_put, butdevice_delhas already calledkobject_del. Are you sure this is what you want to do here?
Quoted 5 lines
Hmm, I was just doing what
device_unregister()does. We manually calldevice_add()for these devices, so I understand from the documentation thatdevice_del()should be called, but I thinkdevice_unregisterwould work as well. I can confirm this works and doesn't throw any warnings after repeated fsi scans.
Thanks for looking into this.
I will merge this patch as-is, but please work with Chris to get this change added to his upstream FSI patchset. The fix should be folded into his series for his next submission (v4).
Cheers,
Joel
PATCH 2/2 drivers: fsi: scom: Add remove function
In reply to Eddie JamesFrom: "Edward A. James" <[email protected]>
driver wasn't cleaning up miscdevice
--- drivers/fsi/fsi-scom.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/fsi/fsi-scom.c +16 -0
@@ -199,6 +199,21 @@ static int scom_probe(struct device *dev)return misc_register (&scom->mdev); } +static int scom_remove (struct device *dev) +{ +struct scom_device *scom, *scom_tmp; +struct fsi_device *fsi_dev =to_fsi_dev (dev); + +list_for_each_entry_safe (scom, scom_tmp, &scom_devices, link) { +if (scom->fsi_dev == fsi_dev) { +list_del (&scom->link); +misc_deregister (&scom->mdev); + } + } + +return 0 ; +} +static struct fsi_device_id scom_ids[] = { { .engine_type =FSI_ENGID_SCOM ,
@@ -213,6 +228,7 @@ static struct fsi_driver scom_drv = { .name = "scom", .bus = &fsi_bus_type, .probe = scom_probe, + .remove = scom_remove, } };
Signature · 1 line
1.8.3.1
Re: [PATCH linux dev-4.7 2/2] drivers: fsi: scom: Add remove function
Acked by: Christopher Bostic <[email protected]>
Quoted 43 lines · Eddie James
From: "Edward A. James" <[email protected]>
driver wasn't cleaning up miscdevice
Signed-off-by Edward A. James <[email protected]>--- drivers/fsi/fsi-scom.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)drivers/fsi/fsi-scom.c +16
-0@@ -199,6 +199,21 @@ static int scom_probe(struct device *dev)return misc_register (&scom->mdev); } +static int scom_remove (struct device *dev) +{ +struct scom_device *scom, *scom_tmp; +struct fsi_device *fsi_dev =to_fsi_dev (dev); + +list_for_each_entry_safe (scom, scom_tmp, &scom_devices, link) { +if (scom->fsi_dev == fsi_dev) { +list_del (&scom->link); +misc_deregister (&scom->mdev); + } + } + +return 0 ; +} +static struct fsi_device_id scom_ids[] = { { .engine_type =FSI_ENGID_SCOM ,@@ -213,6 +228,7 @@ static struct fsi_driver scom_drv = { .name = "scom", .bus = &fsi_bus_type, .probe = scom_probe, + .remove = scom_remove, } };