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@xxxxxxxxxxxxxxxx> --- drivers/usb/host/isp1760-hcd.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/isp1760-hcd.c b/drivers/usb/host/isp1760-hcd.c index 2c10ad8..df715b6 100644 --- a/drivers/usb/host/isp1760-hcd.c +++ b/drivers/usb/host/isp1760-hcd.c @@ -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 */ @@ -2166,7 +2168,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, @@ -2219,21 +2221,29 @@ void isp1760_deinit_kmem_cache(void) int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, int rst_gpio, 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 = kzalloc(sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + /* prevent usb-core allocating DMA pages */ dev->dma_mask = NULL; hcd = usb_create_hcd(&isp1760_hc_driver, dev, dev_name(dev)); - if (!hcd) - return -ENOMEM; + if (!hcd) { + ret = -ENOMEM; + goto err_put; + } + + priv->hcd = hcd; + *(struct isp1760_hcd **)hcd->hcd_priv = priv; - priv = hcd_to_priv(hcd); priv->devflags = devflags; priv->rst_gpio = rst_gpio; init_memory(priv); @@ -2252,7 +2262,7 @@ int isp1760_register(struct resource *mem, int irq, unsigned long irqflags, goto err_unmap; device_wakeup_enable(hcd->self.controller); - dev_set_drvdata(dev, hcd); + dev_set_drvdata(dev, priv); return 0; @@ -2261,14 +2271,15 @@ err_unmap: err_put: usb_put_hcd(hcd); + kfree(priv); return ret; } void isp1760_unregister(struct device *dev) { - struct usb_hcd *hcd = dev_get_drvdata(dev); - struct isp1760_hcd *priv = hcd_to_priv(hcd); + struct isp1760_hcd *priv = dev_get_drvdata(dev); + struct usb_hcd *hcd = priv->hcd; release_mem_region(hcd->rsrc_start, hcd->rsrc_len); @@ -2278,6 +2289,8 @@ void isp1760_unregister(struct device *dev) if (gpio_is_valid(priv->rst_gpio)) gpio_free(priv->rst_gpio); + + kfree(priv); } MODULE_DESCRIPTION("Driver for the ISP1760 USB-controller from NXP"); -- 2.0.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html