From 8552ca0f3634bf6aaf8f752fb9a73652326117eb Mon Sep 17 00:00:00 2001 From: Viresh Kumar Date: Mon, 7 Sep 2015 17:56:58 +0530 Subject: [PATCH] greybus: connection: Add sysfs 'ap_cport_id' file for connections Its a very useful piece of information, i.e. the cport id of the AP to which the cport of the module is connected, and is required lots of times. It isn't known in advance as it is allocated at runtime. This patch creates another file 'ap_cport_id', only for the connection directories, which will give the cport id of the AP. Signed-off-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/Documentation/sysfs-bus-greybus | 8 ++++++++ drivers/staging/greybus/connection.c | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/drivers/staging/greybus/Documentation/sysfs-bus-greybus b/drivers/staging/greybus/Documentation/sysfs-bus-greybus index 808fde9..acc4054 100644 --- a/drivers/staging/greybus/Documentation/sysfs-bus-greybus +++ b/drivers/staging/greybus/Documentation/sysfs-bus-greybus @@ -126,6 +126,14 @@ Description: 3 - error 4 - destroying +What: /sys/bus/greybus/device/.../ap_cport_id +Date: October 2015 +KernelVersion: 4.XX +Contact: Greg Kroah-Hartman +Description: + The cport ID of the AP, to which cport of the module is + connected. + What: /sys/bus/greybus/device/.../protocol_id Date: October 2015 KernelVersion: 4.XX diff --git a/drivers/staging/greybus/connection.c b/drivers/staging/greybus/connection.c index 3dcbb78..dc45298 100644 --- a/drivers/staging/greybus/connection.c +++ b/drivers/staging/greybus/connection.c @@ -116,9 +116,18 @@ protocol_id_show(struct device *dev, struct device_attribute *attr, char *buf) } static DEVICE_ATTR_RO(protocol_id); +static ssize_t +ap_cport_id_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + struct gb_connection *connection = to_gb_connection(dev); + return sprintf(buf, "%hu\n", connection->hd_cport_id); +} +static DEVICE_ATTR_RO(ap_cport_id); + static struct attribute *connection_attrs[] = { &dev_attr_state.attr, &dev_attr_protocol_id.attr, + &dev_attr_ap_cport_id.attr, NULL, }; -- 2.7.4