[PATCH 2/2] usb/composite: move suspended attribute from composite into udc-core

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

 



This attribute could be usefull for every gadget driver and udc-core
looks like the perfect place for it.

Should we provide a temporary symlink for it?

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
 drivers/usb/gadget/composite.c |   22 ++--------------------
 drivers/usb/gadget/udc-core.c  |    2 ++
 include/linux/usb/composite.h  |    1 -
 include/linux/usb/gadget.h     |    1 +
 4 files changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index e7464b3..cee17e2 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -1454,18 +1454,6 @@ static void composite_disconnect(struct usb_gadget *gadget)
 
 /*-------------------------------------------------------------------------*/
 
-static ssize_t composite_show_suspended(struct device *dev,
-					struct device_attribute *attr,
-					char *buf)
-{
-	struct usb_gadget *gadget = dev_to_usb_gadget(dev);
-	struct usb_composite_dev *cdev = get_gadget_data(gadget);
-
-	return sprintf(buf, "%d\n", cdev->suspended);
-}
-
-static DEVICE_ATTR(suspended, 0444, composite_show_suspended, NULL);
-
 static void
 composite_unbind(struct usb_gadget *gadget)
 {
@@ -1516,7 +1504,6 @@ composite_unbind(struct usb_gadget *gadget)
 		kfree(cdev->req->buf);
 		usb_ep_free_request(gadget->ep0, cdev->req);
 	}
-	device_remove_file(&gadget->dev, &dev_attr_suspended);
 	kfree(cdev);
 	set_gadget_data(gadget, NULL);
 	composite = NULL;
@@ -1622,13 +1609,8 @@ static int composite_bind(struct usb_gadget *gadget)
 		WARNING(cdev, "userspace failed to provide iSerialNumber\n");
 
 	/* finish up */
-	status = device_create_file(&gadget->dev, &dev_attr_suspended);
-	if (status)
-		goto fail;
-
 	INFO(cdev, "%s ready\n", composite->name);
 	return 0;
-
 fail:
 	composite_unbind(gadget);
 	return status;
@@ -1655,7 +1637,7 @@ composite_suspend(struct usb_gadget *gadget)
 	if (composite->suspend)
 		composite->suspend(cdev);
 
-	cdev->suspended = 1;
+	gadget->suspended = 1;
 
 	usb_gadget_vbus_draw(gadget, 2);
 }
@@ -1685,7 +1667,7 @@ composite_resume(struct usb_gadget *gadget)
 			(2 * maxpower) : CONFIG_USB_GADGET_VBUS_DRAW);
 	}
 
-	cdev->suspended = 0;
+	gadget->suspended = 0;
 }
 
 /*-------------------------------------------------------------------------*/
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 08221fa..69a3f13 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -412,11 +412,13 @@ static USB_UDC_ATTR(is_a_peripheral);
 static USB_UDC_ATTR(b_hnp_enable);
 static USB_UDC_ATTR(a_hnp_support);
 static USB_UDC_ATTR(a_alt_hnp_support);
+static USB_UDC_ATTR(suspended);
 
 static struct attribute *usb_udc_attrs[] = {
 	&dev_attr_srp.attr,
 	&dev_attr_soft_connect.attr,
 	&dev_attr_speed.attr,
+	&dev_attr_suspended.attr,
 
 	&dev_attr_is_dualspeed.attr,
 	&dev_attr_is_otg.attr,
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h
index cf532f5..d8ab81c 100644
--- a/include/linux/usb/composite.h
+++ b/include/linux/usb/composite.h
@@ -345,7 +345,6 @@ struct usb_composite_dev {
 
 	/* private: */
 	/* internals */
-	unsigned int			suspended:1;
 	struct usb_device_descriptor	desc;
 	struct list_head		configs;
 	struct usb_composite_driver	*driver;
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 087f4b9..f5b5d5a 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -524,6 +524,7 @@ struct usb_gadget {
 	unsigned			b_hnp_enable:1;
 	unsigned			a_hnp_support:1;
 	unsigned			a_alt_hnp_support:1;
+	unsigned			suspended:1;
 	const char			*name;
 	struct device			dev;
 };
-- 
1.7.4.4

--
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