Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <michael.scott@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>

authored by

Michael Scott and committed by
Greg Kroah-Hartman
d5a26564 f6d6f5bd

+23 -2
+23 -2
drivers/staging/greybus/interface.c
··· 23 23 gb_interface_attr(ddbl1_manufacturer_id, "0x%08x"); 24 24 gb_interface_attr(ddbl1_product_id, "0x%08x"); 25 25 gb_interface_attr(interface_id, "%u"); 26 - gb_interface_attr(vendor_id, "0x%08x"); 27 - gb_interface_attr(product_id, "0x%08x"); 28 26 gb_interface_attr(vendor_string, "%s"); 29 27 gb_interface_attr(product_string, "%s"); 30 28 gb_interface_attr(serial_number, "0x%016llx"); 29 + 30 + static ssize_t vendor_id_show(struct device *dev, 31 + struct device_attribute *attr, 32 + char *buf) 33 + { 34 + struct gb_interface *intf = to_gb_interface(dev); 35 + 36 + /* clear the upper 16-bits to keep userspace "simple" */ 37 + return scnprintf(buf, PAGE_SIZE, "0x%04x\n", 38 + (0x0000FFFF & intf->vendor_id)); 39 + } 40 + static DEVICE_ATTR_RO(vendor_id); 41 + 42 + static ssize_t product_id_show(struct device *dev, struct device_attribute *attr, 43 + char *buf) 44 + { 45 + struct gb_interface *intf = to_gb_interface(dev); 46 + 47 + /* clear the upper 16-bits to keep userspace "simple" */ 48 + return scnprintf(buf, PAGE_SIZE, "0x%04x\n", 49 + (0x0000FFFF & intf->product_id)); 50 + } 51 + static DEVICE_ATTR_RO(product_id); 31 52 32 53 static ssize_t version_show(struct device *dev, struct device_attribute *attr, 33 54 char *buf)