summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEddie James <eajames@us.ibm.com>2023-06-12 14:56:52 -0500
committerJoel Stanley <joel@jms.id.au>2023-08-09 15:43:28 +0930
commit641511bfcc5e016e259131c53ae041ad3732b342 (patch)
tree976e222b60653d947317df2b6609bb9235e7595c
parent02c8fec05bc74d3f50b23c20a54cb6cba3326eef (diff)
downloadlwn-641511bfcc5e016e259131c53ae041ad3732b342.tar.gz
lwn-641511bfcc5e016e259131c53ae041ad3732b342.zip
fsi: core: Fix legacy minor numbering
The legacy minor numbering shifts the chip id too much, resulting in ids that overlap with regular ids. Since there are only 2 bits for 4 types, only shift the chip id by 2 to fit the legacy ids in their reserved space. Signed-off-by: Eddie James <eajames@linux.ibm.com> Link: https://lore.kernel.org/r/20230612195657.245125-10-eajames@linux.ibm.com Signed-off-by: Joel Stanley <joel@jms.id.au>
-rw-r--r--drivers/fsi/fsi-core.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index 161c45857e1d..8735eddc9745 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -913,8 +913,12 @@ static int __fsi_get_new_minor(struct fsi_slave *slave, enum fsi_dev_type type,
/* Check if we qualify for legacy numbering */
if (cid >= 0 && cid < 16 && type < 4) {
- /* Try reserving the legacy number */
- id = (cid << 4) | type;
+ /*
+ * Try reserving the legacy number, which has 0 - 0x3f reserved
+ * in the ida range. cid goes up to 0xf and type contains two
+ * bits, so construct the id with the below two bit shift.
+ */
+ id = (cid << 2) | type;
id = ida_simple_get(&fsi_minor_ida, id, id + 1, GFP_KERNEL);
if (id >= 0) {
*out_index = fsi_adjust_index(cid);
@@ -949,7 +953,8 @@ int fsi_get_new_minor(struct fsi_device *fdev, enum fsi_dev_type type,
int aid = of_alias_get_id(fdev->dev.of_node, fsi_dev_type_names[type]);
if (aid >= 0) {
- int id = (aid << 4) | type;
+ /* Use the same scheme as the legacy numbers. */
+ int id = (aid << 2) | type;
id = ida_simple_get(&fsi_minor_ida, id, id + 1, GFP_KERNEL);
if (id >= 0) {