diff mbox series

[v8,2/8] fsi: Make master device indexing and naming optional

Message ID 20230306161057.44017-3-eajames@linux.ibm.com (mailing list archive)
State Handled Elsewhere
Headers show
Series fsi: Add IBM I2C Responder virtual FSI master | expand

Commit Message

Eddie James March 6, 2023, 4:10 p.m. UTC
Some FSI masters need different device naming, so make the indexing and naming
an optional part of FSI master registration.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 drivers/fsi/fsi-core.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index d591e68afd11..3271e40702ec 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -1297,11 +1297,16 @@  int fsi_master_register(struct fsi_master *master)
 	struct device_node *np;
 
 	mutex_init(&master->scan_lock);
-	master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL);
-	if (master->idx < 0)
-		return master->idx;
 
-	dev_set_name(&master->dev, "fsi%d", master->idx);
+	if (!master->idx) {
+		master->idx = ida_simple_get(&master_ida, 0, INT_MAX,
+					     GFP_KERNEL);
+		if (master->idx < 0)
+			return master->idx;
+
+		dev_set_name(&master->dev, "fsi%d", master->idx);
+	}
+
 	master->dev.class = &fsi_master_class;
 
 	rc = device_register(&master->dev);