Skip to content

Commit

Permalink
rpmsg: qcom_smd: Add support for "label" property
Browse files Browse the repository at this point in the history
Add support for the "label" property, used to give the edge a name other
than the one of the DT node. This allows the implementor to provide
consistently named edges when using the rpmsg character device.

Signed-off-by: Bjorn Andersson <[email protected]>
  • Loading branch information
andersson committed Jan 18, 2017
1 parent 49def18 commit 5e53c42
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions drivers/rpmsg/qcom_smd.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ static const struct {
struct qcom_smd_edge {
struct device dev;

const char *name;

struct device_node *of_node;
unsigned edge_id;
unsigned remote_pid;
Expand Down Expand Up @@ -1248,6 +1250,10 @@ static int qcom_smd_parse_edge(struct device *dev,
return -EINVAL;
}

ret = of_property_read_string(node, "label", &edge->name);
if (ret < 0)
edge->name = node->name;

irq = irq_of_parse_and_map(node, 0);
if (irq < 0) {
dev_err(dev, "required smd interrupt missing\n");
Expand Down Expand Up @@ -1285,6 +1291,21 @@ static void qcom_smd_edge_release(struct device *dev)
kfree(edge);
}

static ssize_t rpmsg_name_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct qcom_smd_edge *edge = to_smd_edge(dev);

return sprintf(buf, "%s\n", edge->name);
}
static DEVICE_ATTR_RO(rpmsg_name);

static struct attribute *qcom_smd_edge_attrs[] = {
&dev_attr_rpmsg_name.attr,
NULL
};
ATTRIBUTE_GROUPS(qcom_smd_edge);

/**
* qcom_smd_register_edge() - register an edge based on an device_node
* @parent: parent device for the edge
Expand All @@ -1306,6 +1327,7 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,

edge->dev.parent = parent;
edge->dev.release = qcom_smd_edge_release;
edge->dev.groups = qcom_smd_edge_groups;
dev_set_name(&edge->dev, "%s:%s", dev_name(parent), node->name);
ret = device_register(&edge->dev);
if (ret) {
Expand Down

0 comments on commit 5e53c42

Please sign in to comment.