summaryrefslogtreecommitdiff
path: root/drivers/fpga/machxo2-spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/fpga/machxo2-spi.c')
-rw-r--r--drivers/fpga/machxo2-spi.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/drivers/fpga/machxo2-spi.c b/drivers/fpga/machxo2-spi.c
index 8e95ec9c5c9a..a582e0000c97 100644
--- a/drivers/fpga/machxo2-spi.c
+++ b/drivers/fpga/machxo2-spi.c
@@ -355,21 +355,33 @@ static const struct fpga_manager_ops machxo2_ops = {
static int machxo2_spi_probe(struct spi_device *spi)
{
struct device *dev = &spi->dev;
+ struct fpga_manager *mgr;
+ int ret;
if (spi->max_speed_hz > MACHXO2_MAX_SPEED) {
dev_err(dev, "Speed is too high\n");
return -EINVAL;
}
- return fpga_mgr_register(dev, "Lattice MachXO2 SPI FPGA Manager",
- &machxo2_ops, spi);
+ mgr = fpga_mgr_create(dev, "Lattice MachXO2 SPI FPGA Manager",
+ &machxo2_ops, spi);
+ if (!mgr)
+ return -ENOMEM;
+
+ spi_set_drvdata(spi, mgr);
+
+ ret = fpga_mgr_register(mgr);
+ if (ret)
+ fpga_mgr_free(mgr);
+
+ return ret;
}
static int machxo2_spi_remove(struct spi_device *spi)
{
- struct device *dev = &spi->dev;
+ struct fpga_manager *mgr = spi_get_drvdata(spi);
- fpga_mgr_unregister(dev);
+ fpga_mgr_unregister(mgr);
return 0;
}