Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rpmsg: virtio_rpmsg_bus: fix channel creation

Since commit 4dffed5b3ac796b ("rpmsg: Name rpmsg devices based on
channel id"), it is no more possible for a firmware to register twice
a service (on different endpoints). rpmsg_register_device function
is failing when calling device_add for the second time as second
device has the same name as first one already register.
It is because name is based only on service name and so is not more
unique. Previously name was unique thanks to the use of rpmsg_dev_index.

This patch adds destination and source endpoint numbers device name to
create an unique identifier.

Fixes: 4dffed5b3ac7 ("rpmsg: Name rpmsg devices based on channel id")
Acked-by: Peter Griffin <peter.griffin@linaro.org>
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
[bjorn: flipped name and address in device name]
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

authored by

Loic Pallardy and committed by
Bjorn Andersson
63447646 7ce7d89f

+2 -2
+2 -2
drivers/rpmsg/rpmsg_core.c
··· 453 453 struct device *dev = &rpdev->dev; 454 454 int ret; 455 455 456 - dev_set_name(&rpdev->dev, "%s:%s", 457 - dev_name(dev->parent), rpdev->id.name); 456 + dev_set_name(&rpdev->dev, "%s.%s.%d.%d", dev_name(dev->parent), 457 + rpdev->id.name, rpdev->src, rpdev->dst); 458 458 459 459 rpdev->dev.bus = &rpmsg_bus; 460 460 rpdev->dev.release = rpmsg_release_device;