aboutsummaryrefslogtreecommitdiff
path: root/kernel/ethosu_driver.c
diff options
context:
space:
mode:
authorKristofer Jonsson <kristofer.jonsson@arm.com>2023-01-20 13:38:13 +0100
committerKristofer Jonsson <kristofer.jonsson@arm.com>2023-02-02 16:30:39 +0100
commitec47704ab3fd50a9ef8339f33139ddae4caa00b6 (patch)
tree87698ce04f75b460580dfbc637d453dbfc141c37 /kernel/ethosu_driver.c
parentd779a08a0f7ca3cdde16941720ddc7af96e74520 (diff)
downloadethos-u-linux-driver-stack-ec47704ab3fd50a9ef8339f33139ddae4caa00b6.tar.gz
Break circulare dependency on struct ethosu_device
The 'struct ethosu_device' has been passed as argument to classes. This creates a circular dependency dependency and it gives all classes full visibility to all resources in the device struct. This patch removes the circular dependency. Using device_lock() and device_unlock() to for synchronization. Change-Id: I8322e6530c72d7bd67f48f411b4f14b612be2706
Diffstat (limited to 'kernel/ethosu_driver.c')
-rw-r--r--kernel/ethosu_driver.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/kernel/ethosu_driver.c b/kernel/ethosu_driver.c
index c6fc8cd..6e5bfb9 100644
--- a/kernel/ethosu_driver.c
+++ b/kernel/ethosu_driver.c
@@ -57,7 +57,6 @@ static DECLARE_BITMAP(minors, MINOR_COUNT);
static int ethosu_rpmsg_probe(struct rpmsg_device *rpdev)
{
struct device *dev = &rpdev->dev;
- struct ethosu_device *edev;
int minor;
int ret;
@@ -69,15 +68,8 @@ static int ethosu_rpmsg_probe(struct rpmsg_device *rpdev)
return -ENOMEM;
}
- edev = devm_kzalloc(dev, sizeof(*edev), GFP_KERNEL);
- if (!edev)
- return -ENOMEM;
-
- dev_set_drvdata(dev, edev);
-
/* Initialize device */
- ret = ethosu_dev_init(edev, rpdev, ethosu_class,
- MKDEV(MAJOR(devt), minor));
+ ret = ethosu_dev_init(rpdev, ethosu_class, MKDEV(MAJOR(devt), minor));
if (ret)
return ret;
@@ -88,12 +80,13 @@ static int ethosu_rpmsg_probe(struct rpmsg_device *rpdev)
static void ethosu_rpmsg_remove(struct rpmsg_device *rpdev)
{
- struct ethosu_device *edev = dev_get_drvdata(&rpdev->dev);
+ struct device *dev = &rpdev->dev;
+ struct ethosu_device *edev = dev_get_drvdata(dev);
- dev_info(&rpdev->dev, "%s", __FUNCTION__);
+ dev_info(dev, "%s", __FUNCTION__);
clear_bit(MINOR(edev->devt), minors);
- ethosu_dev_deinit(edev);
+ ethosu_dev_deinit(rpdev);
}
static int ethosu_rpmsg_cb(struct rpmsg_device *rpdev,