[PATCH 11/12] at91_udc: update vbus param only if updated

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Sat Dec 31 10:21:37 EST 2011


Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 drivers/usb/gadget/at91_udc.c |   17 +++++++++++++++--
 drivers/usb/gadget/at91_udc.h |    1 +
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c
index 9277427..bb0d614 100644
--- a/drivers/usb/gadget/at91_udc.c
+++ b/drivers/usb/gadget/at91_udc.c
@@ -1315,6 +1315,19 @@ static struct at91_udc controller = {
 
 static void at91_udc_irq (void *_udc);
 
+static void at91_update_vbus(struct at91_udc *udc, u32 value)
+{
+	if (value == udc->gpio_vbus_val)
+		return;
+
+	if (value)
+		dev_set_param(udc->dev, "vbus", "1");
+	else
+		dev_set_param(udc->dev, "vbus", "0");
+
+	udc->gpio_vbus_val = value;
+}
+
 int usb_gadget_poll(void)
 {
 	struct at91_udc	*udc = &controller;
@@ -1327,10 +1340,10 @@ int usb_gadget_poll(void)
 	value ^= udc->board.vbus_active_low;
 
 	if (!value) {
-		dev_set_param(udc->dev, "vbus", "0");
+		at91_update_vbus(udc, value);
 		return 0;
 	}
-	dev_set_param(udc->dev, "vbus", "1");
+	at91_update_vbus(udc, value);
 
 	value = at91_udp_read(udc, AT91_UDP_ISR) & (~(AT91_UDP_SOFINT));
 	if (value)
diff --git a/drivers/usb/gadget/at91_udc.h b/drivers/usb/gadget/at91_udc.h
index 21aaf39..e592cc5 100644
--- a/drivers/usb/gadget/at91_udc.h
+++ b/drivers/usb/gadget/at91_udc.h
@@ -128,6 +128,7 @@ struct at91_udc {
 	unsigned			selfpowered:1;
 	unsigned			active_suspend:1;
 	u8				addr;
+	u32				gpio_vbus_val;
 	struct at91_udc_data		board;
 	struct clk			*iclk, *fclk;
 	struct device_d			*dev;
-- 
1.7.7




More information about the barebox mailing list