summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2016-09-01 15:28:03 -0700
committerBjorn Andersson <bjorn.andersson@linaro.org>2016-09-08 22:15:23 -0700
commit6eed598a049193917a2e15b163abb58c5c1ef466 (patch)
tree3ff7f2c0bd82f7a6f39d5a91e2111b641a6b031a /drivers
parent8b881c07cb805e1a126d434359706e45864ea2df (diff)
downloadlinux-stable-6eed598a049193917a2e15b163abb58c5c1ef466.tar.gz
linux-stable-6eed598a049193917a2e15b163abb58c5c1ef466.tar.bz2
linux-stable-6eed598a049193917a2e15b163abb58c5c1ef466.zip
rpmsg: Split off generic tail of create_channel()
The tail of create_channel() is common among all rpmsg backends, so split it off from the virtio specific part to allow it to be extracted to the rpmsg core. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/rpmsg/virtio_rpmsg_bus.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c
index 488fd93a290c..e1052622c6a2 100644
--- a/drivers/rpmsg/virtio_rpmsg_bus.c
+++ b/drivers/rpmsg/virtio_rpmsg_bus.c
@@ -120,6 +120,7 @@ static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data,
int len, u32 dst);
static int virtio_rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src,
u32 dst, void *data, int len);
+static int rpmsg_register_device(struct rpmsg_device *rpdev);
/* sysfs show configuration fields */
#define rpmsg_show_attr(field, path, format_string) \
@@ -499,10 +500,22 @@ static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp,
strncpy(rpdev->id.name, chinfo->name, RPMSG_NAME_SIZE);
+ rpdev->dev.parent = &vrp->vdev->dev;
+ ret = rpmsg_register_device(rpdev);
+ if (ret)
+ return NULL;
+
+ return rpdev;
+}
+
+static int rpmsg_register_device(struct rpmsg_device *rpdev)
+{
+ struct device *dev = &rpdev->dev;
+ int ret;
+
dev_set_name(&rpdev->dev, "%s:%s",
dev_name(dev->parent), rpdev->id.name);
- rpdev->dev.parent = &vrp->vdev->dev;
rpdev->dev.bus = &rpmsg_bus;
rpdev->dev.release = rpmsg_release_device;
@@ -510,10 +523,9 @@ static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp,
if (ret) {
dev_err(dev, "device_register failed: %d\n", ret);
put_device(&rpdev->dev);
- return NULL;
}
- return rpdev;
+ return ret;
}
/*