Skip to content

Commit

Permalink
rpmsg: Split off generic tail of create_channel()
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
andersson committed Sep 9, 2016
1 parent 8b881c0 commit 6eed598
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions drivers/rpmsg/virtio_rpmsg_bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -499,21 +500,32 @@ 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;

ret = device_register(&rpdev->dev);
if (ret) {
dev_err(dev, "device_register failed: %d\n", ret);
put_device(&rpdev->dev);
return NULL;
}

return rpdev;
return ret;
}

/*
Expand Down

0 comments on commit 6eed598

Please sign in to comment.