Re: [PATCH] USB: gadget: f_uac2: Fix broken prm to uac2 mapping

2013-05-31 Thread Felipe Balbi
HI,

On Thu, May 30, 2013 at 06:23:33PM +0530, Jassi Brar wrote:
 From: Jassi Brar jaswinder.si...@linaro.org
 
 prm_to_uac2() is broken because it tests against pointer it itself
 mapped onto, which will never be different.
 Fix the mapping by adding pointer to parent chip in each rtd param
 and removing the prm_to_uac2().
 
 Reported-by: Julien Rouviere jrouvi...@qualistream.com
 Signed-off-by: Jassi Brar jaswinder.si...@linaro.org

when was this bug introduced ? Is it critical for v3.10 ? can it wait
for v3.11 ? Does it need to go to stable ?

-- 
balbi


signature.asc
Description: Digital signature


Re: [PATCH] USB: gadget: f_uac2: Fix broken prm to uac2 mapping

2013-05-31 Thread Jassi Brar
On Sat, Jun 1, 2013 at 2:47 AM, Felipe Balbi ba...@ti.com wrote:
 HI,

 On Thu, May 30, 2013 at 06:23:33PM +0530, Jassi Brar wrote:
 From: Jassi Brar jaswinder.si...@linaro.org

 prm_to_uac2() is broken because it tests against pointer it itself
 mapped onto, which will never be different.
 Fix the mapping by adding pointer to parent chip in each rtd param
 and removing the prm_to_uac2().

 Reported-by: Julien Rouviere jrouvi...@qualistream.com
 Signed-off-by: Jassi Brar jaswinder.si...@linaro.org

 when was this bug introduced ? Is it critical for v3.10 ? can it wait
 for v3.11 ? Does it need to go to stable ?

The bug has already been there. It is hit only in rare error path and
is not critical.

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


[PATCH] USB: gadget: f_uac2: Fix broken prm to uac2 mapping

2013-05-30 Thread Jassi Brar
From: Jassi Brar jaswinder.si...@linaro.org

prm_to_uac2() is broken because it tests against pointer it itself
mapped onto, which will never be different.
Fix the mapping by adding pointer to parent chip in each rtd param
and removing the prm_to_uac2().

Reported-by: Julien Rouviere jrouvi...@qualistream.com
Signed-off-by: Jassi Brar jaswinder.si...@linaro.org
---
 drivers/usb/gadget/f_uac2.c |   20 ++--
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/gadget/f_uac2.c b/drivers/usb/gadget/f_uac2.c
index c7468b6..2c858a8 100644
--- a/drivers/usb/gadget/f_uac2.c
+++ b/drivers/usb/gadget/f_uac2.c
@@ -90,6 +90,7 @@ struct uac2_req {
 };
 
 struct uac2_rtd_params {
+   struct snd_uac2_chip *uac2; /* parent chip */
bool ep_enabled; /* if the ep is enabled */
/* Size of the ring buffer */
size_t dma_bytes;
@@ -169,18 +170,6 @@ struct snd_uac2_chip *pdev_to_uac2(struct platform_device 
*p)
 }
 
 static inline
-struct snd_uac2_chip *prm_to_uac2(struct uac2_rtd_params *r)
-{
-   struct snd_uac2_chip *uac2 = container_of(r,
-   struct snd_uac2_chip, c_prm);
-
-   if (uac2-c_prm != r)
-   uac2 = container_of(r, struct snd_uac2_chip, p_prm);
-
-   return uac2;
-}
-
-static inline
 uint num_channels(uint chanmask)
 {
uint num = 0;
@@ -204,7 +193,7 @@ agdev_iso_complete(struct usb_ep *ep, struct usb_request 
*req)
struct uac2_req *ur = req-context;
struct snd_pcm_substream *substream;
struct uac2_rtd_params *prm = ur-pp;
-   struct snd_uac2_chip *uac2 = prm_to_uac2(prm);
+   struct snd_uac2_chip *uac2 = prm-uac2;
 
/* i/f shutting down */
if (!prm-ep_enabled)
@@ -896,7 +885,7 @@ struct cntrl_range_lay3 {
 static inline void
 free_ep(struct uac2_rtd_params *prm, struct usb_ep *ep)
 {
-   struct snd_uac2_chip *uac2 = prm_to_uac2(prm);
+   struct snd_uac2_chip *uac2 = prm-uac2;
int i;
 
prm-ep_enabled = false;
@@ -972,6 +961,9 @@ afunc_bind(struct usb_configuration *cfg, struct 
usb_function *fn)
}
agdev-in_ep-driver_data = agdev;
 
+   uac2-p_prm.uac2 = uac2;
+   uac2-c_prm.uac2 = uac2;
+
hs_epout_desc.bEndpointAddress = fs_epout_desc.bEndpointAddress;
hs_epout_desc.wMaxPacketSize = fs_epout_desc.wMaxPacketSize;
hs_epin_desc.bEndpointAddress = fs_epin_desc.bEndpointAddress;
-- 
1.7.10.4

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