From: Eddie James <eajames@linux.ibm.com>
To: linux-fsi@lists.ozlabs.org
Cc: rostedt@goodmis.org, linux-trace-kernel@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
mhiramat@kernel.org, alistair@popple.id.au, joel@jms.id.au,
jk@ozlabs.org, andrew@aj.id.au, robh+dt@kernel.org,
krzysztof.kozlowski+dt@linaro.org, eajames@linux.ibm.com
Subject: [PATCH v5 5/6] fsi: Add aliased device numbering
Date: Tue, 21 Feb 2023 15:26:21 -0600 [thread overview]
Message-ID: <20230221212622.3897097-6-eajames@linux.ibm.com> (raw)
In-Reply-To: <20230221212622.3897097-1-eajames@linux.ibm.com>
The I2C and SPI subsystems can use an aliased name to number the device.
Add similar support to the FSI subsystem for any device type.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
drivers/fsi/fsi-core.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index d591e68afd11..b77013b9d8a7 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -955,9 +955,34 @@ 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) {
+ int id = (aid << 4) | type;
+
+ id = ida_simple_get(&fsi_minor_ida, id, id + 1, 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);
}
EXPORT_SYMBOL_GPL(fsi_get_new_minor);
--
2.31.1
next prev parent reply other threads:[~2023-02-21 21:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-21 21:26 [PATCH v5 0/6] fsi: Add IBM I2C Responder virtual FSI master Eddie James
2023-02-21 21:26 ` [PATCH v5 1/6] fsi: Move fsi_slave structure definition to header Eddie James
2023-02-21 21:26 ` [PATCH v5 2/6] dt-bindings: fsi: Document the IBM I2C Responder virtual FSI master Eddie James
2023-02-21 21:26 ` [PATCH v5 3/6] fsi: Add " Eddie James
2023-02-21 21:26 ` [PATCH v5 4/6] fsi: Add I2C Responder SCOM driver Eddie James
2023-02-22 15:37 ` kernel test robot
2023-02-21 21:26 ` Eddie James [this message]
2023-02-21 21:26 ` [PATCH v5 6/6] fsi: Use of_match_table for bus matching if specified Eddie James
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230221212622.3897097-6-eajames@linux.ibm.com \
--to=eajames@linux.ibm.com \
--cc=alistair@popple.id.au \
--cc=andrew@aj.id.au \
--cc=devicetree@vger.kernel.org \
--cc=jk@ozlabs.org \
--cc=joel@jms.id.au \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=linux-fsi@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=robh+dt@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.