const struct greybus_module_id *id)
{
struct greybus_descriptor_module *module;
- struct greybus_descriptor_serial_number *serial_num;
module = &gmod->module;
- serial_num = &gmod->serial_number;
if ((id->match_flags & GREYBUS_DEVICE_ID_MATCH_VENDOR) &&
(id->vendor != le16_to_cpu(module->vendor)))
return 0;
if ((id->match_flags & GREYBUS_DEVICE_ID_MATCH_SERIAL) &&
- (id->serial_number != le64_to_cpu(serial_num->serial_number)))
+ (id->serial_number != le64_to_cpu(module->serial_number)))
return 0;
return 1;
return 0;
}
-static int create_serial_number(struct greybus_module *gmod,
- struct greybus_descriptor_serial_number *serial_num,
- size_t desc_size)
-{
- if (desc_size != sizeof(*serial_num)) {
- dev_err(gmod->dev.parent, "invalid serial number header size %zu\n",
- desc_size);
- return -EINVAL;
- }
- memcpy(&gmod->serial_number, serial_num, desc_size);
- return 0;
-}
-
static int create_string(struct greybus_module *gmod,
struct greybus_descriptor_string *string,
size_t desc_size)
data_size);
break;
- case GREYBUS_TYPE_SERIAL_NUMBER:
- retval = create_serial_number(gmod,
- &desc->serial_number,
- data_size);
- break;
-
case GREYBUS_TYPE_STRING:
retval = create_string(gmod, &desc->string, data_size);
break;
GREYBUS_TYPE_INVALID = 0x0000,
GREYBUS_TYPE_FUNCTION = 0x0001,
GREYBUS_TYPE_MODULE = 0x0002,
- GREYBUS_TYPE_SERIAL_NUMBER = 0x0003,
GREYBUS_TYPE_STRING = 0x0004,
GREYBUS_TYPE_CPORT = 0x0005,
};
__le16 vendor;
__le16 product;
__le16 version;
+ __le64 serial_number;
__u8 vendor_stringid;
__u8 product_stringid;
};
-struct greybus_descriptor_serial_number {
- __le64 serial_number;
-};
-
struct greybus_descriptor_string {
__le16 length;
__u8 id;
union {
struct greybus_descriptor_function function;
struct greybus_descriptor_module module;
- struct greybus_descriptor_serial_number serial_number;
struct greybus_descriptor_string string;
struct greybus_descriptor_cport cport;
};
greybus_module_attr(product);
greybus_module_attr(version);
+static ssize_t module_serial_number_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct greybus_module *gmod = to_greybus_module(dev);
+
+ return sprintf(buf, "%llX\n",
+ (unsigned long long)le64_to_cpu(gmod->module.serial_number));
+}
+static DEVICE_ATTR_RO(module_serial_number);
+
static ssize_t module_vendor_string_show(struct device *dev,
struct device_attribute *attr,
char *buf)
&dev_attr_module_vendor.attr,
&dev_attr_module_product.attr,
&dev_attr_module_version.attr,
+ &dev_attr_module_serial_number.attr,
&dev_attr_module_vendor_string.attr,
&dev_attr_module_product_string.attr,
NULL,
// or not easier?
if (gmod->module.vendor ||
gmod->module.product ||
- gmod->module.version)
+ gmod->module.version ||
+ gmod->module.serial_number)
return a->mode;
return 0;
}
};
-/* Serial Number */
-static ssize_t serial_number_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct greybus_module *gmod = to_greybus_module(dev);
-
- return sprintf(buf, "%llX\n",
- (unsigned long long)le64_to_cpu(gmod->serial_number.serial_number));
-}
-static DEVICE_ATTR_RO(serial_number);
-
-static struct attribute *serial_number_attrs[] = {
- &dev_attr_serial_number.attr,
- NULL,
-};
-
-static umode_t serial_number_is_visible(struct kobject *kobj,
- struct attribute *a, int n)
-{
- return a->mode;
-}
-
-static struct attribute_group serial_number_attr_grp = {
- .attrs = serial_number_attrs,
- .is_visible = serial_number_is_visible,
-};
const struct attribute_group *greybus_module_groups[] = {
&function_attr_grp,
&module_attr_grp,
- &serial_number_attr_grp,
NULL,
};