[PATCH] ARM: dts: fix usb pin control for imx-rex dts

2015-09-16 Thread eu
From: "Felipe F. Tonello" 

This fixes a duplicated pin control causing this error:

imx6q-pinctrl 20e.iomuxc: pin MX6Q_PAD_GPIO_1 already
requested by regulators:regulator@2; cannot claim for 2184000.usb
imx6q-pinctrl 20e.iomuxc: pin-137 (2184000.usb) status -22
imx6q-pinctrl 20e.iomuxc: could not request pin 137
(MX6Q_PAD_GPIO_1) from group usbotggrp  on device 20e.iomuxc
imx_usb 2184000.usb: Error applying setting, reverse things
back
imx6q-pinctrl 20e.iomuxc: pin MX6Q_PAD_EIM_D31 already
requested by regulators:regulator@1; cannot claim for 2184200.usb
imx6q-pinctrl 20e.iomuxc: pin-52 (2184200.usb) status -22
imx6q-pinctrl 20e.iomuxc: could not request pin 52 (MX6Q_PAD_EIM_D31)
from group usbh1grp  on device 20e.iomuxc
imx_usb 2184200.usb: Error applying setting, reverse things
back

Signed-off-by: Felipe F. Tonello 
---
 arch/arm/boot/dts/imx6qdl-rex.dtsi | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl-rex.dtsi 
b/arch/arm/boot/dts/imx6qdl-rex.dtsi
index 3373fd9..a503562 100644
--- a/arch/arm/boot/dts/imx6qdl-rex.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-rex.dtsi
@@ -35,7 +35,6 @@
compatible = "regulator-fixed";
reg = <1>;
pinctrl-names = "default";
-   pinctrl-0 = <&pinctrl_usbh1>;
regulator-name = "usbh1_vbus";
regulator-min-microvolt = <500>;
regulator-max-microvolt = <500>;
@@ -47,7 +46,6 @@
compatible = "regulator-fixed";
reg = <2>;
pinctrl-names = "default";
-   pinctrl-0 = <&pinctrl_usbotg>;
regulator-name = "usb_otg_vbus";
regulator-min-microvolt = <500>;
regulator-max-microvolt = <500>;
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] usb: chipidea: udc: improve error handling on ep_queue and f_midi

2015-09-18 Thread eu
From: "Felipe F. Tonello" 

_ep_queue() didn't check for errors when using add_td_to_list()
which can fail if dma_pool_alloc fails, thus causing a kernel
panic when lastnode->ptr is NULL.

Also f_midi is not checking weather the is an error on usb_ep_queue
request, ignoring potential problems, such as memory leaks.

Signed-off-by: Felipe F. Tonello 
---
 drivers/usb/chipidea/udc.c   | 26 +++---
 drivers/usb/gadget/function/f_midi.c | 11 +--
 2 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 764f668..7169113e 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -404,9 +404,9 @@ static inline u8 _usb_addr(struct ci_hw_ep *ep)
 }
 
 /**
- * _hardware_queue: configures a request at hardware level
- * @gadget: gadget
+ * _hardware_enqueue: configures a request at hardware level
  * @hwep:   endpoint
+ * @hwreq:  request
  *
  * This function returns an error code
  */
@@ -435,19 +435,27 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, 
struct ci_hw_req *hwreq)
if (hwreq->req.dma % PAGE_SIZE)
pages--;
 
-   if (rest == 0)
-   add_td_to_list(hwep, hwreq, 0);
+   if (rest == 0) {
+   ret = add_td_to_list(hwep, hwreq, 0);
+   if (ret < 0)
+   goto done;
+   }
 
while (rest > 0) {
unsigned count = min(hwreq->req.length - hwreq->req.actual,
(unsigned)(pages * CI_HDRC_PAGE_SIZE));
-   add_td_to_list(hwep, hwreq, count);
+   ret = add_td_to_list(hwep, hwreq, count);
+   if (ret < 0)
+   goto done;
rest -= count;
}
 
if (hwreq->req.zero && hwreq->req.length
-   && (hwreq->req.length % hwep->ep.maxpacket == 0))
-   add_td_to_list(hwep, hwreq, 0);
+   && (hwreq->req.length % hwep->ep.maxpacket == 0)) {
+   ret = add_td_to_list(hwep, hwreq, 0);
+   if (ret < 0)
+   goto done;
+   }
 
firstnode = list_first_entry(&hwreq->tds, struct td_node, td);
 
@@ -750,8 +758,12 @@ static void isr_get_status_complete(struct usb_ep *ep, 
struct usb_request *req)
 
 /**
  * _ep_queue: queues (submits) an I/O request to an endpoint
+ * @ep:endpoint
+ * @req:   request
+ * @gfp_flags: GFP flags (not used)
  *
  * Caller must hold lock
+ * This function returns an error code
  */
 static int _ep_queue(struct usb_ep *ep, struct usb_request *req,
gfp_t __maybe_unused gfp_flags)
diff --git a/drivers/usb/gadget/function/f_midi.c 
b/drivers/usb/gadget/function/f_midi.c
index ad50a67..bb580e8 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -543,8 +543,15 @@ static void f_midi_transmit(struct f_midi *midi, struct 
usb_request *req)
}
}
 
-   if (req->length > 0)
-   usb_ep_queue(ep, req, GFP_ATOMIC);
+   if (req->length > 0) {
+   int err;
+
+   err = usb_ep_queue(ep, req, GFP_ATOMIC);
+   if (err < 0) {
+   ERROR(midi, "%s queue req: %d\n",
+ midi->out_ep->name, err);
+   }
+   }
else
free_ep_req(ep, req);
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/2] improve error handling on chipidea/udc.c and f_midi.c

2015-09-18 Thread eu
From: "Felipe F. Tonello" 

Felipe F. Tonello (2):
  usb: chipidea: udc: improve error handling on ep_queue
  usb: gadget: f_midi: check for error on usb_ep_queue

 drivers/usb/chipidea/udc.c   | 26 +++---
 drivers/usb/gadget/function/f_midi.c | 10 --
 2 files changed, 27 insertions(+), 9 deletions(-)

-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] usb: gadget: f_midi: check for error on usb_ep_queue

2015-09-18 Thread eu
From: "Felipe F. Tonello" 

f_midi is not checking weather the is an error on usb_ep_queue
request, ignoring potential problems, such as memory leaks.

Signed-off-by: Felipe F. Tonello 
---
 drivers/usb/gadget/function/f_midi.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/function/f_midi.c 
b/drivers/usb/gadget/function/f_midi.c
index ad50a67..a5e446d 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -543,8 +543,14 @@ static void f_midi_transmit(struct f_midi *midi, struct 
usb_request *req)
}
}
 
-   if (req->length > 0)
-   usb_ep_queue(ep, req, GFP_ATOMIC);
+   if (req->length > 0) {
+   int err;
+
+   err = usb_ep_queue(ep, req, GFP_ATOMIC);
+   if (err < 0)
+   ERROR(midi, "%s queue req: %d\n",
+ midi->out_ep->name, err);
+   }
else
free_ep_req(ep, req);
 }
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] usb: chipidea: udc: improve error handling on ep_queue

2015-09-18 Thread eu
From: "Felipe F. Tonello" 

_ep_queue() didn't check for errors when using add_td_to_list()
which can fail if dma_pool_alloc fails, thus causing a kernel
panic when lastnode->ptr is NULL.

Signed-off-by: Felipe F. Tonello 
---
 drivers/usb/chipidea/udc.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 764f668..7169113e 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -404,9 +404,9 @@ static inline u8 _usb_addr(struct ci_hw_ep *ep)
 }
 
 /**
- * _hardware_queue: configures a request at hardware level
- * @gadget: gadget
+ * _hardware_enqueue: configures a request at hardware level
  * @hwep:   endpoint
+ * @hwreq:  request
  *
  * This function returns an error code
  */
@@ -435,19 +435,27 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, 
struct ci_hw_req *hwreq)
if (hwreq->req.dma % PAGE_SIZE)
pages--;
 
-   if (rest == 0)
-   add_td_to_list(hwep, hwreq, 0);
+   if (rest == 0) {
+   ret = add_td_to_list(hwep, hwreq, 0);
+   if (ret < 0)
+   goto done;
+   }
 
while (rest > 0) {
unsigned count = min(hwreq->req.length - hwreq->req.actual,
(unsigned)(pages * CI_HDRC_PAGE_SIZE));
-   add_td_to_list(hwep, hwreq, count);
+   ret = add_td_to_list(hwep, hwreq, count);
+   if (ret < 0)
+   goto done;
rest -= count;
}
 
if (hwreq->req.zero && hwreq->req.length
-   && (hwreq->req.length % hwep->ep.maxpacket == 0))
-   add_td_to_list(hwep, hwreq, 0);
+   && (hwreq->req.length % hwep->ep.maxpacket == 0)) {
+   ret = add_td_to_list(hwep, hwreq, 0);
+   if (ret < 0)
+   goto done;
+   }
 
firstnode = list_first_entry(&hwreq->tds, struct td_node, td);
 
@@ -750,8 +758,12 @@ static void isr_get_status_complete(struct usb_ep *ep, 
struct usb_request *req)
 
 /**
  * _ep_queue: queues (submits) an I/O request to an endpoint
+ * @ep:endpoint
+ * @req:   request
+ * @gfp_flags: GFP flags (not used)
  *
  * Caller must hold lock
+ * This function returns an error code
  */
 static int _ep_queue(struct usb_ep *ep, struct usb_request *req,
gfp_t __maybe_unused gfp_flags)
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] usb: chipidea: udc: improve error handling on ep_queue

2015-09-18 Thread eu
From: "Felipe F. Tonello" 

_ep_queue() didn't check for errors when using add_td_to_list()
which can fail if dma_pool_alloc fails, thus causing a kernel
panic when lastnode->ptr is NULL.

Signed-off-by: Felipe F. Tonello 
---

Changes for v2:
  - Use separate patch for cleanups.

 drivers/usb/chipidea/udc.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index c936c72..7169113e 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -435,19 +435,27 @@ static int _hardware_enqueue(struct ci_hw_ep *hwep, 
struct ci_hw_req *hwreq)
if (hwreq->req.dma % PAGE_SIZE)
pages--;
 
-   if (rest == 0)
-   add_td_to_list(hwep, hwreq, 0);
+   if (rest == 0) {
+   ret = add_td_to_list(hwep, hwreq, 0);
+   if (ret < 0)
+   goto done;
+   }
 
while (rest > 0) {
unsigned count = min(hwreq->req.length - hwreq->req.actual,
(unsigned)(pages * CI_HDRC_PAGE_SIZE));
-   add_td_to_list(hwep, hwreq, count);
+   ret = add_td_to_list(hwep, hwreq, count);
+   if (ret < 0)
+   goto done;
rest -= count;
}
 
if (hwreq->req.zero && hwreq->req.length
-   && (hwreq->req.length % hwep->ep.maxpacket == 0))
-   add_td_to_list(hwep, hwreq, 0);
+   && (hwreq->req.length % hwep->ep.maxpacket == 0)) {
+   ret = add_td_to_list(hwep, hwreq, 0);
+   if (ret < 0)
+   goto done;
+   }
 
firstnode = list_first_entry(&hwreq->tds, struct td_node, td);
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] usb: gadget: f_midi: check for error on usb_ep_queue

2015-09-18 Thread eu
From: "Felipe F. Tonello" 

f_midi is not checking weather the is an error on usb_ep_queue
request, ignoring potential problems, such as memory leaks.

Signed-off-by: Felipe F. Tonello 
---

Changes for v2:
  - Update code style.

 drivers/usb/gadget/function/f_midi.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/function/f_midi.c 
b/drivers/usb/gadget/function/f_midi.c
index ad50a67..c04133422 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -543,10 +543,16 @@ static void f_midi_transmit(struct f_midi *midi, struct 
usb_request *req)
}
}
 
-   if (req->length > 0)
-   usb_ep_queue(ep, req, GFP_ATOMIC);
-   else
+   if (req->length > 0) {
+   int err;
+
+   err = usb_ep_queue(ep, req, GFP_ATOMIC);
+   if (err < 0)
+   ERROR(midi, "%s queue req: %d\n",
+ midi->out_ep->name, err);
+   } else {
free_ep_req(ep, req);
+   }
 }
 
 static void f_midi_in_tasklet(unsigned long data)
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] usb: chipidea: udc: _ep_queue and _hw_queue cleanup

2015-09-18 Thread eu
From: "Felipe F. Tonello" 

Update comments to reflect current state of functions.

Signed-off-by: Felipe F. Tonello 
---

Changes for v2:
  - Introduced this patch.

 drivers/usb/chipidea/udc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c
index 764f668..c936c72 100644
--- a/drivers/usb/chipidea/udc.c
+++ b/drivers/usb/chipidea/udc.c
@@ -404,9 +404,9 @@ static inline u8 _usb_addr(struct ci_hw_ep *ep)
 }
 
 /**
- * _hardware_queue: configures a request at hardware level
- * @gadget: gadget
+ * _hardware_enqueue: configures a request at hardware level
  * @hwep:   endpoint
+ * @hwreq:  request
  *
  * This function returns an error code
  */
@@ -750,8 +750,12 @@ static void isr_get_status_complete(struct usb_ep *ep, 
struct usb_request *req)
 
 /**
  * _ep_queue: queues (submits) an I/O request to an endpoint
+ * @ep:endpoint
+ * @req:   request
+ * @gfp_flags: GFP flags (not used)
  *
  * Caller must hold lock
+ * This function returns an error code
  */
 static int _ep_queue(struct usb_ep *ep, struct usb_request *req,
gfp_t __maybe_unused gfp_flags)
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] usb: gadget: f_midi: check for error on usb_ep_queue

2015-09-18 Thread eu
From: "Felipe F. Tonello" 

f_midi is not checking whether there is an error on usb_ep_queue
request, ignoring potential problems, such as memory leaks.

Signed-off-by: Felipe F. Tonello 
---

Changes for v2:
  - Update code style.

Changes for v3:
  - Use ip_ep instead of out_ep. Fixed typo in commit message.

 drivers/usb/gadget/function/f_midi.c | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/function/f_midi.c 
b/drivers/usb/gadget/function/f_midi.c
index ad50a67..edb84ca 100644
--- a/drivers/usb/gadget/function/f_midi.c
+++ b/drivers/usb/gadget/function/f_midi.c
@@ -543,10 +543,16 @@ static void f_midi_transmit(struct f_midi *midi, struct 
usb_request *req)
}
}
 
-   if (req->length > 0)
-   usb_ep_queue(ep, req, GFP_ATOMIC);
-   else
+   if (req->length > 0) {
+   int err;
+
+   err = usb_ep_queue(ep, req, GFP_ATOMIC);
+   if (err < 0)
+   ERROR(midi, "%s queue req: %d\n",
+ midi->in_ep->name, err);
+   } else {
free_ep_req(ep, req);
+   }
 }
 
 static void f_midi_in_tasklet(unsigned long data)
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/