Hi Mathieu,
This patch and next moved to follow up set that deals with sysfs links all in one go.
Regards
Mike
On Thu, 3 Oct 2019 at 22:37, Mathieu Poirier mathieu.poirier@linaro.org wrote:
On Mon, Aug 19, 2019 at 10:13:56PM +0100, Mike Leach wrote:
To allow the connections between coresight components to be represented in sysfs, generic methods for creating sysfs links between two coresight devices are added.
This patch should be moved to the CS sysfs topology set [1]. That way coresight-sysfs.c can be created once and the content herein would have to be moved.
[1]. https://lists.linaro.org/pipermail/coresight/2019-August/003199.html
Signed-off-by: Mike Leach mike.leach@linaro.org
drivers/hwtracing/coresight/coresight-priv.h | 2 + drivers/hwtracing/coresight/coresight.c | 73 ++++++++++++++++++++ include/linux/coresight.h | 18 +++++ 3 files changed, 93 insertions(+)
diff --git a/drivers/hwtracing/coresight/coresight-priv.h b/drivers/hwtracing/coresight/coresight-priv.h index 4c176498a367..d02e9d6b80ab 100644 --- a/drivers/hwtracing/coresight/coresight-priv.h +++ b/drivers/hwtracing/coresight/coresight-priv.h @@ -153,6 +153,8 @@ struct coresight_device *coresight_get_sink_by_id(u32 id); struct list_head *coresight_build_path(struct coresight_device *csdev, struct coresight_device *sink); void coresight_release_path(struct list_head *path); +int coresight_add_sysfs_link(struct coresight_sysfs_link *info); +void coresight_remove_sysfs_link(struct coresight_sysfs_link *info);
#ifdef CONFIG_CORESIGHT_SOURCE_ETM3X extern int etm_readl_cp14(u32 off, unsigned int *val); diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 52b294dd898e..5a07ba9e3a00 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1032,6 +1032,79 @@ static void coresight_device_release(struct device *dev) kfree(csdev); }
+static int coresight_create_sysfs_link(struct kobject *from,
struct kobject *to,
const char *link_name,
const char *group_name)
+{
if (group_name)
return sysfs_add_link_to_group(from, group_name,
to, link_name);
else
return sysfs_create_link(from, to, link_name);
I would mandate new links to go under "connections" and nothing else, hence no need for sysfs_create_link().
+}
+static void coresight_delete_sysfs_link(struct kobject *kobj,
const char *link_name,
const char *group_name)
+{
if (group_name)
sysfs_remove_link_from_group(kobj, group_name, link_name);
else
sysfs_remove_link(kobj, link_name);
Same as above.
+}
+int coresight_add_sysfs_link(struct coresight_sysfs_link *info) +{
int ret = 0;
if (!info)
return -EINVAL;
if (!info->orig || !info->target ||
!info->orig_name || !info->target_name)
return -EINVAL;
/* first link orig->target */
ret = coresight_create_sysfs_link(&info->orig->dev.kobj,
&info->target->dev.kobj,
info->orig_name,
info->orig->sysfs_link_grp);
if (ret)
return ret;
/* second link target->orig */
ret = coresight_create_sysfs_link(&info->target->dev.kobj,
&info->orig->dev.kobj,
info->target_name,
info->target->sysfs_link_grp);
/* error in second link - remove first */
if (ret) {
coresight_delete_sysfs_link(&info->orig->dev.kobj,
info->orig_name,
info->orig->sysfs_link_grp);
}
return ret;
+}
+void coresight_remove_sysfs_link(struct coresight_sysfs_link *info) +{
if (!info)
return;
if (!info->orig || !info->target ||
!info->orig_name || !info->target_name)
return;
coresight_delete_sysfs_link(&info->orig->dev.kobj,
info->orig_name,
info->orig->sysfs_link_grp);
coresight_delete_sysfs_link(&info->target->dev.kobj,
info->target_name,
info->target->sysfs_link_grp);
+}
static int coresight_orphan_match(struct device *dev, void *data) { int i; diff --git a/include/linux/coresight.h b/include/linux/coresight.h index ff97e9a7080a..cd0d92611be6 100644 --- a/include/linux/coresight.h +++ b/include/linux/coresight.h @@ -148,6 +148,20 @@ struct coresight_connection { struct coresight_device *child_dev; };
+/**
- struct coresight_sysfs_link - representation of a connection in sysfs.
- @orig: Originating (master) coresight device for the link.
- @orig_name: Name to use for the link orig->target.
- @target: Target (slave) coresight device for the link.
- @target_name: Name to use for the link target->orig.
- */
+struct coresight_sysfs_link {
struct coresight_device *orig;
const char *orig_name;
struct coresight_device *target;
const char *target_name;
+};
/**
- struct coresight_device - representation of a device as used by the framework
- @pdata: Platform data with device connections associated to this device.
@@ -165,6 +179,9 @@ struct coresight_connection {
- @ea: Device attribute for sink representation under PMU directory.
- @ect_dev: Associated cross trigger device. Not part of the trace data
path or connections.
- @sysfs_link_grp: Optional name for a group created to add sysfs links into
on this device. Group must have been created on device
*/
registration.
struct coresight_device { struct coresight_platform_data *pdata; @@ -180,6 +197,7 @@ struct coresight_device { struct dev_ext_attribute *ea; /* cross trigger handling */ struct coresight_device *ect_dev;
const char *sysfs_link_grp;
Do we need this at all? From what I see in this set and the CS sysfs topology set it will always be "connections" and we don't want this to change since sysfs is considered to be an ABI.
};
/*
2.17.1
-- Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK