From: Anatolij Gustschin <agust@denx.de>
To: atull@kernel.org, mdf@kernel.org
Cc: linux-fpga@vger.kernel.org
Subject: [PATCH v2] fpga: mgr: altera-ps-spi: enable usage on non-dt platforms
Date: Mon, 29 Oct 2018 15:17:09 +0100 [thread overview]
Message-ID: <20181029141709.14749-1-agust@denx.de> (raw)
Driver probing fails on non-dt platforms since of_match_device()
always returns NULL here. Add device names and matching driver
data to the spi_device_id table. This allows driver binding to
dynamically added PS-SPI devices (e.g. added via spi_new_device()
after hot-plugging).
Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
Changes in v2:
- removed not necessary braces {}
- dropped not needed !id check
drivers/fpga/altera-ps-spi.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c
index 33aafda50af5..b8136ee49ace 100644
--- a/drivers/fpga/altera-ps-spi.c
+++ b/drivers/fpga/altera-ps-spi.c
@@ -238,17 +238,23 @@ static int altera_ps_probe(struct spi_device *spi)
{
struct altera_ps_conf *conf;
const struct of_device_id *of_id;
+ const struct spi_device_id *id;
struct fpga_manager *mgr;
conf = devm_kzalloc(&spi->dev, sizeof(*conf), GFP_KERNEL);
if (!conf)
return -ENOMEM;
- of_id = of_match_device(of_ef_match, &spi->dev);
- if (!of_id)
- return -ENODEV;
+ if (spi->dev.of_node) {
+ of_id = of_match_device(of_ef_match, &spi->dev);
+ if (!of_id)
+ return -ENODEV;
+ conf->data = of_id->data;
+ } else {
+ id = spi_get_device_id(spi);
+ conf->data = (struct altera_ps_data *)id->driver_data;
+ }
- conf->data = of_id->data;
conf->spi = spi;
conf->config = devm_gpiod_get(&spi->dev, "nconfig", GPIOD_OUT_LOW);
if (IS_ERR(conf->config)) {
@@ -294,7 +300,9 @@ static int altera_ps_remove(struct spi_device *spi)
}
static const struct spi_device_id altera_ps_spi_ids[] = {
- {"cyclone-ps-spi", 0},
+ {"cyclone-ps-spi", (kernel_ulong_t)&c5_data},
+ {"fpga-passive-serial", (kernel_ulong_t)&c5_data},
+ {"fpga-arria10-passive-serial", (kernel_ulong_t)&a10_data},
{}
};
MODULE_DEVICE_TABLE(spi, altera_ps_spi_ids);
--
2.17.1
next reply other threads:[~2018-10-29 14:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-29 14:17 Anatolij Gustschin [this message]
2018-11-01 19:37 ` [PATCH v2] fpga: mgr: altera-ps-spi: enable usage on non-dt platforms Alan Tull
2018-11-05 17:54 ` Anatolij Gustschin
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=20181029141709.14749-1-agust@denx.de \
--to=agust@denx.de \
--cc=atull@kernel.org \
--cc=linux-fpga@vger.kernel.org \
--cc=mdf@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).