OSDN Git Service

greybus: endo: rework some attributes
authorAlex Elder <elder@linaro.org>
Fri, 22 May 2015 17:56:47 +0000 (12:56 -0500)
committerGreg Kroah-Hartman <gregkh@google.com>
Sat, 23 May 2015 23:44:45 +0000 (16:44 -0700)
The SVC is not the same as the Endo.  There are some attributes
(such as the Endo ID) that are independent of attributes of
the SVC (like its version).

The current "Endo attributes" are really SVC attributes.
Rename a few functions and variables to reflect that.

Add a new attribute group for Endo-specific attributes, and
populate it with the Endo ID.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/endo.c

index e4faa5c..72037ff 100644 (file)
                (4 + ((endo_layout)->max_ribs + 1) * 2)
 
 /* endo sysfs attributes */
-static ssize_t serial_number_show(struct device *dev,
-                                 struct device_attribute *attr, char *buf)
+static ssize_t svc_serial_number_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
 {
        struct gb_endo *endo = to_gb_endo(dev);
 
        return sprintf(buf, "%s", &endo->svc_info.serial_number[0]);
 }
-static DEVICE_ATTR_RO(serial_number);
+static DEVICE_ATTR_RO(svc_serial_number);
 
-static ssize_t version_show(struct device *dev, struct device_attribute *attr,
-                           char *buf)
+static ssize_t svc_version_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
 {
        struct gb_endo *endo = to_gb_endo(dev);
 
        return sprintf(buf, "%s", &endo->svc_info.version[0]);
 }
-static DEVICE_ATTR_RO(version);
+static DEVICE_ATTR_RO(svc_version);
+
+static struct attribute *svc_attrs[] = {
+       &dev_attr_svc_serial_number.attr,
+       &dev_attr_svc_version.attr,
+       NULL,
+};
+
+static const struct attribute_group svc_group = {
+       .attrs = svc_attrs,
+       .name = "SVC",
+};
+
+static ssize_t endo_id_show(struct device *dev,
+                       struct device_attribute *attr, char *buf)
+{
+       struct gb_endo *endo = to_gb_endo(dev);
+
+       return sprintf(buf, "0x%04x", endo->id);
+}
+static DEVICE_ATTR_RO(endo_id);
 
 static struct attribute *endo_attrs[] = {
-       &dev_attr_serial_number.attr,
-       &dev_attr_version.attr,
+       &dev_attr_endo_id.attr,
        NULL,
 };
+
 static const struct attribute_group endo_group = {
        .attrs = endo_attrs,
-       .name = "SVC",
+       .name = "Endo",
 };
+
 static const struct attribute_group *endo_groups[] = {
        &endo_group,
+       &svc_group,
        NULL,
 };