Skip to contentSkip to conversation

remoteproc: Add a sysfs interface for name

PATCH In review Suman Anna 2 participants 2 messages Aug 9, 2019 – Aug 27, 2019 Remote processor (remoteproc)

lore
Share & tools
lore

Suman Anna

author
#0 lore raw

PATCH 1/1 remoteproc: Add a sysfs interface for name

This patch adds a sysfs interface that provides the name of the remote processor to userspace. This allows the userspace to identify a remote processor as the remoteproc devices themselves are created based on probe order and can change from one boot to another or at runtime.

The name is made available in debugfs originally, and is being retained for now. This can be cleaned up after couple of releases once users get familiar with the new interface.

---
 Documentation/ABI/testing/sysfs-class-remoteproc | 10 ++++++++++
 drivers/remoteproc/remoteproc_sysfs.c            | 11 +++++++++++
 2 files changed, 21 insertions(+)
Documentation/ABI/testing/sysfs-class-remoteproc +10 -0
index c3afe9fab646..36094fbeb974 100644
@@ -48,3 +48,13 @@ Description:	Remote processor state
 
 		Writing "stop" will attempt to halt the remote processor and
 		return it to the "offline" state.
+
+What:		/sys/class/remoteproc/.../name
+Date:		August 2019
+KernelVersion:	5.4
+Contact:	Suman Anna <[email protected]>
+Description:	Remote processor name
+
+		Reports the name of the remote processor. This can be used by
+		userspace in exactly identifying a remote processor and ease
+		up the usage in modifying the 'firmware' or 'state' files.
drivers/remoteproc/remoteproc_sysfs.c +11 -0
index fa4131930106..7f8536b73295 100644
@@ -113,9 +113,20 @@ static ssize_t state_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(state);
 
+/* Expose the name of the remote processor via sysfs */
+static ssize_t name_show(struct device *dev, struct device_attribute *attr,
+			 char *buf)
+{
+	struct rproc *rproc = to_rproc(dev);
+
+	return sprintf(buf, "%s\n", rproc->name);
+}
+static DEVICE_ATTR_RO(name);
+
 static struct attribute *rproc_attrs[] = {
 	&dev_attr_firmware.attr,
 	&dev_attr_state.attr,
+	&dev_attr_name.attr,
 	NULL
 };
 
Signature · 1 line
2.22.0
Acked-by on v1 1/1
#1 lore raw

Hi Suman,

Thanks,
Arnaud

Quoted 60 lines · Suman Anna

This patch adds a sysfs interface that provides the name of the remote processor to userspace. This allows the userspace to identify a remote processor as the remoteproc devices themselves are created based on probe order and can change from one boot to another or at runtime.

The name is made available in debugfs originally, and is being retained for now. This can be cleaned up after couple of releases once users get familiar with the new interface.

---
  Documentation/ABI/testing/sysfs-class-remoteproc | 10 ++++++++++
  drivers/remoteproc/remoteproc_sysfs.c            | 11 +++++++++++
  2 files changed, 21 insertions(+)
Documentation/ABI/testing/sysfs-class-remoteproc +10 -0
index c3afe9fab646..36094fbeb974 100644
@@ -48,3 +48,13 @@ Description:	Remote processor state
 
  		Writing "stop" will attempt to halt the remote processor and
  		return it to the "offline" state.
+
+What:		/sys/class/remoteproc/.../name
+Date:		August 2019
+KernelVersion:	5.4
+Contact:	Suman Anna <[email protected]>
+Description:	Remote processor name
+
+		Reports the name of the remote processor. This can be used by
+		userspace in exactly identifying a remote processor and ease
+		up the usage in modifying the 'firmware' or 'state' files.
drivers/remoteproc/remoteproc_sysfs.c +11 -0
index fa4131930106..7f8536b73295 100644
@@ -113,9 +113,20 @@ static ssize_t state_store(struct device *dev,
  }
  static DEVICE_ATTR_RW(state);
 
+/* Expose the name of the remote processor via sysfs */
+static ssize_t name_show(struct device *dev, struct device_attribute *attr,
+			 char *buf)
+{
+	struct rproc *rproc = to_rproc(dev);
+
+	return sprintf(buf, "%s\n", rproc->name);
+}
+static DEVICE_ATTR_RO(name);
+
  static struct attribute *rproc_attrs[] = {
  	&dev_attr_firmware.attr,
  	&dev_attr_state.attr,
+	&dev_attr_name.attr,
  	NULL
  };