Commit d72e253e authored by Federico Vaga's avatar Federico Vaga

kernel:[plat] fix sub-devices removal order (just before re-programming)

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent dcd9ca5e
......@@ -16,6 +16,7 @@
#include <linux/firmware.h>
#include <linux/delay.h>
#include <linux/jhash.h>
#include <linux/platform_device.h>
#include <linux/fmc-sdb.h>
#include "svec.h"
#include "hw/xloader_regs.h"
......@@ -383,6 +384,16 @@ static int svec_remove(struct device *pdev, unsigned int ndev)
{
struct svec_dev *svec = dev_get_drvdata(pdev);
/* The MockTurtle use the VIC so remove it before */
if (svec->pdev_trtl) {
platform_device_unregister(svec->pdev_trtl);
svec->pdev_trtl = NULL;
}
if (svec->pdev_vic) {
platform_device_unregister(svec->pdev_vic);
svec->pdev_vic = NULL;
}
if (test_bit(SVEC_FLAG_FMCS_REGISTERED, &svec->flags)) {
svec_fmc_destroy(svec);
clear_bit(SVEC_FLAG_FMCS_REGISTERED, &svec->flags);
......
......@@ -57,6 +57,17 @@ static int svec_reprogram_raw(struct fmc_device *fmc, struct fmc_driver *drv,
if (!drv)
dev_info(dev, "Carrier FPGA re-program\n");
/* Destroy old components */
/* Remove trtl before vic. MockTurtle use the VIC */
if (svec->pdev_trtl) {
platform_device_unregister(svec->pdev_trtl);
svec->pdev_trtl = NULL;
}
if (svec->pdev_vic) {
platform_device_unregister(svec->pdev_vic);
svec->pdev_vic = NULL;
}
fmc_free_sdb_tree(fmc);
fmc->flags &= ~FMC_DEVICE_HAS_GOLDEN;
......@@ -74,6 +85,7 @@ static int svec_reprogram_raw(struct fmc_device *fmc, struct fmc_driver *drv,
fmc->flags |= FMC_DEVICE_HAS_CUSTOM;
svec_scan_cores(svec);
return 0;
}
......@@ -83,16 +95,6 @@ static struct resource htvic_resource[] = {
};
static void svec_destroy_platform(struct platform_device *pdev)
{
if (!pdev)
return;
platform_device_unregister(pdev);
pdev = NULL;
}
static int svec_create_vic(struct svec_dev *svec)
{
struct vme_dev *vme_dev = to_vme_dev(svec->dev);
......@@ -210,11 +212,6 @@ static int svec_create_trtl(struct svec_dev *svec)
static int svec_scan_cores(struct svec_dev *svec)
{
/* Destroy old components */
/* Remove trtl before vic. MockTurtle use the VIC */
svec_destroy_platform(svec->pdev_trtl);
svec_destroy_platform(svec->pdev_vic);
svec_create_vic(svec);
svec_create_trtl(svec);
......@@ -460,10 +457,6 @@ failed:
void svec_fmc_destroy(struct svec_dev *svec)
{
/* The MockTurtle use the VIC so remove it before */
svec_destroy_platform(svec->pdev_trtl);
svec_destroy_platform(svec->pdev_vic);
if (!svec->fmcs[0])
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment