[PATCH 2/3] usbip: vudc: make dev_desc attribute binary

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We read a struct usb_device_descriptor from it, so make it an actual
binary attribute.

Signed-off-by: Igor Kotrasinski <i.kotrasinsk@xxxxxxxxx>
---
 drivers/usb/usbip/vudc_sysfs.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c
index 79b4955..b101af0 100644
--- a/drivers/usb/usbip/vudc_sysfs.c
+++ b/drivers/usb/usbip/vudc_sysfs.c
@@ -99,17 +99,20 @@ int descriptor_cache(struct vudc *udc)
 /*
  * Fetches device descriptor from the gadget driver.
  */
-static ssize_t dev_desc_show(struct device *dev,
-			       struct device_attribute *attr, char *out)
+static ssize_t dev_desc_read(struct file *file, struct kobject *kobj,
+			     struct bin_attribute *attr, char *out,
+			     loff_t off, size_t count)
 {
+	struct device *dev = kobj_to_dev(kobj);
 	struct vudc *udc = (struct vudc *) dev_get_drvdata(dev);
+	char *desc_ptr = (char *) &udc->dev_desc;
 
 	if (!udc->driver)
 		return -ENODEV;
-	memcpy(out, &udc->dev_desc, sizeof(udc->dev_desc));
-	return sizeof(struct usb_device_descriptor);
+	memcpy(out, desc_ptr + off, count);
+	return count;
 }
-static DEVICE_ATTR_RO(dev_desc);
+static BIN_ATTR_RO(dev_desc, sizeof(struct usb_device_descriptor));
 
 static ssize_t store_sockfd(struct device *dev, struct device_attribute *attr,
 		     const char *in, size_t count)
@@ -194,12 +197,17 @@ static ssize_t usbip_status_show(struct device *dev,
 static DEVICE_ATTR_RO(usbip_status);
 
 static struct attribute *dev_attrs[] = {
-	&dev_attr_dev_desc.attr,
 	&dev_attr_usbip_sockfd.attr,
 	&dev_attr_usbip_status.attr,
 	NULL,
 };
 
+static struct bin_attribute *dev_bin_attrs[] = {
+	&bin_attr_dev_desc,
+	NULL,
+};
+
 const struct attribute_group vudc_attr_group = {
 	.attrs = dev_attrs,
+	.bin_attrs = dev_bin_attrs,
 };
-- 
2.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux