Commit 4fc64549 authored by Matt Porter's avatar Matt Porter Committed by Greg Kroah-Hartman

greybus: remove serial number descriptor to match spec

Greybus spec was updated to remove the serial number descriptor and
move the serial number field to the, now mandatory, module descriptor.
Change everything accordingly.
Signed-off-by: default avatarMatt Porter <mporter@linaro.org>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 6d63ff7a
......@@ -34,10 +34,8 @@ static int greybus_match_one_id(struct greybus_module *gmod,
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)))
......@@ -48,7 +46,7 @@ static int greybus_match_one_id(struct greybus_module *gmod,
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;
......@@ -262,19 +260,6 @@ static int create_module(struct greybus_module *gmod,
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)
......@@ -427,12 +412,6 @@ void gb_add_module(struct greybus_host_device *hd, u8 module_id,
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;
......
......@@ -201,7 +201,6 @@ struct greybus_module {
u16 module_number;
struct greybus_descriptor_function function;
struct greybus_descriptor_module module;
struct greybus_descriptor_serial_number serial_number;
int num_cports;
int num_strings;
struct gmod_cport *cport[MAX_CPORTS_PER_MODULE];
......
......@@ -22,7 +22,6 @@ enum greybus_descriptor_type {
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,
};
......@@ -62,14 +61,11 @@ struct greybus_descriptor_module {
__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;
......@@ -88,7 +84,6 @@ struct greybus_descriptor {
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;
};
......
......@@ -82,6 +82,17 @@ greybus_module_attr(vendor);
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)
......@@ -108,6 +119,7 @@ static struct attribute *module_attrs[] = {
&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,
......@@ -129,7 +141,8 @@ static umode_t module_attrs_are_visible(struct kobject *kobj,
// 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;
}
......@@ -140,38 +153,11 @@ static struct attribute_group module_attr_grp = {
};
/* 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,
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment