From: Michael Scott Date: Tue, 9 Feb 2016 01:08:46 +0000 (-0800) Subject: greybus: interface: clear upper 16-bits of version_id and product_id X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d5a265648aa830383bc2c3e750ffe1bea0cd4309;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git greybus: interface: clear upper 16-bits of version_id and product_id Current userspace looks through the sysfs interface entries for matching vendor_id and product_id any time an interface is opened by module developers. The upper 16-bits of ES3 vendor_id and product_id contain a reverse mask of the lower 16-bits. This additional information is never used and should be removed so that every consumer of these sysfs entries doesn't have to perform the same bit clearing logic. Signed-off-by: Michael Scott Reviewed-by: Alex Elder Reviewed-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index 9c05d8142d8b..6c815db112b6 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -23,12 +23,33 @@ static DEVICE_ATTR_RO(field) gb_interface_attr(ddbl1_manufacturer_id, "0x%08x"); gb_interface_attr(ddbl1_product_id, "0x%08x"); gb_interface_attr(interface_id, "%u"); -gb_interface_attr(vendor_id, "0x%08x"); -gb_interface_attr(product_id, "0x%08x"); gb_interface_attr(vendor_string, "%s"); gb_interface_attr(product_string, "%s"); gb_interface_attr(serial_number, "0x%016llx"); +static ssize_t vendor_id_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + struct gb_interface *intf = to_gb_interface(dev); + + /* clear the upper 16-bits to keep userspace "simple" */ + return scnprintf(buf, PAGE_SIZE, "0x%04x\n", + (0x0000FFFF & intf->vendor_id)); +} +static DEVICE_ATTR_RO(vendor_id); + +static ssize_t product_id_show(struct device *dev, struct device_attribute *attr, + char *buf) +{ + struct gb_interface *intf = to_gb_interface(dev); + + /* clear the upper 16-bits to keep userspace "simple" */ + return scnprintf(buf, PAGE_SIZE, "0x%04x\n", + (0x0000FFFF & intf->product_id)); +} +static DEVICE_ATTR_RO(product_id); + static ssize_t version_show(struct device *dev, struct device_attribute *attr, char *buf) {