usb: gadget: udc: make debug prints compatible with both pci and platform devices
authorRaviteja Garimella <raviteja.garimella@broadcom.com>
Wed, 10 May 2017 12:51:18 +0000 (18:21 +0530)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 13 Jun 2017 10:21:01 +0000 (13:21 +0300)
This patch adds a struct device member to UDC data structure and
makes changes to the arguments of dev_err and dev_dbg calls so that
the debug prints work for both pci and platform devices.

Signed-off-by: Raviteja Garimella <raviteja.garimella@broadcom.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/udc/amd5536udc.h
drivers/usb/gadget/udc/amd5536udc_pci.c
drivers/usb/gadget/udc/snps_udc_core.c

index fae49bf3833e603a8bb7e0a305d0655bea97a73e..91aae23b737055a24ecca60f2e8023645a5f2930 100644 (file)
@@ -563,6 +563,8 @@ struct udc {
        u16                             cur_config;
        u16                             cur_intf;
        u16                             cur_alt;
+
+       struct device                   *dev;
 };
 
 #define to_amd5536_udc(g)      (container_of((g), struct udc, gadget))
@@ -639,7 +641,7 @@ MODULE_PARM_DESC(use_fullspeed, "true for fullspeed only");
 
 /* debug macros ------------------------------------------------------------*/
 
-#define DBG(udc , args...)     dev_dbg(&(udc)->pdev->dev, args)
+#define DBG(udc , args...)     dev_dbg(udc->dev, args)
 
 #ifdef UDC_VERBOSE
 #define VDBG                   DBG
index 2a2d0a96fe246d4be570da05c228ea97528e86d3..57a13f080a791bbb8cd729301b1532e331246f0d 100644 (file)
@@ -168,6 +168,7 @@ static int udc_pci_probe(
        dev->phys_addr = resource;
        dev->irq = pdev->irq;
        dev->pdev = pdev;
+       dev->dev = &pdev->dev;
 
        /* general probing */
        if (udc_probe(dev)) {
index 4ecd2f20ea480082a5a3abf2f9a7f8e756e6c495..4c43ce2de4f48d975acafbff09314f759d9cc197 100644 (file)
@@ -209,18 +209,18 @@ static void print_regs(struct udc *dev)
        if (use_dma && use_dma_ppb && !use_dma_ppb_du) {
                DBG(dev, "DMA mode       = PPBNDU (packet per buffer "
                        "WITHOUT desc. update)\n");
-               dev_info(&dev->pdev->dev, "DMA mode (%s)\n", "PPBNDU");
+               dev_info(dev->dev, "DMA mode (%s)\n", "PPBNDU");
        } else if (use_dma && use_dma_ppb && use_dma_ppb_du) {
                DBG(dev, "DMA mode       = PPBDU (packet per buffer "
                        "WITH desc. update)\n");
-               dev_info(&dev->pdev->dev, "DMA mode (%s)\n", "PPBDU");
+               dev_info(dev->dev, "DMA mode (%s)\n", "PPBDU");
        }
        if (use_dma && use_dma_bufferfill_mode) {
                DBG(dev, "DMA mode       = BF (buffer fill mode)\n");
-               dev_info(&dev->pdev->dev, "DMA mode (%s)\n", "BF");
+               dev_info(dev->dev, "DMA mode (%s)\n", "BF");
        }
        if (!use_dma)
-               dev_info(&dev->pdev->dev, "FIFO mode\n");
+               dev_info(dev->dev, "FIFO mode\n");
        DBG(dev, "-------------------------------------------------------\n");
 }
 
@@ -1624,7 +1624,7 @@ static void udc_setup_endpoints(struct udc *dev)
 static void usb_connect(struct udc *dev)
 {
 
-       dev_info(&dev->pdev->dev, "USB Connect\n");
+       dev_info(dev->dev, "USB Connect\n");
 
        dev->connected = 1;
 
@@ -1642,7 +1642,7 @@ static void usb_connect(struct udc *dev)
 static void usb_disconnect(struct udc *dev)
 {
 
-       dev_info(&dev->pdev->dev, "USB Disconnect\n");
+       dev_info(dev->dev, "USB Disconnect\n");
 
        dev->connected = 0;
 
@@ -2106,7 +2106,7 @@ static irqreturn_t udc_data_out_isr(struct udc *dev, int ep_ix)
        }
        /* HE event ? */
        if (tmp & AMD_BIT(UDC_EPSTS_HE)) {
-               dev_err(&dev->pdev->dev, "HE ep%dout occurred\n", ep->num);
+               dev_err(dev->dev, "HE ep%dout occurred\n", ep->num);
 
                /* clear HE */
                writel(tmp | AMD_BIT(UDC_EPSTS_HE), &ep->regs->sts);
@@ -2305,7 +2305,7 @@ static irqreturn_t udc_data_in_isr(struct udc *dev, int ep_ix)
        if (use_dma) {
                /* BNA ? */
                if (epsts & AMD_BIT(UDC_EPSTS_BNA)) {
-                       dev_err(&dev->pdev->dev,
+                       dev_err(dev->dev,
                                "BNA ep%din occurred - DESPTR = %08lx\n",
                                ep->num,
                                (unsigned long) readl(&ep->regs->desptr));
@@ -2318,7 +2318,7 @@ static irqreturn_t udc_data_in_isr(struct udc *dev, int ep_ix)
        }
        /* HE event ? */
        if (epsts & AMD_BIT(UDC_EPSTS_HE)) {
-               dev_err(&dev->pdev->dev,
+               dev_err(dev->dev,
                        "HE ep%dn occurred - DESPTR = %08lx\n",
                        ep->num, (unsigned long) readl(&ep->regs->desptr));
 
@@ -2956,7 +2956,7 @@ __acquires(dev->lock)
 
                /* link up all endpoints */
                udc_setup_endpoints(dev);
-               dev_info(&dev->pdev->dev, "Connect: %s\n",
+               dev_info(dev->dev, "Connect: %s\n",
                         usb_speed_string(dev->gadget.speed));
 
                /* init ep 0 */
@@ -3168,20 +3168,20 @@ int udc_probe(struct udc *dev)
        /* init registers, interrupts, ... */
        startup_registers(dev);
 
-       dev_info(&dev->pdev->dev, "%s\n", mod_desc);
+       dev_info(dev->dev, "%s\n", mod_desc);
 
        snprintf(tmp, sizeof(tmp), "%d", dev->irq);
-       dev_info(&dev->pdev->dev,
+       dev_info(dev->dev,
                 "irq %s, pci mem %08lx, chip rev %02x(Geode5536 %s)\n",
                 tmp, dev->phys_addr, dev->chiprev,
                 (dev->chiprev == UDC_HSA0_REV) ? "A0" : "B1");
        strcpy(tmp, UDC_DRIVER_VERSION_STRING);
        if (dev->chiprev == UDC_HSA0_REV) {
-               dev_err(&dev->pdev->dev, "chip revision is A0; too old\n");
+               dev_err(dev->dev, "chip revision is A0; too old\n");
                retval = -ENODEV;
                goto finished;
        }
-       dev_info(&dev->pdev->dev,
+       dev_info(dev->dev,
                 "driver version: %s(for Geode5536 B1)\n", tmp);
        udc = dev;