drivers/fsi: Remove hub devices during master unregister
PATCH 1/1 drivers/fsi: Remove hub devices during master unregister
All hub devices must be removed when the primary FSI master is being unregistered. This ensures that the system is in a clean state when another scan is attempted. Failure to do so will result in duplicate /sys device name errors.
--- drivers/fsi/fsi-core.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/fsi/fsi-core.c +16 -0
@@ -84,6 +84,7 @@ struct fsi_master_hub {#define to_fsi_master_hub (d) container_of(d, struct fsi_master_hub, master)#define to_fsi_slave (d) container_of(d, struct fsi_slave, dev) +static void fsi_master_unscan (struct fsi_master *master);static int fsi_slave_read (struct fsi_slave *slave,uint32_t addr,void *val,size_t size); static int fsi_slave_write(struct fsi_slave *slave, uint32_t addr,
@@ -441,6 +442,7 @@ static int fsi_slave_scan(struct fsi_slave *slave) hub->dev.release = hub_master_release; hub->master.dev = &hub->dev; hub->master.dev->parent = &slave->dev; +dev_set_drvdata (&hub->dev, hub); rc =device_add (&hub->dev);if (rc)return rc;
@@ -739,6 +741,18 @@ static int fsi_master_scan(struct fsi_master *master)return 0 ; } +static int fsi_unregister_hubs (struct device *dev,void *data) +{ +struct fsi_master_hub *hub = + (struct fsi_master_hub *)dev_get_drvdata (dev); + +if (!hub) +return 0 ; + +device_del (dev); +fsi_master_unscan (&hub->master); +} +static void fsi_master_unscan (struct fsi_master *master) {struct fsi_slave *slave, *slave_tmp;
@@ -756,6 +770,8 @@ static void fsi_master_unscan(struct fsi_master *master)device_del (&fsi_dev->dev);put_device (&fsi_dev->dev); } +/* Remove any hub masters */ +device_for_each_child (&slave->dev,NULL , fsi_unregister_hubs);device_unregister (&slave->dev); } master->slave_list = false;
Signature · 1 line
1.8.2.2
drivers/fsi/fsi-core.c static int fsi_master_scan(struct fsi_master *master) · line 754
Quoted 12 lines · Christopher Bostic
drivers/fsi/fsi-core.c +11
-0+static int fsi_unregister_hubs (struct device *dev,void *data) +{ +struct fsi_master_hub *hub = + (struct fsi_master_hub *)dev_get_drvdata (dev); + +if (!hub) +return 0 ; + +device_del (dev); +fsi_master_unscan (&hub->master); +}
This introduces a warning:
drivers/fsi/fsi-core.c: In function ‘fsi_unregister_hubs’:drivers/fsi/fsi-core.c:754:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
Did you build test this patch?
Have you boot tested it?
What runtime testing did you perform?
Cheers,
Joel
Quoted 15 lines · Joel Stanley
drivers/fsi/fsi-core.c static int fsi_master_scan(struct fsi_master *master) · line 754
Quoted 11 lines · Christopher Bostic
drivers/fsi/fsi-core.c +11
-0+static int fsi_unregister_hubs (struct device *dev,void *data) +{ +struct fsi_master_hub *hub = + (struct fsi_master_hub *)dev_get_drvdata (dev); + +if (!hub) +return 0 ; + +device_del (dev); +fsi_master_unscan (&hub->master); +}This introduces a warning:
Quoted 7 lines
drivers/fsi/fsi-core.c: In function ‘fsi_unregister_hubs’:drivers/fsi/fsi-core.c:754:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^Did you build test this patch?
I did build but didn't see the warning. Wasn't looking close enough apparently -will correct.
Quoted 1 line
Have you boot tested it?
I did boot it.
Quoted 1 line
What runtime testing did you perform?
I ran multiple scans without rebooting to verify the removal and creation of sysfs files was done properly. Also verified no further sysfs warnings attempting to create duplicate file names.
Quoted 4 lines
Cheers,
Joel