[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240215220759.976998-13-eajames@linux.ibm.com>
Date: Thu, 15 Feb 2024 16:07:38 -0600
From: Eddie James <eajames@...ux.ibm.com>
To: linux-fsi@...ts.ozlabs.org
Cc: linux-kernel@...r.kernel.org, linux-i2c@...r.kernel.org,
linux-clk@...r.kernel.org, devicetree@...r.kernel.org,
andi.shyti@...nel.org, eajames@...ux.ibm.com, alistair@...ple.id.au,
joel@....id.au, jk@...abs.org, sboyd@...nel.org,
mturquette@...libre.com, robh@...nel.org,
krzysztof.kozlowski+dt@...aro.org, conor+dt@...nel.org
Subject: [PATCH 12/33] fsi: core: Allow cfam device type aliases
Other FSI devices can uses aliases for the device numbering, so
modify the function to get a new minor to allow the cfam type
to use aliases too.
Signed-off-by: Eddie James <eajames@...ux.ibm.com>
---
drivers/fsi/fsi-core.c | 59 +++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 30 deletions(-)
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index eb15e5f5a2ee..95f6ce81f8f4 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -884,12 +884,37 @@ static int fsi_adjust_index(int index)
#endif
}
-static int __fsi_get_new_minor(struct fsi_slave *slave, enum fsi_dev_type type,
- dev_t *out_dev, int *out_index)
+static const char *const fsi_dev_type_names[] = {
+ "cfam",
+ "sbefifo",
+ "scom",
+ "occ",
+};
+
+static int __fsi_get_new_minor(struct fsi_slave *slave, struct device_node *np,
+ enum fsi_dev_type type, dev_t *out_dev, int *out_index)
{
int cid = slave->chip_id;
int id;
+ if (np) {
+ int aid = of_alias_get_id(np, fsi_dev_type_names[type]);
+
+ if (aid >= 0) {
+ /* Use the same scheme as the legacy numbers. */
+ id = (aid << 2) | type;
+ id = ida_alloc_range(&fsi_minor_ida, id, id, GFP_KERNEL);
+ if (id >= 0) {
+ *out_index = aid;
+ *out_dev = fsi_base_dev + id;
+ return 0;
+ }
+
+ if (id != -ENOSPC)
+ return id;
+ }
+ }
+
/* Check if we qualify for legacy numbering */
if (cid >= 0 && cid < 16 && type < 4) {
/*
@@ -918,36 +943,10 @@ static int __fsi_get_new_minor(struct fsi_slave *slave, enum fsi_dev_type type,
return 0;
}
-static const char *const fsi_dev_type_names[] = {
- "cfam",
- "sbefifo",
- "scom",
- "occ",
-};
-
int fsi_get_new_minor(struct fsi_device *fdev, enum fsi_dev_type type,
dev_t *out_dev, int *out_index)
{
- if (fdev->dev.of_node) {
- int aid = of_alias_get_id(fdev->dev.of_node, fsi_dev_type_names[type]);
-
- if (aid >= 0) {
- /* Use the same scheme as the legacy numbers. */
- int id = (aid << 2) | type;
-
- id = ida_alloc_range(&fsi_minor_ida, id, id, GFP_KERNEL);
- if (id >= 0) {
- *out_index = aid;
- *out_dev = fsi_base_dev + id;
- return 0;
- }
-
- if (id != -ENOSPC)
- return id;
- }
- }
-
- return __fsi_get_new_minor(fdev->slave, type, out_dev, out_index);
+ return __fsi_get_new_minor(fdev->slave, fdev->dev.of_node, type, out_dev, out_index);
}
EXPORT_SYMBOL_GPL(fsi_get_new_minor);
@@ -1052,7 +1051,7 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
}
/* Allocate a minor in the FSI space */
- rc = __fsi_get_new_minor(slave, fsi_dev_cfam, &slave->dev.devt,
+ rc = __fsi_get_new_minor(slave, slave->dev.of_node, fsi_dev_cfam, &slave->dev.devt,
&slave->cdev_idx);
if (rc)
goto err_free;
--
2.39.3
Powered by blists - more mailing lists