From 4ccc2a6dbc6b94cbea1c4d6fcb108be548016456 Mon Sep 17 00:00:00 2001 From: Siddharth Gupta Date: Tue, 20 Apr 2021 16:02:10 -0700 Subject: [PATCH] FROMLIST: remoteproc: core: Move cdev add before device add When cdev_add is called after device_add has been called there is no way for the userspace to know about the addition of a cdev as cdev_add itself doesn't trigger a uevent notification, or for the kernel to know about the change to devt. This results in two problems: - mknod is never called for the cdev and hence no cdev appears on devtmpfs. - sysfs links to the new cdev are not established. Based on how cdev_device_add[1] is written, it appears that the correct way to use these APIs is to call cdev_add before device_add is called. Since the cdev is an optional feature for remoteproc we cannot directly use the existing API. Hence moving rproc_char_device_add() before device_add() in rproc_add(). [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/char_dev.c#n537 Signed-off-by: Siddharth Gupta Bug: 185924092 Change-Id: Iad8a45f564996d73cd3f33ed124427cb73497dad Link: https://lore.kernel.org/linux-remoteproc/1618946805-26970-1-git-send-email-sidgup@codeaurora.org/ Signed-off-by: Siddharth Gupta --- drivers/remoteproc/remoteproc_core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index eba7543565a9..9a21a252bc3c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1996,6 +1996,11 @@ int rproc_add(struct rproc *rproc) struct device *dev = &rproc->dev; int ret; + /* add char device for this remoteproc */ + ret = rproc_char_device_add(rproc); + if (ret < 0) + return ret; + ret = device_add(dev); if (ret < 0) return ret; @@ -2009,11 +2014,6 @@ int rproc_add(struct rproc *rproc) /* create debugfs entries */ rproc_create_debug_dir(rproc); - /* add char device for this remoteproc */ - ret = rproc_char_device_add(rproc); - if (ret < 0) - return ret; - /* * Remind ourselves the remote processor has been attached to rather * than booted by the remoteproc core. This is important because the