usb: ohci: Move the td array struct to inside the ohci_dev struct
authorHans de Goede <hdegoede@redhat.com>
Tue, 5 May 2015 21:56:09 +0000 (23:56 +0200)
committerSimon Glass <sjg@chromium.org>
Wed, 6 May 2015 18:48:35 +0000 (12:48 -0600)
This is a preparation patch for adding driver-model support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Marek Vasut <marex@denx.de>
drivers/usb/host/ohci-hcd.c
drivers/usb/host/ohci.h

index 745825cd3206bc27824d327df19a81f418b4fd11..b5676ab05db680c112d3bc3db74e8d165b243f53 100644 (file)
@@ -447,7 +447,7 @@ int sohci_submit_job(ohci_t *ohci, ohci_dev_t *ohci_dev, urb_priv_t *urb,
        /* allocate the TDs */
        /* note that td[0] was allocated in ep_add_ed */
        for (i = 0; i < size; i++) {
-               purb_priv->td[i] = td_alloc(dev);
+               purb_priv->td[i] = td_alloc(ohci_dev, dev);
                if (!purb_priv->td[i]) {
                        purb_priv->length = i;
                        urb_free_priv(purb_priv);
@@ -760,7 +760,7 @@ static ed_t *ep_add_ed(ohci_dev_t *ohci_dev, struct usb_device *usb_dev,
 
        if (ed->state == ED_NEW) {
                /* dummy td; end of td list for ed */
-               td = td_alloc(usb_dev);
+               td = td_alloc(ohci_dev, usb_dev);
                ed->hwTailP = m32_swap((unsigned long)td);
                ed->hwHeadP = ed->hwTailP;
                ed->state = ED_UNLINK;
@@ -1762,12 +1762,6 @@ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller)
        }
        phcca = &ghcca[0];
        info("aligned ghcca %p", phcca);
-       memset(gtd, 0, sizeof(td_t) * (NUM_TD + 1));
-       if ((__u32)gtd & 0x7) {
-               err("TDs not aligned!!");
-               return -1;
-       }
-       ptd = gtd;
        gohci.hcca = phcca;
        memset(phcca, 0, sizeof(struct ohci_hcca));
 
index c3191641ce9f94c4da33bc283489360d5a2d72fa..96a0ac1ed44eb95efbc2b8c09d64702c188a7757 100644 (file)
@@ -410,8 +410,11 @@ typedef struct
 
 #define NUM_EDS 8              /* num of preallocated endpoint descriptors */
 
+#define NUM_TD 64              /* we need more TDs than EDs */
+
 typedef struct ohci_device {
        ed_t ed[NUM_EDS] __aligned(16);
+       td_t tds[NUM_TD] __aligned(32);
        int ed_cnt;
 } ohci_dev_t;
 
@@ -425,7 +428,7 @@ typedef struct ohci_device {
 
 typedef struct ohci {
        /* this allocates EDs for all possible endpoints */
-       struct ohci_device ohci_dev __aligned(16);
+       struct ohci_device ohci_dev __aligned(32);
        struct ohci_hcca *hcca;         /* hcca */
        /*dma_addr_t hcca_dma;*/
 
@@ -457,17 +460,9 @@ static ed_t *ep_add_ed(ohci_dev_t *ohci_dev, struct usb_device *usb_dev,
 
 /*-------------------------------------------------------------------------*/
 
-/* we need more TDs than EDs */
-#define NUM_TD 64
-
-/* +1 so we can align the storage */
-td_t gtd[NUM_TD+1];
-/* pointers to aligned storage */
-td_t *ptd;
-
 /* TDs ... */
 static inline struct td *
-td_alloc (struct usb_device *usb_dev)
+td_alloc (ohci_dev_t *ohci_dev, struct usb_device *usb_dev)
 {
        int i;
        struct td       *td;
@@ -475,9 +470,9 @@ td_alloc (struct usb_device *usb_dev)
        td = NULL;
        for (i = 0; i < NUM_TD; i++)
        {
-               if (ptd[i].usb_dev == NULL)
+               if (ohci_dev->tds[i].usb_dev == NULL)
                {
-                       td = &ptd[i];
+                       td = &ohci_dev->tds[i];
                        td->usb_dev = usb_dev;
                        break;
                }