aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/fsl_qe_udc.c
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2008-11-08 12:51:48 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-07 12:59:52 -0500
commitcd40c4c45eaedc289d2e1cc33b18a49a211f0f82 (patch)
treeba98d97ca7ec7f8abc88f44845c691830b4b4e9e /drivers/usb/gadget/fsl_qe_udc.c
parent011b15df465745474e3ec85482633685933ed5a7 (diff)
USB: fsl_qe_udc: Check for muram allocation errors
The QE UDC doesn't check for cpm_muram_alloc() return values, this might cause all sorts of misbehaviour when cpm_muram_alloc() failed to allocate the muram memory. While at at, change few dev_dbg() calls to dev_err(), so that the driver would not die silently. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: Li Yang <leoli@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/fsl_qe_udc.c')
-rw-r--r--drivers/usb/gadget/fsl_qe_udc.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/usb/gadget/fsl_qe_udc.c b/drivers/usb/gadget/fsl_qe_udc.c
index f4027256509..d6c5bcd4006 100644
--- a/drivers/usb/gadget/fsl_qe_udc.c
+++ b/drivers/usb/gadget/fsl_qe_udc.c
@@ -26,6 +26,7 @@
26#include <linux/ioport.h> 26#include <linux/ioport.h>
27#include <linux/types.h> 27#include <linux/types.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
29#include <linux/err.h>
29#include <linux/slab.h> 30#include <linux/slab.h>
30#include <linux/list.h> 31#include <linux/list.h>
31#include <linux/interrupt.h> 32#include <linux/interrupt.h>
@@ -370,6 +371,9 @@ static int qe_ep_bd_init(struct qe_udc *udc, unsigned char pipe_num)
370 /* alloc multi-ram for BD rings and set the ep parameters */ 371 /* alloc multi-ram for BD rings and set the ep parameters */
371 tmp_addr = cpm_muram_alloc(sizeof(struct qe_bd) * (bdring_len + 372 tmp_addr = cpm_muram_alloc(sizeof(struct qe_bd) * (bdring_len +
372 USB_BDRING_LEN_TX), QE_ALIGNMENT_OF_BD); 373 USB_BDRING_LEN_TX), QE_ALIGNMENT_OF_BD);
374 if (IS_ERR_VALUE(tmp_addr))
375 return -ENOMEM;
376
373 out_be16(&epparam->rbase, (u16)tmp_addr); 377 out_be16(&epparam->rbase, (u16)tmp_addr);
374 out_be16(&epparam->tbase, (u16)(tmp_addr + 378 out_be16(&epparam->tbase, (u16)(tmp_addr +
375 (sizeof(struct qe_bd) * bdring_len))); 379 (sizeof(struct qe_bd) * bdring_len)));
@@ -689,7 +693,7 @@ en_done2:
689en_done1: 693en_done1:
690 spin_unlock_irqrestore(&udc->lock, flags); 694 spin_unlock_irqrestore(&udc->lock, flags);
691en_done: 695en_done:
692 dev_dbg(udc->dev, "failed to initialize %s\n", ep->ep.name); 696 dev_err(udc->dev, "failed to initialize %s\n", ep->ep.name);
693 return -ENODEV; 697 return -ENODEV;
694} 698}
695 699
@@ -2408,6 +2412,8 @@ static struct qe_udc __devinit *qe_udc_config(struct of_device *ofdev)
2408 tmp_addr = cpm_muram_alloc((USB_MAX_ENDPOINTS * 2412 tmp_addr = cpm_muram_alloc((USB_MAX_ENDPOINTS *
2409 sizeof(struct usb_ep_para)), 2413 sizeof(struct usb_ep_para)),
2410 USB_EP_PARA_ALIGNMENT); 2414 USB_EP_PARA_ALIGNMENT);
2415 if (IS_ERR_VALUE(tmp_addr))
2416 goto cleanup;
2411 2417
2412 for (i = 0; i < USB_MAX_ENDPOINTS; i++) { 2418 for (i = 0; i < USB_MAX_ENDPOINTS; i++) {
2413 out_be16(&usbpram->epptr[i], (u16)tmp_addr); 2419 out_be16(&usbpram->epptr[i], (u16)tmp_addr);
@@ -2513,7 +2519,7 @@ static int __devinit qe_udc_probe(struct of_device *ofdev,
2513 /* Initialize the udc structure including QH member and other member */ 2519 /* Initialize the udc structure including QH member and other member */
2514 udc_controller = qe_udc_config(ofdev); 2520 udc_controller = qe_udc_config(ofdev);
2515 if (!udc_controller) { 2521 if (!udc_controller) {
2516 dev_dbg(&ofdev->dev, "udc_controll is NULL\n"); 2522 dev_err(&ofdev->dev, "failed to initialize\n");
2517 return -ENOMEM; 2523 return -ENOMEM;
2518 } 2524 }
2519 2525
@@ -2568,7 +2574,7 @@ static int __devinit qe_udc_probe(struct of_device *ofdev,
2568 /* create a buf for ZLP send, need to remain zeroed */ 2574 /* create a buf for ZLP send, need to remain zeroed */
2569 udc_controller->nullbuf = kzalloc(256, GFP_KERNEL); 2575 udc_controller->nullbuf = kzalloc(256, GFP_KERNEL);
2570 if (udc_controller->nullbuf == NULL) { 2576 if (udc_controller->nullbuf == NULL) {
2571 dev_dbg(udc_controller->dev, "cannot alloc nullbuf\n"); 2577 dev_err(udc_controller->dev, "cannot alloc nullbuf\n");
2572 ret = -ENOMEM; 2578 ret = -ENOMEM;
2573 goto err3; 2579 goto err3;
2574 } 2580 }