[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230809180814.151984-3-eajames@linux.ibm.com>
Date: Wed, 9 Aug 2023 13:08:14 -0500
From: Eddie James <eajames@...ux.ibm.com>
To: linux-fsi@...ts.ozlabs.org
Cc: joel@....id.au, linux-kernel@...r.kernel.org,
alistair@...ple.id.au, k@...abs.org,
Eddie James <eajames@...ux.ibm.com>
Subject: [PATCH 2/2] fsi: Lock mutex for master device registration
Because master device registration may cause hub master scans, or
user scans may begin before device registration has ended, so the
master scan lock must be held while registering the device.
Signed-off-by: Eddie James <eajames@...ux.ibm.com>
---
drivers/fsi/fsi-core.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index c7a002076292..ad50cdaf8421 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -1306,7 +1306,6 @@ static struct class fsi_master_class = {
int fsi_master_register(struct fsi_master *master)
{
int rc;
- struct device_node *np;
mutex_init(&master->scan_lock);
@@ -1326,20 +1325,19 @@ int fsi_master_register(struct fsi_master *master)
master->dev.class = &fsi_master_class;
+ mutex_lock(&master->scan_lock);
rc = device_register(&master->dev);
if (rc) {
ida_free(&master_ida, master->idx);
- return rc;
- }
+ } else {
+ struct device_node *np = dev_of_node(&master->dev);
- np = dev_of_node(&master->dev);
- if (!of_property_read_bool(np, "no-scan-on-init")) {
- mutex_lock(&master->scan_lock);
- fsi_master_scan(master);
- mutex_unlock(&master->scan_lock);
+ if (!of_property_read_bool(np, "no-scan-on-init"))
+ fsi_master_scan(master);
}
- return 0;
+ mutex_unlock(&master->scan_lock);
+ return rc;
}
EXPORT_SYMBOL_GPL(fsi_master_register);
--
2.39.3
Powered by blists - more mailing lists