]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
usb: isp1760: Decouple usb_hdc and isp1760_priv
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tue, 20 Jan 2015 22:55:54 +0000 (00:55 +0200)
committerFelipe Balbi <balbi@ti.com>
Tue, 27 Jan 2015 15:39:03 +0000 (09:39 -0600)
Allocate the driver private data structure manually instead of using the
usb_hcd private space. This will allow skipping hcd registration for the
isp1761 when used in device mode only.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/host/isp1760-hcd.c

index 2e38efe8d4d4b7266d9bea029dd02b589d4cf650..55c0add700b12405c65ca9a97b56eda67d757acd 100644 (file)
@@ -40,6 +40,8 @@ enum queue_head_types {
 };
 
 struct isp1760_hcd {
+       struct usb_hcd          *hcd;
+
        u32 hcs_params;
        spinlock_t              lock;
        struct slotinfo         atl_slots[32];
@@ -65,7 +67,7 @@ typedef void (packet_enqueue)(struct usb_hcd *hcd, struct isp1760_qh *qh,
 
 static inline struct isp1760_hcd *hcd_to_priv(struct usb_hcd *hcd)
 {
-       return (struct isp1760_hcd *) (hcd->hcd_priv);
+       return *(struct isp1760_hcd **)hcd->hcd_priv;
 }
 
 /* Section 2.2 Host Controller Capability Registers */
@@ -2161,7 +2163,7 @@ static void isp1760_clear_tt_buffer_complete(struct usb_hcd *hcd,
 static const struct hc_driver isp1760_hc_driver = {
        .description            = "isp1760-hcd",
        .product_desc           = "NXP ISP1760 USB Host Controller",
-       .hcd_priv_size          = sizeof(struct isp1760_hcd),
+       .hcd_priv_size          = sizeof(struct isp1760_hcd *),
        .irq                    = isp1760_irq,
        .flags                  = HCD_MEMORY | HCD_USB2,
        .reset                  = isp1760_hc_setup,
@@ -2214,13 +2216,17 @@ void isp1760_deinit_kmem_cache(void)
 int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
                     struct device *dev, unsigned int devflags)
 {
-       struct usb_hcd *hcd;
+       struct usb_hcd *hcd = NULL;
        struct isp1760_hcd *priv;
        int ret;
 
        if (usb_disabled())
                return -ENODEV;
 
+       priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+       if (!priv)
+               return -ENOMEM;
+
        /* prevent usb-core allocating DMA pages */
        dev->dma_mask = NULL;
 
@@ -2228,7 +2234,9 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
        if (!hcd)
                return -ENOMEM;
 
-       priv = hcd_to_priv(hcd);
+       priv->hcd = hcd;
+       *(struct isp1760_hcd **)hcd->hcd_priv = priv;
+
        priv->devflags = devflags;
 
        priv->rst_gpio = devm_gpiod_get_optional(dev, NULL, GPIOD_OUT_HIGH);
@@ -2253,7 +2261,7 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
                goto error;
        device_wakeup_enable(hcd->self.controller);
 
-       dev_set_drvdata(dev, hcd);
+       dev_set_drvdata(dev, priv);
 
        return 0;
 
@@ -2264,7 +2272,8 @@ error:
 
 void isp1760_unregister(struct device *dev)
 {
-       struct usb_hcd *hcd = dev_get_drvdata(dev);
+       struct isp1760_hcd *priv = dev_get_drvdata(dev);
+       struct usb_hcd *hcd = priv->hcd;
 
        usb_remove_hcd(hcd);
        usb_put_hcd(hcd);